babylon.js 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110
  1. !function(e, t) {
  2. "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("babylonjs", [], t) : "object" == typeof exports ? exports.babylonjs = t() : e.BABYLON = t()
  3. }("undefined" != typeof self ? self : "undefined" != typeof global ? global : this, (function() {
  4. return (()=>{
  5. "use strict";
  6. var e = {
  7. d: (t,i)=>{
  8. for (var n in i)
  9. e.o(i, n) && !e.o(t, n) && Object.defineProperty(t, n, {
  10. enumerable: !0,
  11. get: i[n]
  12. })
  13. }
  14. };
  15. e.g = function() {
  16. if ("object" == typeof globalThis)
  17. return globalThis;
  18. try {
  19. return this || new Function("return this")()
  20. } catch (e) {
  21. if ("object" == typeof window)
  22. return window
  23. }
  24. }(),
  25. e.o = (e,t)=>Object.prototype.hasOwnProperty.call(e, t),
  26. e.r = e=>{
  27. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
  28. value: "Module"
  29. }),
  30. Object.defineProperty(e, "__esModule", {
  31. value: !0
  32. })
  33. }
  34. ;
  35. var t = {};
  36. e.d(t, {
  37. default: ()=>XE
  38. });
  39. var i = {};
  40. e.r(i),
  41. e.d(i, {
  42. AxesViewer: ()=>xl,
  43. BoneAxesViewer: ()=>Rl,
  44. DebugLayer: ()=>Cl,
  45. DebugLayerTab: ()=>bl,
  46. DirectionalLightFrustumViewer: ()=>uc,
  47. PhysicsViewer: ()=>Wl,
  48. RayHelper: ()=>tc,
  49. SkeletonViewer: ()=>cc
  50. });
  51. var n = {};
  52. e.r(n),
  53. e.d(n, {
  54. AbstractActionManager: ()=>s,
  55. AbstractAssetTask: ()=>jb,
  56. AbstractMesh: ()=>Sr,
  57. AbstractScene: ()=>o,
  58. AcquireNativeObjectAsync: ()=>ru,
  59. Action: ()=>F,
  60. ActionEvent: ()=>w,
  61. ActionManager: ()=>_e,
  62. AddBlock: ()=>Hm,
  63. AddressMode: ()=>Tu,
  64. AdvancedTimer: ()=>Uf,
  65. AlphaState: ()=>Dt,
  66. AmmoJSPlugin: ()=>I_,
  67. AnaglyphArcRotateCamera: ()=>za,
  68. AnaglyphFreeCamera: ()=>Wa,
  69. AnaglyphGamepadCamera: ()=>Ha,
  70. AnaglyphPostProcess: ()=>ka,
  71. AnaglyphUniversalCamera: ()=>Xa,
  72. Analyser: ()=>Wr,
  73. AndOrNotEvaluator: ()=>ve,
  74. Angle: ()=>An,
  75. Animatable: ()=>bn,
  76. AnimatedInputBlockTypes: ()=>qp,
  77. Animation: ()=>Qe,
  78. AnimationEvent: ()=>zn,
  79. AnimationGroup: ()=>Hn,
  80. AnimationKeyInterpolation: ()=>ke,
  81. AnimationPropertiesOverride: ()=>En,
  82. AnimationRange: ()=>We,
  83. AnisotropyBlock: ()=>Og,
  84. ApplyPostProcess: ()=>Ic,
  85. Arc2: ()=>xn,
  86. ArcFollowCamera: ()=>Ea,
  87. ArcRotateCamera: ()=>_a,
  88. ArcRotateCameraGamepadInput: ()=>Ho,
  89. ArcRotateCameraInputsManager: ()=>Ko,
  90. ArcRotateCameraKeyboardMoveInput: ()=>Xo,
  91. ArcRotateCameraMouseWheelInput: ()=>jo,
  92. ArcRotateCameraPointersInput: ()=>Yo,
  93. ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
  94. ArcTan2Block: ()=>pg,
  95. AssetContainer: ()=>zr,
  96. AssetTaskState: ()=>Wb,
  97. AssetsManager: ()=>nT,
  98. AssetsProgressEvent: ()=>Yb,
  99. AsyncLoop: ()=>yi,
  100. AttachToBoxBehavior: ()=>po,
  101. AudioEngine: ()=>Hr,
  102. AudioSceneComponent: ()=>Yr,
  103. AutoReleaseWorkerPool: ()=>vp,
  104. AutoRotationBehavior: ()=>lo,
  105. AxesViewer: ()=>xl,
  106. Axis: ()=>vn,
  107. AxisDragGizmo: ()=>Al,
  108. AxisScaleGizmo: ()=>fd,
  109. BRDFTextureTools: ()=>Xd,
  110. BabylonFileLoaderConfiguration: ()=>N_,
  111. BackEase: ()=>On,
  112. BackgroundMaterial: ()=>Vd,
  113. BakedVertexAnimationManager: ()=>Qr,
  114. BaseCameraMouseWheelInput: ()=>Bo,
  115. BaseCameraPointersInput: ()=>Uo,
  116. BaseError: ()=>dt,
  117. BaseParticleSystem: ()=>Tf,
  118. BaseSixDofDragBehavior: ()=>Ro,
  119. BaseTexture: ()=>Zr,
  120. BasisTools: ()=>um,
  121. BasisToolsOptions: ()=>nm,
  122. BasisTranscodeConfiguration: ()=>im,
  123. BezierCurve: ()=>Sn,
  124. BezierCurveEase: ()=>Gn,
  125. BinaryFileAssetTask: ()=>Zb,
  126. BlackAndWhitePostProcess: ()=>Uy,
  127. BlendFactor: ()=>Lu,
  128. BlendOperation: ()=>Fu,
  129. BloomEffect: ()=>zy,
  130. BloomMergePostProcess: ()=>Gy,
  131. BlurPostProcess: ()=>Fd,
  132. Bone: ()=>yn,
  133. BoneAxesViewer: ()=>Rl,
  134. BoneIKController: ()=>No,
  135. BoneLookController: ()=>Lo,
  136. BonesBlock: ()=>Em,
  137. BounceEase: ()=>Dn,
  138. BouncingBehavior: ()=>co,
  139. BoundingBox: ()=>tr,
  140. BoundingBoxGizmo: ()=>_d,
  141. BoundingBoxRenderer: ()=>Ab,
  142. BoundingInfo: ()=>sr,
  143. BoundingSphere: ()=>ir,
  144. BoxBuilder: ()=>Il,
  145. BoxParticleEmitter: ()=>hf,
  146. Buffer: ()=>wi,
  147. BufferBindingType: ()=>xu,
  148. BufferUsage: ()=>fu,
  149. CSG: ()=>cv,
  150. Camera: ()=>Rr,
  151. CameraGizmo: ()=>Ld,
  152. CameraInputTypes: ()=>Vo,
  153. CameraInputsManager: ()=>ko,
  154. CannonJSPlugin: ()=>P_,
  155. CanvasCompositingAlphaMode: ()=>Xu,
  156. CapsuleBuilder: ()=>zl,
  157. CascadedShadowGenerator: ()=>p_,
  158. ChromaticAberrationPostProcess: ()=>Wy,
  159. CircleEase: ()=>In,
  160. CircleOfConfusionPostProcess: ()=>Hy,
  161. ClampBlock: ()=>jm,
  162. ClearCoatBlock: ()=>Ng,
  163. ClipPlanesBlock: ()=>Wm,
  164. ClipboardEventTypes: ()=>nd,
  165. ClipboardInfo: ()=>rd,
  166. CloudBlock: ()=>zg,
  167. CloudPoint: ()=>Ay,
  168. Collider: ()=>pl,
  169. Color3: ()=>D,
  170. Color3Gradient: ()=>cy,
  171. Color4: ()=>N,
  172. ColorCorrectionPostProcess: ()=>Xy,
  173. ColorCurves: ()=>Ai,
  174. ColorGradient: ()=>ly,
  175. ColorGradingTexture: ()=>Y_,
  176. ColorMergerBlock: ()=>Zm,
  177. ColorSplitterBlock: ()=>Ef,
  178. ColorWrite: ()=>Nu,
  179. CombineAction: ()=>ie,
  180. CompareFunction: ()=>Su,
  181. CompatibilityOptions: ()=>pr,
  182. CompilationMessageType: ()=>Mu,
  183. ComputeBindingType: ()=>_l,
  184. ComputeEffect: ()=>ml,
  185. ComputePassTimestampLocation: ()=>ku,
  186. ComputePressureObserverWrapper: ()=>_n,
  187. ComputeShader: ()=>gl,
  188. ComputeShaderParticleSystem: ()=>ay,
  189. Condition: ()=>H,
  190. ConditionalBlock: ()=>Gg,
  191. ConditionalBlockConditions: ()=>Vg,
  192. ConeParticleEmitter: ()=>df,
  193. Constants: ()=>a,
  194. ContainerAssetTask: ()=>Kb,
  195. ConvolutionPostProcess: ()=>jy,
  196. Coordinate: ()=>gn,
  197. CopyTools: ()=>to,
  198. CreateBox: ()=>Ml,
  199. CreateBoxVertexData: ()=>Pl,
  200. CreateCapsule: ()=>Gl,
  201. CreateCapsuleVertexData: ()=>kl,
  202. CreateCylinder: ()=>Ys,
  203. CreateCylinderVertexData: ()=>js,
  204. CreateDashedLines: ()=>$l,
  205. CreateDashedLinesVertexData: ()=>ql,
  206. CreateDecal: ()=>wv,
  207. CreateDisc: ()=>Pd,
  208. CreateEnvTextureAsync: ()=>Gc,
  209. CreateGeodesic: ()=>zv,
  210. CreateGoldberg: ()=>Hv,
  211. CreateGoldbergVertexData: ()=>Wv,
  212. CreateGround: ()=>il,
  213. CreateGroundFromHeightMap: ()=>rl,
  214. CreateGroundFromHeightMapVertexData: ()=>tl,
  215. CreateGroundVertexData: ()=>$s,
  216. CreateHemisphere: ()=>Id,
  217. CreateIcoSphere: ()=>Lv,
  218. CreateIcoSphereVertexData: ()=>Nv,
  219. CreateImageDataArrayBufferViews: ()=>Wc,
  220. CreateLathe: ()=>Mv,
  221. CreateLineSystem: ()=>Zl,
  222. CreateLineSystemVertexData: ()=>Ql,
  223. CreateLines: ()=>Jl,
  224. CreatePlane: ()=>vo,
  225. CreatePlaneVertexData: ()=>go,
  226. CreatePolygon: ()=>Rv,
  227. CreatePolygonVertexData: ()=>xv,
  228. CreatePolyhedron: ()=>Td,
  229. CreatePolyhedronVertexData: ()=>bd,
  230. CreateResizedCopy: ()=>Mc,
  231. CreateRibbon: ()=>nc,
  232. CreateRibbonVertexData: ()=>ic,
  233. CreateScreenshot: ()=>AT,
  234. CreateScreenshotAsync: ()=>xT,
  235. CreateScreenshotUsingRenderTarget: ()=>CT,
  236. CreateScreenshotUsingRenderTargetAsync: ()=>PT,
  237. CreateScreenshotWithResizeAsync: ()=>RT,
  238. CreateSphere: ()=>Dl,
  239. CreateSphereVertexData: ()=>Ol,
  240. CreateTiledBox: ()=>mv,
  241. CreateTiledBoxVertexData: ()=>_v,
  242. CreateTiledGround: ()=>nl,
  243. CreateTiledGroundVertexData: ()=>el,
  244. CreateTiledPlane: ()=>pv,
  245. CreateTiledPlaneVertexData: ()=>dv,
  246. CreateTorus: ()=>qs,
  247. CreateTorusKnot: ()=>yv,
  248. CreateTorusKnotVertexData: ()=>vv,
  249. CreateTorusVertexData: ()=>Qs,
  250. CreateTube: ()=>Ov,
  251. CrossBlock: ()=>Ym,
  252. CubeMapToSphericalPolynomialTools: ()=>wc,
  253. CubeTexture: ()=>Bd,
  254. CubeTextureAssetTask: ()=>eT,
  255. CubicEase: ()=>Nn,
  256. CullMode: ()=>Du,
  257. CurrentScreenBlock: ()=>nf,
  258. Curve3: ()=>Pn,
  259. CustomBlock: ()=>Km,
  260. CustomOptimization: ()=>pT,
  261. CustomParticleEmitter: ()=>yf,
  262. CustomProceduralTexture: ()=>mm,
  263. CylinderBuilder: ()=>Ks,
  264. CylinderDirectedParticleEmitter: ()=>ff,
  265. CylinderParticleEmitter: ()=>pf,
  266. DDSTools: ()=>pp,
  267. DataBuffer: ()=>Bt,
  268. DataReader: ()=>NT,
  269. DataStorage: ()=>LT,
  270. Database: ()=>ny,
  271. DaydreamController: ()=>ad,
  272. DebugLayer: ()=>Cl,
  273. DebugLayerTab: ()=>bl,
  274. DecalBuilder: ()=>Bv,
  275. Decode: ()=>se,
  276. DecodeBase64ToBinary: ()=>ue,
  277. DecodeBase64ToString: ()=>ce,
  278. DecodeBase64UrlToBinary: ()=>oi,
  279. DecodeBase64UrlToString: ()=>si,
  280. DeepCopier: ()=>fe,
  281. DefaultCollisionCoordinator: ()=>fl,
  282. DefaultLoadingScreen: ()=>m_,
  283. DefaultRenderingPipeline: ()=>db,
  284. Deferred: ()=>rT,
  285. DepthCullingState: ()=>It,
  286. DepthOfFieldBlurPostProcess: ()=>Yy,
  287. DepthOfFieldEffect: ()=>Zy,
  288. DepthOfFieldEffectBlurLevel: ()=>Ky,
  289. DepthOfFieldMergePostProcess: ()=>qy,
  290. DepthOfFieldMergePostProcessOptions: ()=>Qy,
  291. DepthPeelingRenderer: ()=>Cb,
  292. DepthPeelingSceneComponent: ()=>Pb,
  293. DepthReducer: ()=>s_,
  294. DepthRenderer: ()=>o_,
  295. DepthRendererSceneComponent: ()=>xb,
  296. DepthSortedParticle: ()=>Ty,
  297. DerivativeBlock: ()=>Im,
  298. DesaturateBlock: ()=>Mg,
  299. DetailMapConfiguration: ()=>Ps,
  300. DeviceInputEventType: ()=>Li,
  301. DeviceLostReason: ()=>ju,
  302. DeviceOrientationCamera: ()=>ma,
  303. DeviceSource: ()=>on,
  304. DeviceSourceManager: ()=>sn,
  305. DeviceType: ()=>Ci,
  306. DirectionalLight: ()=>Rd,
  307. DirectionalLightFrustumViewer: ()=>uc,
  308. DiscBuilder: ()=>Md,
  309. DiscardBlock: ()=>Pm,
  310. DisplayPassPostProcess: ()=>Jy,
  311. DistanceBlock: ()=>lg,
  312. DistanceJoint: ()=>Fl,
  313. DivideBlock: ()=>eg,
  314. DoNothingAction: ()=>te,
  315. DomManagement: ()=>lt,
  316. DotBlock: ()=>Qm,
  317. DracoCompression: ()=>iv,
  318. DrawWrapper: ()=>Gt,
  319. DualSenseInput: ()=>Oi,
  320. DualShockButton: ()=>Ca,
  321. DualShockDpad: ()=>Pa,
  322. DualShockInput: ()=>Ii,
  323. DualShockPad: ()=>Ia,
  324. DynamicFloat32Array: ()=>zT,
  325. DynamicTexture: ()=>Ds,
  326. EasingFunction: ()=>Mn,
  327. EdgesRenderer: ()=>Ib,
  328. Effect: ()=>Mt,
  329. EffectFallbacks: ()=>ys,
  330. EffectLayer: ()=>Kf,
  331. EffectLayerSceneComponent: ()=>Qf,
  332. EffectRenderer: ()=>y_,
  333. EffectWrapper: ()=>b_,
  334. ElasticEase: ()=>Ln,
  335. ElbowBlock: ()=>Hg,
  336. EncodeArrayBufferToBase64: ()=>le,
  337. EndsWith: ()=>oe,
  338. Engine: ()=>vr,
  339. EngineFactory: ()=>id,
  340. EngineInstrumentation: ()=>jf,
  341. EngineStore: ()=>E,
  342. EngineView: ()=>mc,
  343. EnvironmentHelper: ()=>kd,
  344. EnvironmentTextureTools: ()=>Qc,
  345. Epsilon: ()=>m,
  346. EquiRectangularCubeTexture: ()=>K_,
  347. EquiRectangularCubeTextureAssetTask: ()=>iT,
  348. ErrorCodes: ()=>pt,
  349. ErrorFilter: ()=>Yu,
  350. EventConstants: ()=>$i,
  351. EventState: ()=>l,
  352. ExecuteCodeAction: ()=>ne,
  353. ExponentialEase: ()=>Fn,
  354. ExternalTexture: ()=>Mh,
  355. ExtractHighlightsPostProcess: ()=>ky,
  356. ExtrudePolygon: ()=>Cv,
  357. ExtrudeShape: ()=>oc,
  358. ExtrudeShapeCustom: ()=>ac,
  359. FactorGradient: ()=>uy,
  360. FadeInOutBehavior: ()=>fo,
  361. FeatureName: ()=>pu,
  362. FileTools: ()=>ai,
  363. FileToolsOptions: ()=>qt,
  364. FilesInput: ()=>aT,
  365. FilesInputStore: ()=>ut,
  366. FilterMode: ()=>Eu,
  367. FilterPostProcess: ()=>$y,
  368. FlyCamera: ()=>va,
  369. FlyCameraInputsManager: ()=>ga,
  370. FlyCameraKeyboardInput: ()=>qo,
  371. FlyCameraMouseInput: ()=>Zo,
  372. FogBlock: ()=>Fm,
  373. FollowBehavior: ()=>Mo,
  374. FollowCamera: ()=>Ta,
  375. FollowCameraInputsManager: ()=>ya,
  376. FollowCameraKeyboardMoveInput: ()=>Jo,
  377. FollowCameraMouseWheelInput: ()=>$o,
  378. FollowCameraPointersInput: ()=>ea,
  379. FragCoordBlock: ()=>Om,
  380. FragmentOutputBlock: ()=>Zp,
  381. FramingBehavior: ()=>uo,
  382. FreeCamera: ()=>pa,
  383. FreeCameraDeviceOrientationInput: ()=>sa,
  384. FreeCameraGamepadInput: ()=>ca,
  385. FreeCameraInputsManager: ()=>aa,
  386. FreeCameraKeyboardMoveInput: ()=>ta,
  387. FreeCameraMouseInput: ()=>na,
  388. FreeCameraMouseWheelInput: ()=>ra,
  389. FreeCameraTouchInput: ()=>oa,
  390. FreeCameraVirtualJoystickInput: ()=>ha,
  391. FresnelBlock: ()=>og,
  392. FresnelParameters: ()=>z_,
  393. FromHalfFloat: ()=>Dc,
  394. FrontFace: ()=>Ou,
  395. FrontFacingBlock: ()=>Mm,
  396. Frustum: ()=>dn,
  397. FxaaPostProcess: ()=>eb,
  398. GPUParticleSystem: ()=>_y,
  399. GUID: ()=>_i,
  400. Gamepad: ()=>zo,
  401. GamepadCamera: ()=>La,
  402. GamepadManager: ()=>Oa,
  403. GamepadSystemSceneComponent: ()=>Da,
  404. GearVRController: ()=>sd,
  405. GenerateBase64StringFromPixelData: ()=>Jr,
  406. GenerateBase64StringFromTexture: ()=>$r,
  407. GenerateBase64StringFromTextureAsync: ()=>eo,
  408. GenericController: ()=>ld,
  409. GenericPad: ()=>Wo,
  410. GeodesicData: ()=>Gv,
  411. Geometry: ()=>fr,
  412. GeometryBufferRenderer: ()=>nb,
  413. GeometryBufferRendererSceneComponent: ()=>ob,
  414. GetClass: ()=>b,
  415. GetDOMTextContent: ()=>at,
  416. GetEnvInfo: ()=>Vc,
  417. GetEnvironmentBRDFTexture: ()=>Hd,
  418. GetInternalFormatFromBasisFormat: ()=>rm,
  419. GetTGAHeader: ()=>q_,
  420. Gizmo: ()=>Sl,
  421. GizmoManager: ()=>Ad,
  422. GlowLayer: ()=>qf,
  423. GoldbergMesh: ()=>uv,
  424. GradientBlock: ()=>Tg,
  425. GradientBlockColorStep: ()=>bg,
  426. GradientHelper: ()=>hy,
  427. GrainPostProcess: ()=>tb,
  428. GroundBuilder: ()=>ol,
  429. GroundMesh: ()=>Js,
  430. HDRCubeTexture: ()=>E_,
  431. HDRCubeTextureAssetTask: ()=>tT,
  432. HDRFiltering: ()=>T_,
  433. HDRTools: ()=>v_,
  434. HandConstraintBehavior: ()=>Do,
  435. HandConstraintOrientation: ()=>Eo,
  436. HandConstraintVisibility: ()=>So,
  437. HandConstraintZone: ()=>To,
  438. HardwareScalingOptimization: ()=>cT,
  439. HemisphereBuilder: ()=>Od,
  440. HemisphericLight: ()=>ds,
  441. HemisphericParticleEmitter: ()=>_f,
  442. HighlightLayer: ()=>Jf,
  443. HighlightsPostProcess: ()=>ib,
  444. Hinge2Joint: ()=>Ul,
  445. HingeJoint: ()=>Bl,
  446. HtmlElementTexture: ()=>Q_,
  447. IWebXRControllerPhysicsOptions: ()=>nE,
  448. IcoSphereBuilder: ()=>Fv,
  449. ImageAssetTask: ()=>Jb,
  450. ImageProcessingBlock: ()=>Rm,
  451. ImageProcessingConfiguration: ()=>Ri,
  452. ImageProcessingConfigurationDefines: ()=>xi,
  453. ImageProcessingPostProcess: ()=>Fs,
  454. ImageSourceBlock: ()=>Um,
  455. IncrementValueAction: ()=>J,
  456. IndexFormat: ()=>Bu,
  457. InputBlock: ()=>tf,
  458. InputStepMode: ()=>Vu,
  459. InspectableType: ()=>IT,
  460. InstancedLinesMesh: ()=>Kl,
  461. InstancedMesh: ()=>Hl,
  462. InstancesBlock: ()=>Sm,
  463. InstantiatedEntries: ()=>Gr,
  464. InternalTexture: ()=>Lt,
  465. InternalTextureSource: ()=>At,
  466. InterpolateValueAction: ()=>qe,
  467. IntersectionInfo: ()=>er,
  468. IsBase64DataUrl: ()=>ri,
  469. IsDocumentAvailable: ()=>ot,
  470. IsFileURL: ()=>ni,
  471. IsNavigatorAvailable: ()=>rt,
  472. IsWindowObjectExist: ()=>nt,
  473. JoystickAxis: ()=>la,
  474. KeepAssets: ()=>kr,
  475. KeyboardEventTypes: ()=>Qi,
  476. KeyboardInfo: ()=>qi,
  477. KeyboardInfoPre: ()=>Zi,
  478. KhronosTextureContainer: ()=>mp,
  479. KhronosTextureContainer2: ()=>yp,
  480. LatheBuilder: ()=>Iv,
  481. Layer: ()=>e_,
  482. LayerSceneComponent: ()=>$f,
  483. LengthBlock: ()=>cg,
  484. LensFlare: ()=>t_,
  485. LensFlareSystem: ()=>i_,
  486. LensFlareSystemSceneComponent: ()=>n_,
  487. LensFlaresOptimization: ()=>dT,
  488. LensRenderingPipeline: ()=>pb,
  489. LerpBlock: ()=>$m,
  490. Light: ()=>Cr,
  491. LightBlock: ()=>wm,
  492. LightGizmo: ()=>Nd,
  493. LightInformationBlock: ()=>xm,
  494. LineEdgesRenderer: ()=>Ob,
  495. LinesBuilder: ()=>ec,
  496. LinesMesh: ()=>Yl,
  497. LoadFile: ()=>ti,
  498. LoadFileError: ()=>Yt,
  499. LoadImage: ()=>$t,
  500. LoadOp: ()=>zu,
  501. LoadTextureFromTranscodeResult: ()=>cm,
  502. Logger: ()=>K,
  503. MapMode: ()=>_u,
  504. Material: ()=>Or,
  505. MaterialAnisotropicDefines: ()=>qd,
  506. MaterialClearCoatDefines: ()=>Kd,
  507. MaterialDefines: ()=>Si,
  508. MaterialDetailMapDefines: ()=>Cs,
  509. MaterialFlags: ()=>vs,
  510. MaterialHelper: ()=>Mr,
  511. MaterialPluginBase: ()=>Rs,
  512. MaterialPluginManager: ()=>bs,
  513. MaterialSheenDefines: ()=>Jd,
  514. MaterialSubSurfaceDefines: ()=>ep,
  515. Matrix: ()=>P,
  516. MatrixBuilderBlock: ()=>kg,
  517. MaxBlock: ()=>ag,
  518. MergeMeshesOptimization: ()=>mT,
  519. Mesh: ()=>Vr,
  520. MeshAssetTask: ()=>Qb,
  521. MeshBuilder: ()=>jv,
  522. MeshExploder: ()=>oT,
  523. MeshLODLevel: ()=>Nr,
  524. MeshParticleEmitter: ()=>bf,
  525. MeshoptCompression: ()=>nv,
  526. MinBlock: ()=>sg,
  527. MinMaxReducer: ()=>a_,
  528. MirrorTexture: ()=>wd,
  529. ModBlock: ()=>Ug,
  530. ModelShape: ()=>by,
  531. MorphTarget: ()=>S_,
  532. MorphTargetManager: ()=>x_,
  533. MorphTargetsBlock: ()=>Am,
  534. MotionBlurPostProcess: ()=>ab,
  535. MotorEnabledJoint: ()=>wl,
  536. MultiMaterial: ()=>Dr,
  537. MultiObserver: ()=>u,
  538. MultiPointerScaleBehavior: ()=>xo,
  539. MultiRenderTarget: ()=>pm,
  540. MultiplyBlock: ()=>uf,
  541. NLerpBlock: ()=>Eg,
  542. NativeDataStream: ()=>bc,
  543. NativeEngine: ()=>uu,
  544. NativePointerInput: ()=>Mi,
  545. NativeXRFrame: ()=>VE,
  546. NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
  547. NativeXRLayerWrapper: ()=>zs,
  548. NativeXRRenderTarget: ()=>Hs,
  549. NegateBlock: ()=>ug,
  550. Node: ()=>Xe,
  551. NodeMaterial: ()=>Of,
  552. NodeMaterialBlock: ()=>Wp,
  553. NodeMaterialBlockConnectionPointMode: ()=>Kp,
  554. NodeMaterialBlockConnectionPointTypes: ()=>Op,
  555. NodeMaterialBlockTargets: ()=>Dp,
  556. NodeMaterialConnectionPoint: ()=>zp,
  557. NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
  558. NodeMaterialConnectionPointDirection: ()=>Vp,
  559. NodeMaterialDefines: ()=>If,
  560. NodeMaterialModes: ()=>cf,
  561. NodeMaterialOptimizer: ()=>Xg,
  562. NodeMaterialSystemValues: ()=>Qp,
  563. NoiseProceduralTexture: ()=>gm,
  564. NormalBlendBlock: ()=>xg,
  565. NormalizeBlock: ()=>qm,
  566. NullEngine: ()=>dc,
  567. NullEngineOptions: ()=>hc,
  568. Observable: ()=>h,
  569. Observer: ()=>c,
  570. OcclusionMaterial: ()=>W_,
  571. Octree: ()=>yl,
  572. OctreeBlock: ()=>vl,
  573. OctreeSceneComponent: ()=>Tl,
  574. OculusTouchController: ()=>cd,
  575. OimoJSPlugin: ()=>M_,
  576. OnAfterEnteringVRObservableEvent: ()=>ul,
  577. OneMinusBlock: ()=>ng,
  578. Orientation: ()=>Tn,
  579. OutlineRenderer: ()=>Ub,
  580. PBRAnisotropicConfiguration: ()=>Zd,
  581. PBRBaseMaterial: ()=>rp,
  582. PBRBaseSimpleMaterial: ()=>H_,
  583. PBRClearCoatConfiguration: ()=>Qd,
  584. PBRMaterial: ()=>op,
  585. PBRMaterialDefines: ()=>np,
  586. PBRMetallicRoughnessBlock: ()=>Bg,
  587. PBRMetallicRoughnessMaterial: ()=>X_,
  588. PBRSheenConfiguration: ()=>$d,
  589. PBRSpecularGlossinessMaterial: ()=>j_,
  590. PBRSubSurfaceConfiguration: ()=>tp,
  591. PHI: ()=>_,
  592. PadNumber: ()=>he,
  593. PanoramaToCubeMapTools: ()=>g_,
  594. Particle: ()=>dy,
  595. ParticleBlendMultiplyBlock: ()=>af,
  596. ParticleHelper: ()=>gy,
  597. ParticleRampGradientBlock: ()=>of,
  598. ParticleSystem: ()=>fy,
  599. ParticleSystemSet: ()=>my,
  600. ParticleTextureBlock: ()=>rf,
  601. ParticlesOptimization: ()=>fT,
  602. PassCubePostProcess: ()=>Va,
  603. PassPostProcess: ()=>Ua,
  604. Path2: ()=>Rn,
  605. Path3D: ()=>Cn,
  606. PathCursor: ()=>Xn,
  607. PerfCollectionStrategy: ()=>qT,
  608. PerfCounter: ()=>un,
  609. PerformanceConfigurator: ()=>T,
  610. PerformanceMonitor: ()=>_r,
  611. PerformanceViewerCollector: ()=>KT,
  612. PerturbNormalBlock: ()=>Cm,
  613. PhotoDome: ()=>zd,
  614. PhysicsEngine: ()=>R_,
  615. PhysicsEngineSceneComponent: ()=>My,
  616. PhysicsHelper: ()=>Iy,
  617. PhysicsImpostor: ()=>Vl,
  618. PhysicsJoint: ()=>Ll,
  619. PhysicsRadialExplosionEventOptions: ()=>Fy,
  620. PhysicsRadialImpulseFalloff: ()=>Cy,
  621. PhysicsUpdraftEventOptions: ()=>wy,
  622. PhysicsUpdraftMode: ()=>Py,
  623. PhysicsViewer: ()=>Wl,
  624. PhysicsVortexEventOptions: ()=>By,
  625. PickingInfo: ()=>Ui,
  626. PivotTools: ()=>mo,
  627. Plane: ()=>hn,
  628. PlaneBuilder: ()=>yo,
  629. PlaneDragGizmo: ()=>vd,
  630. PlaneRotationGizmo: ()=>md,
  631. PlayAnimationAction: ()=>$,
  632. PlaySoundAction: ()=>me,
  633. PointColor: ()=>vy,
  634. PointLight: ()=>__,
  635. PointParticleEmitter: ()=>mf,
  636. PointerDragBehavior: ()=>Ao,
  637. PointerEventTypes: ()=>Xi,
  638. PointerInfo: ()=>Ki,
  639. PointerInfoBase: ()=>ji,
  640. PointerInfoPre: ()=>Yi,
  641. PointerInput: ()=>Pi,
  642. PointsCloudSystem: ()=>Ry,
  643. PointsGroup: ()=>xy,
  644. Polygon: ()=>Sv,
  645. PolygonBuilder: ()=>Pv,
  646. PolygonMeshBuilder: ()=>Av,
  647. PolyhedronBuilder: ()=>Ed,
  648. PolyhedronData: ()=>kv,
  649. PoseEnabledController: ()=>Ra,
  650. PoseEnabledControllerHelper: ()=>xa,
  651. PoseEnabledControllerType: ()=>ba,
  652. PositionGizmo: ()=>yd,
  653. PositionNormalTextureVertex: ()=>Ec,
  654. PositionNormalVertex: ()=>Tc,
  655. PostProcess: ()=>Ba,
  656. PostProcessManager: ()=>Vi,
  657. PostProcessRenderEffect: ()=>Vy,
  658. PostProcessRenderPipeline: ()=>cb,
  659. PostProcessRenderPipelineManager: ()=>ub,
  660. PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
  661. PostProcessesOptimization: ()=>hT,
  662. PosterizeBlock: ()=>vg,
  663. PowBlock: ()=>hg,
  664. PowerEase: ()=>wn,
  665. PowerPreference: ()=>du,
  666. PrePassRenderer: ()=>Nb,
  667. PrePassRendererSceneComponent: ()=>Lb,
  668. PrecisionDate: ()=>ct,
  669. PredefinedColorSpace: ()=>hu,
  670. PredicateCondition: ()=>j,
  671. PrimitiveTopology: ()=>Iu,
  672. ProceduralTexture: ()=>xf,
  673. ProceduralTextureSceneComponent: ()=>Sf,
  674. PromisePolyfill: ()=>di,
  675. PropertyTypeForEdition: ()=>Xp,
  676. PushMaterial: ()=>gs,
  677. QuadraticEase: ()=>Bn,
  678. QuadraticErrorSimplification: ()=>$v,
  679. QuarticEase: ()=>Un,
  680. Quaternion: ()=>C,
  681. QueryType: ()=>Hu,
  682. QuinticEase: ()=>Vn,
  683. RGBDTextureTools: ()=>Lc,
  684. RandomGUID: ()=>fi,
  685. RandomNumberBlock: ()=>dg,
  686. RawCubeTexture: ()=>vm,
  687. RawTexture: ()=>ao,
  688. RawTexture2DArray: ()=>A_,
  689. RawTexture3D: ()=>ym,
  690. Ray: ()=>_o,
  691. RayHelper: ()=>tc,
  692. ReadFile: ()=>ei,
  693. ReadFileError: ()=>Qt,
  694. RecastJSCrowd: ()=>iy,
  695. RecastJSPlugin: ()=>ty,
  696. ReciprocalBlock: ()=>_g,
  697. ReflectBlock: ()=>Cg,
  698. ReflectionBlock: ()=>Dg,
  699. ReflectionProbe: ()=>O_,
  700. ReflectionTextureBlock: ()=>Gm,
  701. Reflector: ()=>GT,
  702. RefractBlock: ()=>Pg,
  703. RefractionBlock: ()=>Lg,
  704. RefractionPostProcess: ()=>sb,
  705. RefractionTexture: ()=>bm,
  706. RegisterClass: ()=>y,
  707. RegisterMaterialPlugin: ()=>Ss,
  708. RegisterNativeTypeAsync: ()=>ou,
  709. RemapBlock: ()=>lf,
  710. RenderPassTimestampLocation: ()=>Gu,
  711. RenderTargetTexture: ()=>ns,
  712. RenderTargetWrapper: ()=>Fa,
  713. RenderTargetsOptimization: ()=>_T,
  714. RenderingGroup: ()=>ki,
  715. RenderingGroupInfo: ()=>Gi,
  716. RenderingManager: ()=>zi,
  717. ReplaceColorBlock: ()=>mg,
  718. RequestFile: ()=>ii,
  719. RequestFileError: ()=>Kt,
  720. RetryStrategy: ()=>ht,
  721. RibbonBuilder: ()=>rc,
  722. RollingAverage: ()=>mr,
  723. Rotate2dBlock: ()=>Rg,
  724. RotationGizmo: ()=>gd,
  725. RuntimeAnimation: ()=>it,
  726. RuntimeError: ()=>ft,
  727. SSAO2RenderingPipeline: ()=>_b,
  728. SSAORenderingPipeline: ()=>mb,
  729. SamplerBindingType: ()=>Ru,
  730. Scalar: ()=>d,
  731. ScaleBlock: ()=>Xm,
  732. ScaleGizmo: ()=>Sd,
  733. Scene: ()=>mn,
  734. SceneComponentConstants: ()=>Wi,
  735. SceneDepthBlock: ()=>zm,
  736. SceneInstrumentation: ()=>Yf,
  737. SceneLoader: ()=>od,
  738. SceneLoaderAnimationGroupLoadingMode: ()=>td,
  739. SceneLoaderFlags: ()=>dr,
  740. SceneOptimization: ()=>sT,
  741. SceneOptimizer: ()=>vT,
  742. SceneOptimizerOptions: ()=>gT,
  743. SceneRecorder: ()=>FT,
  744. SceneSerializer: ()=>ET,
  745. ScreenSizeBlock: ()=>Dm,
  746. ScreenSpaceBlock: ()=>Nm,
  747. ScreenSpaceCurvaturePostProcess: ()=>Sb,
  748. ScreenSpaceReflectionPostProcess: ()=>vb,
  749. ScreenshotTools: ()=>OT,
  750. SerializationHelper: ()=>Ge,
  751. SetCorsBehavior: ()=>Jt,
  752. SetParentAction: ()=>re,
  753. SetStateAction: ()=>q,
  754. SetValueAction: ()=>Z,
  755. ShaderCodeInliner: ()=>iu,
  756. ShaderLanguage: ()=>st,
  757. ShaderMaterial: ()=>jl,
  758. ShaderStage: ()=>Au,
  759. ShaderStore: ()=>Pt,
  760. ShadowDepthWrapper: ()=>Yg,
  761. ShadowGenerator: ()=>r_,
  762. ShadowGeneratorSceneComponent: ()=>f_,
  763. ShadowLight: ()=>xd,
  764. ShadowsOptimization: ()=>uT,
  765. ShapeBuilder: ()=>lc,
  766. SharpenPostProcess: ()=>lb,
  767. SheenBlock: ()=>Ig,
  768. SimplexPerlin3DBlock: ()=>Ag,
  769. SimplicationQueueSceneComponent: ()=>ey,
  770. SimplificationQueue: ()=>Kv,
  771. SimplificationSettings: ()=>Yv,
  772. SimplificationType: ()=>Xv,
  773. SineEase: ()=>kn,
  774. SixDofDragBehavior: ()=>Co,
  775. Size: ()=>je,
  776. Skeleton: ()=>Fo,
  777. SkeletonViewer: ()=>cc,
  778. SmartArray: ()=>bi,
  779. SmartArrayNoDuplicate: ()=>Ti,
  780. SmoothStepBlock: ()=>fg,
  781. SolidParticle: ()=>yy,
  782. SolidParticleSystem: ()=>Sy,
  783. SolidParticleVertex: ()=>Ey,
  784. Sound: ()=>Xr,
  785. SoundTrack: ()=>jr,
  786. Space: ()=>Ji,
  787. SphereBuilder: ()=>Nl,
  788. SphereDirectedParticleEmitter: ()=>vf,
  789. SphereParticleEmitter: ()=>gf,
  790. SphericalHarmonics: ()=>Cc,
  791. SphericalPolynomial: ()=>Pc,
  792. SpotLight: ()=>Dd,
  793. Sprite: ()=>Vb,
  794. SpriteManager: ()=>zb,
  795. SpriteMap: ()=>Hb,
  796. SpritePackedManager: ()=>Xb,
  797. SpriteSceneComponent: ()=>kb,
  798. Stage: ()=>Hi,
  799. StandardMaterial: ()=>Os,
  800. StandardMaterialDefines: ()=>Is,
  801. StandardRenderingPipeline: ()=>yb,
  802. StartsWith: ()=>ae,
  803. StateCondition: ()=>Y,
  804. StencilOperation: ()=>wu,
  805. StencilState: ()=>Ot,
  806. StencilStateComposer: ()=>zt,
  807. StepBlock: ()=>ig,
  808. StereoscopicArcRotateCamera: ()=>Qa,
  809. StereoscopicFreeCamera: ()=>qa,
  810. StereoscopicGamepadCamera: ()=>Za,
  811. StereoscopicInterlacePostProcess: ()=>Ya,
  812. StereoscopicInterlacePostProcessI: ()=>ja,
  813. StereoscopicScreenUniversalCamera: ()=>$a,
  814. StereoscopicUniversalCamera: ()=>Ja,
  815. StickValues: ()=>Go,
  816. StopAnimationAction: ()=>ee,
  817. StopSoundAction: ()=>ge,
  818. StorageBuffer: ()=>wo,
  819. StorageTextureAccess: ()=>Pu,
  820. StoreOp: ()=>Wu,
  821. StringDictionary: ()=>Ei,
  822. StringTools: ()=>de,
  823. SubEmitter: ()=>py,
  824. SubEmitterType: ()=>sy,
  825. SubMesh: ()=>hr,
  826. SubSurfaceBlock: ()=>Fg,
  827. SubSurfaceSceneComponent: ()=>Bb,
  828. SubtractBlock: ()=>tg,
  829. SurfaceMagnetismBehavior: ()=>Po,
  830. SwitchBooleanAction: ()=>Q,
  831. SwitchInput: ()=>Ni,
  832. TGATools: ()=>J_,
  833. Tags: ()=>ye,
  834. TargetCamera: ()=>da,
  835. TargetedAnimation: ()=>Wn,
  836. TextFileAssetTask: ()=>qb,
  837. Texture: ()=>io,
  838. TextureAspect: ()=>yu,
  839. TextureAssetTask: ()=>$b,
  840. TextureBlock: ()=>Vm,
  841. TextureDimension: ()=>mu,
  842. TextureFormat: ()=>bu,
  843. TextureOptimization: ()=>lT,
  844. TexturePacker: ()=>_m,
  845. TexturePackerFrame: ()=>fm,
  846. TextureSampleType: ()=>Cu,
  847. TextureSampler: ()=>Nt,
  848. TextureTools: ()=>Nc,
  849. TextureUsage: ()=>gu,
  850. TextureViewDimension: ()=>vu,
  851. ThinEngine: ()=>Ht,
  852. ThinMaterialHelper: ()=>Pr,
  853. ThinRenderTargetTexture: ()=>Tm,
  854. ThinTexture: ()=>qr,
  855. TiledBoxBuilder: ()=>gv,
  856. TiledPlaneBuilder: ()=>fv,
  857. TimerState: ()=>Nf,
  858. TmpColors: ()=>L,
  859. TmpVectors: ()=>I,
  860. ToGammaSpace: ()=>p,
  861. ToHalfFloat: ()=>Oc,
  862. ToLinearSpace: ()=>f,
  863. TonemapPostProcess: ()=>Tb,
  864. TonemappingOperator: ()=>bb,
  865. Tools: ()=>gi,
  866. TorusBuilder: ()=>Zs,
  867. TorusKnotBuilder: ()=>bv,
  868. TouchCamera: ()=>fa,
  869. TrailMesh: ()=>hv,
  870. Trajectory: ()=>wT,
  871. TrajectoryClassifier: ()=>kT,
  872. TranscodeAsync: ()=>lm,
  873. TransformBlock: ()=>Hp,
  874. TransformNode: ()=>yr,
  875. TrigonometryBlock: ()=>Rf,
  876. TrigonometryBlockOperations: ()=>Af,
  877. TubeBuilder: ()=>Dv,
  878. TwirlBlock: ()=>Lm,
  879. UniformBuffer: ()=>Fi,
  880. UniversalCamera: ()=>Na,
  881. UnregisterAllMaterialPlugins: ()=>xs,
  882. UnregisterMaterialPlugin: ()=>As,
  883. UploadContent: ()=>Z_,
  884. UploadEnvLevelsAsync: ()=>Hc,
  885. UploadEnvSpherical: ()=>Yc,
  886. UploadLevelsAsync: ()=>jc,
  887. UtilityLayerRenderer: ()=>El,
  888. VRCameraMetrics: ()=>ts,
  889. VRDeviceOrientationArcRotateCamera: ()=>cs,
  890. VRDeviceOrientationFreeCamera: ()=>us,
  891. VRDeviceOrientationGamepadCamera: ()=>hs,
  892. VRDistortionCorrectionPostProcess: ()=>is,
  893. VRExperienceHelper: ()=>hl,
  894. VRMultiviewToSingleviewPostProcess: ()=>ss,
  895. ValidatedNativeDataStream: ()=>Ku,
  896. ValueCondition: ()=>X,
  897. Vector2: ()=>A,
  898. Vector3: ()=>x,
  899. Vector4: ()=>R,
  900. VectorMergerBlock: ()=>sf,
  901. VectorSplitterBlock: ()=>Jm,
  902. VertexAnimationBaker: ()=>so,
  903. VertexBuffer: ()=>Bi,
  904. VertexData: ()=>$n,
  905. VertexFormat: ()=>Uu,
  906. VertexOutputBlock: ()=>jp,
  907. VideoDome: ()=>Xf,
  908. VideoRecorder: ()=>ST,
  909. VideoTexture: ()=>Hf,
  910. ViewDirectionBlock: ()=>rg,
  911. Viewport: ()=>xr,
  912. VirtualJoystick: ()=>ua,
  913. VirtualJoysticksCamera: ()=>es,
  914. ViveController: ()=>ud,
  915. VolumetricLightScatteringPostProcess: ()=>Eb,
  916. VoronoiNoiseBlock: ()=>Wg,
  917. WaveBlock: ()=>yg,
  918. WaveBlockKind: ()=>gg,
  919. WebGL2ParticleSystem: ()=>oy,
  920. WebGL2ShaderProcessor: ()=>wt,
  921. WebGLDataBuffer: ()=>Ut,
  922. WebGLHardwareTexture: ()=>kt,
  923. WebGLPipelineContext: ()=>Vt,
  924. WebGPUCacheBindGroups: ()=>Nh,
  925. WebGPUCacheRenderPipeline: ()=>Ah,
  926. WebGPUCacheRenderPipelineTree: ()=>Rh,
  927. WebGPUCacheSampler: ()=>Th,
  928. WebGPUDataBuffer: ()=>_h,
  929. WebGPUDrawContext: ()=>Oh,
  930. WebGPUEngine: ()=>Qh,
  931. WebGPUTintWASM: ()=>Yh,
  932. WebRequest: ()=>Ye,
  933. WebVRController: ()=>_s,
  934. WebVRFreeCamera: ()=>fs,
  935. WebXRAbstractFeature: ()=>wp,
  936. WebXRAbstractMotionController: ()=>xp,
  937. WebXRAnchorSystem: ()=>$T,
  938. WebXRBackgroundRemover: ()=>iE,
  939. WebXRCamera: ()=>Ep,
  940. WebXRCompositionLayerWrapper: ()=>AE,
  941. WebXRControllerComponent: ()=>Ap,
  942. WebXRControllerMovement: ()=>mE,
  943. WebXRControllerPhysics: ()=>rE,
  944. WebXRControllerPointerSelection: ()=>Bp,
  945. WebXRDefaultExperience: ()=>Gf,
  946. WebXRDefaultExperienceOptions: ()=>kf,
  947. WebXRDomOverlay: ()=>_E,
  948. WebXREnterExitUI: ()=>wf,
  949. WebXREnterExitUIButton: ()=>Lf,
  950. WebXREnterExitUIOptions: ()=>Ff,
  951. WebXRExperienceHelper: ()=>Sp,
  952. WebXREyeTracking: ()=>vE,
  953. WebXRFeatureName: ()=>Io,
  954. WebXRFeaturePointSystem: ()=>sE,
  955. WebXRFeaturesManager: ()=>Oo,
  956. WebXRGenericHandController: ()=>OE,
  957. WebXRGenericTriggerMotionController: ()=>Rp,
  958. WebXRHTCViveMotionController: ()=>BE,
  959. WebXRHand: ()=>uE,
  960. WebXRHandTracking: ()=>hE,
  961. WebXRHitTest: ()=>oE,
  962. WebXRHitTestLegacy: ()=>ZT,
  963. WebXRImageTracking: ()=>fE,
  964. WebXRInput: ()=>Fp,
  965. WebXRInputSource: ()=>Lp,
  966. WebXRLayers: ()=>IE,
  967. WebXRLightEstimation: ()=>gE,
  968. WebXRManagedOutputCanvas: ()=>Gs,
  969. WebXRManagedOutputCanvasOptions: ()=>ks,
  970. WebXRMeshDetector: ()=>pE,
  971. WebXRMicrosoftMixedRealityController: ()=>NE,
  972. WebXRMotionControllerManager: ()=>Ip,
  973. WebXRMotionControllerTeleportation: ()=>Vf,
  974. WebXRNearControllerMode: ()=>Pf,
  975. WebXRNearInteraction: ()=>Df,
  976. WebXROculusTouchMotionController: ()=>FE,
  977. WebXRPlaneDetector: ()=>tE,
  978. WebXRProfiledMotionController: ()=>Pp,
  979. WebXRProjectionLayerWrapper: ()=>RE,
  980. WebXRSessionManager: ()=>Xs,
  981. WebXRState: ()=>Ns,
  982. WebXRTrackingState: ()=>Ls,
  983. WebXRWalkingLocomotion: ()=>SE,
  984. WeightedSound: ()=>Kr,
  985. WindowsMotionController: ()=>dd,
  986. WorkerPool: ()=>gp,
  987. WorleyNoise3DBlock: ()=>Sg,
  988. XRWindowsMotionController: ()=>pd,
  989. Xbox360Button: ()=>Sa,
  990. Xbox360Dpad: ()=>Aa,
  991. Xbox360Pad: ()=>Ma,
  992. XboxInput: ()=>Di,
  993. _BabylonLoaderRegistered: ()=>D_,
  994. _BasisTextureLoader: ()=>dm,
  995. _CreationDataStorage: ()=>Lr,
  996. _DDSTextureLoader: ()=>fp,
  997. _ENVTextureLoader: ()=>_p,
  998. _HDRTextureLoader: ()=>em,
  999. _IAnimationState: ()=>Ke,
  1000. _InstancesBatch: ()=>wr,
  1001. _KTXTextureLoader: ()=>Tp,
  1002. _MeshCollisionData: ()=>br,
  1003. _OcclusionDataStorage: ()=>fc,
  1004. _PrimaryIsoTriangle: ()=>Vv,
  1005. _TGATextureLoader: ()=>$_,
  1006. _TimeToken: ()=>pc,
  1007. _UpdateRGBDAsync: ()=>Kc,
  1008. _forceSceneHelpersToBundle: ()=>zf,
  1009. _forceTransformFeedbackToBundle: ()=>_c,
  1010. _injectLTSFileTools: ()=>ci,
  1011. allocateAndCopyTypedBuffer: ()=>gr,
  1012. className: ()=>vi,
  1013. createDetailMapPlugin: ()=>$g,
  1014. createPBRAnisotropicPlugin: ()=>Kg,
  1015. createPBRBRDFPlugin: ()=>Qg,
  1016. createPBRClearCoatPlugin: ()=>qg,
  1017. createPBRSheenPlugin: ()=>Zg,
  1018. createPBRSubSurfacePlugin: ()=>Jg,
  1019. createYieldingScheduler: ()=>Yn,
  1020. editableInPropertyPage: ()=>Yp,
  1021. expandToProperty: ()=>Re,
  1022. extractMinAndMax: ()=>ur,
  1023. extractMinAndMaxIndexed: ()=>cr,
  1024. inlineScheduler: ()=>jn,
  1025. makeAsyncFunction: ()=>Jn,
  1026. makeSyncFunction: ()=>Zn,
  1027. nativeOverride: ()=>ze,
  1028. normalizeEnvInfo: ()=>kc,
  1029. runCoroutine: ()=>Kn,
  1030. runCoroutineAsync: ()=>qn,
  1031. runCoroutineSync: ()=>Qn,
  1032. serialize: ()=>Ce,
  1033. serializeAsCameraReference: ()=>Ve,
  1034. serializeAsColor3: ()=>Me,
  1035. serializeAsColor4: ()=>Fe,
  1036. serializeAsColorCurves: ()=>Le,
  1037. serializeAsFresnelParameters: ()=>Ie,
  1038. serializeAsImageProcessingConfiguration: ()=>we,
  1039. serializeAsMatrix: ()=>Ue,
  1040. serializeAsMeshReference: ()=>Ne,
  1041. serializeAsQuaternion: ()=>Be,
  1042. serializeAsTexture: ()=>Pe,
  1043. serializeAsVector2: ()=>Oe,
  1044. serializeAsVector3: ()=>De,
  1045. setAndStartTimer: ()=>Bf,
  1046. setStereoscopicAnaglyphRigMode: ()=>Ga,
  1047. setStereoscopicRigMode: ()=>Ka,
  1048. setVRRigMode: ()=>ls,
  1049. setWebVRRigMode: ()=>ps
  1050. });
  1051. var r = {};
  1052. e.r(r),
  1053. e.d(r, {
  1054. AbstractActionManager: ()=>s,
  1055. AbstractAssetTask: ()=>jb,
  1056. AbstractMesh: ()=>Sr,
  1057. AbstractScene: ()=>o,
  1058. AcquireNativeObjectAsync: ()=>ru,
  1059. Action: ()=>F,
  1060. ActionEvent: ()=>w,
  1061. ActionManager: ()=>_e,
  1062. AddBlock: ()=>Hm,
  1063. AddressMode: ()=>Tu,
  1064. AdvancedTimer: ()=>Uf,
  1065. AlphaState: ()=>Dt,
  1066. AmmoJSPlugin: ()=>I_,
  1067. AnaglyphArcRotateCamera: ()=>za,
  1068. AnaglyphFreeCamera: ()=>Wa,
  1069. AnaglyphGamepadCamera: ()=>Ha,
  1070. AnaglyphPostProcess: ()=>ka,
  1071. AnaglyphUniversalCamera: ()=>Xa,
  1072. Analyser: ()=>Wr,
  1073. AndOrNotEvaluator: ()=>ve,
  1074. Angle: ()=>An,
  1075. Animatable: ()=>bn,
  1076. AnimatedInputBlockTypes: ()=>qp,
  1077. Animation: ()=>Qe,
  1078. AnimationEvent: ()=>zn,
  1079. AnimationGroup: ()=>Hn,
  1080. AnimationKeyInterpolation: ()=>ke,
  1081. AnimationPropertiesOverride: ()=>En,
  1082. AnimationRange: ()=>We,
  1083. AnisotropyBlock: ()=>Og,
  1084. ApplyPostProcess: ()=>Ic,
  1085. Arc2: ()=>xn,
  1086. ArcFollowCamera: ()=>Ea,
  1087. ArcRotateCamera: ()=>_a,
  1088. ArcRotateCameraGamepadInput: ()=>Ho,
  1089. ArcRotateCameraInputsManager: ()=>Ko,
  1090. ArcRotateCameraKeyboardMoveInput: ()=>Xo,
  1091. ArcRotateCameraMouseWheelInput: ()=>jo,
  1092. ArcRotateCameraPointersInput: ()=>Yo,
  1093. ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
  1094. ArcTan2Block: ()=>pg,
  1095. AssetContainer: ()=>zr,
  1096. AssetTaskState: ()=>Wb,
  1097. AssetsManager: ()=>nT,
  1098. AssetsProgressEvent: ()=>Yb,
  1099. AsyncLoop: ()=>yi,
  1100. AttachToBoxBehavior: ()=>po,
  1101. AudioEngine: ()=>Hr,
  1102. AudioSceneComponent: ()=>Yr,
  1103. AutoReleaseWorkerPool: ()=>vp,
  1104. AutoRotationBehavior: ()=>lo,
  1105. AxesViewer: ()=>xl,
  1106. Axis: ()=>vn,
  1107. AxisDragGizmo: ()=>Al,
  1108. AxisScaleGizmo: ()=>fd,
  1109. BRDFTextureTools: ()=>Xd,
  1110. BabylonFileLoaderConfiguration: ()=>N_,
  1111. BackEase: ()=>On,
  1112. BackgroundMaterial: ()=>Vd,
  1113. BakedVertexAnimationManager: ()=>Qr,
  1114. BaseCameraMouseWheelInput: ()=>Bo,
  1115. BaseCameraPointersInput: ()=>Uo,
  1116. BaseError: ()=>dt,
  1117. BaseParticleSystem: ()=>Tf,
  1118. BaseSixDofDragBehavior: ()=>Ro,
  1119. BaseTexture: ()=>Zr,
  1120. BasisTools: ()=>um,
  1121. BasisToolsOptions: ()=>nm,
  1122. BasisTranscodeConfiguration: ()=>im,
  1123. BezierCurve: ()=>Sn,
  1124. BezierCurveEase: ()=>Gn,
  1125. BinaryFileAssetTask: ()=>Zb,
  1126. BlackAndWhitePostProcess: ()=>Uy,
  1127. BlendFactor: ()=>Lu,
  1128. BlendOperation: ()=>Fu,
  1129. BloomEffect: ()=>zy,
  1130. BloomMergePostProcess: ()=>Gy,
  1131. BlurPostProcess: ()=>Fd,
  1132. Bone: ()=>yn,
  1133. BoneAxesViewer: ()=>Rl,
  1134. BoneIKController: ()=>No,
  1135. BoneLookController: ()=>Lo,
  1136. BonesBlock: ()=>Em,
  1137. BounceEase: ()=>Dn,
  1138. BouncingBehavior: ()=>co,
  1139. BoundingBox: ()=>tr,
  1140. BoundingBoxGizmo: ()=>_d,
  1141. BoundingBoxRenderer: ()=>Ab,
  1142. BoundingInfo: ()=>sr,
  1143. BoundingSphere: ()=>ir,
  1144. BoxBuilder: ()=>Il,
  1145. BoxParticleEmitter: ()=>hf,
  1146. Buffer: ()=>wi,
  1147. BufferBindingType: ()=>xu,
  1148. BufferUsage: ()=>fu,
  1149. CSG: ()=>cv,
  1150. Camera: ()=>Rr,
  1151. CameraGizmo: ()=>Ld,
  1152. CameraInputTypes: ()=>Vo,
  1153. CameraInputsManager: ()=>ko,
  1154. CannonJSPlugin: ()=>P_,
  1155. CanvasCompositingAlphaMode: ()=>Xu,
  1156. CapsuleBuilder: ()=>zl,
  1157. CascadedShadowGenerator: ()=>p_,
  1158. ChromaticAberrationPostProcess: ()=>Wy,
  1159. CircleEase: ()=>In,
  1160. CircleOfConfusionPostProcess: ()=>Hy,
  1161. ClampBlock: ()=>jm,
  1162. ClearCoatBlock: ()=>Ng,
  1163. ClipPlanesBlock: ()=>Wm,
  1164. ClipboardEventTypes: ()=>nd,
  1165. ClipboardInfo: ()=>rd,
  1166. CloudBlock: ()=>zg,
  1167. CloudPoint: ()=>Ay,
  1168. Collider: ()=>pl,
  1169. Color3: ()=>D,
  1170. Color3Gradient: ()=>cy,
  1171. Color4: ()=>N,
  1172. ColorCorrectionPostProcess: ()=>Xy,
  1173. ColorCurves: ()=>Ai,
  1174. ColorGradient: ()=>ly,
  1175. ColorGradingTexture: ()=>Y_,
  1176. ColorMergerBlock: ()=>Zm,
  1177. ColorSplitterBlock: ()=>Ef,
  1178. ColorWrite: ()=>Nu,
  1179. CombineAction: ()=>ie,
  1180. CompareFunction: ()=>Su,
  1181. CompatibilityOptions: ()=>pr,
  1182. CompilationMessageType: ()=>Mu,
  1183. ComputeBindingType: ()=>_l,
  1184. ComputeEffect: ()=>ml,
  1185. ComputePassTimestampLocation: ()=>ku,
  1186. ComputePressureObserverWrapper: ()=>_n,
  1187. ComputeShader: ()=>gl,
  1188. ComputeShaderParticleSystem: ()=>ay,
  1189. Condition: ()=>H,
  1190. ConditionalBlock: ()=>Gg,
  1191. ConditionalBlockConditions: ()=>Vg,
  1192. ConeParticleEmitter: ()=>df,
  1193. Constants: ()=>a,
  1194. ContainerAssetTask: ()=>Kb,
  1195. ConvolutionPostProcess: ()=>jy,
  1196. Coordinate: ()=>gn,
  1197. CopyTools: ()=>to,
  1198. CreateBox: ()=>Ml,
  1199. CreateBoxVertexData: ()=>Pl,
  1200. CreateCapsule: ()=>Gl,
  1201. CreateCapsuleVertexData: ()=>kl,
  1202. CreateCylinder: ()=>Ys,
  1203. CreateCylinderVertexData: ()=>js,
  1204. CreateDashedLines: ()=>$l,
  1205. CreateDashedLinesVertexData: ()=>ql,
  1206. CreateDecal: ()=>wv,
  1207. CreateDisc: ()=>Pd,
  1208. CreateEnvTextureAsync: ()=>Gc,
  1209. CreateGeodesic: ()=>zv,
  1210. CreateGoldberg: ()=>Hv,
  1211. CreateGoldbergVertexData: ()=>Wv,
  1212. CreateGround: ()=>il,
  1213. CreateGroundFromHeightMap: ()=>rl,
  1214. CreateGroundFromHeightMapVertexData: ()=>tl,
  1215. CreateGroundVertexData: ()=>$s,
  1216. CreateHemisphere: ()=>Id,
  1217. CreateIcoSphere: ()=>Lv,
  1218. CreateIcoSphereVertexData: ()=>Nv,
  1219. CreateImageDataArrayBufferViews: ()=>Wc,
  1220. CreateLathe: ()=>Mv,
  1221. CreateLineSystem: ()=>Zl,
  1222. CreateLineSystemVertexData: ()=>Ql,
  1223. CreateLines: ()=>Jl,
  1224. CreatePlane: ()=>vo,
  1225. CreatePlaneVertexData: ()=>go,
  1226. CreatePolygon: ()=>Rv,
  1227. CreatePolygonVertexData: ()=>xv,
  1228. CreatePolyhedron: ()=>Td,
  1229. CreatePolyhedronVertexData: ()=>bd,
  1230. CreateResizedCopy: ()=>Mc,
  1231. CreateRibbon: ()=>nc,
  1232. CreateRibbonVertexData: ()=>ic,
  1233. CreateScreenshot: ()=>AT,
  1234. CreateScreenshotAsync: ()=>xT,
  1235. CreateScreenshotUsingRenderTarget: ()=>CT,
  1236. CreateScreenshotUsingRenderTargetAsync: ()=>PT,
  1237. CreateScreenshotWithResizeAsync: ()=>RT,
  1238. CreateSphere: ()=>Dl,
  1239. CreateSphereVertexData: ()=>Ol,
  1240. CreateTiledBox: ()=>mv,
  1241. CreateTiledBoxVertexData: ()=>_v,
  1242. CreateTiledGround: ()=>nl,
  1243. CreateTiledGroundVertexData: ()=>el,
  1244. CreateTiledPlane: ()=>pv,
  1245. CreateTiledPlaneVertexData: ()=>dv,
  1246. CreateTorus: ()=>qs,
  1247. CreateTorusKnot: ()=>yv,
  1248. CreateTorusKnotVertexData: ()=>vv,
  1249. CreateTorusVertexData: ()=>Qs,
  1250. CreateTube: ()=>Ov,
  1251. CrossBlock: ()=>Ym,
  1252. CubeMapToSphericalPolynomialTools: ()=>wc,
  1253. CubeTexture: ()=>Bd,
  1254. CubeTextureAssetTask: ()=>eT,
  1255. CubicEase: ()=>Nn,
  1256. CullMode: ()=>Du,
  1257. CurrentScreenBlock: ()=>nf,
  1258. Curve3: ()=>Pn,
  1259. CustomBlock: ()=>Km,
  1260. CustomOptimization: ()=>pT,
  1261. CustomParticleEmitter: ()=>yf,
  1262. CustomProceduralTexture: ()=>mm,
  1263. CylinderBuilder: ()=>Ks,
  1264. CylinderDirectedParticleEmitter: ()=>ff,
  1265. CylinderParticleEmitter: ()=>pf,
  1266. DDSTools: ()=>pp,
  1267. DataBuffer: ()=>Bt,
  1268. DataReader: ()=>NT,
  1269. DataStorage: ()=>LT,
  1270. Database: ()=>ny,
  1271. DaydreamController: ()=>ad,
  1272. Debug: ()=>HE,
  1273. DebugLayer: ()=>Cl,
  1274. DebugLayerTab: ()=>bl,
  1275. DecalBuilder: ()=>Bv,
  1276. Decode: ()=>se,
  1277. DecodeBase64ToBinary: ()=>ue,
  1278. DecodeBase64ToString: ()=>ce,
  1279. DecodeBase64UrlToBinary: ()=>oi,
  1280. DecodeBase64UrlToString: ()=>si,
  1281. DeepCopier: ()=>fe,
  1282. DefaultCollisionCoordinator: ()=>fl,
  1283. DefaultLoadingScreen: ()=>m_,
  1284. DefaultRenderingPipeline: ()=>db,
  1285. Deferred: ()=>rT,
  1286. DepthCullingState: ()=>It,
  1287. DepthOfFieldBlurPostProcess: ()=>Yy,
  1288. DepthOfFieldEffect: ()=>Zy,
  1289. DepthOfFieldEffectBlurLevel: ()=>Ky,
  1290. DepthOfFieldMergePostProcess: ()=>qy,
  1291. DepthOfFieldMergePostProcessOptions: ()=>Qy,
  1292. DepthPeelingRenderer: ()=>Cb,
  1293. DepthPeelingSceneComponent: ()=>Pb,
  1294. DepthReducer: ()=>s_,
  1295. DepthRenderer: ()=>o_,
  1296. DepthRendererSceneComponent: ()=>xb,
  1297. DepthSortedParticle: ()=>Ty,
  1298. DerivativeBlock: ()=>Im,
  1299. DesaturateBlock: ()=>Mg,
  1300. DetailMapConfiguration: ()=>Ps,
  1301. DeviceInputEventType: ()=>Li,
  1302. DeviceLostReason: ()=>ju,
  1303. DeviceOrientationCamera: ()=>ma,
  1304. DeviceSource: ()=>on,
  1305. DeviceSourceManager: ()=>sn,
  1306. DeviceType: ()=>Ci,
  1307. DirectionalLight: ()=>Rd,
  1308. DirectionalLightFrustumViewer: ()=>uc,
  1309. DiscBuilder: ()=>Md,
  1310. DiscardBlock: ()=>Pm,
  1311. DisplayPassPostProcess: ()=>Jy,
  1312. DistanceBlock: ()=>lg,
  1313. DistanceJoint: ()=>Fl,
  1314. DivideBlock: ()=>eg,
  1315. DoNothingAction: ()=>te,
  1316. DomManagement: ()=>lt,
  1317. DotBlock: ()=>Qm,
  1318. DracoCompression: ()=>iv,
  1319. DrawWrapper: ()=>Gt,
  1320. DualSenseInput: ()=>Oi,
  1321. DualShockButton: ()=>Ca,
  1322. DualShockDpad: ()=>Pa,
  1323. DualShockInput: ()=>Ii,
  1324. DualShockPad: ()=>Ia,
  1325. DynamicFloat32Array: ()=>zT,
  1326. DynamicTexture: ()=>Ds,
  1327. EasingFunction: ()=>Mn,
  1328. EdgesRenderer: ()=>Ib,
  1329. Effect: ()=>Mt,
  1330. EffectFallbacks: ()=>ys,
  1331. EffectLayer: ()=>Kf,
  1332. EffectLayerSceneComponent: ()=>Qf,
  1333. EffectRenderer: ()=>y_,
  1334. EffectWrapper: ()=>b_,
  1335. ElasticEase: ()=>Ln,
  1336. ElbowBlock: ()=>Hg,
  1337. EncodeArrayBufferToBase64: ()=>le,
  1338. EndsWith: ()=>oe,
  1339. Engine: ()=>vr,
  1340. EngineFactory: ()=>id,
  1341. EngineInstrumentation: ()=>jf,
  1342. EngineStore: ()=>E,
  1343. EngineView: ()=>mc,
  1344. EnvironmentHelper: ()=>kd,
  1345. EnvironmentTextureTools: ()=>Qc,
  1346. Epsilon: ()=>m,
  1347. EquiRectangularCubeTexture: ()=>K_,
  1348. EquiRectangularCubeTextureAssetTask: ()=>iT,
  1349. ErrorCodes: ()=>pt,
  1350. ErrorFilter: ()=>Yu,
  1351. EventConstants: ()=>$i,
  1352. EventState: ()=>l,
  1353. ExecuteCodeAction: ()=>ne,
  1354. ExponentialEase: ()=>Fn,
  1355. ExternalTexture: ()=>Mh,
  1356. ExtractHighlightsPostProcess: ()=>ky,
  1357. ExtrudePolygon: ()=>Cv,
  1358. ExtrudeShape: ()=>oc,
  1359. ExtrudeShapeCustom: ()=>ac,
  1360. FactorGradient: ()=>uy,
  1361. FadeInOutBehavior: ()=>fo,
  1362. FeatureName: ()=>pu,
  1363. FileTools: ()=>ai,
  1364. FileToolsOptions: ()=>qt,
  1365. FilesInput: ()=>aT,
  1366. FilesInputStore: ()=>ut,
  1367. FilterMode: ()=>Eu,
  1368. FilterPostProcess: ()=>$y,
  1369. FlyCamera: ()=>va,
  1370. FlyCameraInputsManager: ()=>ga,
  1371. FlyCameraKeyboardInput: ()=>qo,
  1372. FlyCameraMouseInput: ()=>Zo,
  1373. FogBlock: ()=>Fm,
  1374. FollowBehavior: ()=>Mo,
  1375. FollowCamera: ()=>Ta,
  1376. FollowCameraInputsManager: ()=>ya,
  1377. FollowCameraKeyboardMoveInput: ()=>Jo,
  1378. FollowCameraMouseWheelInput: ()=>$o,
  1379. FollowCameraPointersInput: ()=>ea,
  1380. FragCoordBlock: ()=>Om,
  1381. FragmentOutputBlock: ()=>Zp,
  1382. FramingBehavior: ()=>uo,
  1383. FreeCamera: ()=>pa,
  1384. FreeCameraDeviceOrientationInput: ()=>sa,
  1385. FreeCameraGamepadInput: ()=>ca,
  1386. FreeCameraInputsManager: ()=>aa,
  1387. FreeCameraKeyboardMoveInput: ()=>ta,
  1388. FreeCameraMouseInput: ()=>na,
  1389. FreeCameraMouseWheelInput: ()=>ra,
  1390. FreeCameraTouchInput: ()=>oa,
  1391. FreeCameraVirtualJoystickInput: ()=>ha,
  1392. FresnelBlock: ()=>og,
  1393. FresnelParameters: ()=>z_,
  1394. FromHalfFloat: ()=>Dc,
  1395. FrontFace: ()=>Ou,
  1396. FrontFacingBlock: ()=>Mm,
  1397. Frustum: ()=>dn,
  1398. FxaaPostProcess: ()=>eb,
  1399. GPUParticleSystem: ()=>_y,
  1400. GUID: ()=>_i,
  1401. Gamepad: ()=>zo,
  1402. GamepadCamera: ()=>La,
  1403. GamepadManager: ()=>Oa,
  1404. GamepadSystemSceneComponent: ()=>Da,
  1405. GearVRController: ()=>sd,
  1406. GenerateBase64StringFromPixelData: ()=>Jr,
  1407. GenerateBase64StringFromTexture: ()=>$r,
  1408. GenerateBase64StringFromTextureAsync: ()=>eo,
  1409. GenericController: ()=>ld,
  1410. GenericPad: ()=>Wo,
  1411. GeodesicData: ()=>Gv,
  1412. Geometry: ()=>fr,
  1413. GeometryBufferRenderer: ()=>nb,
  1414. GeometryBufferRendererSceneComponent: ()=>ob,
  1415. GetClass: ()=>b,
  1416. GetDOMTextContent: ()=>at,
  1417. GetEnvInfo: ()=>Vc,
  1418. GetEnvironmentBRDFTexture: ()=>Hd,
  1419. GetInternalFormatFromBasisFormat: ()=>rm,
  1420. GetTGAHeader: ()=>q_,
  1421. Gizmo: ()=>Sl,
  1422. GizmoManager: ()=>Ad,
  1423. GlowLayer: ()=>qf,
  1424. GoldbergMesh: ()=>uv,
  1425. GradientBlock: ()=>Tg,
  1426. GradientBlockColorStep: ()=>bg,
  1427. GradientHelper: ()=>hy,
  1428. GrainPostProcess: ()=>tb,
  1429. GroundBuilder: ()=>ol,
  1430. GroundMesh: ()=>Js,
  1431. HDRCubeTexture: ()=>E_,
  1432. HDRCubeTextureAssetTask: ()=>tT,
  1433. HDRFiltering: ()=>T_,
  1434. HDRTools: ()=>v_,
  1435. HandConstraintBehavior: ()=>Do,
  1436. HandConstraintOrientation: ()=>Eo,
  1437. HandConstraintVisibility: ()=>So,
  1438. HandConstraintZone: ()=>To,
  1439. HardwareScalingOptimization: ()=>cT,
  1440. HemisphereBuilder: ()=>Od,
  1441. HemisphericLight: ()=>ds,
  1442. HemisphericParticleEmitter: ()=>_f,
  1443. HighlightLayer: ()=>Jf,
  1444. HighlightsPostProcess: ()=>ib,
  1445. Hinge2Joint: ()=>Ul,
  1446. HingeJoint: ()=>Bl,
  1447. HtmlElementTexture: ()=>Q_,
  1448. IWebXRControllerPhysicsOptions: ()=>nE,
  1449. IcoSphereBuilder: ()=>Fv,
  1450. ImageAssetTask: ()=>Jb,
  1451. ImageProcessingBlock: ()=>Rm,
  1452. ImageProcessingConfiguration: ()=>Ri,
  1453. ImageProcessingConfigurationDefines: ()=>xi,
  1454. ImageProcessingPostProcess: ()=>Fs,
  1455. ImageSourceBlock: ()=>Um,
  1456. IncrementValueAction: ()=>J,
  1457. IndexFormat: ()=>Bu,
  1458. InputBlock: ()=>tf,
  1459. InputStepMode: ()=>Vu,
  1460. InspectableType: ()=>IT,
  1461. InstancedLinesMesh: ()=>Kl,
  1462. InstancedMesh: ()=>Hl,
  1463. InstancesBlock: ()=>Sm,
  1464. InstantiatedEntries: ()=>Gr,
  1465. InternalTexture: ()=>Lt,
  1466. InternalTextureSource: ()=>At,
  1467. InterpolateValueAction: ()=>qe,
  1468. IntersectionInfo: ()=>er,
  1469. IsBase64DataUrl: ()=>ri,
  1470. IsDocumentAvailable: ()=>ot,
  1471. IsFileURL: ()=>ni,
  1472. IsNavigatorAvailable: ()=>rt,
  1473. IsWindowObjectExist: ()=>nt,
  1474. JoystickAxis: ()=>la,
  1475. KeepAssets: ()=>kr,
  1476. KeyboardEventTypes: ()=>Qi,
  1477. KeyboardInfo: ()=>qi,
  1478. KeyboardInfoPre: ()=>Zi,
  1479. KhronosTextureContainer: ()=>mp,
  1480. KhronosTextureContainer2: ()=>yp,
  1481. LatheBuilder: ()=>Iv,
  1482. Layer: ()=>e_,
  1483. LayerSceneComponent: ()=>$f,
  1484. LengthBlock: ()=>cg,
  1485. LensFlare: ()=>t_,
  1486. LensFlareSystem: ()=>i_,
  1487. LensFlareSystemSceneComponent: ()=>n_,
  1488. LensFlaresOptimization: ()=>dT,
  1489. LensRenderingPipeline: ()=>pb,
  1490. LerpBlock: ()=>$m,
  1491. Light: ()=>Cr,
  1492. LightBlock: ()=>wm,
  1493. LightGizmo: ()=>Nd,
  1494. LightInformationBlock: ()=>xm,
  1495. LineEdgesRenderer: ()=>Ob,
  1496. LinesBuilder: ()=>ec,
  1497. LinesMesh: ()=>Yl,
  1498. LoadFile: ()=>ti,
  1499. LoadFileError: ()=>Yt,
  1500. LoadImage: ()=>$t,
  1501. LoadOp: ()=>zu,
  1502. LoadTextureFromTranscodeResult: ()=>cm,
  1503. Logger: ()=>K,
  1504. MapMode: ()=>_u,
  1505. Material: ()=>Or,
  1506. MaterialAnisotropicDefines: ()=>qd,
  1507. MaterialClearCoatDefines: ()=>Kd,
  1508. MaterialDefines: ()=>Si,
  1509. MaterialDetailMapDefines: ()=>Cs,
  1510. MaterialFlags: ()=>vs,
  1511. MaterialHelper: ()=>Mr,
  1512. MaterialPluginBase: ()=>Rs,
  1513. MaterialPluginManager: ()=>bs,
  1514. MaterialSheenDefines: ()=>Jd,
  1515. MaterialSubSurfaceDefines: ()=>ep,
  1516. Matrix: ()=>P,
  1517. MatrixBuilderBlock: ()=>kg,
  1518. MaxBlock: ()=>ag,
  1519. MergeMeshesOptimization: ()=>mT,
  1520. Mesh: ()=>Vr,
  1521. MeshAssetTask: ()=>Qb,
  1522. MeshBuilder: ()=>jv,
  1523. MeshExploder: ()=>oT,
  1524. MeshLODLevel: ()=>Nr,
  1525. MeshParticleEmitter: ()=>bf,
  1526. MeshoptCompression: ()=>nv,
  1527. MinBlock: ()=>sg,
  1528. MinMaxReducer: ()=>a_,
  1529. MirrorTexture: ()=>wd,
  1530. ModBlock: ()=>Ug,
  1531. ModelShape: ()=>by,
  1532. MorphTarget: ()=>S_,
  1533. MorphTargetManager: ()=>x_,
  1534. MorphTargetsBlock: ()=>Am,
  1535. MotionBlurPostProcess: ()=>ab,
  1536. MotorEnabledJoint: ()=>wl,
  1537. MultiMaterial: ()=>Dr,
  1538. MultiObserver: ()=>u,
  1539. MultiPointerScaleBehavior: ()=>xo,
  1540. MultiRenderTarget: ()=>pm,
  1541. MultiplyBlock: ()=>uf,
  1542. NLerpBlock: ()=>Eg,
  1543. NativeDataStream: ()=>bc,
  1544. NativeEngine: ()=>uu,
  1545. NativePointerInput: ()=>Mi,
  1546. NativeXRFrame: ()=>VE,
  1547. NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
  1548. NativeXRLayerWrapper: ()=>zs,
  1549. NativeXRRenderTarget: ()=>Hs,
  1550. NegateBlock: ()=>ug,
  1551. Node: ()=>Xe,
  1552. NodeMaterial: ()=>Of,
  1553. NodeMaterialBlock: ()=>Wp,
  1554. NodeMaterialBlockConnectionPointMode: ()=>Kp,
  1555. NodeMaterialBlockConnectionPointTypes: ()=>Op,
  1556. NodeMaterialBlockTargets: ()=>Dp,
  1557. NodeMaterialConnectionPoint: ()=>zp,
  1558. NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
  1559. NodeMaterialConnectionPointDirection: ()=>Vp,
  1560. NodeMaterialDefines: ()=>If,
  1561. NodeMaterialModes: ()=>cf,
  1562. NodeMaterialOptimizer: ()=>Xg,
  1563. NodeMaterialSystemValues: ()=>Qp,
  1564. NoiseProceduralTexture: ()=>gm,
  1565. NormalBlendBlock: ()=>xg,
  1566. NormalizeBlock: ()=>qm,
  1567. NullEngine: ()=>dc,
  1568. NullEngineOptions: ()=>hc,
  1569. Observable: ()=>h,
  1570. Observer: ()=>c,
  1571. OcclusionMaterial: ()=>W_,
  1572. Octree: ()=>yl,
  1573. OctreeBlock: ()=>vl,
  1574. OctreeSceneComponent: ()=>Tl,
  1575. OculusTouchController: ()=>cd,
  1576. OimoJSPlugin: ()=>M_,
  1577. OnAfterEnteringVRObservableEvent: ()=>ul,
  1578. OneMinusBlock: ()=>ng,
  1579. Orientation: ()=>Tn,
  1580. OutlineRenderer: ()=>Ub,
  1581. PBRAnisotropicConfiguration: ()=>Zd,
  1582. PBRBaseMaterial: ()=>rp,
  1583. PBRBaseSimpleMaterial: ()=>H_,
  1584. PBRClearCoatConfiguration: ()=>Qd,
  1585. PBRMaterial: ()=>op,
  1586. PBRMaterialDefines: ()=>np,
  1587. PBRMetallicRoughnessBlock: ()=>Bg,
  1588. PBRMetallicRoughnessMaterial: ()=>X_,
  1589. PBRSheenConfiguration: ()=>$d,
  1590. PBRSpecularGlossinessMaterial: ()=>j_,
  1591. PBRSubSurfaceConfiguration: ()=>tp,
  1592. PHI: ()=>_,
  1593. PadNumber: ()=>he,
  1594. PanoramaToCubeMapTools: ()=>g_,
  1595. Particle: ()=>dy,
  1596. ParticleBlendMultiplyBlock: ()=>af,
  1597. ParticleHelper: ()=>gy,
  1598. ParticleRampGradientBlock: ()=>of,
  1599. ParticleSystem: ()=>fy,
  1600. ParticleSystemSet: ()=>my,
  1601. ParticleTextureBlock: ()=>rf,
  1602. ParticlesOptimization: ()=>fT,
  1603. PassCubePostProcess: ()=>Va,
  1604. PassPostProcess: ()=>Ua,
  1605. Path2: ()=>Rn,
  1606. Path3D: ()=>Cn,
  1607. PathCursor: ()=>Xn,
  1608. PerfCollectionStrategy: ()=>qT,
  1609. PerfCounter: ()=>un,
  1610. PerformanceConfigurator: ()=>T,
  1611. PerformanceMonitor: ()=>_r,
  1612. PerformanceViewerCollector: ()=>KT,
  1613. PerturbNormalBlock: ()=>Cm,
  1614. PhotoDome: ()=>zd,
  1615. PhysicsEngine: ()=>R_,
  1616. PhysicsEngineSceneComponent: ()=>My,
  1617. PhysicsHelper: ()=>Iy,
  1618. PhysicsImpostor: ()=>Vl,
  1619. PhysicsJoint: ()=>Ll,
  1620. PhysicsRadialExplosionEventOptions: ()=>Fy,
  1621. PhysicsRadialImpulseFalloff: ()=>Cy,
  1622. PhysicsUpdraftEventOptions: ()=>wy,
  1623. PhysicsUpdraftMode: ()=>Py,
  1624. PhysicsViewer: ()=>Wl,
  1625. PhysicsVortexEventOptions: ()=>By,
  1626. PickingInfo: ()=>Ui,
  1627. PivotTools: ()=>mo,
  1628. Plane: ()=>hn,
  1629. PlaneBuilder: ()=>yo,
  1630. PlaneDragGizmo: ()=>vd,
  1631. PlaneRotationGizmo: ()=>md,
  1632. PlayAnimationAction: ()=>$,
  1633. PlaySoundAction: ()=>me,
  1634. PointColor: ()=>vy,
  1635. PointLight: ()=>__,
  1636. PointParticleEmitter: ()=>mf,
  1637. PointerDragBehavior: ()=>Ao,
  1638. PointerEventTypes: ()=>Xi,
  1639. PointerInfo: ()=>Ki,
  1640. PointerInfoBase: ()=>ji,
  1641. PointerInfoPre: ()=>Yi,
  1642. PointerInput: ()=>Pi,
  1643. PointsCloudSystem: ()=>Ry,
  1644. PointsGroup: ()=>xy,
  1645. Polygon: ()=>Sv,
  1646. PolygonBuilder: ()=>Pv,
  1647. PolygonMeshBuilder: ()=>Av,
  1648. PolyhedronBuilder: ()=>Ed,
  1649. PolyhedronData: ()=>kv,
  1650. PoseEnabledController: ()=>Ra,
  1651. PoseEnabledControllerHelper: ()=>xa,
  1652. PoseEnabledControllerType: ()=>ba,
  1653. PositionGizmo: ()=>yd,
  1654. PositionNormalTextureVertex: ()=>Ec,
  1655. PositionNormalVertex: ()=>Tc,
  1656. PostProcess: ()=>Ba,
  1657. PostProcessManager: ()=>Vi,
  1658. PostProcessRenderEffect: ()=>Vy,
  1659. PostProcessRenderPipeline: ()=>cb,
  1660. PostProcessRenderPipelineManager: ()=>ub,
  1661. PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
  1662. PostProcessesOptimization: ()=>hT,
  1663. PosterizeBlock: ()=>vg,
  1664. PowBlock: ()=>hg,
  1665. PowerEase: ()=>wn,
  1666. PowerPreference: ()=>du,
  1667. PrePassRenderer: ()=>Nb,
  1668. PrePassRendererSceneComponent: ()=>Lb,
  1669. PrecisionDate: ()=>ct,
  1670. PredefinedColorSpace: ()=>hu,
  1671. PredicateCondition: ()=>j,
  1672. PrimitiveTopology: ()=>Iu,
  1673. ProceduralTexture: ()=>xf,
  1674. ProceduralTextureSceneComponent: ()=>Sf,
  1675. PromisePolyfill: ()=>di,
  1676. PropertyTypeForEdition: ()=>Xp,
  1677. PushMaterial: ()=>gs,
  1678. QuadraticEase: ()=>Bn,
  1679. QuadraticErrorSimplification: ()=>$v,
  1680. QuarticEase: ()=>Un,
  1681. Quaternion: ()=>C,
  1682. QueryType: ()=>Hu,
  1683. QuinticEase: ()=>Vn,
  1684. RGBDTextureTools: ()=>Lc,
  1685. RandomGUID: ()=>fi,
  1686. RandomNumberBlock: ()=>dg,
  1687. RawCubeTexture: ()=>vm,
  1688. RawTexture: ()=>ao,
  1689. RawTexture2DArray: ()=>A_,
  1690. RawTexture3D: ()=>ym,
  1691. Ray: ()=>_o,
  1692. RayHelper: ()=>tc,
  1693. ReadFile: ()=>ei,
  1694. ReadFileError: ()=>Qt,
  1695. RecastJSCrowd: ()=>iy,
  1696. RecastJSPlugin: ()=>ty,
  1697. ReciprocalBlock: ()=>_g,
  1698. ReflectBlock: ()=>Cg,
  1699. ReflectionBlock: ()=>Dg,
  1700. ReflectionProbe: ()=>O_,
  1701. ReflectionTextureBlock: ()=>Gm,
  1702. Reflector: ()=>GT,
  1703. RefractBlock: ()=>Pg,
  1704. RefractionBlock: ()=>Lg,
  1705. RefractionPostProcess: ()=>sb,
  1706. RefractionTexture: ()=>bm,
  1707. RegisterClass: ()=>y,
  1708. RegisterMaterialPlugin: ()=>Ss,
  1709. RegisterNativeTypeAsync: ()=>ou,
  1710. RemapBlock: ()=>lf,
  1711. RenderPassTimestampLocation: ()=>Gu,
  1712. RenderTargetTexture: ()=>ns,
  1713. RenderTargetWrapper: ()=>Fa,
  1714. RenderTargetsOptimization: ()=>_T,
  1715. RenderingGroup: ()=>ki,
  1716. RenderingGroupInfo: ()=>Gi,
  1717. RenderingManager: ()=>zi,
  1718. ReplaceColorBlock: ()=>mg,
  1719. RequestFile: ()=>ii,
  1720. RequestFileError: ()=>Kt,
  1721. RetryStrategy: ()=>ht,
  1722. RibbonBuilder: ()=>rc,
  1723. RollingAverage: ()=>mr,
  1724. Rotate2dBlock: ()=>Rg,
  1725. RotationGizmo: ()=>gd,
  1726. RuntimeAnimation: ()=>it,
  1727. RuntimeError: ()=>ft,
  1728. SSAO2RenderingPipeline: ()=>_b,
  1729. SSAORenderingPipeline: ()=>mb,
  1730. SamplerBindingType: ()=>Ru,
  1731. Scalar: ()=>d,
  1732. ScaleBlock: ()=>Xm,
  1733. ScaleGizmo: ()=>Sd,
  1734. Scene: ()=>mn,
  1735. SceneComponentConstants: ()=>Wi,
  1736. SceneDepthBlock: ()=>zm,
  1737. SceneInstrumentation: ()=>Yf,
  1738. SceneLoader: ()=>od,
  1739. SceneLoaderAnimationGroupLoadingMode: ()=>td,
  1740. SceneLoaderFlags: ()=>dr,
  1741. SceneOptimization: ()=>sT,
  1742. SceneOptimizer: ()=>vT,
  1743. SceneOptimizerOptions: ()=>gT,
  1744. SceneRecorder: ()=>FT,
  1745. SceneSerializer: ()=>ET,
  1746. ScreenSizeBlock: ()=>Dm,
  1747. ScreenSpaceBlock: ()=>Nm,
  1748. ScreenSpaceCurvaturePostProcess: ()=>Sb,
  1749. ScreenSpaceReflectionPostProcess: ()=>vb,
  1750. ScreenshotTools: ()=>OT,
  1751. SerializationHelper: ()=>Ge,
  1752. SetCorsBehavior: ()=>Jt,
  1753. SetParentAction: ()=>re,
  1754. SetStateAction: ()=>q,
  1755. SetValueAction: ()=>Z,
  1756. ShaderCodeInliner: ()=>iu,
  1757. ShaderLanguage: ()=>st,
  1758. ShaderMaterial: ()=>jl,
  1759. ShaderStage: ()=>Au,
  1760. ShaderStore: ()=>Pt,
  1761. ShadowDepthWrapper: ()=>Yg,
  1762. ShadowGenerator: ()=>r_,
  1763. ShadowGeneratorSceneComponent: ()=>f_,
  1764. ShadowLight: ()=>xd,
  1765. ShadowsOptimization: ()=>uT,
  1766. ShapeBuilder: ()=>lc,
  1767. SharpenPostProcess: ()=>lb,
  1768. SheenBlock: ()=>Ig,
  1769. SimplexPerlin3DBlock: ()=>Ag,
  1770. SimplicationQueueSceneComponent: ()=>ey,
  1771. SimplificationQueue: ()=>Kv,
  1772. SimplificationSettings: ()=>Yv,
  1773. SimplificationType: ()=>Xv,
  1774. SineEase: ()=>kn,
  1775. SixDofDragBehavior: ()=>Co,
  1776. Size: ()=>je,
  1777. Skeleton: ()=>Fo,
  1778. SkeletonViewer: ()=>cc,
  1779. SmartArray: ()=>bi,
  1780. SmartArrayNoDuplicate: ()=>Ti,
  1781. SmoothStepBlock: ()=>fg,
  1782. SolidParticle: ()=>yy,
  1783. SolidParticleSystem: ()=>Sy,
  1784. SolidParticleVertex: ()=>Ey,
  1785. Sound: ()=>Xr,
  1786. SoundTrack: ()=>jr,
  1787. Space: ()=>Ji,
  1788. SphereBuilder: ()=>Nl,
  1789. SphereDirectedParticleEmitter: ()=>vf,
  1790. SphereParticleEmitter: ()=>gf,
  1791. SphericalHarmonics: ()=>Cc,
  1792. SphericalPolynomial: ()=>Pc,
  1793. SpotLight: ()=>Dd,
  1794. Sprite: ()=>Vb,
  1795. SpriteManager: ()=>zb,
  1796. SpriteMap: ()=>Hb,
  1797. SpritePackedManager: ()=>Xb,
  1798. SpriteSceneComponent: ()=>kb,
  1799. Stage: ()=>Hi,
  1800. StandardMaterial: ()=>Os,
  1801. StandardMaterialDefines: ()=>Is,
  1802. StandardRenderingPipeline: ()=>yb,
  1803. StartsWith: ()=>ae,
  1804. StateCondition: ()=>Y,
  1805. StencilOperation: ()=>wu,
  1806. StencilState: ()=>Ot,
  1807. StencilStateComposer: ()=>zt,
  1808. StepBlock: ()=>ig,
  1809. StereoscopicArcRotateCamera: ()=>Qa,
  1810. StereoscopicFreeCamera: ()=>qa,
  1811. StereoscopicGamepadCamera: ()=>Za,
  1812. StereoscopicInterlacePostProcess: ()=>Ya,
  1813. StereoscopicInterlacePostProcessI: ()=>ja,
  1814. StereoscopicScreenUniversalCamera: ()=>$a,
  1815. StereoscopicUniversalCamera: ()=>Ja,
  1816. StickValues: ()=>Go,
  1817. StopAnimationAction: ()=>ee,
  1818. StopSoundAction: ()=>ge,
  1819. StorageBuffer: ()=>wo,
  1820. StorageTextureAccess: ()=>Pu,
  1821. StoreOp: ()=>Wu,
  1822. StringDictionary: ()=>Ei,
  1823. StringTools: ()=>de,
  1824. SubEmitter: ()=>py,
  1825. SubEmitterType: ()=>sy,
  1826. SubMesh: ()=>hr,
  1827. SubSurfaceBlock: ()=>Fg,
  1828. SubSurfaceSceneComponent: ()=>Bb,
  1829. SubtractBlock: ()=>tg,
  1830. SurfaceMagnetismBehavior: ()=>Po,
  1831. SwitchBooleanAction: ()=>Q,
  1832. SwitchInput: ()=>Ni,
  1833. TGATools: ()=>J_,
  1834. Tags: ()=>ye,
  1835. TargetCamera: ()=>da,
  1836. TargetedAnimation: ()=>Wn,
  1837. TextFileAssetTask: ()=>qb,
  1838. Texture: ()=>io,
  1839. TextureAspect: ()=>yu,
  1840. TextureAssetTask: ()=>$b,
  1841. TextureBlock: ()=>Vm,
  1842. TextureDimension: ()=>mu,
  1843. TextureFormat: ()=>bu,
  1844. TextureOptimization: ()=>lT,
  1845. TexturePacker: ()=>_m,
  1846. TexturePackerFrame: ()=>fm,
  1847. TextureSampleType: ()=>Cu,
  1848. TextureSampler: ()=>Nt,
  1849. TextureTools: ()=>Nc,
  1850. TextureUsage: ()=>gu,
  1851. TextureViewDimension: ()=>vu,
  1852. ThinEngine: ()=>Ht,
  1853. ThinMaterialHelper: ()=>Pr,
  1854. ThinRenderTargetTexture: ()=>Tm,
  1855. ThinTexture: ()=>qr,
  1856. TiledBoxBuilder: ()=>gv,
  1857. TiledPlaneBuilder: ()=>fv,
  1858. TimerState: ()=>Nf,
  1859. TmpColors: ()=>L,
  1860. TmpVectors: ()=>I,
  1861. ToGammaSpace: ()=>p,
  1862. ToHalfFloat: ()=>Oc,
  1863. ToLinearSpace: ()=>f,
  1864. TonemapPostProcess: ()=>Tb,
  1865. TonemappingOperator: ()=>bb,
  1866. Tools: ()=>gi,
  1867. TorusBuilder: ()=>Zs,
  1868. TorusKnotBuilder: ()=>bv,
  1869. TouchCamera: ()=>fa,
  1870. TrailMesh: ()=>hv,
  1871. Trajectory: ()=>wT,
  1872. TrajectoryClassifier: ()=>kT,
  1873. TranscodeAsync: ()=>lm,
  1874. TransformBlock: ()=>Hp,
  1875. TransformNode: ()=>yr,
  1876. TrigonometryBlock: ()=>Rf,
  1877. TrigonometryBlockOperations: ()=>Af,
  1878. TubeBuilder: ()=>Dv,
  1879. TwirlBlock: ()=>Lm,
  1880. UniformBuffer: ()=>Fi,
  1881. UniversalCamera: ()=>Na,
  1882. UnregisterAllMaterialPlugins: ()=>xs,
  1883. UnregisterMaterialPlugin: ()=>As,
  1884. UploadContent: ()=>Z_,
  1885. UploadEnvLevelsAsync: ()=>Hc,
  1886. UploadEnvSpherical: ()=>Yc,
  1887. UploadLevelsAsync: ()=>jc,
  1888. UtilityLayerRenderer: ()=>El,
  1889. VRCameraMetrics: ()=>ts,
  1890. VRDeviceOrientationArcRotateCamera: ()=>cs,
  1891. VRDeviceOrientationFreeCamera: ()=>us,
  1892. VRDeviceOrientationGamepadCamera: ()=>hs,
  1893. VRDistortionCorrectionPostProcess: ()=>is,
  1894. VRExperienceHelper: ()=>hl,
  1895. VRMultiviewToSingleviewPostProcess: ()=>ss,
  1896. ValidatedNativeDataStream: ()=>Ku,
  1897. ValueCondition: ()=>X,
  1898. Vector2: ()=>A,
  1899. Vector3: ()=>x,
  1900. Vector4: ()=>R,
  1901. VectorMergerBlock: ()=>sf,
  1902. VectorSplitterBlock: ()=>Jm,
  1903. VertexAnimationBaker: ()=>so,
  1904. VertexBuffer: ()=>Bi,
  1905. VertexData: ()=>$n,
  1906. VertexFormat: ()=>Uu,
  1907. VertexOutputBlock: ()=>jp,
  1908. VideoDome: ()=>Xf,
  1909. VideoRecorder: ()=>ST,
  1910. VideoTexture: ()=>Hf,
  1911. ViewDirectionBlock: ()=>rg,
  1912. Viewport: ()=>xr,
  1913. VirtualJoystick: ()=>ua,
  1914. VirtualJoysticksCamera: ()=>es,
  1915. ViveController: ()=>ud,
  1916. VolumetricLightScatteringPostProcess: ()=>Eb,
  1917. VoronoiNoiseBlock: ()=>Wg,
  1918. WaveBlock: ()=>yg,
  1919. WaveBlockKind: ()=>gg,
  1920. WebGL2ParticleSystem: ()=>oy,
  1921. WebGL2ShaderProcessor: ()=>wt,
  1922. WebGLDataBuffer: ()=>Ut,
  1923. WebGLHardwareTexture: ()=>kt,
  1924. WebGLPipelineContext: ()=>Vt,
  1925. WebGPUCacheBindGroups: ()=>Nh,
  1926. WebGPUCacheRenderPipeline: ()=>Ah,
  1927. WebGPUCacheRenderPipelineTree: ()=>Rh,
  1928. WebGPUCacheSampler: ()=>Th,
  1929. WebGPUDataBuffer: ()=>_h,
  1930. WebGPUDrawContext: ()=>Oh,
  1931. WebGPUEngine: ()=>Qh,
  1932. WebGPUTintWASM: ()=>Yh,
  1933. WebRequest: ()=>Ye,
  1934. WebVRController: ()=>_s,
  1935. WebVRFreeCamera: ()=>fs,
  1936. WebXRAbstractFeature: ()=>wp,
  1937. WebXRAbstractMotionController: ()=>xp,
  1938. WebXRAnchorSystem: ()=>$T,
  1939. WebXRBackgroundRemover: ()=>iE,
  1940. WebXRCamera: ()=>Ep,
  1941. WebXRCompositionLayerWrapper: ()=>AE,
  1942. WebXRControllerComponent: ()=>Ap,
  1943. WebXRControllerMovement: ()=>mE,
  1944. WebXRControllerPhysics: ()=>rE,
  1945. WebXRControllerPointerSelection: ()=>Bp,
  1946. WebXRDefaultExperience: ()=>Gf,
  1947. WebXRDefaultExperienceOptions: ()=>kf,
  1948. WebXRDomOverlay: ()=>_E,
  1949. WebXREnterExitUI: ()=>wf,
  1950. WebXREnterExitUIButton: ()=>Lf,
  1951. WebXREnterExitUIOptions: ()=>Ff,
  1952. WebXRExperienceHelper: ()=>Sp,
  1953. WebXREyeTracking: ()=>vE,
  1954. WebXRFeatureName: ()=>Io,
  1955. WebXRFeaturePointSystem: ()=>sE,
  1956. WebXRFeaturesManager: ()=>Oo,
  1957. WebXRGenericHandController: ()=>OE,
  1958. WebXRGenericTriggerMotionController: ()=>Rp,
  1959. WebXRHTCViveMotionController: ()=>BE,
  1960. WebXRHand: ()=>uE,
  1961. WebXRHandTracking: ()=>hE,
  1962. WebXRHitTest: ()=>oE,
  1963. WebXRHitTestLegacy: ()=>ZT,
  1964. WebXRImageTracking: ()=>fE,
  1965. WebXRInput: ()=>Fp,
  1966. WebXRInputSource: ()=>Lp,
  1967. WebXRLayers: ()=>IE,
  1968. WebXRLightEstimation: ()=>gE,
  1969. WebXRManagedOutputCanvas: ()=>Gs,
  1970. WebXRManagedOutputCanvasOptions: ()=>ks,
  1971. WebXRMeshDetector: ()=>pE,
  1972. WebXRMicrosoftMixedRealityController: ()=>NE,
  1973. WebXRMotionControllerManager: ()=>Ip,
  1974. WebXRMotionControllerTeleportation: ()=>Vf,
  1975. WebXRNearControllerMode: ()=>Pf,
  1976. WebXRNearInteraction: ()=>Df,
  1977. WebXROculusTouchMotionController: ()=>FE,
  1978. WebXRPlaneDetector: ()=>tE,
  1979. WebXRProfiledMotionController: ()=>Pp,
  1980. WebXRProjectionLayerWrapper: ()=>RE,
  1981. WebXRSessionManager: ()=>Xs,
  1982. WebXRState: ()=>Ns,
  1983. WebXRTrackingState: ()=>Ls,
  1984. WebXRWalkingLocomotion: ()=>SE,
  1985. WeightedSound: ()=>Kr,
  1986. WindowsMotionController: ()=>dd,
  1987. WorkerPool: ()=>gp,
  1988. WorleyNoise3DBlock: ()=>Sg,
  1989. XRWindowsMotionController: ()=>pd,
  1990. Xbox360Button: ()=>Sa,
  1991. Xbox360Dpad: ()=>Aa,
  1992. Xbox360Pad: ()=>Ma,
  1993. XboxInput: ()=>Di,
  1994. _BabylonLoaderRegistered: ()=>D_,
  1995. _BasisTextureLoader: ()=>dm,
  1996. _CreationDataStorage: ()=>Lr,
  1997. _DDSTextureLoader: ()=>fp,
  1998. _ENVTextureLoader: ()=>_p,
  1999. _HDRTextureLoader: ()=>em,
  2000. _IAnimationState: ()=>Ke,
  2001. _InstancesBatch: ()=>wr,
  2002. _KTXTextureLoader: ()=>Tp,
  2003. _MeshCollisionData: ()=>br,
  2004. _OcclusionDataStorage: ()=>fc,
  2005. _PrimaryIsoTriangle: ()=>Vv,
  2006. _TGATextureLoader: ()=>$_,
  2007. _TimeToken: ()=>pc,
  2008. _UpdateRGBDAsync: ()=>Kc,
  2009. _forceSceneHelpersToBundle: ()=>zf,
  2010. _forceTransformFeedbackToBundle: ()=>_c,
  2011. _injectLTSFileTools: ()=>ci,
  2012. allocateAndCopyTypedBuffer: ()=>gr,
  2013. className: ()=>vi,
  2014. createDetailMapPlugin: ()=>$g,
  2015. createPBRAnisotropicPlugin: ()=>Kg,
  2016. createPBRBRDFPlugin: ()=>Qg,
  2017. createPBRClearCoatPlugin: ()=>qg,
  2018. createPBRSheenPlugin: ()=>Zg,
  2019. createPBRSubSurfacePlugin: ()=>Jg,
  2020. createYieldingScheduler: ()=>Yn,
  2021. editableInPropertyPage: ()=>Yp,
  2022. expandToProperty: ()=>Re,
  2023. extractMinAndMax: ()=>ur,
  2024. extractMinAndMaxIndexed: ()=>cr,
  2025. inlineScheduler: ()=>jn,
  2026. makeAsyncFunction: ()=>Jn,
  2027. makeSyncFunction: ()=>Zn,
  2028. nativeOverride: ()=>ze,
  2029. normalizeEnvInfo: ()=>kc,
  2030. runCoroutine: ()=>Kn,
  2031. runCoroutineAsync: ()=>qn,
  2032. runCoroutineSync: ()=>Qn,
  2033. serialize: ()=>Ce,
  2034. serializeAsCameraReference: ()=>Ve,
  2035. serializeAsColor3: ()=>Me,
  2036. serializeAsColor4: ()=>Fe,
  2037. serializeAsColorCurves: ()=>Le,
  2038. serializeAsFresnelParameters: ()=>Ie,
  2039. serializeAsImageProcessingConfiguration: ()=>we,
  2040. serializeAsMatrix: ()=>Ue,
  2041. serializeAsMeshReference: ()=>Ne,
  2042. serializeAsQuaternion: ()=>Be,
  2043. serializeAsTexture: ()=>Pe,
  2044. serializeAsVector2: ()=>Oe,
  2045. serializeAsVector3: ()=>De,
  2046. setAndStartTimer: ()=>Bf,
  2047. setStereoscopicAnaglyphRigMode: ()=>Ga,
  2048. setStereoscopicRigMode: ()=>Ka,
  2049. setVRRigMode: ()=>ls,
  2050. setWebVRRigMode: ()=>ps
  2051. });
  2052. var o = function() {
  2053. function e() {
  2054. this.rootNodes = new Array,
  2055. this.cameras = new Array,
  2056. this.lights = new Array,
  2057. this.meshes = new Array,
  2058. this.skeletons = new Array,
  2059. this.particleSystems = new Array,
  2060. this.animations = [],
  2061. this.animationGroups = new Array,
  2062. this.multiMaterials = new Array,
  2063. this.materials = new Array,
  2064. this.morphTargetManagers = new Array,
  2065. this.geometries = new Array,
  2066. this.transformNodes = new Array,
  2067. this.actionManagers = new Array,
  2068. this.textures = new Array,
  2069. this._environmentTexture = null,
  2070. this.postProcesses = new Array
  2071. }
  2072. return e.AddParser = function(e, t) {
  2073. this._BabylonFileParsers[e] = t
  2074. }
  2075. ,
  2076. e.GetParser = function(e) {
  2077. return this._BabylonFileParsers[e] ? this._BabylonFileParsers[e] : null
  2078. }
  2079. ,
  2080. e.AddIndividualParser = function(e, t) {
  2081. this._IndividualBabylonFileParsers[e] = t
  2082. }
  2083. ,
  2084. e.GetIndividualParser = function(e) {
  2085. return this._IndividualBabylonFileParsers[e] ? this._IndividualBabylonFileParsers[e] : null
  2086. }
  2087. ,
  2088. e.Parse = function(e, t, i, n) {
  2089. for (var r in this._BabylonFileParsers)
  2090. Object.prototype.hasOwnProperty.call(this._BabylonFileParsers, r) && this._BabylonFileParsers[r](e, t, i, n)
  2091. }
  2092. ,
  2093. Object.defineProperty(e.prototype, "environmentTexture", {
  2094. get: function() {
  2095. return this._environmentTexture
  2096. },
  2097. set: function(e) {
  2098. this._environmentTexture = e
  2099. },
  2100. enumerable: !1,
  2101. configurable: !0
  2102. }),
  2103. e.prototype.getNodes = function() {
  2104. var e = new Array;
  2105. return e = (e = (e = (e = e.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),
  2106. this.skeletons.forEach((function(t) {
  2107. return e = e.concat(t.bones)
  2108. }
  2109. )),
  2110. e
  2111. }
  2112. ,
  2113. e._BabylonFileParsers = {},
  2114. e._IndividualBabylonFileParsers = {},
  2115. e
  2116. }()
  2117. , a = function() {
  2118. function e() {}
  2119. return e.ALPHA_DISABLE = 0,
  2120. e.ALPHA_ADD = 1,
  2121. e.ALPHA_COMBINE = 2,
  2122. e.ALPHA_SUBTRACT = 3,
  2123. e.ALPHA_MULTIPLY = 4,
  2124. e.ALPHA_MAXIMIZED = 5,
  2125. e.ALPHA_ONEONE = 6,
  2126. e.ALPHA_PREMULTIPLIED = 7,
  2127. e.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
  2128. e.ALPHA_INTERPOLATE = 9,
  2129. e.ALPHA_SCREENMODE = 10,
  2130. e.ALPHA_ONEONE_ONEONE = 11,
  2131. e.ALPHA_ALPHATOCOLOR = 12,
  2132. e.ALPHA_REVERSEONEMINUS = 13,
  2133. e.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14,
  2134. e.ALPHA_ONEONE_ONEZERO = 15,
  2135. e.ALPHA_EXCLUSION = 16,
  2136. e.ALPHA_LAYER_ACCUMULATE = 17,
  2137. e.ALPHA_EQUATION_ADD = 0,
  2138. e.ALPHA_EQUATION_SUBSTRACT = 1,
  2139. e.ALPHA_EQUATION_REVERSE_SUBTRACT = 2,
  2140. e.ALPHA_EQUATION_MAX = 3,
  2141. e.ALPHA_EQUATION_MIN = 4,
  2142. e.ALPHA_EQUATION_DARKEN = 5,
  2143. e.DELAYLOADSTATE_NONE = 0,
  2144. e.DELAYLOADSTATE_LOADED = 1,
  2145. e.DELAYLOADSTATE_LOADING = 2,
  2146. e.DELAYLOADSTATE_NOTLOADED = 4,
  2147. e.NEVER = 512,
  2148. e.ALWAYS = 519,
  2149. e.LESS = 513,
  2150. e.EQUAL = 514,
  2151. e.LEQUAL = 515,
  2152. e.GREATER = 516,
  2153. e.GEQUAL = 518,
  2154. e.NOTEQUAL = 517,
  2155. e.KEEP = 7680,
  2156. e.ZERO = 0,
  2157. e.REPLACE = 7681,
  2158. e.INCR = 7682,
  2159. e.DECR = 7683,
  2160. e.INVERT = 5386,
  2161. e.INCR_WRAP = 34055,
  2162. e.DECR_WRAP = 34056,
  2163. e.TEXTURE_CLAMP_ADDRESSMODE = 0,
  2164. e.TEXTURE_WRAP_ADDRESSMODE = 1,
  2165. e.TEXTURE_MIRROR_ADDRESSMODE = 2,
  2166. e.TEXTURE_CREATIONFLAG_STORAGE = 1,
  2167. e.TEXTUREFORMAT_ALPHA = 0,
  2168. e.TEXTUREFORMAT_LUMINANCE = 1,
  2169. e.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
  2170. e.TEXTUREFORMAT_RGB = 4,
  2171. e.TEXTUREFORMAT_RGBA = 5,
  2172. e.TEXTUREFORMAT_RED = 6,
  2173. e.TEXTUREFORMAT_R = 6,
  2174. e.TEXTUREFORMAT_RG = 7,
  2175. e.TEXTUREFORMAT_RED_INTEGER = 8,
  2176. e.TEXTUREFORMAT_R_INTEGER = 8,
  2177. e.TEXTUREFORMAT_RG_INTEGER = 9,
  2178. e.TEXTUREFORMAT_RGB_INTEGER = 10,
  2179. e.TEXTUREFORMAT_RGBA_INTEGER = 11,
  2180. e.TEXTUREFORMAT_BGRA = 12,
  2181. e.TEXTUREFORMAT_DEPTH24_STENCIL8 = 13,
  2182. e.TEXTUREFORMAT_DEPTH32_FLOAT = 14,
  2183. e.TEXTUREFORMAT_DEPTH16 = 15,
  2184. e.TEXTUREFORMAT_DEPTH24 = 16,
  2185. e.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM = 36492,
  2186. e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 36495,
  2187. e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 36494,
  2188. e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5 = 33779,
  2189. e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3 = 33778,
  2190. e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777,
  2191. e.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776,
  2192. e.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808,
  2193. e.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196,
  2194. e.TEXTURETYPE_UNSIGNED_BYTE = 0,
  2195. e.TEXTURETYPE_UNSIGNED_INT = 0,
  2196. e.TEXTURETYPE_FLOAT = 1,
  2197. e.TEXTURETYPE_HALF_FLOAT = 2,
  2198. e.TEXTURETYPE_BYTE = 3,
  2199. e.TEXTURETYPE_SHORT = 4,
  2200. e.TEXTURETYPE_UNSIGNED_SHORT = 5,
  2201. e.TEXTURETYPE_INT = 6,
  2202. e.TEXTURETYPE_UNSIGNED_INTEGER = 7,
  2203. e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
  2204. e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
  2205. e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
  2206. e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
  2207. e.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
  2208. e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
  2209. e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
  2210. e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
  2211. e.TEXTURETYPE_UNDEFINED = 16,
  2212. e.TEXTURE_NEAREST_SAMPLINGMODE = 1,
  2213. e.TEXTURE_NEAREST_NEAREST = 1,
  2214. e.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
  2215. e.TEXTURE_LINEAR_LINEAR = 2,
  2216. e.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
  2217. e.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
  2218. e.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
  2219. e.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
  2220. e.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
  2221. e.TEXTURE_NEAREST_LINEAR = 7,
  2222. e.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
  2223. e.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
  2224. e.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
  2225. e.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
  2226. e.TEXTURE_LINEAR_NEAREST = 12,
  2227. e.TEXTURE_EXPLICIT_MODE = 0,
  2228. e.TEXTURE_SPHERICAL_MODE = 1,
  2229. e.TEXTURE_PLANAR_MODE = 2,
  2230. e.TEXTURE_CUBIC_MODE = 3,
  2231. e.TEXTURE_PROJECTION_MODE = 4,
  2232. e.TEXTURE_SKYBOX_MODE = 5,
  2233. e.TEXTURE_INVCUBIC_MODE = 6,
  2234. e.TEXTURE_EQUIRECTANGULAR_MODE = 7,
  2235. e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
  2236. e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
  2237. e.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096,
  2238. e.TEXTURE_FILTERING_QUALITY_HIGH = 64,
  2239. e.TEXTURE_FILTERING_QUALITY_MEDIUM = 16,
  2240. e.TEXTURE_FILTERING_QUALITY_LOW = 8,
  2241. e.SCALEMODE_FLOOR = 1,
  2242. e.SCALEMODE_NEAREST = 2,
  2243. e.SCALEMODE_CEILING = 3,
  2244. e.MATERIAL_TextureDirtyFlag = 1,
  2245. e.MATERIAL_LightDirtyFlag = 2,
  2246. e.MATERIAL_FresnelDirtyFlag = 4,
  2247. e.MATERIAL_AttributesDirtyFlag = 8,
  2248. e.MATERIAL_MiscDirtyFlag = 16,
  2249. e.MATERIAL_PrePassDirtyFlag = 32,
  2250. e.MATERIAL_AllDirtyFlag = 63,
  2251. e.MATERIAL_TriangleFillMode = 0,
  2252. e.MATERIAL_WireFrameFillMode = 1,
  2253. e.MATERIAL_PointFillMode = 2,
  2254. e.MATERIAL_PointListDrawMode = 3,
  2255. e.MATERIAL_LineListDrawMode = 4,
  2256. e.MATERIAL_LineLoopDrawMode = 5,
  2257. e.MATERIAL_LineStripDrawMode = 6,
  2258. e.MATERIAL_TriangleStripDrawMode = 7,
  2259. e.MATERIAL_TriangleFanDrawMode = 8,
  2260. e.MATERIAL_ClockWiseSideOrientation = 0,
  2261. e.MATERIAL_CounterClockWiseSideOrientation = 1,
  2262. e.ACTION_NothingTrigger = 0,
  2263. e.ACTION_OnPickTrigger = 1,
  2264. e.ACTION_OnLeftPickTrigger = 2,
  2265. e.ACTION_OnRightPickTrigger = 3,
  2266. e.ACTION_OnCenterPickTrigger = 4,
  2267. e.ACTION_OnPickDownTrigger = 5,
  2268. e.ACTION_OnDoublePickTrigger = 6,
  2269. e.ACTION_OnPickUpTrigger = 7,
  2270. e.ACTION_OnPickOutTrigger = 16,
  2271. e.ACTION_OnLongPressTrigger = 8,
  2272. e.ACTION_OnPointerOverTrigger = 9,
  2273. e.ACTION_OnPointerOutTrigger = 10,
  2274. e.ACTION_OnEveryFrameTrigger = 11,
  2275. e.ACTION_OnIntersectionEnterTrigger = 12,
  2276. e.ACTION_OnIntersectionExitTrigger = 13,
  2277. e.ACTION_OnKeyDownTrigger = 14,
  2278. e.ACTION_OnKeyUpTrigger = 15,
  2279. e.PARTICLES_BILLBOARDMODE_Y = 2,
  2280. e.PARTICLES_BILLBOARDMODE_ALL = 7,
  2281. e.PARTICLES_BILLBOARDMODE_STRETCHED = 8,
  2282. e.MESHES_CULLINGSTRATEGY_STANDARD = 0,
  2283. e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
  2284. e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
  2285. e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
  2286. e.SCENELOADER_NO_LOGGING = 0,
  2287. e.SCENELOADER_MINIMAL_LOGGING = 1,
  2288. e.SCENELOADER_SUMMARY_LOGGING = 2,
  2289. e.SCENELOADER_DETAILED_LOGGING = 3,
  2290. e.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0,
  2291. e.PREPASS_POSITION_TEXTURE_TYPE = 1,
  2292. e.PREPASS_VELOCITY_TEXTURE_TYPE = 2,
  2293. e.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3,
  2294. e.PREPASS_COLOR_TEXTURE_TYPE = 4,
  2295. e.PREPASS_DEPTH_TEXTURE_TYPE = 5,
  2296. e.PREPASS_NORMAL_TEXTURE_TYPE = 6,
  2297. e.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE = 7,
  2298. e.BUFFER_CREATIONFLAG_READ = 1,
  2299. e.BUFFER_CREATIONFLAG_WRITE = 2,
  2300. e.BUFFER_CREATIONFLAG_READWRITE = 3,
  2301. e.BUFFER_CREATIONFLAG_UNIFORM = 4,
  2302. e.BUFFER_CREATIONFLAG_VERTEX = 8,
  2303. e.BUFFER_CREATIONFLAG_INDEX = 16,
  2304. e.BUFFER_CREATIONFLAG_STORAGE = 32,
  2305. e.RENDERPASS_MAIN = 0,
  2306. e.INPUT_ALT_KEY = 18,
  2307. e.INPUT_CTRL_KEY = 17,
  2308. e.INPUT_META_KEY1 = 91,
  2309. e.INPUT_META_KEY2 = 92,
  2310. e.INPUT_META_KEY3 = 93,
  2311. e.INPUT_SHIFT_KEY = 16,
  2312. e.SNAPSHOTRENDERING_STANDARD = 0,
  2313. e.SNAPSHOTRENDERING_FAST = 1,
  2314. e.PERSPECTIVE_CAMERA = 0,
  2315. e.ORTHOGRAPHIC_CAMERA = 1,
  2316. e.FOVMODE_VERTICAL_FIXED = 0,
  2317. e.FOVMODE_HORIZONTAL_FIXED = 1,
  2318. e.RIG_MODE_NONE = 0,
  2319. e.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
  2320. e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
  2321. e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
  2322. e.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
  2323. e.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
  2324. e.RIG_MODE_VR = 20,
  2325. e.RIG_MODE_WEBVR = 21,
  2326. e.RIG_MODE_CUSTOM = 22,
  2327. e.MAX_SUPPORTED_UV_SETS = 6,
  2328. e.GL_ALPHA_EQUATION_ADD = 32774,
  2329. e.GL_ALPHA_EQUATION_MIN = 32775,
  2330. e.GL_ALPHA_EQUATION_MAX = 32776,
  2331. e.GL_ALPHA_EQUATION_SUBTRACT = 32778,
  2332. e.GL_ALPHA_EQUATION_REVERSE_SUBTRACT = 32779,
  2333. e.GL_ALPHA_FUNCTION_SRC = 768,
  2334. e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR = 769,
  2335. e.GL_ALPHA_FUNCTION_SRC_ALPHA = 770,
  2336. e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA = 771,
  2337. e.GL_ALPHA_FUNCTION_DST_ALPHA = 772,
  2338. e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA = 773,
  2339. e.GL_ALPHA_FUNCTION_DST_COLOR = 774,
  2340. e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR = 775,
  2341. e.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED = 776,
  2342. e.GL_ALPHA_FUNCTION_CONSTANT_COLOR = 32769,
  2343. e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR = 32770,
  2344. e.GL_ALPHA_FUNCTION_CONSTANT_ALPHA = 32771,
  2345. e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA = 32772,
  2346. e
  2347. }()
  2348. , s = function() {
  2349. function e() {
  2350. this.hoverCursor = "",
  2351. this.actions = new Array,
  2352. this.isRecursive = !1
  2353. }
  2354. return Object.defineProperty(e, "HasTriggers", {
  2355. get: function() {
  2356. for (var t in e.Triggers)
  2357. if (Object.prototype.hasOwnProperty.call(e.Triggers, t))
  2358. return !0;
  2359. return !1
  2360. },
  2361. enumerable: !1,
  2362. configurable: !0
  2363. }),
  2364. Object.defineProperty(e, "HasPickTriggers", {
  2365. get: function() {
  2366. for (var t in e.Triggers)
  2367. if (Object.prototype.hasOwnProperty.call(e.Triggers, t)) {
  2368. var i = parseInt(t);
  2369. if (i >= a.ACTION_OnPickTrigger && i <= a.ACTION_OnPickUpTrigger)
  2370. return !0
  2371. }
  2372. return !1
  2373. },
  2374. enumerable: !1,
  2375. configurable: !0
  2376. }),
  2377. e.HasSpecificTrigger = function(t) {
  2378. for (var i in e.Triggers)
  2379. if (Object.prototype.hasOwnProperty.call(e.Triggers, i) && parseInt(i) === t)
  2380. return !0;
  2381. return !1
  2382. }
  2383. ,
  2384. e.Triggers = {},
  2385. e
  2386. }()
  2387. , l = function() {
  2388. function e(e, t, i, n) {
  2389. void 0 === t && (t = !1),
  2390. this.initialize(e, t, i, n)
  2391. }
  2392. return e.prototype.initialize = function(e, t, i, n) {
  2393. return void 0 === t && (t = !1),
  2394. this.mask = e,
  2395. this.skipNextObservers = t,
  2396. this.target = i,
  2397. this.currentTarget = n,
  2398. this
  2399. }
  2400. ,
  2401. e
  2402. }()
  2403. , c = function(e, t, i) {
  2404. void 0 === i && (i = null),
  2405. this.callback = e,
  2406. this.mask = t,
  2407. this.scope = i,
  2408. this._willBeUnregistered = !1,
  2409. this.unregisterOnNextCall = !1
  2410. }
  2411. , u = function() {
  2412. function e() {}
  2413. return e.prototype.dispose = function() {
  2414. if (this._observers && this._observables)
  2415. for (var e = 0; e < this._observers.length; e++)
  2416. this._observables[e].remove(this._observers[e]);
  2417. this._observers = null,
  2418. this._observables = null
  2419. }
  2420. ,
  2421. e.Watch = function(t, i, n, r) {
  2422. void 0 === n && (n = -1),
  2423. void 0 === r && (r = null);
  2424. var o = new e;
  2425. o._observers = new Array,
  2426. o._observables = t;
  2427. for (var a = 0, s = t; a < s.length; a++) {
  2428. var l = s[a].add(i, n, !1, r);
  2429. l && o._observers.push(l)
  2430. }
  2431. return o
  2432. }
  2433. ,
  2434. e
  2435. }()
  2436. , h = function() {
  2437. function e(e) {
  2438. this._observers = new Array,
  2439. this._eventState = new l(0),
  2440. e && (this._onObserverAdded = e)
  2441. }
  2442. return e.FromPromise = function(t, i) {
  2443. var n = new e;
  2444. return t.then((function(e) {
  2445. n.notifyObservers(e)
  2446. }
  2447. )).catch((function(e) {
  2448. if (!i)
  2449. throw e;
  2450. i.notifyObservers(e)
  2451. }
  2452. )),
  2453. n
  2454. }
  2455. ,
  2456. Object.defineProperty(e.prototype, "observers", {
  2457. get: function() {
  2458. return this._observers
  2459. },
  2460. enumerable: !1,
  2461. configurable: !0
  2462. }),
  2463. e.prototype.add = function(e, t, i, n, r) {
  2464. if (void 0 === t && (t = -1),
  2465. void 0 === i && (i = !1),
  2466. void 0 === n && (n = null),
  2467. void 0 === r && (r = !1),
  2468. !e)
  2469. return null;
  2470. var o = new c(e,t,n);
  2471. return o.unregisterOnNextCall = r,
  2472. i ? this._observers.unshift(o) : this._observers.push(o),
  2473. this._onObserverAdded && this._onObserverAdded(o),
  2474. o
  2475. }
  2476. ,
  2477. e.prototype.addOnce = function(e) {
  2478. return this.add(e, void 0, void 0, void 0, !0)
  2479. }
  2480. ,
  2481. e.prototype.remove = function(e) {
  2482. return !!e && -1 !== this._observers.indexOf(e) && (this._deferUnregister(e),
  2483. !0)
  2484. }
  2485. ,
  2486. e.prototype.removeCallback = function(e, t) {
  2487. for (var i = 0; i < this._observers.length; i++) {
  2488. var n = this._observers[i];
  2489. if (!(n._willBeUnregistered || n.callback !== e || t && t !== n.scope))
  2490. return this._deferUnregister(n),
  2491. !0
  2492. }
  2493. return !1
  2494. }
  2495. ,
  2496. e.prototype._deferUnregister = function(e) {
  2497. var t = this;
  2498. e.unregisterOnNextCall = !1,
  2499. e._willBeUnregistered = !0,
  2500. setTimeout((function() {
  2501. t._remove(e)
  2502. }
  2503. ), 0)
  2504. }
  2505. ,
  2506. e.prototype._remove = function(e) {
  2507. if (!e)
  2508. return !1;
  2509. var t = this._observers.indexOf(e);
  2510. return -1 !== t && (this._observers.splice(t, 1),
  2511. !0)
  2512. }
  2513. ,
  2514. e.prototype.makeObserverTopPriority = function(e) {
  2515. this._remove(e),
  2516. this._observers.unshift(e)
  2517. }
  2518. ,
  2519. e.prototype.makeObserverBottomPriority = function(e) {
  2520. this._remove(e),
  2521. this._observers.push(e)
  2522. }
  2523. ,
  2524. e.prototype.notifyObservers = function(e, t, i, n, r) {
  2525. if (void 0 === t && (t = -1),
  2526. !this._observers.length)
  2527. return !0;
  2528. var o = this._eventState;
  2529. o.mask = t,
  2530. o.target = i,
  2531. o.currentTarget = n,
  2532. o.skipNextObservers = !1,
  2533. o.lastReturnValue = e,
  2534. o.userInfo = r;
  2535. for (var a = 0, s = this._observers; a < s.length; a++) {
  2536. var l = s[a];
  2537. if (!l._willBeUnregistered && (l.mask & t && (l.scope ? o.lastReturnValue = l.callback.apply(l.scope, [e, o]) : o.lastReturnValue = l.callback(e, o),
  2538. l.unregisterOnNextCall && this._deferUnregister(l)),
  2539. o.skipNextObservers))
  2540. return !1
  2541. }
  2542. return !0
  2543. }
  2544. ,
  2545. e.prototype.notifyObserversWithPromise = function(e, t, i, n, r) {
  2546. var o = this;
  2547. void 0 === t && (t = -1);
  2548. var a = Promise.resolve(e);
  2549. if (!this._observers.length)
  2550. return a;
  2551. var s = this._eventState;
  2552. return s.mask = t,
  2553. s.target = i,
  2554. s.currentTarget = n,
  2555. s.skipNextObservers = !1,
  2556. s.userInfo = r,
  2557. this._observers.forEach((function(i) {
  2558. s.skipNextObservers || i._willBeUnregistered || i.mask & t && (a = i.scope ? a.then((function(t) {
  2559. return s.lastReturnValue = t,
  2560. i.callback.apply(i.scope, [e, s])
  2561. }
  2562. )) : a.then((function(t) {
  2563. return s.lastReturnValue = t,
  2564. i.callback(e, s)
  2565. }
  2566. )),
  2567. i.unregisterOnNextCall && o._deferUnregister(i))
  2568. }
  2569. )),
  2570. a.then((function() {
  2571. return e
  2572. }
  2573. ))
  2574. }
  2575. ,
  2576. e.prototype.notifyObserver = function(e, t, i) {
  2577. if (void 0 === i && (i = -1),
  2578. !e._willBeUnregistered) {
  2579. var n = this._eventState;
  2580. n.mask = i,
  2581. n.skipNextObservers = !1,
  2582. e.callback(t, n),
  2583. e.unregisterOnNextCall && this._deferUnregister(e)
  2584. }
  2585. }
  2586. ,
  2587. e.prototype.hasObservers = function() {
  2588. return this._observers.length > 0
  2589. }
  2590. ,
  2591. e.prototype.clear = function() {
  2592. this._observers = new Array,
  2593. this._onObserverAdded = null
  2594. }
  2595. ,
  2596. e.prototype.clone = function() {
  2597. var t = new e;
  2598. return t._observers = this._observers.slice(0),
  2599. t
  2600. }
  2601. ,
  2602. e.prototype.hasSpecificMask = function(e) {
  2603. void 0 === e && (e = -1);
  2604. for (var t = 0, i = this._observers; t < i.length; t++) {
  2605. var n = i[t];
  2606. if (n.mask & e || n.mask === e)
  2607. return !0
  2608. }
  2609. return !1
  2610. }
  2611. ,
  2612. e
  2613. }()
  2614. , d = function() {
  2615. function e() {}
  2616. return e.WithinEpsilon = function(e, t, i) {
  2617. return void 0 === i && (i = 1401298e-51),
  2618. Math.abs(e - t) <= i
  2619. }
  2620. ,
  2621. e.ToHex = function(e) {
  2622. var t = e.toString(16);
  2623. return e <= 15 ? ("0" + t).toUpperCase() : t.toUpperCase()
  2624. }
  2625. ,
  2626. e.Sign = function(e) {
  2627. return 0 == (e = +e) || isNaN(e) ? e : e > 0 ? 1 : -1
  2628. }
  2629. ,
  2630. e.Clamp = function(e, t, i) {
  2631. return void 0 === t && (t = 0),
  2632. void 0 === i && (i = 1),
  2633. Math.min(i, Math.max(t, e))
  2634. }
  2635. ,
  2636. e.Log2 = function(e) {
  2637. return Math.log(e) * Math.LOG2E
  2638. }
  2639. ,
  2640. e.ILog2 = function(e) {
  2641. if (Math.log2)
  2642. return Math.floor(Math.log2(e));
  2643. if (e < 0)
  2644. return NaN;
  2645. if (0 === e)
  2646. return -1 / 0;
  2647. var t = 0;
  2648. if (e < 1) {
  2649. for (; e < 1; )
  2650. t++,
  2651. e *= 2;
  2652. t = -t
  2653. } else if (e > 1)
  2654. for (; e > 1; )
  2655. t++,
  2656. e = Math.floor(e / 2);
  2657. return t
  2658. }
  2659. ,
  2660. e.Repeat = function(e, t) {
  2661. return e - Math.floor(e / t) * t
  2662. }
  2663. ,
  2664. e.Normalize = function(e, t, i) {
  2665. return (e - t) / (i - t)
  2666. }
  2667. ,
  2668. e.Denormalize = function(e, t, i) {
  2669. return e * (i - t) + t
  2670. }
  2671. ,
  2672. e.DeltaAngle = function(t, i) {
  2673. var n = e.Repeat(i - t, 360);
  2674. return n > 180 && (n -= 360),
  2675. n
  2676. }
  2677. ,
  2678. e.PingPong = function(t, i) {
  2679. var n = e.Repeat(t, 2 * i);
  2680. return i - Math.abs(n - i)
  2681. }
  2682. ,
  2683. e.SmoothStep = function(t, i, n) {
  2684. var r = e.Clamp(n);
  2685. return i * (r = -2 * r * r * r + 3 * r * r) + t * (1 - r)
  2686. }
  2687. ,
  2688. e.MoveTowards = function(t, i, n) {
  2689. return Math.abs(i - t) <= n ? i : t + e.Sign(i - t) * n
  2690. }
  2691. ,
  2692. e.MoveTowardsAngle = function(t, i, n) {
  2693. var r = e.DeltaAngle(t, i)
  2694. , o = 0;
  2695. return -n < r && r < n ? o = i : (i = t + r,
  2696. o = e.MoveTowards(t, i, n)),
  2697. o
  2698. }
  2699. ,
  2700. e.Lerp = function(e, t, i) {
  2701. return e + (t - e) * i
  2702. }
  2703. ,
  2704. e.LerpAngle = function(t, i, n) {
  2705. var r = e.Repeat(i - t, 360);
  2706. return r > 180 && (r -= 360),
  2707. t + r * e.Clamp(n)
  2708. }
  2709. ,
  2710. e.InverseLerp = function(t, i, n) {
  2711. return t != i ? e.Clamp((n - t) / (i - t)) : 0
  2712. }
  2713. ,
  2714. e.Hermite = function(e, t, i, n, r) {
  2715. var o = r * r
  2716. , a = r * o;
  2717. return e * (2 * a - 3 * o + 1) + i * (-2 * a + 3 * o) + t * (a - 2 * o + r) + n * (a - o)
  2718. }
  2719. ,
  2720. e.Hermite1stDerivative = function(e, t, i, n, r) {
  2721. var o = r * r;
  2722. return 6 * (o - r) * e + (3 * o - 4 * r + 1) * t + 6 * (-o + r) * i + (3 * o - 2 * r) * n
  2723. }
  2724. ,
  2725. e.RandomRange = function(e, t) {
  2726. return e === t ? e : Math.random() * (t - e) + e
  2727. }
  2728. ,
  2729. e.RangeToPercent = function(e, t, i) {
  2730. return (e - t) / (i - t)
  2731. }
  2732. ,
  2733. e.PercentToRange = function(e, t, i) {
  2734. return (i - t) * e + t
  2735. }
  2736. ,
  2737. e.NormalizeRadians = function(t) {
  2738. return t - e.TwoPi * Math.floor((t + Math.PI) / e.TwoPi)
  2739. }
  2740. ,
  2741. e.HCF = function(t, i) {
  2742. var n = t % i;
  2743. return 0 === n ? i : e.HCF(i, n)
  2744. }
  2745. ,
  2746. e.TwoPi = 2 * Math.PI,
  2747. e
  2748. }()
  2749. , p = 1 / 2.2
  2750. , f = 2.2
  2751. , _ = (1 + Math.sqrt(5)) / 2
  2752. , m = .001
  2753. , g = function() {
  2754. function e() {}
  2755. return e.BuildArray = function(e, t) {
  2756. for (var i = [], n = 0; n < e; ++n)
  2757. i.push(t());
  2758. return i
  2759. }
  2760. ,
  2761. e.BuildTuple = function(t, i) {
  2762. return e.BuildArray(t, i)
  2763. }
  2764. ,
  2765. e
  2766. }()
  2767. , v = {};
  2768. function y(e, t) {
  2769. v[e] = t
  2770. }
  2771. function b(e) {
  2772. return v[e]
  2773. }
  2774. var T = function() {
  2775. function e() {}
  2776. return e.SetMatrixPrecision = function(t) {
  2777. if (e.MatrixTrackPrecisionChange = !1,
  2778. t && !e.MatrixUse64Bits && e.MatrixTrackedMatrices)
  2779. for (var i = 0; i < e.MatrixTrackedMatrices.length; ++i) {
  2780. var n = e.MatrixTrackedMatrices[i]
  2781. , r = n._m;
  2782. n._m = new Array(16);
  2783. for (var o = 0; o < 16; ++o)
  2784. n._m[o] = r[o]
  2785. }
  2786. e.MatrixUse64Bits = t,
  2787. e.MatrixCurrentType = e.MatrixUse64Bits ? Array : Float32Array,
  2788. e.MatrixTrackedMatrices = null
  2789. }
  2790. ,
  2791. e.MatrixUse64Bits = !1,
  2792. e.MatrixTrackPrecisionChange = !0,
  2793. e.MatrixCurrentType = Float32Array,
  2794. e.MatrixTrackedMatrices = [],
  2795. e
  2796. }()
  2797. , E = function() {
  2798. function e() {}
  2799. return Object.defineProperty(e, "LastCreatedEngine", {
  2800. get: function() {
  2801. return 0 === this.Instances.length ? null : this.Instances[this.Instances.length - 1]
  2802. },
  2803. enumerable: !1,
  2804. configurable: !0
  2805. }),
  2806. Object.defineProperty(e, "LastCreatedScene", {
  2807. get: function() {
  2808. return this._LastCreatedScene
  2809. },
  2810. enumerable: !1,
  2811. configurable: !0
  2812. }),
  2813. e.Instances = new Array,
  2814. e._LastCreatedScene = null,
  2815. e.UseFallbackTexture = !0,
  2816. e.FallbackTexture = "",
  2817. e
  2818. }()
  2819. , S = function(e) {
  2820. return parseInt(e.toString().replace(/\W/g, ""))
  2821. }
  2822. , A = function() {
  2823. function e(e, t) {
  2824. void 0 === e && (e = 0),
  2825. void 0 === t && (t = 0),
  2826. this.x = e,
  2827. this.y = t
  2828. }
  2829. return e.prototype.toString = function() {
  2830. return "{X: ".concat(this.x, " Y: ").concat(this.y, "}")
  2831. }
  2832. ,
  2833. e.prototype.getClassName = function() {
  2834. return "Vector2"
  2835. }
  2836. ,
  2837. e.prototype.getHashCode = function() {
  2838. var e = S(this.x);
  2839. return 397 * e ^ S(this.y)
  2840. }
  2841. ,
  2842. e.prototype.toArray = function(e, t) {
  2843. return void 0 === t && (t = 0),
  2844. e[t] = this.x,
  2845. e[t + 1] = this.y,
  2846. this
  2847. }
  2848. ,
  2849. e.prototype.fromArray = function(t, i) {
  2850. return void 0 === i && (i = 0),
  2851. e.FromArrayToRef(t, i, this),
  2852. this
  2853. }
  2854. ,
  2855. e.prototype.asArray = function() {
  2856. var e = new Array;
  2857. return this.toArray(e, 0),
  2858. e
  2859. }
  2860. ,
  2861. e.prototype.copyFrom = function(e) {
  2862. return this.x = e.x,
  2863. this.y = e.y,
  2864. this
  2865. }
  2866. ,
  2867. e.prototype.copyFromFloats = function(e, t) {
  2868. return this.x = e,
  2869. this.y = t,
  2870. this
  2871. }
  2872. ,
  2873. e.prototype.set = function(e, t) {
  2874. return this.copyFromFloats(e, t)
  2875. }
  2876. ,
  2877. e.prototype.add = function(t) {
  2878. return new e(this.x + t.x,this.y + t.y)
  2879. }
  2880. ,
  2881. e.prototype.addToRef = function(e, t) {
  2882. return t.x = this.x + e.x,
  2883. t.y = this.y + e.y,
  2884. this
  2885. }
  2886. ,
  2887. e.prototype.addInPlace = function(e) {
  2888. return this.x += e.x,
  2889. this.y += e.y,
  2890. this
  2891. }
  2892. ,
  2893. e.prototype.addVector3 = function(t) {
  2894. return new e(this.x + t.x,this.y + t.y)
  2895. }
  2896. ,
  2897. e.prototype.subtract = function(t) {
  2898. return new e(this.x - t.x,this.y - t.y)
  2899. }
  2900. ,
  2901. e.prototype.subtractToRef = function(e, t) {
  2902. return t.x = this.x - e.x,
  2903. t.y = this.y - e.y,
  2904. this
  2905. }
  2906. ,
  2907. e.prototype.subtractInPlace = function(e) {
  2908. return this.x -= e.x,
  2909. this.y -= e.y,
  2910. this
  2911. }
  2912. ,
  2913. e.prototype.multiplyInPlace = function(e) {
  2914. return this.x *= e.x,
  2915. this.y *= e.y,
  2916. this
  2917. }
  2918. ,
  2919. e.prototype.multiply = function(t) {
  2920. return new e(this.x * t.x,this.y * t.y)
  2921. }
  2922. ,
  2923. e.prototype.multiplyToRef = function(e, t) {
  2924. return t.x = this.x * e.x,
  2925. t.y = this.y * e.y,
  2926. this
  2927. }
  2928. ,
  2929. e.prototype.multiplyByFloats = function(t, i) {
  2930. return new e(this.x * t,this.y * i)
  2931. }
  2932. ,
  2933. e.prototype.divide = function(t) {
  2934. return new e(this.x / t.x,this.y / t.y)
  2935. }
  2936. ,
  2937. e.prototype.divideToRef = function(e, t) {
  2938. return t.x = this.x / e.x,
  2939. t.y = this.y / e.y,
  2940. this
  2941. }
  2942. ,
  2943. e.prototype.divideInPlace = function(e) {
  2944. return this.divideToRef(e, this)
  2945. }
  2946. ,
  2947. e.prototype.negate = function() {
  2948. return new e(-this.x,-this.y)
  2949. }
  2950. ,
  2951. e.prototype.negateInPlace = function() {
  2952. return this.x *= -1,
  2953. this.y *= -1,
  2954. this
  2955. }
  2956. ,
  2957. e.prototype.negateToRef = function(e) {
  2958. return e.copyFromFloats(-1 * this.x, -1 * this.y)
  2959. }
  2960. ,
  2961. e.prototype.scaleInPlace = function(e) {
  2962. return this.x *= e,
  2963. this.y *= e,
  2964. this
  2965. }
  2966. ,
  2967. e.prototype.scale = function(t) {
  2968. var i = new e(0,0);
  2969. return this.scaleToRef(t, i),
  2970. i
  2971. }
  2972. ,
  2973. e.prototype.scaleToRef = function(e, t) {
  2974. return t.x = this.x * e,
  2975. t.y = this.y * e,
  2976. this
  2977. }
  2978. ,
  2979. e.prototype.scaleAndAddToRef = function(e, t) {
  2980. return t.x += this.x * e,
  2981. t.y += this.y * e,
  2982. this
  2983. }
  2984. ,
  2985. e.prototype.equals = function(e) {
  2986. return e && this.x === e.x && this.y === e.y
  2987. }
  2988. ,
  2989. e.prototype.equalsWithEpsilon = function(e, t) {
  2990. return void 0 === t && (t = m),
  2991. e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t)
  2992. }
  2993. ,
  2994. e.prototype.floor = function() {
  2995. return new e(Math.floor(this.x),Math.floor(this.y))
  2996. }
  2997. ,
  2998. e.prototype.fract = function() {
  2999. return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
  3000. }
  3001. ,
  3002. e.prototype.rotateToRef = function(e, t) {
  3003. var i = Math.cos(e)
  3004. , n = Math.sin(e);
  3005. return t.x = i * this.x - n * this.y,
  3006. t.y = n * this.x + i * this.y,
  3007. this
  3008. }
  3009. ,
  3010. e.prototype.length = function() {
  3011. return Math.sqrt(this.x * this.x + this.y * this.y)
  3012. }
  3013. ,
  3014. e.prototype.lengthSquared = function() {
  3015. return this.x * this.x + this.y * this.y
  3016. }
  3017. ,
  3018. e.prototype.normalize = function() {
  3019. return e.NormalizeToRef(this, this),
  3020. this
  3021. }
  3022. ,
  3023. e.prototype.clone = function() {
  3024. return new e(this.x,this.y)
  3025. }
  3026. ,
  3027. e.Zero = function() {
  3028. return new e(0,0)
  3029. }
  3030. ,
  3031. e.One = function() {
  3032. return new e(1,1)
  3033. }
  3034. ,
  3035. e.FromArray = function(t, i) {
  3036. return void 0 === i && (i = 0),
  3037. new e(t[i],t[i + 1])
  3038. }
  3039. ,
  3040. e.FromArrayToRef = function(e, t, i) {
  3041. i.x = e[t],
  3042. i.y = e[t + 1]
  3043. }
  3044. ,
  3045. e.CatmullRom = function(t, i, n, r, o) {
  3046. var a = o * o
  3047. , s = o * a;
  3048. return new e(.5 * (2 * i.x + (-t.x + n.x) * o + (2 * t.x - 5 * i.x + 4 * n.x - r.x) * a + (-t.x + 3 * i.x - 3 * n.x + r.x) * s),.5 * (2 * i.y + (-t.y + n.y) * o + (2 * t.y - 5 * i.y + 4 * n.y - r.y) * a + (-t.y + 3 * i.y - 3 * n.y + r.y) * s))
  3049. }
  3050. ,
  3051. e.Clamp = function(t, i, n) {
  3052. var r = t.x;
  3053. r = (r = r > n.x ? n.x : r) < i.x ? i.x : r;
  3054. var o = t.y;
  3055. return new e(r,o = (o = o > n.y ? n.y : o) < i.y ? i.y : o)
  3056. }
  3057. ,
  3058. e.Hermite = function(t, i, n, r, o) {
  3059. var a = o * o
  3060. , s = o * a
  3061. , l = 2 * s - 3 * a + 1
  3062. , c = -2 * s + 3 * a
  3063. , u = s - 2 * a + o
  3064. , h = s - a;
  3065. return new e(t.x * l + n.x * c + i.x * u + r.x * h,t.y * l + n.y * c + i.y * u + r.y * h)
  3066. }
  3067. ,
  3068. e.Hermite1stDerivative = function(t, i, n, r, o) {
  3069. var a = e.Zero();
  3070. return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
  3071. a
  3072. }
  3073. ,
  3074. e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
  3075. var a = r * r;
  3076. o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
  3077. o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y
  3078. }
  3079. ,
  3080. e.Lerp = function(t, i, n) {
  3081. return new e(t.x + (i.x - t.x) * n,t.y + (i.y - t.y) * n)
  3082. }
  3083. ,
  3084. e.Dot = function(e, t) {
  3085. return e.x * t.x + e.y * t.y
  3086. }
  3087. ,
  3088. e.Normalize = function(t) {
  3089. var i = e.Zero();
  3090. return this.NormalizeToRef(t, i),
  3091. i
  3092. }
  3093. ,
  3094. e.NormalizeToRef = function(e, t) {
  3095. var i = e.length();
  3096. 0 !== i && (t.x = e.x / i,
  3097. t.y = e.y / i)
  3098. }
  3099. ,
  3100. e.Minimize = function(t, i) {
  3101. return new e(t.x < i.x ? t.x : i.x,t.y < i.y ? t.y : i.y)
  3102. }
  3103. ,
  3104. e.Maximize = function(t, i) {
  3105. return new e(t.x > i.x ? t.x : i.x,t.y > i.y ? t.y : i.y)
  3106. }
  3107. ,
  3108. e.Transform = function(t, i) {
  3109. var n = e.Zero();
  3110. return e.TransformToRef(t, i, n),
  3111. n
  3112. }
  3113. ,
  3114. e.TransformToRef = function(e, t, i) {
  3115. var n = t.m
  3116. , r = e.x * n[0] + e.y * n[4] + n[12]
  3117. , o = e.x * n[1] + e.y * n[5] + n[13];
  3118. i.x = r,
  3119. i.y = o
  3120. }
  3121. ,
  3122. e.PointInTriangle = function(e, t, i, n) {
  3123. var r = .5 * (-i.y * n.x + t.y * (-i.x + n.x) + t.x * (i.y - n.y) + i.x * n.y)
  3124. , o = r < 0 ? -1 : 1
  3125. , a = (t.y * n.x - t.x * n.y + (n.y - t.y) * e.x + (t.x - n.x) * e.y) * o
  3126. , s = (t.x * i.y - t.y * i.x + (t.y - i.y) * e.x + (i.x - t.x) * e.y) * o;
  3127. return a > 0 && s > 0 && a + s < 2 * r * o
  3128. }
  3129. ,
  3130. e.Distance = function(t, i) {
  3131. return Math.sqrt(e.DistanceSquared(t, i))
  3132. }
  3133. ,
  3134. e.DistanceSquared = function(e, t) {
  3135. var i = e.x - t.x
  3136. , n = e.y - t.y;
  3137. return i * i + n * n
  3138. }
  3139. ,
  3140. e.Center = function(t, i) {
  3141. return e.CenterToRef(t, i, e.Zero())
  3142. }
  3143. ,
  3144. e.CenterToRef = function(e, t, i) {
  3145. return i.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2)
  3146. }
  3147. ,
  3148. e.DistanceOfPointFromSegment = function(t, i, n) {
  3149. var r = e.DistanceSquared(i, n);
  3150. if (0 === r)
  3151. return e.Distance(t, i);
  3152. var o = n.subtract(i)
  3153. , a = Math.max(0, Math.min(1, e.Dot(t.subtract(i), o) / r))
  3154. , s = i.add(o.multiplyByFloats(a, a));
  3155. return e.Distance(t, s)
  3156. }
  3157. ,
  3158. e
  3159. }()
  3160. , x = function() {
  3161. function e(e, t, i) {
  3162. void 0 === e && (e = 0),
  3163. void 0 === t && (t = 0),
  3164. void 0 === i && (i = 0),
  3165. this._isDirty = !0,
  3166. this._x = e,
  3167. this._y = t,
  3168. this._z = i
  3169. }
  3170. return Object.defineProperty(e.prototype, "x", {
  3171. get: function() {
  3172. return this._x
  3173. },
  3174. set: function(e) {
  3175. this._x = e,
  3176. this._isDirty = !0
  3177. },
  3178. enumerable: !1,
  3179. configurable: !0
  3180. }),
  3181. Object.defineProperty(e.prototype, "y", {
  3182. get: function() {
  3183. return this._y
  3184. },
  3185. set: function(e) {
  3186. this._y = e,
  3187. this._isDirty = !0
  3188. },
  3189. enumerable: !1,
  3190. configurable: !0
  3191. }),
  3192. Object.defineProperty(e.prototype, "z", {
  3193. get: function() {
  3194. return this._z
  3195. },
  3196. set: function(e) {
  3197. this._z = e,
  3198. this._isDirty = !0
  3199. },
  3200. enumerable: !1,
  3201. configurable: !0
  3202. }),
  3203. e.prototype.toString = function() {
  3204. return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, "}")
  3205. }
  3206. ,
  3207. e.prototype.getClassName = function() {
  3208. return "Vector3"
  3209. }
  3210. ,
  3211. e.prototype.getHashCode = function() {
  3212. var e = S(this._x);
  3213. return 397 * (e = 397 * e ^ S(this._y)) ^ S(this._z)
  3214. }
  3215. ,
  3216. e.prototype.asArray = function() {
  3217. var e = [];
  3218. return this.toArray(e, 0),
  3219. e
  3220. }
  3221. ,
  3222. e.prototype.toArray = function(e, t) {
  3223. return void 0 === t && (t = 0),
  3224. e[t] = this._x,
  3225. e[t + 1] = this._y,
  3226. e[t + 2] = this._z,
  3227. this
  3228. }
  3229. ,
  3230. e.prototype.fromArray = function(t, i) {
  3231. return void 0 === i && (i = 0),
  3232. e.FromArrayToRef(t, i, this),
  3233. this
  3234. }
  3235. ,
  3236. e.prototype.toQuaternion = function() {
  3237. return C.RotationYawPitchRoll(this._y, this._x, this._z)
  3238. }
  3239. ,
  3240. e.prototype.addInPlace = function(e) {
  3241. return this.addInPlaceFromFloats(e._x, e._y, e._z)
  3242. }
  3243. ,
  3244. e.prototype.addInPlaceFromFloats = function(e, t, i) {
  3245. return this.x += e,
  3246. this.y += t,
  3247. this.z += i,
  3248. this
  3249. }
  3250. ,
  3251. e.prototype.add = function(t) {
  3252. return new e(this._x + t._x,this._y + t._y,this._z + t._z)
  3253. }
  3254. ,
  3255. e.prototype.addToRef = function(e, t) {
  3256. return t.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
  3257. }
  3258. ,
  3259. e.prototype.subtractInPlace = function(e) {
  3260. return this.x -= e._x,
  3261. this.y -= e._y,
  3262. this.z -= e._z,
  3263. this
  3264. }
  3265. ,
  3266. e.prototype.subtract = function(t) {
  3267. return new e(this._x - t._x,this._y - t._y,this._z - t._z)
  3268. }
  3269. ,
  3270. e.prototype.subtractToRef = function(e, t) {
  3271. return this.subtractFromFloatsToRef(e._x, e._y, e._z, t)
  3272. }
  3273. ,
  3274. e.prototype.subtractFromFloats = function(t, i, n) {
  3275. return new e(this._x - t,this._y - i,this._z - n)
  3276. }
  3277. ,
  3278. e.prototype.subtractFromFloatsToRef = function(e, t, i, n) {
  3279. return n.copyFromFloats(this._x - e, this._y - t, this._z - i)
  3280. }
  3281. ,
  3282. e.prototype.negate = function() {
  3283. return new e(-this._x,-this._y,-this._z)
  3284. }
  3285. ,
  3286. e.prototype.negateInPlace = function() {
  3287. return this.x *= -1,
  3288. this.y *= -1,
  3289. this.z *= -1,
  3290. this
  3291. }
  3292. ,
  3293. e.prototype.negateToRef = function(e) {
  3294. return e.copyFromFloats(-1 * this._x, -1 * this._y, -1 * this._z)
  3295. }
  3296. ,
  3297. e.prototype.scaleInPlace = function(e) {
  3298. return this.x *= e,
  3299. this.y *= e,
  3300. this.z *= e,
  3301. this
  3302. }
  3303. ,
  3304. e.prototype.scale = function(t) {
  3305. return new e(this._x * t,this._y * t,this._z * t)
  3306. }
  3307. ,
  3308. e.prototype.scaleToRef = function(e, t) {
  3309. return t.copyFromFloats(this._x * e, this._y * e, this._z * e)
  3310. }
  3311. ,
  3312. e.prototype.scaleAndAddToRef = function(e, t) {
  3313. return t.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
  3314. }
  3315. ,
  3316. e.prototype.projectOnPlane = function(t, i) {
  3317. var n = e.Zero();
  3318. return this.projectOnPlaneToRef(t, i, n),
  3319. n
  3320. }
  3321. ,
  3322. e.prototype.projectOnPlaneToRef = function(t, i, n) {
  3323. var r = t.normal
  3324. , o = t.d
  3325. , a = M.Vector3[0];
  3326. this.subtractToRef(i, a),
  3327. a.normalize();
  3328. var s = e.Dot(a, r)
  3329. , l = -(e.Dot(i, r) + o) / s
  3330. , c = a.scaleInPlace(l);
  3331. i.addToRef(c, n)
  3332. }
  3333. ,
  3334. e.prototype.equals = function(e) {
  3335. return e && this._x === e._x && this._y === e._y && this._z === e._z
  3336. }
  3337. ,
  3338. e.prototype.equalsWithEpsilon = function(e, t) {
  3339. return void 0 === t && (t = m),
  3340. e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.WithinEpsilon(this._z, e._z, t)
  3341. }
  3342. ,
  3343. e.prototype.equalsToFloats = function(e, t, i) {
  3344. return this._x === e && this._y === t && this._z === i
  3345. }
  3346. ,
  3347. e.prototype.multiplyInPlace = function(e) {
  3348. return this.x *= e._x,
  3349. this.y *= e._y,
  3350. this.z *= e._z,
  3351. this
  3352. }
  3353. ,
  3354. e.prototype.multiply = function(e) {
  3355. return this.multiplyByFloats(e._x, e._y, e._z)
  3356. }
  3357. ,
  3358. e.prototype.multiplyToRef = function(e, t) {
  3359. return t.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
  3360. }
  3361. ,
  3362. e.prototype.multiplyByFloats = function(t, i, n) {
  3363. return new e(this._x * t,this._y * i,this._z * n)
  3364. }
  3365. ,
  3366. e.prototype.divide = function(t) {
  3367. return new e(this._x / t._x,this._y / t._y,this._z / t._z)
  3368. }
  3369. ,
  3370. e.prototype.divideToRef = function(e, t) {
  3371. return t.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
  3372. }
  3373. ,
  3374. e.prototype.divideInPlace = function(e) {
  3375. return this.divideToRef(e, this)
  3376. }
  3377. ,
  3378. e.prototype.minimizeInPlace = function(e) {
  3379. return this.minimizeInPlaceFromFloats(e._x, e._y, e._z)
  3380. }
  3381. ,
  3382. e.prototype.maximizeInPlace = function(e) {
  3383. return this.maximizeInPlaceFromFloats(e._x, e._y, e._z)
  3384. }
  3385. ,
  3386. e.prototype.minimizeInPlaceFromFloats = function(e, t, i) {
  3387. return e < this._x && (this.x = e),
  3388. t < this._y && (this.y = t),
  3389. i < this._z && (this.z = i),
  3390. this
  3391. }
  3392. ,
  3393. e.prototype.maximizeInPlaceFromFloats = function(e, t, i) {
  3394. return e > this._x && (this.x = e),
  3395. t > this._y && (this.y = t),
  3396. i > this._z && (this.z = i),
  3397. this
  3398. }
  3399. ,
  3400. e.prototype.isNonUniformWithinEpsilon = function(e) {
  3401. var t = Math.abs(this._x)
  3402. , i = Math.abs(this._y);
  3403. if (!d.WithinEpsilon(t, i, e))
  3404. return !0;
  3405. var n = Math.abs(this._z);
  3406. return !d.WithinEpsilon(t, n, e) || !d.WithinEpsilon(i, n, e)
  3407. }
  3408. ,
  3409. Object.defineProperty(e.prototype, "isNonUniform", {
  3410. get: function() {
  3411. var e = Math.abs(this._x);
  3412. return e !== Math.abs(this._y) || e !== Math.abs(this._z)
  3413. },
  3414. enumerable: !1,
  3415. configurable: !0
  3416. }),
  3417. e.prototype.floor = function() {
  3418. return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
  3419. }
  3420. ,
  3421. e.prototype.fract = function() {
  3422. return new e(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
  3423. }
  3424. ,
  3425. e.prototype.length = function() {
  3426. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z)
  3427. }
  3428. ,
  3429. e.prototype.lengthSquared = function() {
  3430. return this._x * this._x + this._y * this._y + this._z * this._z
  3431. }
  3432. ,
  3433. e.prototype.normalize = function() {
  3434. return this.normalizeFromLength(this.length())
  3435. }
  3436. ,
  3437. e.prototype.reorderInPlace = function(e) {
  3438. var t = this;
  3439. return "xyz" === (e = e.toLowerCase()) || (M.Vector3[0].copyFrom(this),
  3440. ["x", "y", "z"].forEach((function(i, n) {
  3441. t[i] = M.Vector3[0][e[n]]
  3442. }
  3443. ))),
  3444. this
  3445. }
  3446. ,
  3447. e.prototype.rotateByQuaternionToRef = function(t, i) {
  3448. return t.toRotationMatrix(M.Matrix[0]),
  3449. e.TransformCoordinatesToRef(this, M.Matrix[0], i),
  3450. i
  3451. }
  3452. ,
  3453. e.prototype.rotateByQuaternionAroundPointToRef = function(e, t, i) {
  3454. return this.subtractToRef(t, M.Vector3[0]),
  3455. M.Vector3[0].rotateByQuaternionToRef(e, M.Vector3[0]),
  3456. t.addToRef(M.Vector3[0], i),
  3457. i
  3458. }
  3459. ,
  3460. e.prototype.cross = function(t) {
  3461. return e.Cross(this, t)
  3462. }
  3463. ,
  3464. e.prototype.normalizeFromLength = function(e) {
  3465. return 0 === e || 1 === e ? this : this.scaleInPlace(1 / e)
  3466. }
  3467. ,
  3468. e.prototype.normalizeToNew = function() {
  3469. var t = new e(0,0,0);
  3470. return this.normalizeToRef(t),
  3471. t
  3472. }
  3473. ,
  3474. e.prototype.normalizeToRef = function(e) {
  3475. var t = this.length();
  3476. return 0 === t || 1 === t ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / t, e)
  3477. }
  3478. ,
  3479. e.prototype.clone = function() {
  3480. return new e(this._x,this._y,this._z)
  3481. }
  3482. ,
  3483. e.prototype.copyFrom = function(e) {
  3484. return this.copyFromFloats(e._x, e._y, e._z)
  3485. }
  3486. ,
  3487. e.prototype.copyFromFloats = function(e, t, i) {
  3488. return this.x = e,
  3489. this.y = t,
  3490. this.z = i,
  3491. this
  3492. }
  3493. ,
  3494. e.prototype.set = function(e, t, i) {
  3495. return this.copyFromFloats(e, t, i)
  3496. }
  3497. ,
  3498. e.prototype.setAll = function(e) {
  3499. return this.x = this.y = this.z = e,
  3500. this
  3501. }
  3502. ,
  3503. e.GetClipFactor = function(t, i, n, r) {
  3504. var o = e.Dot(t, n) - r;
  3505. return o / (o - (e.Dot(i, n) - r))
  3506. }
  3507. ,
  3508. e.GetAngleBetweenVectors = function(t, i, n) {
  3509. var r = t.normalizeToRef(M.Vector3[1])
  3510. , o = i.normalizeToRef(M.Vector3[2])
  3511. , a = e.Dot(r, o)
  3512. , s = Math.acos(a)
  3513. , l = M.Vector3[3];
  3514. return e.CrossToRef(r, o, l),
  3515. e.Dot(l, n) > 0 ? isNaN(s) ? 0 : s : isNaN(s) ? -Math.PI : -Math.acos(a)
  3516. }
  3517. ,
  3518. e.GetAngleBetweenVectorsOnPlane = function(t, i, n) {
  3519. M.Vector3[0].copyFrom(t);
  3520. var r = M.Vector3[0];
  3521. M.Vector3[1].copyFrom(i);
  3522. var o = M.Vector3[1];
  3523. M.Vector3[2].copyFrom(n);
  3524. var a = M.Vector3[2]
  3525. , s = M.Vector3[3]
  3526. , l = M.Vector3[4];
  3527. r.normalize(),
  3528. o.normalize(),
  3529. a.normalize(),
  3530. e.CrossToRef(a, r, s),
  3531. e.CrossToRef(s, a, l);
  3532. var c = Math.atan2(e.Dot(o, s), e.Dot(o, l));
  3533. return d.NormalizeRadians(c)
  3534. }
  3535. ,
  3536. e.SlerpToRef = function(t, i, n, r) {
  3537. n = d.Clamp(n, 0, 1);
  3538. var o = M.Vector3[0]
  3539. , a = M.Vector3[1];
  3540. o.copyFrom(t);
  3541. var s = o.length();
  3542. o.normalizeFromLength(s),
  3543. a.copyFrom(i);
  3544. var l = a.length();
  3545. a.normalizeFromLength(l);
  3546. var c, u, h = e.Dot(o, a);
  3547. if (h < 1 - m) {
  3548. var p = Math.acos(h)
  3549. , f = 1 / Math.sin(p);
  3550. c = Math.sin((1 - n) * p) * f,
  3551. u = Math.sin(n * p) * f
  3552. } else
  3553. c = 1 - n,
  3554. u = n;
  3555. o.scaleInPlace(c),
  3556. a.scaleInPlace(u),
  3557. r.copyFrom(o).addInPlace(a),
  3558. r.scaleInPlace(d.Lerp(s, l, n))
  3559. }
  3560. ,
  3561. e.SmoothToRef = function(t, i, n, r, o) {
  3562. e.SlerpToRef(t, i, 0 === r ? 1 : n / r, o)
  3563. }
  3564. ,
  3565. e.FromArray = function(t, i) {
  3566. return void 0 === i && (i = 0),
  3567. new e(t[i],t[i + 1],t[i + 2])
  3568. }
  3569. ,
  3570. e.FromFloatArray = function(t, i) {
  3571. return e.FromArray(t, i)
  3572. }
  3573. ,
  3574. e.FromArrayToRef = function(e, t, i) {
  3575. i.x = e[t],
  3576. i.y = e[t + 1],
  3577. i.z = e[t + 2]
  3578. }
  3579. ,
  3580. e.FromFloatArrayToRef = function(t, i, n) {
  3581. return e.FromArrayToRef(t, i, n)
  3582. }
  3583. ,
  3584. e.FromFloatsToRef = function(e, t, i, n) {
  3585. n.copyFromFloats(e, t, i)
  3586. }
  3587. ,
  3588. e.Zero = function() {
  3589. return new e(0,0,0)
  3590. }
  3591. ,
  3592. e.One = function() {
  3593. return new e(1,1,1)
  3594. }
  3595. ,
  3596. e.Up = function() {
  3597. return new e(0,1,0)
  3598. }
  3599. ,
  3600. Object.defineProperty(e, "UpReadOnly", {
  3601. get: function() {
  3602. return e._UpReadOnly
  3603. },
  3604. enumerable: !1,
  3605. configurable: !0
  3606. }),
  3607. Object.defineProperty(e, "RightReadOnly", {
  3608. get: function() {
  3609. return e._RightReadOnly
  3610. },
  3611. enumerable: !1,
  3612. configurable: !0
  3613. }),
  3614. Object.defineProperty(e, "LeftReadOnly", {
  3615. get: function() {
  3616. return e._LeftReadOnly
  3617. },
  3618. enumerable: !1,
  3619. configurable: !0
  3620. }),
  3621. Object.defineProperty(e, "LeftHandedForwardReadOnly", {
  3622. get: function() {
  3623. return e._LeftHandedForwardReadOnly
  3624. },
  3625. enumerable: !1,
  3626. configurable: !0
  3627. }),
  3628. Object.defineProperty(e, "RightHandedForwardReadOnly", {
  3629. get: function() {
  3630. return e._RightHandedForwardReadOnly
  3631. },
  3632. enumerable: !1,
  3633. configurable: !0
  3634. }),
  3635. Object.defineProperty(e, "ZeroReadOnly", {
  3636. get: function() {
  3637. return e._ZeroReadOnly
  3638. },
  3639. enumerable: !1,
  3640. configurable: !0
  3641. }),
  3642. e.Down = function() {
  3643. return new e(0,-1,0)
  3644. }
  3645. ,
  3646. e.Forward = function(t) {
  3647. return void 0 === t && (t = !1),
  3648. new e(0,0,t ? -1 : 1)
  3649. }
  3650. ,
  3651. e.Backward = function(t) {
  3652. return void 0 === t && (t = !1),
  3653. new e(0,0,t ? 1 : -1)
  3654. }
  3655. ,
  3656. e.Right = function() {
  3657. return new e(1,0,0)
  3658. }
  3659. ,
  3660. e.Left = function() {
  3661. return new e(-1,0,0)
  3662. }
  3663. ,
  3664. e.TransformCoordinates = function(t, i) {
  3665. var n = e.Zero();
  3666. return e.TransformCoordinatesToRef(t, i, n),
  3667. n
  3668. }
  3669. ,
  3670. e.TransformCoordinatesToRef = function(t, i, n) {
  3671. e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
  3672. }
  3673. ,
  3674. e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
  3675. var o = n.m
  3676. , a = e * o[0] + t * o[4] + i * o[8] + o[12]
  3677. , s = e * o[1] + t * o[5] + i * o[9] + o[13]
  3678. , l = e * o[2] + t * o[6] + i * o[10] + o[14]
  3679. , c = 1 / (e * o[3] + t * o[7] + i * o[11] + o[15]);
  3680. r.x = a * c,
  3681. r.y = s * c,
  3682. r.z = l * c
  3683. }
  3684. ,
  3685. e.TransformNormal = function(t, i) {
  3686. var n = e.Zero();
  3687. return e.TransformNormalToRef(t, i, n),
  3688. n
  3689. }
  3690. ,
  3691. e.TransformNormalToRef = function(e, t, i) {
  3692. this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, t, i)
  3693. }
  3694. ,
  3695. e.TransformNormalFromFloatsToRef = function(e, t, i, n, r) {
  3696. var o = n.m;
  3697. r.x = e * o[0] + t * o[4] + i * o[8],
  3698. r.y = e * o[1] + t * o[5] + i * o[9],
  3699. r.z = e * o[2] + t * o[6] + i * o[10]
  3700. }
  3701. ,
  3702. e.CatmullRom = function(t, i, n, r, o) {
  3703. var a = o * o
  3704. , s = o * a;
  3705. return new e(.5 * (2 * i._x + (-t._x + n._x) * o + (2 * t._x - 5 * i._x + 4 * n._x - r._x) * a + (-t._x + 3 * i._x - 3 * n._x + r._x) * s),.5 * (2 * i._y + (-t._y + n._y) * o + (2 * t._y - 5 * i._y + 4 * n._y - r._y) * a + (-t._y + 3 * i._y - 3 * n._y + r._y) * s),.5 * (2 * i._z + (-t._z + n._z) * o + (2 * t._z - 5 * i._z + 4 * n._z - r._z) * a + (-t._z + 3 * i._z - 3 * n._z + r._z) * s))
  3706. }
  3707. ,
  3708. e.Clamp = function(t, i, n) {
  3709. var r = new e;
  3710. return e.ClampToRef(t, i, n, r),
  3711. r
  3712. }
  3713. ,
  3714. e.ClampToRef = function(e, t, i, n) {
  3715. var r = e._x;
  3716. r = (r = r > i._x ? i._x : r) < t._x ? t._x : r;
  3717. var o = e._y;
  3718. o = (o = o > i._y ? i._y : o) < t._y ? t._y : o;
  3719. var a = e._z;
  3720. a = (a = a > i._z ? i._z : a) < t._z ? t._z : a,
  3721. n.copyFromFloats(r, o, a)
  3722. }
  3723. ,
  3724. e.CheckExtends = function(e, t, i) {
  3725. t.minimizeInPlace(e),
  3726. i.maximizeInPlace(e)
  3727. }
  3728. ,
  3729. e.Hermite = function(t, i, n, r, o) {
  3730. var a = o * o
  3731. , s = o * a
  3732. , l = 2 * s - 3 * a + 1
  3733. , c = -2 * s + 3 * a
  3734. , u = s - 2 * a + o
  3735. , h = s - a;
  3736. return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h)
  3737. }
  3738. ,
  3739. e.Hermite1stDerivative = function(t, i, n, r, o) {
  3740. var a = e.Zero();
  3741. return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
  3742. a
  3743. }
  3744. ,
  3745. e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
  3746. var a = r * r;
  3747. o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
  3748. o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
  3749. o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z
  3750. }
  3751. ,
  3752. e.Lerp = function(t, i, n) {
  3753. var r = new e(0,0,0);
  3754. return e.LerpToRef(t, i, n, r),
  3755. r
  3756. }
  3757. ,
  3758. e.LerpToRef = function(e, t, i, n) {
  3759. n.x = e._x + (t._x - e._x) * i,
  3760. n.y = e._y + (t._y - e._y) * i,
  3761. n.z = e._z + (t._z - e._z) * i
  3762. }
  3763. ,
  3764. e.Dot = function(e, t) {
  3765. return e._x * t._x + e._y * t._y + e._z * t._z
  3766. }
  3767. ,
  3768. e.Cross = function(t, i) {
  3769. var n = e.Zero();
  3770. return e.CrossToRef(t, i, n),
  3771. n
  3772. }
  3773. ,
  3774. e.CrossToRef = function(e, t, i) {
  3775. var n = e._y * t._z - e._z * t._y
  3776. , r = e._z * t._x - e._x * t._z
  3777. , o = e._x * t._y - e._y * t._x;
  3778. i.copyFromFloats(n, r, o)
  3779. }
  3780. ,
  3781. e.Normalize = function(t) {
  3782. var i = e.Zero();
  3783. return e.NormalizeToRef(t, i),
  3784. i
  3785. }
  3786. ,
  3787. e.NormalizeToRef = function(e, t) {
  3788. e.normalizeToRef(t)
  3789. }
  3790. ,
  3791. e.Project = function(t, i, n, r) {
  3792. var o = new e;
  3793. return e.ProjectToRef(t, i, n, r, o),
  3794. o
  3795. }
  3796. ,
  3797. e.ProjectToRef = function(t, i, n, r, o) {
  3798. var a = r.width
  3799. , s = r.height
  3800. , l = r.x
  3801. , c = r.y
  3802. , u = M.Matrix[1];
  3803. P.FromValuesToRef(a / 2, 0, 0, 0, 0, -s / 2, 0, 0, 0, 0, .5, 0, l + a / 2, s / 2 + c, .5, 1, u);
  3804. var h = M.Matrix[0];
  3805. return i.multiplyToRef(n, h),
  3806. h.multiplyToRef(u, h),
  3807. e.TransformCoordinatesToRef(t, h, o),
  3808. o
  3809. }
  3810. ,
  3811. e._UnprojectFromInvertedMatrixToRef = function(t, i, n) {
  3812. e.TransformCoordinatesToRef(t, i, n);
  3813. var r = i.m
  3814. , o = t._x * r[3] + t._y * r[7] + t._z * r[11] + r[15];
  3815. d.WithinEpsilon(o, 1) && n.scaleInPlace(1 / o)
  3816. }
  3817. ,
  3818. e.UnprojectFromTransform = function(e, t, i, n, r) {
  3819. return this.Unproject(e, t, i, n, r, P.IdentityReadOnly)
  3820. }
  3821. ,
  3822. e.Unproject = function(t, i, n, r, o, a) {
  3823. var s = e.Zero();
  3824. return e.UnprojectToRef(t, i, n, r, o, a, s),
  3825. s
  3826. }
  3827. ,
  3828. e.UnprojectToRef = function(t, i, n, r, o, a, s) {
  3829. e.UnprojectFloatsToRef(t._x, t._y, t._z, i, n, r, o, a, s)
  3830. }
  3831. ,
  3832. e.UnprojectFloatsToRef = function(t, i, n, r, o, a, s, l, c) {
  3833. var u, h = M.Matrix[0];
  3834. a.multiplyToRef(s, h),
  3835. h.multiplyToRef(l, h),
  3836. h.invert();
  3837. var d = M.Vector3[0];
  3838. d.x = t / r * 2 - 1,
  3839. d.y = -(i / o * 2 - 1),
  3840. (null === (u = E.LastCreatedEngine) || void 0 === u ? void 0 : u.isNDCHalfZRange) ? d.z = n : d.z = 2 * n - 1,
  3841. e._UnprojectFromInvertedMatrixToRef(d, h, c)
  3842. }
  3843. ,
  3844. e.Minimize = function(e, t) {
  3845. var i = e.clone();
  3846. return i.minimizeInPlace(t),
  3847. i
  3848. }
  3849. ,
  3850. e.Maximize = function(e, t) {
  3851. var i = e.clone();
  3852. return i.maximizeInPlace(t),
  3853. i
  3854. }
  3855. ,
  3856. e.Distance = function(t, i) {
  3857. return Math.sqrt(e.DistanceSquared(t, i))
  3858. }
  3859. ,
  3860. e.DistanceSquared = function(e, t) {
  3861. var i = e._x - t._x
  3862. , n = e._y - t._y
  3863. , r = e._z - t._z;
  3864. return i * i + n * n + r * r
  3865. }
  3866. ,
  3867. e.ProjectOnTriangleToRef = function(t, i, n, r, o) {
  3868. var a = M.Vector3[0]
  3869. , s = M.Vector3[1]
  3870. , l = M.Vector3[2]
  3871. , c = M.Vector3[3]
  3872. , u = M.Vector3[4];
  3873. n.subtractToRef(i, a),
  3874. r.subtractToRef(i, s),
  3875. r.subtractToRef(n, l);
  3876. var h = a.length()
  3877. , p = s.length()
  3878. , f = l.length();
  3879. if (h < m || p < m || f < m)
  3880. return o.copyFrom(i),
  3881. e.Distance(t, i);
  3882. t.subtractToRef(i, u),
  3883. e.CrossToRef(a, s, c);
  3884. var _ = c.length();
  3885. if (_ < m)
  3886. return o.copyFrom(i),
  3887. e.Distance(t, i);
  3888. c.normalizeFromLength(_);
  3889. var g = u.length();
  3890. if (g < m)
  3891. return o.copyFrom(i),
  3892. 0;
  3893. u.normalizeFromLength(g);
  3894. var v = e.Dot(c, u)
  3895. , y = M.Vector3[5]
  3896. , b = M.Vector3[6];
  3897. y.copyFrom(c).scaleInPlace(-g * v),
  3898. b.copyFrom(t).addInPlace(y);
  3899. var T = M.Vector3[4]
  3900. , E = M.Vector3[5]
  3901. , S = M.Vector3[7]
  3902. , A = M.Vector3[8];
  3903. T.copyFrom(a).scaleInPlace(1 / h),
  3904. A.copyFrom(s).scaleInPlace(1 / p),
  3905. T.addInPlace(A).scaleInPlace(-1),
  3906. E.copyFrom(a).scaleInPlace(-1 / h),
  3907. A.copyFrom(l).scaleInPlace(1 / f),
  3908. E.addInPlace(A).scaleInPlace(-1),
  3909. S.copyFrom(l).scaleInPlace(-1 / f),
  3910. A.copyFrom(s).scaleInPlace(-1 / p),
  3911. S.addInPlace(A).scaleInPlace(-1);
  3912. var x = M.Vector3[9];
  3913. x.copyFrom(b).subtractInPlace(i),
  3914. e.CrossToRef(T, x, A);
  3915. var R = e.Dot(A, c);
  3916. x.copyFrom(b).subtractInPlace(n),
  3917. e.CrossToRef(E, x, A);
  3918. var C = e.Dot(A, c);
  3919. x.copyFrom(b).subtractInPlace(r),
  3920. e.CrossToRef(S, x, A);
  3921. var P, I, O = e.Dot(A, c), D = M.Vector3[10];
  3922. R > 0 && C < 0 ? (D.copyFrom(a),
  3923. P = i,
  3924. I = n) : C > 0 && O < 0 ? (D.copyFrom(l),
  3925. P = n,
  3926. I = r) : (D.copyFrom(s).scaleInPlace(-1),
  3927. P = r,
  3928. I = i);
  3929. var N = M.Vector3[9]
  3930. , L = M.Vector3[4];
  3931. if (P.subtractToRef(b, A),
  3932. I.subtractToRef(b, N),
  3933. e.CrossToRef(A, N, L),
  3934. !(e.Dot(L, c) < 0))
  3935. return o.copyFrom(b),
  3936. Math.abs(g * v);
  3937. var F = M.Vector3[5];
  3938. e.CrossToRef(D, L, F),
  3939. F.normalize();
  3940. var w = M.Vector3[9];
  3941. w.copyFrom(P).subtractInPlace(b);
  3942. var B = w.length();
  3943. if (B < m)
  3944. return o.copyFrom(P),
  3945. e.Distance(t, P);
  3946. w.normalizeFromLength(B);
  3947. var U = e.Dot(F, w)
  3948. , V = M.Vector3[7];
  3949. V.copyFrom(b).addInPlace(F.scaleInPlace(B * U)),
  3950. A.copyFrom(V).subtractInPlace(P),
  3951. g = D.length(),
  3952. D.normalizeFromLength(g);
  3953. var k = e.Dot(A, D) / Math.max(g, m);
  3954. return k = d.Clamp(k, 0, 1),
  3955. V.copyFrom(P).addInPlace(D.scaleInPlace(k * g)),
  3956. o.copyFrom(V),
  3957. e.Distance(t, V)
  3958. }
  3959. ,
  3960. e.Center = function(t, i) {
  3961. return e.CenterToRef(t, i, e.Zero())
  3962. }
  3963. ,
  3964. e.CenterToRef = function(e, t, i) {
  3965. return i.copyFromFloats((e._x + t._x) / 2, (e._y + t._y) / 2, (e._z + t._z) / 2)
  3966. }
  3967. ,
  3968. e.RotationFromAxis = function(t, i, n) {
  3969. var r = e.Zero();
  3970. return e.RotationFromAxisToRef(t, i, n, r),
  3971. r
  3972. }
  3973. ,
  3974. e.RotationFromAxisToRef = function(e, t, i, n) {
  3975. var r = M.Quaternion[0];
  3976. C.RotationQuaternionFromAxisToRef(e, t, i, r),
  3977. r.toEulerAnglesToRef(n)
  3978. }
  3979. ,
  3980. e._UpReadOnly = e.Up(),
  3981. e._LeftHandedForwardReadOnly = e.Forward(!1),
  3982. e._RightHandedForwardReadOnly = e.Forward(!0),
  3983. e._RightReadOnly = e.Right(),
  3984. e._LeftReadOnly = e.Left(),
  3985. e._ZeroReadOnly = e.Zero(),
  3986. e
  3987. }()
  3988. , R = function() {
  3989. function e(e, t, i, n) {
  3990. this.x = e,
  3991. this.y = t,
  3992. this.z = i,
  3993. this.w = n
  3994. }
  3995. return e.prototype.toString = function() {
  3996. return "{X: ".concat(this.x, " Y: ").concat(this.y, " Z: ").concat(this.z, " W: ").concat(this.w, "}")
  3997. }
  3998. ,
  3999. e.prototype.getClassName = function() {
  4000. return "Vector4"
  4001. }
  4002. ,
  4003. e.prototype.getHashCode = function() {
  4004. var e = S(this.x);
  4005. return 397 * (e = 397 * (e = 397 * e ^ S(this.y)) ^ S(this.z)) ^ S(this.w)
  4006. }
  4007. ,
  4008. e.prototype.asArray = function() {
  4009. var e = new Array;
  4010. return this.toArray(e, 0),
  4011. e
  4012. }
  4013. ,
  4014. e.prototype.toArray = function(e, t) {
  4015. return void 0 === t && (t = 0),
  4016. e[t] = this.x,
  4017. e[t + 1] = this.y,
  4018. e[t + 2] = this.z,
  4019. e[t + 3] = this.w,
  4020. this
  4021. }
  4022. ,
  4023. e.prototype.fromArray = function(t, i) {
  4024. return void 0 === i && (i = 0),
  4025. e.FromArrayToRef(t, i, this),
  4026. this
  4027. }
  4028. ,
  4029. e.prototype.addInPlace = function(e) {
  4030. return this.x += e.x,
  4031. this.y += e.y,
  4032. this.z += e.z,
  4033. this.w += e.w,
  4034. this
  4035. }
  4036. ,
  4037. e.prototype.add = function(t) {
  4038. return new e(this.x + t.x,this.y + t.y,this.z + t.z,this.w + t.w)
  4039. }
  4040. ,
  4041. e.prototype.addToRef = function(e, t) {
  4042. return t.x = this.x + e.x,
  4043. t.y = this.y + e.y,
  4044. t.z = this.z + e.z,
  4045. t.w = this.w + e.w,
  4046. this
  4047. }
  4048. ,
  4049. e.prototype.subtractInPlace = function(e) {
  4050. return this.x -= e.x,
  4051. this.y -= e.y,
  4052. this.z -= e.z,
  4053. this.w -= e.w,
  4054. this
  4055. }
  4056. ,
  4057. e.prototype.subtract = function(t) {
  4058. return new e(this.x - t.x,this.y - t.y,this.z - t.z,this.w - t.w)
  4059. }
  4060. ,
  4061. e.prototype.subtractToRef = function(e, t) {
  4062. return t.x = this.x - e.x,
  4063. t.y = this.y - e.y,
  4064. t.z = this.z - e.z,
  4065. t.w = this.w - e.w,
  4066. this
  4067. }
  4068. ,
  4069. e.prototype.subtractFromFloats = function(t, i, n, r) {
  4070. return new e(this.x - t,this.y - i,this.z - n,this.w - r)
  4071. }
  4072. ,
  4073. e.prototype.subtractFromFloatsToRef = function(e, t, i, n, r) {
  4074. return r.x = this.x - e,
  4075. r.y = this.y - t,
  4076. r.z = this.z - i,
  4077. r.w = this.w - n,
  4078. this
  4079. }
  4080. ,
  4081. e.prototype.negate = function() {
  4082. return new e(-this.x,-this.y,-this.z,-this.w)
  4083. }
  4084. ,
  4085. e.prototype.negateInPlace = function() {
  4086. return this.x *= -1,
  4087. this.y *= -1,
  4088. this.z *= -1,
  4089. this.w *= -1,
  4090. this
  4091. }
  4092. ,
  4093. e.prototype.negateToRef = function(e) {
  4094. return e.copyFromFloats(-1 * this.x, -1 * this.y, -1 * this.z, -1 * this.w)
  4095. }
  4096. ,
  4097. e.prototype.scaleInPlace = function(e) {
  4098. return this.x *= e,
  4099. this.y *= e,
  4100. this.z *= e,
  4101. this.w *= e,
  4102. this
  4103. }
  4104. ,
  4105. e.prototype.scale = function(t) {
  4106. return new e(this.x * t,this.y * t,this.z * t,this.w * t)
  4107. }
  4108. ,
  4109. e.prototype.scaleToRef = function(e, t) {
  4110. return t.x = this.x * e,
  4111. t.y = this.y * e,
  4112. t.z = this.z * e,
  4113. t.w = this.w * e,
  4114. this
  4115. }
  4116. ,
  4117. e.prototype.scaleAndAddToRef = function(e, t) {
  4118. return t.x += this.x * e,
  4119. t.y += this.y * e,
  4120. t.z += this.z * e,
  4121. t.w += this.w * e,
  4122. this
  4123. }
  4124. ,
  4125. e.prototype.equals = function(e) {
  4126. return e && this.x === e.x && this.y === e.y && this.z === e.z && this.w === e.w
  4127. }
  4128. ,
  4129. e.prototype.equalsWithEpsilon = function(e, t) {
  4130. return void 0 === t && (t = m),
  4131. e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t) && d.WithinEpsilon(this.z, e.z, t) && d.WithinEpsilon(this.w, e.w, t)
  4132. }
  4133. ,
  4134. e.prototype.equalsToFloats = function(e, t, i, n) {
  4135. return this.x === e && this.y === t && this.z === i && this.w === n
  4136. }
  4137. ,
  4138. e.prototype.multiplyInPlace = function(e) {
  4139. return this.x *= e.x,
  4140. this.y *= e.y,
  4141. this.z *= e.z,
  4142. this.w *= e.w,
  4143. this
  4144. }
  4145. ,
  4146. e.prototype.multiply = function(t) {
  4147. return new e(this.x * t.x,this.y * t.y,this.z * t.z,this.w * t.w)
  4148. }
  4149. ,
  4150. e.prototype.multiplyToRef = function(e, t) {
  4151. return t.x = this.x * e.x,
  4152. t.y = this.y * e.y,
  4153. t.z = this.z * e.z,
  4154. t.w = this.w * e.w,
  4155. this
  4156. }
  4157. ,
  4158. e.prototype.multiplyByFloats = function(t, i, n, r) {
  4159. return new e(this.x * t,this.y * i,this.z * n,this.w * r)
  4160. }
  4161. ,
  4162. e.prototype.divide = function(t) {
  4163. return new e(this.x / t.x,this.y / t.y,this.z / t.z,this.w / t.w)
  4164. }
  4165. ,
  4166. e.prototype.divideToRef = function(e, t) {
  4167. return t.x = this.x / e.x,
  4168. t.y = this.y / e.y,
  4169. t.z = this.z / e.z,
  4170. t.w = this.w / e.w,
  4171. this
  4172. }
  4173. ,
  4174. e.prototype.divideInPlace = function(e) {
  4175. return this.divideToRef(e, this)
  4176. }
  4177. ,
  4178. e.prototype.minimizeInPlace = function(e) {
  4179. return e.x < this.x && (this.x = e.x),
  4180. e.y < this.y && (this.y = e.y),
  4181. e.z < this.z && (this.z = e.z),
  4182. e.w < this.w && (this.w = e.w),
  4183. this
  4184. }
  4185. ,
  4186. e.prototype.maximizeInPlace = function(e) {
  4187. return e.x > this.x && (this.x = e.x),
  4188. e.y > this.y && (this.y = e.y),
  4189. e.z > this.z && (this.z = e.z),
  4190. e.w > this.w && (this.w = e.w),
  4191. this
  4192. }
  4193. ,
  4194. e.prototype.floor = function() {
  4195. return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
  4196. }
  4197. ,
  4198. e.prototype.fract = function() {
  4199. return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y),this.z - Math.floor(this.z),this.w - Math.floor(this.w))
  4200. }
  4201. ,
  4202. e.prototype.length = function() {
  4203. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
  4204. }
  4205. ,
  4206. e.prototype.lengthSquared = function() {
  4207. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
  4208. }
  4209. ,
  4210. e.prototype.normalize = function() {
  4211. var e = this.length();
  4212. return 0 === e ? this : this.scaleInPlace(1 / e)
  4213. }
  4214. ,
  4215. e.prototype.toVector3 = function() {
  4216. return new x(this.x,this.y,this.z)
  4217. }
  4218. ,
  4219. e.prototype.clone = function() {
  4220. return new e(this.x,this.y,this.z,this.w)
  4221. }
  4222. ,
  4223. e.prototype.copyFrom = function(e) {
  4224. return this.x = e.x,
  4225. this.y = e.y,
  4226. this.z = e.z,
  4227. this.w = e.w,
  4228. this
  4229. }
  4230. ,
  4231. e.prototype.copyFromFloats = function(e, t, i, n) {
  4232. return this.x = e,
  4233. this.y = t,
  4234. this.z = i,
  4235. this.w = n,
  4236. this
  4237. }
  4238. ,
  4239. e.prototype.set = function(e, t, i, n) {
  4240. return this.copyFromFloats(e, t, i, n)
  4241. }
  4242. ,
  4243. e.prototype.setAll = function(e) {
  4244. return this.x = this.y = this.z = this.w = e,
  4245. this
  4246. }
  4247. ,
  4248. e.FromArray = function(t, i) {
  4249. return i || (i = 0),
  4250. new e(t[i],t[i + 1],t[i + 2],t[i + 3])
  4251. }
  4252. ,
  4253. e.FromArrayToRef = function(e, t, i) {
  4254. i.x = e[t],
  4255. i.y = e[t + 1],
  4256. i.z = e[t + 2],
  4257. i.w = e[t + 3]
  4258. }
  4259. ,
  4260. e.FromFloatArrayToRef = function(t, i, n) {
  4261. e.FromArrayToRef(t, i, n)
  4262. }
  4263. ,
  4264. e.FromFloatsToRef = function(e, t, i, n, r) {
  4265. r.x = e,
  4266. r.y = t,
  4267. r.z = i,
  4268. r.w = n
  4269. }
  4270. ,
  4271. e.Zero = function() {
  4272. return new e(0,0,0,0)
  4273. }
  4274. ,
  4275. e.One = function() {
  4276. return new e(1,1,1,1)
  4277. }
  4278. ,
  4279. e.Normalize = function(t) {
  4280. var i = e.Zero();
  4281. return e.NormalizeToRef(t, i),
  4282. i
  4283. }
  4284. ,
  4285. e.NormalizeToRef = function(e, t) {
  4286. t.copyFrom(e),
  4287. t.normalize()
  4288. }
  4289. ,
  4290. e.Minimize = function(e, t) {
  4291. var i = e.clone();
  4292. return i.minimizeInPlace(t),
  4293. i
  4294. }
  4295. ,
  4296. e.Maximize = function(e, t) {
  4297. var i = e.clone();
  4298. return i.maximizeInPlace(t),
  4299. i
  4300. }
  4301. ,
  4302. e.Distance = function(t, i) {
  4303. return Math.sqrt(e.DistanceSquared(t, i))
  4304. }
  4305. ,
  4306. e.DistanceSquared = function(e, t) {
  4307. var i = e.x - t.x
  4308. , n = e.y - t.y
  4309. , r = e.z - t.z
  4310. , o = e.w - t.w;
  4311. return i * i + n * n + r * r + o * o
  4312. }
  4313. ,
  4314. e.Center = function(t, i) {
  4315. return e.CenterToRef(t, i, e.Zero())
  4316. }
  4317. ,
  4318. e.CenterToRef = function(e, t, i) {
  4319. return i.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2, (e.z + t.z) / 2, (e.w + t.w) / 2)
  4320. }
  4321. ,
  4322. e.TransformCoordinates = function(t, i) {
  4323. var n = e.Zero();
  4324. return e.TransformCoordinatesToRef(t, i, n),
  4325. n
  4326. }
  4327. ,
  4328. e.TransformCoordinatesToRef = function(t, i, n) {
  4329. e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
  4330. }
  4331. ,
  4332. e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
  4333. var o = n.m
  4334. , a = e * o[0] + t * o[4] + i * o[8] + o[12]
  4335. , s = e * o[1] + t * o[5] + i * o[9] + o[13]
  4336. , l = e * o[2] + t * o[6] + i * o[10] + o[14]
  4337. , c = e * o[3] + t * o[7] + i * o[11] + o[15];
  4338. r.x = a,
  4339. r.y = s,
  4340. r.z = l,
  4341. r.w = c
  4342. }
  4343. ,
  4344. e.TransformNormal = function(t, i) {
  4345. var n = e.Zero();
  4346. return e.TransformNormalToRef(t, i, n),
  4347. n
  4348. }
  4349. ,
  4350. e.TransformNormalToRef = function(e, t, i) {
  4351. var n = t.m
  4352. , r = e.x * n[0] + e.y * n[4] + e.z * n[8]
  4353. , o = e.x * n[1] + e.y * n[5] + e.z * n[9]
  4354. , a = e.x * n[2] + e.y * n[6] + e.z * n[10];
  4355. i.x = r,
  4356. i.y = o,
  4357. i.z = a,
  4358. i.w = e.w
  4359. }
  4360. ,
  4361. e.TransformNormalFromFloatsToRef = function(e, t, i, n, r, o) {
  4362. var a = r.m;
  4363. o.x = e * a[0] + t * a[4] + i * a[8],
  4364. o.y = e * a[1] + t * a[5] + i * a[9],
  4365. o.z = e * a[2] + t * a[6] + i * a[10],
  4366. o.w = n
  4367. }
  4368. ,
  4369. e.FromVector3 = function(t, i) {
  4370. return void 0 === i && (i = 0),
  4371. new e(t._x,t._y,t._z,i)
  4372. }
  4373. ,
  4374. e
  4375. }()
  4376. , C = function() {
  4377. function e(e, t, i, n) {
  4378. void 0 === e && (e = 0),
  4379. void 0 === t && (t = 0),
  4380. void 0 === i && (i = 0),
  4381. void 0 === n && (n = 1),
  4382. this._isDirty = !0,
  4383. this._x = e,
  4384. this._y = t,
  4385. this._z = i,
  4386. this._w = n
  4387. }
  4388. return Object.defineProperty(e.prototype, "x", {
  4389. get: function() {
  4390. return this._x
  4391. },
  4392. set: function(e) {
  4393. this._x = e,
  4394. this._isDirty = !0
  4395. },
  4396. enumerable: !1,
  4397. configurable: !0
  4398. }),
  4399. Object.defineProperty(e.prototype, "y", {
  4400. get: function() {
  4401. return this._y
  4402. },
  4403. set: function(e) {
  4404. this._y = e,
  4405. this._isDirty = !0
  4406. },
  4407. enumerable: !1,
  4408. configurable: !0
  4409. }),
  4410. Object.defineProperty(e.prototype, "z", {
  4411. get: function() {
  4412. return this._z
  4413. },
  4414. set: function(e) {
  4415. this._z = e,
  4416. this._isDirty = !0
  4417. },
  4418. enumerable: !1,
  4419. configurable: !0
  4420. }),
  4421. Object.defineProperty(e.prototype, "w", {
  4422. get: function() {
  4423. return this._w
  4424. },
  4425. set: function(e) {
  4426. this._w = e,
  4427. this._isDirty = !0
  4428. },
  4429. enumerable: !1,
  4430. configurable: !0
  4431. }),
  4432. e.prototype.toString = function() {
  4433. return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, " W: ").concat(this._w, "}")
  4434. }
  4435. ,
  4436. e.prototype.getClassName = function() {
  4437. return "Quaternion"
  4438. }
  4439. ,
  4440. e.prototype.getHashCode = function() {
  4441. var e = S(this._x);
  4442. return 397 * (e = 397 * (e = 397 * e ^ S(this._y)) ^ S(this._z)) ^ S(this._w)
  4443. }
  4444. ,
  4445. e.prototype.asArray = function() {
  4446. return [this._x, this._y, this._z, this._w]
  4447. }
  4448. ,
  4449. e.prototype.equals = function(e) {
  4450. return e && this._x === e._x && this._y === e._y && this._z === e._z && this._w === e._w
  4451. }
  4452. ,
  4453. e.prototype.equalsWithEpsilon = function(e, t) {
  4454. return void 0 === t && (t = m),
  4455. e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.WithinEpsilon(this._z, e._z, t) && d.WithinEpsilon(this._w, e._w, t)
  4456. }
  4457. ,
  4458. e.prototype.clone = function() {
  4459. return new e(this._x,this._y,this._z,this._w)
  4460. }
  4461. ,
  4462. e.prototype.copyFrom = function(e) {
  4463. return this.x = e._x,
  4464. this.y = e._y,
  4465. this.z = e._z,
  4466. this.w = e._w,
  4467. this
  4468. }
  4469. ,
  4470. e.prototype.copyFromFloats = function(e, t, i, n) {
  4471. return this.x = e,
  4472. this.y = t,
  4473. this.z = i,
  4474. this.w = n,
  4475. this
  4476. }
  4477. ,
  4478. e.prototype.set = function(e, t, i, n) {
  4479. return this.copyFromFloats(e, t, i, n)
  4480. }
  4481. ,
  4482. e.prototype.add = function(t) {
  4483. return new e(this._x + t._x,this._y + t._y,this._z + t._z,this._w + t._w)
  4484. }
  4485. ,
  4486. e.prototype.addInPlace = function(e) {
  4487. return this._x += e._x,
  4488. this._y += e._y,
  4489. this._z += e._z,
  4490. this._w += e._w,
  4491. this
  4492. }
  4493. ,
  4494. e.prototype.subtract = function(t) {
  4495. return new e(this._x - t._x,this._y - t._y,this._z - t._z,this._w - t._w)
  4496. }
  4497. ,
  4498. e.prototype.scale = function(t) {
  4499. return new e(this._x * t,this._y * t,this._z * t,this._w * t)
  4500. }
  4501. ,
  4502. e.prototype.scaleToRef = function(e, t) {
  4503. return t.x = this._x * e,
  4504. t.y = this._y * e,
  4505. t.z = this._z * e,
  4506. t.w = this._w * e,
  4507. this
  4508. }
  4509. ,
  4510. e.prototype.scaleInPlace = function(e) {
  4511. return this.x *= e,
  4512. this.y *= e,
  4513. this.z *= e,
  4514. this.w *= e,
  4515. this
  4516. }
  4517. ,
  4518. e.prototype.scaleAndAddToRef = function(e, t) {
  4519. return t.x += this._x * e,
  4520. t.y += this._y * e,
  4521. t.z += this._z * e,
  4522. t.w += this._w * e,
  4523. this
  4524. }
  4525. ,
  4526. e.prototype.multiply = function(t) {
  4527. var i = new e(0,0,0,1);
  4528. return this.multiplyToRef(t, i),
  4529. i
  4530. }
  4531. ,
  4532. e.prototype.multiplyToRef = function(e, t) {
  4533. var i = this._x * e._w + this._y * e._z - this._z * e._y + this._w * e._x
  4534. , n = -this._x * e._z + this._y * e._w + this._z * e._x + this._w * e._y
  4535. , r = this._x * e._y - this._y * e._x + this._z * e._w + this._w * e._z
  4536. , o = -this._x * e._x - this._y * e._y - this._z * e._z + this._w * e._w;
  4537. return t.copyFromFloats(i, n, r, o),
  4538. this
  4539. }
  4540. ,
  4541. e.prototype.multiplyInPlace = function(e) {
  4542. return this.multiplyToRef(e, this),
  4543. this
  4544. }
  4545. ,
  4546. e.prototype.conjugateToRef = function(e) {
  4547. return e.copyFromFloats(-this._x, -this._y, -this._z, this._w),
  4548. this
  4549. }
  4550. ,
  4551. e.prototype.conjugateInPlace = function() {
  4552. return this.x *= -1,
  4553. this.y *= -1,
  4554. this.z *= -1,
  4555. this
  4556. }
  4557. ,
  4558. e.prototype.conjugate = function() {
  4559. return new e(-this._x,-this._y,-this._z,this._w)
  4560. }
  4561. ,
  4562. e.prototype.length = function() {
  4563. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
  4564. }
  4565. ,
  4566. e.prototype.normalize = function() {
  4567. var e = this.length();
  4568. if (0 === e)
  4569. return this;
  4570. var t = 1 / e;
  4571. return this.x *= t,
  4572. this.y *= t,
  4573. this.z *= t,
  4574. this.w *= t,
  4575. this
  4576. }
  4577. ,
  4578. e.prototype.toEulerAngles = function() {
  4579. var e = x.Zero();
  4580. return this.toEulerAnglesToRef(e),
  4581. e
  4582. }
  4583. ,
  4584. e.prototype.toEulerAnglesToRef = function(e) {
  4585. var t = this._z
  4586. , i = this._x
  4587. , n = this._y
  4588. , r = this._w
  4589. , o = r * r
  4590. , a = t * t
  4591. , s = i * i
  4592. , l = n * n
  4593. , c = n * t - i * r
  4594. , u = .4999999;
  4595. return c < -u ? (e.y = 2 * Math.atan2(n, r),
  4596. e.x = Math.PI / 2,
  4597. e.z = 0) : c > u ? (e.y = 2 * Math.atan2(n, r),
  4598. e.x = -Math.PI / 2,
  4599. e.z = 0) : (e.z = Math.atan2(2 * (i * n + t * r), -a - s + l + o),
  4600. e.x = Math.asin(-2 * (t * n - i * r)),
  4601. e.y = Math.atan2(2 * (t * i + n * r), a - s - l + o)),
  4602. this
  4603. }
  4604. ,
  4605. e.prototype.toRotationMatrix = function(e) {
  4606. return P.FromQuaternionToRef(this, e),
  4607. this
  4608. }
  4609. ,
  4610. e.prototype.fromRotationMatrix = function(t) {
  4611. return e.FromRotationMatrixToRef(t, this),
  4612. this
  4613. }
  4614. ,
  4615. e.FromRotationMatrix = function(t) {
  4616. var i = new e;
  4617. return e.FromRotationMatrixToRef(t, i),
  4618. i
  4619. }
  4620. ,
  4621. e.FromRotationMatrixToRef = function(e, t) {
  4622. var i, n = e.m, r = n[0], o = n[4], a = n[8], s = n[1], l = n[5], c = n[9], u = n[2], h = n[6], d = n[10], p = r + l + d;
  4623. p > 0 ? (i = .5 / Math.sqrt(p + 1),
  4624. t.w = .25 / i,
  4625. t.x = (h - c) * i,
  4626. t.y = (a - u) * i,
  4627. t.z = (s - o) * i) : r > l && r > d ? (i = 2 * Math.sqrt(1 + r - l - d),
  4628. t.w = (h - c) / i,
  4629. t.x = .25 * i,
  4630. t.y = (o + s) / i,
  4631. t.z = (a + u) / i) : l > d ? (i = 2 * Math.sqrt(1 + l - r - d),
  4632. t.w = (a - u) / i,
  4633. t.x = (o + s) / i,
  4634. t.y = .25 * i,
  4635. t.z = (c + h) / i) : (i = 2 * Math.sqrt(1 + d - r - l),
  4636. t.w = (s - o) / i,
  4637. t.x = (a + u) / i,
  4638. t.y = (c + h) / i,
  4639. t.z = .25 * i)
  4640. }
  4641. ,
  4642. e.Dot = function(e, t) {
  4643. return e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w
  4644. }
  4645. ,
  4646. e.AreClose = function(t, i) {
  4647. return e.Dot(t, i) >= 0
  4648. }
  4649. ,
  4650. e.SmoothToRef = function(t, i, n, r, o) {
  4651. var a = 0 === r ? 1 : n / r;
  4652. a = d.Clamp(a, 0, 1),
  4653. e.SlerpToRef(t, i, a, o)
  4654. }
  4655. ,
  4656. e.Zero = function() {
  4657. return new e(0,0,0,0)
  4658. }
  4659. ,
  4660. e.Inverse = function(t) {
  4661. return new e(-t._x,-t._y,-t._z,t._w)
  4662. }
  4663. ,
  4664. e.InverseToRef = function(e, t) {
  4665. return t.set(-e._x, -e._y, -e._z, e._w),
  4666. t
  4667. }
  4668. ,
  4669. e.Identity = function() {
  4670. return new e(0,0,0,1)
  4671. }
  4672. ,
  4673. e.IsIdentity = function(e) {
  4674. return e && 0 === e._x && 0 === e._y && 0 === e._z && 1 === e._w
  4675. }
  4676. ,
  4677. e.RotationAxis = function(t, i) {
  4678. return e.RotationAxisToRef(t, i, new e)
  4679. }
  4680. ,
  4681. e.RotationAxisToRef = function(e, t, i) {
  4682. var n = Math.sin(t / 2);
  4683. return e.normalize(),
  4684. i.w = Math.cos(t / 2),
  4685. i.x = e._x * n,
  4686. i.y = e._y * n,
  4687. i.z = e._z * n,
  4688. i
  4689. }
  4690. ,
  4691. e.FromArray = function(t, i) {
  4692. return i || (i = 0),
  4693. new e(t[i],t[i + 1],t[i + 2],t[i + 3])
  4694. }
  4695. ,
  4696. e.FromArrayToRef = function(e, t, i) {
  4697. i.x = e[t],
  4698. i.y = e[t + 1],
  4699. i.z = e[t + 2],
  4700. i.w = e[t + 3]
  4701. }
  4702. ,
  4703. e.FromEulerAngles = function(t, i, n) {
  4704. var r = new e;
  4705. return e.RotationYawPitchRollToRef(i, t, n, r),
  4706. r
  4707. }
  4708. ,
  4709. e.FromEulerAnglesToRef = function(t, i, n, r) {
  4710. return e.RotationYawPitchRollToRef(i, t, n, r),
  4711. r
  4712. }
  4713. ,
  4714. e.FromEulerVector = function(t) {
  4715. var i = new e;
  4716. return e.RotationYawPitchRollToRef(t._y, t._x, t._z, i),
  4717. i
  4718. }
  4719. ,
  4720. e.FromEulerVectorToRef = function(t, i) {
  4721. return e.RotationYawPitchRollToRef(t._y, t._x, t._z, i),
  4722. i
  4723. }
  4724. ,
  4725. e.FromUnitVectorsToRef = function(e, t, i) {
  4726. var n = x.Dot(e, t) + 1;
  4727. return n < m ? Math.abs(e.x) > Math.abs(e.z) ? i.set(-e.y, e.x, 0, 0) : i.set(0, -e.z, e.y, 0) : (x.CrossToRef(e, t, I.Vector3[0]),
  4728. i.set(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z, n)),
  4729. i.normalize()
  4730. }
  4731. ,
  4732. e.RotationYawPitchRoll = function(t, i, n) {
  4733. var r = new e;
  4734. return e.RotationYawPitchRollToRef(t, i, n, r),
  4735. r
  4736. }
  4737. ,
  4738. e.RotationYawPitchRollToRef = function(e, t, i, n) {
  4739. var r = .5 * i
  4740. , o = .5 * t
  4741. , a = .5 * e
  4742. , s = Math.sin(r)
  4743. , l = Math.cos(r)
  4744. , c = Math.sin(o)
  4745. , u = Math.cos(o)
  4746. , h = Math.sin(a)
  4747. , d = Math.cos(a);
  4748. n.x = d * c * l + h * u * s,
  4749. n.y = h * u * l - d * c * s,
  4750. n.z = d * u * s - h * c * l,
  4751. n.w = d * u * l + h * c * s
  4752. }
  4753. ,
  4754. e.RotationAlphaBetaGamma = function(t, i, n) {
  4755. var r = new e;
  4756. return e.RotationAlphaBetaGammaToRef(t, i, n, r),
  4757. r
  4758. }
  4759. ,
  4760. e.RotationAlphaBetaGammaToRef = function(e, t, i, n) {
  4761. var r = .5 * (i + e)
  4762. , o = .5 * (i - e)
  4763. , a = .5 * t;
  4764. n.x = Math.cos(o) * Math.sin(a),
  4765. n.y = Math.sin(o) * Math.sin(a),
  4766. n.z = Math.sin(r) * Math.cos(a),
  4767. n.w = Math.cos(r) * Math.cos(a)
  4768. }
  4769. ,
  4770. e.RotationQuaternionFromAxis = function(t, i, n) {
  4771. var r = new e(0,0,0,0);
  4772. return e.RotationQuaternionFromAxisToRef(t, i, n, r),
  4773. r
  4774. }
  4775. ,
  4776. e.RotationQuaternionFromAxisToRef = function(t, i, n, r) {
  4777. var o = M.Matrix[0];
  4778. P.FromXYZAxesToRef(t.normalize(), i.normalize(), n.normalize(), o),
  4779. e.FromRotationMatrixToRef(o, r)
  4780. }
  4781. ,
  4782. e.FromLookDirectionLH = function(t, i) {
  4783. var n = new e;
  4784. return e.FromLookDirectionLHToRef(t, i, n),
  4785. n
  4786. }
  4787. ,
  4788. e.FromLookDirectionLHToRef = function(t, i, n) {
  4789. var r = M.Matrix[0];
  4790. P.LookDirectionLHToRef(t, i, r),
  4791. e.FromRotationMatrixToRef(r, n)
  4792. }
  4793. ,
  4794. e.FromLookDirectionRH = function(t, i) {
  4795. var n = new e;
  4796. return e.FromLookDirectionRHToRef(t, i, n),
  4797. n
  4798. }
  4799. ,
  4800. e.FromLookDirectionRHToRef = function(t, i, n) {
  4801. var r = M.Matrix[0];
  4802. return P.LookDirectionRHToRef(t, i, r),
  4803. e.FromRotationMatrixToRef(r, n)
  4804. }
  4805. ,
  4806. e.Slerp = function(t, i, n) {
  4807. var r = e.Identity();
  4808. return e.SlerpToRef(t, i, n, r),
  4809. r
  4810. }
  4811. ,
  4812. e.SlerpToRef = function(e, t, i, n) {
  4813. var r, o, a = e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w, s = !1;
  4814. if (a < 0 && (s = !0,
  4815. a = -a),
  4816. a > .999999)
  4817. o = 1 - i,
  4818. r = s ? -i : i;
  4819. else {
  4820. var l = Math.acos(a)
  4821. , c = 1 / Math.sin(l);
  4822. o = Math.sin((1 - i) * l) * c,
  4823. r = s ? -Math.sin(i * l) * c : Math.sin(i * l) * c
  4824. }
  4825. n.x = o * e._x + r * t._x,
  4826. n.y = o * e._y + r * t._y,
  4827. n.z = o * e._z + r * t._z,
  4828. n.w = o * e._w + r * t._w
  4829. }
  4830. ,
  4831. e.Hermite = function(t, i, n, r, o) {
  4832. var a = o * o
  4833. , s = o * a
  4834. , l = 2 * s - 3 * a + 1
  4835. , c = -2 * s + 3 * a
  4836. , u = s - 2 * a + o
  4837. , h = s - a;
  4838. return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h,t._w * l + n._w * c + i._w * u + r._w * h)
  4839. }
  4840. ,
  4841. e.Hermite1stDerivative = function(t, i, n, r, o) {
  4842. var a = e.Zero();
  4843. return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
  4844. a
  4845. }
  4846. ,
  4847. e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
  4848. var a = r * r;
  4849. o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
  4850. o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
  4851. o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z,
  4852. o.w = 6 * (a - r) * e.w + (3 * a - 4 * r + 1) * t.w + 6 * (-a + r) * i.w + (3 * a - 2 * r) * n.w
  4853. }
  4854. ,
  4855. e
  4856. }()
  4857. , P = function() {
  4858. function e() {
  4859. this._isIdentity = !1,
  4860. this._isIdentityDirty = !0,
  4861. this._isIdentity3x2 = !0,
  4862. this._isIdentity3x2Dirty = !0,
  4863. this.updateFlag = -1,
  4864. T.MatrixTrackPrecisionChange && T.MatrixTrackedMatrices.push(this),
  4865. this._m = new T.MatrixCurrentType(16),
  4866. this.markAsUpdated()
  4867. }
  4868. return Object.defineProperty(e, "Use64Bits", {
  4869. get: function() {
  4870. return T.MatrixUse64Bits
  4871. },
  4872. enumerable: !1,
  4873. configurable: !0
  4874. }),
  4875. Object.defineProperty(e.prototype, "m", {
  4876. get: function() {
  4877. return this._m
  4878. },
  4879. enumerable: !1,
  4880. configurable: !0
  4881. }),
  4882. e.prototype.markAsUpdated = function() {
  4883. this.updateFlag = e._UpdateFlagSeed++,
  4884. this._isIdentity = !1,
  4885. this._isIdentity3x2 = !1,
  4886. this._isIdentityDirty = !0,
  4887. this._isIdentity3x2Dirty = !0
  4888. }
  4889. ,
  4890. e.prototype._updateIdentityStatus = function(e, t, i, n) {
  4891. void 0 === t && (t = !1),
  4892. void 0 === i && (i = !1),
  4893. void 0 === n && (n = !0),
  4894. this._isIdentity = e,
  4895. this._isIdentity3x2 = e || i,
  4896. this._isIdentityDirty = !this._isIdentity && t,
  4897. this._isIdentity3x2Dirty = !this._isIdentity3x2 && n
  4898. }
  4899. ,
  4900. e.prototype.isIdentity = function() {
  4901. if (this._isIdentityDirty) {
  4902. this._isIdentityDirty = !1;
  4903. var e = this._m;
  4904. this._isIdentity = 1 === e[0] && 0 === e[1] && 0 === e[2] && 0 === e[3] && 0 === e[4] && 1 === e[5] && 0 === e[6] && 0 === e[7] && 0 === e[8] && 0 === e[9] && 1 === e[10] && 0 === e[11] && 0 === e[12] && 0 === e[13] && 0 === e[14] && 1 === e[15]
  4905. }
  4906. return this._isIdentity
  4907. }
  4908. ,
  4909. e.prototype.isIdentityAs3x2 = function() {
  4910. return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1,
  4911. 1 !== this._m[0] || 1 !== this._m[5] || 1 !== this._m[15] || 0 !== this._m[1] || 0 !== this._m[2] || 0 !== this._m[3] || 0 !== this._m[4] || 0 !== this._m[6] || 0 !== this._m[7] || 0 !== this._m[8] || 0 !== this._m[9] || 0 !== this._m[10] || 0 !== this._m[11] || 0 !== this._m[12] || 0 !== this._m[13] || 0 !== this._m[14] ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0),
  4912. this._isIdentity3x2
  4913. }
  4914. ,
  4915. e.prototype.determinant = function() {
  4916. if (!0 === this._isIdentity)
  4917. return 1;
  4918. var e = this._m
  4919. , t = e[0]
  4920. , i = e[1]
  4921. , n = e[2]
  4922. , r = e[3]
  4923. , o = e[4]
  4924. , a = e[5]
  4925. , s = e[6]
  4926. , l = e[7]
  4927. , c = e[8]
  4928. , u = e[9]
  4929. , h = e[10]
  4930. , d = e[11]
  4931. , p = e[12]
  4932. , f = e[13]
  4933. , _ = e[14]
  4934. , m = e[15]
  4935. , g = h * m - _ * d
  4936. , v = u * m - f * d
  4937. , y = u * _ - f * h
  4938. , b = c * m - p * d
  4939. , T = c * _ - h * p
  4940. , E = c * f - p * u;
  4941. return t * +(a * g - s * v + l * y) + i * -(o * g - s * b + l * T) + n * +(o * v - a * b + l * E) + r * -(o * y - a * T + s * E)
  4942. }
  4943. ,
  4944. e.prototype.toArray = function() {
  4945. return this._m
  4946. }
  4947. ,
  4948. e.prototype.asArray = function() {
  4949. return this._m
  4950. }
  4951. ,
  4952. e.prototype.invert = function() {
  4953. return this.invertToRef(this),
  4954. this
  4955. }
  4956. ,
  4957. e.prototype.reset = function() {
  4958. return e.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this),
  4959. this._updateIdentityStatus(!1),
  4960. this
  4961. }
  4962. ,
  4963. e.prototype.add = function(t) {
  4964. var i = new e;
  4965. return this.addToRef(t, i),
  4966. i
  4967. }
  4968. ,
  4969. e.prototype.addToRef = function(e, t) {
  4970. for (var i = this._m, n = t._m, r = e.m, o = 0; o < 16; o++)
  4971. n[o] = i[o] + r[o];
  4972. return t.markAsUpdated(),
  4973. this
  4974. }
  4975. ,
  4976. e.prototype.addToSelf = function(e) {
  4977. for (var t = this._m, i = e.m, n = 0; n < 16; n++)
  4978. t[n] += i[n];
  4979. return this.markAsUpdated(),
  4980. this
  4981. }
  4982. ,
  4983. e.prototype.invertToRef = function(t) {
  4984. if (!0 === this._isIdentity)
  4985. return e.IdentityToRef(t),
  4986. this;
  4987. var i = this._m
  4988. , n = i[0]
  4989. , r = i[1]
  4990. , o = i[2]
  4991. , a = i[3]
  4992. , s = i[4]
  4993. , l = i[5]
  4994. , c = i[6]
  4995. , u = i[7]
  4996. , h = i[8]
  4997. , d = i[9]
  4998. , p = i[10]
  4999. , f = i[11]
  5000. , _ = i[12]
  5001. , m = i[13]
  5002. , g = i[14]
  5003. , v = i[15]
  5004. , y = p * v - g * f
  5005. , b = d * v - m * f
  5006. , T = d * g - m * p
  5007. , E = h * v - _ * f
  5008. , S = h * g - p * _
  5009. , A = h * m - _ * d
  5010. , x = +(l * y - c * b + u * T)
  5011. , R = -(s * y - c * E + u * S)
  5012. , C = +(s * b - l * E + u * A)
  5013. , P = -(s * T - l * S + c * A)
  5014. , M = n * x + r * R + o * C + a * P;
  5015. if (0 === M)
  5016. return t.copyFrom(this),
  5017. this;
  5018. var I = 1 / M
  5019. , O = c * v - g * u
  5020. , D = l * v - m * u
  5021. , N = l * g - m * c
  5022. , L = s * v - _ * u
  5023. , F = s * g - _ * c
  5024. , w = s * m - _ * l
  5025. , B = c * f - p * u
  5026. , U = l * f - d * u
  5027. , V = l * p - d * c
  5028. , k = s * f - h * u
  5029. , G = s * p - h * c
  5030. , z = s * d - h * l
  5031. , W = -(r * y - o * b + a * T)
  5032. , H = +(n * y - o * E + a * S)
  5033. , X = -(n * b - r * E + a * A)
  5034. , j = +(n * T - r * S + o * A)
  5035. , Y = +(r * O - o * D + a * N)
  5036. , K = -(n * O - o * L + a * F)
  5037. , Q = +(n * D - r * L + a * w)
  5038. , q = -(n * N - r * F + o * w)
  5039. , Z = -(r * B - o * U + a * V)
  5040. , J = +(n * B - o * k + a * G)
  5041. , $ = -(n * U - r * k + a * z)
  5042. , ee = +(n * V - r * G + o * z);
  5043. return e.FromValuesToRef(x * I, W * I, Y * I, Z * I, R * I, H * I, K * I, J * I, C * I, X * I, Q * I, $ * I, P * I, j * I, q * I, ee * I, t),
  5044. this
  5045. }
  5046. ,
  5047. e.prototype.addAtIndex = function(e, t) {
  5048. return this._m[e] += t,
  5049. this.markAsUpdated(),
  5050. this
  5051. }
  5052. ,
  5053. e.prototype.multiplyAtIndex = function(e, t) {
  5054. return this._m[e] *= t,
  5055. this.markAsUpdated(),
  5056. this
  5057. }
  5058. ,
  5059. e.prototype.setTranslationFromFloats = function(e, t, i) {
  5060. return this._m[12] = e,
  5061. this._m[13] = t,
  5062. this._m[14] = i,
  5063. this.markAsUpdated(),
  5064. this
  5065. }
  5066. ,
  5067. e.prototype.addTranslationFromFloats = function(e, t, i) {
  5068. return this._m[12] += e,
  5069. this._m[13] += t,
  5070. this._m[14] += i,
  5071. this.markAsUpdated(),
  5072. this
  5073. }
  5074. ,
  5075. e.prototype.setTranslation = function(e) {
  5076. return this.setTranslationFromFloats(e._x, e._y, e._z)
  5077. }
  5078. ,
  5079. e.prototype.getTranslation = function() {
  5080. return new x(this._m[12],this._m[13],this._m[14])
  5081. }
  5082. ,
  5083. e.prototype.getTranslationToRef = function(e) {
  5084. return e.x = this._m[12],
  5085. e.y = this._m[13],
  5086. e.z = this._m[14],
  5087. this
  5088. }
  5089. ,
  5090. e.prototype.removeRotationAndScaling = function() {
  5091. var t = this.m;
  5092. return e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t[12], t[13], t[14], t[15], this),
  5093. this._updateIdentityStatus(0 === t[12] && 0 === t[13] && 0 === t[14] && 1 === t[15]),
  5094. this
  5095. }
  5096. ,
  5097. e.prototype.multiply = function(t) {
  5098. var i = new e;
  5099. return this.multiplyToRef(t, i),
  5100. i
  5101. }
  5102. ,
  5103. e.prototype.copyFrom = function(e) {
  5104. e.copyToArray(this._m);
  5105. var t = e;
  5106. return this.updateFlag = t.updateFlag,
  5107. this._updateIdentityStatus(t._isIdentity, t._isIdentityDirty, t._isIdentity3x2, t._isIdentity3x2Dirty),
  5108. this
  5109. }
  5110. ,
  5111. e.prototype.copyToArray = function(e, t) {
  5112. void 0 === t && (t = 0);
  5113. var i = this._m;
  5114. return e[t] = i[0],
  5115. e[t + 1] = i[1],
  5116. e[t + 2] = i[2],
  5117. e[t + 3] = i[3],
  5118. e[t + 4] = i[4],
  5119. e[t + 5] = i[5],
  5120. e[t + 6] = i[6],
  5121. e[t + 7] = i[7],
  5122. e[t + 8] = i[8],
  5123. e[t + 9] = i[9],
  5124. e[t + 10] = i[10],
  5125. e[t + 11] = i[11],
  5126. e[t + 12] = i[12],
  5127. e[t + 13] = i[13],
  5128. e[t + 14] = i[14],
  5129. e[t + 15] = i[15],
  5130. this
  5131. }
  5132. ,
  5133. e.prototype.multiplyToRef = function(e, t) {
  5134. return this._isIdentity ? (t.copyFrom(e),
  5135. this) : e._isIdentity ? (t.copyFrom(this),
  5136. this) : (this.multiplyToArray(e, t._m, 0),
  5137. t.markAsUpdated(),
  5138. this)
  5139. }
  5140. ,
  5141. e.prototype.multiplyToArray = function(e, t, i) {
  5142. var n = this._m
  5143. , r = e.m
  5144. , o = n[0]
  5145. , a = n[1]
  5146. , s = n[2]
  5147. , l = n[3]
  5148. , c = n[4]
  5149. , u = n[5]
  5150. , h = n[6]
  5151. , d = n[7]
  5152. , p = n[8]
  5153. , f = n[9]
  5154. , _ = n[10]
  5155. , m = n[11]
  5156. , g = n[12]
  5157. , v = n[13]
  5158. , y = n[14]
  5159. , b = n[15]
  5160. , T = r[0]
  5161. , E = r[1]
  5162. , S = r[2]
  5163. , A = r[3]
  5164. , x = r[4]
  5165. , R = r[5]
  5166. , C = r[6]
  5167. , P = r[7]
  5168. , M = r[8]
  5169. , I = r[9]
  5170. , O = r[10]
  5171. , D = r[11]
  5172. , N = r[12]
  5173. , L = r[13]
  5174. , F = r[14]
  5175. , w = r[15];
  5176. return t[i] = o * T + a * x + s * M + l * N,
  5177. t[i + 1] = o * E + a * R + s * I + l * L,
  5178. t[i + 2] = o * S + a * C + s * O + l * F,
  5179. t[i + 3] = o * A + a * P + s * D + l * w,
  5180. t[i + 4] = c * T + u * x + h * M + d * N,
  5181. t[i + 5] = c * E + u * R + h * I + d * L,
  5182. t[i + 6] = c * S + u * C + h * O + d * F,
  5183. t[i + 7] = c * A + u * P + h * D + d * w,
  5184. t[i + 8] = p * T + f * x + _ * M + m * N,
  5185. t[i + 9] = p * E + f * R + _ * I + m * L,
  5186. t[i + 10] = p * S + f * C + _ * O + m * F,
  5187. t[i + 11] = p * A + f * P + _ * D + m * w,
  5188. t[i + 12] = g * T + v * x + y * M + b * N,
  5189. t[i + 13] = g * E + v * R + y * I + b * L,
  5190. t[i + 14] = g * S + v * C + y * O + b * F,
  5191. t[i + 15] = g * A + v * P + y * D + b * w,
  5192. this
  5193. }
  5194. ,
  5195. e.prototype.equals = function(e) {
  5196. var t = e;
  5197. if (!t)
  5198. return !1;
  5199. if ((this._isIdentity || t._isIdentity) && !this._isIdentityDirty && !t._isIdentityDirty)
  5200. return this._isIdentity && t._isIdentity;
  5201. var i = this.m
  5202. , n = t.m;
  5203. return i[0] === n[0] && i[1] === n[1] && i[2] === n[2] && i[3] === n[3] && i[4] === n[4] && i[5] === n[5] && i[6] === n[6] && i[7] === n[7] && i[8] === n[8] && i[9] === n[9] && i[10] === n[10] && i[11] === n[11] && i[12] === n[12] && i[13] === n[13] && i[14] === n[14] && i[15] === n[15]
  5204. }
  5205. ,
  5206. e.prototype.clone = function() {
  5207. var t = new e;
  5208. return t.copyFrom(this),
  5209. t
  5210. }
  5211. ,
  5212. e.prototype.getClassName = function() {
  5213. return "Matrix"
  5214. }
  5215. ,
  5216. e.prototype.getHashCode = function() {
  5217. for (var e = S(this._m[0]), t = 1; t < 16; t++)
  5218. e = 397 * e ^ S(this._m[t]);
  5219. return e
  5220. }
  5221. ,
  5222. e.prototype.decomposeToTransformNode = function(e) {
  5223. return e.rotationQuaternion = e.rotationQuaternion || new C,
  5224. this.decompose(e.scaling, e.rotationQuaternion, e.position)
  5225. }
  5226. ,
  5227. e.prototype.decompose = function(t, i, n, r) {
  5228. if (this._isIdentity)
  5229. return n && n.setAll(0),
  5230. t && t.setAll(1),
  5231. i && i.copyFromFloats(0, 0, 0, 1),
  5232. !0;
  5233. var o = this._m;
  5234. if (n && n.copyFromFloats(o[12], o[13], o[14]),
  5235. (t = t || M.Vector3[0]).x = Math.sqrt(o[0] * o[0] + o[1] * o[1] + o[2] * o[2]),
  5236. t.y = Math.sqrt(o[4] * o[4] + o[5] * o[5] + o[6] * o[6]),
  5237. t.z = Math.sqrt(o[8] * o[8] + o[9] * o[9] + o[10] * o[10]),
  5238. r) {
  5239. var a = r.scaling.x < 0 ? -1 : 1
  5240. , s = r.scaling.y < 0 ? -1 : 1
  5241. , l = r.scaling.z < 0 ? -1 : 1;
  5242. t.x *= a,
  5243. t.y *= s,
  5244. t.z *= l
  5245. } else
  5246. this.determinant() <= 0 && (t.y *= -1);
  5247. if (0 === t._x || 0 === t._y || 0 === t._z)
  5248. return i && i.copyFromFloats(0, 0, 0, 1),
  5249. !1;
  5250. if (i) {
  5251. var c = 1 / t._x
  5252. , u = 1 / t._y
  5253. , h = 1 / t._z;
  5254. e.FromValuesToRef(o[0] * c, o[1] * c, o[2] * c, 0, o[4] * u, o[5] * u, o[6] * u, 0, o[8] * h, o[9] * h, o[10] * h, 0, 0, 0, 0, 1, M.Matrix[0]),
  5255. C.FromRotationMatrixToRef(M.Matrix[0], i)
  5256. }
  5257. return !0
  5258. }
  5259. ,
  5260. e.prototype.getRow = function(e) {
  5261. if (e < 0 || e > 3)
  5262. return null;
  5263. var t = 4 * e;
  5264. return new R(this._m[t + 0],this._m[t + 1],this._m[t + 2],this._m[t + 3])
  5265. }
  5266. ,
  5267. e.prototype.setRow = function(e, t) {
  5268. return this.setRowFromFloats(e, t.x, t.y, t.z, t.w)
  5269. }
  5270. ,
  5271. e.prototype.transpose = function() {
  5272. return e.Transpose(this)
  5273. }
  5274. ,
  5275. e.prototype.transposeToRef = function(t) {
  5276. return e.TransposeToRef(this, t),
  5277. this
  5278. }
  5279. ,
  5280. e.prototype.setRowFromFloats = function(e, t, i, n, r) {
  5281. if (e < 0 || e > 3)
  5282. return this;
  5283. var o = 4 * e;
  5284. return this._m[o + 0] = t,
  5285. this._m[o + 1] = i,
  5286. this._m[o + 2] = n,
  5287. this._m[o + 3] = r,
  5288. this.markAsUpdated(),
  5289. this
  5290. }
  5291. ,
  5292. e.prototype.scale = function(t) {
  5293. var i = new e;
  5294. return this.scaleToRef(t, i),
  5295. i
  5296. }
  5297. ,
  5298. e.prototype.scaleToRef = function(e, t) {
  5299. for (var i = 0; i < 16; i++)
  5300. t._m[i] = this._m[i] * e;
  5301. return t.markAsUpdated(),
  5302. this
  5303. }
  5304. ,
  5305. e.prototype.scaleAndAddToRef = function(e, t) {
  5306. for (var i = 0; i < 16; i++)
  5307. t._m[i] += this._m[i] * e;
  5308. return t.markAsUpdated(),
  5309. this
  5310. }
  5311. ,
  5312. e.prototype.toNormalMatrix = function(t) {
  5313. var i = M.Matrix[0];
  5314. this.invertToRef(i),
  5315. i.transposeToRef(t);
  5316. var n = t._m;
  5317. e.FromValuesToRef(n[0], n[1], n[2], 0, n[4], n[5], n[6], 0, n[8], n[9], n[10], 0, 0, 0, 0, 1, t)
  5318. }
  5319. ,
  5320. e.prototype.getRotationMatrix = function() {
  5321. var t = new e;
  5322. return this.getRotationMatrixToRef(t),
  5323. t
  5324. }
  5325. ,
  5326. e.prototype.getRotationMatrixToRef = function(t) {
  5327. var i = M.Vector3[0];
  5328. if (!this.decompose(i))
  5329. return e.IdentityToRef(t),
  5330. this;
  5331. var n = this._m
  5332. , r = 1 / i._x
  5333. , o = 1 / i._y
  5334. , a = 1 / i._z;
  5335. return e.FromValuesToRef(n[0] * r, n[1] * r, n[2] * r, 0, n[4] * o, n[5] * o, n[6] * o, 0, n[8] * a, n[9] * a, n[10] * a, 0, 0, 0, 0, 1, t),
  5336. this
  5337. }
  5338. ,
  5339. e.prototype.toggleModelMatrixHandInPlace = function() {
  5340. var e = this._m;
  5341. e[2] *= -1,
  5342. e[6] *= -1,
  5343. e[8] *= -1,
  5344. e[9] *= -1,
  5345. e[14] *= -1,
  5346. this.markAsUpdated()
  5347. }
  5348. ,
  5349. e.prototype.toggleProjectionMatrixHandInPlace = function() {
  5350. var e = this._m;
  5351. e[8] *= -1,
  5352. e[9] *= -1,
  5353. e[10] *= -1,
  5354. e[11] *= -1,
  5355. this.markAsUpdated()
  5356. }
  5357. ,
  5358. e.FromArray = function(t, i) {
  5359. void 0 === i && (i = 0);
  5360. var n = new e;
  5361. return e.FromArrayToRef(t, i, n),
  5362. n
  5363. }
  5364. ,
  5365. e.FromArrayToRef = function(e, t, i) {
  5366. for (var n = 0; n < 16; n++)
  5367. i._m[n] = e[n + t];
  5368. i.markAsUpdated()
  5369. }
  5370. ,
  5371. e.FromFloat32ArrayToRefScaled = function(e, t, i, n) {
  5372. for (var r = 0; r < 16; r++)
  5373. n._m[r] = e[r + t] * i;
  5374. n.markAsUpdated()
  5375. }
  5376. ,
  5377. Object.defineProperty(e, "IdentityReadOnly", {
  5378. get: function() {
  5379. return e._IdentityReadOnly
  5380. },
  5381. enumerable: !1,
  5382. configurable: !0
  5383. }),
  5384. e.FromValuesToRef = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m) {
  5385. var g = m._m;
  5386. g[0] = e,
  5387. g[1] = t,
  5388. g[2] = i,
  5389. g[3] = n,
  5390. g[4] = r,
  5391. g[5] = o,
  5392. g[6] = a,
  5393. g[7] = s,
  5394. g[8] = l,
  5395. g[9] = c,
  5396. g[10] = u,
  5397. g[11] = h,
  5398. g[12] = d,
  5399. g[13] = p,
  5400. g[14] = f,
  5401. g[15] = _,
  5402. m.markAsUpdated()
  5403. }
  5404. ,
  5405. e.FromValues = function(t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m) {
  5406. var g = new e
  5407. , v = g._m;
  5408. return v[0] = t,
  5409. v[1] = i,
  5410. v[2] = n,
  5411. v[3] = r,
  5412. v[4] = o,
  5413. v[5] = a,
  5414. v[6] = s,
  5415. v[7] = l,
  5416. v[8] = c,
  5417. v[9] = u,
  5418. v[10] = h,
  5419. v[11] = d,
  5420. v[12] = p,
  5421. v[13] = f,
  5422. v[14] = _,
  5423. v[15] = m,
  5424. g.markAsUpdated(),
  5425. g
  5426. }
  5427. ,
  5428. e.Compose = function(t, i, n) {
  5429. var r = new e;
  5430. return e.ComposeToRef(t, i, n, r),
  5431. r
  5432. }
  5433. ,
  5434. e.ComposeToRef = function(e, t, i, n) {
  5435. var r = n._m
  5436. , o = t._x
  5437. , a = t._y
  5438. , s = t._z
  5439. , l = t._w
  5440. , c = o + o
  5441. , u = a + a
  5442. , h = s + s
  5443. , d = o * c
  5444. , p = o * u
  5445. , f = o * h
  5446. , _ = a * u
  5447. , m = a * h
  5448. , g = s * h
  5449. , v = l * c
  5450. , y = l * u
  5451. , b = l * h
  5452. , T = e._x
  5453. , E = e._y
  5454. , S = e._z;
  5455. r[0] = (1 - (_ + g)) * T,
  5456. r[1] = (p + b) * T,
  5457. r[2] = (f - y) * T,
  5458. r[3] = 0,
  5459. r[4] = (p - b) * E,
  5460. r[5] = (1 - (d + g)) * E,
  5461. r[6] = (m + v) * E,
  5462. r[7] = 0,
  5463. r[8] = (f + y) * S,
  5464. r[9] = (m - v) * S,
  5465. r[10] = (1 - (d + _)) * S,
  5466. r[11] = 0,
  5467. r[12] = i._x,
  5468. r[13] = i._y,
  5469. r[14] = i._z,
  5470. r[15] = 1,
  5471. n.markAsUpdated()
  5472. }
  5473. ,
  5474. e.Identity = function() {
  5475. var t = e.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  5476. return t._updateIdentityStatus(!0),
  5477. t
  5478. }
  5479. ,
  5480. e.IdentityToRef = function(t) {
  5481. e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, t),
  5482. t._updateIdentityStatus(!0)
  5483. }
  5484. ,
  5485. e.Zero = function() {
  5486. var t = e.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  5487. return t._updateIdentityStatus(!1),
  5488. t
  5489. }
  5490. ,
  5491. e.RotationX = function(t) {
  5492. var i = new e;
  5493. return e.RotationXToRef(t, i),
  5494. i
  5495. }
  5496. ,
  5497. e.Invert = function(t) {
  5498. var i = new e;
  5499. return t.invertToRef(i),
  5500. i
  5501. }
  5502. ,
  5503. e.RotationXToRef = function(t, i) {
  5504. var n = Math.sin(t)
  5505. , r = Math.cos(t);
  5506. e.FromValuesToRef(1, 0, 0, 0, 0, r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, i),
  5507. i._updateIdentityStatus(1 === r && 0 === n)
  5508. }
  5509. ,
  5510. e.RotationY = function(t) {
  5511. var i = new e;
  5512. return e.RotationYToRef(t, i),
  5513. i
  5514. }
  5515. ,
  5516. e.RotationYToRef = function(t, i) {
  5517. var n = Math.sin(t)
  5518. , r = Math.cos(t);
  5519. e.FromValuesToRef(r, 0, -n, 0, 0, 1, 0, 0, n, 0, r, 0, 0, 0, 0, 1, i),
  5520. i._updateIdentityStatus(1 === r && 0 === n)
  5521. }
  5522. ,
  5523. e.RotationZ = function(t) {
  5524. var i = new e;
  5525. return e.RotationZToRef(t, i),
  5526. i
  5527. }
  5528. ,
  5529. e.RotationZToRef = function(t, i) {
  5530. var n = Math.sin(t)
  5531. , r = Math.cos(t);
  5532. e.FromValuesToRef(r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, i),
  5533. i._updateIdentityStatus(1 === r && 0 === n)
  5534. }
  5535. ,
  5536. e.RotationAxis = function(t, i) {
  5537. var n = new e;
  5538. return e.RotationAxisToRef(t, i, n),
  5539. n
  5540. }
  5541. ,
  5542. e.RotationAxisToRef = function(e, t, i) {
  5543. var n = Math.sin(-t)
  5544. , r = Math.cos(-t)
  5545. , o = 1 - r;
  5546. e.normalize();
  5547. var a = i._m;
  5548. a[0] = e._x * e._x * o + r,
  5549. a[1] = e._x * e._y * o - e._z * n,
  5550. a[2] = e._x * e._z * o + e._y * n,
  5551. a[3] = 0,
  5552. a[4] = e._y * e._x * o + e._z * n,
  5553. a[5] = e._y * e._y * o + r,
  5554. a[6] = e._y * e._z * o - e._x * n,
  5555. a[7] = 0,
  5556. a[8] = e._z * e._x * o - e._y * n,
  5557. a[9] = e._z * e._y * o + e._x * n,
  5558. a[10] = e._z * e._z * o + r,
  5559. a[11] = 0,
  5560. a[12] = 0,
  5561. a[13] = 0,
  5562. a[14] = 0,
  5563. a[15] = 1,
  5564. i.markAsUpdated()
  5565. }
  5566. ,
  5567. e.RotationAlignToRef = function(e, t, i) {
  5568. var n = x.Dot(t, e)
  5569. , r = i._m;
  5570. if (n < -1 + m)
  5571. r[0] = -1,
  5572. r[1] = 0,
  5573. r[2] = 0,
  5574. r[3] = 0,
  5575. r[4] = 0,
  5576. r[5] = -1,
  5577. r[6] = 0,
  5578. r[7] = 0,
  5579. r[8] = 0,
  5580. r[9] = 0,
  5581. r[10] = 1,
  5582. r[11] = 0;
  5583. else {
  5584. var o = x.Cross(t, e)
  5585. , a = 1 / (1 + n);
  5586. r[0] = o._x * o._x * a + n,
  5587. r[1] = o._y * o._x * a - o._z,
  5588. r[2] = o._z * o._x * a + o._y,
  5589. r[3] = 0,
  5590. r[4] = o._x * o._y * a + o._z,
  5591. r[5] = o._y * o._y * a + n,
  5592. r[6] = o._z * o._y * a - o._x,
  5593. r[7] = 0,
  5594. r[8] = o._x * o._z * a - o._y,
  5595. r[9] = o._y * o._z * a + o._x,
  5596. r[10] = o._z * o._z * a + n,
  5597. r[11] = 0
  5598. }
  5599. r[12] = 0,
  5600. r[13] = 0,
  5601. r[14] = 0,
  5602. r[15] = 1,
  5603. i.markAsUpdated()
  5604. }
  5605. ,
  5606. e.RotationYawPitchRoll = function(t, i, n) {
  5607. var r = new e;
  5608. return e.RotationYawPitchRollToRef(t, i, n, r),
  5609. r
  5610. }
  5611. ,
  5612. e.RotationYawPitchRollToRef = function(e, t, i, n) {
  5613. C.RotationYawPitchRollToRef(e, t, i, M.Quaternion[0]),
  5614. M.Quaternion[0].toRotationMatrix(n)
  5615. }
  5616. ,
  5617. e.Scaling = function(t, i, n) {
  5618. var r = new e;
  5619. return e.ScalingToRef(t, i, n, r),
  5620. r
  5621. }
  5622. ,
  5623. e.ScalingToRef = function(t, i, n, r) {
  5624. e.FromValuesToRef(t, 0, 0, 0, 0, i, 0, 0, 0, 0, n, 0, 0, 0, 0, 1, r),
  5625. r._updateIdentityStatus(1 === t && 1 === i && 1 === n)
  5626. }
  5627. ,
  5628. e.Translation = function(t, i, n) {
  5629. var r = new e;
  5630. return e.TranslationToRef(t, i, n, r),
  5631. r
  5632. }
  5633. ,
  5634. e.TranslationToRef = function(t, i, n, r) {
  5635. e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, n, 1, r),
  5636. r._updateIdentityStatus(0 === t && 0 === i && 0 === n)
  5637. }
  5638. ,
  5639. e.Lerp = function(t, i, n) {
  5640. var r = new e;
  5641. return e.LerpToRef(t, i, n, r),
  5642. r
  5643. }
  5644. ,
  5645. e.LerpToRef = function(e, t, i, n) {
  5646. for (var r = n._m, o = e.m, a = t.m, s = 0; s < 16; s++)
  5647. r[s] = o[s] * (1 - i) + a[s] * i;
  5648. n.markAsUpdated()
  5649. }
  5650. ,
  5651. e.DecomposeLerp = function(t, i, n) {
  5652. var r = new e;
  5653. return e.DecomposeLerpToRef(t, i, n, r),
  5654. r
  5655. }
  5656. ,
  5657. e.DecomposeLerpToRef = function(t, i, n, r) {
  5658. var o = M.Vector3[0]
  5659. , a = M.Quaternion[0]
  5660. , s = M.Vector3[1];
  5661. t.decompose(o, a, s);
  5662. var l = M.Vector3[2]
  5663. , c = M.Quaternion[1]
  5664. , u = M.Vector3[3];
  5665. i.decompose(l, c, u);
  5666. var h = M.Vector3[4];
  5667. x.LerpToRef(o, l, n, h);
  5668. var d = M.Quaternion[2];
  5669. C.SlerpToRef(a, c, n, d);
  5670. var p = M.Vector3[5];
  5671. x.LerpToRef(s, u, n, p),
  5672. e.ComposeToRef(h, d, p, r)
  5673. }
  5674. ,
  5675. e.LookAtLH = function(t, i, n) {
  5676. var r = new e;
  5677. return e.LookAtLHToRef(t, i, n, r),
  5678. r
  5679. }
  5680. ,
  5681. e.LookAtLHToRef = function(t, i, n, r) {
  5682. var o = M.Vector3[0]
  5683. , a = M.Vector3[1]
  5684. , s = M.Vector3[2];
  5685. i.subtractToRef(t, s),
  5686. s.normalize(),
  5687. x.CrossToRef(n, s, o);
  5688. var l = o.lengthSquared();
  5689. 0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
  5690. x.CrossToRef(s, o, a),
  5691. a.normalize();
  5692. var c = -x.Dot(o, t)
  5693. , u = -x.Dot(a, t)
  5694. , h = -x.Dot(s, t);
  5695. e.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r)
  5696. }
  5697. ,
  5698. e.LookAtRH = function(t, i, n) {
  5699. var r = new e;
  5700. return e.LookAtRHToRef(t, i, n, r),
  5701. r
  5702. }
  5703. ,
  5704. e.LookAtRHToRef = function(t, i, n, r) {
  5705. var o = M.Vector3[0]
  5706. , a = M.Vector3[1]
  5707. , s = M.Vector3[2];
  5708. t.subtractToRef(i, s),
  5709. s.normalize(),
  5710. x.CrossToRef(n, s, o);
  5711. var l = o.lengthSquared();
  5712. 0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
  5713. x.CrossToRef(s, o, a),
  5714. a.normalize();
  5715. var c = -x.Dot(o, t)
  5716. , u = -x.Dot(a, t)
  5717. , h = -x.Dot(s, t);
  5718. e.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r)
  5719. }
  5720. ,
  5721. e.LookDirectionLH = function(t, i) {
  5722. var n = new e;
  5723. return e.LookDirectionLHToRef(t, i, n),
  5724. n
  5725. }
  5726. ,
  5727. e.LookDirectionLHToRef = function(t, i, n) {
  5728. var r = M.Vector3[0];
  5729. r.copyFrom(t),
  5730. r.scaleInPlace(-1);
  5731. var o = M.Vector3[1];
  5732. x.CrossToRef(i, r, o),
  5733. e.FromValuesToRef(o._x, o._y, o._z, 0, i._x, i._y, i._z, 0, r._x, r._y, r._z, 0, 0, 0, 0, 1, n)
  5734. }
  5735. ,
  5736. e.LookDirectionRH = function(t, i) {
  5737. var n = new e;
  5738. return e.LookDirectionRHToRef(t, i, n),
  5739. n
  5740. }
  5741. ,
  5742. e.LookDirectionRHToRef = function(t, i, n) {
  5743. var r = M.Vector3[2];
  5744. x.CrossToRef(i, t, r),
  5745. e.FromValuesToRef(r._x, r._y, r._z, 0, i._x, i._y, i._z, 0, t._x, t._y, t._z, 0, 0, 0, 0, 1, n)
  5746. }
  5747. ,
  5748. e.OrthoLH = function(t, i, n, r, o) {
  5749. var a = new e;
  5750. return e.OrthoLHToRef(t, i, n, r, a, o),
  5751. a
  5752. }
  5753. ,
  5754. e.OrthoLHToRef = function(t, i, n, r, o, a) {
  5755. var s = 2 / t
  5756. , l = 2 / i
  5757. , c = 2 / (r - n)
  5758. , u = -(r + n) / (r - n);
  5759. e.FromValuesToRef(s, 0, 0, 0, 0, l, 0, 0, 0, 0, c, 0, 0, 0, u, 1, o),
  5760. a && o.multiplyToRef(O, o),
  5761. o._updateIdentityStatus(1 === s && 1 === l && 1 === c && 0 === u)
  5762. }
  5763. ,
  5764. e.OrthoOffCenterLH = function(t, i, n, r, o, a, s) {
  5765. var l = new e;
  5766. return e.OrthoOffCenterLHToRef(t, i, n, r, o, a, l, s),
  5767. l
  5768. }
  5769. ,
  5770. e.OrthoOffCenterLHToRef = function(t, i, n, r, o, a, s, l) {
  5771. var c = 2 / (i - t)
  5772. , u = 2 / (r - n)
  5773. , h = 2 / (a - o)
  5774. , d = -(a + o) / (a - o)
  5775. , p = (t + i) / (t - i)
  5776. , f = (r + n) / (n - r);
  5777. e.FromValuesToRef(c, 0, 0, 0, 0, u, 0, 0, 0, 0, h, 0, p, f, d, 1, s),
  5778. l && s.multiplyToRef(O, s),
  5779. s.markAsUpdated()
  5780. }
  5781. ,
  5782. e.OrthoOffCenterRH = function(t, i, n, r, o, a, s) {
  5783. var l = new e;
  5784. return e.OrthoOffCenterRHToRef(t, i, n, r, o, a, l, s),
  5785. l
  5786. }
  5787. ,
  5788. e.OrthoOffCenterRHToRef = function(t, i, n, r, o, a, s, l) {
  5789. e.OrthoOffCenterLHToRef(t, i, n, r, o, a, s, l),
  5790. s._m[10] *= -1
  5791. }
  5792. ,
  5793. e.PerspectiveLH = function(t, i, n, r, o, a) {
  5794. void 0 === a && (a = 0);
  5795. var s = new e
  5796. , l = 2 * n / t
  5797. , c = 2 * n / i
  5798. , u = (r + n) / (r - n)
  5799. , h = -2 * r * n / (r - n)
  5800. , d = Math.tan(a);
  5801. return e.FromValuesToRef(l, 0, 0, 0, 0, c, 0, d, 0, 0, u, 1, 0, 0, h, 0, s),
  5802. o && s.multiplyToRef(O, s),
  5803. s._updateIdentityStatus(!1),
  5804. s
  5805. }
  5806. ,
  5807. e.PerspectiveFovLH = function(t, i, n, r, o, a, s) {
  5808. void 0 === a && (a = 0),
  5809. void 0 === s && (s = !1);
  5810. var l = new e;
  5811. return e.PerspectiveFovLHToRef(t, i, n, r, l, !0, o, a, s),
  5812. l
  5813. }
  5814. ,
  5815. e.PerspectiveFovLHToRef = function(t, i, n, r, o, a, s, l, c) {
  5816. void 0 === a && (a = !0),
  5817. void 0 === l && (l = 0),
  5818. void 0 === c && (c = !1);
  5819. var u = n
  5820. , h = r
  5821. , d = 1 / Math.tan(.5 * t)
  5822. , p = a ? d / i : d
  5823. , f = a ? d : d * i
  5824. , _ = c && 0 === u ? -1 : 0 !== h ? (h + u) / (h - u) : 1
  5825. , m = c && 0 === u ? 2 * h : 0 !== h ? -2 * h * u / (h - u) : -2 * u
  5826. , g = Math.tan(l);
  5827. e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, 1, 0, 0, m, 0, o),
  5828. s && o.multiplyToRef(O, o),
  5829. o._updateIdentityStatus(!1)
  5830. }
  5831. ,
  5832. e.PerspectiveFovReverseLHToRef = function(t, i, n, r, o, a, s, l) {
  5833. void 0 === a && (a = !0),
  5834. void 0 === l && (l = 0);
  5835. var c = 1 / Math.tan(.5 * t)
  5836. , u = a ? c / i : c
  5837. , h = a ? c : c * i
  5838. , d = Math.tan(l);
  5839. e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, 1, 0, 0, 1, 0, o),
  5840. s && o.multiplyToRef(O, o),
  5841. o._updateIdentityStatus(!1)
  5842. }
  5843. ,
  5844. e.PerspectiveFovRH = function(t, i, n, r, o, a, s) {
  5845. void 0 === a && (a = 0),
  5846. void 0 === s && (s = !1);
  5847. var l = new e;
  5848. return e.PerspectiveFovRHToRef(t, i, n, r, l, !0, o, a, s),
  5849. l
  5850. }
  5851. ,
  5852. e.PerspectiveFovRHToRef = function(t, i, n, r, o, a, s, l, c) {
  5853. void 0 === a && (a = !0),
  5854. void 0 === l && (l = 0),
  5855. void 0 === c && (c = !1);
  5856. var u = n
  5857. , h = r
  5858. , d = 1 / Math.tan(.5 * t)
  5859. , p = a ? d / i : d
  5860. , f = a ? d : d * i
  5861. , _ = c && 0 === u ? 1 : 0 !== h ? -(h + u) / (h - u) : -1
  5862. , m = c && 0 === u ? 2 * h : 0 !== h ? -2 * h * u / (h - u) : -2 * u
  5863. , g = Math.tan(l);
  5864. e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, -1, 0, 0, m, 0, o),
  5865. s && o.multiplyToRef(O, o),
  5866. o._updateIdentityStatus(!1)
  5867. }
  5868. ,
  5869. e.PerspectiveFovReverseRHToRef = function(t, i, n, r, o, a, s, l) {
  5870. void 0 === a && (a = !0),
  5871. void 0 === l && (l = 0);
  5872. var c = 1 / Math.tan(.5 * t)
  5873. , u = a ? c / i : c
  5874. , h = a ? c : c * i
  5875. , d = Math.tan(l);
  5876. e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, -1, 0, 0, -1, 0, o),
  5877. s && o.multiplyToRef(O, o),
  5878. o._updateIdentityStatus(!1)
  5879. }
  5880. ,
  5881. e.PerspectiveFovWebVRToRef = function(e, t, i, n, r, o, a) {
  5882. void 0 === r && (r = !1),
  5883. void 0 === a && (a = 0);
  5884. var s = r ? -1 : 1
  5885. , l = Math.tan(e.upDegrees * Math.PI / 180)
  5886. , c = Math.tan(e.downDegrees * Math.PI / 180)
  5887. , u = Math.tan(e.leftDegrees * Math.PI / 180)
  5888. , h = Math.tan(e.rightDegrees * Math.PI / 180)
  5889. , d = 2 / (u + h)
  5890. , p = 2 / (l + c)
  5891. , f = Math.tan(a)
  5892. , _ = n._m;
  5893. _[0] = d,
  5894. _[1] = _[2] = _[3] = _[4] = 0,
  5895. _[5] = p,
  5896. _[6] = 0,
  5897. _[7] = f,
  5898. _[8] = (u - h) * d * .5,
  5899. _[9] = -(l - c) * p * .5,
  5900. _[10] = -i / (t - i),
  5901. _[11] = 1 * s,
  5902. _[12] = _[13] = _[15] = 0,
  5903. _[14] = -2 * i * t / (i - t),
  5904. o && n.multiplyToRef(O, n),
  5905. n.markAsUpdated()
  5906. }
  5907. ,
  5908. e.GetFinalMatrix = function(t, i, n, r, o, a) {
  5909. var s = t.width
  5910. , l = t.height
  5911. , c = t.x
  5912. , u = t.y
  5913. , h = e.FromValues(s / 2, 0, 0, 0, 0, -l / 2, 0, 0, 0, 0, a - o, 0, c + s / 2, l / 2 + u, o, 1)
  5914. , d = M.Matrix[0];
  5915. return i.multiplyToRef(n, d),
  5916. d.multiplyToRef(r, d),
  5917. d.multiply(h)
  5918. }
  5919. ,
  5920. e.GetAsMatrix2x2 = function(e) {
  5921. var t = e.m
  5922. , i = [t[0], t[1], t[4], t[5]];
  5923. return T.MatrixUse64Bits ? i : new Float32Array(i)
  5924. }
  5925. ,
  5926. e.GetAsMatrix3x3 = function(e) {
  5927. var t = e.m
  5928. , i = [t[0], t[1], t[2], t[4], t[5], t[6], t[8], t[9], t[10]];
  5929. return T.MatrixUse64Bits ? i : new Float32Array(i)
  5930. }
  5931. ,
  5932. e.Transpose = function(t) {
  5933. var i = new e;
  5934. return e.TransposeToRef(t, i),
  5935. i
  5936. }
  5937. ,
  5938. e.TransposeToRef = function(e, t) {
  5939. var i = t._m
  5940. , n = e.m;
  5941. i[0] = n[0],
  5942. i[1] = n[4],
  5943. i[2] = n[8],
  5944. i[3] = n[12],
  5945. i[4] = n[1],
  5946. i[5] = n[5],
  5947. i[6] = n[9],
  5948. i[7] = n[13],
  5949. i[8] = n[2],
  5950. i[9] = n[6],
  5951. i[10] = n[10],
  5952. i[11] = n[14],
  5953. i[12] = n[3],
  5954. i[13] = n[7],
  5955. i[14] = n[11],
  5956. i[15] = n[15],
  5957. t.markAsUpdated(),
  5958. t._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
  5959. }
  5960. ,
  5961. e.Reflection = function(t) {
  5962. var i = new e;
  5963. return e.ReflectionToRef(t, i),
  5964. i
  5965. }
  5966. ,
  5967. e.ReflectionToRef = function(t, i) {
  5968. t.normalize();
  5969. var n = t.normal.x
  5970. , r = t.normal.y
  5971. , o = t.normal.z
  5972. , a = -2 * n
  5973. , s = -2 * r
  5974. , l = -2 * o;
  5975. e.FromValuesToRef(a * n + 1, s * n, l * n, 0, a * r, s * r + 1, l * r, 0, a * o, s * o, l * o + 1, 0, a * t.d, s * t.d, l * t.d, 1, i)
  5976. }
  5977. ,
  5978. e.FromXYZAxesToRef = function(t, i, n, r) {
  5979. e.FromValuesToRef(t._x, t._y, t._z, 0, i._x, i._y, i._z, 0, n._x, n._y, n._z, 0, 0, 0, 0, 1, r)
  5980. }
  5981. ,
  5982. e.FromQuaternionToRef = function(e, t) {
  5983. var i = e._x * e._x
  5984. , n = e._y * e._y
  5985. , r = e._z * e._z
  5986. , o = e._x * e._y
  5987. , a = e._z * e._w
  5988. , s = e._z * e._x
  5989. , l = e._y * e._w
  5990. , c = e._y * e._z
  5991. , u = e._x * e._w;
  5992. t._m[0] = 1 - 2 * (n + r),
  5993. t._m[1] = 2 * (o + a),
  5994. t._m[2] = 2 * (s - l),
  5995. t._m[3] = 0,
  5996. t._m[4] = 2 * (o - a),
  5997. t._m[5] = 1 - 2 * (r + i),
  5998. t._m[6] = 2 * (c + u),
  5999. t._m[7] = 0,
  6000. t._m[8] = 2 * (s + l),
  6001. t._m[9] = 2 * (c - u),
  6002. t._m[10] = 1 - 2 * (n + i),
  6003. t._m[11] = 0,
  6004. t._m[12] = 0,
  6005. t._m[13] = 0,
  6006. t._m[14] = 0,
  6007. t._m[15] = 1,
  6008. t.markAsUpdated()
  6009. }
  6010. ,
  6011. e._UpdateFlagSeed = 0,
  6012. e._IdentityReadOnly = e.Identity(),
  6013. e
  6014. }()
  6015. , M = function() {
  6016. function e() {}
  6017. return e.Vector3 = g.BuildTuple(11, x.Zero),
  6018. e.Matrix = g.BuildTuple(2, P.Identity),
  6019. e.Quaternion = g.BuildTuple(3, C.Zero),
  6020. e
  6021. }()
  6022. , I = function() {
  6023. function e() {}
  6024. return e.Vector2 = g.BuildTuple(3, A.Zero),
  6025. e.Vector3 = g.BuildTuple(13, x.Zero),
  6026. e.Vector4 = g.BuildTuple(3, R.Zero),
  6027. e.Quaternion = g.BuildTuple(2, C.Zero),
  6028. e.Matrix = g.BuildTuple(8, P.Identity),
  6029. e
  6030. }();
  6031. y("BABYLON.Vector2", A),
  6032. y("BABYLON.Vector3", x),
  6033. y("BABYLON.Vector4", R),
  6034. y("BABYLON.Matrix", P);
  6035. var O = P.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
  6036. , D = function() {
  6037. function e(e, t, i) {
  6038. void 0 === e && (e = 0),
  6039. void 0 === t && (t = 0),
  6040. void 0 === i && (i = 0),
  6041. this.r = e,
  6042. this.g = t,
  6043. this.b = i
  6044. }
  6045. return e.prototype.toString = function() {
  6046. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}"
  6047. }
  6048. ,
  6049. e.prototype.getClassName = function() {
  6050. return "Color3"
  6051. }
  6052. ,
  6053. e.prototype.getHashCode = function() {
  6054. var e = 255 * this.r | 0;
  6055. return 397 * (e = 397 * e ^ (255 * this.g | 0)) ^ (255 * this.b | 0)
  6056. }
  6057. ,
  6058. e.prototype.toArray = function(e, t) {
  6059. return void 0 === t && (t = 0),
  6060. e[t] = this.r,
  6061. e[t + 1] = this.g,
  6062. e[t + 2] = this.b,
  6063. this
  6064. }
  6065. ,
  6066. e.prototype.fromArray = function(t, i) {
  6067. return void 0 === i && (i = 0),
  6068. e.FromArrayToRef(t, i, this),
  6069. this
  6070. }
  6071. ,
  6072. e.prototype.toColor4 = function(e) {
  6073. return void 0 === e && (e = 1),
  6074. new N(this.r,this.g,this.b,e)
  6075. }
  6076. ,
  6077. e.prototype.asArray = function() {
  6078. var e = new Array;
  6079. return this.toArray(e, 0),
  6080. e
  6081. }
  6082. ,
  6083. e.prototype.toLuminance = function() {
  6084. return .3 * this.r + .59 * this.g + .11 * this.b
  6085. }
  6086. ,
  6087. e.prototype.multiply = function(t) {
  6088. return new e(this.r * t.r,this.g * t.g,this.b * t.b)
  6089. }
  6090. ,
  6091. e.prototype.multiplyToRef = function(e, t) {
  6092. return t.r = this.r * e.r,
  6093. t.g = this.g * e.g,
  6094. t.b = this.b * e.b,
  6095. this
  6096. }
  6097. ,
  6098. e.prototype.equals = function(e) {
  6099. return e && this.r === e.r && this.g === e.g && this.b === e.b
  6100. }
  6101. ,
  6102. e.prototype.equalsFloats = function(e, t, i) {
  6103. return this.r === e && this.g === t && this.b === i
  6104. }
  6105. ,
  6106. e.prototype.scale = function(t) {
  6107. return new e(this.r * t,this.g * t,this.b * t)
  6108. }
  6109. ,
  6110. e.prototype.scaleToRef = function(e, t) {
  6111. return t.r = this.r * e,
  6112. t.g = this.g * e,
  6113. t.b = this.b * e,
  6114. this
  6115. }
  6116. ,
  6117. e.prototype.scaleAndAddToRef = function(e, t) {
  6118. return t.r += this.r * e,
  6119. t.g += this.g * e,
  6120. t.b += this.b * e,
  6121. this
  6122. }
  6123. ,
  6124. e.prototype.clampToRef = function(e, t, i) {
  6125. return void 0 === e && (e = 0),
  6126. void 0 === t && (t = 1),
  6127. i.r = d.Clamp(this.r, e, t),
  6128. i.g = d.Clamp(this.g, e, t),
  6129. i.b = d.Clamp(this.b, e, t),
  6130. this
  6131. }
  6132. ,
  6133. e.prototype.add = function(t) {
  6134. return new e(this.r + t.r,this.g + t.g,this.b + t.b)
  6135. }
  6136. ,
  6137. e.prototype.addToRef = function(e, t) {
  6138. return t.r = this.r + e.r,
  6139. t.g = this.g + e.g,
  6140. t.b = this.b + e.b,
  6141. this
  6142. }
  6143. ,
  6144. e.prototype.subtract = function(t) {
  6145. return new e(this.r - t.r,this.g - t.g,this.b - t.b)
  6146. }
  6147. ,
  6148. e.prototype.subtractToRef = function(e, t) {
  6149. return t.r = this.r - e.r,
  6150. t.g = this.g - e.g,
  6151. t.b = this.b - e.b,
  6152. this
  6153. }
  6154. ,
  6155. e.prototype.clone = function() {
  6156. return new e(this.r,this.g,this.b)
  6157. }
  6158. ,
  6159. e.prototype.copyFrom = function(e) {
  6160. return this.r = e.r,
  6161. this.g = e.g,
  6162. this.b = e.b,
  6163. this
  6164. }
  6165. ,
  6166. e.prototype.copyFromFloats = function(e, t, i) {
  6167. return this.r = e,
  6168. this.g = t,
  6169. this.b = i,
  6170. this
  6171. }
  6172. ,
  6173. e.prototype.set = function(e, t, i) {
  6174. return this.copyFromFloats(e, t, i)
  6175. }
  6176. ,
  6177. e.prototype.toHexString = function() {
  6178. var e = Math.round(255 * this.r)
  6179. , t = Math.round(255 * this.g)
  6180. , i = Math.round(255 * this.b);
  6181. return "#" + d.ToHex(e) + d.ToHex(t) + d.ToHex(i)
  6182. }
  6183. ,
  6184. e.prototype.toLinearSpace = function() {
  6185. var t = new e;
  6186. return this.toLinearSpaceToRef(t),
  6187. t
  6188. }
  6189. ,
  6190. e.prototype.toHSV = function() {
  6191. var t = new e;
  6192. return this.toHSVToRef(t),
  6193. t
  6194. }
  6195. ,
  6196. e.prototype.toHSVToRef = function(e) {
  6197. var t = this.r
  6198. , i = this.g
  6199. , n = this.b
  6200. , r = Math.max(t, i, n)
  6201. , o = Math.min(t, i, n)
  6202. , a = 0
  6203. , s = 0
  6204. , l = r
  6205. , c = r - o;
  6206. 0 !== r && (s = c / r),
  6207. r != o && (r == t ? (a = (i - n) / c,
  6208. i < n && (a += 6)) : r == i ? a = (n - t) / c + 2 : r == n && (a = (t - i) / c + 4),
  6209. a *= 60),
  6210. e.r = a,
  6211. e.g = s,
  6212. e.b = l
  6213. }
  6214. ,
  6215. e.prototype.toLinearSpaceToRef = function(e) {
  6216. return e.r = Math.pow(this.r, f),
  6217. e.g = Math.pow(this.g, f),
  6218. e.b = Math.pow(this.b, f),
  6219. this
  6220. }
  6221. ,
  6222. e.prototype.toGammaSpace = function() {
  6223. var t = new e;
  6224. return this.toGammaSpaceToRef(t),
  6225. t
  6226. }
  6227. ,
  6228. e.prototype.toGammaSpaceToRef = function(e) {
  6229. return e.r = Math.pow(this.r, p),
  6230. e.g = Math.pow(this.g, p),
  6231. e.b = Math.pow(this.b, p),
  6232. this
  6233. }
  6234. ,
  6235. e.HSVtoRGBToRef = function(e, t, i, n) {
  6236. var r = i * t
  6237. , o = e / 60
  6238. , a = r * (1 - Math.abs(o % 2 - 1))
  6239. , s = 0
  6240. , l = 0
  6241. , c = 0;
  6242. o >= 0 && o <= 1 ? (s = r,
  6243. l = a) : o >= 1 && o <= 2 ? (s = a,
  6244. l = r) : o >= 2 && o <= 3 ? (l = r,
  6245. c = a) : o >= 3 && o <= 4 ? (l = a,
  6246. c = r) : o >= 4 && o <= 5 ? (s = a,
  6247. c = r) : o >= 5 && o <= 6 && (s = r,
  6248. c = a);
  6249. var u = i - r;
  6250. n.set(s + u, l + u, c + u)
  6251. }
  6252. ,
  6253. e.FromHexString = function(t) {
  6254. if ("#" !== t.substring(0, 1) || 7 !== t.length)
  6255. return new e(0,0,0);
  6256. var i = parseInt(t.substring(1, 3), 16)
  6257. , n = parseInt(t.substring(3, 5), 16)
  6258. , r = parseInt(t.substring(5, 7), 16);
  6259. return e.FromInts(i, n, r)
  6260. }
  6261. ,
  6262. e.FromArray = function(t, i) {
  6263. return void 0 === i && (i = 0),
  6264. new e(t[i],t[i + 1],t[i + 2])
  6265. }
  6266. ,
  6267. e.FromArrayToRef = function(e, t, i) {
  6268. void 0 === t && (t = 0),
  6269. i.r = e[t],
  6270. i.g = e[t + 1],
  6271. i.b = e[t + 2]
  6272. }
  6273. ,
  6274. e.FromInts = function(t, i, n) {
  6275. return new e(t / 255,i / 255,n / 255)
  6276. }
  6277. ,
  6278. e.Lerp = function(t, i, n) {
  6279. var r = new e(0,0,0);
  6280. return e.LerpToRef(t, i, n, r),
  6281. r
  6282. }
  6283. ,
  6284. e.LerpToRef = function(e, t, i, n) {
  6285. n.r = e.r + (t.r - e.r) * i,
  6286. n.g = e.g + (t.g - e.g) * i,
  6287. n.b = e.b + (t.b - e.b) * i
  6288. }
  6289. ,
  6290. e.Hermite = function(t, i, n, r, o) {
  6291. var a = o * o
  6292. , s = o * a
  6293. , l = 2 * s - 3 * a + 1
  6294. , c = -2 * s + 3 * a
  6295. , u = s - 2 * a + o
  6296. , h = s - a;
  6297. return new e(t.r * l + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h)
  6298. }
  6299. ,
  6300. e.Hermite1stDerivative = function(t, i, n, r, o) {
  6301. var a = e.Black();
  6302. return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
  6303. a
  6304. }
  6305. ,
  6306. e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
  6307. var a = r * r;
  6308. o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
  6309. o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
  6310. o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.b
  6311. }
  6312. ,
  6313. e.Red = function() {
  6314. return new e(1,0,0)
  6315. }
  6316. ,
  6317. e.Green = function() {
  6318. return new e(0,1,0)
  6319. }
  6320. ,
  6321. e.Blue = function() {
  6322. return new e(0,0,1)
  6323. }
  6324. ,
  6325. e.Black = function() {
  6326. return new e(0,0,0)
  6327. }
  6328. ,
  6329. Object.defineProperty(e, "BlackReadOnly", {
  6330. get: function() {
  6331. return e._BlackReadOnly
  6332. },
  6333. enumerable: !1,
  6334. configurable: !0
  6335. }),
  6336. e.White = function() {
  6337. return new e(1,1,1)
  6338. }
  6339. ,
  6340. e.Purple = function() {
  6341. return new e(.5,0,.5)
  6342. }
  6343. ,
  6344. e.Magenta = function() {
  6345. return new e(1,0,1)
  6346. }
  6347. ,
  6348. e.Yellow = function() {
  6349. return new e(1,1,0)
  6350. }
  6351. ,
  6352. e.Gray = function() {
  6353. return new e(.5,.5,.5)
  6354. }
  6355. ,
  6356. e.Teal = function() {
  6357. return new e(0,1,1)
  6358. }
  6359. ,
  6360. e.Random = function() {
  6361. return new e(Math.random(),Math.random(),Math.random())
  6362. }
  6363. ,
  6364. e._BlackReadOnly = e.Black(),
  6365. e
  6366. }()
  6367. , N = function() {
  6368. function e(e, t, i, n) {
  6369. void 0 === e && (e = 0),
  6370. void 0 === t && (t = 0),
  6371. void 0 === i && (i = 0),
  6372. void 0 === n && (n = 1),
  6373. this.r = e,
  6374. this.g = t,
  6375. this.b = i,
  6376. this.a = n
  6377. }
  6378. return e.prototype.addInPlace = function(e) {
  6379. return this.r += e.r,
  6380. this.g += e.g,
  6381. this.b += e.b,
  6382. this.a += e.a,
  6383. this
  6384. }
  6385. ,
  6386. e.prototype.asArray = function() {
  6387. var e = new Array;
  6388. return this.toArray(e, 0),
  6389. e
  6390. }
  6391. ,
  6392. e.prototype.toArray = function(e, t) {
  6393. return void 0 === t && (t = 0),
  6394. e[t] = this.r,
  6395. e[t + 1] = this.g,
  6396. e[t + 2] = this.b,
  6397. e[t + 3] = this.a,
  6398. this
  6399. }
  6400. ,
  6401. e.prototype.fromArray = function(t, i) {
  6402. return void 0 === i && (i = 0),
  6403. e.FromArrayToRef(t, i, this),
  6404. this
  6405. }
  6406. ,
  6407. e.prototype.equals = function(e) {
  6408. return e && this.r === e.r && this.g === e.g && this.b === e.b && this.a === e.a
  6409. }
  6410. ,
  6411. e.prototype.add = function(t) {
  6412. return new e(this.r + t.r,this.g + t.g,this.b + t.b,this.a + t.a)
  6413. }
  6414. ,
  6415. e.prototype.subtract = function(t) {
  6416. return new e(this.r - t.r,this.g - t.g,this.b - t.b,this.a - t.a)
  6417. }
  6418. ,
  6419. e.prototype.subtractToRef = function(e, t) {
  6420. return t.r = this.r - e.r,
  6421. t.g = this.g - e.g,
  6422. t.b = this.b - e.b,
  6423. t.a = this.a - e.a,
  6424. this
  6425. }
  6426. ,
  6427. e.prototype.scale = function(t) {
  6428. return new e(this.r * t,this.g * t,this.b * t,this.a * t)
  6429. }
  6430. ,
  6431. e.prototype.scaleToRef = function(e, t) {
  6432. return t.r = this.r * e,
  6433. t.g = this.g * e,
  6434. t.b = this.b * e,
  6435. t.a = this.a * e,
  6436. this
  6437. }
  6438. ,
  6439. e.prototype.scaleAndAddToRef = function(e, t) {
  6440. return t.r += this.r * e,
  6441. t.g += this.g * e,
  6442. t.b += this.b * e,
  6443. t.a += this.a * e,
  6444. this
  6445. }
  6446. ,
  6447. e.prototype.clampToRef = function(e, t, i) {
  6448. return void 0 === e && (e = 0),
  6449. void 0 === t && (t = 1),
  6450. i.r = d.Clamp(this.r, e, t),
  6451. i.g = d.Clamp(this.g, e, t),
  6452. i.b = d.Clamp(this.b, e, t),
  6453. i.a = d.Clamp(this.a, e, t),
  6454. this
  6455. }
  6456. ,
  6457. e.prototype.multiply = function(t) {
  6458. return new e(this.r * t.r,this.g * t.g,this.b * t.b,this.a * t.a)
  6459. }
  6460. ,
  6461. e.prototype.multiplyToRef = function(e, t) {
  6462. return t.r = this.r * e.r,
  6463. t.g = this.g * e.g,
  6464. t.b = this.b * e.b,
  6465. t.a = this.a * e.a,
  6466. t
  6467. }
  6468. ,
  6469. e.prototype.toString = function() {
  6470. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}"
  6471. }
  6472. ,
  6473. e.prototype.getClassName = function() {
  6474. return "Color4"
  6475. }
  6476. ,
  6477. e.prototype.getHashCode = function() {
  6478. var e = 255 * this.r | 0;
  6479. return 397 * (e = 397 * (e = 397 * e ^ (255 * this.g | 0)) ^ (255 * this.b | 0)) ^ (255 * this.a | 0)
  6480. }
  6481. ,
  6482. e.prototype.clone = function() {
  6483. return new e(this.r,this.g,this.b,this.a)
  6484. }
  6485. ,
  6486. e.prototype.copyFrom = function(e) {
  6487. return this.r = e.r,
  6488. this.g = e.g,
  6489. this.b = e.b,
  6490. this.a = e.a,
  6491. this
  6492. }
  6493. ,
  6494. e.prototype.copyFromFloats = function(e, t, i, n) {
  6495. return this.r = e,
  6496. this.g = t,
  6497. this.b = i,
  6498. this.a = n,
  6499. this
  6500. }
  6501. ,
  6502. e.prototype.set = function(e, t, i, n) {
  6503. return this.copyFromFloats(e, t, i, n)
  6504. }
  6505. ,
  6506. e.prototype.toHexString = function(e) {
  6507. void 0 === e && (e = !1);
  6508. var t = Math.round(255 * this.r)
  6509. , i = Math.round(255 * this.g)
  6510. , n = Math.round(255 * this.b);
  6511. if (e)
  6512. return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n);
  6513. var r = Math.round(255 * this.a);
  6514. return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n) + d.ToHex(r)
  6515. }
  6516. ,
  6517. e.prototype.toLinearSpace = function() {
  6518. var t = new e;
  6519. return this.toLinearSpaceToRef(t),
  6520. t
  6521. }
  6522. ,
  6523. e.prototype.toLinearSpaceToRef = function(e) {
  6524. return e.r = Math.pow(this.r, f),
  6525. e.g = Math.pow(this.g, f),
  6526. e.b = Math.pow(this.b, f),
  6527. e.a = this.a,
  6528. this
  6529. }
  6530. ,
  6531. e.prototype.toGammaSpace = function() {
  6532. var t = new e;
  6533. return this.toGammaSpaceToRef(t),
  6534. t
  6535. }
  6536. ,
  6537. e.prototype.toGammaSpaceToRef = function(e) {
  6538. return e.r = Math.pow(this.r, p),
  6539. e.g = Math.pow(this.g, p),
  6540. e.b = Math.pow(this.b, p),
  6541. e.a = this.a,
  6542. this
  6543. }
  6544. ,
  6545. e.FromHexString = function(t) {
  6546. if ("#" !== t.substring(0, 1) || 9 !== t.length && 7 !== t.length)
  6547. return new e(0,0,0,0);
  6548. var i = parseInt(t.substring(1, 3), 16)
  6549. , n = parseInt(t.substring(3, 5), 16)
  6550. , r = parseInt(t.substring(5, 7), 16)
  6551. , o = 9 === t.length ? parseInt(t.substring(7, 9), 16) : 255;
  6552. return e.FromInts(i, n, r, o)
  6553. }
  6554. ,
  6555. e.Lerp = function(t, i, n) {
  6556. var r = new e(0,0,0,0);
  6557. return e.LerpToRef(t, i, n, r),
  6558. r
  6559. }
  6560. ,
  6561. e.LerpToRef = function(e, t, i, n) {
  6562. n.r = e.r + (t.r - e.r) * i,
  6563. n.g = e.g + (t.g - e.g) * i,
  6564. n.b = e.b + (t.b - e.b) * i,
  6565. n.a = e.a + (t.a - e.a) * i
  6566. }
  6567. ,
  6568. e.Hermite = function(t, i, n, r, o) {
  6569. var a = o * o
  6570. , s = o * a
  6571. , l = 2 * s - 3 * a + 1
  6572. , c = -2 * s + 3 * a
  6573. , u = s - 2 * a + o
  6574. , h = s - a;
  6575. return new e(t.r * l + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h,t.a * l + n.a * c + i.a * u + r.a * h)
  6576. }
  6577. ,
  6578. e.Hermite1stDerivative = function(t, i, n, r, o) {
  6579. var a = new e;
  6580. return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
  6581. a
  6582. }
  6583. ,
  6584. e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
  6585. var a = r * r;
  6586. o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
  6587. o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
  6588. o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.b,
  6589. o.a = 6 * (a - r) * e.a + (3 * a - 4 * r + 1) * t.a + 6 * (-a + r) * i.a + (3 * a - 2 * r) * n.a
  6590. }
  6591. ,
  6592. e.FromColor3 = function(t, i) {
  6593. return void 0 === i && (i = 1),
  6594. new e(t.r,t.g,t.b,i)
  6595. }
  6596. ,
  6597. e.FromArray = function(t, i) {
  6598. return void 0 === i && (i = 0),
  6599. new e(t[i],t[i + 1],t[i + 2],t[i + 3])
  6600. }
  6601. ,
  6602. e.FromArrayToRef = function(e, t, i) {
  6603. void 0 === t && (t = 0),
  6604. i.r = e[t],
  6605. i.g = e[t + 1],
  6606. i.b = e[t + 2],
  6607. i.a = e[t + 3]
  6608. }
  6609. ,
  6610. e.FromInts = function(t, i, n, r) {
  6611. return new e(t / 255,i / 255,n / 255,r / 255)
  6612. }
  6613. ,
  6614. e.CheckColors4 = function(e, t) {
  6615. if (e.length === 3 * t) {
  6616. for (var i = [], n = 0; n < e.length; n += 3) {
  6617. var r = n / 3 * 4;
  6618. i[r] = e[n],
  6619. i[r + 1] = e[n + 1],
  6620. i[r + 2] = e[n + 2],
  6621. i[r + 3] = 1
  6622. }
  6623. return i
  6624. }
  6625. return e
  6626. }
  6627. ,
  6628. e
  6629. }()
  6630. , L = function() {
  6631. function e() {}
  6632. return e.Color3 = g.BuildArray(3, D.Black),
  6633. e.Color4 = g.BuildArray(3, (function() {
  6634. return new N(0,0,0,0)
  6635. }
  6636. )),
  6637. e
  6638. }();
  6639. y("BABYLON.Color3", D),
  6640. y("BABYLON.Color4", N);
  6641. var F = function() {
  6642. function e(e, t) {
  6643. this.triggerOptions = e,
  6644. this.onBeforeExecuteObservable = new h,
  6645. e.parameter ? (this.trigger = e.trigger,
  6646. this._triggerParameter = e.parameter) : e.trigger ? this.trigger = e.trigger : this.trigger = e,
  6647. this._nextActiveAction = this,
  6648. this._condition = t
  6649. }
  6650. return e.prototype._prepare = function() {}
  6651. ,
  6652. e.prototype.getTriggerParameter = function() {
  6653. return this._triggerParameter
  6654. }
  6655. ,
  6656. e.prototype.setTriggerParameter = function(e) {
  6657. this._triggerParameter = e
  6658. }
  6659. ,
  6660. e.prototype._evaluateConditionForCurrentFrame = function() {
  6661. var e = this._condition;
  6662. if (!e)
  6663. return !0;
  6664. var t = this._actionManager.getScene().getRenderId();
  6665. return e._evaluationId !== t && (e._evaluationId = t,
  6666. e._currentResult = e.isValid()),
  6667. e._currentResult
  6668. }
  6669. ,
  6670. e.prototype._executeCurrent = function(e) {
  6671. this._evaluateConditionForCurrentFrame() && (this.onBeforeExecuteObservable.notifyObservers(this),
  6672. this._nextActiveAction.execute(e),
  6673. this.skipToNextActiveAction())
  6674. }
  6675. ,
  6676. e.prototype.execute = function(e) {}
  6677. ,
  6678. e.prototype.skipToNextActiveAction = function() {
  6679. this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager),
  6680. this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this
  6681. }
  6682. ,
  6683. e.prototype.then = function(e) {
  6684. return this._child = e,
  6685. e._actionManager = this._actionManager,
  6686. e._prepare(),
  6687. e
  6688. }
  6689. ,
  6690. e.prototype._getProperty = function(e) {
  6691. return this._actionManager._getProperty(e)
  6692. }
  6693. ,
  6694. e.prototype._getEffectiveTarget = function(e, t) {
  6695. return this._actionManager._getEffectiveTarget(e, t)
  6696. }
  6697. ,
  6698. e.prototype.serialize = function(e) {}
  6699. ,
  6700. e.prototype._serialize = function(e, t) {
  6701. var i = {
  6702. type: 1,
  6703. children: [],
  6704. name: e.name,
  6705. properties: e.properties || []
  6706. };
  6707. if (this._child && this._child.serialize(i),
  6708. this._condition) {
  6709. var n = this._condition.serialize();
  6710. return n.children.push(i),
  6711. t && t.children.push(n),
  6712. n
  6713. }
  6714. return t && t.children.push(i),
  6715. i
  6716. }
  6717. ,
  6718. e._SerializeValueAsString = function(e) {
  6719. return "number" == typeof e ? e.toString() : "boolean" == typeof e ? e ? "true" : "false" : e instanceof A ? e.x + ", " + e.y : e instanceof x ? e.x + ", " + e.y + ", " + e.z : e instanceof D ? e.r + ", " + e.g + ", " + e.b : e instanceof N ? e.r + ", " + e.g + ", " + e.b + ", " + e.a : e
  6720. }
  6721. ,
  6722. e._GetTargetProperty = function(e) {
  6723. return {
  6724. name: "target",
  6725. targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : "SceneProperties",
  6726. value: e._isScene ? "Scene" : e.name
  6727. }
  6728. }
  6729. ,
  6730. e
  6731. }();
  6732. y("BABYLON.Action", F);
  6733. var w = function() {
  6734. function e(e, t, i, n, r, o) {
  6735. this.source = e,
  6736. this.pointerX = t,
  6737. this.pointerY = i,
  6738. this.meshUnderPointer = n,
  6739. this.sourceEvent = r,
  6740. this.additionalData = o
  6741. }
  6742. return e.CreateNew = function(t, i, n) {
  6743. var r = t.getScene();
  6744. return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer || t,i,n)
  6745. }
  6746. ,
  6747. e.CreateNewFromSprite = function(t, i, n, r) {
  6748. return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,n,r)
  6749. }
  6750. ,
  6751. e.CreateNewFromScene = function(t, i) {
  6752. return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)
  6753. }
  6754. ,
  6755. e.CreateNewFromPrimitive = function(t, i, n, r) {
  6756. return new e(t,i.x,i.y,null,n,r)
  6757. }
  6758. ,
  6759. e
  6760. }()
  6761. , B = function(e, t) {
  6762. return B = Object.setPrototypeOf || {
  6763. __proto__: []
  6764. }instanceof Array && function(e, t) {
  6765. e.__proto__ = t
  6766. }
  6767. || function(e, t) {
  6768. for (var i in t)
  6769. Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i])
  6770. }
  6771. ,
  6772. B(e, t)
  6773. };
  6774. function U(e, t) {
  6775. if ("function" != typeof t && null !== t)
  6776. throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
  6777. function i() {
  6778. this.constructor = e
  6779. }
  6780. B(e, t),
  6781. e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype,
  6782. new i)
  6783. }
  6784. var V = function() {
  6785. return V = Object.assign || function(e) {
  6786. for (var t, i = 1, n = arguments.length; i < n; i++)
  6787. for (var r in t = arguments[i])
  6788. Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
  6789. return e
  6790. }
  6791. ,
  6792. V.apply(this, arguments)
  6793. };
  6794. function k(e, t, i, n) {
  6795. var r, o = arguments.length, a = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, i) : n;
  6796. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
  6797. a = Reflect.decorate(e, t, i, n);
  6798. else
  6799. for (var s = e.length - 1; s >= 0; s--)
  6800. (r = e[s]) && (a = (o < 3 ? r(a) : o > 3 ? r(t, i, a) : r(t, i)) || a);
  6801. return o > 3 && a && Object.defineProperty(t, i, a),
  6802. a
  6803. }
  6804. function G(e, t, i, n) {
  6805. return new (i || (i = Promise))((function(r, o) {
  6806. function a(e) {
  6807. try {
  6808. l(n.next(e))
  6809. } catch (e) {
  6810. o(e)
  6811. }
  6812. }
  6813. function s(e) {
  6814. try {
  6815. l(n.throw(e))
  6816. } catch (e) {
  6817. o(e)
  6818. }
  6819. }
  6820. function l(e) {
  6821. var t;
  6822. e.done ? r(e.value) : (t = e.value,
  6823. t instanceof i ? t : new i((function(e) {
  6824. e(t)
  6825. }
  6826. ))).then(a, s)
  6827. }
  6828. l((n = n.apply(e, t || [])).next())
  6829. }
  6830. ))
  6831. }
  6832. function z(e, t) {
  6833. var i, n, r, o, a = {
  6834. label: 0,
  6835. sent: function() {
  6836. if (1 & r[0])
  6837. throw r[1];
  6838. return r[1]
  6839. },
  6840. trys: [],
  6841. ops: []
  6842. };
  6843. return o = {
  6844. next: s(0),
  6845. throw: s(1),
  6846. return: s(2)
  6847. },
  6848. "function" == typeof Symbol && (o[Symbol.iterator] = function() {
  6849. return this
  6850. }
  6851. ),
  6852. o;
  6853. function s(o) {
  6854. return function(s) {
  6855. return function(o) {
  6856. if (i)
  6857. throw new TypeError("Generator is already executing.");
  6858. for (; a; )
  6859. try {
  6860. if (i = 1,
  6861. n && (r = 2 & o[0] ? n.return : o[0] ? n.throw || ((r = n.return) && r.call(n),
  6862. 0) : n.next) && !(r = r.call(n, o[1])).done)
  6863. return r;
  6864. switch (n = 0,
  6865. r && (o = [2 & o[0], r.value]),
  6866. o[0]) {
  6867. case 0:
  6868. case 1:
  6869. r = o;
  6870. break;
  6871. case 4:
  6872. return a.label++,
  6873. {
  6874. value: o[1],
  6875. done: !1
  6876. };
  6877. case 5:
  6878. a.label++,
  6879. n = o[1],
  6880. o = [0];
  6881. continue;
  6882. case 7:
  6883. o = a.ops.pop(),
  6884. a.trys.pop();
  6885. continue;
  6886. default:
  6887. if (!((r = (r = a.trys).length > 0 && r[r.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
  6888. a = 0;
  6889. continue
  6890. }
  6891. if (3 === o[0] && (!r || o[1] > r[0] && o[1] < r[3])) {
  6892. a.label = o[1];
  6893. break
  6894. }
  6895. if (6 === o[0] && a.label < r[1]) {
  6896. a.label = r[1],
  6897. r = o;
  6898. break
  6899. }
  6900. if (r && a.label < r[2]) {
  6901. a.label = r[2],
  6902. a.ops.push(o);
  6903. break
  6904. }
  6905. r[2] && a.ops.pop(),
  6906. a.trys.pop();
  6907. continue
  6908. }
  6909. o = t.call(e, a)
  6910. } catch (e) {
  6911. o = [6, e],
  6912. n = 0
  6913. } finally {
  6914. i = r = 0
  6915. }
  6916. if (5 & o[0])
  6917. throw o[1];
  6918. return {
  6919. value: o[0] ? o[1] : void 0,
  6920. done: !0
  6921. }
  6922. }([o, s])
  6923. }
  6924. }
  6925. }
  6926. function W(e, t, i) {
  6927. if (i || 2 === arguments.length)
  6928. for (var n, r = 0, o = t.length; r < o; r++)
  6929. !n && r in t || (n || (n = Array.prototype.slice.call(t, 0, r)),
  6930. n[r] = t[r]);
  6931. return e.concat(n || Array.prototype.slice.call(t))
  6932. }
  6933. Object.create,
  6934. Object.create;
  6935. var H = function() {
  6936. function e(e) {
  6937. this._actionManager = e
  6938. }
  6939. return e.prototype.isValid = function() {
  6940. return !0
  6941. }
  6942. ,
  6943. e.prototype._getProperty = function(e) {
  6944. return this._actionManager._getProperty(e)
  6945. }
  6946. ,
  6947. e.prototype._getEffectiveTarget = function(e, t) {
  6948. return this._actionManager._getEffectiveTarget(e, t)
  6949. }
  6950. ,
  6951. e.prototype.serialize = function() {}
  6952. ,
  6953. e.prototype._serialize = function(e) {
  6954. return {
  6955. type: 2,
  6956. children: [],
  6957. name: e.name,
  6958. properties: e.properties
  6959. }
  6960. }
  6961. ,
  6962. e
  6963. }()
  6964. , X = function(e) {
  6965. function t(i, n, r, o, a) {
  6966. void 0 === a && (a = t.IsEqual);
  6967. var s = e.call(this, i) || this;
  6968. return s.propertyPath = r,
  6969. s.value = o,
  6970. s.operator = a,
  6971. s._target = n,
  6972. s._effectiveTarget = s._getEffectiveTarget(n, s.propertyPath),
  6973. s._property = s._getProperty(s.propertyPath),
  6974. s
  6975. }
  6976. return U(t, e),
  6977. Object.defineProperty(t, "IsEqual", {
  6978. get: function() {
  6979. return t._IsEqual
  6980. },
  6981. enumerable: !1,
  6982. configurable: !0
  6983. }),
  6984. Object.defineProperty(t, "IsDifferent", {
  6985. get: function() {
  6986. return t._IsDifferent
  6987. },
  6988. enumerable: !1,
  6989. configurable: !0
  6990. }),
  6991. Object.defineProperty(t, "IsGreater", {
  6992. get: function() {
  6993. return t._IsGreater
  6994. },
  6995. enumerable: !1,
  6996. configurable: !0
  6997. }),
  6998. Object.defineProperty(t, "IsLesser", {
  6999. get: function() {
  7000. return t._IsLesser
  7001. },
  7002. enumerable: !1,
  7003. configurable: !0
  7004. }),
  7005. t.prototype.isValid = function() {
  7006. switch (this.operator) {
  7007. case t.IsGreater:
  7008. return this._effectiveTarget[this._property] > this.value;
  7009. case t.IsLesser:
  7010. return this._effectiveTarget[this._property] < this.value;
  7011. case t.IsEqual:
  7012. case t.IsDifferent:
  7013. var e;
  7014. return e = this.value.equals ? this.value.equals(this._effectiveTarget[this._property]) : this.value === this._effectiveTarget[this._property],
  7015. this.operator === t.IsEqual ? e : !e
  7016. }
  7017. return !1
  7018. }
  7019. ,
  7020. t.prototype.serialize = function() {
  7021. return this._serialize({
  7022. name: "ValueCondition",
  7023. properties: [F._GetTargetProperty(this._target), {
  7024. name: "propertyPath",
  7025. value: this.propertyPath
  7026. }, {
  7027. name: "value",
  7028. value: F._SerializeValueAsString(this.value)
  7029. }, {
  7030. name: "operator",
  7031. value: t.GetOperatorName(this.operator)
  7032. }]
  7033. })
  7034. }
  7035. ,
  7036. t.GetOperatorName = function(e) {
  7037. switch (e) {
  7038. case t._IsEqual:
  7039. return "IsEqual";
  7040. case t._IsDifferent:
  7041. return "IsDifferent";
  7042. case t._IsGreater:
  7043. return "IsGreater";
  7044. case t._IsLesser:
  7045. return "IsLesser";
  7046. default:
  7047. return ""
  7048. }
  7049. }
  7050. ,
  7051. t._IsEqual = 0,
  7052. t._IsDifferent = 1,
  7053. t._IsGreater = 2,
  7054. t._IsLesser = 3,
  7055. t
  7056. }(H)
  7057. , j = function(e) {
  7058. function t(t, i) {
  7059. var n = e.call(this, t) || this;
  7060. return n.predicate = i,
  7061. n
  7062. }
  7063. return U(t, e),
  7064. t.prototype.isValid = function() {
  7065. return this.predicate()
  7066. }
  7067. ,
  7068. t
  7069. }(H)
  7070. , Y = function(e) {
  7071. function t(t, i, n) {
  7072. var r = e.call(this, t) || this;
  7073. return r.value = n,
  7074. r._target = i,
  7075. r
  7076. }
  7077. return U(t, e),
  7078. t.prototype.isValid = function() {
  7079. return this._target.state === this.value
  7080. }
  7081. ,
  7082. t.prototype.serialize = function() {
  7083. return this._serialize({
  7084. name: "StateCondition",
  7085. properties: [F._GetTargetProperty(this._target), {
  7086. name: "value",
  7087. value: this.value
  7088. }]
  7089. })
  7090. }
  7091. ,
  7092. t
  7093. }(H);
  7094. y("BABYLON.ValueCondition", X),
  7095. y("BABYLON.PredicateCondition", j),
  7096. y("BABYLON.StateCondition", Y);
  7097. var K = function() {
  7098. function e() {}
  7099. return e._CheckLimit = function(t, i) {
  7100. var n = e._LogLimitOutputs[t];
  7101. return n ? n.current++ : (n = {
  7102. limit: i,
  7103. current: 1
  7104. },
  7105. e._LogLimitOutputs[t] = n),
  7106. n.current <= n.limit
  7107. }
  7108. ,
  7109. e._GenerateLimitMessage = function(t, i) {
  7110. var n = e._LogLimitOutputs[t];
  7111. if (n && e.MessageLimitReached && n.current === n.limit)
  7112. switch (i) {
  7113. case 0:
  7114. e.Log(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "log"));
  7115. break;
  7116. case 1:
  7117. e.Warn(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "warning"));
  7118. break;
  7119. case 2:
  7120. e.Error(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "error"))
  7121. }
  7122. }
  7123. ,
  7124. e._AddLogEntry = function(t) {
  7125. e._LogCache = t + e._LogCache,
  7126. e.OnNewCacheEntry && e.OnNewCacheEntry(t)
  7127. }
  7128. ,
  7129. e._FormatMessage = function(e) {
  7130. var t = function(e) {
  7131. return e < 10 ? "0" + e : "" + e
  7132. }
  7133. , i = new Date;
  7134. return "[" + t(i.getHours()) + ":" + t(i.getMinutes()) + ":" + t(i.getSeconds()) + "]: " + e
  7135. }
  7136. ,
  7137. e._LogDisabled = function(e, t) {}
  7138. ,
  7139. e._LogEnabled = function(t, i) {
  7140. if (void 0 === i || e._CheckLimit(t, i)) {
  7141. var n = e._FormatMessage(t);
  7142. console.log("BJS - " + n);
  7143. var r = "<div style='color:white'>" + n + "</div><br>";
  7144. e._AddLogEntry(r),
  7145. e._GenerateLimitMessage(t, 0)
  7146. }
  7147. }
  7148. ,
  7149. e._WarnDisabled = function(e, t) {}
  7150. ,
  7151. e._WarnEnabled = function(t, i) {
  7152. if (void 0 === i || e._CheckLimit(t, i)) {
  7153. var n = e._FormatMessage(t);
  7154. console.warn("BJS - " + n);
  7155. var r = "<div style='color:orange'>" + t + "</div><br>";
  7156. e._AddLogEntry(r),
  7157. e._GenerateLimitMessage(t, 1)
  7158. }
  7159. }
  7160. ,
  7161. e._ErrorDisabled = function(e, t) {}
  7162. ,
  7163. e._ErrorEnabled = function(t, i) {
  7164. if (void 0 === i || e._CheckLimit(t, i)) {
  7165. var n = e._FormatMessage(t);
  7166. e.errorsCount++,
  7167. console.error("BJS - " + n);
  7168. var r = "<div style='color:red'>" + n + "</div><br>";
  7169. e._AddLogEntry(r),
  7170. e._GenerateLimitMessage(t, 2)
  7171. }
  7172. }
  7173. ,
  7174. Object.defineProperty(e, "LogCache", {
  7175. get: function() {
  7176. return e._LogCache
  7177. },
  7178. enumerable: !1,
  7179. configurable: !0
  7180. }),
  7181. e.ClearLogCache = function() {
  7182. e._LogCache = "",
  7183. e._LogLimitOutputs = {},
  7184. e.errorsCount = 0
  7185. }
  7186. ,
  7187. Object.defineProperty(e, "LogLevels", {
  7188. set: function(t) {
  7189. (t & e.MessageLogLevel) === e.MessageLogLevel ? e.Log = e._LogEnabled : e.Log = e._LogDisabled,
  7190. (t & e.WarningLogLevel) === e.WarningLogLevel ? e.Warn = e._WarnEnabled : e.Warn = e._WarnDisabled,
  7191. (t & e.ErrorLogLevel) === e.ErrorLogLevel ? e.Error = e._ErrorEnabled : e.Error = e._ErrorDisabled
  7192. },
  7193. enumerable: !1,
  7194. configurable: !0
  7195. }),
  7196. e.NoneLogLevel = 0,
  7197. e.MessageLogLevel = 1,
  7198. e.WarningLogLevel = 2,
  7199. e.ErrorLogLevel = 4,
  7200. e.AllLogLevel = 7,
  7201. e.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",
  7202. e._LogCache = "",
  7203. e._LogLimitOutputs = {},
  7204. e.errorsCount = 0,
  7205. e.Log = e._LogEnabled,
  7206. e.Warn = e._WarnEnabled,
  7207. e.Error = e._ErrorEnabled,
  7208. e
  7209. }()
  7210. , Q = function(e) {
  7211. function t(t, i, n, r) {
  7212. var o = e.call(this, t, r) || this;
  7213. return o.propertyPath = n,
  7214. o._target = o._effectiveTarget = i,
  7215. o
  7216. }
  7217. return U(t, e),
  7218. t.prototype._prepare = function() {
  7219. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  7220. this._property = this._getProperty(this.propertyPath)
  7221. }
  7222. ,
  7223. t.prototype.execute = function() {
  7224. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property]
  7225. }
  7226. ,
  7227. t.prototype.serialize = function(t) {
  7228. return e.prototype._serialize.call(this, {
  7229. name: "SwitchBooleanAction",
  7230. properties: [F._GetTargetProperty(this._target), {
  7231. name: "propertyPath",
  7232. value: this.propertyPath
  7233. }]
  7234. }, t)
  7235. }
  7236. ,
  7237. t
  7238. }(F)
  7239. , q = function(e) {
  7240. function t(t, i, n, r) {
  7241. var o = e.call(this, t, r) || this;
  7242. return o.value = n,
  7243. o._target = i,
  7244. o
  7245. }
  7246. return U(t, e),
  7247. t.prototype.execute = function() {
  7248. this._target.state = this.value
  7249. }
  7250. ,
  7251. t.prototype.serialize = function(t) {
  7252. return e.prototype._serialize.call(this, {
  7253. name: "SetStateAction",
  7254. properties: [F._GetTargetProperty(this._target), {
  7255. name: "value",
  7256. value: this.value
  7257. }]
  7258. }, t)
  7259. }
  7260. ,
  7261. t
  7262. }(F)
  7263. , Z = function(e) {
  7264. function t(t, i, n, r, o) {
  7265. var a = e.call(this, t, o) || this;
  7266. return a.propertyPath = n,
  7267. a.value = r,
  7268. a._target = a._effectiveTarget = i,
  7269. a
  7270. }
  7271. return U(t, e),
  7272. t.prototype._prepare = function() {
  7273. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  7274. this._property = this._getProperty(this.propertyPath)
  7275. }
  7276. ,
  7277. t.prototype.execute = function() {
  7278. this._effectiveTarget[this._property] = this.value,
  7279. this._target.markAsDirty && this._target.markAsDirty(this._property)
  7280. }
  7281. ,
  7282. t.prototype.serialize = function(t) {
  7283. return e.prototype._serialize.call(this, {
  7284. name: "SetValueAction",
  7285. properties: [F._GetTargetProperty(this._target), {
  7286. name: "propertyPath",
  7287. value: this.propertyPath
  7288. }, {
  7289. name: "value",
  7290. value: F._SerializeValueAsString(this.value)
  7291. }]
  7292. }, t)
  7293. }
  7294. ,
  7295. t
  7296. }(F)
  7297. , J = function(e) {
  7298. function t(t, i, n, r, o) {
  7299. var a = e.call(this, t, o) || this;
  7300. return a.propertyPath = n,
  7301. a.value = r,
  7302. a._target = a._effectiveTarget = i,
  7303. a
  7304. }
  7305. return U(t, e),
  7306. t.prototype._prepare = function() {
  7307. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  7308. this._property = this._getProperty(this.propertyPath),
  7309. "number" != typeof this._effectiveTarget[this._property] && K.Warn("Warning: IncrementValueAction can only be used with number values")
  7310. }
  7311. ,
  7312. t.prototype.execute = function() {
  7313. this._effectiveTarget[this._property] += this.value,
  7314. this._target.markAsDirty && this._target.markAsDirty(this._property)
  7315. }
  7316. ,
  7317. t.prototype.serialize = function(t) {
  7318. return e.prototype._serialize.call(this, {
  7319. name: "IncrementValueAction",
  7320. properties: [F._GetTargetProperty(this._target), {
  7321. name: "propertyPath",
  7322. value: this.propertyPath
  7323. }, {
  7324. name: "value",
  7325. value: F._SerializeValueAsString(this.value)
  7326. }]
  7327. }, t)
  7328. }
  7329. ,
  7330. t
  7331. }(F)
  7332. , $ = function(e) {
  7333. function t(t, i, n, r, o, a) {
  7334. var s = e.call(this, t, a) || this;
  7335. return s.from = n,
  7336. s.to = r,
  7337. s.loop = o,
  7338. s._target = i,
  7339. s
  7340. }
  7341. return U(t, e),
  7342. t.prototype._prepare = function() {}
  7343. ,
  7344. t.prototype.execute = function() {
  7345. this._actionManager.getScene().beginAnimation(this._target, this.from, this.to, this.loop)
  7346. }
  7347. ,
  7348. t.prototype.serialize = function(t) {
  7349. return e.prototype._serialize.call(this, {
  7350. name: "PlayAnimationAction",
  7351. properties: [F._GetTargetProperty(this._target), {
  7352. name: "from",
  7353. value: String(this.from)
  7354. }, {
  7355. name: "to",
  7356. value: String(this.to)
  7357. }, {
  7358. name: "loop",
  7359. value: F._SerializeValueAsString(this.loop) || !1
  7360. }]
  7361. }, t)
  7362. }
  7363. ,
  7364. t
  7365. }(F)
  7366. , ee = function(e) {
  7367. function t(t, i, n) {
  7368. var r = e.call(this, t, n) || this;
  7369. return r._target = i,
  7370. r
  7371. }
  7372. return U(t, e),
  7373. t.prototype._prepare = function() {}
  7374. ,
  7375. t.prototype.execute = function() {
  7376. this._actionManager.getScene().stopAnimation(this._target)
  7377. }
  7378. ,
  7379. t.prototype.serialize = function(t) {
  7380. return e.prototype._serialize.call(this, {
  7381. name: "StopAnimationAction",
  7382. properties: [F._GetTargetProperty(this._target)]
  7383. }, t)
  7384. }
  7385. ,
  7386. t
  7387. }(F)
  7388. , te = function(e) {
  7389. function t(t, i) {
  7390. return void 0 === t && (t = a.ACTION_NothingTrigger),
  7391. e.call(this, t, i) || this
  7392. }
  7393. return U(t, e),
  7394. t.prototype.execute = function() {}
  7395. ,
  7396. t.prototype.serialize = function(t) {
  7397. return e.prototype._serialize.call(this, {
  7398. name: "DoNothingAction",
  7399. properties: []
  7400. }, t)
  7401. }
  7402. ,
  7403. t
  7404. }(F)
  7405. , ie = function(e) {
  7406. function t(t, i, n, r) {
  7407. void 0 === r && (r = !0);
  7408. var o = e.call(this, t, n) || this;
  7409. return o.children = i,
  7410. o.enableChildrenConditions = r,
  7411. o
  7412. }
  7413. return U(t, e),
  7414. t.prototype._prepare = function() {
  7415. for (var e = 0; e < this.children.length; e++)
  7416. this.children[e]._actionManager = this._actionManager,
  7417. this.children[e]._prepare()
  7418. }
  7419. ,
  7420. t.prototype.execute = function(e) {
  7421. for (var t = 0, i = this.children; t < i.length; t++) {
  7422. var n = i[t];
  7423. this.enableChildrenConditions && !n._evaluateConditionForCurrentFrame() || n.execute(e)
  7424. }
  7425. }
  7426. ,
  7427. t.prototype.serialize = function(t) {
  7428. for (var i = e.prototype._serialize.call(this, {
  7429. name: "CombineAction",
  7430. properties: [],
  7431. combine: []
  7432. }, t), n = 0; n < this.children.length; n++)
  7433. i.combine.push(this.children[n].serialize(null));
  7434. return i
  7435. }
  7436. ,
  7437. t
  7438. }(F)
  7439. , ne = function(e) {
  7440. function t(t, i, n) {
  7441. var r = e.call(this, t, n) || this;
  7442. return r.func = i,
  7443. r
  7444. }
  7445. return U(t, e),
  7446. t.prototype.execute = function(e) {
  7447. this.func(e)
  7448. }
  7449. ,
  7450. t
  7451. }(F)
  7452. , re = function(e) {
  7453. function t(t, i, n, r) {
  7454. var o = e.call(this, t, r) || this;
  7455. return o._target = i,
  7456. o._parent = n,
  7457. o
  7458. }
  7459. return U(t, e),
  7460. t.prototype._prepare = function() {}
  7461. ,
  7462. t.prototype.execute = function() {
  7463. if (this._target.parent !== this._parent) {
  7464. var e = this._parent.getWorldMatrix().clone();
  7465. e.invert(),
  7466. this._target.position = x.TransformCoordinates(this._target.position, e),
  7467. this._target.parent = this._parent
  7468. }
  7469. }
  7470. ,
  7471. t.prototype.serialize = function(t) {
  7472. return e.prototype._serialize.call(this, {
  7473. name: "SetParentAction",
  7474. properties: [F._GetTargetProperty(this._target), F._GetTargetProperty(this._parent)]
  7475. }, t)
  7476. }
  7477. ,
  7478. t
  7479. }(F);
  7480. y("BABYLON.SetParentAction", re),
  7481. y("BABYLON.ExecuteCodeAction", ne),
  7482. y("BABYLON.DoNothingAction", te),
  7483. y("BABYLON.StopAnimationAction", ee),
  7484. y("BABYLON.PlayAnimationAction", $),
  7485. y("BABYLON.IncrementValueAction", J),
  7486. y("BABYLON.SetValueAction", Z),
  7487. y("BABYLON.SetStateAction", q),
  7488. y("BABYLON.SetParentAction", re);
  7489. var oe = function(e, t) {
  7490. return -1 !== e.indexOf(t, e.length - t.length)
  7491. }
  7492. , ae = function(e, t) {
  7493. return !!e && 0 === e.indexOf(t)
  7494. }
  7495. , se = function(e) {
  7496. if ("undefined" != typeof TextDecoder)
  7497. return (new TextDecoder).decode(e);
  7498. for (var t = "", i = 0; i < e.byteLength; i++)
  7499. t += String.fromCharCode(e[i]);
  7500. return t
  7501. }
  7502. , le = function(e) {
  7503. for (var t, i, n, r, o, a, s, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = "", u = 0, h = ArrayBuffer.isView(e) ? new Uint8Array(e.buffer,e.byteOffset,e.byteLength) : new Uint8Array(e); u < h.length; )
  7504. r = (t = h[u++]) >> 2,
  7505. o = (3 & t) << 4 | (i = u < h.length ? h[u++] : Number.NaN) >> 4,
  7506. a = (15 & i) << 2 | (n = u < h.length ? h[u++] : Number.NaN) >> 6,
  7507. s = 63 & n,
  7508. isNaN(i) ? a = s = 64 : isNaN(n) && (s = 64),
  7509. c += l.charAt(r) + l.charAt(o) + l.charAt(a) + l.charAt(s);
  7510. return c
  7511. }
  7512. , ce = function(e) {
  7513. return atob(e)
  7514. }
  7515. , ue = function(e) {
  7516. for (var t = ce(e), i = t.length, n = new Uint8Array(new ArrayBuffer(i)), r = 0; r < i; r++)
  7517. n[r] = t.charCodeAt(r);
  7518. return n.buffer
  7519. }
  7520. , he = function(e, t) {
  7521. for (var i = String(e); i.length < t; )
  7522. i = "0" + i;
  7523. return i
  7524. }
  7525. , de = {
  7526. EndsWith: oe,
  7527. StartsWith: ae,
  7528. Decode: se,
  7529. EncodeArrayBufferToBase64: le,
  7530. DecodeBase64ToString: ce,
  7531. DecodeBase64ToBinary: ue,
  7532. PadNumber: he
  7533. }
  7534. , pe = function(e, t) {
  7535. return e ? e.getClassName && "Mesh" === e.getClassName() ? null : e.getClassName && "SubMesh" === e.getClassName() ? e.clone(t) : e.clone ? e.clone() : null : null
  7536. }
  7537. , fe = function() {
  7538. function e() {}
  7539. return e.DeepCopy = function(e, t, i, n) {
  7540. for (var r = function(e) {
  7541. var t = [];
  7542. do {
  7543. Object.getOwnPropertyNames(e).forEach((function(e) {
  7544. -1 === t.indexOf(e) && t.push(e)
  7545. }
  7546. ))
  7547. } while (e = Object.getPrototypeOf(e));
  7548. return t
  7549. }(e), o = 0, a = r; o < a.length; o++) {
  7550. var s = a[o];
  7551. if (("_" !== s[0] || n && -1 !== n.indexOf(s)) && !(oe(s, "Observable") || i && -1 !== i.indexOf(s))) {
  7552. var l = e[s]
  7553. , c = typeof l;
  7554. if ("function" !== c)
  7555. try {
  7556. if ("object" === c)
  7557. if (l instanceof Array) {
  7558. if (t[s] = [],
  7559. l.length > 0)
  7560. if ("object" == typeof l[0])
  7561. for (var u = 0; u < l.length; u++) {
  7562. var h = pe(l[u], t);
  7563. -1 === t[s].indexOf(h) && t[s].push(h)
  7564. }
  7565. else
  7566. t[s] = l.slice(0)
  7567. } else
  7568. t[s] = pe(l, t);
  7569. else
  7570. t[s] = l
  7571. } catch (e) {
  7572. K.Warn(e.message)
  7573. }
  7574. }
  7575. }
  7576. }
  7577. ,
  7578. e
  7579. }()
  7580. , _e = function(e) {
  7581. function t(t) {
  7582. var i = e.call(this) || this;
  7583. return (t = t || E.LastCreatedScene) ? (i._scene = t,
  7584. t.actionManagers.push(i),
  7585. i) : i
  7586. }
  7587. return U(t, e),
  7588. t.prototype.dispose = function() {
  7589. for (var e = this._scene.actionManagers.indexOf(this), i = 0; i < this.actions.length; i++) {
  7590. var n = this.actions[i];
  7591. t.Triggers[n.trigger]--,
  7592. 0 === t.Triggers[n.trigger] && delete t.Triggers[n.trigger]
  7593. }
  7594. e > -1 && this._scene.actionManagers.splice(e, 1)
  7595. }
  7596. ,
  7597. t.prototype.getScene = function() {
  7598. return this._scene
  7599. }
  7600. ,
  7601. t.prototype.hasSpecificTriggers = function(e) {
  7602. for (var t = 0; t < this.actions.length; t++) {
  7603. var i = this.actions[t];
  7604. if (e.indexOf(i.trigger) > -1)
  7605. return !0
  7606. }
  7607. return !1
  7608. }
  7609. ,
  7610. t.prototype.hasSpecificTriggers2 = function(e, t) {
  7611. for (var i = 0; i < this.actions.length; i++) {
  7612. var n = this.actions[i];
  7613. if (e == n.trigger || t == n.trigger)
  7614. return !0
  7615. }
  7616. return !1
  7617. }
  7618. ,
  7619. t.prototype.hasSpecificTrigger = function(e, t) {
  7620. for (var i = 0; i < this.actions.length; i++) {
  7621. var n = this.actions[i];
  7622. if (n.trigger === e) {
  7623. if (!t)
  7624. return !0;
  7625. if (t(n.getTriggerParameter()))
  7626. return !0
  7627. }
  7628. }
  7629. return !1
  7630. }
  7631. ,
  7632. Object.defineProperty(t.prototype, "hasPointerTriggers", {
  7633. get: function() {
  7634. for (var e = 0; e < this.actions.length; e++) {
  7635. var i = this.actions[e];
  7636. if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPointerOutTrigger)
  7637. return !0
  7638. }
  7639. return !1
  7640. },
  7641. enumerable: !1,
  7642. configurable: !0
  7643. }),
  7644. Object.defineProperty(t.prototype, "hasPickTriggers", {
  7645. get: function() {
  7646. for (var e = 0; e < this.actions.length; e++) {
  7647. var i = this.actions[e];
  7648. if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPickUpTrigger)
  7649. return !0
  7650. }
  7651. return !1
  7652. },
  7653. enumerable: !1,
  7654. configurable: !0
  7655. }),
  7656. t.prototype.registerAction = function(e) {
  7657. return e.trigger === t.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (K.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
  7658. null) : (this.actions.push(e),
  7659. t.Triggers[e.trigger] ? t.Triggers[e.trigger]++ : t.Triggers[e.trigger] = 1,
  7660. e._actionManager = this,
  7661. e._prepare(),
  7662. e)
  7663. }
  7664. ,
  7665. t.prototype.unregisterAction = function(e) {
  7666. var i = this.actions.indexOf(e);
  7667. return -1 !== i && (this.actions.splice(i, 1),
  7668. t.Triggers[e.trigger] -= 1,
  7669. 0 === t.Triggers[e.trigger] && delete t.Triggers[e.trigger],
  7670. e._actionManager = null,
  7671. !0)
  7672. }
  7673. ,
  7674. t.prototype.processTrigger = function(e, i) {
  7675. for (var n = 0; n < this.actions.length; n++) {
  7676. var r = this.actions[n];
  7677. if (r.trigger === e) {
  7678. if (i && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) {
  7679. var o = r.getTriggerParameter();
  7680. if (o && o !== i.sourceEvent.keyCode) {
  7681. if (!o.toLowerCase)
  7682. continue;
  7683. var a = o.toLowerCase();
  7684. if (a !== i.sourceEvent.key) {
  7685. var s = i.sourceEvent.charCode ? i.sourceEvent.charCode : i.sourceEvent.keyCode;
  7686. if (String.fromCharCode(s).toLowerCase() !== a)
  7687. continue
  7688. }
  7689. }
  7690. }
  7691. r._executeCurrent(i)
  7692. }
  7693. }
  7694. }
  7695. ,
  7696. t.prototype._getEffectiveTarget = function(e, t) {
  7697. for (var i = t.split("."), n = 0; n < i.length - 1; n++)
  7698. e = e[i[n]];
  7699. return e
  7700. }
  7701. ,
  7702. t.prototype._getProperty = function(e) {
  7703. var t = e.split(".");
  7704. return t[t.length - 1]
  7705. }
  7706. ,
  7707. t.prototype.serialize = function(e) {
  7708. for (var i = {
  7709. children: new Array,
  7710. name: e,
  7711. type: 3,
  7712. properties: new Array
  7713. }, n = 0; n < this.actions.length; n++) {
  7714. var r = {
  7715. type: 0,
  7716. children: new Array,
  7717. name: t.GetTriggerName(this.actions[n].trigger),
  7718. properties: new Array
  7719. }
  7720. , o = this.actions[n].triggerOptions;
  7721. if (o && "number" != typeof o)
  7722. if (o.parameter instanceof Node)
  7723. r.properties.push(F._GetTargetProperty(o.parameter));
  7724. else {
  7725. var a = {};
  7726. fe.DeepCopy(o.parameter, a, ["mesh"]),
  7727. o.parameter && o.parameter.mesh && (a._meshId = o.parameter.mesh.id),
  7728. r.properties.push({
  7729. name: "parameter",
  7730. targetType: null,
  7731. value: a
  7732. })
  7733. }
  7734. this.actions[n].serialize(r),
  7735. i.children.push(r)
  7736. }
  7737. return i
  7738. }
  7739. ,
  7740. t.Parse = function(e, i, n) {
  7741. var r = new t(n);
  7742. null === i ? n.actionManager = r : i.actionManager = r;
  7743. for (var o = function(e, t, i, n) {
  7744. if (null === n) {
  7745. var r = parseFloat(t);
  7746. return "true" === t || "false" === t ? "true" === t : isNaN(r) ? t : r
  7747. }
  7748. for (var o = n.split("."), a = t.split(","), s = 0; s < o.length; s++)
  7749. i = i[o[s]];
  7750. if ("boolean" == typeof i)
  7751. return "true" === a[0];
  7752. if ("string" == typeof i)
  7753. return a[0];
  7754. var l = new Array;
  7755. for (s = 0; s < a.length; s++)
  7756. l.push(parseFloat(a[s]));
  7757. return i instanceof x ? x.FromArray(l) : i instanceof R ? R.FromArray(l) : i instanceof D ? D.FromArray(l) : i instanceof N ? N.FromArray(l) : parseFloat(a[0])
  7758. }, a = function(e, i, s, l, c) {
  7759. if (void 0 === c && (c = null),
  7760. !e.detached) {
  7761. var u = new Array
  7762. , h = null
  7763. , d = null
  7764. , p = e.combine && e.combine.length > 0;
  7765. if (2 === e.type ? u.push(r) : u.push(i),
  7766. p) {
  7767. for (var f = new Array, _ = 0; _ < e.combine.length; _++)
  7768. a(e.combine[_], t.NothingTrigger, s, l, f);
  7769. u.push(f)
  7770. } else
  7771. for (var m = 0; m < e.properties.length; m++) {
  7772. var g = e.properties[m].value
  7773. , v = e.properties[m].name
  7774. , y = e.properties[m].targetType;
  7775. "target" === v ? g = h = null !== y && "SceneProperties" === y ? n : n.getNodeByName(g) : "parent" === v ? g = n.getNodeByName(g) : "sound" === v ? n.getSoundByName && (g = n.getSoundByName(g)) : "propertyPath" !== v ? g = 2 === e.type && "operator" === v ? X[g] : o(0, g, h, "value" === v ? d : null) : d = g,
  7776. u.push(g)
  7777. }
  7778. if (null === c ? u.push(s) : u.push(null),
  7779. "InterpolateValueAction" === e.name) {
  7780. var T = u[u.length - 2];
  7781. u[u.length - 1] = T,
  7782. u[u.length - 2] = s
  7783. }
  7784. var E = function(e, t) {
  7785. var i = b("BABYLON." + e);
  7786. if (i) {
  7787. var n = Object.create(i.prototype);
  7788. return n.constructor.apply(n, t),
  7789. n
  7790. }
  7791. }(e.name, u);
  7792. if (E instanceof H && null !== s) {
  7793. var S = new te(i,s);
  7794. l ? l.then(S) : r.registerAction(S),
  7795. l = S
  7796. }
  7797. for (null === c ? E instanceof H ? (s = E,
  7798. E = l) : (s = null,
  7799. l ? l.then(E) : r.registerAction(E)) : c.push(E),
  7800. m = 0; m < e.children.length; m++)
  7801. a(e.children[m], i, s, E, null)
  7802. }
  7803. }, s = 0; s < e.children.length; s++) {
  7804. var l = void 0
  7805. , c = e.children[s];
  7806. if (c.properties.length > 0) {
  7807. var u = c.properties[0].value
  7808. , h = null === c.properties[0].targetType ? u : n.getMeshByName(u);
  7809. h._meshId && (h.mesh = n.getMeshById(h._meshId)),
  7810. l = {
  7811. trigger: t[c.name],
  7812. parameter: h
  7813. }
  7814. } else
  7815. l = t[c.name];
  7816. for (var d = 0; d < c.children.length; d++)
  7817. c.detached || a(c.children[d], l, null, null)
  7818. }
  7819. }
  7820. ,
  7821. t.GetTriggerName = function(e) {
  7822. switch (e) {
  7823. case 0:
  7824. return "NothingTrigger";
  7825. case 1:
  7826. return "OnPickTrigger";
  7827. case 2:
  7828. return "OnLeftPickTrigger";
  7829. case 3:
  7830. return "OnRightPickTrigger";
  7831. case 4:
  7832. return "OnCenterPickTrigger";
  7833. case 5:
  7834. return "OnPickDownTrigger";
  7835. case 6:
  7836. return "OnPickUpTrigger";
  7837. case 7:
  7838. return "OnLongPressTrigger";
  7839. case 8:
  7840. return "OnPointerOverTrigger";
  7841. case 9:
  7842. return "OnPointerOutTrigger";
  7843. case 10:
  7844. return "OnEveryFrameTrigger";
  7845. case 11:
  7846. return "OnIntersectionEnterTrigger";
  7847. case 12:
  7848. return "OnIntersectionExitTrigger";
  7849. case 13:
  7850. return "OnKeyDownTrigger";
  7851. case 14:
  7852. return "OnKeyUpTrigger";
  7853. case 15:
  7854. return "OnPickOutTrigger";
  7855. default:
  7856. return ""
  7857. }
  7858. }
  7859. ,
  7860. t.NothingTrigger = a.ACTION_NothingTrigger,
  7861. t.OnPickTrigger = a.ACTION_OnPickTrigger,
  7862. t.OnLeftPickTrigger = a.ACTION_OnLeftPickTrigger,
  7863. t.OnRightPickTrigger = a.ACTION_OnRightPickTrigger,
  7864. t.OnCenterPickTrigger = a.ACTION_OnCenterPickTrigger,
  7865. t.OnPickDownTrigger = a.ACTION_OnPickDownTrigger,
  7866. t.OnDoublePickTrigger = a.ACTION_OnDoublePickTrigger,
  7867. t.OnPickUpTrigger = a.ACTION_OnPickUpTrigger,
  7868. t.OnPickOutTrigger = a.ACTION_OnPickOutTrigger,
  7869. t.OnLongPressTrigger = a.ACTION_OnLongPressTrigger,
  7870. t.OnPointerOverTrigger = a.ACTION_OnPointerOverTrigger,
  7871. t.OnPointerOutTrigger = a.ACTION_OnPointerOutTrigger,
  7872. t.OnEveryFrameTrigger = a.ACTION_OnEveryFrameTrigger,
  7873. t.OnIntersectionEnterTrigger = a.ACTION_OnIntersectionEnterTrigger,
  7874. t.OnIntersectionExitTrigger = a.ACTION_OnIntersectionExitTrigger,
  7875. t.OnKeyDownTrigger = a.ACTION_OnKeyDownTrigger,
  7876. t.OnKeyUpTrigger = 15,
  7877. t
  7878. }(s)
  7879. , me = function(e) {
  7880. function t(t, i, n) {
  7881. var r = e.call(this, t, n) || this;
  7882. return r._sound = i,
  7883. r
  7884. }
  7885. return U(t, e),
  7886. t.prototype._prepare = function() {}
  7887. ,
  7888. t.prototype.execute = function() {
  7889. void 0 !== this._sound && this._sound.play()
  7890. }
  7891. ,
  7892. t.prototype.serialize = function(t) {
  7893. return e.prototype._serialize.call(this, {
  7894. name: "PlaySoundAction",
  7895. properties: [{
  7896. name: "sound",
  7897. value: this._sound.name
  7898. }]
  7899. }, t)
  7900. }
  7901. ,
  7902. t
  7903. }(F)
  7904. , ge = function(e) {
  7905. function t(t, i, n) {
  7906. var r = e.call(this, t, n) || this;
  7907. return r._sound = i,
  7908. r
  7909. }
  7910. return U(t, e),
  7911. t.prototype._prepare = function() {}
  7912. ,
  7913. t.prototype.execute = function() {
  7914. void 0 !== this._sound && this._sound.stop()
  7915. }
  7916. ,
  7917. t.prototype.serialize = function(t) {
  7918. return e.prototype._serialize.call(this, {
  7919. name: "StopSoundAction",
  7920. properties: [{
  7921. name: "sound",
  7922. value: this._sound.name
  7923. }]
  7924. }, t)
  7925. }
  7926. ,
  7927. t
  7928. }(F);
  7929. y("BABYLON.PlaySoundAction", me),
  7930. y("BABYLON.StopSoundAction", ge);
  7931. var ve = function() {
  7932. function e() {}
  7933. return e.Eval = function(t, i) {
  7934. return "true" === (t = t.match(/\([^()]*\)/g) ? t.replace(/\([^()]*\)/g, (function(t) {
  7935. return t = t.slice(1, t.length - 1),
  7936. e._HandleParenthesisContent(t, i)
  7937. }
  7938. )) : e._HandleParenthesisContent(t, i)) || "false" !== t && e.Eval(t, i)
  7939. }
  7940. ,
  7941. e._HandleParenthesisContent = function(t, i) {
  7942. var n;
  7943. i = i || function(e) {
  7944. return "true" === e
  7945. }
  7946. ;
  7947. var r = t.split("||");
  7948. for (var o in r)
  7949. if (Object.prototype.hasOwnProperty.call(r, o)) {
  7950. var a = e._SimplifyNegation(r[o].trim())
  7951. , s = a.split("&&");
  7952. if (s.length > 1)
  7953. for (var l = 0; l < s.length; ++l) {
  7954. var c = e._SimplifyNegation(s[l].trim());
  7955. if (!(n = "true" !== c && "false" !== c ? "!" === c[0] ? !i(c.substring(1)) : i(c) : "true" === c)) {
  7956. a = "false";
  7957. break
  7958. }
  7959. }
  7960. if (n || "true" === a) {
  7961. n = !0;
  7962. break
  7963. }
  7964. n = "true" !== a && "false" !== a ? "!" === a[0] ? !i(a.substring(1)) : i(a) : "true" === a
  7965. }
  7966. return n ? "true" : "false"
  7967. }
  7968. ,
  7969. e._SimplifyNegation = function(e) {
  7970. return "!true" === (e = (e = e.replace(/^[\s!]+/, (function(e) {
  7971. return (e = e.replace(/[\s]/g, (function() {
  7972. return ""
  7973. }
  7974. ))).length % 2 ? "!" : ""
  7975. }
  7976. ))).trim()) ? e = "false" : "!false" === e && (e = "true"),
  7977. e
  7978. }
  7979. ,
  7980. e
  7981. }()
  7982. , ye = function() {
  7983. function e() {}
  7984. return e.EnableFor = function(t) {
  7985. t._tags = t._tags || {},
  7986. t.hasTags = function() {
  7987. return e.HasTags(t)
  7988. }
  7989. ,
  7990. t.addTags = function(i) {
  7991. return e.AddTagsTo(t, i)
  7992. }
  7993. ,
  7994. t.removeTags = function(i) {
  7995. return e.RemoveTagsFrom(t, i)
  7996. }
  7997. ,
  7998. t.matchesTagsQuery = function(i) {
  7999. return e.MatchesQuery(t, i)
  8000. }
  8001. }
  8002. ,
  8003. e.DisableFor = function(e) {
  8004. delete e._tags,
  8005. delete e.hasTags,
  8006. delete e.addTags,
  8007. delete e.removeTags,
  8008. delete e.matchesTagsQuery
  8009. }
  8010. ,
  8011. e.HasTags = function(e) {
  8012. if (!e._tags)
  8013. return !1;
  8014. var t = e._tags;
  8015. for (var i in t)
  8016. if (Object.prototype.hasOwnProperty.call(t, i))
  8017. return !0;
  8018. return !1
  8019. }
  8020. ,
  8021. e.GetTags = function(e, t) {
  8022. if (void 0 === t && (t = !0),
  8023. !e._tags)
  8024. return null;
  8025. if (t) {
  8026. var i = [];
  8027. for (var n in e._tags)
  8028. Object.prototype.hasOwnProperty.call(e._tags, n) && !0 === e._tags[n] && i.push(n);
  8029. return i.join(" ")
  8030. }
  8031. return e._tags
  8032. }
  8033. ,
  8034. e.AddTagsTo = function(t, i) {
  8035. i && "string" == typeof i && i.split(" ").forEach((function(i) {
  8036. e._AddTagTo(t, i)
  8037. }
  8038. ))
  8039. }
  8040. ,
  8041. e._AddTagTo = function(t, i) {
  8042. "" !== (i = i.trim()) && "true" !== i && "false" !== i && (i.match(/[\s]/) || i.match(/^([!]|([|]|[&]){2})/) || (e.EnableFor(t),
  8043. t._tags[i] = !0))
  8044. }
  8045. ,
  8046. e.RemoveTagsFrom = function(t, i) {
  8047. if (e.HasTags(t)) {
  8048. var n = i.split(" ");
  8049. for (var r in n)
  8050. e._RemoveTagFrom(t, n[r])
  8051. }
  8052. }
  8053. ,
  8054. e._RemoveTagFrom = function(e, t) {
  8055. delete e._tags[t]
  8056. }
  8057. ,
  8058. e.MatchesQuery = function(t, i) {
  8059. return void 0 === i || ("" === i ? e.HasTags(t) : ve.Eval(i, (function(i) {
  8060. return e.HasTags(t) && t._tags[i]
  8061. }
  8062. )))
  8063. }
  8064. ,
  8065. e
  8066. }();
  8067. function be(e) {
  8068. return "".concat(e, " needs to be imported before as it contains a side-effect required by your code.")
  8069. }
  8070. var Te = {}
  8071. , Ee = {}
  8072. , Se = function(e, t, i) {
  8073. var n = e();
  8074. ye && ye.AddTagsTo(n, t.tags);
  8075. var r = Ae(n);
  8076. for (var o in r) {
  8077. var a = r[o]
  8078. , s = t[o]
  8079. , l = a.type;
  8080. if (null != s && ("uniqueId" !== o || Ge.AllowLoadingUniqueId))
  8081. switch (l) {
  8082. case 0:
  8083. case 6:
  8084. case 11:
  8085. n[o] = s;
  8086. break;
  8087. case 1:
  8088. n[o] = i || s.isRenderTarget ? s : s.clone();
  8089. break;
  8090. case 2:
  8091. case 3:
  8092. case 4:
  8093. case 5:
  8094. case 7:
  8095. case 10:
  8096. case 12:
  8097. n[o] = i ? s : s.clone()
  8098. }
  8099. }
  8100. return n
  8101. };
  8102. function Ae(e) {
  8103. var t = e.getClassName();
  8104. if (Ee[t])
  8105. return Ee[t];
  8106. Ee[t] = {};
  8107. for (var i = Ee[t], n = e, r = t; r; ) {
  8108. var o = Te[r];
  8109. for (var a in o)
  8110. i[a] = o[a];
  8111. var s = void 0
  8112. , l = !1;
  8113. do {
  8114. if (!(s = Object.getPrototypeOf(n)).getClassName) {
  8115. l = !0;
  8116. break
  8117. }
  8118. if (s.getClassName() !== r)
  8119. break;
  8120. n = s
  8121. } while (s);
  8122. if (l)
  8123. break;
  8124. r = s.getClassName(),
  8125. n = s
  8126. }
  8127. return i
  8128. }
  8129. function xe(e, t) {
  8130. return function(i, n) {
  8131. var r = function(e) {
  8132. var t = e.getClassName();
  8133. return Te[t] || (Te[t] = {}),
  8134. Te[t]
  8135. }(i);
  8136. r[n] || (r[n] = {
  8137. type: e,
  8138. sourceName: t
  8139. })
  8140. }
  8141. }
  8142. function Re(e, t) {
  8143. return void 0 === t && (t = null),
  8144. function(e, t) {
  8145. return void 0 === t && (t = null),
  8146. function(i, n) {
  8147. var r = t || "_" + n;
  8148. Object.defineProperty(i, n, {
  8149. get: function() {
  8150. return this[r]
  8151. },
  8152. set: function(t) {
  8153. "function" == typeof this.equals && this.equals(t) || this[r] !== t && (this[r] = t,
  8154. i[e].apply(this))
  8155. },
  8156. enumerable: !0,
  8157. configurable: !0
  8158. })
  8159. }
  8160. }(e, t)
  8161. }
  8162. function Ce(e) {
  8163. return xe(0, e)
  8164. }
  8165. function Pe(e) {
  8166. return xe(1, e)
  8167. }
  8168. function Me(e) {
  8169. return xe(2, e)
  8170. }
  8171. function Ie(e) {
  8172. return xe(3, e)
  8173. }
  8174. function Oe(e) {
  8175. return xe(4, e)
  8176. }
  8177. function De(e) {
  8178. return xe(5, e)
  8179. }
  8180. function Ne(e) {
  8181. return xe(6, e)
  8182. }
  8183. function Le(e) {
  8184. return xe(7, e)
  8185. }
  8186. function Fe(e) {
  8187. return xe(8, e)
  8188. }
  8189. function we(e) {
  8190. return xe(9, e)
  8191. }
  8192. function Be(e) {
  8193. return xe(10, e)
  8194. }
  8195. function Ue(e) {
  8196. return xe(12, e)
  8197. }
  8198. function Ve(e) {
  8199. return xe(11, e)
  8200. }
  8201. var ke, Ge = function() {
  8202. function e() {}
  8203. return e.AppendSerializedAnimations = function(e, t) {
  8204. if (e.animations) {
  8205. t.animations = [];
  8206. for (var i = 0; i < e.animations.length; i++) {
  8207. var n = e.animations[i];
  8208. t.animations.push(n.serialize())
  8209. }
  8210. }
  8211. }
  8212. ,
  8213. e.Serialize = function(t, i) {
  8214. i || (i = {}),
  8215. ye && (i.tags = ye.GetTags(t));
  8216. var n = Ae(t);
  8217. for (var r in n) {
  8218. var o = n[r]
  8219. , a = o.sourceName || r
  8220. , s = o.type
  8221. , l = t[r];
  8222. if (null != l && ("uniqueId" !== r || e.AllowLoadingUniqueId))
  8223. switch (s) {
  8224. case 0:
  8225. i[a] = l;
  8226. break;
  8227. case 1:
  8228. case 3:
  8229. case 7:
  8230. case 9:
  8231. i[a] = l.serialize();
  8232. break;
  8233. case 2:
  8234. case 4:
  8235. case 5:
  8236. case 8:
  8237. case 10:
  8238. case 12:
  8239. i[a] = l.asArray();
  8240. break;
  8241. case 6:
  8242. case 11:
  8243. i[a] = l.id
  8244. }
  8245. }
  8246. return i
  8247. }
  8248. ,
  8249. e.Parse = function(t, i, n, r) {
  8250. void 0 === r && (r = null);
  8251. var o = t();
  8252. r || (r = ""),
  8253. ye && ye.AddTagsTo(o, i.tags);
  8254. var a = Ae(o);
  8255. for (var s in a) {
  8256. var l = a[s]
  8257. , c = i[l.sourceName || s]
  8258. , u = l.type;
  8259. if (null != c && ("uniqueId" !== s || e.AllowLoadingUniqueId)) {
  8260. var h = o;
  8261. switch (u) {
  8262. case 0:
  8263. h[s] = c;
  8264. break;
  8265. case 1:
  8266. n && (h[s] = e._TextureParser(c, n, r));
  8267. break;
  8268. case 2:
  8269. h[s] = D.FromArray(c);
  8270. break;
  8271. case 3:
  8272. h[s] = e._FresnelParametersParser(c);
  8273. break;
  8274. case 4:
  8275. h[s] = A.FromArray(c);
  8276. break;
  8277. case 5:
  8278. h[s] = x.FromArray(c);
  8279. break;
  8280. case 6:
  8281. n && (h[s] = n.getLastMeshById(c));
  8282. break;
  8283. case 7:
  8284. h[s] = e._ColorCurvesParser(c);
  8285. break;
  8286. case 8:
  8287. h[s] = N.FromArray(c);
  8288. break;
  8289. case 9:
  8290. h[s] = e._ImageProcessingConfigurationParser(c);
  8291. break;
  8292. case 10:
  8293. h[s] = C.FromArray(c);
  8294. break;
  8295. case 11:
  8296. n && (h[s] = n.getCameraById(c));
  8297. break;
  8298. case 12:
  8299. h[s] = P.FromArray(c)
  8300. }
  8301. }
  8302. }
  8303. return o
  8304. }
  8305. ,
  8306. e.Clone = function(e, t) {
  8307. return Se(e, t, !1)
  8308. }
  8309. ,
  8310. e.Instanciate = function(e, t) {
  8311. return Se(e, t, !0)
  8312. }
  8313. ,
  8314. e.AllowLoadingUniqueId = !1,
  8315. e._ImageProcessingConfigurationParser = function(e) {
  8316. throw be("ImageProcessingConfiguration")
  8317. }
  8318. ,
  8319. e._FresnelParametersParser = function(e) {
  8320. throw be("FresnelParameters")
  8321. }
  8322. ,
  8323. e._ColorCurvesParser = function(e) {
  8324. throw be("ColorCurves")
  8325. }
  8326. ,
  8327. e._TextureParser = function(e, t, i) {
  8328. throw be("Texture")
  8329. }
  8330. ,
  8331. e
  8332. }();
  8333. function ze(e, t, i, n) {
  8334. var r = i.value;
  8335. i.value = function() {
  8336. for (var i = [], o = 0; o < arguments.length; o++)
  8337. i[o] = arguments[o];
  8338. var a = r;
  8339. if ("undefined" != typeof _native && _native[t]) {
  8340. var s = _native[t];
  8341. a = n ? function() {
  8342. for (var e = [], t = 0; t < arguments.length; t++)
  8343. e[t] = arguments[t];
  8344. return n.apply(void 0, e) ? s.apply(void 0, e) : r.apply(void 0, e)
  8345. }
  8346. : s
  8347. }
  8348. return e[t] = a,
  8349. a.apply(void 0, i)
  8350. }
  8351. }
  8352. ze.filter = function(e) {
  8353. return function(t, i, n) {
  8354. return ze(t, i, n, e)
  8355. }
  8356. }
  8357. ,
  8358. function(e) {
  8359. e[e.NONE = 0] = "NONE",
  8360. e[e.STEP = 1] = "STEP"
  8361. }(ke || (ke = {}));
  8362. var We = function() {
  8363. function e(e, t, i) {
  8364. this.name = e,
  8365. this.from = t,
  8366. this.to = i
  8367. }
  8368. return e.prototype.clone = function() {
  8369. return new e(this.name,this.from,this.to)
  8370. }
  8371. ,
  8372. e
  8373. }()
  8374. , He = function() {
  8375. this._doNotSerialize = !1,
  8376. this._isDisposed = !1,
  8377. this._sceneRootNodesIndex = -1,
  8378. this._isEnabled = !0,
  8379. this._isParentEnabled = !0,
  8380. this._isReady = !0,
  8381. this._onEnabledStateChangedObservable = new h,
  8382. this._onClonedObservable = new h
  8383. }
  8384. , Xe = function() {
  8385. function e(e, t) {
  8386. void 0 === t && (t = null),
  8387. this._isDirty = !1,
  8388. this._nodeDataStorage = new He,
  8389. this.state = "",
  8390. this.metadata = null,
  8391. this.reservedDataStore = null,
  8392. this._parentContainer = null,
  8393. this.animations = new Array,
  8394. this._ranges = {},
  8395. this.onReady = null,
  8396. this._currentRenderId = -1,
  8397. this._parentUpdateId = -1,
  8398. this._childUpdateId = -1,
  8399. this._waitingParentId = null,
  8400. this._cache = {},
  8401. this._parentNode = null,
  8402. this._children = null,
  8403. this._worldMatrix = P.Identity(),
  8404. this._worldMatrixDeterminant = 0,
  8405. this._worldMatrixDeterminantIsDirty = !0,
  8406. this._animationPropertiesOverride = null,
  8407. this._isNode = !0,
  8408. this.onDisposeObservable = new h,
  8409. this._onDisposeObserver = null,
  8410. this._behaviors = new Array,
  8411. this.name = e,
  8412. this.id = e,
  8413. this._scene = t || E.LastCreatedScene,
  8414. this.uniqueId = this._scene.getUniqueId(),
  8415. this._initCache()
  8416. }
  8417. return e.AddNodeConstructor = function(e, t) {
  8418. this._NodeConstructors[e] = t
  8419. }
  8420. ,
  8421. e.Construct = function(e, t, i, n) {
  8422. var r = this._NodeConstructors[e];
  8423. return r ? r(t, i, n) : null
  8424. }
  8425. ,
  8426. Object.defineProperty(e.prototype, "doNotSerialize", {
  8427. get: function() {
  8428. return !!this._nodeDataStorage._doNotSerialize || !!this._parentNode && this._parentNode.doNotSerialize
  8429. },
  8430. set: function(e) {
  8431. this._nodeDataStorage._doNotSerialize = e
  8432. },
  8433. enumerable: !1,
  8434. configurable: !0
  8435. }),
  8436. e.prototype.isDisposed = function() {
  8437. return this._nodeDataStorage._isDisposed
  8438. }
  8439. ,
  8440. Object.defineProperty(e.prototype, "parent", {
  8441. get: function() {
  8442. return this._parentNode
  8443. },
  8444. set: function(e) {
  8445. if (this._parentNode !== e) {
  8446. var t = this._parentNode;
  8447. if (this._parentNode && void 0 !== this._parentNode._children && null !== this._parentNode._children) {
  8448. var i = this._parentNode._children.indexOf(this);
  8449. -1 !== i && this._parentNode._children.splice(i, 1),
  8450. e || this._nodeDataStorage._isDisposed || this._addToSceneRootNodes()
  8451. }
  8452. this._parentNode = e,
  8453. this._parentNode && (void 0 !== this._parentNode._children && null !== this._parentNode._children || (this._parentNode._children = new Array),
  8454. this._parentNode._children.push(this),
  8455. t || this._removeFromSceneRootNodes()),
  8456. this._syncParentEnabledState()
  8457. }
  8458. },
  8459. enumerable: !1,
  8460. configurable: !0
  8461. }),
  8462. e.prototype._addToSceneRootNodes = function() {
  8463. -1 === this._nodeDataStorage._sceneRootNodesIndex && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length,
  8464. this._scene.rootNodes.push(this))
  8465. }
  8466. ,
  8467. e.prototype._removeFromSceneRootNodes = function() {
  8468. if (-1 !== this._nodeDataStorage._sceneRootNodesIndex) {
  8469. var e = this._scene.rootNodes
  8470. , t = e.length - 1;
  8471. e[this._nodeDataStorage._sceneRootNodesIndex] = e[t],
  8472. e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex,
  8473. this._scene.rootNodes.pop(),
  8474. this._nodeDataStorage._sceneRootNodesIndex = -1
  8475. }
  8476. }
  8477. ,
  8478. Object.defineProperty(e.prototype, "animationPropertiesOverride", {
  8479. get: function() {
  8480. return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
  8481. },
  8482. set: function(e) {
  8483. this._animationPropertiesOverride = e
  8484. },
  8485. enumerable: !1,
  8486. configurable: !0
  8487. }),
  8488. e.prototype.getClassName = function() {
  8489. return "Node"
  8490. }
  8491. ,
  8492. Object.defineProperty(e.prototype, "onDispose", {
  8493. set: function(e) {
  8494. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  8495. this._onDisposeObserver = this.onDisposeObservable.add(e)
  8496. },
  8497. enumerable: !1,
  8498. configurable: !0
  8499. }),
  8500. Object.defineProperty(e.prototype, "onEnabledStateChangedObservable", {
  8501. get: function() {
  8502. return this._nodeDataStorage._onEnabledStateChangedObservable
  8503. },
  8504. enumerable: !1,
  8505. configurable: !0
  8506. }),
  8507. Object.defineProperty(e.prototype, "onClonedObservable", {
  8508. get: function() {
  8509. return this._nodeDataStorage._onClonedObservable
  8510. },
  8511. enumerable: !1,
  8512. configurable: !0
  8513. }),
  8514. e.prototype.getScene = function() {
  8515. return this._scene
  8516. }
  8517. ,
  8518. e.prototype.getEngine = function() {
  8519. return this._scene.getEngine()
  8520. }
  8521. ,
  8522. e.prototype.addBehavior = function(e, t) {
  8523. var i = this;
  8524. return void 0 === t && (t = !1),
  8525. -1 !== this._behaviors.indexOf(e) || (e.init(),
  8526. this._scene.isLoading && !t ? this._scene.onDataLoadedObservable.addOnce((function() {
  8527. e.attach(i)
  8528. }
  8529. )) : e.attach(this),
  8530. this._behaviors.push(e)),
  8531. this
  8532. }
  8533. ,
  8534. e.prototype.removeBehavior = function(e) {
  8535. var t = this._behaviors.indexOf(e);
  8536. return -1 === t || (this._behaviors[t].detach(),
  8537. this._behaviors.splice(t, 1)),
  8538. this
  8539. }
  8540. ,
  8541. Object.defineProperty(e.prototype, "behaviors", {
  8542. get: function() {
  8543. return this._behaviors
  8544. },
  8545. enumerable: !1,
  8546. configurable: !0
  8547. }),
  8548. e.prototype.getBehaviorByName = function(e) {
  8549. for (var t = 0, i = this._behaviors; t < i.length; t++) {
  8550. var n = i[t];
  8551. if (n.name === e)
  8552. return n
  8553. }
  8554. return null
  8555. }
  8556. ,
  8557. e.prototype.getWorldMatrix = function() {
  8558. return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(),
  8559. this._worldMatrix
  8560. }
  8561. ,
  8562. e.prototype._getWorldMatrixDeterminant = function() {
  8563. return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1,
  8564. this._worldMatrixDeterminant = this._worldMatrix.determinant()),
  8565. this._worldMatrixDeterminant
  8566. }
  8567. ,
  8568. Object.defineProperty(e.prototype, "worldMatrixFromCache", {
  8569. get: function() {
  8570. return this._worldMatrix
  8571. },
  8572. enumerable: !1,
  8573. configurable: !0
  8574. }),
  8575. e.prototype._initCache = function() {
  8576. this._cache = {},
  8577. this._cache.parent = void 0
  8578. }
  8579. ,
  8580. e.prototype.updateCache = function(e) {
  8581. !e && this.isSynchronized() || (this._cache.parent = this.parent,
  8582. this._updateCache())
  8583. }
  8584. ,
  8585. e.prototype._getActionManagerForTrigger = function(e, t) {
  8586. return void 0 === t && (t = !0),
  8587. this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
  8588. }
  8589. ,
  8590. e.prototype._updateCache = function(e) {}
  8591. ,
  8592. e.prototype._isSynchronized = function() {
  8593. return !0
  8594. }
  8595. ,
  8596. e.prototype._markSyncedWithParent = function() {
  8597. this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId)
  8598. }
  8599. ,
  8600. e.prototype.isSynchronizedWithParent = function() {
  8601. return !this._parentNode || !this._parentNode._isDirty && this._parentUpdateId === this._parentNode._childUpdateId && this._parentNode.isSynchronized()
  8602. }
  8603. ,
  8604. e.prototype.isSynchronized = function() {
  8605. return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode,
  8606. !1) : !(this._parentNode && !this.isSynchronizedWithParent()) && this._isSynchronized()
  8607. }
  8608. ,
  8609. e.prototype.isReady = function(e) {
  8610. return void 0 === e && (e = !1),
  8611. this._nodeDataStorage._isReady
  8612. }
  8613. ,
  8614. e.prototype.markAsDirty = function(e) {
  8615. return this._currentRenderId = Number.MAX_VALUE,
  8616. this._isDirty = !0,
  8617. this
  8618. }
  8619. ,
  8620. e.prototype.isEnabled = function(e) {
  8621. return void 0 === e && (e = !0),
  8622. !1 === e ? this._nodeDataStorage._isEnabled : !!this._nodeDataStorage._isEnabled && this._nodeDataStorage._isParentEnabled
  8623. }
  8624. ,
  8625. e.prototype._syncParentEnabledState = function() {
  8626. this._nodeDataStorage._isParentEnabled = !this._parentNode || this._parentNode.isEnabled(),
  8627. this._children && this._children.forEach((function(e) {
  8628. e._syncParentEnabledState()
  8629. }
  8630. ))
  8631. }
  8632. ,
  8633. e.prototype.setEnabled = function(e) {
  8634. this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e,
  8635. this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
  8636. this._syncParentEnabledState())
  8637. }
  8638. ,
  8639. e.prototype.isDescendantOf = function(e) {
  8640. return !!this.parent && (this.parent === e || this.parent.isDescendantOf(e))
  8641. }
  8642. ,
  8643. e.prototype._getDescendants = function(e, t, i) {
  8644. if (void 0 === t && (t = !1),
  8645. this._children)
  8646. for (var n = 0; n < this._children.length; n++) {
  8647. var r = this._children[n];
  8648. i && !i(r) || e.push(r),
  8649. t || r._getDescendants(e, !1, i)
  8650. }
  8651. }
  8652. ,
  8653. e.prototype.getDescendants = function(e, t) {
  8654. var i = new Array;
  8655. return this._getDescendants(i, e, t),
  8656. i
  8657. }
  8658. ,
  8659. e.prototype.getChildMeshes = function(e, t) {
  8660. var i = [];
  8661. return this._getDescendants(i, e, (function(e) {
  8662. return (!t || t(e)) && void 0 !== e.cullingStrategy
  8663. }
  8664. )),
  8665. i
  8666. }
  8667. ,
  8668. e.prototype.getChildren = function(e, t) {
  8669. return void 0 === t && (t = !0),
  8670. this.getDescendants(t, e)
  8671. }
  8672. ,
  8673. e.prototype._setReady = function(e) {
  8674. e !== this._nodeDataStorage._isReady && (e ? (this.onReady && this.onReady(this),
  8675. this._nodeDataStorage._isReady = !0) : this._nodeDataStorage._isReady = !1)
  8676. }
  8677. ,
  8678. e.prototype.getAnimationByName = function(e) {
  8679. for (var t = 0; t < this.animations.length; t++) {
  8680. var i = this.animations[t];
  8681. if (i.name === e)
  8682. return i
  8683. }
  8684. return null
  8685. }
  8686. ,
  8687. e.prototype.createAnimationRange = function(t, i, n) {
  8688. if (!this._ranges[t]) {
  8689. this._ranges[t] = e._AnimationRangeFactory(t, i, n);
  8690. for (var r = 0, o = this.animations.length; r < o; r++)
  8691. this.animations[r] && this.animations[r].createRange(t, i, n)
  8692. }
  8693. }
  8694. ,
  8695. e.prototype.deleteAnimationRange = function(e, t) {
  8696. void 0 === t && (t = !0);
  8697. for (var i = 0, n = this.animations.length; i < n; i++)
  8698. this.animations[i] && this.animations[i].deleteRange(e, t);
  8699. this._ranges[e] = null
  8700. }
  8701. ,
  8702. e.prototype.getAnimationRange = function(e) {
  8703. return this._ranges[e] || null
  8704. }
  8705. ,
  8706. e.prototype.getAnimationRanges = function() {
  8707. var e, t = [];
  8708. for (e in this._ranges)
  8709. t.push(this._ranges[e]);
  8710. return t
  8711. }
  8712. ,
  8713. e.prototype.beginAnimation = function(e, t, i, n) {
  8714. var r = this.getAnimationRange(e);
  8715. return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
  8716. }
  8717. ,
  8718. e.prototype.serializeAnimationRanges = function() {
  8719. var e = [];
  8720. for (var t in this._ranges) {
  8721. var i = this._ranges[t];
  8722. if (i) {
  8723. var n = {};
  8724. n.name = t,
  8725. n.from = i.from,
  8726. n.to = i.to,
  8727. e.push(n)
  8728. }
  8729. }
  8730. return e
  8731. }
  8732. ,
  8733. e.prototype.computeWorldMatrix = function(e) {
  8734. return this._worldMatrix || (this._worldMatrix = P.Identity()),
  8735. this._worldMatrix
  8736. }
  8737. ,
  8738. e.prototype.dispose = function(e, t) {
  8739. if (void 0 === t && (t = !1),
  8740. this._nodeDataStorage._isDisposed = !0,
  8741. !e)
  8742. for (var i = 0, n = this.getDescendants(!0); i < n.length; i++)
  8743. n[i].dispose(e, t);
  8744. this.parent ? this.parent = null : this._removeFromSceneRootNodes(),
  8745. this.onDisposeObservable.notifyObservers(this),
  8746. this.onDisposeObservable.clear(),
  8747. this.onEnabledStateChangedObservable.clear(),
  8748. this.onClonedObservable.clear();
  8749. for (var r = 0, o = this._behaviors; r < o.length; r++)
  8750. o[r].detach();
  8751. this._behaviors = [],
  8752. this.metadata = null
  8753. }
  8754. ,
  8755. e.ParseAnimationRanges = function(e, t, i) {
  8756. if (t.ranges)
  8757. for (var n = 0; n < t.ranges.length; n++) {
  8758. var r = t.ranges[n];
  8759. e.createAnimationRange(r.name, r.from, r.to)
  8760. }
  8761. }
  8762. ,
  8763. e.prototype.getHierarchyBoundingVectors = function(e, t) {
  8764. var i, n;
  8765. void 0 === e && (e = !0),
  8766. void 0 === t && (t = null),
  8767. this.getScene().incrementRenderId(),
  8768. this.computeWorldMatrix(!0);
  8769. var r = this;
  8770. if (r.getBoundingInfo && r.subMeshes) {
  8771. var o = r.getBoundingInfo();
  8772. i = o.boundingBox.minimumWorld.clone(),
  8773. n = o.boundingBox.maximumWorld.clone()
  8774. } else
  8775. i = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  8776. n = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  8777. if (e)
  8778. for (var a = 0, s = this.getDescendants(!1); a < s.length; a++) {
  8779. var l = s[a];
  8780. if (l.computeWorldMatrix(!0),
  8781. (!t || t(l)) && l.getBoundingInfo && 0 !== l.getTotalVertices()) {
  8782. var c = l.getBoundingInfo().boundingBox
  8783. , u = c.minimumWorld
  8784. , h = c.maximumWorld;
  8785. x.CheckExtends(u, i, n),
  8786. x.CheckExtends(h, i, n)
  8787. }
  8788. }
  8789. return {
  8790. min: i,
  8791. max: n
  8792. }
  8793. }
  8794. ,
  8795. e._AnimationRangeFactory = function(e, t, i) {
  8796. throw be("AnimationRange")
  8797. }
  8798. ,
  8799. e._NodeConstructors = {},
  8800. k([Ce()], e.prototype, "name", void 0),
  8801. k([Ce()], e.prototype, "id", void 0),
  8802. k([Ce()], e.prototype, "uniqueId", void 0),
  8803. k([Ce()], e.prototype, "state", void 0),
  8804. k([Ce()], e.prototype, "metadata", void 0),
  8805. e
  8806. }()
  8807. , je = function() {
  8808. function e(e, t) {
  8809. this.width = e,
  8810. this.height = t
  8811. }
  8812. return e.prototype.toString = function() {
  8813. return "{W: ".concat(this.width, ", H: ").concat(this.height, "}")
  8814. }
  8815. ,
  8816. e.prototype.getClassName = function() {
  8817. return "Size"
  8818. }
  8819. ,
  8820. e.prototype.getHashCode = function() {
  8821. var e = 0 | this.width;
  8822. return 397 * e ^ (0 | this.height)
  8823. }
  8824. ,
  8825. e.prototype.copyFrom = function(e) {
  8826. this.width = e.width,
  8827. this.height = e.height
  8828. }
  8829. ,
  8830. e.prototype.copyFromFloats = function(e, t) {
  8831. return this.width = e,
  8832. this.height = t,
  8833. this
  8834. }
  8835. ,
  8836. e.prototype.set = function(e, t) {
  8837. return this.copyFromFloats(e, t)
  8838. }
  8839. ,
  8840. e.prototype.multiplyByFloats = function(t, i) {
  8841. return new e(this.width * t,this.height * i)
  8842. }
  8843. ,
  8844. e.prototype.clone = function() {
  8845. return new e(this.width,this.height)
  8846. }
  8847. ,
  8848. e.prototype.equals = function(e) {
  8849. return !!e && this.width === e.width && this.height === e.height
  8850. }
  8851. ,
  8852. Object.defineProperty(e.prototype, "surface", {
  8853. get: function() {
  8854. return this.width * this.height
  8855. },
  8856. enumerable: !1,
  8857. configurable: !0
  8858. }),
  8859. e.Zero = function() {
  8860. return new e(0,0)
  8861. }
  8862. ,
  8863. e.prototype.add = function(t) {
  8864. return new e(this.width + t.width,this.height + t.height)
  8865. }
  8866. ,
  8867. e.prototype.subtract = function(t) {
  8868. return new e(this.width - t.width,this.height - t.height)
  8869. }
  8870. ,
  8871. e.Lerp = function(t, i, n) {
  8872. return new e(t.width + (i.width - t.width) * n,t.height + (i.height - t.height) * n)
  8873. }
  8874. ,
  8875. e
  8876. }()
  8877. , Ye = function() {
  8878. function e() {
  8879. this._xhr = "undefined" != typeof _native && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
  8880. }
  8881. return e.prototype._injectCustomRequestHeaders = function() {
  8882. for (var t in e.CustomRequestHeaders) {
  8883. var i = e.CustomRequestHeaders[t];
  8884. i && this._xhr.setRequestHeader(t, i)
  8885. }
  8886. }
  8887. ,
  8888. Object.defineProperty(e.prototype, "onprogress", {
  8889. get: function() {
  8890. return this._xhr.onprogress
  8891. },
  8892. set: function(e) {
  8893. this._xhr.onprogress = e
  8894. },
  8895. enumerable: !1,
  8896. configurable: !0
  8897. }),
  8898. Object.defineProperty(e.prototype, "readyState", {
  8899. get: function() {
  8900. return this._xhr.readyState
  8901. },
  8902. enumerable: !1,
  8903. configurable: !0
  8904. }),
  8905. Object.defineProperty(e.prototype, "status", {
  8906. get: function() {
  8907. return this._xhr.status
  8908. },
  8909. enumerable: !1,
  8910. configurable: !0
  8911. }),
  8912. Object.defineProperty(e.prototype, "statusText", {
  8913. get: function() {
  8914. return this._xhr.statusText
  8915. },
  8916. enumerable: !1,
  8917. configurable: !0
  8918. }),
  8919. Object.defineProperty(e.prototype, "response", {
  8920. get: function() {
  8921. return this._xhr.response
  8922. },
  8923. enumerable: !1,
  8924. configurable: !0
  8925. }),
  8926. Object.defineProperty(e.prototype, "responseURL", {
  8927. get: function() {
  8928. return this._xhr.responseURL
  8929. },
  8930. enumerable: !1,
  8931. configurable: !0
  8932. }),
  8933. Object.defineProperty(e.prototype, "responseText", {
  8934. get: function() {
  8935. return this._xhr.responseText
  8936. },
  8937. enumerable: !1,
  8938. configurable: !0
  8939. }),
  8940. Object.defineProperty(e.prototype, "responseType", {
  8941. get: function() {
  8942. return this._xhr.responseType
  8943. },
  8944. set: function(e) {
  8945. this._xhr.responseType = e
  8946. },
  8947. enumerable: !1,
  8948. configurable: !0
  8949. }),
  8950. Object.defineProperty(e.prototype, "timeout", {
  8951. get: function() {
  8952. return this._xhr.timeout
  8953. },
  8954. set: function(e) {
  8955. this._xhr.timeout = e
  8956. },
  8957. enumerable: !1,
  8958. configurable: !0
  8959. }),
  8960. e.prototype.addEventListener = function(e, t, i) {
  8961. this._xhr.addEventListener(e, t, i)
  8962. }
  8963. ,
  8964. e.prototype.removeEventListener = function(e, t, i) {
  8965. this._xhr.removeEventListener(e, t, i)
  8966. }
  8967. ,
  8968. e.prototype.abort = function() {
  8969. this._xhr.abort()
  8970. }
  8971. ,
  8972. e.prototype.send = function(t) {
  8973. e.CustomRequestHeaders && this._injectCustomRequestHeaders(),
  8974. this._xhr.send(t)
  8975. }
  8976. ,
  8977. e.prototype.open = function(t, i) {
  8978. for (var n = 0, r = e.CustomRequestModifiers; n < r.length; n++)
  8979. (0,
  8980. r[n])(this._xhr, i);
  8981. return i = (i = i.replace("file:http:", "http:")).replace("file:https:", "https:"),
  8982. this._xhr.open(t, i, !0)
  8983. }
  8984. ,
  8985. e.prototype.setRequestHeader = function(e, t) {
  8986. this._xhr.setRequestHeader(e, t)
  8987. }
  8988. ,
  8989. e.prototype.getResponseHeader = function(e) {
  8990. return this._xhr.getResponseHeader(e)
  8991. }
  8992. ,
  8993. e.CustomRequestHeaders = {},
  8994. e.CustomRequestModifiers = new Array,
  8995. e
  8996. }()
  8997. , Ke = function() {}
  8998. , Qe = function() {
  8999. function e(t, i, n, r, o, a) {
  9000. this.name = t,
  9001. this.targetProperty = i,
  9002. this.framePerSecond = n,
  9003. this.dataType = r,
  9004. this.loopMode = o,
  9005. this.enableBlending = a,
  9006. this._easingFunction = null,
  9007. this._runtimeAnimations = new Array,
  9008. this._events = new Array,
  9009. this.blendingSpeed = .01,
  9010. this._ranges = {},
  9011. this.targetPropertyPath = i.split("."),
  9012. this.dataType = r,
  9013. this.loopMode = void 0 === o ? e.ANIMATIONLOOPMODE_CYCLE : o,
  9014. this.uniqueId = e._UniqueIdGenerator++
  9015. }
  9016. return e._PrepareAnimation = function(t, i, n, r, o, a, s, l) {
  9017. var c = void 0;
  9018. if (!isNaN(parseFloat(o)) && isFinite(o) ? c = e.ANIMATIONTYPE_FLOAT : o instanceof C ? c = e.ANIMATIONTYPE_QUATERNION : o instanceof x ? c = e.ANIMATIONTYPE_VECTOR3 : o instanceof A ? c = e.ANIMATIONTYPE_VECTOR2 : o instanceof D ? c = e.ANIMATIONTYPE_COLOR3 : o instanceof N ? c = e.ANIMATIONTYPE_COLOR4 : o instanceof je && (c = e.ANIMATIONTYPE_SIZE),
  9019. null == c)
  9020. return null;
  9021. var u = new e(t,i,n,c,s)
  9022. , h = [{
  9023. frame: 0,
  9024. value: o
  9025. }, {
  9026. frame: r,
  9027. value: a
  9028. }];
  9029. return u.setKeys(h),
  9030. void 0 !== l && u.setEasingFunction(l),
  9031. u
  9032. }
  9033. ,
  9034. e.CreateAnimation = function(t, i, n, r) {
  9035. var o = new e(t + "Animation",t,n,i,e.ANIMATIONLOOPMODE_CONSTANT);
  9036. return o.setEasingFunction(r),
  9037. o
  9038. }
  9039. ,
  9040. e.CreateAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u, h) {
  9041. var d = e._PrepareAnimation(t, n, r, o, a, s, l, c);
  9042. return d ? (i.getScene && (h = i.getScene()),
  9043. h ? h.beginDirectAnimation(i, [d], 0, o, 1 === d.loopMode, 1, u) : null) : null
  9044. }
  9045. ,
  9046. e.CreateAndStartHierarchyAnimation = function(t, i, n, r, o, a, s, l, c, u, h) {
  9047. var d = e._PrepareAnimation(t, r, o, a, s, l, c, u);
  9048. return d ? i.getScene().beginDirectHierarchyAnimation(i, n, [d], 0, a, 1 === d.loopMode, 1, h) : null
  9049. }
  9050. ,
  9051. e.CreateMergeAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u) {
  9052. var h = e._PrepareAnimation(t, n, r, o, a, s, l, c);
  9053. return h ? (i.animations.push(h),
  9054. i.getScene().beginAnimation(i, 0, o, 1 === h.loopMode, 1, u)) : null
  9055. }
  9056. ,
  9057. e.MakeAnimationAdditive = function(t, i, n, r, o) {
  9058. void 0 === i && (i = 0),
  9059. void 0 === r && (r = !1);
  9060. var a = t;
  9061. if (r && ((a = t.clone()).name = o || a.name),
  9062. !a._keys.length)
  9063. return a;
  9064. i = i >= 0 ? i : 0;
  9065. var s = 0
  9066. , l = a._keys[0]
  9067. , c = a._keys.length - 1
  9068. , u = a._keys[c]
  9069. , h = {
  9070. referenceValue: l.value,
  9071. referencePosition: I.Vector3[0],
  9072. referenceQuaternion: I.Quaternion[0],
  9073. referenceScaling: I.Vector3[1],
  9074. keyPosition: I.Vector3[2],
  9075. keyQuaternion: I.Quaternion[1],
  9076. keyScaling: I.Vector3[3]
  9077. }
  9078. , d = !1
  9079. , p = l.frame
  9080. , f = u.frame;
  9081. if (n) {
  9082. var _ = a.getRange(n);
  9083. _ && (p = _.from,
  9084. f = _.to)
  9085. }
  9086. var m = l.frame === p
  9087. , g = u.frame === f;
  9088. if (1 === a._keys.length) {
  9089. var v = a._getKeyValue(a._keys[0]);
  9090. h.referenceValue = v.clone ? v.clone() : v,
  9091. d = !0
  9092. } else
  9093. i <= l.frame ? (v = a._getKeyValue(l.value),
  9094. h.referenceValue = v.clone ? v.clone() : v,
  9095. d = !0) : i >= u.frame && (v = a._getKeyValue(u.value),
  9096. h.referenceValue = v.clone ? v.clone() : v,
  9097. d = !0);
  9098. for (var y = 0; !d || !m || !g && y < a._keys.length - 1; ) {
  9099. var b = a._keys[y]
  9100. , T = a._keys[y + 1];
  9101. if (!d && i >= b.frame && i <= T.frame) {
  9102. if (v = void 0,
  9103. i === b.frame)
  9104. v = a._getKeyValue(b.value);
  9105. else if (i === T.frame)
  9106. v = a._getKeyValue(T.value);
  9107. else {
  9108. var E = {
  9109. key: y,
  9110. repeatCount: 0,
  9111. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  9112. };
  9113. v = a._interpolate(i, E)
  9114. }
  9115. h.referenceValue = v.clone ? v.clone() : v,
  9116. d = !0
  9117. }
  9118. if (!m && p >= b.frame && p <= T.frame) {
  9119. if (p === b.frame)
  9120. s = y;
  9121. else if (p === T.frame)
  9122. s = y + 1;
  9123. else {
  9124. E = {
  9125. key: y,
  9126. repeatCount: 0,
  9127. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  9128. };
  9129. var S = {
  9130. frame: p,
  9131. value: (v = a._interpolate(p, E)).clone ? v.clone() : v
  9132. };
  9133. a._keys.splice(y + 1, 0, S),
  9134. s = y + 1
  9135. }
  9136. m = !0
  9137. }
  9138. !g && f >= b.frame && f <= T.frame && (f === b.frame ? c = y : (f === T.frame || (E = {
  9139. key: y,
  9140. repeatCount: 0,
  9141. loopMode: this.ANIMATIONLOOPMODE_CONSTANT
  9142. },
  9143. S = {
  9144. frame: f,
  9145. value: (v = a._interpolate(f, E)).clone ? v.clone() : v
  9146. },
  9147. a._keys.splice(y + 1, 0, S)),
  9148. c = y + 1),
  9149. g = !0),
  9150. y++
  9151. }
  9152. for (a.dataType === e.ANIMATIONTYPE_QUATERNION ? h.referenceValue.normalize().conjugateInPlace() : a.dataType === e.ANIMATIONTYPE_MATRIX && (h.referenceValue.decompose(h.referenceScaling, h.referenceQuaternion, h.referencePosition),
  9153. h.referenceQuaternion.normalize().conjugateInPlace()),
  9154. y = s; y <= c; y++)
  9155. if (S = a._keys[y],
  9156. !y || a.dataType === e.ANIMATIONTYPE_FLOAT || S.value !== l.value)
  9157. switch (a.dataType) {
  9158. case e.ANIMATIONTYPE_MATRIX:
  9159. S.value.decompose(h.keyScaling, h.keyQuaternion, h.keyPosition),
  9160. h.keyPosition.subtractInPlace(h.referencePosition),
  9161. h.keyScaling.divideInPlace(h.referenceScaling),
  9162. h.referenceQuaternion.multiplyToRef(h.keyQuaternion, h.keyQuaternion),
  9163. P.ComposeToRef(h.keyScaling, h.keyQuaternion, h.keyPosition, S.value);
  9164. break;
  9165. case e.ANIMATIONTYPE_QUATERNION:
  9166. h.referenceValue.multiplyToRef(S.value, S.value);
  9167. break;
  9168. case e.ANIMATIONTYPE_VECTOR2:
  9169. case e.ANIMATIONTYPE_VECTOR3:
  9170. case e.ANIMATIONTYPE_COLOR3:
  9171. case e.ANIMATIONTYPE_COLOR4:
  9172. S.value.subtractToRef(h.referenceValue, S.value);
  9173. break;
  9174. case e.ANIMATIONTYPE_SIZE:
  9175. S.value.width -= h.referenceValue.width,
  9176. S.value.height -= h.referenceValue.height;
  9177. break;
  9178. default:
  9179. S.value -= h.referenceValue
  9180. }
  9181. return a
  9182. }
  9183. ,
  9184. e.TransitionTo = function(e, t, i, n, r, o, a, s) {
  9185. if (void 0 === s && (s = null),
  9186. a <= 0)
  9187. return i[e] = t,
  9188. s && s(),
  9189. null;
  9190. var l = r * (a / 1e3);
  9191. o.setKeys([{
  9192. frame: 0,
  9193. value: i[e].clone ? i[e].clone() : i[e]
  9194. }, {
  9195. frame: l,
  9196. value: t
  9197. }]),
  9198. i.animations || (i.animations = []),
  9199. i.animations.push(o);
  9200. var c = n.beginAnimation(i, 0, l, !1);
  9201. return c.onAnimationEnd = s,
  9202. c
  9203. }
  9204. ,
  9205. Object.defineProperty(e.prototype, "runtimeAnimations", {
  9206. get: function() {
  9207. return this._runtimeAnimations
  9208. },
  9209. enumerable: !1,
  9210. configurable: !0
  9211. }),
  9212. Object.defineProperty(e.prototype, "hasRunningRuntimeAnimations", {
  9213. get: function() {
  9214. for (var e = 0, t = this._runtimeAnimations; e < t.length; e++)
  9215. if (!t[e].isStopped())
  9216. return !0;
  9217. return !1
  9218. },
  9219. enumerable: !1,
  9220. configurable: !0
  9221. }),
  9222. e.prototype.toString = function(e) {
  9223. var t = "Name: " + this.name + ", property: " + this.targetProperty;
  9224. if (t += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType],
  9225. t += ", nKeys: " + (this._keys ? this._keys.length : "none"),
  9226. t += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
  9227. e) {
  9228. t += ", Ranges: {";
  9229. var i = !0;
  9230. for (var n in this._ranges)
  9231. i && (t += ", ",
  9232. i = !1),
  9233. t += n;
  9234. t += "}"
  9235. }
  9236. return t
  9237. }
  9238. ,
  9239. e.prototype.addEvent = function(e) {
  9240. this._events.push(e),
  9241. this._events.sort((function(e, t) {
  9242. return e.frame - t.frame
  9243. }
  9244. ))
  9245. }
  9246. ,
  9247. e.prototype.removeEvents = function(e) {
  9248. for (var t = 0; t < this._events.length; t++)
  9249. this._events[t].frame === e && (this._events.splice(t, 1),
  9250. t--)
  9251. }
  9252. ,
  9253. e.prototype.getEvents = function() {
  9254. return this._events
  9255. }
  9256. ,
  9257. e.prototype.createRange = function(e, t, i) {
  9258. this._ranges[e] || (this._ranges[e] = new We(e,t,i))
  9259. }
  9260. ,
  9261. e.prototype.deleteRange = function(e, t) {
  9262. void 0 === t && (t = !0);
  9263. var i = this._ranges[e];
  9264. if (i) {
  9265. if (t)
  9266. for (var n = i.from, r = i.to, o = this._keys.length - 1; o >= 0; o--)
  9267. this._keys[o].frame >= n && this._keys[o].frame <= r && this._keys.splice(o, 1);
  9268. this._ranges[e] = null
  9269. }
  9270. }
  9271. ,
  9272. e.prototype.getRange = function(e) {
  9273. return this._ranges[e]
  9274. }
  9275. ,
  9276. e.prototype.getKeys = function() {
  9277. return this._keys
  9278. }
  9279. ,
  9280. e.prototype.getHighestFrame = function() {
  9281. for (var e = 0, t = 0, i = this._keys.length; t < i; t++)
  9282. e < this._keys[t].frame && (e = this._keys[t].frame);
  9283. return e
  9284. }
  9285. ,
  9286. e.prototype.getEasingFunction = function() {
  9287. return this._easingFunction
  9288. }
  9289. ,
  9290. e.prototype.setEasingFunction = function(e) {
  9291. this._easingFunction = e
  9292. }
  9293. ,
  9294. e.prototype.floatInterpolateFunction = function(e, t, i) {
  9295. return d.Lerp(e, t, i)
  9296. }
  9297. ,
  9298. e.prototype.floatInterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9299. return d.Hermite(e, t, i, n, r)
  9300. }
  9301. ,
  9302. e.prototype.quaternionInterpolateFunction = function(e, t, i) {
  9303. return C.Slerp(e, t, i)
  9304. }
  9305. ,
  9306. e.prototype.quaternionInterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9307. return C.Hermite(e, t, i, n, r).normalize()
  9308. }
  9309. ,
  9310. e.prototype.vector3InterpolateFunction = function(e, t, i) {
  9311. return x.Lerp(e, t, i)
  9312. }
  9313. ,
  9314. e.prototype.vector3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9315. return x.Hermite(e, t, i, n, r)
  9316. }
  9317. ,
  9318. e.prototype.vector2InterpolateFunction = function(e, t, i) {
  9319. return A.Lerp(e, t, i)
  9320. }
  9321. ,
  9322. e.prototype.vector2InterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9323. return A.Hermite(e, t, i, n, r)
  9324. }
  9325. ,
  9326. e.prototype.sizeInterpolateFunction = function(e, t, i) {
  9327. return je.Lerp(e, t, i)
  9328. }
  9329. ,
  9330. e.prototype.color3InterpolateFunction = function(e, t, i) {
  9331. return D.Lerp(e, t, i)
  9332. }
  9333. ,
  9334. e.prototype.color3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9335. return D.Hermite(e, t, i, n, r)
  9336. }
  9337. ,
  9338. e.prototype.color4InterpolateFunction = function(e, t, i) {
  9339. return N.Lerp(e, t, i)
  9340. }
  9341. ,
  9342. e.prototype.color4InterpolateFunctionWithTangents = function(e, t, i, n, r) {
  9343. return N.Hermite(e, t, i, n, r)
  9344. }
  9345. ,
  9346. e.prototype._getKeyValue = function(e) {
  9347. return "function" == typeof e ? e() : e
  9348. }
  9349. ,
  9350. e.prototype.evaluate = function(t) {
  9351. return this._interpolate(t, {
  9352. key: 0,
  9353. repeatCount: 0,
  9354. loopMode: e.ANIMATIONLOOPMODE_CONSTANT
  9355. })
  9356. }
  9357. ,
  9358. e.prototype._interpolate = function(t, i) {
  9359. if (i.loopMode === e.ANIMATIONLOOPMODE_CONSTANT && i.repeatCount > 0)
  9360. return i.highLimitValue.clone ? i.highLimitValue.clone() : i.highLimitValue;
  9361. var n = this._keys;
  9362. if (1 === n.length)
  9363. return this._getKeyValue(n[0].value);
  9364. var r = i.key;
  9365. if (n[r].frame >= t)
  9366. for (; r - 1 >= 0 && n[r].frame >= t; )
  9367. r--;
  9368. for (var o = r; o < n.length - 1; o++) {
  9369. var a = n[o + 1];
  9370. if (a.frame >= t) {
  9371. i.key = o;
  9372. var s = n[o]
  9373. , l = this._getKeyValue(s.value)
  9374. , c = this._getKeyValue(a.value);
  9375. if (s.interpolation === ke.STEP)
  9376. return a.frame > t ? l : c;
  9377. var u = void 0 !== s.outTangent && void 0 !== a.inTangent
  9378. , h = a.frame - s.frame
  9379. , d = (t - s.frame) / h
  9380. , p = this.getEasingFunction();
  9381. switch (null !== p && (d = p.ease(d)),
  9382. this.dataType) {
  9383. case e.ANIMATIONTYPE_FLOAT:
  9384. var f = u ? this.floatInterpolateFunctionWithTangents(l, s.outTangent * h, c, a.inTangent * h, d) : this.floatInterpolateFunction(l, c, d);
  9385. switch (i.loopMode) {
  9386. case e.ANIMATIONLOOPMODE_CYCLE:
  9387. case e.ANIMATIONLOOPMODE_CONSTANT:
  9388. return f;
  9389. case e.ANIMATIONLOOPMODE_RELATIVE:
  9390. return i.offsetValue * i.repeatCount + f
  9391. }
  9392. break;
  9393. case e.ANIMATIONTYPE_QUATERNION:
  9394. var _ = u ? this.quaternionInterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.quaternionInterpolateFunction(l, c, d);
  9395. switch (i.loopMode) {
  9396. case e.ANIMATIONLOOPMODE_CYCLE:
  9397. case e.ANIMATIONLOOPMODE_CONSTANT:
  9398. return _;
  9399. case e.ANIMATIONLOOPMODE_RELATIVE:
  9400. return _.addInPlace(i.offsetValue.scale(i.repeatCount))
  9401. }
  9402. return _;
  9403. case e.ANIMATIONTYPE_VECTOR3:
  9404. var m = u ? this.vector3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector3InterpolateFunction(l, c, d);
  9405. switch (i.loopMode) {
  9406. case e.ANIMATIONLOOPMODE_CYCLE:
  9407. case e.ANIMATIONLOOPMODE_CONSTANT:
  9408. return m;
  9409. case e.ANIMATIONLOOPMODE_RELATIVE:
  9410. return m.add(i.offsetValue.scale(i.repeatCount))
  9411. }
  9412. break;
  9413. case e.ANIMATIONTYPE_VECTOR2:
  9414. var g = u ? this.vector2InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector2InterpolateFunction(l, c, d);
  9415. switch (i.loopMode) {
  9416. case e.ANIMATIONLOOPMODE_CYCLE:
  9417. case e.ANIMATIONLOOPMODE_CONSTANT:
  9418. return g;
  9419. case e.ANIMATIONLOOPMODE_RELATIVE:
  9420. return g.add(i.offsetValue.scale(i.repeatCount))
  9421. }
  9422. break;
  9423. case e.ANIMATIONTYPE_SIZE:
  9424. switch (i.loopMode) {
  9425. case e.ANIMATIONLOOPMODE_CYCLE:
  9426. case e.ANIMATIONLOOPMODE_CONSTANT:
  9427. return this.sizeInterpolateFunction(l, c, d);
  9428. case e.ANIMATIONLOOPMODE_RELATIVE:
  9429. return this.sizeInterpolateFunction(l, c, d).add(i.offsetValue.scale(i.repeatCount))
  9430. }
  9431. break;
  9432. case e.ANIMATIONTYPE_COLOR3:
  9433. var v = u ? this.color3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color3InterpolateFunction(l, c, d);
  9434. switch (i.loopMode) {
  9435. case e.ANIMATIONLOOPMODE_CYCLE:
  9436. case e.ANIMATIONLOOPMODE_CONSTANT:
  9437. return v;
  9438. case e.ANIMATIONLOOPMODE_RELATIVE:
  9439. return v.add(i.offsetValue.scale(i.repeatCount))
  9440. }
  9441. break;
  9442. case e.ANIMATIONTYPE_COLOR4:
  9443. var y = u ? this.color4InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color4InterpolateFunction(l, c, d);
  9444. switch (i.loopMode) {
  9445. case e.ANIMATIONLOOPMODE_CYCLE:
  9446. case e.ANIMATIONLOOPMODE_CONSTANT:
  9447. return y;
  9448. case e.ANIMATIONLOOPMODE_RELATIVE:
  9449. return y.add(i.offsetValue.scale(i.repeatCount))
  9450. }
  9451. break;
  9452. case e.ANIMATIONTYPE_MATRIX:
  9453. switch (i.loopMode) {
  9454. case e.ANIMATIONLOOPMODE_CYCLE:
  9455. case e.ANIMATIONLOOPMODE_CONSTANT:
  9456. return e.AllowMatricesInterpolation ? this.matrixInterpolateFunction(l, c, d, i.workValue) : l;
  9457. case e.ANIMATIONLOOPMODE_RELATIVE:
  9458. return l
  9459. }
  9460. }
  9461. break
  9462. }
  9463. }
  9464. return this._getKeyValue(n[n.length - 1].value)
  9465. }
  9466. ,
  9467. e.prototype.matrixInterpolateFunction = function(t, i, n, r) {
  9468. return e.AllowMatrixDecomposeForInterpolation ? r ? (P.DecomposeLerpToRef(t, i, n, r),
  9469. r) : P.DecomposeLerp(t, i, n) : r ? (P.LerpToRef(t, i, n, r),
  9470. r) : P.Lerp(t, i, n)
  9471. }
  9472. ,
  9473. e.prototype.clone = function() {
  9474. var t = new e(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
  9475. if (t.enableBlending = this.enableBlending,
  9476. t.blendingSpeed = this.blendingSpeed,
  9477. this._keys && t.setKeys(this._keys),
  9478. this._ranges)
  9479. for (var i in t._ranges = {},
  9480. this._ranges) {
  9481. var n = this._ranges[i];
  9482. n && (t._ranges[i] = n.clone())
  9483. }
  9484. return t
  9485. }
  9486. ,
  9487. e.prototype.setKeys = function(e) {
  9488. this._keys = e.slice(0)
  9489. }
  9490. ,
  9491. e.prototype.serialize = function() {
  9492. var t = {};
  9493. t.name = this.name,
  9494. t.property = this.targetProperty,
  9495. t.framePerSecond = this.framePerSecond,
  9496. t.dataType = this.dataType,
  9497. t.loopBehavior = this.loopMode,
  9498. t.enableBlending = this.enableBlending,
  9499. t.blendingSpeed = this.blendingSpeed;
  9500. var i = this.dataType;
  9501. t.keys = [];
  9502. for (var n = this.getKeys(), r = 0; r < n.length; r++) {
  9503. var o = n[r]
  9504. , a = {};
  9505. switch (a.frame = o.frame,
  9506. i) {
  9507. case e.ANIMATIONTYPE_FLOAT:
  9508. a.values = [o.value],
  9509. void 0 !== o.inTangent && a.values.push(o.inTangent),
  9510. void 0 !== o.outTangent && (void 0 === o.inTangent && a.values.push(void 0),
  9511. a.values.push(o.outTangent)),
  9512. void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0),
  9513. void 0 === o.outTangent && a.values.push(void 0),
  9514. a.values.push(o.interpolation));
  9515. break;
  9516. case e.ANIMATIONTYPE_QUATERNION:
  9517. case e.ANIMATIONTYPE_MATRIX:
  9518. case e.ANIMATIONTYPE_VECTOR3:
  9519. case e.ANIMATIONTYPE_COLOR3:
  9520. case e.ANIMATIONTYPE_COLOR4:
  9521. a.values = o.value.asArray(),
  9522. null != o.inTangent && a.values.push(o.inTangent.asArray()),
  9523. null != o.outTangent && (void 0 === o.inTangent && a.values.push(void 0),
  9524. a.values.push(o.outTangent.asArray())),
  9525. void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0),
  9526. void 0 === o.outTangent && a.values.push(void 0),
  9527. a.values.push(o.interpolation))
  9528. }
  9529. t.keys.push(a)
  9530. }
  9531. for (var s in t.ranges = [],
  9532. this._ranges) {
  9533. var l = this._ranges[s];
  9534. if (l) {
  9535. var c = {};
  9536. c.name = s,
  9537. c.from = l.from,
  9538. c.to = l.to,
  9539. t.ranges.push(c)
  9540. }
  9541. }
  9542. return t
  9543. }
  9544. ,
  9545. e._UniversalLerp = function(e, t, i) {
  9546. var n = e.constructor;
  9547. return n.Lerp ? n.Lerp(e, t, i) : n.Slerp ? n.Slerp(e, t, i) : e.toFixed ? e * (1 - i) + i * t : t
  9548. }
  9549. ,
  9550. e.Parse = function(t) {
  9551. var i, n, r = new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior), o = t.dataType, a = [];
  9552. for (t.enableBlending && (r.enableBlending = t.enableBlending),
  9553. t.blendingSpeed && (r.blendingSpeed = t.blendingSpeed),
  9554. n = 0; n < t.keys.length; n++) {
  9555. var s = t.keys[n]
  9556. , l = void 0
  9557. , c = void 0
  9558. , u = void 0;
  9559. switch (o) {
  9560. case e.ANIMATIONTYPE_FLOAT:
  9561. i = s.values[0],
  9562. s.values.length >= 2 && (l = s.values[1]),
  9563. s.values.length >= 3 && (c = s.values[2]),
  9564. s.values.length >= 4 && (u = s.values[3]);
  9565. break;
  9566. case e.ANIMATIONTYPE_QUATERNION:
  9567. if (i = C.FromArray(s.values),
  9568. s.values.length >= 8) {
  9569. var h = C.FromArray(s.values.slice(4, 8));
  9570. h.equals(C.Zero()) || (l = h)
  9571. }
  9572. if (s.values.length >= 12) {
  9573. var d = C.FromArray(s.values.slice(8, 12));
  9574. d.equals(C.Zero()) || (c = d)
  9575. }
  9576. s.values.length >= 13 && (u = s.values[12]);
  9577. break;
  9578. case e.ANIMATIONTYPE_MATRIX:
  9579. i = P.FromArray(s.values),
  9580. s.values.length >= 17 && (u = s.values[16]);
  9581. break;
  9582. case e.ANIMATIONTYPE_COLOR3:
  9583. i = D.FromArray(s.values),
  9584. s.values[3] && (l = D.FromArray(s.values[3])),
  9585. s.values[4] && (c = D.FromArray(s.values[4])),
  9586. s.values[5] && (u = s.values[5]);
  9587. break;
  9588. case e.ANIMATIONTYPE_COLOR4:
  9589. i = N.FromArray(s.values),
  9590. s.values[4] && (l = N.FromArray(s.values[4])),
  9591. s.values[5] && (c = N.FromArray(s.values[5])),
  9592. s.values[6] && (u = N.FromArray(s.values[6]));
  9593. break;
  9594. case e.ANIMATIONTYPE_VECTOR3:
  9595. default:
  9596. i = x.FromArray(s.values),
  9597. s.values[3] && (l = x.FromArray(s.values[3])),
  9598. s.values[4] && (c = x.FromArray(s.values[4])),
  9599. s.values[5] && (u = s.values[5])
  9600. }
  9601. var p = {};
  9602. p.frame = s.frame,
  9603. p.value = i,
  9604. null != l && (p.inTangent = l),
  9605. null != c && (p.outTangent = c),
  9606. null != u && (p.interpolation = u),
  9607. a.push(p)
  9608. }
  9609. if (r.setKeys(a),
  9610. t.ranges)
  9611. for (n = 0; n < t.ranges.length; n++)
  9612. i = t.ranges[n],
  9613. r.createRange(i.name, i.from, i.to);
  9614. return r
  9615. }
  9616. ,
  9617. e.AppendSerializedAnimations = function(e, t) {
  9618. Ge.AppendSerializedAnimations(e, t)
  9619. }
  9620. ,
  9621. e.ParseFromFileAsync = function(e, t) {
  9622. var i = this;
  9623. return new Promise((function(n, r) {
  9624. var o = new Ye;
  9625. o.addEventListener("readystatechange", (function() {
  9626. if (4 == o.readyState)
  9627. if (200 == o.status) {
  9628. var t = JSON.parse(o.responseText);
  9629. if (t.animations && (t = t.animations),
  9630. t.length) {
  9631. for (var a = new Array, s = 0, l = t; s < l.length; s++) {
  9632. var c = l[s];
  9633. a.push(i.Parse(c))
  9634. }
  9635. n(a)
  9636. } else
  9637. a = i.Parse(t),
  9638. e && (a.name = e),
  9639. n(a)
  9640. } else
  9641. r("Unable to load the animation")
  9642. }
  9643. )),
  9644. o.open("GET", t),
  9645. o.send()
  9646. }
  9647. ))
  9648. }
  9649. ,
  9650. e.CreateFromSnippetAsync = function(e) {
  9651. var t = this;
  9652. return new Promise((function(i, n) {
  9653. var r = new Ye;
  9654. r.addEventListener("readystatechange", (function() {
  9655. if (4 == r.readyState)
  9656. if (200 == r.status) {
  9657. var o = JSON.parse(JSON.parse(r.responseText).jsonPayload);
  9658. if (o.animations) {
  9659. for (var a = JSON.parse(o.animations), s = new Array, l = 0, c = a.animations; l < c.length; l++) {
  9660. var u = c[l];
  9661. (h = t.Parse(u)).snippetId = e,
  9662. s.push(h)
  9663. }
  9664. i(s)
  9665. } else {
  9666. var h;
  9667. a = JSON.parse(o.animation),
  9668. (h = t.Parse(a)).snippetId = e,
  9669. i(h)
  9670. }
  9671. } else
  9672. n("Unable to load the snippet " + e)
  9673. }
  9674. )),
  9675. r.open("GET", t.SnippetUrl + "/" + e.replace(/#/g, "/")),
  9676. r.send()
  9677. }
  9678. ))
  9679. }
  9680. ,
  9681. e._UniqueIdGenerator = 0,
  9682. e.AllowMatricesInterpolation = !1,
  9683. e.AllowMatrixDecomposeForInterpolation = !0,
  9684. e.SnippetUrl = "https://snippet.babylonjs.com",
  9685. e.ANIMATIONTYPE_FLOAT = 0,
  9686. e.ANIMATIONTYPE_VECTOR3 = 1,
  9687. e.ANIMATIONTYPE_QUATERNION = 2,
  9688. e.ANIMATIONTYPE_MATRIX = 3,
  9689. e.ANIMATIONTYPE_COLOR3 = 4,
  9690. e.ANIMATIONTYPE_COLOR4 = 7,
  9691. e.ANIMATIONTYPE_VECTOR2 = 5,
  9692. e.ANIMATIONTYPE_SIZE = 6,
  9693. e.ANIMATIONLOOPMODE_RELATIVE = 0,
  9694. e.ANIMATIONLOOPMODE_CYCLE = 1,
  9695. e.ANIMATIONLOOPMODE_CONSTANT = 2,
  9696. e
  9697. }();
  9698. y("BABYLON.Animation", Qe),
  9699. Xe._AnimationRangeFactory = function(e, t, i) {
  9700. return new We(e,t,i)
  9701. }
  9702. ;
  9703. var qe = function(e) {
  9704. function t(t, i, n, r, o, a, s, l) {
  9705. void 0 === o && (o = 1e3);
  9706. var c = e.call(this, t, a) || this;
  9707. return c.duration = 1e3,
  9708. c.onInterpolationDoneObservable = new h,
  9709. c.propertyPath = n,
  9710. c.value = r,
  9711. c.duration = o,
  9712. c.stopOtherAnimations = s,
  9713. c.onInterpolationDone = l,
  9714. c._target = c._effectiveTarget = i,
  9715. c
  9716. }
  9717. return U(t, e),
  9718. t.prototype._prepare = function() {
  9719. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
  9720. this._property = this._getProperty(this.propertyPath)
  9721. }
  9722. ,
  9723. t.prototype.execute = function() {
  9724. var e, t = this, i = this._actionManager.getScene(), n = [{
  9725. frame: 0,
  9726. value: this._effectiveTarget[this._property]
  9727. }, {
  9728. frame: 100,
  9729. value: this.value
  9730. }];
  9731. if ("number" == typeof this.value)
  9732. e = Qe.ANIMATIONTYPE_FLOAT;
  9733. else if (this.value instanceof D)
  9734. e = Qe.ANIMATIONTYPE_COLOR3;
  9735. else if (this.value instanceof x)
  9736. e = Qe.ANIMATIONTYPE_VECTOR3;
  9737. else if (this.value instanceof P)
  9738. e = Qe.ANIMATIONTYPE_MATRIX;
  9739. else {
  9740. if (!(this.value instanceof C))
  9741. return void K.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  9742. e = Qe.ANIMATIONTYPE_QUATERNION
  9743. }
  9744. var r = new Qe("InterpolateValueAction",this._property,1e3 / this.duration * 100,e,Qe.ANIMATIONLOOPMODE_CONSTANT);
  9745. r.setKeys(n),
  9746. this.stopOtherAnimations && i.stopAnimation(this._effectiveTarget),
  9747. i.beginDirectAnimation(this._effectiveTarget, [r], 0, 100, !1, 1, (function() {
  9748. t.onInterpolationDoneObservable.notifyObservers(t),
  9749. t.onInterpolationDone && t.onInterpolationDone()
  9750. }
  9751. ))
  9752. }
  9753. ,
  9754. t.prototype.serialize = function(t) {
  9755. return e.prototype._serialize.call(this, {
  9756. name: "InterpolateValueAction",
  9757. properties: [F._GetTargetProperty(this._target), {
  9758. name: "propertyPath",
  9759. value: this.propertyPath
  9760. }, {
  9761. name: "value",
  9762. value: F._SerializeValueAsString(this.value)
  9763. }, {
  9764. name: "duration",
  9765. value: F._SerializeValueAsString(this.duration)
  9766. }, {
  9767. name: "stopOtherAnimations",
  9768. value: F._SerializeValueAsString(this.stopOtherAnimations) || !1
  9769. }]
  9770. }, t)
  9771. }
  9772. ,
  9773. t
  9774. }(F);
  9775. y("BABYLON.InterpolateValueAction", qe);
  9776. var Ze = Object.freeze(new C(0,0,0,0))
  9777. , Je = Object.freeze(x.Zero())
  9778. , $e = Object.freeze(A.Zero())
  9779. , et = Object.freeze(je.Zero())
  9780. , tt = Object.freeze(D.Black())
  9781. , it = function() {
  9782. function e(e, t, i, n) {
  9783. var r = this;
  9784. if (this._events = new Array,
  9785. this._currentFrame = 0,
  9786. this._originalValue = new Array,
  9787. this._originalBlendValue = null,
  9788. this._offsetsCache = {},
  9789. this._highLimitsCache = {},
  9790. this._stopped = !1,
  9791. this._blendingFactor = 0,
  9792. this._currentValue = null,
  9793. this._currentActiveTarget = null,
  9794. this._directTarget = null,
  9795. this._targetPath = "",
  9796. this._weight = 1,
  9797. this._ratioOffset = 0,
  9798. this._previousDelay = 0,
  9799. this._previousRatio = 0,
  9800. this._targetIsArray = !1,
  9801. this._animation = t,
  9802. this._target = e,
  9803. this._scene = i,
  9804. this._host = n,
  9805. this._activeTargets = [],
  9806. t._runtimeAnimations.push(this),
  9807. this._animationState = {
  9808. key: 0,
  9809. repeatCount: 0,
  9810. loopMode: this._getCorrectLoopMode()
  9811. },
  9812. this._animation.dataType === Qe.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = P.Zero()),
  9813. this._keys = this._animation.getKeys(),
  9814. this._minFrame = this._keys[0].frame,
  9815. this._maxFrame = this._keys[this._keys.length - 1].frame,
  9816. this._minValue = this._keys[0].value,
  9817. this._maxValue = this._keys[this._keys.length - 1].value,
  9818. 0 !== this._minFrame) {
  9819. var o = {
  9820. frame: 0,
  9821. value: this._minValue
  9822. };
  9823. this._keys.splice(0, 0, o)
  9824. }
  9825. if (this._target instanceof Array) {
  9826. for (var a = 0, s = 0, l = this._target; s < l.length; s++) {
  9827. var c = l[s];
  9828. this._preparePath(c, a),
  9829. this._getOriginalValues(a),
  9830. a++
  9831. }
  9832. this._targetIsArray = !0
  9833. } else
  9834. this._preparePath(this._target),
  9835. this._getOriginalValues(),
  9836. this._targetIsArray = !1,
  9837. this._directTarget = this._activeTargets[0];
  9838. var u = t.getEvents();
  9839. u && u.length > 0 && u.forEach((function(e) {
  9840. r._events.push(e._clone())
  9841. }
  9842. )),
  9843. this._enableBlending = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.enableBlending : this._animation.enableBlending
  9844. }
  9845. return Object.defineProperty(e.prototype, "currentFrame", {
  9846. get: function() {
  9847. return this._currentFrame
  9848. },
  9849. enumerable: !1,
  9850. configurable: !0
  9851. }),
  9852. Object.defineProperty(e.prototype, "weight", {
  9853. get: function() {
  9854. return this._weight
  9855. },
  9856. enumerable: !1,
  9857. configurable: !0
  9858. }),
  9859. Object.defineProperty(e.prototype, "currentValue", {
  9860. get: function() {
  9861. return this._currentValue
  9862. },
  9863. enumerable: !1,
  9864. configurable: !0
  9865. }),
  9866. Object.defineProperty(e.prototype, "targetPath", {
  9867. get: function() {
  9868. return this._targetPath
  9869. },
  9870. enumerable: !1,
  9871. configurable: !0
  9872. }),
  9873. Object.defineProperty(e.prototype, "target", {
  9874. get: function() {
  9875. return this._currentActiveTarget
  9876. },
  9877. enumerable: !1,
  9878. configurable: !0
  9879. }),
  9880. Object.defineProperty(e.prototype, "isAdditive", {
  9881. get: function() {
  9882. return this._host && this._host.isAdditive
  9883. },
  9884. enumerable: !1,
  9885. configurable: !0
  9886. }),
  9887. e.prototype._preparePath = function(e, t) {
  9888. void 0 === t && (t = 0);
  9889. var i = this._animation.targetPropertyPath;
  9890. if (i.length > 1) {
  9891. for (var n = e[i[0]], r = 1; r < i.length - 1; r++)
  9892. n = n[i[r]];
  9893. this._targetPath = i[i.length - 1],
  9894. this._activeTargets[t] = n
  9895. } else
  9896. this._targetPath = i[0],
  9897. this._activeTargets[t] = e
  9898. }
  9899. ,
  9900. Object.defineProperty(e.prototype, "animation", {
  9901. get: function() {
  9902. return this._animation
  9903. },
  9904. enumerable: !1,
  9905. configurable: !0
  9906. }),
  9907. e.prototype.reset = function(e) {
  9908. if (void 0 === e && (e = !1),
  9909. e)
  9910. if (this._target instanceof Array)
  9911. for (var t = 0, i = 0, n = this._target; i < n.length; i++) {
  9912. var r = n[i];
  9913. void 0 !== this._originalValue[t] && this._setValue(r, this._activeTargets[t], this._originalValue[t], -1, t),
  9914. t++
  9915. }
  9916. else
  9917. void 0 !== this._originalValue[0] && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  9918. for (this._offsetsCache = {},
  9919. this._highLimitsCache = {},
  9920. this._currentFrame = 0,
  9921. this._blendingFactor = 0,
  9922. t = 0; t < this._events.length; t++)
  9923. this._events[t].isDone = !1
  9924. }
  9925. ,
  9926. e.prototype.isStopped = function() {
  9927. return this._stopped
  9928. }
  9929. ,
  9930. e.prototype.dispose = function() {
  9931. var e = this._animation.runtimeAnimations.indexOf(this);
  9932. e > -1 && this._animation.runtimeAnimations.splice(e, 1)
  9933. }
  9934. ,
  9935. e.prototype.setValue = function(e, t) {
  9936. if (this._targetIsArray)
  9937. for (var i = 0; i < this._target.length; i++) {
  9938. var n = this._target[i];
  9939. this._setValue(n, this._activeTargets[i], e, t, i)
  9940. }
  9941. else
  9942. this._setValue(this._target, this._directTarget, e, t, 0)
  9943. }
  9944. ,
  9945. e.prototype._getOriginalValues = function(e) {
  9946. var t;
  9947. void 0 === e && (e = 0);
  9948. var i = this._activeTargets[e];
  9949. (t = i.getRestPose && "_matrix" === this._targetPath ? i.getRestPose() : i[this._targetPath]) && t.clone ? this._originalValue[e] = t.clone() : this._originalValue[e] = t
  9950. }
  9951. ,
  9952. e.prototype._setValue = function(e, t, i, n, r) {
  9953. if (this._currentActiveTarget = t,
  9954. this._weight = n,
  9955. this._enableBlending && this._blendingFactor <= 1) {
  9956. if (!this._originalBlendValue) {
  9957. var o = t[this._targetPath];
  9958. o.clone ? this._originalBlendValue = o.clone() : this._originalBlendValue = o
  9959. }
  9960. this._originalBlendValue.m ? Qe.AllowMatrixDecomposeForInterpolation ? this._currentValue ? P.DecomposeLerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.DecomposeLerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue ? P.LerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.Lerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue = Qe._UniversalLerp(this._originalBlendValue, i, this._blendingFactor);
  9961. var a = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  9962. this._blendingFactor += a
  9963. } else
  9964. this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(i) : this._currentValue = i : (null == i ? void 0 : i.clone) ? this._currentValue = i.clone() : this._currentValue = i;
  9965. -1 !== n ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[r]) : t[this._targetPath] = this._currentValue,
  9966. e.markAsDirty && e.markAsDirty(this._animation.targetProperty)
  9967. }
  9968. ,
  9969. e.prototype._getCorrectLoopMode = function() {
  9970. return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode
  9971. }
  9972. ,
  9973. e.prototype.goToFrame = function(e) {
  9974. var t = this._animation.getKeys();
  9975. e < t[0].frame ? e = t[0].frame : e > t[t.length - 1].frame && (e = t[t.length - 1].frame);
  9976. var i = this._events;
  9977. if (i.length)
  9978. for (var n = 0; n < i.length; n++)
  9979. i[n].onlyOnce || (i[n].isDone = i[n].frame < e);
  9980. this._currentFrame = e;
  9981. var r = this._animation._interpolate(e, this._animationState);
  9982. this.setValue(r, -1)
  9983. }
  9984. ,
  9985. e.prototype._prepareForSpeedRatioChange = function(e) {
  9986. var t = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
  9987. this._ratioOffset = this._previousRatio - t
  9988. }
  9989. ,
  9990. e.prototype.animate = function(e, t, i, n, r, o) {
  9991. void 0 === o && (o = -1);
  9992. var a = this._animation
  9993. , s = a.targetPropertyPath;
  9994. if (!s || s.length < 1)
  9995. return this._stopped = !0,
  9996. !1;
  9997. var l = !0;
  9998. (t < this._minFrame || t > this._maxFrame) && (t = this._minFrame),
  9999. (i < this._minFrame || i > this._maxFrame) && (i = this._maxFrame);
  10000. var c, u, h = i - t, d = e * (a.framePerSecond * r) / 1e3 + this._ratioOffset, p = 0;
  10001. if (this._previousDelay = e,
  10002. this._previousRatio = d,
  10003. !n && i >= t && d >= h)
  10004. l = !1,
  10005. p = a._getKeyValue(this._maxValue);
  10006. else if (!n && t >= i && d <= h)
  10007. l = !1,
  10008. p = a._getKeyValue(this._minValue);
  10009. else if (this._animationState.loopMode !== Qe.ANIMATIONLOOPMODE_CYCLE) {
  10010. var f = i.toString() + t.toString();
  10011. if (!this._offsetsCache[f]) {
  10012. this._animationState.repeatCount = 0,
  10013. this._animationState.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE;
  10014. var _ = a._interpolate(t, this._animationState)
  10015. , m = a._interpolate(i, this._animationState);
  10016. switch (this._animationState.loopMode = this._getCorrectLoopMode(),
  10017. a.dataType) {
  10018. case Qe.ANIMATIONTYPE_FLOAT:
  10019. this._offsetsCache[f] = m - _;
  10020. break;
  10021. case Qe.ANIMATIONTYPE_QUATERNION:
  10022. case Qe.ANIMATIONTYPE_VECTOR3:
  10023. case Qe.ANIMATIONTYPE_VECTOR2:
  10024. case Qe.ANIMATIONTYPE_SIZE:
  10025. case Qe.ANIMATIONTYPE_COLOR3:
  10026. this._offsetsCache[f] = m.subtract(_)
  10027. }
  10028. this._highLimitsCache[f] = m
  10029. }
  10030. p = this._highLimitsCache[f],
  10031. c = this._offsetsCache[f]
  10032. }
  10033. if (void 0 === c)
  10034. switch (a.dataType) {
  10035. case Qe.ANIMATIONTYPE_FLOAT:
  10036. c = 0;
  10037. break;
  10038. case Qe.ANIMATIONTYPE_QUATERNION:
  10039. c = Ze;
  10040. break;
  10041. case Qe.ANIMATIONTYPE_VECTOR3:
  10042. c = Je;
  10043. break;
  10044. case Qe.ANIMATIONTYPE_VECTOR2:
  10045. c = $e;
  10046. break;
  10047. case Qe.ANIMATIONTYPE_SIZE:
  10048. c = et;
  10049. break;
  10050. case Qe.ANIMATIONTYPE_COLOR3:
  10051. c = tt
  10052. }
  10053. if (this._host && this._host.syncRoot) {
  10054. var g = this._host.syncRoot;
  10055. u = t + (i - t) * ((g.masterFrame - g.fromFrame) / (g.toFrame - g.fromFrame))
  10056. } else
  10057. u = d > 0 && t > i || d < 0 && t < i ? l && 0 !== h ? i + d % h : t : l && 0 !== h ? t + d % h : i;
  10058. var v = this._events;
  10059. if ((r > 0 && this.currentFrame > u || r < 0 && this.currentFrame < u) && (this._onLoop(),
  10060. v.length))
  10061. for (var y = 0; y < v.length; y++)
  10062. v[y].onlyOnce || (v[y].isDone = !1);
  10063. this._currentFrame = u,
  10064. this._animationState.repeatCount = 0 === h ? 0 : d / h >> 0,
  10065. this._animationState.highLimitValue = p,
  10066. this._animationState.offsetValue = c;
  10067. var b = a._interpolate(u, this._animationState);
  10068. if (this.setValue(b, o),
  10069. v.length)
  10070. for (y = 0; y < v.length; y++)
  10071. if (h > 0 && u >= v[y].frame && v[y].frame >= t || h < 0 && u <= v[y].frame && v[y].frame <= t) {
  10072. var T = v[y];
  10073. T.isDone || (T.onlyOnce && (v.splice(y, 1),
  10074. y--),
  10075. T.isDone = !0,
  10076. T.action(u))
  10077. }
  10078. return l || (this._stopped = !0),
  10079. l
  10080. }
  10081. ,
  10082. e
  10083. }();
  10084. function nt() {
  10085. return "undefined" != typeof window
  10086. }
  10087. function rt() {
  10088. return "undefined" != typeof navigator
  10089. }
  10090. function ot() {
  10091. return "undefined" != typeof document
  10092. }
  10093. function at(e) {
  10094. for (var t = "", i = e.firstChild; i; )
  10095. 3 === i.nodeType && (t += i.textContent),
  10096. i = i.nextSibling;
  10097. return t
  10098. }
  10099. var st, lt = {
  10100. IsWindowObjectExist: nt,
  10101. IsNavigatorAvailable: rt,
  10102. IsDocumentAvailable: ot,
  10103. GetDOMTextContent: at
  10104. }, ct = function() {
  10105. function e() {}
  10106. return Object.defineProperty(e, "Now", {
  10107. get: function() {
  10108. return lt.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
  10109. },
  10110. enumerable: !1,
  10111. configurable: !0
  10112. }),
  10113. e
  10114. }(), ut = function() {
  10115. function e() {}
  10116. return e.FilesToLoad = {},
  10117. e
  10118. }(), ht = function() {
  10119. function e() {}
  10120. return e.ExponentialBackoff = function(e, t) {
  10121. return void 0 === e && (e = 3),
  10122. void 0 === t && (t = 500),
  10123. function(i, n, r) {
  10124. return 0 !== n.status || r >= e || -1 !== i.indexOf("file:") ? -1 : Math.pow(2, r) * t
  10125. }
  10126. }
  10127. ,
  10128. e
  10129. }(), dt = function(e) {
  10130. function t() {
  10131. return null !== e && e.apply(this, arguments) || this
  10132. }
  10133. return U(t, e),
  10134. t._setPrototypeOf = Object.setPrototypeOf || function(e, t) {
  10135. return e.__proto__ = t,
  10136. e
  10137. }
  10138. ,
  10139. t
  10140. }(Error), pt = {
  10141. MeshInvalidPositionsError: 0,
  10142. UnsupportedTextureError: 1e3,
  10143. GLTFLoaderUnexpectedMagicError: 2e3,
  10144. SceneLoaderError: 3e3,
  10145. LoadFileError: 4e3,
  10146. RequestFileError: 4001,
  10147. ReadFileError: 4002
  10148. }, ft = function(e) {
  10149. function t(i, n, r) {
  10150. var o = e.call(this, i) || this;
  10151. return o.errorCode = n,
  10152. o.innerError = r,
  10153. o.name = "RuntimeError",
  10154. dt._setPrototypeOf(o, t.prototype),
  10155. o
  10156. }
  10157. return U(t, e),
  10158. t
  10159. }(dt), _t = function() {
  10160. function e() {
  10161. this.children = []
  10162. }
  10163. return e.prototype.isValid = function(e) {
  10164. return !0
  10165. }
  10166. ,
  10167. e.prototype.process = function(e, t) {
  10168. var i = "";
  10169. if (this.line) {
  10170. var n = this.line
  10171. , r = t.processor;
  10172. r && (r.lineProcessor && (n = r.lineProcessor(n, t.isFragment, t.processingContext)),
  10173. r.attributeProcessor && ae(this.line, "attribute") ? n = r.attributeProcessor(this.line, e, t.processingContext) : r.varyingProcessor && ae(this.line, "varying") ? n = r.varyingProcessor(this.line, t.isFragment, e, t.processingContext) : r.uniformProcessor && r.uniformRegexp && r.uniformRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && r.uniformBufferRegexp && r.uniformBufferRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
  10174. t.lookForClosingBracketForUniformBuffer = !0) : r.textureProcessor && r.textureRegexp && r.textureRegexp.test(this.line) ? n = r.textureProcessor(this.line, t.isFragment, e, t.processingContext) : (r.uniformProcessor || r.uniformBufferProcessor) && ae(this.line, "uniform") && !t.lookForClosingBracketForUniformBuffer && (/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line) ? r.uniformProcessor && (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
  10175. t.lookForClosingBracketForUniformBuffer = !0)),
  10176. t.lookForClosingBracketForUniformBuffer && -1 !== this.line.indexOf("}") && (t.lookForClosingBracketForUniformBuffer = !1,
  10177. r.endOfUniformBufferProcessor && (n = r.endOfUniformBufferProcessor(this.line, t.isFragment, t.processingContext)))),
  10178. i += n + "\r\n"
  10179. }
  10180. return this.children.forEach((function(n) {
  10181. i += n.process(e, t)
  10182. }
  10183. )),
  10184. this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
  10185. i
  10186. }
  10187. ,
  10188. e
  10189. }(), mt = function() {
  10190. function e() {}
  10191. return Object.defineProperty(e.prototype, "currentLine", {
  10192. get: function() {
  10193. return this._lines[this.lineIndex]
  10194. },
  10195. enumerable: !1,
  10196. configurable: !0
  10197. }),
  10198. Object.defineProperty(e.prototype, "canRead", {
  10199. get: function() {
  10200. return this.lineIndex < this._lines.length - 1
  10201. },
  10202. enumerable: !1,
  10203. configurable: !0
  10204. }),
  10205. Object.defineProperty(e.prototype, "lines", {
  10206. set: function(e) {
  10207. this._lines = [];
  10208. for (var t = 0, i = e; t < i.length; t++) {
  10209. var n = i[t];
  10210. if ("#" !== n[0])
  10211. for (var r = n.split(";"), o = 0; o < r.length; o++) {
  10212. var a = r[o];
  10213. (a = a.trim()) && this._lines.push(a + (o !== r.length - 1 ? ";" : ""))
  10214. }
  10215. else
  10216. this._lines.push(n)
  10217. }
  10218. },
  10219. enumerable: !1,
  10220. configurable: !0
  10221. }),
  10222. e
  10223. }(), gt = function(e) {
  10224. function t() {
  10225. return null !== e && e.apply(this, arguments) || this
  10226. }
  10227. return U(t, e),
  10228. t.prototype.process = function(e, t) {
  10229. for (var i = 0; i < this.children.length; i++) {
  10230. var n = this.children[i];
  10231. if (n.isValid(e))
  10232. return n.process(e, t)
  10233. }
  10234. return ""
  10235. }
  10236. ,
  10237. t
  10238. }(_t), vt = function(e) {
  10239. function t() {
  10240. return null !== e && e.apply(this, arguments) || this
  10241. }
  10242. return U(t, e),
  10243. t.prototype.isValid = function(e) {
  10244. return this.testExpression.isTrue(e)
  10245. }
  10246. ,
  10247. t
  10248. }(_t), yt = function() {
  10249. function e() {}
  10250. return e.prototype.isTrue = function(e) {
  10251. return !0
  10252. }
  10253. ,
  10254. e.postfixToInfix = function(t) {
  10255. for (var i = [], n = 0, r = t; n < r.length; n++) {
  10256. var o = r[n];
  10257. if (void 0 === e._OperatorPriority[o])
  10258. i.push(o);
  10259. else {
  10260. var a = i[i.length - 1]
  10261. , s = i[i.length - 2];
  10262. i.length -= 2,
  10263. i.push("(".concat(s).concat(o).concat(a, ")"))
  10264. }
  10265. }
  10266. return i[i.length - 1]
  10267. }
  10268. ,
  10269. e.infixToPostfix = function(t) {
  10270. for (var i = [], n = -1, r = function() {
  10271. "" !== (c = c.trim()) && (i.push(c),
  10272. c = "")
  10273. }, o = function(t) {
  10274. n < e._Stack.length - 1 && (e._Stack[++n] = t)
  10275. }, a = function() {
  10276. return e._Stack[n]
  10277. }, s = function() {
  10278. return -1 === n ? "!!INVALID EXPRESSION!!" : e._Stack[n--]
  10279. }, l = 0, c = ""; l < t.length; ) {
  10280. var u = t.charAt(l)
  10281. , h = l < t.length - 1 ? t.substr(l, 2) : "";
  10282. if ("(" === u)
  10283. c = "",
  10284. o(u);
  10285. else if (")" === u) {
  10286. for (r(); -1 !== n && "(" !== a(); )
  10287. i.push(s());
  10288. s()
  10289. } else if (e._OperatorPriority[h] > 1) {
  10290. for (r(); -1 !== n && e._OperatorPriority[a()] >= e._OperatorPriority[h]; )
  10291. i.push(s());
  10292. o(h),
  10293. l++
  10294. } else
  10295. c += u;
  10296. l++
  10297. }
  10298. for (r(); -1 !== n; )
  10299. "(" === a() ? s() : i.push(s());
  10300. return i
  10301. }
  10302. ,
  10303. e._OperatorPriority = {
  10304. ")": 0,
  10305. "(": 1,
  10306. "||": 2,
  10307. "&&": 3
  10308. },
  10309. e._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
  10310. e
  10311. }(), bt = function(e) {
  10312. function t(t, i) {
  10313. void 0 === i && (i = !1);
  10314. var n = e.call(this) || this;
  10315. return n.define = t,
  10316. n.not = i,
  10317. n
  10318. }
  10319. return U(t, e),
  10320. t.prototype.isTrue = function(e) {
  10321. var t = void 0 !== e[this.define];
  10322. return this.not && (t = !t),
  10323. t
  10324. }
  10325. ,
  10326. t
  10327. }(yt), Tt = function(e) {
  10328. function t() {
  10329. return null !== e && e.apply(this, arguments) || this
  10330. }
  10331. return U(t, e),
  10332. t.prototype.isTrue = function(e) {
  10333. return this.leftOperand.isTrue(e) || this.rightOperand.isTrue(e)
  10334. }
  10335. ,
  10336. t
  10337. }(yt), Et = function(e) {
  10338. function t() {
  10339. return null !== e && e.apply(this, arguments) || this
  10340. }
  10341. return U(t, e),
  10342. t.prototype.isTrue = function(e) {
  10343. return this.leftOperand.isTrue(e) && this.rightOperand.isTrue(e)
  10344. }
  10345. ,
  10346. t
  10347. }(yt), St = function(e) {
  10348. function t(t, i, n) {
  10349. var r = e.call(this) || this;
  10350. return r.define = t,
  10351. r.operand = i,
  10352. r.testValue = n,
  10353. r
  10354. }
  10355. return U(t, e),
  10356. t.prototype.isTrue = function(e) {
  10357. var t = e[this.define];
  10358. void 0 === t && (t = this.define);
  10359. var i = !1
  10360. , n = parseInt(t)
  10361. , r = parseInt(this.testValue);
  10362. switch (this.operand) {
  10363. case ">":
  10364. i = n > r;
  10365. break;
  10366. case "<":
  10367. i = n < r;
  10368. break;
  10369. case "<=":
  10370. i = n <= r;
  10371. break;
  10372. case ">=":
  10373. i = n >= r;
  10374. break;
  10375. case "==":
  10376. i = n === r
  10377. }
  10378. return i
  10379. }
  10380. ,
  10381. t
  10382. }(yt);
  10383. !function(e) {
  10384. e[e.GLSL = 0] = "GLSL",
  10385. e[e.WGSL = 1] = "WGSL"
  10386. }(st || (st = {}));
  10387. var At, xt = /defined\s*?\((.+?)\)/g, Rt = /defined\s*?\[(.+?)\]/g, Ct = function() {
  10388. function e() {}
  10389. return e.Initialize = function(e) {
  10390. e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
  10391. }
  10392. ,
  10393. e.Process = function(e, t, i, n) {
  10394. var r, o = this;
  10395. (null === (r = t.processor) || void 0 === r ? void 0 : r.preProcessShaderCode) && (e = t.processor.preProcessShaderCode(e, t.isFragment)),
  10396. this._ProcessIncludes(e, t, (function(e) {
  10397. t.processCodeAfterIncludes && (e = t.processCodeAfterIncludes(t.isFragment ? "fragment" : "vertex", e));
  10398. var r = o._ProcessShaderConversion(e, t, n);
  10399. i(r)
  10400. }
  10401. ))
  10402. }
  10403. ,
  10404. e.PreProcess = function(e, t, i, n) {
  10405. var r, o = this;
  10406. (null === (r = t.processor) || void 0 === r ? void 0 : r.preProcessShaderCode) && (e = t.processor.preProcessShaderCode(e, t.isFragment)),
  10407. this._ProcessIncludes(e, t, (function(e) {
  10408. t.processCodeAfterIncludes && (e = t.processCodeAfterIncludes(t.isFragment ? "fragment" : "vertex", e));
  10409. var r = o._ApplyPreProcessing(e, t, n);
  10410. i(r)
  10411. }
  10412. ))
  10413. }
  10414. ,
  10415. e.Finalize = function(e, t, i) {
  10416. return i.processor && i.processor.finalizeShaders ? i.processor.finalizeShaders(e, t, i.processingContext) : {
  10417. vertexCode: e,
  10418. fragmentCode: t
  10419. }
  10420. }
  10421. ,
  10422. e._ProcessPrecision = function(e, t) {
  10423. var i;
  10424. if (null === (i = t.processor) || void 0 === i ? void 0 : i.noPrecision)
  10425. return e;
  10426. var n = t.shouldUseHighPrecisionShader;
  10427. return -1 === e.indexOf("precision highp float") ? e = n ? "precision highp float;\n" + e : "precision mediump float;\n" + e : n || (e = e.replace("precision highp float", "precision mediump float")),
  10428. e
  10429. }
  10430. ,
  10431. e._ExtractOperation = function(e) {
  10432. var t = /defined\((.+)\)/.exec(e);
  10433. if (t && t.length)
  10434. return new bt(t[1].trim(),"!" === e[0]);
  10435. for (var i = "", n = 0, r = 0, o = ["==", ">=", "<=", "<", ">"]; r < o.length && (i = o[r],
  10436. !((n = e.indexOf(i)) > -1)); r++)
  10437. ;
  10438. if (-1 === n)
  10439. return new bt(e);
  10440. var a = e.substring(0, n).trim()
  10441. , s = e.substring(n + i.length).trim();
  10442. return new St(a,i,s)
  10443. }
  10444. ,
  10445. e._BuildSubExpression = function(e) {
  10446. e = e.replace(xt, "defined[$1]");
  10447. for (var t = [], i = 0, n = yt.infixToPostfix(e); i < n.length; i++) {
  10448. var r = n[i];
  10449. if ("||" !== r && "&&" !== r)
  10450. t.push(r);
  10451. else if (t.length >= 2) {
  10452. var o = t[t.length - 1]
  10453. , a = t[t.length - 2];
  10454. t.length -= 2;
  10455. var s = "&&" == r ? new Et : new Tt;
  10456. "string" == typeof o && (o = o.replace(Rt, "defined($1)")),
  10457. "string" == typeof a && (a = a.replace(Rt, "defined($1)")),
  10458. s.leftOperand = "string" == typeof a ? this._ExtractOperation(a) : a,
  10459. s.rightOperand = "string" == typeof o ? this._ExtractOperation(o) : o,
  10460. t.push(s)
  10461. }
  10462. }
  10463. var l = t[t.length - 1];
  10464. return "string" == typeof l && (l = l.replace(Rt, "defined($1)")),
  10465. "string" == typeof l ? this._ExtractOperation(l) : l
  10466. }
  10467. ,
  10468. e._BuildExpression = function(e, t) {
  10469. var i = new vt
  10470. , n = e.substring(0, t)
  10471. , r = e.substring(t);
  10472. return r = r.substring(0, (r.indexOf("//") + 1 || r.length + 1) - 1).trim(),
  10473. i.testExpression = "#ifdef" === n ? new bt(r) : "#ifndef" === n ? new bt(r,!0) : this._BuildSubExpression(r),
  10474. i
  10475. }
  10476. ,
  10477. e._MoveCursorWithinIf = function(e, t, i) {
  10478. for (var n = e.currentLine; this._MoveCursor(e, i); ) {
  10479. var r = (n = e.currentLine).substring(0, 5).toLowerCase();
  10480. if ("#else" === r) {
  10481. var o = new _t;
  10482. return t.children.push(o),
  10483. void this._MoveCursor(e, o)
  10484. }
  10485. if ("#elif" === r) {
  10486. var a = this._BuildExpression(n, 5);
  10487. t.children.push(a),
  10488. i = a
  10489. }
  10490. }
  10491. }
  10492. ,
  10493. e._MoveCursor = function(e, t) {
  10494. for (; e.canRead; ) {
  10495. e.lineIndex++;
  10496. var i = e.currentLine
  10497. , n = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);
  10498. if (n && n.length)
  10499. switch (n[0]) {
  10500. case "#ifdef":
  10501. var r = new gt;
  10502. t.children.push(r);
  10503. var o = this._BuildExpression(i, 6);
  10504. r.children.push(o),
  10505. this._MoveCursorWithinIf(e, r, o);
  10506. break;
  10507. case "#else":
  10508. case "#elif":
  10509. return !0;
  10510. case "#endif":
  10511. return !1;
  10512. case "#ifndef":
  10513. r = new gt,
  10514. t.children.push(r),
  10515. o = this._BuildExpression(i, 7),
  10516. r.children.push(o),
  10517. this._MoveCursorWithinIf(e, r, o);
  10518. break;
  10519. case "#if":
  10520. r = new gt,
  10521. o = this._BuildExpression(i, 3),
  10522. t.children.push(r),
  10523. r.children.push(o),
  10524. this._MoveCursorWithinIf(e, r, o)
  10525. }
  10526. else {
  10527. var a = new _t;
  10528. if (a.line = i,
  10529. t.children.push(a),
  10530. "#" === i[0] && "d" === i[1]) {
  10531. var s = i.replace(";", "").split(" ");
  10532. a.additionalDefineKey = s[1],
  10533. 3 === s.length && (a.additionalDefineValue = s[2])
  10534. }
  10535. }
  10536. }
  10537. return !1
  10538. }
  10539. ,
  10540. e._EvaluatePreProcessors = function(e, t, i) {
  10541. var n = new _t
  10542. , r = new mt;
  10543. return r.lineIndex = -1,
  10544. r.lines = e.split("\n"),
  10545. this._MoveCursor(r, n),
  10546. n.process(t, i)
  10547. }
  10548. ,
  10549. e._PreparePreProcessors = function(e, t) {
  10550. for (var i, n = {}, r = 0, o = e.defines; r < o.length; r++) {
  10551. var a = o[r].replace("#define", "").replace(";", "").trim().split(" ");
  10552. n[a[0]] = a.length > 1 ? a[1] : ""
  10553. }
  10554. return (null === (i = e.processor) || void 0 === i ? void 0 : i.shaderLanguage) === st.GLSL && (n.GL_ES = "true"),
  10555. n.__VERSION__ = e.version,
  10556. n[e.platformName] = "true",
  10557. t._getGlobalDefines(n),
  10558. n
  10559. }
  10560. ,
  10561. e._ProcessShaderConversion = function(e, t, i) {
  10562. var n = this._ProcessPrecision(e, t);
  10563. if (!t.processor)
  10564. return n;
  10565. if (t.processor.shaderLanguage === st.GLSL && -1 !== n.indexOf("#version 3"))
  10566. return n.replace("#version 300 es", "");
  10567. var r = t.defines
  10568. , o = this._PreparePreProcessors(t, i);
  10569. return t.processor.preProcessor && (n = t.processor.preProcessor(n, r, t.isFragment, t.processingContext)),
  10570. n = this._EvaluatePreProcessors(n, o, t),
  10571. t.processor.postProcessor && (n = t.processor.postProcessor(n, r, t.isFragment, t.processingContext, i)),
  10572. i._features.needShaderCodeInlining && (n = i.inlineShaderCode(n)),
  10573. n
  10574. }
  10575. ,
  10576. e._ApplyPreProcessing = function(e, t, i) {
  10577. var n, r, o = e, a = t.defines, s = this._PreparePreProcessors(t, i);
  10578. return (null === (n = t.processor) || void 0 === n ? void 0 : n.preProcessor) && (o = t.processor.preProcessor(o, a, t.isFragment, t.processingContext)),
  10579. o = this._EvaluatePreProcessors(o, s, t),
  10580. (null === (r = t.processor) || void 0 === r ? void 0 : r.postProcessor) && (o = t.processor.postProcessor(o, a, t.isFragment, t.processingContext, i)),
  10581. i._features.needShaderCodeInlining && (o = i.inlineShaderCode(o)),
  10582. o
  10583. }
  10584. ,
  10585. e._ProcessIncludes = function(t, i, n) {
  10586. for (var r = this, o = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, a = o.exec(t), s = new String(t), l = !1, c = function() {
  10587. var c = a[1];
  10588. if (-1 !== c.indexOf("__decl__") && (c = c.replace(/__decl__/, ""),
  10589. i.supportsUniformBuffers && (c = (c = c.replace(/Vertex/, "Ubo")).replace(/Fragment/, "Ubo")),
  10590. c += "Declaration"),
  10591. !i.includesShadersStore[c]) {
  10592. var u = i.shadersRepository + "ShadersInclude/" + c + ".fx";
  10593. return e._FileToolsLoadFile(u, (function(e) {
  10594. i.includesShadersStore[c] = e,
  10595. r._ProcessIncludes(s, i, n)
  10596. }
  10597. )),
  10598. {
  10599. value: void 0
  10600. }
  10601. }
  10602. var h = i.includesShadersStore[c];
  10603. if (a[2])
  10604. for (var d = a[3].split(","), p = 0; p < d.length; p += 2) {
  10605. var f = new RegExp(d[p],"g")
  10606. , _ = d[p + 1];
  10607. h = h.replace(f, _)
  10608. }
  10609. if (a[4]) {
  10610. var m = a[5];
  10611. if (-1 !== m.indexOf("..")) {
  10612. var g = m.split("..")
  10613. , v = parseInt(g[0])
  10614. , y = parseInt(g[1])
  10615. , b = h.slice(0);
  10616. h = "",
  10617. isNaN(y) && (y = i.indexParameters[g[1]]);
  10618. for (var T = v; T < y; T++)
  10619. i.supportsUniformBuffers || (b = b.replace(/light\{X\}.(\w*)/g, (function(e, t) {
  10620. return t + "{X}"
  10621. }
  10622. ))),
  10623. h += b.replace(/\{X\}/g, T.toString()) + "\n"
  10624. } else
  10625. i.supportsUniformBuffers || (h = h.replace(/light\{X\}.(\w*)/g, (function(e, t) {
  10626. return t + "{X}"
  10627. }
  10628. ))),
  10629. h = h.replace(/\{X\}/g, m)
  10630. }
  10631. s = s.replace(a[0], h),
  10632. l = l || h.indexOf("#include<") >= 0 || h.indexOf("#include <") >= 0,
  10633. a = o.exec(t)
  10634. }; null != a; ) {
  10635. var u = c();
  10636. if ("object" == typeof u)
  10637. return u.value
  10638. }
  10639. l ? this._ProcessIncludes(s.toString(), i, n) : n(s)
  10640. }
  10641. ,
  10642. e._FileToolsLoadFile = function(e, t, i, n, r, o) {
  10643. throw be("FileTools")
  10644. }
  10645. ,
  10646. e
  10647. }(), Pt = function() {
  10648. function e() {}
  10649. return e.GetShadersRepository = function(t) {
  10650. return void 0 === t && (t = st.GLSL),
  10651. t === st.GLSL ? e.ShadersRepository : e.ShadersRepositoryWGSL
  10652. }
  10653. ,
  10654. e.GetShadersStore = function(t) {
  10655. return void 0 === t && (t = st.GLSL),
  10656. t === st.GLSL ? e.ShadersStore : e.ShadersStoreWGSL
  10657. }
  10658. ,
  10659. e.GetIncludesShadersStore = function(t) {
  10660. return void 0 === t && (t = st.GLSL),
  10661. t === st.GLSL ? e.IncludesShadersStore : e.IncludesShadersStoreWGSL
  10662. }
  10663. ,
  10664. e.ShadersRepository = "src/Shaders/",
  10665. e.ShadersStore = {},
  10666. e.IncludesShadersStore = {},
  10667. e.ShadersRepositoryWGSL = "src/ShadersWGSL/",
  10668. e.ShadersStoreWGSL = {},
  10669. e.IncludesShadersStoreWGSL = {},
  10670. e
  10671. }(), Mt = function() {
  10672. function e(t, i, n, r, o, a, s, l, c, u, d, p) {
  10673. void 0 === r && (r = null),
  10674. void 0 === a && (a = null),
  10675. void 0 === s && (s = null),
  10676. void 0 === l && (l = null),
  10677. void 0 === c && (c = null),
  10678. void 0 === d && (d = ""),
  10679. void 0 === p && (p = st.GLSL);
  10680. var f, _, m, g = this;
  10681. this.name = null,
  10682. this.defines = "",
  10683. this.onCompiled = null,
  10684. this.onError = null,
  10685. this.onBind = null,
  10686. this.uniqueId = 0,
  10687. this.onCompileObservable = new h,
  10688. this.onErrorObservable = new h,
  10689. this._onBindObservable = null,
  10690. this._wasPreviouslyReady = !1,
  10691. this._bonesComputationForcedToCPU = !1,
  10692. this._uniformBuffersNames = {},
  10693. this._multiTarget = !1,
  10694. this._samplers = {},
  10695. this._isReady = !1,
  10696. this._compilationError = "",
  10697. this._allFallbacksProcessed = !1,
  10698. this._uniforms = {},
  10699. this._key = "",
  10700. this._fallbacks = null,
  10701. this._vertexSourceCodeOverride = "",
  10702. this._fragmentSourceCodeOverride = "",
  10703. this._transformFeedbackVaryings = null,
  10704. this._pipelineContext = null,
  10705. this._vertexSourceCode = "",
  10706. this._fragmentSourceCode = "",
  10707. this._rawVertexSourceCode = "",
  10708. this._rawFragmentSourceCode = "",
  10709. this.name = t,
  10710. this._key = d;
  10711. var v, y, b = void 0, T = null;
  10712. if (i.attributes) {
  10713. var E = i;
  10714. if (this._engine = n,
  10715. this._attributesNames = E.attributes,
  10716. this._uniformsNames = E.uniformsNames.concat(E.samplers),
  10717. this._samplerList = E.samplers.slice(),
  10718. this.defines = E.defines,
  10719. this.onError = E.onError,
  10720. this.onCompiled = E.onCompiled,
  10721. this._fallbacks = E.fallbacks,
  10722. this._indexParameters = E.indexParameters,
  10723. this._transformFeedbackVaryings = E.transformFeedbackVaryings || null,
  10724. this._multiTarget = !!E.multiTarget,
  10725. this._shaderLanguage = null !== (f = E.shaderLanguage) && void 0 !== f ? f : st.GLSL,
  10726. E.uniformBuffersNames) {
  10727. this._uniformBuffersNamesList = E.uniformBuffersNames.slice();
  10728. for (var S = 0; S < E.uniformBuffersNames.length; S++)
  10729. this._uniformBuffersNames[E.uniformBuffersNames[S]] = S
  10730. }
  10731. T = null !== (_ = E.processFinalCode) && void 0 !== _ ? _ : null,
  10732. b = null !== (m = E.processCodeAfterIncludes) && void 0 !== m ? m : void 0
  10733. } else
  10734. this._engine = o,
  10735. this.defines = null == a ? "" : a,
  10736. this._uniformsNames = n.concat(r),
  10737. this._samplerList = r ? r.slice() : [],
  10738. this._attributesNames = i,
  10739. this._uniformBuffersNamesList = [],
  10740. this._shaderLanguage = p,
  10741. this.onError = c,
  10742. this.onCompiled = l,
  10743. this._indexParameters = u,
  10744. this._fallbacks = s;
  10745. this._attributeLocationByName = {},
  10746. this.uniqueId = e._UniqueIdSeed++;
  10747. var A = nt() ? this._engine.getHostDocument() : null;
  10748. t.vertexSource ? v = "source:" + t.vertexSource : t.vertexElement ? (v = A ? A.getElementById(t.vertexElement) : null) || (v = t.vertexElement) : v = t.vertex || t,
  10749. t.fragmentSource ? y = "source:" + t.fragmentSource : t.fragmentElement ? (y = A ? A.getElementById(t.fragmentElement) : null) || (y = t.fragmentElement) : y = t.fragment || t,
  10750. this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
  10751. var x = {
  10752. defines: this.defines.split("\n"),
  10753. indexParameters: this._indexParameters,
  10754. isFragment: !1,
  10755. shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
  10756. processor: this._engine._getShaderProcessor(this._shaderLanguage),
  10757. supportsUniformBuffers: this._engine.supportsUniformBuffers,
  10758. shadersRepository: Pt.GetShadersRepository(this._shaderLanguage),
  10759. includesShadersStore: Pt.GetIncludesShadersStore(this._shaderLanguage),
  10760. version: (100 * this._engine.version).toString(),
  10761. platformName: this._engine.shaderPlatformName,
  10762. processingContext: this._processingContext,
  10763. isNDCHalfZRange: this._engine.isNDCHalfZRange,
  10764. useReverseDepthBuffer: this._engine.useReverseDepthBuffer,
  10765. processCodeAfterIncludes: b
  10766. }
  10767. , R = [void 0, void 0]
  10768. , C = function() {
  10769. if (R[0] && R[1]) {
  10770. x.isFragment = !0;
  10771. var e = R[0]
  10772. , i = R[1];
  10773. Ct.Process(i, x, (function(i) {
  10774. T && (i = T("fragment", i));
  10775. var n = Ct.Finalize(e, i, x);
  10776. g._useFinalCode(n.vertexCode, n.fragmentCode, t)
  10777. }
  10778. ), g._engine)
  10779. }
  10780. };
  10781. this._loadShader(v, "Vertex", "", (function(e) {
  10782. Ct.Initialize(x),
  10783. Ct.Process(e, x, (function(t) {
  10784. g._rawVertexSourceCode = e,
  10785. T && (t = T("vertex", t)),
  10786. R[0] = t,
  10787. C()
  10788. }
  10789. ), g._engine)
  10790. }
  10791. )),
  10792. this._loadShader(y, "Fragment", "Pixel", (function(e) {
  10793. g._rawFragmentSourceCode = e,
  10794. R[1] = e,
  10795. C()
  10796. }
  10797. ))
  10798. }
  10799. return Object.defineProperty(e, "ShadersRepository", {
  10800. get: function() {
  10801. return Pt.ShadersRepository
  10802. },
  10803. set: function(e) {
  10804. Pt.ShadersRepository = e
  10805. },
  10806. enumerable: !1,
  10807. configurable: !0
  10808. }),
  10809. Object.defineProperty(e.prototype, "onBindObservable", {
  10810. get: function() {
  10811. return this._onBindObservable || (this._onBindObservable = new h),
  10812. this._onBindObservable
  10813. },
  10814. enumerable: !1,
  10815. configurable: !0
  10816. }),
  10817. e.prototype._useFinalCode = function(e, t, i) {
  10818. if (i) {
  10819. var n = i.vertexElement || i.vertex || i.spectorName || i
  10820. , r = i.fragmentElement || i.fragment || i.spectorName || i;
  10821. this._vertexSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + n + "\n" + e,
  10822. this._fragmentSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + r + "\n" + t
  10823. } else
  10824. this._vertexSourceCode = e,
  10825. this._fragmentSourceCode = t;
  10826. this._prepareEffect()
  10827. }
  10828. ,
  10829. Object.defineProperty(e.prototype, "key", {
  10830. get: function() {
  10831. return this._key
  10832. },
  10833. enumerable: !1,
  10834. configurable: !0
  10835. }),
  10836. e.prototype.isReady = function() {
  10837. try {
  10838. return this._isReadyInternal()
  10839. } catch (e) {
  10840. return !1
  10841. }
  10842. }
  10843. ,
  10844. e.prototype._isReadyInternal = function() {
  10845. return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady
  10846. }
  10847. ,
  10848. e.prototype.getEngine = function() {
  10849. return this._engine
  10850. }
  10851. ,
  10852. e.prototype.getPipelineContext = function() {
  10853. return this._pipelineContext
  10854. }
  10855. ,
  10856. e.prototype.getAttributesNames = function() {
  10857. return this._attributesNames
  10858. }
  10859. ,
  10860. e.prototype.getAttributeLocation = function(e) {
  10861. return this._attributes[e]
  10862. }
  10863. ,
  10864. e.prototype.getAttributeLocationByName = function(e) {
  10865. return this._attributeLocationByName[e]
  10866. }
  10867. ,
  10868. e.prototype.getAttributesCount = function() {
  10869. return this._attributes.length
  10870. }
  10871. ,
  10872. e.prototype.getUniformIndex = function(e) {
  10873. return this._uniformsNames.indexOf(e)
  10874. }
  10875. ,
  10876. e.prototype.getUniform = function(e) {
  10877. return this._uniforms[e]
  10878. }
  10879. ,
  10880. e.prototype.getSamplers = function() {
  10881. return this._samplerList
  10882. }
  10883. ,
  10884. e.prototype.getUniformNames = function() {
  10885. return this._uniformsNames
  10886. }
  10887. ,
  10888. e.prototype.getUniformBuffersNames = function() {
  10889. return this._uniformBuffersNamesList
  10890. }
  10891. ,
  10892. e.prototype.getIndexParameters = function() {
  10893. return this._indexParameters
  10894. }
  10895. ,
  10896. e.prototype.getCompilationError = function() {
  10897. return this._compilationError
  10898. }
  10899. ,
  10900. e.prototype.allFallbacksProcessed = function() {
  10901. return this._allFallbacksProcessed
  10902. }
  10903. ,
  10904. e.prototype.executeWhenCompiled = function(e) {
  10905. var t = this;
  10906. this.isReady() ? e(this) : (this.onCompileObservable.add((function(t) {
  10907. e(t)
  10908. }
  10909. )),
  10910. this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function() {
  10911. t._checkIsReady(null)
  10912. }
  10913. ), 16))
  10914. }
  10915. ,
  10916. e.prototype._checkIsReady = function(e) {
  10917. var t = this;
  10918. try {
  10919. if (this._isReadyInternal())
  10920. return
  10921. } catch (t) {
  10922. return void this._processCompilationErrors(t, e)
  10923. }
  10924. setTimeout((function() {
  10925. t._checkIsReady(e)
  10926. }
  10927. ), 16)
  10928. }
  10929. ,
  10930. e.prototype._loadShader = function(e, t, i, n) {
  10931. if ("undefined" != typeof HTMLElement && e instanceof HTMLElement)
  10932. n(at(e));
  10933. else if ("source:" !== e.substr(0, 7))
  10934. if ("base64:" !== e.substr(0, 7)) {
  10935. var r, o = Pt.GetShadersStore(this._shaderLanguage);
  10936. o[e + t + "Shader"] ? n(o[e + t + "Shader"]) : i && o[e + i + "Shader"] ? n(o[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : Pt.GetShadersRepository(this._shaderLanguage) + e,
  10937. this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n))
  10938. } else
  10939. n(window.atob(e.substr(7)));
  10940. else
  10941. n(e.substr(7))
  10942. }
  10943. ,
  10944. Object.defineProperty(e.prototype, "vertexSourceCode", {
  10945. get: function() {
  10946. var e, t;
  10947. return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getVertexShaderCode()) && void 0 !== t ? t : this._vertexSourceCode
  10948. },
  10949. enumerable: !1,
  10950. configurable: !0
  10951. }),
  10952. Object.defineProperty(e.prototype, "fragmentSourceCode", {
  10953. get: function() {
  10954. var e, t;
  10955. return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getFragmentShaderCode()) && void 0 !== t ? t : this._fragmentSourceCode
  10956. },
  10957. enumerable: !1,
  10958. configurable: !0
  10959. }),
  10960. Object.defineProperty(e.prototype, "rawVertexSourceCode", {
  10961. get: function() {
  10962. return this._rawVertexSourceCode
  10963. },
  10964. enumerable: !1,
  10965. configurable: !0
  10966. }),
  10967. Object.defineProperty(e.prototype, "rawFragmentSourceCode", {
  10968. get: function() {
  10969. return this._rawFragmentSourceCode
  10970. },
  10971. enumerable: !1,
  10972. configurable: !0
  10973. }),
  10974. e.prototype._rebuildProgram = function(e, t, i, n) {
  10975. var r = this;
  10976. this._isReady = !1,
  10977. this._vertexSourceCodeOverride = e,
  10978. this._fragmentSourceCodeOverride = t,
  10979. this.onError = function(e, t) {
  10980. n && n(t)
  10981. }
  10982. ,
  10983. this.onCompiled = function() {
  10984. var e = r.getEngine().scenes;
  10985. if (e)
  10986. for (var t = 0; t < e.length; t++)
  10987. e[t].markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag);
  10988. r._pipelineContext._handlesSpectorRebuildCallback(i)
  10989. }
  10990. ,
  10991. this._fallbacks = null,
  10992. this._prepareEffect()
  10993. }
  10994. ,
  10995. e.prototype._prepareEffect = function() {
  10996. var e = this
  10997. , t = this._attributesNames
  10998. , i = this.defines
  10999. , n = this._pipelineContext;
  11000. this._isReady = !1;
  11001. try {
  11002. var r = this._engine;
  11003. this._pipelineContext = r.createPipelineContext(this._processingContext),
  11004. this._pipelineContext._name = this._key;
  11005. var o = this._rebuildProgram.bind(this);
  11006. this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? r._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, null, this._transformFeedbackVaryings, this._key) : r._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, i, this._transformFeedbackVaryings, this._key),
  11007. r._executeWhenRenderingStateIsCompiled(this._pipelineContext, (function() {
  11008. if (e._attributes = [],
  11009. e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, t, e._attributes),
  11010. t)
  11011. for (var i = 0; i < t.length; i++) {
  11012. var o = t[i];
  11013. e._attributeLocationByName[o] = e._attributes[i]
  11014. }
  11015. r.bindSamplers(e),
  11016. e._compilationError = "",
  11017. e._isReady = !0,
  11018. e.onCompiled && e.onCompiled(e),
  11019. e.onCompileObservable.notifyObservers(e),
  11020. e.onCompileObservable.clear(),
  11021. e._fallbacks && e._fallbacks.unBindMesh(),
  11022. n && e.getEngine()._deletePipelineContext(n)
  11023. }
  11024. )),
  11025. this._pipelineContext.isAsync && this._checkIsReady(n)
  11026. } catch (e) {
  11027. this._processCompilationErrors(e, n)
  11028. }
  11029. }
  11030. ,
  11031. e.prototype._getShaderCodeAndErrorLine = function(e, t, i) {
  11032. var n = i ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
  11033. , r = null;
  11034. if (t && e) {
  11035. var o = t.match(n);
  11036. if (o && 2 === o.length) {
  11037. var a = parseInt(o[1])
  11038. , s = e.split("\n", -1);
  11039. s.length >= a && (r = "Offending line [".concat(a, "] in ").concat(i ? "fragment" : "vertex", " code: ").concat(s[a - 1]))
  11040. }
  11041. }
  11042. return [e, r]
  11043. }
  11044. ,
  11045. e.prototype._processCompilationErrors = function(t, i) {
  11046. var n, r, o, a, s;
  11047. void 0 === i && (i = null),
  11048. this._compilationError = t.message;
  11049. var l = this._attributesNames
  11050. , c = this._fallbacks;
  11051. if (K.Error("Unable to compile effect:"),
  11052. K.Error("Uniforms: " + this._uniformsNames.map((function(e) {
  11053. return " " + e
  11054. }
  11055. ))),
  11056. K.Error("Attributes: " + l.map((function(e) {
  11057. return " " + e
  11058. }
  11059. ))),
  11060. K.Error("Defines:\r\n" + this.defines),
  11061. e.LogShaderCodeOnCompilationError) {
  11062. var u = null
  11063. , h = null
  11064. , d = null;
  11065. (null === (o = this._pipelineContext) || void 0 === o ? void 0 : o._getVertexShaderCode()) && (d = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1))[0],
  11066. u = n[1],
  11067. d && (K.Error("Vertex code:"),
  11068. K.Error(d))),
  11069. (null === (a = this._pipelineContext) || void 0 === a ? void 0 : a._getFragmentShaderCode()) && (d = (r = this._getShaderCodeAndErrorLine(null === (s = this._pipelineContext) || void 0 === s ? void 0 : s._getFragmentShaderCode(), this._compilationError, !0))[0],
  11070. h = r[1],
  11071. d && (K.Error("Fragment code:"),
  11072. K.Error(d))),
  11073. u && K.Error(u),
  11074. h && K.Error(h)
  11075. }
  11076. K.Error("Error: " + this._compilationError),
  11077. i && (this._pipelineContext = i,
  11078. this._isReady = !0,
  11079. this.onError && this.onError(this, this._compilationError),
  11080. this.onErrorObservable.notifyObservers(this)),
  11081. c ? (this._pipelineContext = null,
  11082. c.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
  11083. K.Error("Trying next fallback."),
  11084. this.defines = c.reduce(this.defines, this),
  11085. this._prepareEffect()) : (this._allFallbacksProcessed = !0,
  11086. this.onError && this.onError(this, this._compilationError),
  11087. this.onErrorObservable.notifyObservers(this),
  11088. this.onErrorObservable.clear(),
  11089. this._fallbacks && this._fallbacks.unBindMesh())) : this._allFallbacksProcessed = !0
  11090. }
  11091. ,
  11092. Object.defineProperty(e.prototype, "isSupported", {
  11093. get: function() {
  11094. return "" === this._compilationError
  11095. },
  11096. enumerable: !1,
  11097. configurable: !0
  11098. }),
  11099. e.prototype._bindTexture = function(e, t) {
  11100. this._engine._bindTexture(this._samplers[e], t, e)
  11101. }
  11102. ,
  11103. e.prototype.setTexture = function(e, t) {
  11104. this._engine.setTexture(this._samplers[e], this._uniforms[e], t, e)
  11105. }
  11106. ,
  11107. e.prototype.setDepthStencilTexture = function(e, t) {
  11108. this._engine.setDepthStencilTexture(this._samplers[e], this._uniforms[e], t, e)
  11109. }
  11110. ,
  11111. e.prototype.setTextureArray = function(e, t) {
  11112. var i = e + "Ex";
  11113. if (-1 === this._samplerList.indexOf(i + "0")) {
  11114. for (var n = this._samplerList.indexOf(e), r = 1; r < t.length; r++) {
  11115. var o = i + (r - 1).toString();
  11116. this._samplerList.splice(n + r, 0, o)
  11117. }
  11118. for (var a = 0, s = 0, l = this._samplerList; s < l.length; s++) {
  11119. var c = l[s];
  11120. this._samplers[c] = a,
  11121. a += 1
  11122. }
  11123. }
  11124. this._engine.setTextureArray(this._samplers[e], this._uniforms[e], t, e)
  11125. }
  11126. ,
  11127. e.prototype.setTextureFromPostProcess = function(e, t) {
  11128. this._engine.setTextureFromPostProcess(this._samplers[e], t, e)
  11129. }
  11130. ,
  11131. e.prototype.setTextureFromPostProcessOutput = function(e, t) {
  11132. this._engine.setTextureFromPostProcessOutput(this._samplers[e], t, e)
  11133. }
  11134. ,
  11135. e.prototype.bindUniformBuffer = function(t, i) {
  11136. var n = this._uniformBuffersNames[i];
  11137. void 0 === n || e._BaseCache[n] === t && this._engine._features.useUBOBindingCache || (e._BaseCache[n] = t,
  11138. this._engine.bindUniformBufferBase(t, n, i))
  11139. }
  11140. ,
  11141. e.prototype.bindUniformBlock = function(e, t) {
  11142. this._engine.bindUniformBlock(this._pipelineContext, e, t)
  11143. }
  11144. ,
  11145. e.prototype.setInt = function(e, t) {
  11146. return this._pipelineContext.setInt(e, t),
  11147. this
  11148. }
  11149. ,
  11150. e.prototype.setInt2 = function(e, t, i) {
  11151. return this._pipelineContext.setInt2(e, t, i),
  11152. this
  11153. }
  11154. ,
  11155. e.prototype.setInt3 = function(e, t, i, n) {
  11156. return this._pipelineContext.setInt3(e, t, i, n),
  11157. this
  11158. }
  11159. ,
  11160. e.prototype.setInt4 = function(e, t, i, n, r) {
  11161. return this._pipelineContext.setInt4(e, t, i, n, r),
  11162. this
  11163. }
  11164. ,
  11165. e.prototype.setIntArray = function(e, t) {
  11166. return this._pipelineContext.setIntArray(e, t),
  11167. this
  11168. }
  11169. ,
  11170. e.prototype.setIntArray2 = function(e, t) {
  11171. return this._pipelineContext.setIntArray2(e, t),
  11172. this
  11173. }
  11174. ,
  11175. e.prototype.setIntArray3 = function(e, t) {
  11176. return this._pipelineContext.setIntArray3(e, t),
  11177. this
  11178. }
  11179. ,
  11180. e.prototype.setIntArray4 = function(e, t) {
  11181. return this._pipelineContext.setIntArray4(e, t),
  11182. this
  11183. }
  11184. ,
  11185. e.prototype.setFloatArray = function(e, t) {
  11186. return this._pipelineContext.setArray(e, t),
  11187. this
  11188. }
  11189. ,
  11190. e.prototype.setFloatArray2 = function(e, t) {
  11191. return this._pipelineContext.setArray2(e, t),
  11192. this
  11193. }
  11194. ,
  11195. e.prototype.setFloatArray3 = function(e, t) {
  11196. return this._pipelineContext.setArray3(e, t),
  11197. this
  11198. }
  11199. ,
  11200. e.prototype.setFloatArray4 = function(e, t) {
  11201. return this._pipelineContext.setArray4(e, t),
  11202. this
  11203. }
  11204. ,
  11205. e.prototype.setArray = function(e, t) {
  11206. return this._pipelineContext.setArray(e, t),
  11207. this
  11208. }
  11209. ,
  11210. e.prototype.setArray2 = function(e, t) {
  11211. return this._pipelineContext.setArray2(e, t),
  11212. this
  11213. }
  11214. ,
  11215. e.prototype.setArray3 = function(e, t) {
  11216. return this._pipelineContext.setArray3(e, t),
  11217. this
  11218. }
  11219. ,
  11220. e.prototype.setArray4 = function(e, t) {
  11221. return this._pipelineContext.setArray4(e, t),
  11222. this
  11223. }
  11224. ,
  11225. e.prototype.setMatrices = function(e, t) {
  11226. return this._pipelineContext.setMatrices(e, t),
  11227. this
  11228. }
  11229. ,
  11230. e.prototype.setMatrix = function(e, t) {
  11231. return this._pipelineContext.setMatrix(e, t),
  11232. this
  11233. }
  11234. ,
  11235. e.prototype.setMatrix3x3 = function(e, t) {
  11236. return this._pipelineContext.setMatrix3x3(e, t),
  11237. this
  11238. }
  11239. ,
  11240. e.prototype.setMatrix2x2 = function(e, t) {
  11241. return this._pipelineContext.setMatrix2x2(e, t),
  11242. this
  11243. }
  11244. ,
  11245. e.prototype.setFloat = function(e, t) {
  11246. return this._pipelineContext.setFloat(e, t),
  11247. this
  11248. }
  11249. ,
  11250. e.prototype.setBool = function(e, t) {
  11251. return this._pipelineContext.setInt(e, t ? 1 : 0),
  11252. this
  11253. }
  11254. ,
  11255. e.prototype.setVector2 = function(e, t) {
  11256. return this._pipelineContext.setVector2(e, t),
  11257. this
  11258. }
  11259. ,
  11260. e.prototype.setFloat2 = function(e, t, i) {
  11261. return this._pipelineContext.setFloat2(e, t, i),
  11262. this
  11263. }
  11264. ,
  11265. e.prototype.setVector3 = function(e, t) {
  11266. return this._pipelineContext.setVector3(e, t),
  11267. this
  11268. }
  11269. ,
  11270. e.prototype.setFloat3 = function(e, t, i, n) {
  11271. return this._pipelineContext.setFloat3(e, t, i, n),
  11272. this
  11273. }
  11274. ,
  11275. e.prototype.setVector4 = function(e, t) {
  11276. return this._pipelineContext.setVector4(e, t),
  11277. this
  11278. }
  11279. ,
  11280. e.prototype.setFloat4 = function(e, t, i, n, r) {
  11281. return this._pipelineContext.setFloat4(e, t, i, n, r),
  11282. this
  11283. }
  11284. ,
  11285. e.prototype.setColor3 = function(e, t) {
  11286. return this._pipelineContext.setColor3(e, t),
  11287. this
  11288. }
  11289. ,
  11290. e.prototype.setColor4 = function(e, t, i) {
  11291. return this._pipelineContext.setColor4(e, t, i),
  11292. this
  11293. }
  11294. ,
  11295. e.prototype.setDirectColor4 = function(e, t) {
  11296. return this._pipelineContext.setDirectColor4(e, t),
  11297. this
  11298. }
  11299. ,
  11300. e.prototype.dispose = function() {
  11301. this._pipelineContext && this._pipelineContext.dispose(),
  11302. this._engine._releaseEffect(this)
  11303. }
  11304. ,
  11305. e.RegisterShader = function(e, t, i, n) {
  11306. void 0 === n && (n = st.GLSL),
  11307. t && (Pt.GetShadersStore(n)["".concat(e, "PixelShader")] = t),
  11308. i && (Pt.GetShadersStore(n)["".concat(e, "VertexShader")] = i)
  11309. }
  11310. ,
  11311. e.ResetCache = function() {
  11312. e._BaseCache = {}
  11313. }
  11314. ,
  11315. e.LogShaderCodeOnCompilationError = !0,
  11316. e._UniqueIdSeed = 0,
  11317. e._BaseCache = {},
  11318. e.ShadersStore = Pt.ShadersStore,
  11319. e.IncludesShadersStore = Pt.IncludesShadersStore,
  11320. e
  11321. }(), It = function() {
  11322. function e(e) {
  11323. void 0 === e && (e = !0),
  11324. this._isDepthTestDirty = !1,
  11325. this._isDepthMaskDirty = !1,
  11326. this._isDepthFuncDirty = !1,
  11327. this._isCullFaceDirty = !1,
  11328. this._isCullDirty = !1,
  11329. this._isZOffsetDirty = !1,
  11330. this._isFrontFaceDirty = !1,
  11331. e && this.reset()
  11332. }
  11333. return Object.defineProperty(e.prototype, "isDirty", {
  11334. get: function() {
  11335. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty
  11336. },
  11337. enumerable: !1,
  11338. configurable: !0
  11339. }),
  11340. Object.defineProperty(e.prototype, "zOffset", {
  11341. get: function() {
  11342. return this._zOffset
  11343. },
  11344. set: function(e) {
  11345. this._zOffset !== e && (this._zOffset = e,
  11346. this._isZOffsetDirty = !0)
  11347. },
  11348. enumerable: !1,
  11349. configurable: !0
  11350. }),
  11351. Object.defineProperty(e.prototype, "zOffsetUnits", {
  11352. get: function() {
  11353. return this._zOffsetUnits
  11354. },
  11355. set: function(e) {
  11356. this._zOffsetUnits !== e && (this._zOffsetUnits = e,
  11357. this._isZOffsetDirty = !0)
  11358. },
  11359. enumerable: !1,
  11360. configurable: !0
  11361. }),
  11362. Object.defineProperty(e.prototype, "cullFace", {
  11363. get: function() {
  11364. return this._cullFace
  11365. },
  11366. set: function(e) {
  11367. this._cullFace !== e && (this._cullFace = e,
  11368. this._isCullFaceDirty = !0)
  11369. },
  11370. enumerable: !1,
  11371. configurable: !0
  11372. }),
  11373. Object.defineProperty(e.prototype, "cull", {
  11374. get: function() {
  11375. return this._cull
  11376. },
  11377. set: function(e) {
  11378. this._cull !== e && (this._cull = e,
  11379. this._isCullDirty = !0)
  11380. },
  11381. enumerable: !1,
  11382. configurable: !0
  11383. }),
  11384. Object.defineProperty(e.prototype, "depthFunc", {
  11385. get: function() {
  11386. return this._depthFunc
  11387. },
  11388. set: function(e) {
  11389. this._depthFunc !== e && (this._depthFunc = e,
  11390. this._isDepthFuncDirty = !0)
  11391. },
  11392. enumerable: !1,
  11393. configurable: !0
  11394. }),
  11395. Object.defineProperty(e.prototype, "depthMask", {
  11396. get: function() {
  11397. return this._depthMask
  11398. },
  11399. set: function(e) {
  11400. this._depthMask !== e && (this._depthMask = e,
  11401. this._isDepthMaskDirty = !0)
  11402. },
  11403. enumerable: !1,
  11404. configurable: !0
  11405. }),
  11406. Object.defineProperty(e.prototype, "depthTest", {
  11407. get: function() {
  11408. return this._depthTest
  11409. },
  11410. set: function(e) {
  11411. this._depthTest !== e && (this._depthTest = e,
  11412. this._isDepthTestDirty = !0)
  11413. },
  11414. enumerable: !1,
  11415. configurable: !0
  11416. }),
  11417. Object.defineProperty(e.prototype, "frontFace", {
  11418. get: function() {
  11419. return this._frontFace
  11420. },
  11421. set: function(e) {
  11422. this._frontFace !== e && (this._frontFace = e,
  11423. this._isFrontFaceDirty = !0)
  11424. },
  11425. enumerable: !1,
  11426. configurable: !0
  11427. }),
  11428. e.prototype.reset = function() {
  11429. this._depthMask = !0,
  11430. this._depthTest = !0,
  11431. this._depthFunc = null,
  11432. this._cullFace = null,
  11433. this._cull = null,
  11434. this._zOffset = 0,
  11435. this._zOffsetUnits = 0,
  11436. this._frontFace = null,
  11437. this._isDepthTestDirty = !0,
  11438. this._isDepthMaskDirty = !0,
  11439. this._isDepthFuncDirty = !1,
  11440. this._isCullFaceDirty = !1,
  11441. this._isCullDirty = !1,
  11442. this._isZOffsetDirty = !0,
  11443. this._isFrontFaceDirty = !1
  11444. }
  11445. ,
  11446. e.prototype.apply = function(e) {
  11447. this.isDirty && (this._isCullDirty && (this.cull ? e.enable(e.CULL_FACE) : e.disable(e.CULL_FACE),
  11448. this._isCullDirty = !1),
  11449. this._isCullFaceDirty && (e.cullFace(this.cullFace),
  11450. this._isCullFaceDirty = !1),
  11451. this._isDepthMaskDirty && (e.depthMask(this.depthMask),
  11452. this._isDepthMaskDirty = !1),
  11453. this._isDepthTestDirty && (this.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST),
  11454. this._isDepthTestDirty = !1),
  11455. this._isDepthFuncDirty && (e.depthFunc(this.depthFunc),
  11456. this._isDepthFuncDirty = !1),
  11457. this._isZOffsetDirty && (this.zOffset || this.zOffsetUnits ? (e.enable(e.POLYGON_OFFSET_FILL),
  11458. e.polygonOffset(this.zOffset, this.zOffsetUnits)) : e.disable(e.POLYGON_OFFSET_FILL),
  11459. this._isZOffsetDirty = !1),
  11460. this._isFrontFaceDirty && (e.frontFace(this.frontFace),
  11461. this._isFrontFaceDirty = !1))
  11462. }
  11463. ,
  11464. e
  11465. }(), Ot = function() {
  11466. function e() {
  11467. this.reset()
  11468. }
  11469. return e.prototype.reset = function() {
  11470. this.enabled = !1,
  11471. this.mask = 255,
  11472. this.func = e.ALWAYS,
  11473. this.funcRef = 1,
  11474. this.funcMask = 255,
  11475. this.opStencilFail = e.KEEP,
  11476. this.opDepthFail = e.KEEP,
  11477. this.opStencilDepthPass = e.REPLACE
  11478. }
  11479. ,
  11480. Object.defineProperty(e.prototype, "stencilFunc", {
  11481. get: function() {
  11482. return this.func
  11483. },
  11484. set: function(e) {
  11485. this.func = e
  11486. },
  11487. enumerable: !1,
  11488. configurable: !0
  11489. }),
  11490. Object.defineProperty(e.prototype, "stencilFuncRef", {
  11491. get: function() {
  11492. return this.funcRef
  11493. },
  11494. set: function(e) {
  11495. this.funcRef = e
  11496. },
  11497. enumerable: !1,
  11498. configurable: !0
  11499. }),
  11500. Object.defineProperty(e.prototype, "stencilFuncMask", {
  11501. get: function() {
  11502. return this.funcMask
  11503. },
  11504. set: function(e) {
  11505. this.funcMask = e
  11506. },
  11507. enumerable: !1,
  11508. configurable: !0
  11509. }),
  11510. Object.defineProperty(e.prototype, "stencilOpStencilFail", {
  11511. get: function() {
  11512. return this.opStencilFail
  11513. },
  11514. set: function(e) {
  11515. this.opStencilFail = e
  11516. },
  11517. enumerable: !1,
  11518. configurable: !0
  11519. }),
  11520. Object.defineProperty(e.prototype, "stencilOpDepthFail", {
  11521. get: function() {
  11522. return this.opDepthFail
  11523. },
  11524. set: function(e) {
  11525. this.opDepthFail = e
  11526. },
  11527. enumerable: !1,
  11528. configurable: !0
  11529. }),
  11530. Object.defineProperty(e.prototype, "stencilOpStencilDepthPass", {
  11531. get: function() {
  11532. return this.opStencilDepthPass
  11533. },
  11534. set: function(e) {
  11535. this.opStencilDepthPass = e
  11536. },
  11537. enumerable: !1,
  11538. configurable: !0
  11539. }),
  11540. Object.defineProperty(e.prototype, "stencilMask", {
  11541. get: function() {
  11542. return this.mask
  11543. },
  11544. set: function(e) {
  11545. this.mask = e
  11546. },
  11547. enumerable: !1,
  11548. configurable: !0
  11549. }),
  11550. Object.defineProperty(e.prototype, "stencilTest", {
  11551. get: function() {
  11552. return this.enabled
  11553. },
  11554. set: function(e) {
  11555. this.enabled = e
  11556. },
  11557. enumerable: !1,
  11558. configurable: !0
  11559. }),
  11560. e.ALWAYS = a.ALWAYS,
  11561. e.KEEP = a.KEEP,
  11562. e.REPLACE = a.REPLACE,
  11563. e
  11564. }(), Dt = function() {
  11565. function e() {
  11566. this._blendFunctionParameters = new Array(4),
  11567. this._blendEquationParameters = new Array(2),
  11568. this._blendConstants = new Array(4),
  11569. this._isBlendConstantsDirty = !1,
  11570. this._alphaBlend = !1,
  11571. this._isAlphaBlendDirty = !1,
  11572. this._isBlendFunctionParametersDirty = !1,
  11573. this._isBlendEquationParametersDirty = !1,
  11574. this.reset()
  11575. }
  11576. return Object.defineProperty(e.prototype, "isDirty", {
  11577. get: function() {
  11578. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty
  11579. },
  11580. enumerable: !1,
  11581. configurable: !0
  11582. }),
  11583. Object.defineProperty(e.prototype, "alphaBlend", {
  11584. get: function() {
  11585. return this._alphaBlend
  11586. },
  11587. set: function(e) {
  11588. this._alphaBlend !== e && (this._alphaBlend = e,
  11589. this._isAlphaBlendDirty = !0)
  11590. },
  11591. enumerable: !1,
  11592. configurable: !0
  11593. }),
  11594. e.prototype.setAlphaBlendConstants = function(e, t, i, n) {
  11595. this._blendConstants[0] === e && this._blendConstants[1] === t && this._blendConstants[2] === i && this._blendConstants[3] === n || (this._blendConstants[0] = e,
  11596. this._blendConstants[1] = t,
  11597. this._blendConstants[2] = i,
  11598. this._blendConstants[3] = n,
  11599. this._isBlendConstantsDirty = !0)
  11600. }
  11601. ,
  11602. e.prototype.setAlphaBlendFunctionParameters = function(e, t, i, n) {
  11603. this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === t && this._blendFunctionParameters[2] === i && this._blendFunctionParameters[3] === n || (this._blendFunctionParameters[0] = e,
  11604. this._blendFunctionParameters[1] = t,
  11605. this._blendFunctionParameters[2] = i,
  11606. this._blendFunctionParameters[3] = n,
  11607. this._isBlendFunctionParametersDirty = !0)
  11608. }
  11609. ,
  11610. e.prototype.setAlphaEquationParameters = function(e, t) {
  11611. this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === t || (this._blendEquationParameters[0] = e,
  11612. this._blendEquationParameters[1] = t,
  11613. this._isBlendEquationParametersDirty = !0)
  11614. }
  11615. ,
  11616. e.prototype.reset = function() {
  11617. this._alphaBlend = !1,
  11618. this._blendFunctionParameters[0] = null,
  11619. this._blendFunctionParameters[1] = null,
  11620. this._blendFunctionParameters[2] = null,
  11621. this._blendFunctionParameters[3] = null,
  11622. this._blendEquationParameters[0] = null,
  11623. this._blendEquationParameters[1] = null,
  11624. this._blendConstants[0] = null,
  11625. this._blendConstants[1] = null,
  11626. this._blendConstants[2] = null,
  11627. this._blendConstants[3] = null,
  11628. this._isAlphaBlendDirty = !0,
  11629. this._isBlendFunctionParametersDirty = !1,
  11630. this._isBlendEquationParametersDirty = !1,
  11631. this._isBlendConstantsDirty = !1
  11632. }
  11633. ,
  11634. e.prototype.apply = function(e) {
  11635. this.isDirty && (this._isAlphaBlendDirty && (this._alphaBlend ? e.enable(e.BLEND) : e.disable(e.BLEND),
  11636. this._isAlphaBlendDirty = !1),
  11637. this._isBlendFunctionParametersDirty && (e.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]),
  11638. this._isBlendFunctionParametersDirty = !1),
  11639. this._isBlendEquationParametersDirty && (e.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]),
  11640. this._isBlendEquationParametersDirty = !1),
  11641. this._isBlendConstantsDirty && (e.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]),
  11642. this._isBlendConstantsDirty = !1))
  11643. }
  11644. ,
  11645. e
  11646. }(), Nt = function() {
  11647. function e() {
  11648. this.samplingMode = -1,
  11649. this._useMipMaps = !0,
  11650. this._cachedWrapU = null,
  11651. this._cachedWrapV = null,
  11652. this._cachedWrapR = null,
  11653. this._cachedAnisotropicFilteringLevel = null,
  11654. this._comparisonFunction = 0
  11655. }
  11656. return Object.defineProperty(e.prototype, "wrapU", {
  11657. get: function() {
  11658. return this._cachedWrapU
  11659. },
  11660. set: function(e) {
  11661. this._cachedWrapU = e
  11662. },
  11663. enumerable: !1,
  11664. configurable: !0
  11665. }),
  11666. Object.defineProperty(e.prototype, "wrapV", {
  11667. get: function() {
  11668. return this._cachedWrapV
  11669. },
  11670. set: function(e) {
  11671. this._cachedWrapV = e
  11672. },
  11673. enumerable: !1,
  11674. configurable: !0
  11675. }),
  11676. Object.defineProperty(e.prototype, "wrapR", {
  11677. get: function() {
  11678. return this._cachedWrapR
  11679. },
  11680. set: function(e) {
  11681. this._cachedWrapR = e
  11682. },
  11683. enumerable: !1,
  11684. configurable: !0
  11685. }),
  11686. Object.defineProperty(e.prototype, "anisotropicFilteringLevel", {
  11687. get: function() {
  11688. return this._cachedAnisotropicFilteringLevel
  11689. },
  11690. set: function(e) {
  11691. this._cachedAnisotropicFilteringLevel = e
  11692. },
  11693. enumerable: !1,
  11694. configurable: !0
  11695. }),
  11696. Object.defineProperty(e.prototype, "comparisonFunction", {
  11697. get: function() {
  11698. return this._comparisonFunction
  11699. },
  11700. set: function(e) {
  11701. this._comparisonFunction = e
  11702. },
  11703. enumerable: !1,
  11704. configurable: !0
  11705. }),
  11706. Object.defineProperty(e.prototype, "useMipMaps", {
  11707. get: function() {
  11708. return this._useMipMaps
  11709. },
  11710. set: function(e) {
  11711. this._useMipMaps = e
  11712. },
  11713. enumerable: !1,
  11714. configurable: !0
  11715. }),
  11716. e.prototype.setParameters = function(e, t, i, n, r, o) {
  11717. return void 0 === e && (e = a.TEXTURE_WRAP_ADDRESSMODE),
  11718. void 0 === t && (t = a.TEXTURE_WRAP_ADDRESSMODE),
  11719. void 0 === i && (i = a.TEXTURE_WRAP_ADDRESSMODE),
  11720. void 0 === n && (n = 1),
  11721. void 0 === r && (r = a.TEXTURE_BILINEAR_SAMPLINGMODE),
  11722. void 0 === o && (o = 0),
  11723. this._cachedWrapU = e,
  11724. this._cachedWrapV = t,
  11725. this._cachedWrapR = i,
  11726. this._cachedAnisotropicFilteringLevel = n,
  11727. this.samplingMode = r,
  11728. this._comparisonFunction = o,
  11729. this
  11730. }
  11731. ,
  11732. e.prototype.compareSampler = function(e) {
  11733. return this._cachedWrapU === e._cachedWrapU && this._cachedWrapV === e._cachedWrapV && this._cachedWrapR === e._cachedWrapR && this._cachedAnisotropicFilteringLevel === e._cachedAnisotropicFilteringLevel && this.samplingMode === e.samplingMode && this._comparisonFunction === e._comparisonFunction && this._useMipMaps === e._useMipMaps
  11734. }
  11735. ,
  11736. e
  11737. }();
  11738. !function(e) {
  11739. e[e.Unknown = 0] = "Unknown",
  11740. e[e.Url = 1] = "Url",
  11741. e[e.Temp = 2] = "Temp",
  11742. e[e.Raw = 3] = "Raw",
  11743. e[e.Dynamic = 4] = "Dynamic",
  11744. e[e.RenderTarget = 5] = "RenderTarget",
  11745. e[e.MultiRenderTarget = 6] = "MultiRenderTarget",
  11746. e[e.Cube = 7] = "Cube",
  11747. e[e.CubeRaw = 8] = "CubeRaw",
  11748. e[e.CubePrefiltered = 9] = "CubePrefiltered",
  11749. e[e.Raw3D = 10] = "Raw3D",
  11750. e[e.Raw2DArray = 11] = "Raw2DArray",
  11751. e[e.DepthStencil = 12] = "DepthStencil",
  11752. e[e.CubeRawRGBD = 13] = "CubeRawRGBD",
  11753. e[e.Depth = 14] = "Depth"
  11754. }(At || (At = {}));
  11755. var Lt = function(e) {
  11756. function t(i, n, r) {
  11757. void 0 === r && (r = !1);
  11758. var o = e.call(this) || this;
  11759. return o.isReady = !1,
  11760. o.isCube = !1,
  11761. o.is3D = !1,
  11762. o.is2DArray = !1,
  11763. o.isMultiview = !1,
  11764. o.url = "",
  11765. o.generateMipMaps = !1,
  11766. o.samples = 0,
  11767. o.type = -1,
  11768. o.format = -1,
  11769. o.onLoadedObservable = new h,
  11770. o.onErrorObservable = new h,
  11771. o.onRebuildCallback = null,
  11772. o.width = 0,
  11773. o.height = 0,
  11774. o.depth = 0,
  11775. o.baseWidth = 0,
  11776. o.baseHeight = 0,
  11777. o.baseDepth = 0,
  11778. o.invertY = !1,
  11779. o._invertVScale = !1,
  11780. o._associatedChannel = -1,
  11781. o._source = At.Unknown,
  11782. o._buffer = null,
  11783. o._bufferView = null,
  11784. o._bufferViewArray = null,
  11785. o._bufferViewArrayArray = null,
  11786. o._size = 0,
  11787. o._extension = "",
  11788. o._files = null,
  11789. o._workingCanvas = null,
  11790. o._workingContext = null,
  11791. o._cachedCoordinatesMode = null,
  11792. o._isDisabled = !1,
  11793. o._compression = null,
  11794. o._sphericalPolynomial = null,
  11795. o._sphericalPolynomialPromise = null,
  11796. o._sphericalPolynomialComputed = !1,
  11797. o._lodGenerationScale = 0,
  11798. o._lodGenerationOffset = 0,
  11799. o._useSRGBBuffer = !1,
  11800. o._lodTextureHigh = null,
  11801. o._lodTextureMid = null,
  11802. o._lodTextureLow = null,
  11803. o._isRGBD = !1,
  11804. o._linearSpecularLOD = !1,
  11805. o._irradianceTexture = null,
  11806. o._hardwareTexture = null,
  11807. o._maxLodLevel = null,
  11808. o._references = 1,
  11809. o._gammaSpace = null,
  11810. o._engine = i,
  11811. o._source = n,
  11812. o._uniqueId = t._Counter++,
  11813. r || (o._hardwareTexture = i._createHardwareTexture()),
  11814. o
  11815. }
  11816. return U(t, e),
  11817. Object.defineProperty(t.prototype, "useMipMaps", {
  11818. get: function() {
  11819. return this.generateMipMaps
  11820. },
  11821. set: function(e) {
  11822. this.generateMipMaps = e
  11823. },
  11824. enumerable: !1,
  11825. configurable: !0
  11826. }),
  11827. Object.defineProperty(t.prototype, "uniqueId", {
  11828. get: function() {
  11829. return this._uniqueId
  11830. },
  11831. enumerable: !1,
  11832. configurable: !0
  11833. }),
  11834. t.prototype.getEngine = function() {
  11835. return this._engine
  11836. }
  11837. ,
  11838. Object.defineProperty(t.prototype, "source", {
  11839. get: function() {
  11840. return this._source
  11841. },
  11842. enumerable: !1,
  11843. configurable: !0
  11844. }),
  11845. t.prototype.incrementReferences = function() {
  11846. this._references++
  11847. }
  11848. ,
  11849. t.prototype.updateSize = function(e, t, i) {
  11850. void 0 === i && (i = 1),
  11851. this._engine.updateTextureDimensions(this, e, t, i),
  11852. this.width = e,
  11853. this.height = t,
  11854. this.depth = i,
  11855. this.baseWidth = e,
  11856. this.baseHeight = t,
  11857. this.baseDepth = i,
  11858. this._size = e * t * i
  11859. }
  11860. ,
  11861. t.prototype._rebuild = function() {
  11862. var e, t = this;
  11863. if (this.isReady = !1,
  11864. this._cachedCoordinatesMode = null,
  11865. this._cachedWrapU = null,
  11866. this._cachedWrapV = null,
  11867. this._cachedWrapR = null,
  11868. this._cachedAnisotropicFilteringLevel = null,
  11869. this.onRebuildCallback) {
  11870. var i = this.onRebuildCallback(this)
  11871. , n = function(e) {
  11872. e._swapAndDie(t, !1),
  11873. t.isReady = i.isReady
  11874. };
  11875. i.isAsync ? i.proxy.then(n) : n(i.proxy)
  11876. } else {
  11877. var r;
  11878. switch (this.source) {
  11879. case At.Temp:
  11880. break;
  11881. case At.Url:
  11882. return void (r = this._engine.createTexture(null !== (e = this._originalUrl) && void 0 !== e ? e : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, (function() {
  11883. r._swapAndDie(t, !1),
  11884. t.isReady = !0
  11885. }
  11886. ), null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer));
  11887. case At.Raw:
  11888. (r = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
  11889. this.isReady = !0;
  11890. break;
  11891. case At.Raw3D:
  11892. (r = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
  11893. this.isReady = !0;
  11894. break;
  11895. case At.Raw2DArray:
  11896. (r = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
  11897. this.isReady = !0;
  11898. break;
  11899. case At.Dynamic:
  11900. (r = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode))._swapAndDie(this, !1),
  11901. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
  11902. break;
  11903. case At.Cube:
  11904. return void (r = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, (function() {
  11905. r._swapAndDie(t, !1),
  11906. t.isReady = !0
  11907. }
  11908. ), null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer));
  11909. case At.CubeRaw:
  11910. (r = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this, !1),
  11911. this.isReady = !0;
  11912. break;
  11913. case At.CubeRawRGBD:
  11914. return;
  11915. case At.CubePrefiltered:
  11916. return void ((r = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, (function(e) {
  11917. e && e._swapAndDie(t, !1),
  11918. t.isReady = !0
  11919. }
  11920. ), null, this.format, this._extension))._sphericalPolynomial = this._sphericalPolynomial)
  11921. }
  11922. }
  11923. }
  11924. ,
  11925. t.prototype._swapAndDie = function(e, t) {
  11926. var i;
  11927. void 0 === t && (t = !0),
  11928. null === (i = this._hardwareTexture) || void 0 === i || i.setUsage(e._source, this.generateMipMaps, this.isCube, this.width, this.height),
  11929. e._hardwareTexture = this._hardwareTexture,
  11930. t && (e._isRGBD = this._isRGBD),
  11931. this._lodTextureHigh && (e._lodTextureHigh && e._lodTextureHigh.dispose(),
  11932. e._lodTextureHigh = this._lodTextureHigh),
  11933. this._lodTextureMid && (e._lodTextureMid && e._lodTextureMid.dispose(),
  11934. e._lodTextureMid = this._lodTextureMid),
  11935. this._lodTextureLow && (e._lodTextureLow && e._lodTextureLow.dispose(),
  11936. e._lodTextureLow = this._lodTextureLow),
  11937. this._irradianceTexture && (e._irradianceTexture && e._irradianceTexture.dispose(),
  11938. e._irradianceTexture = this._irradianceTexture);
  11939. var n = this._engine.getLoadedTexturesCache()
  11940. , r = n.indexOf(this);
  11941. -1 !== r && n.splice(r, 1),
  11942. -1 === (r = n.indexOf(e)) && n.push(e)
  11943. }
  11944. ,
  11945. t.prototype.dispose = function() {
  11946. this._references--,
  11947. this.onLoadedObservable.clear(),
  11948. this.onErrorObservable.clear(),
  11949. 0 === this._references && (this._engine._releaseTexture(this),
  11950. this._hardwareTexture = null)
  11951. }
  11952. ,
  11953. t._Counter = 0,
  11954. t
  11955. }(Nt)
  11956. , Ft = function() {
  11957. function e() {
  11958. this.shaderLanguage = st.GLSL
  11959. }
  11960. return e.prototype.postProcessor = function(e, t, i, n, r) {
  11961. return r.getCaps().drawBuffersExtension || (e = e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")),
  11962. e
  11963. }
  11964. ,
  11965. e
  11966. }()
  11967. , wt = function() {
  11968. function e() {
  11969. this.shaderLanguage = st.GLSL
  11970. }
  11971. return e.prototype.attributeProcessor = function(e) {
  11972. return e.replace("attribute", "in")
  11973. }
  11974. ,
  11975. e.prototype.varyingProcessor = function(e, t) {
  11976. return e.replace("varying", t ? "in" : "out")
  11977. }
  11978. ,
  11979. e.prototype.postProcessor = function(e, t, i) {
  11980. var n = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/);
  11981. if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("),
  11982. i)
  11983. e = (e = (e = (e = (e = (e = (e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/void\s+?main\s*\(/g, (n ? "" : "out vec4 glFragColor;\n") + "void main(");
  11984. else if (-1 !== t.indexOf("#define MULTIVIEW"))
  11985. return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + e;
  11986. return e
  11987. }
  11988. ,
  11989. e
  11990. }()
  11991. , Bt = function() {
  11992. function e() {
  11993. this.references = 0,
  11994. this.capacity = 0,
  11995. this.is32Bits = !1,
  11996. this.uniqueId = e._Counter++
  11997. }
  11998. return Object.defineProperty(e.prototype, "underlyingResource", {
  11999. get: function() {
  12000. return null
  12001. },
  12002. enumerable: !1,
  12003. configurable: !0
  12004. }),
  12005. e._Counter = 0,
  12006. e
  12007. }()
  12008. , Ut = function(e) {
  12009. function t(t) {
  12010. var i = e.call(this) || this;
  12011. return i._buffer = t,
  12012. i
  12013. }
  12014. return U(t, e),
  12015. Object.defineProperty(t.prototype, "underlyingResource", {
  12016. get: function() {
  12017. return this._buffer
  12018. },
  12019. enumerable: !1,
  12020. configurable: !0
  12021. }),
  12022. t
  12023. }(Bt)
  12024. , Vt = function() {
  12025. function e() {
  12026. this._valueCache = {},
  12027. this.vertexCompilationError = null,
  12028. this.fragmentCompilationError = null,
  12029. this.programLinkError = null,
  12030. this.programValidationError = null
  12031. }
  12032. return Object.defineProperty(e.prototype, "isAsync", {
  12033. get: function() {
  12034. return this.isParallelCompiled
  12035. },
  12036. enumerable: !1,
  12037. configurable: !0
  12038. }),
  12039. Object.defineProperty(e.prototype, "isReady", {
  12040. get: function() {
  12041. return !!this.program && (!this.isParallelCompiled || this.engine._isRenderingStateCompiled(this))
  12042. },
  12043. enumerable: !1,
  12044. configurable: !0
  12045. }),
  12046. e.prototype._handlesSpectorRebuildCallback = function(e) {
  12047. e && this.program && e(this.program)
  12048. }
  12049. ,
  12050. e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
  12051. var l, c = this.engine;
  12052. if (c.supportsUniformBuffers)
  12053. for (var u in t)
  12054. e.bindUniformBlock(u, t[u]);
  12055. for (this.engine.getUniforms(this, i).forEach((function(e, t) {
  12056. n[i[t]] = e
  12057. }
  12058. )),
  12059. this._uniforms = n,
  12060. l = 0; l < r.length; l++)
  12061. null == e.getUniform(r[l]) && (r.splice(l, 1),
  12062. l--);
  12063. r.forEach((function(e, t) {
  12064. o[e] = t
  12065. }
  12066. ));
  12067. for (var h = 0, d = c.getAttributes(this, a); h < d.length; h++) {
  12068. var p = d[h];
  12069. s.push(p)
  12070. }
  12071. }
  12072. ,
  12073. e.prototype.dispose = function() {
  12074. this._uniforms = {}
  12075. }
  12076. ,
  12077. e.prototype._cacheMatrix = function(e, t) {
  12078. var i = this._valueCache[e]
  12079. , n = t.updateFlag;
  12080. return (void 0 === i || i !== n) && (this._valueCache[e] = n,
  12081. !0)
  12082. }
  12083. ,
  12084. e.prototype._cacheFloat2 = function(e, t, i) {
  12085. var n = this._valueCache[e];
  12086. if (!n || 2 !== n.length)
  12087. return n = [t, i],
  12088. this._valueCache[e] = n,
  12089. !0;
  12090. var r = !1;
  12091. return n[0] !== t && (n[0] = t,
  12092. r = !0),
  12093. n[1] !== i && (n[1] = i,
  12094. r = !0),
  12095. r
  12096. }
  12097. ,
  12098. e.prototype._cacheFloat3 = function(e, t, i, n) {
  12099. var r = this._valueCache[e];
  12100. if (!r || 3 !== r.length)
  12101. return r = [t, i, n],
  12102. this._valueCache[e] = r,
  12103. !0;
  12104. var o = !1;
  12105. return r[0] !== t && (r[0] = t,
  12106. o = !0),
  12107. r[1] !== i && (r[1] = i,
  12108. o = !0),
  12109. r[2] !== n && (r[2] = n,
  12110. o = !0),
  12111. o
  12112. }
  12113. ,
  12114. e.prototype._cacheFloat4 = function(e, t, i, n, r) {
  12115. var o = this._valueCache[e];
  12116. if (!o || 4 !== o.length)
  12117. return o = [t, i, n, r],
  12118. this._valueCache[e] = o,
  12119. !0;
  12120. var a = !1;
  12121. return o[0] !== t && (o[0] = t,
  12122. a = !0),
  12123. o[1] !== i && (o[1] = i,
  12124. a = !0),
  12125. o[2] !== n && (o[2] = n,
  12126. a = !0),
  12127. o[3] !== r && (o[3] = r,
  12128. a = !0),
  12129. a
  12130. }
  12131. ,
  12132. e.prototype.setInt = function(e, t) {
  12133. var i = this._valueCache[e];
  12134. void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t)
  12135. }
  12136. ,
  12137. e.prototype.setInt2 = function(e, t, i) {
  12138. this._cacheFloat2(e, t, i) && (this.engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
  12139. }
  12140. ,
  12141. e.prototype.setInt3 = function(e, t, i, n) {
  12142. this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
  12143. }
  12144. ,
  12145. e.prototype.setInt4 = function(e, t, i, n, r) {
  12146. this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
  12147. }
  12148. ,
  12149. e.prototype.setIntArray = function(e, t) {
  12150. this._valueCache[e] = null,
  12151. this.engine.setIntArray(this._uniforms[e], t)
  12152. }
  12153. ,
  12154. e.prototype.setIntArray2 = function(e, t) {
  12155. this._valueCache[e] = null,
  12156. this.engine.setIntArray2(this._uniforms[e], t)
  12157. }
  12158. ,
  12159. e.prototype.setIntArray3 = function(e, t) {
  12160. this._valueCache[e] = null,
  12161. this.engine.setIntArray3(this._uniforms[e], t)
  12162. }
  12163. ,
  12164. e.prototype.setIntArray4 = function(e, t) {
  12165. this._valueCache[e] = null,
  12166. this.engine.setIntArray4(this._uniforms[e], t)
  12167. }
  12168. ,
  12169. e.prototype.setArray = function(e, t) {
  12170. this._valueCache[e] = null,
  12171. this.engine.setArray(this._uniforms[e], t)
  12172. }
  12173. ,
  12174. e.prototype.setArray2 = function(e, t) {
  12175. this._valueCache[e] = null,
  12176. this.engine.setArray2(this._uniforms[e], t)
  12177. }
  12178. ,
  12179. e.prototype.setArray3 = function(e, t) {
  12180. this._valueCache[e] = null,
  12181. this.engine.setArray3(this._uniforms[e], t)
  12182. }
  12183. ,
  12184. e.prototype.setArray4 = function(e, t) {
  12185. this._valueCache[e] = null,
  12186. this.engine.setArray4(this._uniforms[e], t)
  12187. }
  12188. ,
  12189. e.prototype.setMatrices = function(e, t) {
  12190. t && (this._valueCache[e] = null,
  12191. this.engine.setMatrices(this._uniforms[e], t))
  12192. }
  12193. ,
  12194. e.prototype.setMatrix = function(e, t) {
  12195. this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null))
  12196. }
  12197. ,
  12198. e.prototype.setMatrix3x3 = function(e, t) {
  12199. this._valueCache[e] = null,
  12200. this.engine.setMatrix3x3(this._uniforms[e], t)
  12201. }
  12202. ,
  12203. e.prototype.setMatrix2x2 = function(e, t) {
  12204. this._valueCache[e] = null,
  12205. this.engine.setMatrix2x2(this._uniforms[e], t)
  12206. }
  12207. ,
  12208. e.prototype.setFloat = function(e, t) {
  12209. var i = this._valueCache[e];
  12210. void 0 !== i && i === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t)
  12211. }
  12212. ,
  12213. e.prototype.setVector2 = function(e, t) {
  12214. this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null))
  12215. }
  12216. ,
  12217. e.prototype.setFloat2 = function(e, t, i) {
  12218. this._cacheFloat2(e, t, i) && (this.engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
  12219. }
  12220. ,
  12221. e.prototype.setVector3 = function(e, t) {
  12222. this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null))
  12223. }
  12224. ,
  12225. e.prototype.setFloat3 = function(e, t, i, n) {
  12226. this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
  12227. }
  12228. ,
  12229. e.prototype.setVector4 = function(e, t) {
  12230. this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null))
  12231. }
  12232. ,
  12233. e.prototype.setFloat4 = function(e, t, i, n, r) {
  12234. this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
  12235. }
  12236. ,
  12237. e.prototype.setColor3 = function(e, t) {
  12238. this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null))
  12239. }
  12240. ,
  12241. e.prototype.setColor4 = function(e, t, i) {
  12242. this._cacheFloat4(e, t.r, t.g, t.b, i) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null))
  12243. }
  12244. ,
  12245. e.prototype.setDirectColor4 = function(e, t) {
  12246. this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null))
  12247. }
  12248. ,
  12249. e.prototype._getVertexShaderCode = function() {
  12250. return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null
  12251. }
  12252. ,
  12253. e.prototype._getFragmentShaderCode = function() {
  12254. return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null
  12255. }
  12256. ,
  12257. e
  12258. }()
  12259. , kt = function() {
  12260. function e(e, t) {
  12261. if (void 0 === e && (e = null),
  12262. this._MSAARenderBuffer = null,
  12263. this._context = t,
  12264. !e && !(e = t.createTexture()))
  12265. throw new Error("Unable to create webGL texture");
  12266. this.set(e)
  12267. }
  12268. return Object.defineProperty(e.prototype, "underlyingResource", {
  12269. get: function() {
  12270. return this._webGLTexture
  12271. },
  12272. enumerable: !1,
  12273. configurable: !0
  12274. }),
  12275. e.prototype.setUsage = function() {}
  12276. ,
  12277. e.prototype.set = function(e) {
  12278. this._webGLTexture = e
  12279. }
  12280. ,
  12281. e.prototype.reset = function() {
  12282. this._webGLTexture = null,
  12283. this._MSAARenderBuffer = null
  12284. }
  12285. ,
  12286. e.prototype.release = function() {
  12287. this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
  12288. this._MSAARenderBuffer = null),
  12289. this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
  12290. this.reset()
  12291. }
  12292. ,
  12293. e
  12294. }()
  12295. , Gt = function() {
  12296. function e(e, t) {
  12297. void 0 === t && (t = !0),
  12298. this.effect = null,
  12299. this.defines = null,
  12300. this.drawContext = e.createDrawContext(),
  12301. t && (this.materialContext = e.createMaterialContext())
  12302. }
  12303. return e.IsWrapper = function(e) {
  12304. return void 0 === e.getPipelineContext
  12305. }
  12306. ,
  12307. e.GetEffect = function(e) {
  12308. return void 0 === e.getPipelineContext ? e.effect : e
  12309. }
  12310. ,
  12311. e.prototype.setEffect = function(e, t, i) {
  12312. var n;
  12313. void 0 === i && (i = !0),
  12314. this.effect = e,
  12315. void 0 !== t && (this.defines = t),
  12316. i && (null === (n = this.drawContext) || void 0 === n || n.reset())
  12317. }
  12318. ,
  12319. e.prototype.dispose = function() {
  12320. var e;
  12321. null === (e = this.drawContext) || void 0 === e || e.dispose()
  12322. }
  12323. ,
  12324. e
  12325. }()
  12326. , zt = function() {
  12327. function e(e) {
  12328. void 0 === e && (e = !0),
  12329. this._isStencilTestDirty = !1,
  12330. this._isStencilMaskDirty = !1,
  12331. this._isStencilFuncDirty = !1,
  12332. this._isStencilOpDirty = !1,
  12333. this.useStencilGlobalOnly = !1,
  12334. e && this.reset()
  12335. }
  12336. return Object.defineProperty(e.prototype, "isDirty", {
  12337. get: function() {
  12338. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty
  12339. },
  12340. enumerable: !1,
  12341. configurable: !0
  12342. }),
  12343. Object.defineProperty(e.prototype, "func", {
  12344. get: function() {
  12345. return this._func
  12346. },
  12347. set: function(e) {
  12348. this._func !== e && (this._func = e,
  12349. this._isStencilFuncDirty = !0)
  12350. },
  12351. enumerable: !1,
  12352. configurable: !0
  12353. }),
  12354. Object.defineProperty(e.prototype, "funcRef", {
  12355. get: function() {
  12356. return this._funcRef
  12357. },
  12358. set: function(e) {
  12359. this._funcRef !== e && (this._funcRef = e,
  12360. this._isStencilFuncDirty = !0)
  12361. },
  12362. enumerable: !1,
  12363. configurable: !0
  12364. }),
  12365. Object.defineProperty(e.prototype, "funcMask", {
  12366. get: function() {
  12367. return this._funcMask
  12368. },
  12369. set: function(e) {
  12370. this._funcMask !== e && (this._funcMask = e,
  12371. this._isStencilFuncDirty = !0)
  12372. },
  12373. enumerable: !1,
  12374. configurable: !0
  12375. }),
  12376. Object.defineProperty(e.prototype, "opStencilFail", {
  12377. get: function() {
  12378. return this._opStencilFail
  12379. },
  12380. set: function(e) {
  12381. this._opStencilFail !== e && (this._opStencilFail = e,
  12382. this._isStencilOpDirty = !0)
  12383. },
  12384. enumerable: !1,
  12385. configurable: !0
  12386. }),
  12387. Object.defineProperty(e.prototype, "opDepthFail", {
  12388. get: function() {
  12389. return this._opDepthFail
  12390. },
  12391. set: function(e) {
  12392. this._opDepthFail !== e && (this._opDepthFail = e,
  12393. this._isStencilOpDirty = !0)
  12394. },
  12395. enumerable: !1,
  12396. configurable: !0
  12397. }),
  12398. Object.defineProperty(e.prototype, "opStencilDepthPass", {
  12399. get: function() {
  12400. return this._opStencilDepthPass
  12401. },
  12402. set: function(e) {
  12403. this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
  12404. this._isStencilOpDirty = !0)
  12405. },
  12406. enumerable: !1,
  12407. configurable: !0
  12408. }),
  12409. Object.defineProperty(e.prototype, "mask", {
  12410. get: function() {
  12411. return this._mask
  12412. },
  12413. set: function(e) {
  12414. this._mask !== e && (this._mask = e,
  12415. this._isStencilMaskDirty = !0)
  12416. },
  12417. enumerable: !1,
  12418. configurable: !0
  12419. }),
  12420. Object.defineProperty(e.prototype, "enabled", {
  12421. get: function() {
  12422. return this._enabled
  12423. },
  12424. set: function(e) {
  12425. this._enabled !== e && (this._enabled = e,
  12426. this._isStencilTestDirty = !0)
  12427. },
  12428. enumerable: !1,
  12429. configurable: !0
  12430. }),
  12431. e.prototype.reset = function() {
  12432. var e;
  12433. this.stencilMaterial = void 0,
  12434. null === (e = this.stencilGlobal) || void 0 === e || e.reset(),
  12435. this._isStencilTestDirty = !0,
  12436. this._isStencilMaskDirty = !0,
  12437. this._isStencilFuncDirty = !0,
  12438. this._isStencilOpDirty = !0
  12439. }
  12440. ,
  12441. e.prototype.apply = function(e) {
  12442. var t;
  12443. if (e) {
  12444. var i = !this.useStencilGlobalOnly && !!(null === (t = this.stencilMaterial) || void 0 === t ? void 0 : t.enabled);
  12445. this.enabled = i ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
  12446. this.func = i ? this.stencilMaterial.func : this.stencilGlobal.func,
  12447. this.funcRef = i ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
  12448. this.funcMask = i ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
  12449. this.opStencilFail = i ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
  12450. this.opDepthFail = i ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
  12451. this.opStencilDepthPass = i ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
  12452. this.mask = i ? this.stencilMaterial.mask : this.stencilGlobal.mask,
  12453. this.isDirty && (this._isStencilTestDirty && (this.enabled ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST),
  12454. this._isStencilTestDirty = !1),
  12455. this._isStencilMaskDirty && (e.stencilMask(this.mask),
  12456. this._isStencilMaskDirty = !1),
  12457. this._isStencilFuncDirty && (e.stencilFunc(this.func, this.funcRef, this.funcMask),
  12458. this._isStencilFuncDirty = !1),
  12459. this._isStencilOpDirty && (e.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass),
  12460. this._isStencilOpDirty = !1))
  12461. }
  12462. }
  12463. ,
  12464. e
  12465. }()
  12466. , Wt = function() {}
  12467. , Ht = function() {
  12468. function e(t, i, n, r) {
  12469. var o = this;
  12470. this._name = "WebGL",
  12471. this.forcePOTTextures = !1,
  12472. this.isFullscreen = !1,
  12473. this.cullBackFaces = null,
  12474. this.renderEvenInBackground = !0,
  12475. this.preventCacheWipeBetweenFrames = !1,
  12476. this.validateShaderPrograms = !1,
  12477. this._useReverseDepthBuffer = !1,
  12478. this.isNDCHalfZRange = !1,
  12479. this.hasOriginBottomLeft = !0,
  12480. this.disableUniformBuffers = !1,
  12481. this.onDisposeObservable = new h,
  12482. this._frameId = 0,
  12483. this._uniformBuffers = new Array,
  12484. this._storageBuffers = new Array,
  12485. this._webGLVersion = 1,
  12486. this._windowIsBackground = !1,
  12487. this._highPrecisionShadersAllowed = !0,
  12488. this._badOS = !1,
  12489. this._badDesktopOS = !1,
  12490. this._renderingQueueLaunched = !1,
  12491. this._activeRenderLoops = new Array,
  12492. this.onContextLostObservable = new h,
  12493. this.onContextRestoredObservable = new h,
  12494. this._contextWasLost = !1,
  12495. this._doNotHandleContextLost = !1,
  12496. this.disableVertexArrayObjects = !1,
  12497. this._colorWrite = !0,
  12498. this._colorWriteChanged = !0,
  12499. this._depthCullingState = new It,
  12500. this._stencilStateComposer = new zt,
  12501. this._stencilState = new Ot,
  12502. this._alphaState = new Dt,
  12503. this._alphaMode = a.ALPHA_ADD,
  12504. this._alphaEquation = a.ALPHA_DISABLE,
  12505. this._internalTexturesCache = new Array,
  12506. this._renderTargetWrapperCache = new Array,
  12507. this._activeChannel = 0,
  12508. this._currentTextureChannel = -1,
  12509. this._boundTexturesCache = {},
  12510. this._compiledEffects = {},
  12511. this._vertexAttribArraysEnabled = [],
  12512. this._uintIndicesCurrentlySet = !1,
  12513. this._currentBoundBuffer = new Array,
  12514. this._currentFramebuffer = null,
  12515. this._dummyFramebuffer = null,
  12516. this._currentBufferPointers = new Array,
  12517. this._currentInstanceLocations = new Array,
  12518. this._currentInstanceBuffers = new Array,
  12519. this._vaoRecordInProgress = !1,
  12520. this._mustWipeVertexAttributes = !1,
  12521. this._nextFreeTextureSlots = new Array,
  12522. this._maxSimultaneousTextures = 0,
  12523. this._activeRequests = new Array,
  12524. this._adaptToDeviceRatio = !1,
  12525. this._transformTextureUrl = null,
  12526. this.hostInformation = {
  12527. isMobile: !1
  12528. },
  12529. this.premultipliedAlpha = !0,
  12530. this.onBeforeTextureInitObservable = new h,
  12531. this._isWebGPU = !1,
  12532. this._snapshotRenderingMode = a.SNAPSHOTRENDERING_STANDARD,
  12533. this._viewportCached = {
  12534. x: 0,
  12535. y: 0,
  12536. z: 0,
  12537. w: 0
  12538. },
  12539. this._unpackFlipYCached = null,
  12540. this.enableUnpackFlipYCached = !0,
  12541. this._boundUniforms = {};
  12542. var s = null;
  12543. if (n = n || {},
  12544. this._creationOptions = n,
  12545. this._adaptToDeviceRatio = null != r && r,
  12546. this._stencilStateComposer.stencilGlobal = this._stencilState,
  12547. T.SetMatrixPrecision(!!n.useHighPrecisionMatrix),
  12548. t) {
  12549. if (r = r || n.adaptToDeviceRatio || !1,
  12550. t.getContext) {
  12551. if (s = t,
  12552. this._renderingCanvas = s,
  12553. void 0 !== i && (n.antialias = i),
  12554. void 0 === n.deterministicLockstep && (n.deterministicLockstep = !1),
  12555. void 0 === n.lockstepMaxSteps && (n.lockstepMaxSteps = 4),
  12556. void 0 === n.timeStep && (n.timeStep = 1 / 60),
  12557. void 0 === n.preserveDrawingBuffer && (n.preserveDrawingBuffer = !1),
  12558. void 0 === n.audioEngine && (n.audioEngine = !0),
  12559. void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioContext && (this._audioContext = n.audioEngineOptions.audioContext),
  12560. void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioDestination && (this._audioDestination = n.audioEngineOptions.audioDestination),
  12561. void 0 === n.stencil && (n.stencil = !0),
  12562. !1 === n.premultipliedAlpha && (this.premultipliedAlpha = !1),
  12563. void 0 === n.xrCompatible && (n.xrCompatible = !0),
  12564. this._doNotHandleContextLost = !!n.doNotHandleContextLost,
  12565. navigator && navigator.userAgent) {
  12566. this._checkForMobile = function() {
  12567. var e = navigator.userAgent;
  12568. o.hostInformation.isMobile = -1 !== e.indexOf("Mobile") || -1 !== e.indexOf("Mac") && ot() && "ontouchend"in document
  12569. }
  12570. ,
  12571. this._checkForMobile(),
  12572. nt() && window.addEventListener("resize", this._checkForMobile);
  12573. for (var l = navigator.userAgent, c = 0, u = e.ExceptionList; c < u.length; c++) {
  12574. var d = u[c]
  12575. , p = d.key
  12576. , f = d.targets;
  12577. if (new RegExp(p).test(l)) {
  12578. if (d.capture && d.captureConstraint) {
  12579. var _ = d.capture
  12580. , m = d.captureConstraint
  12581. , g = new RegExp(_).exec(l);
  12582. if (g && g.length > 0 && parseInt(g[g.length - 1]) >= m)
  12583. continue
  12584. }
  12585. for (var v = 0, y = f; v < y.length; v++)
  12586. switch (y[v]) {
  12587. case "uniformBuffer":
  12588. this.disableUniformBuffers = !0;
  12589. break;
  12590. case "vao":
  12591. this.disableVertexArrayObjects = !0
  12592. }
  12593. }
  12594. }
  12595. }
  12596. if (this._doNotHandleContextLost || (this._onContextLost = function(e) {
  12597. e.preventDefault(),
  12598. o._contextWasLost = !0,
  12599. K.Warn("WebGL context lost."),
  12600. o.onContextLostObservable.notifyObservers(o)
  12601. }
  12602. ,
  12603. this._onContextRestored = function() {
  12604. o._restoreEngineAfterContextLost(o._initGLContext.bind(o))
  12605. }
  12606. ,
  12607. s.addEventListener("webglcontextlost", this._onContextLost, !1),
  12608. s.addEventListener("webglcontextrestored", this._onContextRestored, !1),
  12609. n.powerPreference = "high-performance"),
  12610. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
  12611. this._badDesktopOS && (n.xrCompatible = !1),
  12612. !n.disableWebGL2Support)
  12613. try {
  12614. this._gl = s.getContext("webgl2", n) || s.getContext("experimental-webgl2", n),
  12615. this._gl && (this._webGLVersion = 2,
  12616. this._shaderPlatformName = "WEBGL2",
  12617. this._gl.deleteQuery || (this._webGLVersion = 1,
  12618. this._shaderPlatformName = "WEBGL1"))
  12619. } catch (e) {}
  12620. if (!this._gl) {
  12621. if (!s)
  12622. throw new Error("The provided canvas is null or undefined.");
  12623. try {
  12624. this._gl = s.getContext("webgl", n) || s.getContext("experimental-webgl", n)
  12625. } catch (e) {
  12626. throw new Error("WebGL not supported")
  12627. }
  12628. }
  12629. if (!this._gl)
  12630. throw new Error("WebGL not supported")
  12631. } else {
  12632. this._gl = t,
  12633. this._renderingCanvas = this._gl.canvas,
  12634. this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2,
  12635. this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
  12636. var b = this._gl.getContextAttributes();
  12637. b && (n.stencil = b.stencil)
  12638. }
  12639. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
  12640. void 0 !== n.useHighPrecisionFloats && (this._highPrecisionShadersAllowed = n.useHighPrecisionFloats);
  12641. var E = nt() && window.devicePixelRatio || 1
  12642. , S = n.limitDeviceRatio || E;
  12643. this._hardwareScalingLevel = r ? 1 / Math.min(S, E) : 1,
  12644. this.resize(),
  12645. this._isStencilEnable = !!n.stencil,
  12646. this._initGLContext(),
  12647. this._initFeatures();
  12648. for (var A = 0; A < this._caps.maxVertexAttribs; A++)
  12649. this._currentBufferPointers[A] = new Wt;
  12650. this._shaderProcessor = this.webGLVersion > 1 ? new wt : new Ft,
  12651. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  12652. var x = "Babylon.js v".concat(e.Version);
  12653. console.log(x + " - ".concat(this.description)),
  12654. this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", x)
  12655. }
  12656. }
  12657. return Object.defineProperty(e, "NpmPackage", {
  12658. get: function() {
  12659. return "babylonjs@5.0.0-rc.4"
  12660. },
  12661. enumerable: !1,
  12662. configurable: !0
  12663. }),
  12664. Object.defineProperty(e, "Version", {
  12665. get: function() {
  12666. return "5.0.0-rc.4"
  12667. },
  12668. enumerable: !1,
  12669. configurable: !0
  12670. }),
  12671. Object.defineProperty(e.prototype, "description", {
  12672. get: function() {
  12673. var e = this.name + this.webGLVersion;
  12674. return this._caps.parallelShaderCompile && (e += " - Parallel shader compilation"),
  12675. e
  12676. },
  12677. enumerable: !1,
  12678. configurable: !0
  12679. }),
  12680. Object.defineProperty(e.prototype, "name", {
  12681. get: function() {
  12682. return this._name
  12683. },
  12684. set: function(e) {
  12685. this._name = e
  12686. },
  12687. enumerable: !1,
  12688. configurable: !0
  12689. }),
  12690. Object.defineProperty(e.prototype, "version", {
  12691. get: function() {
  12692. return this._webGLVersion
  12693. },
  12694. enumerable: !1,
  12695. configurable: !0
  12696. }),
  12697. Object.defineProperty(e, "ShadersRepository", {
  12698. get: function() {
  12699. return Mt.ShadersRepository
  12700. },
  12701. set: function(e) {
  12702. Mt.ShadersRepository = e
  12703. },
  12704. enumerable: !1,
  12705. configurable: !0
  12706. }),
  12707. e.prototype._getShaderProcessor = function(e) {
  12708. return this._shaderProcessor
  12709. }
  12710. ,
  12711. Object.defineProperty(e.prototype, "useReverseDepthBuffer", {
  12712. get: function() {
  12713. return this._useReverseDepthBuffer
  12714. },
  12715. set: function(e) {
  12716. e !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = e,
  12717. this._depthCullingState.depthFunc = e ? a.GEQUAL : a.LEQUAL)
  12718. },
  12719. enumerable: !1,
  12720. configurable: !0
  12721. }),
  12722. Object.defineProperty(e.prototype, "frameId", {
  12723. get: function() {
  12724. return this._frameId
  12725. },
  12726. enumerable: !1,
  12727. configurable: !0
  12728. }),
  12729. Object.defineProperty(e.prototype, "supportsUniformBuffers", {
  12730. get: function() {
  12731. return this.webGLVersion > 1 && !this.disableUniformBuffers
  12732. },
  12733. enumerable: !1,
  12734. configurable: !0
  12735. }),
  12736. e.prototype.getCreationOptions = function() {
  12737. return this._creationOptions
  12738. }
  12739. ,
  12740. Object.defineProperty(e.prototype, "_shouldUseHighPrecisionShader", {
  12741. get: function() {
  12742. return !(!this._caps.highPrecisionShaderSupported || !this._highPrecisionShadersAllowed)
  12743. },
  12744. enumerable: !1,
  12745. configurable: !0
  12746. }),
  12747. Object.defineProperty(e.prototype, "needPOTTextures", {
  12748. get: function() {
  12749. return this._webGLVersion < 2 || this.forcePOTTextures
  12750. },
  12751. enumerable: !1,
  12752. configurable: !0
  12753. }),
  12754. Object.defineProperty(e.prototype, "activeRenderLoops", {
  12755. get: function() {
  12756. return this._activeRenderLoops
  12757. },
  12758. enumerable: !1,
  12759. configurable: !0
  12760. }),
  12761. Object.defineProperty(e.prototype, "doNotHandleContextLost", {
  12762. get: function() {
  12763. return this._doNotHandleContextLost
  12764. },
  12765. set: function(e) {
  12766. this._doNotHandleContextLost = e
  12767. },
  12768. enumerable: !1,
  12769. configurable: !0
  12770. }),
  12771. Object.defineProperty(e.prototype, "_supportsHardwareTextureRescaling", {
  12772. get: function() {
  12773. return !1
  12774. },
  12775. enumerable: !1,
  12776. configurable: !0
  12777. }),
  12778. Object.defineProperty(e.prototype, "framebufferDimensionsObject", {
  12779. set: function(e) {
  12780. this._framebufferDimensionsObject = e
  12781. },
  12782. enumerable: !1,
  12783. configurable: !0
  12784. }),
  12785. Object.defineProperty(e.prototype, "currentViewport", {
  12786. get: function() {
  12787. return this._cachedViewport
  12788. },
  12789. enumerable: !1,
  12790. configurable: !0
  12791. }),
  12792. Object.defineProperty(e.prototype, "emptyTexture", {
  12793. get: function() {
  12794. return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
  12795. this._emptyTexture
  12796. },
  12797. enumerable: !1,
  12798. configurable: !0
  12799. }),
  12800. Object.defineProperty(e.prototype, "emptyTexture3D", {
  12801. get: function() {
  12802. return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
  12803. this._emptyTexture3D
  12804. },
  12805. enumerable: !1,
  12806. configurable: !0
  12807. }),
  12808. Object.defineProperty(e.prototype, "emptyTexture2DArray", {
  12809. get: function() {
  12810. return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
  12811. this._emptyTexture2DArray
  12812. },
  12813. enumerable: !1,
  12814. configurable: !0
  12815. }),
  12816. Object.defineProperty(e.prototype, "emptyCubeTexture", {
  12817. get: function() {
  12818. if (!this._emptyCubeTexture) {
  12819. var e = new Uint8Array(4)
  12820. , t = [e, e, e, e, e, e];
  12821. this._emptyCubeTexture = this.createRawCubeTexture(t, 1, a.TEXTUREFORMAT_RGBA, a.TEXTURETYPE_UNSIGNED_INT, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
  12822. }
  12823. return this._emptyCubeTexture
  12824. },
  12825. enumerable: !1,
  12826. configurable: !0
  12827. }),
  12828. Object.defineProperty(e.prototype, "isWebGPU", {
  12829. get: function() {
  12830. return this._isWebGPU
  12831. },
  12832. enumerable: !1,
  12833. configurable: !0
  12834. }),
  12835. Object.defineProperty(e.prototype, "shaderPlatformName", {
  12836. get: function() {
  12837. return this._shaderPlatformName
  12838. },
  12839. enumerable: !1,
  12840. configurable: !0
  12841. }),
  12842. Object.defineProperty(e.prototype, "snapshotRendering", {
  12843. get: function() {
  12844. return !1
  12845. },
  12846. set: function(e) {},
  12847. enumerable: !1,
  12848. configurable: !0
  12849. }),
  12850. Object.defineProperty(e.prototype, "snapshotRenderingMode", {
  12851. get: function() {
  12852. return this._snapshotRenderingMode
  12853. },
  12854. set: function(e) {
  12855. this._snapshotRenderingMode = e
  12856. },
  12857. enumerable: !1,
  12858. configurable: !0
  12859. }),
  12860. e.prototype.snapshotRenderingReset = function() {
  12861. this.snapshotRendering = !1
  12862. }
  12863. ,
  12864. e._CreateCanvas = function(e, t) {
  12865. if ("undefined" == typeof document)
  12866. return new OffscreenCanvas(e,t);
  12867. var i = document.createElement("canvas");
  12868. return i.width = e,
  12869. i.height = t,
  12870. i
  12871. }
  12872. ,
  12873. e.prototype.createCanvas = function(t, i) {
  12874. return e._CreateCanvas(t, i)
  12875. }
  12876. ,
  12877. e.prototype.createCanvasImage = function() {
  12878. return document.createElement("img")
  12879. }
  12880. ,
  12881. e.prototype._restoreEngineAfterContextLost = function(e) {
  12882. var t = this;
  12883. setTimeout((function() {
  12884. return G(t, void 0, void 0, (function() {
  12885. var t, i, n, r, o;
  12886. return z(this, (function(a) {
  12887. switch (a.label) {
  12888. case 0:
  12889. return this._dummyFramebuffer = null,
  12890. t = this._depthCullingState.depthTest,
  12891. i = this._depthCullingState.depthFunc,
  12892. n = this._depthCullingState.depthMask,
  12893. r = this._stencilState.stencilTest,
  12894. [4, e()];
  12895. case 1:
  12896. return a.sent(),
  12897. this._rebuildEffects(),
  12898. null === (o = this._rebuildComputeEffects) || void 0 === o || o.call(this),
  12899. this._rebuildInternalTextures(),
  12900. this._rebuildRenderTargetWrappers(),
  12901. this._rebuildBuffers(),
  12902. this.wipeCaches(!0),
  12903. this._depthCullingState.depthTest = t,
  12904. this._depthCullingState.depthFunc = i,
  12905. this._depthCullingState.depthMask = n,
  12906. this._stencilState.stencilTest = r,
  12907. K.Warn(this.name + " context successfully restored."),
  12908. this.onContextRestoredObservable.notifyObservers(this),
  12909. this._contextWasLost = !1,
  12910. [2]
  12911. }
  12912. }
  12913. ))
  12914. }
  12915. ))
  12916. }
  12917. ), 0)
  12918. }
  12919. ,
  12920. e.prototype._sharedInit = function(e, t, i) {
  12921. this._renderingCanvas = e
  12922. }
  12923. ,
  12924. e.prototype._getShaderProcessingContext = function(e) {
  12925. return null
  12926. }
  12927. ,
  12928. e.prototype._rebuildInternalTextures = function() {
  12929. for (var e = 0, t = this._internalTexturesCache.slice(); e < t.length; e++)
  12930. t[e]._rebuild()
  12931. }
  12932. ,
  12933. e.prototype._rebuildRenderTargetWrappers = function() {
  12934. for (var e = 0, t = this._renderTargetWrapperCache.slice(); e < t.length; e++)
  12935. t[e]._rebuild()
  12936. }
  12937. ,
  12938. e.prototype._rebuildEffects = function() {
  12939. for (var e in this._compiledEffects) {
  12940. var t = this._compiledEffects[e];
  12941. t._pipelineContext = null,
  12942. t._wasPreviouslyReady = !1,
  12943. t._prepareEffect()
  12944. }
  12945. Mt.ResetCache()
  12946. }
  12947. ,
  12948. e.prototype.areAllEffectsReady = function() {
  12949. for (var e in this._compiledEffects)
  12950. if (!this._compiledEffects[e].isReady())
  12951. return !1;
  12952. return !0
  12953. }
  12954. ,
  12955. e.prototype._rebuildBuffers = function() {
  12956. for (var e = 0, t = this._uniformBuffers; e < t.length; e++)
  12957. t[e]._rebuild();
  12958. for (var i = 0, n = this._storageBuffers; i < n.length; i++)
  12959. n[i]._rebuild()
  12960. }
  12961. ,
  12962. e.prototype._initGLContext = function() {
  12963. this._caps = {
  12964. maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),
  12965. maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
  12966. maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
  12967. maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
  12968. maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,
  12969. maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
  12970. maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
  12971. maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
  12972. maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),
  12973. maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),
  12974. maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),
  12975. parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0,
  12976. standardDerivatives: this._webGLVersion > 1 || null !== this._gl.getExtension("OES_standard_derivatives"),
  12977. maxAnisotropy: 1,
  12978. astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
  12979. bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
  12980. s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
  12981. s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
  12982. pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
  12983. etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
  12984. etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"),
  12985. textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  12986. uintIndices: this._webGLVersion > 1 || null !== this._gl.getExtension("OES_element_index_uint"),
  12987. fragmentDepthSupported: this._webGLVersion > 1 || null !== this._gl.getExtension("EXT_frag_depth"),
  12988. highPrecisionShaderSupported: !1,
  12989. timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"),
  12990. supportOcclusionQuery: this._webGLVersion > 1,
  12991. canUseTimestampForTimerQuery: !1,
  12992. drawBuffersExtension: !1,
  12993. maxMSAASamples: 1,
  12994. colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")),
  12995. textureFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float")),
  12996. textureHalfFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float")),
  12997. textureHalfFloatRender: !1,
  12998. textureFloatLinearFiltering: !1,
  12999. textureFloatRender: !1,
  13000. textureHalfFloatLinearFiltering: !1,
  13001. vertexArrayObject: !1,
  13002. instancedArrays: !1,
  13003. textureLOD: !!(this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod")),
  13004. blendMinMax: !1,
  13005. multiview: this._gl.getExtension("OVR_multiview2"),
  13006. oculusMultiview: this._gl.getExtension("OCULUS_multiview"),
  13007. depthTextureExtension: !1,
  13008. canUseGLInstanceID: this._webGLVersion > 1,
  13009. canUseGLVertexID: this._webGLVersion > 1,
  13010. supportComputeShaders: !1,
  13011. supportSRGBBuffers: !1,
  13012. supportTransformFeedbacks: this._webGLVersion > 1,
  13013. textureMaxLevel: this._webGLVersion > 1
  13014. },
  13015. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  13016. var e = this._gl.getExtension("WEBGL_debug_renderer_info");
  13017. if (null != e && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),
  13018. this._glVendor = this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),
  13019. this._glVendor || (this._glVendor = this._gl.getParameter(this._gl.VENDOR) || "Unknown vendor"),
  13020. this._glRenderer || (this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || "Unknown renderer"),
  13021. 36193 !== this._gl.HALF_FLOAT_OES && (this._gl.HALF_FLOAT_OES = 36193),
  13022. 34842 !== this._gl.RGBA16F && (this._gl.RGBA16F = 34842),
  13023. 34836 !== this._gl.RGBA32F && (this._gl.RGBA32F = 34836),
  13024. 35056 !== this._gl.DEPTH24_STENCIL8 && (this._gl.DEPTH24_STENCIL8 = 35056),
  13025. this._caps.timerQuery && (1 === this._webGLVersion && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),
  13026. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0),
  13027. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
  13028. this._caps.textureFloatLinearFiltering = !(!this._caps.textureFloat || !this._gl.getExtension("OES_texture_float_linear")),
  13029. this._caps.textureFloatRender = !(!this._caps.textureFloat || !this._canRenderToFloatFramebuffer()),
  13030. this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")),
  13031. this._caps.astc && (this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),
  13032. this._caps.bptc && (this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),
  13033. this._caps.s3tc_srgb && (this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
  13034. this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),
  13035. this._webGLVersion > 1 && 5131 !== this._gl.HALF_FLOAT_OES && (this._gl.HALF_FLOAT_OES = 5131),
  13036. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(),
  13037. this._webGLVersion > 1)
  13038. this._caps.drawBuffersExtension = !0,
  13039. this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);
  13040. else {
  13041. var t = this._gl.getExtension("WEBGL_draw_buffers");
  13042. if (null !== t) {
  13043. this._caps.drawBuffersExtension = !0,
  13044. this._gl.drawBuffers = t.drawBuffersWEBGL.bind(t),
  13045. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  13046. for (var i = 0; i < 16; i++)
  13047. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = t["COLOR_ATTACHMENT" + i + "_WEBGL"]
  13048. }
  13049. }
  13050. if (this._webGLVersion > 1)
  13051. this._caps.depthTextureExtension = !0;
  13052. else {
  13053. var n = this._gl.getExtension("WEBGL_depth_texture");
  13054. null != n && (this._caps.depthTextureExtension = !0,
  13055. this._gl.UNSIGNED_INT_24_8 = n.UNSIGNED_INT_24_8_WEBGL)
  13056. }
  13057. if (this.disableVertexArrayObjects)
  13058. this._caps.vertexArrayObject = !1;
  13059. else if (this._webGLVersion > 1)
  13060. this._caps.vertexArrayObject = !0;
  13061. else {
  13062. var r = this._gl.getExtension("OES_vertex_array_object");
  13063. null != r && (this._caps.vertexArrayObject = !0,
  13064. this._gl.createVertexArray = r.createVertexArrayOES.bind(r),
  13065. this._gl.bindVertexArray = r.bindVertexArrayOES.bind(r),
  13066. this._gl.deleteVertexArray = r.deleteVertexArrayOES.bind(r))
  13067. }
  13068. if (this._webGLVersion > 1)
  13069. this._caps.instancedArrays = !0;
  13070. else {
  13071. var o = this._gl.getExtension("ANGLE_instanced_arrays");
  13072. null != o ? (this._caps.instancedArrays = !0,
  13073. this._gl.drawArraysInstanced = o.drawArraysInstancedANGLE.bind(o),
  13074. this._gl.drawElementsInstanced = o.drawElementsInstancedANGLE.bind(o),
  13075. this._gl.vertexAttribDivisor = o.vertexAttribDivisorANGLE.bind(o)) : this._caps.instancedArrays = !1
  13076. }
  13077. if (this._gl.getShaderPrecisionFormat) {
  13078. var a = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
  13079. , s = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  13080. a && s && (this._caps.highPrecisionShaderSupported = 0 !== a.precision && 0 !== s.precision)
  13081. }
  13082. if (this._webGLVersion > 1)
  13083. this._caps.blendMinMax = !0;
  13084. else {
  13085. var l = this._gl.getExtension("EXT_blend_minmax");
  13086. null != l && (this._caps.blendMinMax = !0,
  13087. this._gl.MAX = l.MAX_EXT,
  13088. this._gl.MIN = l.MIN_EXT)
  13089. }
  13090. if (!this._caps.supportSRGBBuffers) {
  13091. if (this._webGLVersion > 1)
  13092. this._caps.supportSRGBBuffers = !0;
  13093. else {
  13094. var c = this._gl.getExtension("EXT_sRGB");
  13095. null != c && (this._caps.supportSRGBBuffers = !0,
  13096. this._gl.SRGB = c.SRGB_EXT,
  13097. this._gl.SRGB8 = c.SRGB_ALPHA_EXT,
  13098. this._gl.SRGB8_ALPHA8 = c.SRGB_ALPHA_EXT)
  13099. }
  13100. this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && !(!this._creationOptions || !this._creationOptions.forceSRGBBufferSupportState)
  13101. }
  13102. this._depthCullingState.depthTest = !0,
  13103. this._depthCullingState.depthFunc = this._gl.LEQUAL,
  13104. this._depthCullingState.depthMask = !0,
  13105. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  13106. for (var u = 0; u < this._maxSimultaneousTextures; u++)
  13107. this._nextFreeTextureSlots.push(u)
  13108. }
  13109. ,
  13110. e.prototype._initFeatures = function() {
  13111. this._features = {
  13112. forceBitmapOverHTMLImageElement: !1,
  13113. supportRenderAndCopyToLodForFloatTextures: 1 !== this._webGLVersion,
  13114. supportDepthStencilTexture: 1 !== this._webGLVersion,
  13115. supportShadowSamplers: 1 !== this._webGLVersion,
  13116. uniformBufferHardCheckMatrix: !1,
  13117. allowTexturePrefiltering: 1 !== this._webGLVersion,
  13118. trackUbosInFrame: !1,
  13119. checkUbosContentBeforeUpload: !1,
  13120. supportCSM: 1 !== this._webGLVersion,
  13121. basisNeedsPOT: 1 === this._webGLVersion,
  13122. support3DTextures: 1 !== this._webGLVersion,
  13123. needTypeSuffixInShaderConstants: 1 !== this._webGLVersion,
  13124. supportMSAA: 1 !== this._webGLVersion,
  13125. supportSSAO2: 1 !== this._webGLVersion,
  13126. supportExtendedTextureFormats: 1 !== this._webGLVersion,
  13127. supportSwitchCaseInShader: 1 !== this._webGLVersion,
  13128. supportSyncTextureRead: !0,
  13129. needsInvertingBitmap: !0,
  13130. useUBOBindingCache: !0,
  13131. needShaderCodeInlining: !1,
  13132. needToAlwaysBindUniformBuffers: !1,
  13133. supportRenderPasses: !1,
  13134. _collectUbosUpdatedInFrame: !1
  13135. }
  13136. }
  13137. ,
  13138. Object.defineProperty(e.prototype, "webGLVersion", {
  13139. get: function() {
  13140. return this._webGLVersion
  13141. },
  13142. enumerable: !1,
  13143. configurable: !0
  13144. }),
  13145. e.prototype.getClassName = function() {
  13146. return "ThinEngine"
  13147. }
  13148. ,
  13149. Object.defineProperty(e.prototype, "isStencilEnable", {
  13150. get: function() {
  13151. return this._isStencilEnable
  13152. },
  13153. enumerable: !1,
  13154. configurable: !0
  13155. }),
  13156. e.prototype._prepareWorkingCanvas = function() {
  13157. if (!this._workingCanvas) {
  13158. this._workingCanvas = this.createCanvas(1, 1);
  13159. var e = this._workingCanvas.getContext("2d");
  13160. e && (this._workingContext = e)
  13161. }
  13162. }
  13163. ,
  13164. e.prototype.resetTextureCache = function() {
  13165. for (var e in this._boundTexturesCache)
  13166. Object.prototype.hasOwnProperty.call(this._boundTexturesCache, e) && (this._boundTexturesCache[e] = null);
  13167. this._currentTextureChannel = -1
  13168. }
  13169. ,
  13170. e.prototype.getInfo = function() {
  13171. return this.getGlInfo()
  13172. }
  13173. ,
  13174. e.prototype.getGlInfo = function() {
  13175. return {
  13176. vendor: this._glVendor,
  13177. renderer: this._glRenderer,
  13178. version: this._glVersion
  13179. }
  13180. }
  13181. ,
  13182. e.prototype.setHardwareScalingLevel = function(e) {
  13183. this._hardwareScalingLevel = e,
  13184. this.resize()
  13185. }
  13186. ,
  13187. e.prototype.getHardwareScalingLevel = function() {
  13188. return this._hardwareScalingLevel
  13189. }
  13190. ,
  13191. e.prototype.getLoadedTexturesCache = function() {
  13192. return this._internalTexturesCache
  13193. }
  13194. ,
  13195. e.prototype.getCaps = function() {
  13196. return this._caps
  13197. }
  13198. ,
  13199. e.prototype.stopRenderLoop = function(e) {
  13200. if (e) {
  13201. var t = this._activeRenderLoops.indexOf(e);
  13202. t >= 0 && this._activeRenderLoops.splice(t, 1)
  13203. } else
  13204. this._activeRenderLoops = []
  13205. }
  13206. ,
  13207. e.prototype._renderLoop = function() {
  13208. if (!this._contextWasLost) {
  13209. var e = !0;
  13210. if (!this.renderEvenInBackground && this._windowIsBackground && (e = !1),
  13211. e) {
  13212. this.beginFrame();
  13213. for (var t = 0; t < this._activeRenderLoops.length; t++)
  13214. (0,
  13215. this._activeRenderLoops[t])();
  13216. this.endFrame()
  13217. }
  13218. }
  13219. this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
  13220. }
  13221. ,
  13222. e.prototype.getRenderingCanvas = function() {
  13223. return this._renderingCanvas
  13224. }
  13225. ,
  13226. e.prototype.getAudioContext = function() {
  13227. return this._audioContext
  13228. }
  13229. ,
  13230. e.prototype.getAudioDestination = function() {
  13231. return this._audioDestination
  13232. }
  13233. ,
  13234. e.prototype.getHostWindow = function() {
  13235. return nt() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null
  13236. }
  13237. ,
  13238. e.prototype.getRenderWidth = function(e) {
  13239. return void 0 === e && (e = !1),
  13240. !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth
  13241. }
  13242. ,
  13243. e.prototype.getRenderHeight = function(e) {
  13244. return void 0 === e && (e = !1),
  13245. !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight
  13246. }
  13247. ,
  13248. e.prototype._queueNewFrame = function(t, i) {
  13249. return e.QueueNewFrame(t, i)
  13250. }
  13251. ,
  13252. e.prototype.runRenderLoop = function(e) {
  13253. -1 === this._activeRenderLoops.indexOf(e) && (this._activeRenderLoops.push(e),
  13254. this._renderingQueueLaunched || (this._renderingQueueLaunched = !0,
  13255. this._boundRenderFunction = this._renderLoop.bind(this),
  13256. this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())))
  13257. }
  13258. ,
  13259. e.prototype.clear = function(e, t, i, n) {
  13260. void 0 === n && (n = !1);
  13261. var r = this.stencilStateComposer.useStencilGlobalOnly;
  13262. this.stencilStateComposer.useStencilGlobalOnly = !0,
  13263. this.applyStates(),
  13264. this.stencilStateComposer.useStencilGlobalOnly = r;
  13265. var o = 0;
  13266. t && e && (this._gl.clearColor(e.r, e.g, e.b, void 0 !== e.a ? e.a : 1),
  13267. o |= this._gl.COLOR_BUFFER_BIT),
  13268. i && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
  13269. this._gl.clearDepth(0)) : this._gl.clearDepth(1),
  13270. o |= this._gl.DEPTH_BUFFER_BIT),
  13271. n && (this._gl.clearStencil(0),
  13272. o |= this._gl.STENCIL_BUFFER_BIT),
  13273. this._gl.clear(o)
  13274. }
  13275. ,
  13276. e.prototype._viewport = function(e, t, i, n) {
  13277. e === this._viewportCached.x && t === this._viewportCached.y && i === this._viewportCached.z && n === this._viewportCached.w || (this._viewportCached.x = e,
  13278. this._viewportCached.y = t,
  13279. this._viewportCached.z = i,
  13280. this._viewportCached.w = n,
  13281. this._gl.viewport(e, t, i, n))
  13282. }
  13283. ,
  13284. e.prototype.setViewport = function(e, t, i) {
  13285. var n = t || this.getRenderWidth()
  13286. , r = i || this.getRenderHeight()
  13287. , o = e.x || 0
  13288. , a = e.y || 0;
  13289. this._cachedViewport = e,
  13290. this._viewport(o * n, a * r, n * e.width, r * e.height)
  13291. }
  13292. ,
  13293. e.prototype.beginFrame = function() {}
  13294. ,
  13295. e.prototype.endFrame = function() {
  13296. this._badOS && this.flushFramebuffer(),
  13297. this._frameId++
  13298. }
  13299. ,
  13300. e.prototype.resize = function(e) {
  13301. var t, i;
  13302. if (void 0 === e && (e = !1),
  13303. this._adaptToDeviceRatio) {
  13304. var n = nt() && window.devicePixelRatio || 1
  13305. , r = this._creationOptions.limitDeviceRatio || n;
  13306. this._hardwareScalingLevel = this._adaptToDeviceRatio ? 1 / Math.min(r, n) : 1
  13307. }
  13308. nt() ? (t = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
  13309. i = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (t = this._renderingCanvas ? this._renderingCanvas.width : 100,
  13310. i = this._renderingCanvas ? this._renderingCanvas.height : 100),
  13311. this.setSize(t / this._hardwareScalingLevel, i / this._hardwareScalingLevel, e)
  13312. }
  13313. ,
  13314. e.prototype.setSize = function(e, t, i) {
  13315. return void 0 === i && (i = !1),
  13316. !(!this._renderingCanvas || (e |= 0,
  13317. t |= 0,
  13318. !i && this._renderingCanvas.width === e && this._renderingCanvas.height === t || (this._renderingCanvas.width = e,
  13319. this._renderingCanvas.height = t,
  13320. 0)))
  13321. }
  13322. ,
  13323. e.prototype.bindFramebuffer = function(e, t, i, n, r, o, a) {
  13324. var s, l, c, u, h;
  13325. void 0 === t && (t = 0),
  13326. void 0 === o && (o = 0),
  13327. void 0 === a && (a = 0);
  13328. var d = e;
  13329. this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  13330. this._currentRenderTarget = e,
  13331. this._bindUnboundFramebuffer(d._MSAAFramebuffer ? d._MSAAFramebuffer : d._framebuffer);
  13332. var p = this._gl;
  13333. e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, null === (s = e.texture._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource, o, a) : e.isCube && p.framebufferTexture2D(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (l = e.texture._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, o);
  13334. var f = e._depthStencilTexture;
  13335. if (f) {
  13336. var _ = e._depthStencilTextureWithStencil ? p.DEPTH_STENCIL_ATTACHMENT : p.DEPTH_ATTACHMENT;
  13337. e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, _, null === (c = f._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, o, a) : e.isCube ? p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (u = f._hardwareTexture) || void 0 === u ? void 0 : u.underlyingResource, o) : p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_2D, null === (h = f._hardwareTexture) || void 0 === h ? void 0 : h.underlyingResource, o)
  13338. }
  13339. this._cachedViewport && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
  13340. o && (i /= Math.pow(2, o))),
  13341. n || (n = e.height,
  13342. o && (n /= Math.pow(2, o))),
  13343. this._viewport(0, 0, i, n)),
  13344. this.wipeCaches()
  13345. }
  13346. ,
  13347. e.prototype.setState = function(e, t, i, n, r, o, a) {
  13348. var s, l;
  13349. void 0 === t && (t = 0),
  13350. void 0 === n && (n = !1),
  13351. void 0 === a && (a = 0),
  13352. (this._depthCullingState.cull !== e || i) && (this._depthCullingState.cull = e);
  13353. var c = null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? this._gl.BACK : this._gl.FRONT;
  13354. (this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c),
  13355. this.setZOffset(t),
  13356. this.setZOffsetUnits(a);
  13357. var u = n ? this._gl.CW : this._gl.CCW;
  13358. (this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u),
  13359. this._stencilStateComposer.stencilMaterial = o
  13360. }
  13361. ,
  13362. e.prototype.setZOffset = function(e) {
  13363. this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -e : e
  13364. }
  13365. ,
  13366. e.prototype.getZOffset = function() {
  13367. var e = this._depthCullingState.zOffset;
  13368. return this.useReverseDepthBuffer ? -e : e
  13369. }
  13370. ,
  13371. e.prototype.setZOffsetUnits = function(e) {
  13372. this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -e : e
  13373. }
  13374. ,
  13375. e.prototype.getZOffsetUnits = function() {
  13376. var e = this._depthCullingState.zOffsetUnits;
  13377. return this.useReverseDepthBuffer ? -e : e
  13378. }
  13379. ,
  13380. e.prototype._bindUnboundFramebuffer = function(e) {
  13381. this._currentFramebuffer !== e && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, e),
  13382. this._currentFramebuffer = e)
  13383. }
  13384. ,
  13385. e.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
  13386. return null === this._currentFramebuffer
  13387. }
  13388. ,
  13389. e.prototype.generateMipmaps = function(e) {
  13390. this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
  13391. this._gl.generateMipmap(this._gl.TEXTURE_2D),
  13392. this._bindTextureDirectly(this._gl.TEXTURE_2D, null)
  13393. }
  13394. ,
  13395. e.prototype.unBindFramebuffer = function(e, t, i) {
  13396. var n;
  13397. void 0 === t && (t = !1);
  13398. var r = e;
  13399. this._currentRenderTarget = null;
  13400. var o = this._gl;
  13401. if (r._MSAAFramebuffer) {
  13402. if (e.isMulti)
  13403. return void this.unBindMultiColorAttachmentFramebuffer(e, t, i);
  13404. o.bindFramebuffer(o.READ_FRAMEBUFFER, r._MSAAFramebuffer),
  13405. o.bindFramebuffer(o.DRAW_FRAMEBUFFER, r._framebuffer),
  13406. o.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, o.COLOR_BUFFER_BIT, o.NEAREST)
  13407. }
  13408. !(null === (n = e.texture) || void 0 === n ? void 0 : n.generateMipMaps) || t || e.isCube || this.generateMipmaps(e.texture),
  13409. i && (r._MSAAFramebuffer && this._bindUnboundFramebuffer(r._framebuffer),
  13410. i()),
  13411. this._bindUnboundFramebuffer(null)
  13412. }
  13413. ,
  13414. e.prototype.flushFramebuffer = function() {
  13415. this._gl.flush()
  13416. }
  13417. ,
  13418. e.prototype.restoreDefaultFramebuffer = function() {
  13419. this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null),
  13420. this._cachedViewport && this.setViewport(this._cachedViewport),
  13421. this.wipeCaches()
  13422. }
  13423. ,
  13424. e.prototype._resetVertexBufferBinding = function() {
  13425. this.bindArrayBuffer(null),
  13426. this._cachedVertexBuffers = null
  13427. }
  13428. ,
  13429. e.prototype.createVertexBuffer = function(e) {
  13430. return this._createVertexBuffer(e, this._gl.STATIC_DRAW)
  13431. }
  13432. ,
  13433. e.prototype._createVertexBuffer = function(e, t) {
  13434. var i = this._gl.createBuffer();
  13435. if (!i)
  13436. throw new Error("Unable to create vertex buffer");
  13437. var n = new Ut(i);
  13438. return this.bindArrayBuffer(n),
  13439. e instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(e), t) : this._gl.bufferData(this._gl.ARRAY_BUFFER, e, t),
  13440. this._resetVertexBufferBinding(),
  13441. n.references = 1,
  13442. n
  13443. }
  13444. ,
  13445. e.prototype.createDynamicVertexBuffer = function(e) {
  13446. return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW)
  13447. }
  13448. ,
  13449. e.prototype._resetIndexBufferBinding = function() {
  13450. this.bindIndexBuffer(null),
  13451. this._cachedIndexBuffer = null
  13452. }
  13453. ,
  13454. e.prototype.createIndexBuffer = function(e, t) {
  13455. var i = this._gl.createBuffer()
  13456. , n = new Ut(i);
  13457. if (!i)
  13458. throw new Error("Unable to create index buffer");
  13459. this.bindIndexBuffer(n);
  13460. var r = this._normalizeIndexData(e);
  13461. return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, r, t ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
  13462. this._resetIndexBufferBinding(),
  13463. n.references = 1,
  13464. n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
  13465. n
  13466. }
  13467. ,
  13468. e.prototype._normalizeIndexData = function(e) {
  13469. if (2 === e.BYTES_PER_ELEMENT)
  13470. return e;
  13471. if (this._caps.uintIndices) {
  13472. if (e instanceof Uint32Array)
  13473. return e;
  13474. for (var t = 0; t < e.length; t++)
  13475. if (e[t] >= 65535)
  13476. return new Uint32Array(e);
  13477. return new Uint16Array(e)
  13478. }
  13479. return new Uint16Array(e)
  13480. }
  13481. ,
  13482. e.prototype.bindArrayBuffer = function(e) {
  13483. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  13484. this._bindBuffer(e, this._gl.ARRAY_BUFFER)
  13485. }
  13486. ,
  13487. e.prototype.bindUniformBlock = function(e, t, i) {
  13488. var n = e.program
  13489. , r = this._gl.getUniformBlockIndex(n, t);
  13490. this._gl.uniformBlockBinding(n, r, i)
  13491. }
  13492. ,
  13493. e.prototype.bindIndexBuffer = function(e) {
  13494. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  13495. this._bindBuffer(e, this._gl.ELEMENT_ARRAY_BUFFER)
  13496. }
  13497. ,
  13498. e.prototype._bindBuffer = function(e, t) {
  13499. (this._vaoRecordInProgress || this._currentBoundBuffer[t] !== e) && (this._gl.bindBuffer(t, e ? e.underlyingResource : null),
  13500. this._currentBoundBuffer[t] = e)
  13501. }
  13502. ,
  13503. e.prototype.updateArrayBuffer = function(e) {
  13504. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)
  13505. }
  13506. ,
  13507. e.prototype._vertexAttribPointer = function(e, t, i, n, r, o, a) {
  13508. var s = this._currentBufferPointers[t];
  13509. if (s) {
  13510. var l = !1;
  13511. s.active ? (s.buffer !== e && (s.buffer = e,
  13512. l = !0),
  13513. s.size !== i && (s.size = i,
  13514. l = !0),
  13515. s.type !== n && (s.type = n,
  13516. l = !0),
  13517. s.normalized !== r && (s.normalized = r,
  13518. l = !0),
  13519. s.stride !== o && (s.stride = o,
  13520. l = !0),
  13521. s.offset !== a && (s.offset = a,
  13522. l = !0)) : (l = !0,
  13523. s.active = !0,
  13524. s.index = t,
  13525. s.size = i,
  13526. s.type = n,
  13527. s.normalized = r,
  13528. s.stride = o,
  13529. s.offset = a,
  13530. s.buffer = e),
  13531. (l || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
  13532. this._gl.vertexAttribPointer(t, i, n, r, o, a))
  13533. }
  13534. }
  13535. ,
  13536. e.prototype._bindIndexBufferWithCache = function(e) {
  13537. null != e && this._cachedIndexBuffer !== e && (this._cachedIndexBuffer = e,
  13538. this.bindIndexBuffer(e),
  13539. this._uintIndicesCurrentlySet = e.is32Bits)
  13540. }
  13541. ,
  13542. e.prototype._bindVertexBuffersAttributes = function(e, t, i) {
  13543. var n = t.getAttributesNames();
  13544. this._vaoRecordInProgress || this._unbindVertexArrayObject(),
  13545. this.unbindAllAttributes();
  13546. for (var r = 0; r < n.length; r++) {
  13547. var o = t.getAttributeLocation(r);
  13548. if (o >= 0) {
  13549. var a = n[r]
  13550. , s = null;
  13551. if (i && (s = i[a]),
  13552. s || (s = e[a]),
  13553. !s)
  13554. continue;
  13555. this._gl.enableVertexAttribArray(o),
  13556. this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[o] = !0);
  13557. var l = s.getBuffer();
  13558. l && (this._vertexAttribPointer(l, o, s.getSize(), s.type, s.normalized, s.byteStride, s.byteOffset),
  13559. s.getIsInstanced() && (this._gl.vertexAttribDivisor(o, s.getInstanceDivisor()),
  13560. this._vaoRecordInProgress || (this._currentInstanceLocations.push(o),
  13561. this._currentInstanceBuffers.push(l))))
  13562. }
  13563. }
  13564. }
  13565. ,
  13566. e.prototype.recordVertexArrayObject = function(e, t, i, n) {
  13567. var r = this._gl.createVertexArray();
  13568. return this._vaoRecordInProgress = !0,
  13569. this._gl.bindVertexArray(r),
  13570. this._mustWipeVertexAttributes = !0,
  13571. this._bindVertexBuffersAttributes(e, i, n),
  13572. this.bindIndexBuffer(t),
  13573. this._vaoRecordInProgress = !1,
  13574. this._gl.bindVertexArray(null),
  13575. r
  13576. }
  13577. ,
  13578. e.prototype.bindVertexArrayObject = function(e, t) {
  13579. this._cachedVertexArrayObject !== e && (this._cachedVertexArrayObject = e,
  13580. this._gl.bindVertexArray(e),
  13581. this._cachedVertexBuffers = null,
  13582. this._cachedIndexBuffer = null,
  13583. this._uintIndicesCurrentlySet = null != t && t.is32Bits,
  13584. this._mustWipeVertexAttributes = !0)
  13585. }
  13586. ,
  13587. e.prototype.bindBuffersDirectly = function(e, t, i, n, r) {
  13588. if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== r) {
  13589. this._cachedVertexBuffers = e,
  13590. this._cachedEffectForVertexBuffers = r;
  13591. var o = r.getAttributesCount();
  13592. this._unbindVertexArrayObject(),
  13593. this.unbindAllAttributes();
  13594. for (var a = 0, s = 0; s < o; s++)
  13595. if (s < i.length) {
  13596. var l = r.getAttributeLocation(s);
  13597. l >= 0 && (this._gl.enableVertexAttribArray(l),
  13598. this._vertexAttribArraysEnabled[l] = !0,
  13599. this._vertexAttribPointer(e, l, i[s], this._gl.FLOAT, !1, n, a)),
  13600. a += 4 * i[s]
  13601. }
  13602. }
  13603. this._bindIndexBufferWithCache(t)
  13604. }
  13605. ,
  13606. e.prototype._unbindVertexArrayObject = function() {
  13607. this._cachedVertexArrayObject && (this._cachedVertexArrayObject = null,
  13608. this._gl.bindVertexArray(null))
  13609. }
  13610. ,
  13611. e.prototype.bindBuffers = function(e, t, i, n) {
  13612. this._cachedVertexBuffers === e && this._cachedEffectForVertexBuffers === i || (this._cachedVertexBuffers = e,
  13613. this._cachedEffectForVertexBuffers = i,
  13614. this._bindVertexBuffersAttributes(e, i, n)),
  13615. this._bindIndexBufferWithCache(t)
  13616. }
  13617. ,
  13618. e.prototype.unbindInstanceAttributes = function() {
  13619. for (var e, t = 0, i = this._currentInstanceLocations.length; t < i; t++) {
  13620. var n = this._currentInstanceBuffers[t];
  13621. e != n && n.references && (e = n,
  13622. this.bindArrayBuffer(n));
  13623. var r = this._currentInstanceLocations[t];
  13624. this._gl.vertexAttribDivisor(r, 0)
  13625. }
  13626. this._currentInstanceBuffers.length = 0,
  13627. this._currentInstanceLocations.length = 0
  13628. }
  13629. ,
  13630. e.prototype.releaseVertexArrayObject = function(e) {
  13631. this._gl.deleteVertexArray(e)
  13632. }
  13633. ,
  13634. e.prototype._releaseBuffer = function(e) {
  13635. return e.references--,
  13636. 0 === e.references && (this._deleteBuffer(e),
  13637. !0)
  13638. }
  13639. ,
  13640. e.prototype._deleteBuffer = function(e) {
  13641. this._gl.deleteBuffer(e.underlyingResource)
  13642. }
  13643. ,
  13644. e.prototype.updateAndBindInstancesBuffer = function(e, t, i) {
  13645. if (this.bindArrayBuffer(e),
  13646. t && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t),
  13647. void 0 !== i[0].index)
  13648. this.bindInstancesBuffer(e, i, !0);
  13649. else
  13650. for (var n = 0; n < 4; n++) {
  13651. var r = i[n];
  13652. this._vertexAttribArraysEnabled[r] || (this._gl.enableVertexAttribArray(r),
  13653. this._vertexAttribArraysEnabled[r] = !0),
  13654. this._vertexAttribPointer(e, r, 4, this._gl.FLOAT, !1, 64, 16 * n),
  13655. this._gl.vertexAttribDivisor(r, 1),
  13656. this._currentInstanceLocations.push(r),
  13657. this._currentInstanceBuffers.push(e)
  13658. }
  13659. }
  13660. ,
  13661. e.prototype.bindInstancesBuffer = function(e, t, i) {
  13662. void 0 === i && (i = !0),
  13663. this.bindArrayBuffer(e);
  13664. var n = 0;
  13665. if (i)
  13666. for (var r = 0; r < t.length; r++)
  13667. n += 4 * (o = t[r]).attributeSize;
  13668. for (r = 0; r < t.length; r++) {
  13669. var o;
  13670. void 0 === (o = t[r]).index && (o.index = this._currentEffect.getAttributeLocationByName(o.attributeName)),
  13671. o.index < 0 || (this._vertexAttribArraysEnabled[o.index] || (this._gl.enableVertexAttribArray(o.index),
  13672. this._vertexAttribArraysEnabled[o.index] = !0),
  13673. this._vertexAttribPointer(e, o.index, o.attributeSize, o.attributeType || this._gl.FLOAT, o.normalized || !1, n, o.offset),
  13674. this._gl.vertexAttribDivisor(o.index, void 0 === o.divisor ? 1 : o.divisor),
  13675. this._currentInstanceLocations.push(o.index),
  13676. this._currentInstanceBuffers.push(e))
  13677. }
  13678. }
  13679. ,
  13680. e.prototype.disableInstanceAttributeByName = function(e) {
  13681. if (this._currentEffect) {
  13682. var t = this._currentEffect.getAttributeLocationByName(e);
  13683. this.disableInstanceAttribute(t)
  13684. }
  13685. }
  13686. ,
  13687. e.prototype.disableInstanceAttribute = function(e) {
  13688. for (var t, i = !1; -1 !== (t = this._currentInstanceLocations.indexOf(e)); )
  13689. this._currentInstanceLocations.splice(t, 1),
  13690. this._currentInstanceBuffers.splice(t, 1),
  13691. i = !0,
  13692. t = this._currentInstanceLocations.indexOf(e);
  13693. i && (this._gl.vertexAttribDivisor(e, 0),
  13694. this.disableAttributeByIndex(e))
  13695. }
  13696. ,
  13697. e.prototype.disableAttributeByIndex = function(e) {
  13698. this._gl.disableVertexAttribArray(e),
  13699. this._vertexAttribArraysEnabled[e] = !1,
  13700. this._currentBufferPointers[e].active = !1
  13701. }
  13702. ,
  13703. e.prototype.draw = function(e, t, i, n) {
  13704. this.drawElementsType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
  13705. }
  13706. ,
  13707. e.prototype.drawPointClouds = function(e, t, i) {
  13708. this.drawArraysType(a.MATERIAL_PointFillMode, e, t, i)
  13709. }
  13710. ,
  13711. e.prototype.drawUnIndexed = function(e, t, i, n) {
  13712. this.drawArraysType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
  13713. }
  13714. ,
  13715. e.prototype.drawElementsType = function(e, t, i, n) {
  13716. this.applyStates(),
  13717. this._reportDrawCall();
  13718. var r = this._drawMode(e)
  13719. , o = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
  13720. , a = this._uintIndicesCurrentlySet ? 4 : 2;
  13721. n ? this._gl.drawElementsInstanced(r, i, o, t * a, n) : this._gl.drawElements(r, i, o, t * a)
  13722. }
  13723. ,
  13724. e.prototype.drawArraysType = function(e, t, i, n) {
  13725. this.applyStates(),
  13726. this._reportDrawCall();
  13727. var r = this._drawMode(e);
  13728. n ? this._gl.drawArraysInstanced(r, t, i, n) : this._gl.drawArrays(r, t, i)
  13729. }
  13730. ,
  13731. e.prototype._drawMode = function(e) {
  13732. switch (e) {
  13733. case a.MATERIAL_TriangleFillMode:
  13734. return this._gl.TRIANGLES;
  13735. case a.MATERIAL_PointFillMode:
  13736. return this._gl.POINTS;
  13737. case a.MATERIAL_WireFrameFillMode:
  13738. return this._gl.LINES;
  13739. case a.MATERIAL_PointListDrawMode:
  13740. return this._gl.POINTS;
  13741. case a.MATERIAL_LineListDrawMode:
  13742. return this._gl.LINES;
  13743. case a.MATERIAL_LineLoopDrawMode:
  13744. return this._gl.LINE_LOOP;
  13745. case a.MATERIAL_LineStripDrawMode:
  13746. return this._gl.LINE_STRIP;
  13747. case a.MATERIAL_TriangleStripDrawMode:
  13748. return this._gl.TRIANGLE_STRIP;
  13749. case a.MATERIAL_TriangleFanDrawMode:
  13750. return this._gl.TRIANGLE_FAN;
  13751. default:
  13752. return this._gl.TRIANGLES
  13753. }
  13754. }
  13755. ,
  13756. e.prototype._reportDrawCall = function() {}
  13757. ,
  13758. e.prototype._releaseEffect = function(e) {
  13759. if (this._compiledEffects[e._key]) {
  13760. delete this._compiledEffects[e._key];
  13761. var t = e.getPipelineContext();
  13762. t && this._deletePipelineContext(t)
  13763. }
  13764. }
  13765. ,
  13766. e.prototype._deletePipelineContext = function(e) {
  13767. var t = e;
  13768. t && t.program && (t.program.__SPECTOR_rebuildProgram = null,
  13769. this._gl.deleteProgram(t.program))
  13770. }
  13771. ,
  13772. e.prototype._getGlobalDefines = function(e) {
  13773. if (e)
  13774. return this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE,
  13775. void (this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER);
  13776. var t = "";
  13777. return this.isNDCHalfZRange && (t += "#define IS_NDC_HALF_ZRANGE"),
  13778. this.useReverseDepthBuffer && (t && (t += "\n"),
  13779. t += "#define USE_REVERSE_DEPTHBUFFER"),
  13780. t
  13781. }
  13782. ,
  13783. e.prototype.createEffect = function(e, t, i, n, r, o, a, s, l, c) {
  13784. var u;
  13785. void 0 === c && (c = st.GLSL);
  13786. var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
  13787. , d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
  13788. , p = this._getGlobalDefines()
  13789. , f = null !== (u = null != r ? r : t.defines) && void 0 !== u ? u : "";
  13790. p && (f += p);
  13791. var _ = h + "+" + d + "@" + f;
  13792. if (this._compiledEffects[_]) {
  13793. var m = this._compiledEffects[_];
  13794. return a && m.isReady() && a(m),
  13795. m
  13796. }
  13797. var g = new Mt(e,t,i,n,this,r,o,a,s,l,_,c);
  13798. return this._compiledEffects[_] = g,
  13799. g
  13800. }
  13801. ,
  13802. e._ConcatenateShader = function(e, t, i) {
  13803. return void 0 === i && (i = ""),
  13804. i + (t ? t + "\n" : "") + e
  13805. }
  13806. ,
  13807. e.prototype._compileShader = function(t, i, n, r) {
  13808. return this._compileRawShader(e._ConcatenateShader(t, n, r), i)
  13809. }
  13810. ,
  13811. e.prototype._compileRawShader = function(e, t) {
  13812. for (var i = this._gl; i.getError() != i.NO_ERROR; )
  13813. ;
  13814. var n = i.createShader("vertex" === t ? i.VERTEX_SHADER : i.FRAGMENT_SHADER);
  13815. if (!n)
  13816. throw new Error("Something went wrong while creating a gl ".concat(t, " shader object. gl error=").concat(i.getError(), ", gl isContextLost=").concat(i.isContextLost(), ", _contextWasLost=").concat(this._contextWasLost));
  13817. return i.shaderSource(n, e),
  13818. i.compileShader(n),
  13819. n
  13820. }
  13821. ,
  13822. e.prototype._getShaderSource = function(e) {
  13823. return this._gl.getShaderSource(e)
  13824. }
  13825. ,
  13826. e.prototype.createRawShaderProgram = function(e, t, i, n, r) {
  13827. void 0 === r && (r = null),
  13828. n = n || this._gl;
  13829. var o = this._compileRawShader(t, "vertex")
  13830. , a = this._compileRawShader(i, "fragment");
  13831. return this._createShaderProgram(e, o, a, n, r)
  13832. }
  13833. ,
  13834. e.prototype.createShaderProgram = function(e, t, i, n, r, o) {
  13835. void 0 === o && (o = null),
  13836. r = r || this._gl;
  13837. var a = this._webGLVersion > 1 ? "#version 300 es\n#define WEBGL2 \n" : ""
  13838. , s = this._compileShader(t, "vertex", n, a)
  13839. , l = this._compileShader(i, "fragment", n, a);
  13840. return this._createShaderProgram(e, s, l, r, o)
  13841. }
  13842. ,
  13843. e.prototype.inlineShaderCode = function(e) {
  13844. return e
  13845. }
  13846. ,
  13847. e.prototype.createPipelineContext = function(e) {
  13848. var t = new Vt;
  13849. return t.engine = this,
  13850. this._caps.parallelShaderCompile && (t.isParallelCompiled = !0),
  13851. t
  13852. }
  13853. ,
  13854. e.prototype.createMaterialContext = function() {}
  13855. ,
  13856. e.prototype.createDrawContext = function() {}
  13857. ,
  13858. e.prototype._createShaderProgram = function(e, t, i, n, r) {
  13859. void 0 === r && (r = null);
  13860. var o = n.createProgram();
  13861. if (e.program = o,
  13862. !o)
  13863. throw new Error("Unable to create program");
  13864. return n.attachShader(o, t),
  13865. n.attachShader(o, i),
  13866. n.linkProgram(o),
  13867. e.context = n,
  13868. e.vertexShader = t,
  13869. e.fragmentShader = i,
  13870. e.isParallelCompiled || this._finalizePipelineContext(e),
  13871. o
  13872. }
  13873. ,
  13874. e.prototype._finalizePipelineContext = function(e) {
  13875. var t = e.context
  13876. , i = e.vertexShader
  13877. , n = e.fragmentShader
  13878. , r = e.program;
  13879. if (!t.getProgramParameter(r, t.LINK_STATUS)) {
  13880. var o, a;
  13881. if (!this._gl.getShaderParameter(i, this._gl.COMPILE_STATUS) && (o = this._gl.getShaderInfoLog(i)))
  13882. throw e.vertexCompilationError = o,
  13883. new Error("VERTEX SHADER " + o);
  13884. if (!this._gl.getShaderParameter(n, this._gl.COMPILE_STATUS) && (o = this._gl.getShaderInfoLog(n)))
  13885. throw e.fragmentCompilationError = o,
  13886. new Error("FRAGMENT SHADER " + o);
  13887. if (a = t.getProgramInfoLog(r))
  13888. throw e.programLinkError = a,
  13889. new Error(a)
  13890. }
  13891. if (this.validateShaderPrograms && (t.validateProgram(r),
  13892. !t.getProgramParameter(r, t.VALIDATE_STATUS) && (a = t.getProgramInfoLog(r))))
  13893. throw e.programValidationError = a,
  13894. new Error(a);
  13895. t.deleteShader(i),
  13896. t.deleteShader(n),
  13897. e.vertexShader = void 0,
  13898. e.fragmentShader = void 0,
  13899. e.onCompiled && (e.onCompiled(),
  13900. e.onCompiled = void 0)
  13901. }
  13902. ,
  13903. e.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l, c) {
  13904. var u = e;
  13905. u.program = n ? this.createRawShaderProgram(u, t, i, void 0, l) : this.createShaderProgram(u, t, i, s, void 0, l),
  13906. u.program.__SPECTOR_rebuildProgram = a
  13907. }
  13908. ,
  13909. e.prototype._isRenderingStateCompiled = function(e) {
  13910. var t = e;
  13911. return !!this._gl.getProgramParameter(t.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) && (this._finalizePipelineContext(t),
  13912. !0)
  13913. }
  13914. ,
  13915. e.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
  13916. var i = e;
  13917. if (i.isParallelCompiled) {
  13918. var n = i.onCompiled;
  13919. i.onCompiled = n ? function() {
  13920. n(),
  13921. t()
  13922. }
  13923. : t
  13924. } else
  13925. t()
  13926. }
  13927. ,
  13928. e.prototype.getUniforms = function(e, t) {
  13929. for (var i = new Array, n = e, r = 0; r < t.length; r++)
  13930. i.push(this._gl.getUniformLocation(n.program, t[r]));
  13931. return i
  13932. }
  13933. ,
  13934. e.prototype.getAttributes = function(e, t) {
  13935. for (var i = [], n = e, r = 0; r < t.length; r++)
  13936. try {
  13937. i.push(this._gl.getAttribLocation(n.program, t[r]))
  13938. } catch (e) {
  13939. i.push(-1)
  13940. }
  13941. return i
  13942. }
  13943. ,
  13944. e.prototype.enableEffect = function(e) {
  13945. (e = null !== e && Gt.IsWrapper(e) ? e.effect : e) && e !== this._currentEffect && (this._stencilStateComposer.stencilMaterial = void 0,
  13946. e = e,
  13947. this.bindSamplers(e),
  13948. this._currentEffect = e,
  13949. e.onBind && e.onBind(e),
  13950. e._onBindObservable && e._onBindObservable.notifyObservers(e))
  13951. }
  13952. ,
  13953. e.prototype.setInt = function(e, t) {
  13954. return !!e && (this._gl.uniform1i(e, t),
  13955. !0)
  13956. }
  13957. ,
  13958. e.prototype.setInt2 = function(e, t, i) {
  13959. return !!e && (this._gl.uniform2i(e, t, i),
  13960. !0)
  13961. }
  13962. ,
  13963. e.prototype.setInt3 = function(e, t, i, n) {
  13964. return !!e && (this._gl.uniform3i(e, t, i, n),
  13965. !0)
  13966. }
  13967. ,
  13968. e.prototype.setInt4 = function(e, t, i, n, r) {
  13969. return !!e && (this._gl.uniform4i(e, t, i, n, r),
  13970. !0)
  13971. }
  13972. ,
  13973. e.prototype.setIntArray = function(e, t) {
  13974. return !!e && (this._gl.uniform1iv(e, t),
  13975. !0)
  13976. }
  13977. ,
  13978. e.prototype.setIntArray2 = function(e, t) {
  13979. return !(!e || t.length % 2 != 0 || (this._gl.uniform2iv(e, t),
  13980. 0))
  13981. }
  13982. ,
  13983. e.prototype.setIntArray3 = function(e, t) {
  13984. return !(!e || t.length % 3 != 0 || (this._gl.uniform3iv(e, t),
  13985. 0))
  13986. }
  13987. ,
  13988. e.prototype.setIntArray4 = function(e, t) {
  13989. return !(!e || t.length % 4 != 0 || (this._gl.uniform4iv(e, t),
  13990. 0))
  13991. }
  13992. ,
  13993. e.prototype.setArray = function(e, t) {
  13994. return !(!e || t.length < 1 || (this._gl.uniform1fv(e, t),
  13995. 0))
  13996. }
  13997. ,
  13998. e.prototype.setArray2 = function(e, t) {
  13999. return !(!e || t.length % 2 != 0 || (this._gl.uniform2fv(e, t),
  14000. 0))
  14001. }
  14002. ,
  14003. e.prototype.setArray3 = function(e, t) {
  14004. return !(!e || t.length % 3 != 0 || (this._gl.uniform3fv(e, t),
  14005. 0))
  14006. }
  14007. ,
  14008. e.prototype.setArray4 = function(e, t) {
  14009. return !(!e || t.length % 4 != 0 || (this._gl.uniform4fv(e, t),
  14010. 0))
  14011. }
  14012. ,
  14013. e.prototype.setMatrices = function(e, t) {
  14014. return !!e && (this._gl.uniformMatrix4fv(e, !1, t),
  14015. !0)
  14016. }
  14017. ,
  14018. e.prototype.setMatrix3x3 = function(e, t) {
  14019. return !!e && (this._gl.uniformMatrix3fv(e, !1, t),
  14020. !0)
  14021. }
  14022. ,
  14023. e.prototype.setMatrix2x2 = function(e, t) {
  14024. return !!e && (this._gl.uniformMatrix2fv(e, !1, t),
  14025. !0)
  14026. }
  14027. ,
  14028. e.prototype.setFloat = function(e, t) {
  14029. return !!e && (this._gl.uniform1f(e, t),
  14030. !0)
  14031. }
  14032. ,
  14033. e.prototype.setFloat2 = function(e, t, i) {
  14034. return !!e && (this._gl.uniform2f(e, t, i),
  14035. !0)
  14036. }
  14037. ,
  14038. e.prototype.setFloat3 = function(e, t, i, n) {
  14039. return !!e && (this._gl.uniform3f(e, t, i, n),
  14040. !0)
  14041. }
  14042. ,
  14043. e.prototype.setFloat4 = function(e, t, i, n, r) {
  14044. return !!e && (this._gl.uniform4f(e, t, i, n, r),
  14045. !0)
  14046. }
  14047. ,
  14048. e.prototype.applyStates = function() {
  14049. if (this._depthCullingState.apply(this._gl),
  14050. this._stencilStateComposer.apply(this._gl),
  14051. this._alphaState.apply(this._gl),
  14052. this._colorWriteChanged) {
  14053. this._colorWriteChanged = !1;
  14054. var e = this._colorWrite;
  14055. this._gl.colorMask(e, e, e, e)
  14056. }
  14057. }
  14058. ,
  14059. e.prototype.setColorWrite = function(e) {
  14060. e !== this._colorWrite && (this._colorWriteChanged = !0,
  14061. this._colorWrite = e)
  14062. }
  14063. ,
  14064. e.prototype.getColorWrite = function() {
  14065. return this._colorWrite
  14066. }
  14067. ,
  14068. Object.defineProperty(e.prototype, "depthCullingState", {
  14069. get: function() {
  14070. return this._depthCullingState
  14071. },
  14072. enumerable: !1,
  14073. configurable: !0
  14074. }),
  14075. Object.defineProperty(e.prototype, "alphaState", {
  14076. get: function() {
  14077. return this._alphaState
  14078. },
  14079. enumerable: !1,
  14080. configurable: !0
  14081. }),
  14082. Object.defineProperty(e.prototype, "stencilState", {
  14083. get: function() {
  14084. return this._stencilState
  14085. },
  14086. enumerable: !1,
  14087. configurable: !0
  14088. }),
  14089. Object.defineProperty(e.prototype, "stencilStateComposer", {
  14090. get: function() {
  14091. return this._stencilStateComposer
  14092. },
  14093. enumerable: !1,
  14094. configurable: !0
  14095. }),
  14096. e.prototype.clearInternalTexturesCache = function() {
  14097. this._internalTexturesCache = []
  14098. }
  14099. ,
  14100. e.prototype.wipeCaches = function(e) {
  14101. this.preventCacheWipeBetweenFrames && !e || (this._currentEffect = null,
  14102. this._viewportCached.x = 0,
  14103. this._viewportCached.y = 0,
  14104. this._viewportCached.z = 0,
  14105. this._viewportCached.w = 0,
  14106. this._unbindVertexArrayObject(),
  14107. e && (this._currentProgram = null,
  14108. this.resetTextureCache(),
  14109. this._stencilStateComposer.reset(),
  14110. this._depthCullingState.reset(),
  14111. this._depthCullingState.depthFunc = this._gl.LEQUAL,
  14112. this._alphaState.reset(),
  14113. this._alphaMode = a.ALPHA_ADD,
  14114. this._alphaEquation = a.ALPHA_DISABLE,
  14115. this._colorWrite = !0,
  14116. this._colorWriteChanged = !0,
  14117. this._unpackFlipYCached = null,
  14118. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
  14119. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
  14120. this._mustWipeVertexAttributes = !0,
  14121. this.unbindAllAttributes()),
  14122. this._resetVertexBufferBinding(),
  14123. this._cachedIndexBuffer = null,
  14124. this._cachedEffectForVertexBuffers = null,
  14125. this.bindIndexBuffer(null))
  14126. }
  14127. ,
  14128. e.prototype._getSamplingParameters = function(e, t) {
  14129. var i = this._gl
  14130. , n = i.NEAREST
  14131. , r = i.NEAREST;
  14132. switch (e) {
  14133. case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
  14134. n = i.LINEAR,
  14135. r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
  14136. break;
  14137. case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
  14138. n = i.LINEAR,
  14139. r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
  14140. break;
  14141. case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
  14142. n = i.NEAREST,
  14143. r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
  14144. break;
  14145. case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  14146. n = i.NEAREST,
  14147. r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
  14148. break;
  14149. case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  14150. n = i.NEAREST,
  14151. r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
  14152. break;
  14153. case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  14154. n = i.NEAREST,
  14155. r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
  14156. break;
  14157. case a.TEXTURE_NEAREST_LINEAR:
  14158. n = i.NEAREST,
  14159. r = i.LINEAR;
  14160. break;
  14161. case a.TEXTURE_NEAREST_NEAREST:
  14162. n = i.NEAREST,
  14163. r = i.NEAREST;
  14164. break;
  14165. case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  14166. n = i.LINEAR,
  14167. r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
  14168. break;
  14169. case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  14170. n = i.LINEAR,
  14171. r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
  14172. break;
  14173. case a.TEXTURE_LINEAR_LINEAR:
  14174. n = i.LINEAR,
  14175. r = i.LINEAR;
  14176. break;
  14177. case a.TEXTURE_LINEAR_NEAREST:
  14178. n = i.LINEAR,
  14179. r = i.NEAREST
  14180. }
  14181. return {
  14182. min: r,
  14183. mag: n
  14184. }
  14185. }
  14186. ,
  14187. e.prototype._createTexture = function() {
  14188. var e = this._gl.createTexture();
  14189. if (!e)
  14190. throw new Error("Unable to create texture");
  14191. return e
  14192. }
  14193. ,
  14194. e.prototype._createHardwareTexture = function() {
  14195. return new kt(this._createTexture(),this._gl)
  14196. }
  14197. ,
  14198. e.prototype._createInternalTexture = function(e, t, i, n) {
  14199. void 0 === i && (i = !0),
  14200. void 0 === n && (n = At.Unknown);
  14201. var r = {};
  14202. void 0 !== t && "object" == typeof t ? (r.generateMipMaps = t.generateMipMaps,
  14203. r.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
  14204. r.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
  14205. r.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (r.generateMipMaps = t,
  14206. r.type = a.TEXTURETYPE_UNSIGNED_INT,
  14207. r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  14208. r.format = a.TEXTUREFORMAT_RGBA),
  14209. (r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (r.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (r.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
  14210. r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (r.type = a.TEXTURETYPE_UNSIGNED_INT,
  14211. K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
  14212. var o = this._gl
  14213. , s = new Lt(this,n)
  14214. , l = e.width || e
  14215. , c = e.height || e
  14216. , u = e.layers || 0
  14217. , h = this._getSamplingParameters(r.samplingMode, !!r.generateMipMaps)
  14218. , d = 0 !== u ? o.TEXTURE_2D_ARRAY : o.TEXTURE_2D
  14219. , p = this._getRGBABufferInternalSizedFormat(r.type, r.format)
  14220. , f = this._getInternalFormat(r.format)
  14221. , _ = this._getWebGLTextureType(r.type);
  14222. return this._bindTextureDirectly(d, s),
  14223. 0 !== u ? (s.is2DArray = !0,
  14224. o.texImage3D(d, 0, p, l, c, u, 0, f, _, null)) : o.texImage2D(d, 0, p, l, c, 0, f, _, null),
  14225. o.texParameteri(d, o.TEXTURE_MAG_FILTER, h.mag),
  14226. o.texParameteri(d, o.TEXTURE_MIN_FILTER, h.min),
  14227. o.texParameteri(d, o.TEXTURE_WRAP_S, o.CLAMP_TO_EDGE),
  14228. o.texParameteri(d, o.TEXTURE_WRAP_T, o.CLAMP_TO_EDGE),
  14229. r.generateMipMaps && this._gl.generateMipmap(d),
  14230. this._bindTextureDirectly(d, null),
  14231. s.baseWidth = l,
  14232. s.baseHeight = c,
  14233. s.width = l,
  14234. s.height = c,
  14235. s.depth = u,
  14236. s.isReady = !0,
  14237. s.samples = 1,
  14238. s.generateMipMaps = !!r.generateMipMaps,
  14239. s.samplingMode = r.samplingMode,
  14240. s.type = r.type,
  14241. s.format = r.format,
  14242. this._internalTexturesCache.push(s),
  14243. s
  14244. }
  14245. ,
  14246. e.prototype._getUseSRGBBuffer = function(e, t) {
  14247. return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || t)
  14248. }
  14249. ,
  14250. e.prototype._createTextureBase = function(t, i, n, r, o, s, l, c, u, h, d, p, f, _, m, g) {
  14251. var v = this;
  14252. void 0 === o && (o = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  14253. void 0 === s && (s = null),
  14254. void 0 === l && (l = null),
  14255. void 0 === h && (h = null),
  14256. void 0 === d && (d = null),
  14257. void 0 === p && (p = null),
  14258. void 0 === f && (f = null);
  14259. var y = "data:" === (t = t || "").substr(0, 5)
  14260. , b = "blob:" === t.substr(0, 5)
  14261. , T = y && -1 !== t.indexOf(";base64,")
  14262. , S = d || new Lt(this,At.Url)
  14263. , A = t;
  14264. !this._transformTextureUrl || T || d || h || (t = this._transformTextureUrl(t)),
  14265. A !== t && (S._originalUrl = A);
  14266. var x = t.lastIndexOf(".")
  14267. , R = f || (x > -1 ? t.substring(x).toLowerCase() : "")
  14268. , C = null;
  14269. R.indexOf("?") > -1 && (R = R.split("?")[0]);
  14270. for (var P = 0, M = e._TextureLoaders; P < M.length; P++) {
  14271. var I = M[P];
  14272. if (I.canLoad(R, _)) {
  14273. C = I;
  14274. break
  14275. }
  14276. }
  14277. r && r._addPendingData(S),
  14278. S.url = t,
  14279. S.generateMipMaps = !i,
  14280. S.samplingMode = o,
  14281. S.invertY = n,
  14282. S._useSRGBBuffer = this._getUseSRGBBuffer(!!g, i),
  14283. this._doNotHandleContextLost || (S._buffer = h);
  14284. var O = null;
  14285. s && !d && (O = S.onLoadedObservable.add(s)),
  14286. d || this._internalTexturesCache.push(S);
  14287. var D = function(e, n) {
  14288. r && r._removePendingData(S),
  14289. t === A ? (O && S.onLoadedObservable.remove(O),
  14290. E.UseFallbackTexture && v._createTextureBase(E.FallbackTexture, i, S.invertY, r, o, null, l, c, u, h, S),
  14291. e = (e || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""),
  14292. S.onErrorObservable.notifyObservers({
  14293. message: e,
  14294. exception: n
  14295. }),
  14296. l && l(e, n)) : (K.Warn("Failed to load ".concat(t, ", falling back to ").concat(A)),
  14297. v._createTextureBase(A, i, S.invertY, r, o, s, l, c, u, h, S, p, f, _, m, g))
  14298. };
  14299. if (C) {
  14300. var N = function(e) {
  14301. C.loadData(e, S, (function(e, t, i, n, a, s) {
  14302. s ? D("TextureLoader failed to load data") : c(S, R, r, {
  14303. width: e,
  14304. height: t
  14305. }, S.invertY, !i, n, (function() {
  14306. return a(),
  14307. !1
  14308. }
  14309. ), o)
  14310. }
  14311. ), m)
  14312. };
  14313. h ? h instanceof ArrayBuffer ? N(new Uint8Array(h)) : ArrayBuffer.isView(h) ? N(h) : l && l("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(t, (function(e) {
  14314. return N(new Uint8Array(e))
  14315. }
  14316. ), void 0, r ? r.offlineProvider : void 0, !0, (function(e, t) {
  14317. D("Unable to load " + (e && e.responseURL,
  14318. t))
  14319. }
  14320. ))
  14321. } else {
  14322. var L = function(e) {
  14323. b && !v._doNotHandleContextLost && (S._buffer = e),
  14324. c(S, R, r, e, S.invertY, i, !1, u, o)
  14325. };
  14326. !y || T ? h && ("string" == typeof h.decoding || h.close) ? L(h) : e._FileToolsLoadImage(t, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
  14327. imageOrientation: "flipY"
  14328. } : void 0) : "string" == typeof h || h instanceof ArrayBuffer || ArrayBuffer.isView(h) || h instanceof Blob ? e._FileToolsLoadImage(h, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
  14329. imageOrientation: "flipY"
  14330. } : void 0) : h && L(h)
  14331. }
  14332. return S
  14333. }
  14334. ,
  14335. e.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
  14336. var m = this;
  14337. return void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  14338. void 0 === o && (o = null),
  14339. void 0 === s && (s = null),
  14340. void 0 === l && (l = null),
  14341. void 0 === c && (c = null),
  14342. void 0 === u && (u = null),
  14343. void 0 === h && (h = null),
  14344. this._createTextureBase(e, t, i, n, r, o, s, this._prepareWebGLTexture.bind(this), (function(e, t, i, r, o, a) {
  14345. var s = m._gl
  14346. , l = i.width === e && i.height === t
  14347. , c = u ? m._getInternalFormat(u, o._useSRGBBuffer) : ".jpg" !== r || o._useSRGBBuffer ? o._useSRGBBuffer ? s.SRGB8_ALPHA8 : s.RGBA : s.RGB
  14348. , h = u ? m._getInternalFormat(u) : ".jpg" !== r || o._useSRGBBuffer ? s.RGBA : s.RGB;
  14349. if (o._useSRGBBuffer && 1 === m.webGLVersion && (h = c),
  14350. l)
  14351. return s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i),
  14352. !1;
  14353. var d = m._caps.maxTextureSize;
  14354. if (i.width > d || i.height > d || !m._supportsHardwareTextureRescaling)
  14355. return m._prepareWorkingCanvas(),
  14356. !(!m._workingCanvas || !m._workingContext || (m._workingCanvas.width = e,
  14357. m._workingCanvas.height = t,
  14358. m._workingContext.drawImage(i, 0, 0, i.width, i.height, 0, 0, e, t),
  14359. s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, m._workingCanvas),
  14360. o.width = e,
  14361. o.height = t,
  14362. 1));
  14363. var p = new Lt(m,At.Temp);
  14364. return m._bindTextureDirectly(s.TEXTURE_2D, p, !0),
  14365. s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i),
  14366. m._rescaleTexture(p, o, n, c, (function() {
  14367. m._releaseTexture(p),
  14368. m._bindTextureDirectly(s.TEXTURE_2D, o, !0),
  14369. a()
  14370. }
  14371. )),
  14372. !0
  14373. }
  14374. ), l, c, u, h, d, p, _)
  14375. }
  14376. ,
  14377. e._FileToolsLoadImage = function(e, t, i, n, r, o) {
  14378. throw be("FileTools")
  14379. }
  14380. ,
  14381. e.prototype._rescaleTexture = function(e, t, i, n, r) {}
  14382. ,
  14383. e.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
  14384. throw void 0 === l && (l = null),
  14385. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  14386. be("Engine.RawTexture")
  14387. }
  14388. ,
  14389. e.prototype.createRawCubeTexture = function(e, t, i, n, r, o, a, s) {
  14390. throw void 0 === s && (s = null),
  14391. be("Engine.RawTexture")
  14392. }
  14393. ,
  14394. e.prototype.createRawTexture3D = function(e, t, i, n, r, o, s, l, c, u) {
  14395. throw void 0 === c && (c = null),
  14396. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  14397. be("Engine.RawTexture")
  14398. }
  14399. ,
  14400. e.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
  14401. throw void 0 === c && (c = null),
  14402. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  14403. be("Engine.RawTexture")
  14404. }
  14405. ,
  14406. e.prototype._unpackFlipY = function(e) {
  14407. this._unpackFlipYCached !== e && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, e ? 1 : 0),
  14408. this.enableUnpackFlipYCached && (this._unpackFlipYCached = e))
  14409. }
  14410. ,
  14411. e.prototype._getUnpackAlignement = function() {
  14412. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)
  14413. }
  14414. ,
  14415. e.prototype._getTextureTarget = function(e) {
  14416. return e.isCube ? this._gl.TEXTURE_CUBE_MAP : e.is3D ? this._gl.TEXTURE_3D : e.is2DArray || e.isMultiview ? this._gl.TEXTURE_2D_ARRAY : this._gl.TEXTURE_2D
  14417. }
  14418. ,
  14419. e.prototype.updateTextureSamplingMode = function(e, t, i) {
  14420. void 0 === i && (i = !1);
  14421. var n = this._getTextureTarget(t)
  14422. , r = this._getSamplingParameters(e, t.generateMipMaps || i);
  14423. this._setTextureParameterInteger(n, this._gl.TEXTURE_MAG_FILTER, r.mag, t),
  14424. this._setTextureParameterInteger(n, this._gl.TEXTURE_MIN_FILTER, r.min),
  14425. i && (t.generateMipMaps = !0,
  14426. this._gl.generateMipmap(n)),
  14427. this._bindTextureDirectly(n, null),
  14428. t.samplingMode = e
  14429. }
  14430. ,
  14431. e.prototype.updateTextureDimensions = function(e, t, i, n) {
  14432. void 0 === n && (n = 1)
  14433. }
  14434. ,
  14435. e.prototype.updateTextureWrappingMode = function(e, t, i, n) {
  14436. void 0 === i && (i = null),
  14437. void 0 === n && (n = null);
  14438. var r = this._getTextureTarget(e);
  14439. null !== t && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t), e),
  14440. e._cachedWrapU = t),
  14441. null !== i && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i), e),
  14442. e._cachedWrapV = i),
  14443. (e.is2DArray || e.is3D) && null !== n && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(n), e),
  14444. e._cachedWrapR = n),
  14445. this._bindTextureDirectly(r, null)
  14446. }
  14447. ,
  14448. e.prototype._setupDepthStencilTexture = function(e, t, i, n, r, o) {
  14449. void 0 === o && (o = 1);
  14450. var s = t.width || t
  14451. , l = t.height || t
  14452. , c = t.layers || 0;
  14453. e.baseWidth = s,
  14454. e.baseHeight = l,
  14455. e.width = s,
  14456. e.height = l,
  14457. e.is2DArray = c > 0,
  14458. e.depth = c,
  14459. e.isReady = !0,
  14460. e.samples = o,
  14461. e.generateMipMaps = !1,
  14462. e.samplingMode = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
  14463. e.type = a.TEXTURETYPE_UNSIGNED_INT,
  14464. e._comparisonFunction = r;
  14465. var u = this._gl
  14466. , h = this._getTextureTarget(e)
  14467. , d = this._getSamplingParameters(e.samplingMode, !1);
  14468. u.texParameteri(h, u.TEXTURE_MAG_FILTER, d.mag),
  14469. u.texParameteri(h, u.TEXTURE_MIN_FILTER, d.min),
  14470. u.texParameteri(h, u.TEXTURE_WRAP_S, u.CLAMP_TO_EDGE),
  14471. u.texParameteri(h, u.TEXTURE_WRAP_T, u.CLAMP_TO_EDGE),
  14472. 0 === r ? (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, a.LEQUAL),
  14473. u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.NONE)) : (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, r),
  14474. u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.COMPARE_REF_TO_TEXTURE))
  14475. }
  14476. ,
  14477. e.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, s) {
  14478. void 0 === o && (o = 0),
  14479. void 0 === s && (s = 0);
  14480. var l = this._gl
  14481. , c = l.TEXTURE_2D;
  14482. if (e.isCube && (c = l.TEXTURE_CUBE_MAP_POSITIVE_X + o),
  14483. e._useSRGBBuffer)
  14484. switch (t) {
  14485. case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
  14486. t = l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
  14487. break;
  14488. case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
  14489. t = l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
  14490. break;
  14491. case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
  14492. this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : e._useSRGBBuffer = !1;
  14493. break;
  14494. case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
  14495. this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : e._useSRGBBuffer = !1;
  14496. break;
  14497. default:
  14498. e._useSRGBBuffer = !1
  14499. }
  14500. this._gl.compressedTexImage2D(c, s, t, i, n, 0, r)
  14501. }
  14502. ,
  14503. e.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
  14504. void 0 === i && (i = 0),
  14505. void 0 === n && (n = 0),
  14506. void 0 === o && (o = !1);
  14507. var a = this._gl
  14508. , s = this._getWebGLTextureType(e.type)
  14509. , l = this._getInternalFormat(e.format)
  14510. , c = void 0 === r ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(r, e._useSRGBBuffer);
  14511. this._unpackFlipY(e.invertY);
  14512. var u = a.TEXTURE_2D;
  14513. e.isCube && (u = a.TEXTURE_CUBE_MAP_POSITIVE_X + i);
  14514. var h = Math.round(Math.log(e.width) * Math.LOG2E)
  14515. , d = Math.round(Math.log(e.height) * Math.LOG2E)
  14516. , p = o ? e.width : Math.pow(2, Math.max(h - n, 0))
  14517. , f = o ? e.height : Math.pow(2, Math.max(d - n, 0));
  14518. a.texImage2D(u, n, c, p, f, 0, l, s, t)
  14519. }
  14520. ,
  14521. e.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
  14522. void 0 === a && (a = 0),
  14523. void 0 === s && (s = 0);
  14524. var l = this._gl
  14525. , c = this._getWebGLTextureType(e.type)
  14526. , u = this._getInternalFormat(e.format);
  14527. this._unpackFlipY(e.invertY);
  14528. var h = l.TEXTURE_2D;
  14529. e.isCube && (h = l.TEXTURE_CUBE_MAP_POSITIVE_X + a),
  14530. l.texSubImage2D(h, s, i, n, r, o, u, c, t)
  14531. }
  14532. ,
  14533. e.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
  14534. void 0 === i && (i = 0),
  14535. void 0 === n && (n = 0);
  14536. var r = this._gl
  14537. , o = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
  14538. this._bindTextureDirectly(o, e, !0),
  14539. this._uploadDataToTextureDirectly(e, t, i, n),
  14540. this._bindTextureDirectly(o, null, !0)
  14541. }
  14542. ,
  14543. e.prototype._prepareWebGLTextureContinuation = function(e, t, i, n, r) {
  14544. var o = this._gl;
  14545. if (o) {
  14546. var a = this._getSamplingParameters(r, !i);
  14547. o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MAG_FILTER, a.mag),
  14548. o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MIN_FILTER, a.min),
  14549. i || n || o.generateMipmap(o.TEXTURE_2D),
  14550. this._bindTextureDirectly(o.TEXTURE_2D, null),
  14551. t && t._removePendingData(e),
  14552. e.onLoadedObservable.notifyObservers(e),
  14553. e.onLoadedObservable.clear()
  14554. }
  14555. }
  14556. ,
  14557. e.prototype._prepareWebGLTexture = function(t, i, n, r, o, s, l, c, u) {
  14558. var h = this;
  14559. void 0 === u && (u = a.TEXTURE_TRILINEAR_SAMPLINGMODE);
  14560. var d = this.getCaps().maxTextureSize
  14561. , p = Math.min(d, this.needPOTTextures ? e.GetExponentOfTwo(r.width, d) : r.width)
  14562. , f = Math.min(d, this.needPOTTextures ? e.GetExponentOfTwo(r.height, d) : r.height)
  14563. , _ = this._gl;
  14564. _ && (t._hardwareTexture ? (this._bindTextureDirectly(_.TEXTURE_2D, t, !0),
  14565. this._unpackFlipY(void 0 === o || !!o),
  14566. t.baseWidth = r.width,
  14567. t.baseHeight = r.height,
  14568. t.width = p,
  14569. t.height = f,
  14570. t.isReady = !0,
  14571. c(p, f, r, i, t, (function() {
  14572. h._prepareWebGLTextureContinuation(t, n, s, l, u)
  14573. }
  14574. )) || this._prepareWebGLTextureContinuation(t, n, s, l, u)) : n && n._removePendingData(t))
  14575. }
  14576. ,
  14577. e.prototype._setupFramebufferDepthAttachments = function(e, t, i, n, r) {
  14578. void 0 === r && (r = 1);
  14579. var o = this._gl;
  14580. if (e && t)
  14581. return this._createRenderBuffer(i, n, r, o.DEPTH_STENCIL, o.DEPTH24_STENCIL8, o.DEPTH_STENCIL_ATTACHMENT);
  14582. if (t) {
  14583. var a = o.DEPTH_COMPONENT16;
  14584. return this._webGLVersion > 1 && (a = o.DEPTH_COMPONENT32F),
  14585. this._createRenderBuffer(i, n, r, a, a, o.DEPTH_ATTACHMENT)
  14586. }
  14587. return e ? this._createRenderBuffer(i, n, r, o.STENCIL_INDEX8, o.STENCIL_INDEX8, o.STENCIL_ATTACHMENT) : null
  14588. }
  14589. ,
  14590. e.prototype._createRenderBuffer = function(e, t, i, n, r, o, a) {
  14591. void 0 === a && (a = !0);
  14592. var s = this._gl
  14593. , l = s.createRenderbuffer();
  14594. return s.bindRenderbuffer(s.RENDERBUFFER, l),
  14595. i > 1 && s.renderbufferStorageMultisample ? s.renderbufferStorageMultisample(s.RENDERBUFFER, i, r, e, t) : s.renderbufferStorage(s.RENDERBUFFER, n, e, t),
  14596. s.framebufferRenderbuffer(s.FRAMEBUFFER, o, s.RENDERBUFFER, l),
  14597. a && s.bindRenderbuffer(s.RENDERBUFFER, null),
  14598. l
  14599. }
  14600. ,
  14601. e.prototype._releaseTexture = function(e) {
  14602. var t;
  14603. this._deleteTexture(null === (t = e._hardwareTexture) || void 0 === t ? void 0 : t.underlyingResource),
  14604. this.unbindAllTextures();
  14605. var i = this._internalTexturesCache.indexOf(e);
  14606. -1 !== i && this._internalTexturesCache.splice(i, 1),
  14607. e._lodTextureHigh && e._lodTextureHigh.dispose(),
  14608. e._lodTextureMid && e._lodTextureMid.dispose(),
  14609. e._lodTextureLow && e._lodTextureLow.dispose(),
  14610. e._irradianceTexture && e._irradianceTexture.dispose()
  14611. }
  14612. ,
  14613. e.prototype._releaseRenderTargetWrapper = function(e) {
  14614. var t = this._renderTargetWrapperCache.indexOf(e);
  14615. -1 !== t && this._renderTargetWrapperCache.splice(t, 1)
  14616. }
  14617. ,
  14618. e.prototype._deleteTexture = function(e) {
  14619. e && this._gl.deleteTexture(e)
  14620. }
  14621. ,
  14622. e.prototype._setProgram = function(e) {
  14623. this._currentProgram !== e && (this._gl.useProgram(e),
  14624. this._currentProgram = e)
  14625. }
  14626. ,
  14627. e.prototype.bindSamplers = function(e) {
  14628. var t = e.getPipelineContext();
  14629. this._setProgram(t.program);
  14630. for (var i = e.getSamplers(), n = 0; n < i.length; n++) {
  14631. var r = e.getUniform(i[n]);
  14632. r && (this._boundUniforms[n] = r)
  14633. }
  14634. this._currentEffect = null
  14635. }
  14636. ,
  14637. e.prototype._activateCurrentTexture = function() {
  14638. this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel),
  14639. this._currentTextureChannel = this._activeChannel)
  14640. }
  14641. ,
  14642. e.prototype._bindTextureDirectly = function(e, t, i, n) {
  14643. var r, o;
  14644. void 0 === i && (i = !1),
  14645. void 0 === n && (n = !1);
  14646. var a = !1
  14647. , s = t && t._associatedChannel > -1;
  14648. if (i && s && (this._activeChannel = t._associatedChannel),
  14649. this._boundTexturesCache[this._activeChannel] !== t || n) {
  14650. if (this._activateCurrentTexture(),
  14651. t && t.isMultiview)
  14652. throw console.error(e, t),
  14653. "_bindTextureDirectly called with a multiview texture!";
  14654. this._gl.bindTexture(e, null !== (o = null === (r = null == t ? void 0 : t._hardwareTexture) || void 0 === r ? void 0 : r.underlyingResource) && void 0 !== o ? o : null),
  14655. this._boundTexturesCache[this._activeChannel] = t,
  14656. t && (t._associatedChannel = this._activeChannel)
  14657. } else
  14658. i && (a = !0,
  14659. this._activateCurrentTexture());
  14660. return s && !i && this._bindSamplerUniformToChannel(t._associatedChannel, this._activeChannel),
  14661. a
  14662. }
  14663. ,
  14664. e.prototype._bindTexture = function(e, t, i) {
  14665. if (void 0 !== e) {
  14666. t && (t._associatedChannel = e),
  14667. this._activeChannel = e;
  14668. var n = t ? this._getTextureTarget(t) : this._gl.TEXTURE_2D;
  14669. this._bindTextureDirectly(n, t)
  14670. }
  14671. }
  14672. ,
  14673. e.prototype.unbindAllTextures = function() {
  14674. for (var e = 0; e < this._maxSimultaneousTextures; e++)
  14675. this._activeChannel = e,
  14676. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  14677. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  14678. this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
  14679. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))
  14680. }
  14681. ,
  14682. e.prototype.setTexture = function(e, t, i, n) {
  14683. void 0 !== e && (t && (this._boundUniforms[e] = t),
  14684. this._setTexture(e, i))
  14685. }
  14686. ,
  14687. e.prototype._bindSamplerUniformToChannel = function(e, t) {
  14688. var i = this._boundUniforms[e];
  14689. i && i._currentState !== t && (this._gl.uniform1i(i, t),
  14690. i._currentState = t)
  14691. }
  14692. ,
  14693. e.prototype._getTextureWrapMode = function(e) {
  14694. switch (e) {
  14695. case a.TEXTURE_WRAP_ADDRESSMODE:
  14696. return this._gl.REPEAT;
  14697. case a.TEXTURE_CLAMP_ADDRESSMODE:
  14698. return this._gl.CLAMP_TO_EDGE;
  14699. case a.TEXTURE_MIRROR_ADDRESSMODE:
  14700. return this._gl.MIRRORED_REPEAT
  14701. }
  14702. return this._gl.REPEAT
  14703. }
  14704. ,
  14705. e.prototype._setTexture = function(e, t, i, n, r) {
  14706. if (void 0 === i && (i = !1),
  14707. void 0 === n && (n = !1),
  14708. void 0 === r && (r = ""),
  14709. !t)
  14710. return null != this._boundTexturesCache[e] && (this._activeChannel = e,
  14711. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  14712. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  14713. this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
  14714. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))),
  14715. !1;
  14716. if (t.video)
  14717. this._activeChannel = e,
  14718. t.update();
  14719. else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
  14720. return t.delayLoad(),
  14721. !1;
  14722. var o;
  14723. o = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
  14724. !i && o && (o._associatedChannel = e);
  14725. var s = !0;
  14726. this._boundTexturesCache[e] === o && (i || this._bindSamplerUniformToChannel(o._associatedChannel, e),
  14727. s = !1),
  14728. this._activeChannel = e;
  14729. var l = this._getTextureTarget(o);
  14730. if (s && this._bindTextureDirectly(l, o, i),
  14731. o && !o.isMultiview) {
  14732. if (o.isCube && o._cachedCoordinatesMode !== t.coordinatesMode) {
  14733. o._cachedCoordinatesMode = t.coordinatesMode;
  14734. var c = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE;
  14735. t.wrapU = c,
  14736. t.wrapV = c
  14737. }
  14738. o._cachedWrapU !== t.wrapU && (o._cachedWrapU = t.wrapU,
  14739. this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t.wrapU), o)),
  14740. o._cachedWrapV !== t.wrapV && (o._cachedWrapV = t.wrapV,
  14741. this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(t.wrapV), o)),
  14742. o.is3D && o._cachedWrapR !== t.wrapR && (o._cachedWrapR = t.wrapR,
  14743. this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(t.wrapR), o)),
  14744. this._setAnisotropicLevel(l, o, t.anisotropicFilteringLevel)
  14745. }
  14746. return !0
  14747. }
  14748. ,
  14749. e.prototype.setTextureArray = function(e, t, i, n) {
  14750. if (void 0 !== e && t) {
  14751. this._textureUnits && this._textureUnits.length === i.length || (this._textureUnits = new Int32Array(i.length));
  14752. for (var r = 0; r < i.length; r++) {
  14753. var o = i[r].getInternalTexture();
  14754. o ? (this._textureUnits[r] = e + r,
  14755. o._associatedChannel = e + r) : this._textureUnits[r] = -1
  14756. }
  14757. this._gl.uniform1iv(t, this._textureUnits);
  14758. for (var a = 0; a < i.length; a++)
  14759. this._setTexture(this._textureUnits[a], i[a], !0)
  14760. }
  14761. }
  14762. ,
  14763. e.prototype._setAnisotropicLevel = function(e, t, i) {
  14764. var n = this._caps.textureAnisotropicFilterExtension;
  14765. t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPNEAREST && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPLINEAR && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR && (i = 1),
  14766. n && t._cachedAnisotropicFilteringLevel !== i && (this._setTextureParameterFloat(e, n.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(i, this._caps.maxAnisotropy), t),
  14767. t._cachedAnisotropicFilteringLevel = i)
  14768. }
  14769. ,
  14770. e.prototype._setTextureParameterFloat = function(e, t, i, n) {
  14771. this._bindTextureDirectly(e, n, !0, !0),
  14772. this._gl.texParameterf(e, t, i)
  14773. }
  14774. ,
  14775. e.prototype._setTextureParameterInteger = function(e, t, i, n) {
  14776. n && this._bindTextureDirectly(e, n, !0, !0),
  14777. this._gl.texParameteri(e, t, i)
  14778. }
  14779. ,
  14780. e.prototype.unbindAllAttributes = function() {
  14781. if (this._mustWipeVertexAttributes) {
  14782. this._mustWipeVertexAttributes = !1;
  14783. for (var e = 0; e < this._caps.maxVertexAttribs; e++)
  14784. this.disableAttributeByIndex(e)
  14785. } else {
  14786. e = 0;
  14787. for (var t = this._vertexAttribArraysEnabled.length; e < t; e++)
  14788. e >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[e] || this.disableAttributeByIndex(e)
  14789. }
  14790. }
  14791. ,
  14792. e.prototype.releaseEffects = function() {
  14793. for (var e in this._compiledEffects) {
  14794. var t = this._compiledEffects[e].getPipelineContext();
  14795. this._deletePipelineContext(t)
  14796. }
  14797. this._compiledEffects = {}
  14798. }
  14799. ,
  14800. e.prototype.dispose = function() {
  14801. var e;
  14802. this.stopRenderLoop(),
  14803. this.onBeforeTextureInitObservable && this.onBeforeTextureInitObservable.clear(),
  14804. this._emptyTexture && (this._releaseTexture(this._emptyTexture),
  14805. this._emptyTexture = null),
  14806. this._emptyCubeTexture && (this._releaseTexture(this._emptyCubeTexture),
  14807. this._emptyCubeTexture = null),
  14808. this._dummyFramebuffer && this._gl.deleteFramebuffer(this._dummyFramebuffer),
  14809. this.releaseEffects(),
  14810. null === (e = this.releaseComputeEffects) || void 0 === e || e.call(this),
  14811. this.unbindAllAttributes(),
  14812. this._boundUniforms = [],
  14813. nt() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost),
  14814. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored)),
  14815. window.removeEventListener("resize", this._checkForMobile)),
  14816. this._workingCanvas = null,
  14817. this._workingContext = null,
  14818. this._currentBufferPointers = [],
  14819. this._renderingCanvas = null,
  14820. this._currentProgram = null,
  14821. this._boundRenderFunction = null,
  14822. Mt.ResetCache();
  14823. for (var t = 0, i = this._activeRequests; t < i.length; t++)
  14824. i[t].abort();
  14825. this.onDisposeObservable.notifyObservers(this),
  14826. this.onDisposeObservable.clear()
  14827. }
  14828. ,
  14829. e.prototype.attachContextLostEvent = function(e) {
  14830. this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1)
  14831. }
  14832. ,
  14833. e.prototype.attachContextRestoredEvent = function(e) {
  14834. this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1)
  14835. }
  14836. ,
  14837. e.prototype.getError = function() {
  14838. return this._gl.getError()
  14839. }
  14840. ,
  14841. e.prototype._canRenderToFloatFramebuffer = function() {
  14842. return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(a.TEXTURETYPE_FLOAT)
  14843. }
  14844. ,
  14845. e.prototype._canRenderToHalfFloatFramebuffer = function() {
  14846. return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(a.TEXTURETYPE_HALF_FLOAT)
  14847. }
  14848. ,
  14849. e.prototype._canRenderToFramebuffer = function(e) {
  14850. for (var t = this._gl; t.getError() !== t.NO_ERROR; )
  14851. ;
  14852. var i = !0
  14853. , n = t.createTexture();
  14854. t.bindTexture(t.TEXTURE_2D, n),
  14855. t.texImage2D(t.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(e), 1, 1, 0, t.RGBA, this._getWebGLTextureType(e), null),
  14856. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST),
  14857. t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST);
  14858. var r = t.createFramebuffer();
  14859. t.bindFramebuffer(t.FRAMEBUFFER, r),
  14860. t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 0);
  14861. var o = t.checkFramebufferStatus(t.FRAMEBUFFER);
  14862. if ((i = (i = i && o === t.FRAMEBUFFER_COMPLETE) && t.getError() === t.NO_ERROR) && (t.clear(t.COLOR_BUFFER_BIT),
  14863. i = i && t.getError() === t.NO_ERROR),
  14864. i) {
  14865. t.bindFramebuffer(t.FRAMEBUFFER, null);
  14866. var a = t.RGBA
  14867. , s = t.UNSIGNED_BYTE
  14868. , l = new Uint8Array(4);
  14869. t.readPixels(0, 0, 1, 1, a, s, l),
  14870. i = i && t.getError() === t.NO_ERROR
  14871. }
  14872. for (t.deleteTexture(n),
  14873. t.deleteFramebuffer(r),
  14874. t.bindFramebuffer(t.FRAMEBUFFER, null); !i && t.getError() !== t.NO_ERROR; )
  14875. ;
  14876. return i
  14877. }
  14878. ,
  14879. e.prototype._getWebGLTextureType = function(e) {
  14880. if (1 === this._webGLVersion) {
  14881. switch (e) {
  14882. case a.TEXTURETYPE_FLOAT:
  14883. return this._gl.FLOAT;
  14884. case a.TEXTURETYPE_HALF_FLOAT:
  14885. return this._gl.HALF_FLOAT_OES;
  14886. case a.TEXTURETYPE_UNSIGNED_BYTE:
  14887. return this._gl.UNSIGNED_BYTE;
  14888. case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  14889. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  14890. case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  14891. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  14892. case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  14893. return this._gl.UNSIGNED_SHORT_5_6_5
  14894. }
  14895. return this._gl.UNSIGNED_BYTE
  14896. }
  14897. switch (e) {
  14898. case a.TEXTURETYPE_BYTE:
  14899. return this._gl.BYTE;
  14900. case a.TEXTURETYPE_UNSIGNED_BYTE:
  14901. return this._gl.UNSIGNED_BYTE;
  14902. case a.TEXTURETYPE_SHORT:
  14903. return this._gl.SHORT;
  14904. case a.TEXTURETYPE_UNSIGNED_SHORT:
  14905. return this._gl.UNSIGNED_SHORT;
  14906. case a.TEXTURETYPE_INT:
  14907. return this._gl.INT;
  14908. case a.TEXTURETYPE_UNSIGNED_INTEGER:
  14909. return this._gl.UNSIGNED_INT;
  14910. case a.TEXTURETYPE_FLOAT:
  14911. return this._gl.FLOAT;
  14912. case a.TEXTURETYPE_HALF_FLOAT:
  14913. return this._gl.HALF_FLOAT;
  14914. case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  14915. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  14916. case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  14917. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  14918. case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  14919. return this._gl.UNSIGNED_SHORT_5_6_5;
  14920. case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  14921. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  14922. case a.TEXTURETYPE_UNSIGNED_INT_24_8:
  14923. return this._gl.UNSIGNED_INT_24_8;
  14924. case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  14925. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  14926. case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  14927. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  14928. case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  14929. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV
  14930. }
  14931. return this._gl.UNSIGNED_BYTE
  14932. }
  14933. ,
  14934. e.prototype._getInternalFormat = function(e, t) {
  14935. void 0 === t && (t = !1);
  14936. var i = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
  14937. switch (e) {
  14938. case a.TEXTUREFORMAT_ALPHA:
  14939. i = this._gl.ALPHA;
  14940. break;
  14941. case a.TEXTUREFORMAT_LUMINANCE:
  14942. i = this._gl.LUMINANCE;
  14943. break;
  14944. case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
  14945. i = this._gl.LUMINANCE_ALPHA;
  14946. break;
  14947. case a.TEXTUREFORMAT_RED:
  14948. i = this._gl.RED;
  14949. break;
  14950. case a.TEXTUREFORMAT_RG:
  14951. i = this._gl.RG;
  14952. break;
  14953. case a.TEXTUREFORMAT_RGB:
  14954. i = t ? this._gl.SRGB : this._gl.RGB;
  14955. break;
  14956. case a.TEXTUREFORMAT_RGBA:
  14957. i = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA
  14958. }
  14959. if (this._webGLVersion > 1)
  14960. switch (e) {
  14961. case a.TEXTUREFORMAT_RED_INTEGER:
  14962. i = this._gl.RED_INTEGER;
  14963. break;
  14964. case a.TEXTUREFORMAT_RG_INTEGER:
  14965. i = this._gl.RG_INTEGER;
  14966. break;
  14967. case a.TEXTUREFORMAT_RGB_INTEGER:
  14968. i = this._gl.RGB_INTEGER;
  14969. break;
  14970. case a.TEXTUREFORMAT_RGBA_INTEGER:
  14971. i = this._gl.RGBA_INTEGER
  14972. }
  14973. return i
  14974. }
  14975. ,
  14976. e.prototype._getRGBABufferInternalSizedFormat = function(e, t, i) {
  14977. if (void 0 === i && (i = !1),
  14978. 1 === this._webGLVersion) {
  14979. if (void 0 !== t)
  14980. switch (t) {
  14981. case a.TEXTUREFORMAT_ALPHA:
  14982. return this._gl.ALPHA;
  14983. case a.TEXTUREFORMAT_LUMINANCE:
  14984. return this._gl.LUMINANCE;
  14985. case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
  14986. return this._gl.LUMINANCE_ALPHA;
  14987. case a.TEXTUREFORMAT_RGB:
  14988. return i ? this._gl.SRGB : this._gl.RGB
  14989. }
  14990. return this._gl.RGBA
  14991. }
  14992. switch (e) {
  14993. case a.TEXTURETYPE_BYTE:
  14994. switch (t) {
  14995. case a.TEXTUREFORMAT_RED:
  14996. return this._gl.R8_SNORM;
  14997. case a.TEXTUREFORMAT_RG:
  14998. return this._gl.RG8_SNORM;
  14999. case a.TEXTUREFORMAT_RGB:
  15000. return this._gl.RGB8_SNORM;
  15001. case a.TEXTUREFORMAT_RED_INTEGER:
  15002. return this._gl.R8I;
  15003. case a.TEXTUREFORMAT_RG_INTEGER:
  15004. return this._gl.RG8I;
  15005. case a.TEXTUREFORMAT_RGB_INTEGER:
  15006. return this._gl.RGB8I;
  15007. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15008. return this._gl.RGBA8I;
  15009. default:
  15010. return this._gl.RGBA8_SNORM
  15011. }
  15012. case a.TEXTURETYPE_UNSIGNED_BYTE:
  15013. switch (t) {
  15014. case a.TEXTUREFORMAT_RED:
  15015. return this._gl.R8;
  15016. case a.TEXTUREFORMAT_RG:
  15017. return this._gl.RG8;
  15018. case a.TEXTUREFORMAT_RGB:
  15019. return i ? this._gl.SRGB8 : this._gl.RGB8;
  15020. case a.TEXTUREFORMAT_RGBA:
  15021. return i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8;
  15022. case a.TEXTUREFORMAT_RED_INTEGER:
  15023. return this._gl.R8UI;
  15024. case a.TEXTUREFORMAT_RG_INTEGER:
  15025. return this._gl.RG8UI;
  15026. case a.TEXTUREFORMAT_RGB_INTEGER:
  15027. return this._gl.RGB8UI;
  15028. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15029. return this._gl.RGBA8UI;
  15030. case a.TEXTUREFORMAT_ALPHA:
  15031. return this._gl.ALPHA;
  15032. case a.TEXTUREFORMAT_LUMINANCE:
  15033. return this._gl.LUMINANCE;
  15034. case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
  15035. return this._gl.LUMINANCE_ALPHA;
  15036. default:
  15037. return this._gl.RGBA8
  15038. }
  15039. case a.TEXTURETYPE_SHORT:
  15040. switch (t) {
  15041. case a.TEXTUREFORMAT_RED_INTEGER:
  15042. return this._gl.R16I;
  15043. case a.TEXTUREFORMAT_RG_INTEGER:
  15044. return this._gl.RG16I;
  15045. case a.TEXTUREFORMAT_RGB_INTEGER:
  15046. return this._gl.RGB16I;
  15047. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15048. default:
  15049. return this._gl.RGBA16I
  15050. }
  15051. case a.TEXTURETYPE_UNSIGNED_SHORT:
  15052. switch (t) {
  15053. case a.TEXTUREFORMAT_RED_INTEGER:
  15054. return this._gl.R16UI;
  15055. case a.TEXTUREFORMAT_RG_INTEGER:
  15056. return this._gl.RG16UI;
  15057. case a.TEXTUREFORMAT_RGB_INTEGER:
  15058. return this._gl.RGB16UI;
  15059. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15060. default:
  15061. return this._gl.RGBA16UI
  15062. }
  15063. case a.TEXTURETYPE_INT:
  15064. switch (t) {
  15065. case a.TEXTUREFORMAT_RED_INTEGER:
  15066. return this._gl.R32I;
  15067. case a.TEXTUREFORMAT_RG_INTEGER:
  15068. return this._gl.RG32I;
  15069. case a.TEXTUREFORMAT_RGB_INTEGER:
  15070. return this._gl.RGB32I;
  15071. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15072. default:
  15073. return this._gl.RGBA32I
  15074. }
  15075. case a.TEXTURETYPE_UNSIGNED_INTEGER:
  15076. switch (t) {
  15077. case a.TEXTUREFORMAT_RED_INTEGER:
  15078. return this._gl.R32UI;
  15079. case a.TEXTUREFORMAT_RG_INTEGER:
  15080. return this._gl.RG32UI;
  15081. case a.TEXTUREFORMAT_RGB_INTEGER:
  15082. return this._gl.RGB32UI;
  15083. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15084. default:
  15085. return this._gl.RGBA32UI
  15086. }
  15087. case a.TEXTURETYPE_FLOAT:
  15088. switch (t) {
  15089. case a.TEXTUREFORMAT_RED:
  15090. return this._gl.R32F;
  15091. case a.TEXTUREFORMAT_RG:
  15092. return this._gl.RG32F;
  15093. case a.TEXTUREFORMAT_RGB:
  15094. return this._gl.RGB32F;
  15095. case a.TEXTUREFORMAT_RGBA:
  15096. default:
  15097. return this._gl.RGBA32F
  15098. }
  15099. case a.TEXTURETYPE_HALF_FLOAT:
  15100. switch (t) {
  15101. case a.TEXTUREFORMAT_RED:
  15102. return this._gl.R16F;
  15103. case a.TEXTUREFORMAT_RG:
  15104. return this._gl.RG16F;
  15105. case a.TEXTUREFORMAT_RGB:
  15106. return this._gl.RGB16F;
  15107. case a.TEXTUREFORMAT_RGBA:
  15108. default:
  15109. return this._gl.RGBA16F
  15110. }
  15111. case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  15112. return this._gl.RGB565;
  15113. case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  15114. return this._gl.R11F_G11F_B10F;
  15115. case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  15116. return this._gl.RGB9_E5;
  15117. case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  15118. return this._gl.RGBA4;
  15119. case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  15120. return this._gl.RGB5_A1;
  15121. case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  15122. switch (t) {
  15123. case a.TEXTUREFORMAT_RGBA:
  15124. return this._gl.RGB10_A2;
  15125. case a.TEXTUREFORMAT_RGBA_INTEGER:
  15126. return this._gl.RGB10_A2UI;
  15127. default:
  15128. return this._gl.RGB10_A2
  15129. }
  15130. }
  15131. return i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8
  15132. }
  15133. ,
  15134. e.prototype._getRGBAMultiSampleBufferFormat = function(e) {
  15135. return e === a.TEXTURETYPE_FLOAT ? this._gl.RGBA32F : e === a.TEXTURETYPE_HALF_FLOAT ? this._gl.RGBA16F : this._gl.RGBA8
  15136. }
  15137. ,
  15138. e.prototype._loadFile = function(t, i, n, r, o, a) {
  15139. var s = this
  15140. , l = e._FileToolsLoadFile(t, i, n, r, o, a);
  15141. return this._activeRequests.push(l),
  15142. l.onCompleteObservable.add((function(e) {
  15143. s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
  15144. }
  15145. )),
  15146. l
  15147. }
  15148. ,
  15149. e._FileToolsLoadFile = function(e, t, i, n, r, o) {
  15150. throw be("FileTools")
  15151. }
  15152. ,
  15153. e.prototype.readPixels = function(e, t, i, n, r, o) {
  15154. void 0 === r && (r = !0),
  15155. void 0 === o && (o = !0);
  15156. var a = r ? 4 : 3
  15157. , s = r ? this._gl.RGBA : this._gl.RGB
  15158. , l = new Uint8Array(n * i * a);
  15159. return o && this.flushFramebuffer(),
  15160. this._gl.readPixels(e, t, i, n, s, this._gl.UNSIGNED_BYTE, l),
  15161. Promise.resolve(l)
  15162. }
  15163. ,
  15164. Object.defineProperty(e, "IsSupportedAsync", {
  15165. get: function() {
  15166. return Promise.resolve(this.isSupported())
  15167. },
  15168. enumerable: !1,
  15169. configurable: !0
  15170. }),
  15171. Object.defineProperty(e, "IsSupported", {
  15172. get: function() {
  15173. return this.isSupported()
  15174. },
  15175. enumerable: !1,
  15176. configurable: !0
  15177. }),
  15178. e.isSupported = function() {
  15179. if (null !== this._HasMajorPerformanceCaveat)
  15180. return !this._HasMajorPerformanceCaveat;
  15181. if (null === this._IsSupported)
  15182. try {
  15183. var e = this._CreateCanvas(1, 1)
  15184. , t = e.getContext("webgl") || e.getContext("experimental-webgl");
  15185. this._IsSupported = null != t && !!window.WebGLRenderingContext
  15186. } catch (e) {
  15187. this._IsSupported = !1
  15188. }
  15189. return this._IsSupported
  15190. }
  15191. ,
  15192. Object.defineProperty(e, "HasMajorPerformanceCaveat", {
  15193. get: function() {
  15194. if (null === this._HasMajorPerformanceCaveat)
  15195. try {
  15196. var e = this._CreateCanvas(1, 1)
  15197. , t = e.getContext("webgl", {
  15198. failIfMajorPerformanceCaveat: !0
  15199. }) || e.getContext("experimental-webgl", {
  15200. failIfMajorPerformanceCaveat: !0
  15201. });
  15202. this._HasMajorPerformanceCaveat = !t
  15203. } catch (e) {
  15204. this._HasMajorPerformanceCaveat = !1
  15205. }
  15206. return this._HasMajorPerformanceCaveat
  15207. },
  15208. enumerable: !1,
  15209. configurable: !0
  15210. }),
  15211. e.CeilingPOT = function(e) {
  15212. return e--,
  15213. e |= e >> 1,
  15214. e |= e >> 2,
  15215. e |= e >> 4,
  15216. e |= e >> 8,
  15217. e |= e >> 16,
  15218. ++e
  15219. }
  15220. ,
  15221. e.FloorPOT = function(e) {
  15222. return e |= e >> 1,
  15223. e |= e >> 2,
  15224. e |= e >> 4,
  15225. e |= e >> 8,
  15226. (e |= e >> 16) - (e >> 1)
  15227. }
  15228. ,
  15229. e.NearestPOT = function(t) {
  15230. var i = e.CeilingPOT(t)
  15231. , n = e.FloorPOT(t);
  15232. return i - t > t - n ? n : i
  15233. }
  15234. ,
  15235. e.GetExponentOfTwo = function(t, i, n) {
  15236. var r;
  15237. switch (void 0 === n && (n = a.SCALEMODE_NEAREST),
  15238. n) {
  15239. case a.SCALEMODE_FLOOR:
  15240. r = e.FloorPOT(t);
  15241. break;
  15242. case a.SCALEMODE_NEAREST:
  15243. r = e.NearestPOT(t);
  15244. break;
  15245. case a.SCALEMODE_CEILING:
  15246. default:
  15247. r = e.CeilingPOT(t)
  15248. }
  15249. return Math.min(r, i)
  15250. }
  15251. ,
  15252. e.QueueNewFrame = function(e, t) {
  15253. return nt() ? (t || (t = window),
  15254. t.requestPostAnimationFrame ? t.requestPostAnimationFrame(e) : t.requestAnimationFrame ? t.requestAnimationFrame(e) : t.msRequestAnimationFrame ? t.msRequestAnimationFrame(e) : t.webkitRequestAnimationFrame ? t.webkitRequestAnimationFrame(e) : t.mozRequestAnimationFrame ? t.mozRequestAnimationFrame(e) : t.oRequestAnimationFrame ? t.oRequestAnimationFrame(e) : window.setTimeout(e, 16)) : "undefined" != typeof requestAnimationFrame ? requestAnimationFrame(e) : setTimeout(e, 16)
  15255. }
  15256. ,
  15257. e.prototype.getHostDocument = function() {
  15258. return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
  15259. }
  15260. ,
  15261. e.ExceptionList = [{
  15262. key: "Chrome/63.0",
  15263. capture: "63\\.0\\.3239\\.(\\d+)",
  15264. captureConstraint: 108,
  15265. targets: ["uniformBuffer"]
  15266. }, {
  15267. key: "Firefox/58",
  15268. capture: null,
  15269. captureConstraint: null,
  15270. targets: ["uniformBuffer"]
  15271. }, {
  15272. key: "Firefox/59",
  15273. capture: null,
  15274. captureConstraint: null,
  15275. targets: ["uniformBuffer"]
  15276. }, {
  15277. key: "Chrome/72.+?Mobile",
  15278. capture: null,
  15279. captureConstraint: null,
  15280. targets: ["vao"]
  15281. }, {
  15282. key: "Chrome/73.+?Mobile",
  15283. capture: null,
  15284. captureConstraint: null,
  15285. targets: ["vao"]
  15286. }, {
  15287. key: "Chrome/74.+?Mobile",
  15288. capture: null,
  15289. captureConstraint: null,
  15290. targets: ["vao"]
  15291. }, {
  15292. key: "Mac OS.+Chrome/71",
  15293. capture: null,
  15294. captureConstraint: null,
  15295. targets: ["vao"]
  15296. }, {
  15297. key: "Mac OS.+Chrome/72",
  15298. capture: null,
  15299. captureConstraint: null,
  15300. targets: ["vao"]
  15301. }],
  15302. e._TextureLoaders = [],
  15303. e.CollisionsEpsilon = .001,
  15304. e._IsSupported = null,
  15305. e._HasMajorPerformanceCaveat = null,
  15306. e
  15307. }()
  15308. , Xt = function() {
  15309. function e() {}
  15310. return e.SetImmediate = function(e) {
  15311. nt() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
  15312. }
  15313. ,
  15314. e
  15315. }()
  15316. , jt = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i)
  15317. , Yt = function(e) {
  15318. function t(i, n) {
  15319. var r = e.call(this, i, pt.LoadFileError) || this;
  15320. return r.name = "LoadFileError",
  15321. dt._setPrototypeOf(r, t.prototype),
  15322. n instanceof Ye ? r.request = n : r.file = n,
  15323. r
  15324. }
  15325. return U(t, e),
  15326. t
  15327. }(ft)
  15328. , Kt = function(e) {
  15329. function t(i, n) {
  15330. var r = e.call(this, i, pt.RequestFileError) || this;
  15331. return r.request = n,
  15332. r.name = "RequestFileError",
  15333. dt._setPrototypeOf(r, t.prototype),
  15334. r
  15335. }
  15336. return U(t, e),
  15337. t
  15338. }(ft)
  15339. , Qt = function(e) {
  15340. function t(i, n) {
  15341. var r = e.call(this, i, pt.ReadFileError) || this;
  15342. return r.file = n,
  15343. r.name = "ReadFileError",
  15344. dt._setPrototypeOf(r, t.prototype),
  15345. r
  15346. }
  15347. return U(t, e),
  15348. t
  15349. }(ft)
  15350. , qt = {
  15351. DefaultRetryStrategy: ht.ExponentialBackoff(),
  15352. BaseUrl: "",
  15353. CorsBehavior: "anonymous",
  15354. PreprocessUrl: function(e) {
  15355. return e
  15356. }
  15357. }
  15358. , Zt = function(e) {
  15359. return e.replace(/#/gm, "%23")
  15360. }
  15361. , Jt = function(e, t) {
  15362. if ((!e || 0 !== e.indexOf("data:")) && qt.CorsBehavior)
  15363. if ("string" == typeof qt.CorsBehavior || qt.CorsBehavior instanceof String)
  15364. t.crossOrigin = qt.CorsBehavior;
  15365. else {
  15366. var i = qt.CorsBehavior(e);
  15367. i && (t.crossOrigin = i)
  15368. }
  15369. }
  15370. , $t = function(e, t, i, n, r, o) {
  15371. var a, s;
  15372. void 0 === r && (r = "");
  15373. var l = !1;
  15374. e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? "undefined" != typeof Blob ? (s = URL.createObjectURL(new Blob([e],{
  15375. type: r
  15376. })),
  15377. l = !0) : s = "data:".concat(r, ";base64,") + le(e) : e instanceof Blob ? (s = URL.createObjectURL(e),
  15378. l = !0) : (s = Zt(e),
  15379. s = qt.PreprocessUrl(e));
  15380. var c = E.LastCreatedEngine
  15381. , u = function(t) {
  15382. if (i) {
  15383. var n = s || e.toString();
  15384. i("Error while trying to load image: ".concat(0 === n.indexOf("http") || n.length <= 128 ? n : n.slice(0, 128) + "..."), t)
  15385. }
  15386. };
  15387. if ("undefined" == typeof Image || null !== (a = null == c ? void 0 : c._features.forceBitmapOverHTMLImageElement) && void 0 !== a && a)
  15388. return ti(s, (function(n) {
  15389. c.createImageBitmap(new Blob([n],{
  15390. type: r
  15391. }), V({
  15392. premultiplyAlpha: "none"
  15393. }, o)).then((function(e) {
  15394. t(e),
  15395. l && URL.revokeObjectURL(s)
  15396. }
  15397. )).catch((function(t) {
  15398. i && i("Error while trying to load image: " + e, t)
  15399. }
  15400. ))
  15401. }
  15402. ), void 0, n || void 0, !0, (function(e, t) {
  15403. u(t)
  15404. }
  15405. )),
  15406. null;
  15407. var h = new Image;
  15408. Jt(s, h);
  15409. var d = function() {
  15410. h.removeEventListener("load", d),
  15411. h.removeEventListener("error", p),
  15412. t(h),
  15413. l && h.src && URL.revokeObjectURL(h.src)
  15414. }
  15415. , p = function(e) {
  15416. h.removeEventListener("load", d),
  15417. h.removeEventListener("error", p),
  15418. u(e),
  15419. l && h.src && URL.revokeObjectURL(h.src)
  15420. };
  15421. h.addEventListener("load", d),
  15422. h.addEventListener("error", p);
  15423. var f = function() {
  15424. h.src = s
  15425. };
  15426. if ("blob:" !== s.substr(0, 5) && "data:" !== s.substr(0, 5) && n && n.enableTexturesOffline)
  15427. n.open((function() {
  15428. n && n.loadImage(s, h)
  15429. }
  15430. ), f);
  15431. else {
  15432. if (-1 !== s.indexOf("file:")) {
  15433. var _ = decodeURIComponent(s.substring(5).toLowerCase());
  15434. if (ut.FilesToLoad[_]) {
  15435. try {
  15436. var m = void 0;
  15437. try {
  15438. m = URL.createObjectURL(ut.FilesToLoad[_])
  15439. } catch (e) {
  15440. m = URL.createObjectURL(ut.FilesToLoad[_])
  15441. }
  15442. h.src = m,
  15443. l = !0
  15444. } catch (e) {
  15445. h.src = ""
  15446. }
  15447. return h
  15448. }
  15449. }
  15450. f()
  15451. }
  15452. return h
  15453. }
  15454. , ei = function(e, t, i, n, r) {
  15455. var o = new FileReader
  15456. , a = {
  15457. onCompleteObservable: new h,
  15458. abort: function() {
  15459. return o.abort()
  15460. }
  15461. };
  15462. return o.onloadend = function() {
  15463. return a.onCompleteObservable.notifyObservers(a)
  15464. }
  15465. ,
  15466. r && (o.onerror = function() {
  15467. r(new Qt("Unable to read ".concat(e.name),e))
  15468. }
  15469. ),
  15470. o.onload = function(e) {
  15471. t(e.target.result)
  15472. }
  15473. ,
  15474. i && (o.onprogress = i),
  15475. n ? o.readAsArrayBuffer(e) : o.readAsText(e),
  15476. a
  15477. }
  15478. , ti = function(e, t, i, n, r, o, a) {
  15479. if (e.name)
  15480. return ei(e, t, i, r, o ? function(e) {
  15481. o(void 0, e)
  15482. }
  15483. : void 0);
  15484. var s = e;
  15485. if (-1 !== s.indexOf("file:")) {
  15486. var l = decodeURIComponent(s.substring(5).toLowerCase());
  15487. 0 === l.indexOf("./") && (l = l.substring(2));
  15488. var c = ut.FilesToLoad[l];
  15489. if (c)
  15490. return ei(c, t, i, r, o ? function(e) {
  15491. return o(void 0, new Yt(e.message,e.file))
  15492. }
  15493. : void 0)
  15494. }
  15495. if (ri(s)) {
  15496. var u = {
  15497. onCompleteObservable: new h,
  15498. abort: function() {
  15499. return function() {}
  15500. }
  15501. };
  15502. try {
  15503. t(r ? oi(s) : si(s))
  15504. } catch (e) {
  15505. o ? o(void 0, e) : K.Error(e.message || "Failed to parse the Data URL")
  15506. }
  15507. return Xt.SetImmediate((function() {
  15508. u.onCompleteObservable.notifyObservers(u)
  15509. }
  15510. )),
  15511. u
  15512. }
  15513. return ii(s, (function(e, i) {
  15514. t(e, i ? i.responseURL : void 0)
  15515. }
  15516. ), i, n, r, o ? function(e) {
  15517. o(e.request, new Yt(e.message,e.request))
  15518. }
  15519. : void 0, a)
  15520. }
  15521. , ii = function(e, t, i, n, r, o, a) {
  15522. e = Zt(e),
  15523. e = qt.PreprocessUrl(e);
  15524. var s = qt.BaseUrl + e
  15525. , l = !1
  15526. , c = {
  15527. onCompleteObservable: new h,
  15528. abort: function() {
  15529. return l = !0
  15530. }
  15531. }
  15532. , u = function() {
  15533. var e, n = new Ye, u = null, h = function() {
  15534. n && (i && n.removeEventListener("progress", i),
  15535. e && n.removeEventListener("readystatechange", e),
  15536. n.removeEventListener("loadend", d))
  15537. }, d = function() {
  15538. h(),
  15539. c.onCompleteObservable.notifyObservers(c),
  15540. c.onCompleteObservable.clear(),
  15541. i = void 0,
  15542. e = null,
  15543. d = null,
  15544. o = void 0,
  15545. a = void 0,
  15546. t = void 0
  15547. };
  15548. c.abort = function() {
  15549. l = !0,
  15550. d && d(),
  15551. n && n.readyState !== (XMLHttpRequest.DONE || 4) && n.abort(),
  15552. null !== u && (clearTimeout(u),
  15553. u = null),
  15554. n = null
  15555. }
  15556. ;
  15557. var p = function(e) {
  15558. var t = e.message || "Unknown error";
  15559. o && n ? o(new Kt(t,n)) : K.Error(t)
  15560. }
  15561. , f = function(c) {
  15562. if (n) {
  15563. if (n.open("GET", s),
  15564. a)
  15565. try {
  15566. a(n)
  15567. } catch (e) {
  15568. return void p(e)
  15569. }
  15570. r && (n.responseType = "arraybuffer"),
  15571. i && n.addEventListener("progress", i),
  15572. d && n.addEventListener("loadend", d),
  15573. e = function() {
  15574. if (!l && n && n.readyState === (XMLHttpRequest.DONE || 4)) {
  15575. if (e && n.removeEventListener("readystatechange", e),
  15576. n.status >= 200 && n.status < 300 || 0 === n.status && (!nt() || ni())) {
  15577. try {
  15578. t && t(r ? n.response : n.responseText, n)
  15579. } catch (e) {
  15580. p(e)
  15581. }
  15582. return
  15583. }
  15584. var i = qt.DefaultRetryStrategy;
  15585. if (i) {
  15586. var a = i(s, n, c);
  15587. if (-1 !== a)
  15588. return h(),
  15589. n = new Ye,
  15590. void (u = setTimeout((function() {
  15591. return f(c + 1)
  15592. }
  15593. ), a))
  15594. }
  15595. var d = new Kt("Error status: " + n.status + " " + n.statusText + " - Unable to load " + s,n);
  15596. o && o(d)
  15597. }
  15598. }
  15599. ,
  15600. n.addEventListener("readystatechange", e),
  15601. n.send()
  15602. }
  15603. };
  15604. f(0)
  15605. };
  15606. if (n && n.enableSceneOffline) {
  15607. var d = function(e) {
  15608. e && e.status > 400 ? o && o(e) : u()
  15609. };
  15610. n.open((function() {
  15611. n && n.loadFile(qt.BaseUrl + e, (function(e) {
  15612. !l && t && t(e),
  15613. c.onCompleteObservable.notifyObservers(c)
  15614. }
  15615. ), i ? function(e) {
  15616. !l && i && i(e)
  15617. }
  15618. : void 0, d, r)
  15619. }
  15620. ), d)
  15621. } else
  15622. u();
  15623. return c
  15624. }
  15625. , ni = function() {
  15626. return "undefined" != typeof location && "file:" === location.protocol
  15627. }
  15628. , ri = function(e) {
  15629. return jt.test(e)
  15630. };
  15631. function oi(e) {
  15632. return ue(e.split(",")[1])
  15633. }
  15634. var ai, si = function(e) {
  15635. return ce(e.split(",")[1])
  15636. };
  15637. Ht._FileToolsLoadImage = $t,
  15638. Ht._FileToolsLoadFile = ti,
  15639. Ct._FileToolsLoadFile = ti;
  15640. var li, ci = function(e, t, i, n, r, o, a, s, l, c) {
  15641. ai = {
  15642. DecodeBase64UrlToBinary: e,
  15643. DecodeBase64UrlToString: t,
  15644. DefaultRetryStrategy: i.DefaultRetryStrategy,
  15645. BaseUrl: i.BaseUrl,
  15646. CorsBehavior: i.CorsBehavior,
  15647. PreprocessUrl: i.PreprocessUrl,
  15648. IsBase64DataUrl: n,
  15649. IsFileURL: r,
  15650. LoadFile: o,
  15651. LoadImage: a,
  15652. ReadFile: s,
  15653. RequestFile: l,
  15654. SetCorsBehavior: c
  15655. },
  15656. Object.defineProperty(ai, "DefaultRetryStrategy", {
  15657. get: function() {
  15658. return i.DefaultRetryStrategy
  15659. },
  15660. set: function(e) {
  15661. i.DefaultRetryStrategy = e
  15662. }
  15663. }),
  15664. Object.defineProperty(ai, "BaseUrl", {
  15665. get: function() {
  15666. return i.BaseUrl
  15667. },
  15668. set: function(e) {
  15669. i.BaseUrl = e
  15670. }
  15671. }),
  15672. Object.defineProperty(ai, "PreprocessUrl", {
  15673. get: function() {
  15674. return i.PreprocessUrl
  15675. },
  15676. set: function(e) {
  15677. i.PreprocessUrl = e
  15678. }
  15679. }),
  15680. Object.defineProperty(ai, "CorsBehavior", {
  15681. get: function() {
  15682. return i.CorsBehavior
  15683. },
  15684. set: function(e) {
  15685. i.CorsBehavior = e
  15686. }
  15687. })
  15688. };
  15689. ci(oi, si, qt, ri, ni, ti, $t, ei, ii, Jt),
  15690. function(e) {
  15691. e[e.Pending = 0] = "Pending",
  15692. e[e.Fulfilled = 1] = "Fulfilled",
  15693. e[e.Rejected = 2] = "Rejected"
  15694. }(li || (li = {}));
  15695. var ui = function() {
  15696. this.count = 0,
  15697. this.target = 0,
  15698. this.results = []
  15699. }
  15700. , hi = function() {
  15701. function e(e) {
  15702. var t = this;
  15703. if (this._state = li.Pending,
  15704. this._children = new Array,
  15705. this._rejectWasConsumed = !1,
  15706. e)
  15707. try {
  15708. e((function(e) {
  15709. t._resolve(e)
  15710. }
  15711. ), (function(e) {
  15712. t._reject(e)
  15713. }
  15714. ))
  15715. } catch (e) {
  15716. this._reject(e)
  15717. }
  15718. }
  15719. return Object.defineProperty(e.prototype, "_result", {
  15720. get: function() {
  15721. return this._resultValue
  15722. },
  15723. set: function(e) {
  15724. this._resultValue = e,
  15725. this._parent && void 0 === this._parent._result && (this._parent._result = e)
  15726. },
  15727. enumerable: !1,
  15728. configurable: !0
  15729. }),
  15730. e.prototype.catch = function(e) {
  15731. return this.then(void 0, e)
  15732. }
  15733. ,
  15734. e.prototype.then = function(t, i) {
  15735. var n = this
  15736. , r = new e;
  15737. return r._onFulfilled = t,
  15738. r._onRejected = i,
  15739. this._children.push(r),
  15740. r._parent = this,
  15741. this._state !== li.Pending && setTimeout((function() {
  15742. n._state === li.Fulfilled || n._rejectWasConsumed ? r._resolve(n._result) : r._reject(n._reason)
  15743. }
  15744. )),
  15745. r
  15746. }
  15747. ,
  15748. e.prototype._moveChildren = function(e) {
  15749. var t, i = this;
  15750. if ((t = this._children).push.apply(t, e.splice(0, e.length)),
  15751. this._children.forEach((function(e) {
  15752. e._parent = i
  15753. }
  15754. )),
  15755. this._state === li.Fulfilled)
  15756. for (var n = 0, r = this._children; n < r.length; n++)
  15757. r[n]._resolve(this._result);
  15758. else if (this._state === li.Rejected)
  15759. for (var o = 0, a = this._children; o < a.length; o++)
  15760. a[o]._reject(this._reason)
  15761. }
  15762. ,
  15763. e.prototype._resolve = function(e) {
  15764. try {
  15765. this._state = li.Fulfilled;
  15766. var t = null;
  15767. if (this._onFulfilled && (t = this._onFulfilled(e)),
  15768. null != t)
  15769. if (void 0 !== t._state) {
  15770. var i = t;
  15771. i._parent = this,
  15772. i._moveChildren(this._children),
  15773. e = i._result
  15774. } else
  15775. e = t;
  15776. this._result = e;
  15777. for (var n = 0, r = this._children; n < r.length; n++)
  15778. r[n]._resolve(e);
  15779. this._children.length = 0,
  15780. delete this._onFulfilled,
  15781. delete this._onRejected
  15782. } catch (e) {
  15783. this._reject(e, !0)
  15784. }
  15785. }
  15786. ,
  15787. e.prototype._reject = function(e, t) {
  15788. if (void 0 === t && (t = !1),
  15789. this._state = li.Rejected,
  15790. this._reason = e,
  15791. this._onRejected && !t)
  15792. try {
  15793. this._onRejected(e),
  15794. this._rejectWasConsumed = !0
  15795. } catch (t) {
  15796. e = t
  15797. }
  15798. for (var i = 0, n = this._children; i < n.length; i++) {
  15799. var r = n[i];
  15800. this._rejectWasConsumed ? r._resolve(null) : r._reject(e)
  15801. }
  15802. this._children.length = 0,
  15803. delete this._onFulfilled,
  15804. delete this._onRejected
  15805. }
  15806. ,
  15807. e.resolve = function(t) {
  15808. var i = new e;
  15809. return i._resolve(t),
  15810. i
  15811. }
  15812. ,
  15813. e._RegisterForFulfillment = function(e, t, i) {
  15814. e.then((function(e) {
  15815. return t.results[i] = e,
  15816. t.count++,
  15817. t.count === t.target && t.rootPromise._resolve(t.results),
  15818. null
  15819. }
  15820. ), (function(e) {
  15821. t.rootPromise._state !== li.Rejected && t.rootPromise._reject(e)
  15822. }
  15823. ))
  15824. }
  15825. ,
  15826. e.all = function(t) {
  15827. var i = new e
  15828. , n = new ui;
  15829. if (n.target = t.length,
  15830. n.rootPromise = i,
  15831. t.length)
  15832. for (var r = 0; r < t.length; r++)
  15833. e._RegisterForFulfillment(t[r], n, r);
  15834. else
  15835. i._resolve([]);
  15836. return i
  15837. }
  15838. ,
  15839. e.race = function(t) {
  15840. var i = new e;
  15841. if (t.length)
  15842. for (var n = 0, r = t; n < r.length; n++)
  15843. r[n].then((function(e) {
  15844. return i && (i._resolve(e),
  15845. i = null),
  15846. null
  15847. }
  15848. ), (function(e) {
  15849. i && (i._reject(e),
  15850. i = null)
  15851. }
  15852. ));
  15853. return i
  15854. }
  15855. ,
  15856. e
  15857. }()
  15858. , di = function() {
  15859. function e() {}
  15860. return e.Apply = function(e) {
  15861. void 0 === e && (e = !1),
  15862. (e || "undefined" == typeof Promise) && (window.Promise = hi)
  15863. }
  15864. ,
  15865. e
  15866. }()
  15867. , pi = function() {
  15868. function e() {}
  15869. return e.Instantiate = function(e) {
  15870. if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
  15871. return this.RegisteredExternalClasses[e];
  15872. var t = b(e);
  15873. if (t)
  15874. return t;
  15875. K.Warn(e + " not found, you may have missed an import.");
  15876. for (var i = e.split("."), n = window || this, r = 0, o = i.length; r < o; r++)
  15877. n = n[i[r]];
  15878. return "function" != typeof n ? null : n
  15879. }
  15880. ,
  15881. e.RegisteredExternalClasses = {},
  15882. e
  15883. }();
  15884. function fi() {
  15885. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (function(e) {
  15886. var t = 16 * Math.random() | 0;
  15887. return ("x" === e ? t : 3 & t | 8).toString(16)
  15888. }
  15889. ))
  15890. }
  15891. var _i = {
  15892. RandomId: fi
  15893. }
  15894. , mi = function() {
  15895. function e() {}
  15896. return e.Slice = function(e, t, i) {
  15897. return e.slice ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
  15898. }
  15899. ,
  15900. e.SliceToArray = function(e, t, i) {
  15901. return Array.isArray(e) ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
  15902. }
  15903. ,
  15904. e
  15905. }()
  15906. , gi = function() {
  15907. function e() {}
  15908. return Object.defineProperty(e, "BaseUrl", {
  15909. get: function() {
  15910. return qt.BaseUrl
  15911. },
  15912. set: function(e) {
  15913. qt.BaseUrl = e
  15914. },
  15915. enumerable: !1,
  15916. configurable: !0
  15917. }),
  15918. Object.defineProperty(e, "DefaultRetryStrategy", {
  15919. get: function() {
  15920. return qt.DefaultRetryStrategy
  15921. },
  15922. set: function(e) {
  15923. qt.DefaultRetryStrategy = e
  15924. },
  15925. enumerable: !1,
  15926. configurable: !0
  15927. }),
  15928. Object.defineProperty(e, "CorsBehavior", {
  15929. get: function() {
  15930. return qt.CorsBehavior
  15931. },
  15932. set: function(e) {
  15933. qt.CorsBehavior = e
  15934. },
  15935. enumerable: !1,
  15936. configurable: !0
  15937. }),
  15938. Object.defineProperty(e, "UseFallbackTexture", {
  15939. get: function() {
  15940. return E.UseFallbackTexture
  15941. },
  15942. set: function(e) {
  15943. E.UseFallbackTexture = e
  15944. },
  15945. enumerable: !1,
  15946. configurable: !0
  15947. }),
  15948. Object.defineProperty(e, "RegisteredExternalClasses", {
  15949. get: function() {
  15950. return pi.RegisteredExternalClasses
  15951. },
  15952. set: function(e) {
  15953. pi.RegisteredExternalClasses = e
  15954. },
  15955. enumerable: !1,
  15956. configurable: !0
  15957. }),
  15958. Object.defineProperty(e, "fallbackTexture", {
  15959. get: function() {
  15960. return E.FallbackTexture
  15961. },
  15962. set: function(e) {
  15963. E.FallbackTexture = e
  15964. },
  15965. enumerable: !1,
  15966. configurable: !0
  15967. }),
  15968. e.FetchToRef = function(e, t, i, n, r, o) {
  15969. var a = 4 * ((Math.abs(e) * i % i | 0) + (Math.abs(t) * n % n | 0) * i);
  15970. o.r = r[a] / 255,
  15971. o.g = r[a + 1] / 255,
  15972. o.b = r[a + 2] / 255,
  15973. o.a = r[a + 3] / 255
  15974. }
  15975. ,
  15976. e.Mix = function(e, t, i) {
  15977. return e * (1 - i) + t * i
  15978. }
  15979. ,
  15980. e.Instantiate = function(e) {
  15981. return pi.Instantiate(e)
  15982. }
  15983. ,
  15984. e.Slice = function(e, t, i) {
  15985. return mi.Slice(e, t, i)
  15986. }
  15987. ,
  15988. e.SliceToArray = function(e, t, i) {
  15989. return mi.SliceToArray(e, t, i)
  15990. }
  15991. ,
  15992. e.SetImmediate = function(e) {
  15993. Xt.SetImmediate(e)
  15994. }
  15995. ,
  15996. e.IsExponentOfTwo = function(e) {
  15997. var t = 1;
  15998. do {
  15999. t *= 2
  16000. } while (t < e);
  16001. return t === e
  16002. }
  16003. ,
  16004. e.FloatRound = function(t) {
  16005. return Math.fround ? Math.fround(t) : (e._TmpFloatArray[0] = t,
  16006. e._TmpFloatArray[0])
  16007. }
  16008. ,
  16009. e.GetFilename = function(e) {
  16010. var t = e.lastIndexOf("/");
  16011. return t < 0 ? e : e.substring(t + 1)
  16012. }
  16013. ,
  16014. e.GetFolderPath = function(e, t) {
  16015. void 0 === t && (t = !1);
  16016. var i = e.lastIndexOf("/");
  16017. return i < 0 ? t ? e : "" : e.substring(0, i + 1)
  16018. }
  16019. ,
  16020. e.ToDegrees = function(e) {
  16021. return 180 * e / Math.PI
  16022. }
  16023. ,
  16024. e.ToRadians = function(e) {
  16025. return e * Math.PI / 180
  16026. }
  16027. ,
  16028. e.MakeArray = function(e, t) {
  16029. return !0 === t || void 0 !== e && null != e ? Array.isArray(e) ? e : [e] : null
  16030. }
  16031. ,
  16032. e.GetPointerPrefix = function(e) {
  16033. var t = "pointer";
  16034. return nt() && !window.PointerEvent && (t = "mouse"),
  16035. !e._badDesktopOS || e._badOS || document && "ontouchend"in document || (t = "mouse"),
  16036. t
  16037. }
  16038. ,
  16039. e.SetCorsBehavior = function(e, t) {
  16040. Jt(e, t)
  16041. }
  16042. ,
  16043. e.CleanUrl = function(e) {
  16044. return e.replace(/#/gm, "%23")
  16045. }
  16046. ,
  16047. Object.defineProperty(e, "PreprocessUrl", {
  16048. get: function() {
  16049. return qt.PreprocessUrl
  16050. },
  16051. set: function(e) {
  16052. qt.PreprocessUrl = e
  16053. },
  16054. enumerable: !1,
  16055. configurable: !0
  16056. }),
  16057. e.LoadImage = function(e, t, i, n, r, o) {
  16058. return $t(e, t, i, n, r, o)
  16059. }
  16060. ,
  16061. e.LoadFile = function(e, t, i, n, r, o) {
  16062. return ti(e, t, i, n, r, o)
  16063. }
  16064. ,
  16065. e.LoadFileAsync = function(e, t) {
  16066. return void 0 === t && (t = !0),
  16067. new Promise((function(i, n) {
  16068. ti(e, (function(e) {
  16069. i(e)
  16070. }
  16071. ), void 0, void 0, t, (function(e, t) {
  16072. n(t)
  16073. }
  16074. ))
  16075. }
  16076. ))
  16077. }
  16078. ,
  16079. e.LoadScript = function(e, t, i, n) {
  16080. if (nt()) {
  16081. var r = document.getElementsByTagName("head")[0]
  16082. , o = document.createElement("script");
  16083. o.setAttribute("type", "text/javascript"),
  16084. o.setAttribute("src", e),
  16085. n && (o.id = n),
  16086. o.onload = function() {
  16087. t && t()
  16088. }
  16089. ,
  16090. o.onerror = function(t) {
  16091. i && i("Unable to load script '".concat(e, "'"), t)
  16092. }
  16093. ,
  16094. r.appendChild(o)
  16095. }
  16096. }
  16097. ,
  16098. e.LoadScriptAsync = function(e) {
  16099. var t = this;
  16100. return new Promise((function(i, n) {
  16101. t.LoadScript(e, (function() {
  16102. i()
  16103. }
  16104. ), (function(e, t) {
  16105. n(t)
  16106. }
  16107. ))
  16108. }
  16109. ))
  16110. }
  16111. ,
  16112. e.ReadFileAsDataURL = function(e, t, i) {
  16113. var n = new FileReader
  16114. , r = {
  16115. onCompleteObservable: new h,
  16116. abort: function() {
  16117. return n.abort()
  16118. }
  16119. };
  16120. return n.onloadend = function() {
  16121. r.onCompleteObservable.notifyObservers(r)
  16122. }
  16123. ,
  16124. n.onload = function(e) {
  16125. t(e.target.result)
  16126. }
  16127. ,
  16128. n.onprogress = i,
  16129. n.readAsDataURL(e),
  16130. r
  16131. }
  16132. ,
  16133. e.ReadFile = function(e, t, i, n, r) {
  16134. return ei(e, t, i, n, r)
  16135. }
  16136. ,
  16137. e.FileAsURL = function(e) {
  16138. var t = new Blob([e]);
  16139. return (window.URL || window.webkitURL).createObjectURL(t)
  16140. }
  16141. ,
  16142. e.Format = function(e, t) {
  16143. return void 0 === t && (t = 2),
  16144. e.toFixed(t)
  16145. }
  16146. ,
  16147. e.DeepCopy = function(e, t, i, n) {
  16148. fe.DeepCopy(e, t, i, n)
  16149. }
  16150. ,
  16151. e.IsEmpty = function(e) {
  16152. for (var t in e)
  16153. if (Object.prototype.hasOwnProperty.call(e, t))
  16154. return !1;
  16155. return !0
  16156. }
  16157. ,
  16158. e.RegisterTopRootEvents = function(e, t) {
  16159. for (var i = 0; i < t.length; i++) {
  16160. var n = t[i];
  16161. e.addEventListener(n.name, n.handler, !1);
  16162. try {
  16163. window.parent && window.parent.addEventListener(n.name, n.handler, !1)
  16164. } catch (e) {}
  16165. }
  16166. }
  16167. ,
  16168. e.UnregisterTopRootEvents = function(e, t) {
  16169. for (var i = 0; i < t.length; i++) {
  16170. var n = t[i];
  16171. e.removeEventListener(n.name, n.handler);
  16172. try {
  16173. e.parent && e.parent.removeEventListener(n.name, n.handler)
  16174. } catch (e) {}
  16175. }
  16176. }
  16177. ,
  16178. e.DumpFramebuffer = function(t, i, n, r, o, a) {
  16179. return void 0 === o && (o = "image/png"),
  16180. G(this, void 0, void 0, (function() {
  16181. var s, l;
  16182. return z(this, (function(c) {
  16183. switch (c.label) {
  16184. case 0:
  16185. return [4, n.readPixels(0, 0, t, i)];
  16186. case 1:
  16187. return s = c.sent(),
  16188. l = new Uint8Array(s.buffer),
  16189. e.DumpData(t, i, l, r, o, a, !0),
  16190. [2]
  16191. }
  16192. }
  16193. ))
  16194. }
  16195. ))
  16196. }
  16197. ,
  16198. e.DumpData = function(t, i, n, r, o, a, s, l, c) {
  16199. void 0 === o && (o = "image/png"),
  16200. void 0 === s && (s = !1),
  16201. void 0 === l && (l = !1),
  16202. e._ScreenshotCanvas || (e._ScreenshotCanvas = document.createElement("canvas")),
  16203. e._ScreenshotCanvas.width = t,
  16204. e._ScreenshotCanvas.height = i;
  16205. var u = e._ScreenshotCanvas.getContext("2d");
  16206. if (u) {
  16207. if (n instanceof Float32Array) {
  16208. for (var h = new Uint8Array(n.length), d = n.length; d--; ) {
  16209. var p = n[d];
  16210. h[d] = p < 0 ? 0 : p > 1 ? 1 : Math.round(255 * p)
  16211. }
  16212. n = h
  16213. }
  16214. var f = u.createImageData(t, i);
  16215. f.data.set(n),
  16216. u.putImageData(f, 0, 0);
  16217. var _ = e._ScreenshotCanvas;
  16218. if (s) {
  16219. var m = document.createElement("canvas");
  16220. m.width = t,
  16221. m.height = i;
  16222. var g = m.getContext("2d");
  16223. if (!g)
  16224. return;
  16225. g.translate(0, i),
  16226. g.scale(1, -1),
  16227. g.drawImage(e._ScreenshotCanvas, 0, 0),
  16228. _ = m
  16229. }
  16230. l ? e.ToBlob(_, (function(e) {
  16231. var t = new FileReader;
  16232. t.onload = function(e) {
  16233. var t = e.target.result;
  16234. r && r(t)
  16235. }
  16236. ,
  16237. t.readAsArrayBuffer(e)
  16238. }
  16239. ), o, c) : e.EncodeScreenshotCanvasData(r, o, a, _, c)
  16240. }
  16241. }
  16242. ,
  16243. e.DumpDataAsync = function(t, i, n, r, o, a, s, l) {
  16244. return void 0 === r && (r = "image/png"),
  16245. void 0 === a && (a = !1),
  16246. void 0 === s && (s = !1),
  16247. new Promise((function(c) {
  16248. e.DumpData(t, i, n, (function(e) {
  16249. return c(e)
  16250. }
  16251. ), r, o, a, s, l)
  16252. }
  16253. ))
  16254. }
  16255. ,
  16256. e.ToBlob = function(e, t, i, n) {
  16257. void 0 === i && (i = "image/png"),
  16258. e.toBlob || (e.toBlob = function(e, t, i) {
  16259. var n = this;
  16260. setTimeout((function() {
  16261. for (var r = atob(n.toDataURL(t, i).split(",")[1]), o = r.length, a = new Uint8Array(o), s = 0; s < o; s++)
  16262. a[s] = r.charCodeAt(s);
  16263. e(new Blob([a]))
  16264. }
  16265. ))
  16266. }
  16267. ),
  16268. e.toBlob((function(e) {
  16269. t(e)
  16270. }
  16271. ), i, n)
  16272. }
  16273. ,
  16274. e.EncodeScreenshotCanvasData = function(t, i, n, r, o) {
  16275. void 0 === i && (i = "image/png"),
  16276. t ? t((null != r ? r : e._ScreenshotCanvas).toDataURL(i, o)) : this.ToBlob(null != r ? r : e._ScreenshotCanvas, (function(t) {
  16277. if ("download"in document.createElement("a")) {
  16278. if (!n) {
  16279. var i = new Date
  16280. , r = (i.getFullYear() + "-" + (i.getMonth() + 1)).slice(2) + "-" + i.getDate() + "_" + i.getHours() + "-" + ("0" + i.getMinutes()).slice(-2);
  16281. n = "screenshot_" + r + ".png"
  16282. }
  16283. e.Download(t, n)
  16284. } else if (t) {
  16285. var o = URL.createObjectURL(t)
  16286. , a = window.open("");
  16287. if (!a)
  16288. return;
  16289. var s = a.document.createElement("img");
  16290. s.onload = function() {
  16291. URL.revokeObjectURL(o)
  16292. }
  16293. ,
  16294. s.src = o,
  16295. a.document.body.appendChild(s)
  16296. }
  16297. }
  16298. ), i, o)
  16299. }
  16300. ,
  16301. e.Download = function(e, t) {
  16302. if (navigator && navigator.msSaveBlob)
  16303. navigator.msSaveBlob(e, t);
  16304. else {
  16305. var i = window.URL.createObjectURL(e)
  16306. , n = document.createElement("a");
  16307. document.body.appendChild(n),
  16308. n.style.display = "none",
  16309. n.href = i,
  16310. n.download = t,
  16311. n.addEventListener("click", (function() {
  16312. n.parentElement && n.parentElement.removeChild(n)
  16313. }
  16314. )),
  16315. n.click(),
  16316. window.URL.revokeObjectURL(i)
  16317. }
  16318. }
  16319. ,
  16320. e.BackCompatCameraNoPreventDefault = function(e) {
  16321. return "boolean" == typeof e[0] ? e[0] : "boolean" == typeof e[1] && e[1]
  16322. }
  16323. ,
  16324. e.CreateScreenshot = function(e, t, i, n, r) {
  16325. throw void 0 === r && (r = "image/png"),
  16326. be("ScreenshotTools")
  16327. }
  16328. ,
  16329. e.CreateScreenshotAsync = function(e, t, i, n) {
  16330. throw void 0 === n && (n = "image/png"),
  16331. be("ScreenshotTools")
  16332. }
  16333. ,
  16334. e.CreateScreenshotUsingRenderTarget = function(e, t, i, n, r, o, a, s) {
  16335. throw void 0 === r && (r = "image/png"),
  16336. void 0 === o && (o = 1),
  16337. void 0 === a && (a = !1),
  16338. be("ScreenshotTools")
  16339. }
  16340. ,
  16341. e.CreateScreenshotUsingRenderTargetAsync = function(e, t, i, n, r, o, a) {
  16342. throw void 0 === n && (n = "image/png"),
  16343. void 0 === r && (r = 1),
  16344. void 0 === o && (o = !1),
  16345. be("ScreenshotTools")
  16346. }
  16347. ,
  16348. e.RandomId = function() {
  16349. return fi()
  16350. }
  16351. ,
  16352. e.IsBase64 = function(e) {
  16353. return ri(e)
  16354. }
  16355. ,
  16356. e.DecodeBase64 = function(e) {
  16357. return oi(e)
  16358. }
  16359. ,
  16360. Object.defineProperty(e, "errorsCount", {
  16361. get: function() {
  16362. return K.errorsCount
  16363. },
  16364. enumerable: !1,
  16365. configurable: !0
  16366. }),
  16367. e.Log = function(e) {
  16368. K.Log(e)
  16369. }
  16370. ,
  16371. e.Warn = function(e) {
  16372. K.Warn(e)
  16373. }
  16374. ,
  16375. e.Error = function(e) {
  16376. K.Error(e)
  16377. }
  16378. ,
  16379. Object.defineProperty(e, "LogCache", {
  16380. get: function() {
  16381. return K.LogCache
  16382. },
  16383. enumerable: !1,
  16384. configurable: !0
  16385. }),
  16386. e.ClearLogCache = function() {
  16387. K.ClearLogCache()
  16388. }
  16389. ,
  16390. Object.defineProperty(e, "LogLevels", {
  16391. set: function(e) {
  16392. K.LogLevels = e
  16393. },
  16394. enumerable: !1,
  16395. configurable: !0
  16396. }),
  16397. Object.defineProperty(e, "PerformanceLogLevel", {
  16398. set: function(t) {
  16399. return (t & e.PerformanceUserMarkLogLevel) === e.PerformanceUserMarkLogLevel ? (e.StartPerformanceCounter = e._StartUserMark,
  16400. void (e.EndPerformanceCounter = e._EndUserMark)) : (t & e.PerformanceConsoleLogLevel) === e.PerformanceConsoleLogLevel ? (e.StartPerformanceCounter = e._StartPerformanceConsole,
  16401. void (e.EndPerformanceCounter = e._EndPerformanceConsole)) : (e.StartPerformanceCounter = e._StartPerformanceCounterDisabled,
  16402. void (e.EndPerformanceCounter = e._EndPerformanceCounterDisabled))
  16403. },
  16404. enumerable: !1,
  16405. configurable: !0
  16406. }),
  16407. e._StartPerformanceCounterDisabled = function(e, t) {}
  16408. ,
  16409. e._EndPerformanceCounterDisabled = function(e, t) {}
  16410. ,
  16411. e._StartUserMark = function(t, i) {
  16412. if (void 0 === i && (i = !0),
  16413. !e._Performance) {
  16414. if (!nt())
  16415. return;
  16416. e._Performance = window.performance
  16417. }
  16418. i && e._Performance.mark && e._Performance.mark(t + "-Begin")
  16419. }
  16420. ,
  16421. e._EndUserMark = function(t, i) {
  16422. void 0 === i && (i = !0),
  16423. i && e._Performance.mark && (e._Performance.mark(t + "-End"),
  16424. e._Performance.measure(t, t + "-Begin", t + "-End"))
  16425. }
  16426. ,
  16427. e._StartPerformanceConsole = function(t, i) {
  16428. void 0 === i && (i = !0),
  16429. i && (e._StartUserMark(t, i),
  16430. console.time && console.time(t))
  16431. }
  16432. ,
  16433. e._EndPerformanceConsole = function(t, i) {
  16434. void 0 === i && (i = !0),
  16435. i && (e._EndUserMark(t, i),
  16436. console.timeEnd(t))
  16437. }
  16438. ,
  16439. Object.defineProperty(e, "Now", {
  16440. get: function() {
  16441. return ct.Now
  16442. },
  16443. enumerable: !1,
  16444. configurable: !0
  16445. }),
  16446. e.GetClassName = function(e, t) {
  16447. void 0 === t && (t = !1);
  16448. var i = null;
  16449. return !t && e.getClassName ? i = e.getClassName() : (e instanceof Object && (i = (t ? e : Object.getPrototypeOf(e)).constructor.__bjsclassName__),
  16450. i || (i = typeof e)),
  16451. i
  16452. }
  16453. ,
  16454. e.First = function(e, t) {
  16455. for (var i = 0, n = e; i < n.length; i++) {
  16456. var r = n[i];
  16457. if (t(r))
  16458. return r
  16459. }
  16460. return null
  16461. }
  16462. ,
  16463. e.getFullClassName = function(e, t) {
  16464. void 0 === t && (t = !1);
  16465. var i = null
  16466. , n = null;
  16467. if (!t && e.getClassName)
  16468. i = e.getClassName();
  16469. else {
  16470. if (e instanceof Object) {
  16471. var r = t ? e : Object.getPrototypeOf(e);
  16472. i = r.constructor.__bjsclassName__,
  16473. n = r.constructor.__bjsmoduleName__
  16474. }
  16475. i || (i = typeof e)
  16476. }
  16477. return i ? (null != n ? n + "." : "") + i : null
  16478. }
  16479. ,
  16480. e.DelayAsync = function(e) {
  16481. return new Promise((function(t) {
  16482. setTimeout((function() {
  16483. t()
  16484. }
  16485. ), e)
  16486. }
  16487. ))
  16488. }
  16489. ,
  16490. e.IsSafari = function() {
  16491. return !!rt() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
  16492. }
  16493. ,
  16494. e.UseCustomRequestHeaders = !1,
  16495. e.CustomRequestHeaders = Ye.CustomRequestHeaders,
  16496. e._TmpFloatArray = new Float32Array(1),
  16497. e.GetDOMTextContent = at,
  16498. e.GetAbsoluteUrl = "object" == typeof document ? function(e) {
  16499. var t = document.createElement("a");
  16500. return t.href = e,
  16501. t.href
  16502. }
  16503. : "function" == typeof URL && "object" == typeof location ? function(e) {
  16504. return new URL(e,location.origin).href
  16505. }
  16506. : function() {
  16507. throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")
  16508. }
  16509. ,
  16510. e.NoneLogLevel = K.NoneLogLevel,
  16511. e.MessageLogLevel = K.MessageLogLevel,
  16512. e.WarningLogLevel = K.WarningLogLevel,
  16513. e.ErrorLogLevel = K.ErrorLogLevel,
  16514. e.AllLogLevel = K.AllLogLevel,
  16515. e.IsWindowObjectExist = nt,
  16516. e.PerformanceNoneLogLevel = 0,
  16517. e.PerformanceUserMarkLogLevel = 1,
  16518. e.PerformanceConsoleLogLevel = 2,
  16519. e.StartPerformanceCounter = e._StartPerformanceCounterDisabled,
  16520. e.EndPerformanceCounter = e._EndPerformanceCounterDisabled,
  16521. e
  16522. }();
  16523. function vi(e, t) {
  16524. return function(i) {
  16525. i.__bjsclassName__ = e,
  16526. i.__bjsmoduleName__ = null != t ? t : null
  16527. }
  16528. }
  16529. var yi = function() {
  16530. function e(e, t, i, n) {
  16531. void 0 === n && (n = 0),
  16532. this.iterations = e,
  16533. this.index = n - 1,
  16534. this._done = !1,
  16535. this._fn = t,
  16536. this._successCallback = i
  16537. }
  16538. return e.prototype.executeNext = function() {
  16539. this._done || (this.index + 1 < this.iterations ? (++this.index,
  16540. this._fn(this)) : this.breakLoop())
  16541. }
  16542. ,
  16543. e.prototype.breakLoop = function() {
  16544. this._done = !0,
  16545. this._successCallback()
  16546. }
  16547. ,
  16548. e.Run = function(t, i, n, r) {
  16549. void 0 === r && (r = 0);
  16550. var o = new e(t,i,n,r);
  16551. return o.executeNext(),
  16552. o
  16553. }
  16554. ,
  16555. e.SyncAsyncForLoop = function(t, i, n, r, o, a) {
  16556. return void 0 === a && (a = 0),
  16557. e.Run(Math.ceil(t / i), (function(e) {
  16558. o && o() ? e.breakLoop() : setTimeout((function() {
  16559. for (var r = 0; r < i; ++r) {
  16560. var a = e.index * i + r;
  16561. if (a >= t)
  16562. break;
  16563. if (n(a),
  16564. o && o()) {
  16565. e.breakLoop();
  16566. break
  16567. }
  16568. }
  16569. e.executeNext()
  16570. }
  16571. ), a)
  16572. }
  16573. ), r)
  16574. }
  16575. ,
  16576. e
  16577. }();
  16578. E.FallbackTexture = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",
  16579. di.Apply();
  16580. var bi = function() {
  16581. function e(t) {
  16582. this.length = 0,
  16583. this.data = new Array(t),
  16584. this._id = e._GlobalId++
  16585. }
  16586. return e.prototype.push = function(e) {
  16587. this.data[this.length++] = e,
  16588. this.length > this.data.length && (this.data.length *= 2)
  16589. }
  16590. ,
  16591. e.prototype.forEach = function(e) {
  16592. for (var t = 0; t < this.length; t++)
  16593. e(this.data[t])
  16594. }
  16595. ,
  16596. e.prototype.sort = function(e) {
  16597. this.data.sort(e)
  16598. }
  16599. ,
  16600. e.prototype.reset = function() {
  16601. this.length = 0
  16602. }
  16603. ,
  16604. e.prototype.dispose = function() {
  16605. this.reset(),
  16606. this.data && (this.data.length = 0,
  16607. this.data = [])
  16608. }
  16609. ,
  16610. e.prototype.concat = function(e) {
  16611. if (0 !== e.length) {
  16612. this.length + e.length > this.data.length && (this.data.length = 2 * (this.length + e.length));
  16613. for (var t = 0; t < e.length; t++)
  16614. this.data[this.length++] = (e.data || e)[t]
  16615. }
  16616. }
  16617. ,
  16618. e.prototype.indexOf = function(e) {
  16619. var t = this.data.indexOf(e);
  16620. return t >= this.length ? -1 : t
  16621. }
  16622. ,
  16623. e.prototype.contains = function(e) {
  16624. return -1 !== this.indexOf(e)
  16625. }
  16626. ,
  16627. e._GlobalId = 0,
  16628. e
  16629. }()
  16630. , Ti = function(e) {
  16631. function t() {
  16632. var t = null !== e && e.apply(this, arguments) || this;
  16633. return t._duplicateId = 0,
  16634. t
  16635. }
  16636. return U(t, e),
  16637. t.prototype.push = function(t) {
  16638. e.prototype.push.call(this, t),
  16639. t.__smartArrayFlags || (t.__smartArrayFlags = {}),
  16640. t.__smartArrayFlags[this._id] = this._duplicateId
  16641. }
  16642. ,
  16643. t.prototype.pushNoDuplicate = function(e) {
  16644. return !(e.__smartArrayFlags && e.__smartArrayFlags[this._id] === this._duplicateId || (this.push(e),
  16645. 0))
  16646. }
  16647. ,
  16648. t.prototype.reset = function() {
  16649. e.prototype.reset.call(this),
  16650. this._duplicateId++
  16651. }
  16652. ,
  16653. t.prototype.concatWithNoDuplicate = function(e) {
  16654. if (0 !== e.length) {
  16655. this.length + e.length > this.data.length && (this.data.length = 2 * (this.length + e.length));
  16656. for (var t = 0; t < e.length; t++) {
  16657. var i = (e.data || e)[t];
  16658. this.pushNoDuplicate(i)
  16659. }
  16660. }
  16661. }
  16662. ,
  16663. t
  16664. }(bi)
  16665. , Ei = function() {
  16666. function e() {
  16667. this._count = 0,
  16668. this._data = {}
  16669. }
  16670. return e.prototype.copyFrom = function(e) {
  16671. var t = this;
  16672. this.clear(),
  16673. e.forEach((function(e, i) {
  16674. return t.add(e, i)
  16675. }
  16676. ))
  16677. }
  16678. ,
  16679. e.prototype.get = function(e) {
  16680. var t = this._data[e];
  16681. if (void 0 !== t)
  16682. return t
  16683. }
  16684. ,
  16685. e.prototype.getOrAddWithFactory = function(e, t) {
  16686. var i = this.get(e);
  16687. return void 0 !== i || (i = t(e)) && this.add(e, i),
  16688. i
  16689. }
  16690. ,
  16691. e.prototype.getOrAdd = function(e, t) {
  16692. var i = this.get(e);
  16693. return void 0 !== i ? i : (this.add(e, t),
  16694. t)
  16695. }
  16696. ,
  16697. e.prototype.contains = function(e) {
  16698. return void 0 !== this._data[e]
  16699. }
  16700. ,
  16701. e.prototype.add = function(e, t) {
  16702. return void 0 === this._data[e] && (this._data[e] = t,
  16703. ++this._count,
  16704. !0)
  16705. }
  16706. ,
  16707. e.prototype.set = function(e, t) {
  16708. return void 0 !== this._data[e] && (this._data[e] = t,
  16709. !0)
  16710. }
  16711. ,
  16712. e.prototype.getAndRemove = function(e) {
  16713. var t = this.get(e);
  16714. return void 0 !== t ? (delete this._data[e],
  16715. --this._count,
  16716. t) : null
  16717. }
  16718. ,
  16719. e.prototype.remove = function(e) {
  16720. return !!this.contains(e) && (delete this._data[e],
  16721. --this._count,
  16722. !0)
  16723. }
  16724. ,
  16725. e.prototype.clear = function() {
  16726. this._data = {},
  16727. this._count = 0
  16728. }
  16729. ,
  16730. Object.defineProperty(e.prototype, "count", {
  16731. get: function() {
  16732. return this._count
  16733. },
  16734. enumerable: !1,
  16735. configurable: !0
  16736. }),
  16737. e.prototype.forEach = function(e) {
  16738. for (var t in this._data)
  16739. e(t, this._data[t])
  16740. }
  16741. ,
  16742. e.prototype.first = function(e) {
  16743. for (var t in this._data) {
  16744. var i = e(t, this._data[t]);
  16745. if (i)
  16746. return i
  16747. }
  16748. return null
  16749. }
  16750. ,
  16751. e
  16752. }()
  16753. , Si = function() {
  16754. function e(e) {
  16755. if (this._isDirty = !0,
  16756. this._areLightsDirty = !0,
  16757. this._areLightsDisposed = !1,
  16758. this._areAttributesDirty = !0,
  16759. this._areTexturesDirty = !0,
  16760. this._areFresnelDirty = !0,
  16761. this._areMiscDirty = !0,
  16762. this._arePrePassDirty = !0,
  16763. this._areImageProcessingDirty = !0,
  16764. this._normals = !1,
  16765. this._uvs = !1,
  16766. this._needNormals = !1,
  16767. this._needUVs = !1,
  16768. this._externalProperties = e,
  16769. e)
  16770. for (var t in e)
  16771. Object.prototype.hasOwnProperty.call(e, t) && this._setDefaultValue(t)
  16772. }
  16773. return Object.defineProperty(e.prototype, "isDirty", {
  16774. get: function() {
  16775. return this._isDirty
  16776. },
  16777. enumerable: !1,
  16778. configurable: !0
  16779. }),
  16780. e.prototype.markAsProcessed = function() {
  16781. this._isDirty = !1,
  16782. this._areAttributesDirty = !1,
  16783. this._areTexturesDirty = !1,
  16784. this._areFresnelDirty = !1,
  16785. this._areLightsDirty = !1,
  16786. this._areLightsDisposed = !1,
  16787. this._areMiscDirty = !1,
  16788. this._arePrePassDirty = !1,
  16789. this._areImageProcessingDirty = !1
  16790. }
  16791. ,
  16792. e.prototype.markAsUnprocessed = function() {
  16793. this._isDirty = !0
  16794. }
  16795. ,
  16796. e.prototype.markAllAsDirty = function() {
  16797. this._areTexturesDirty = !0,
  16798. this._areAttributesDirty = !0,
  16799. this._areLightsDirty = !0,
  16800. this._areFresnelDirty = !0,
  16801. this._areMiscDirty = !0,
  16802. this._areImageProcessingDirty = !0,
  16803. this._isDirty = !0
  16804. }
  16805. ,
  16806. e.prototype.markAsImageProcessingDirty = function() {
  16807. this._areImageProcessingDirty = !0,
  16808. this._isDirty = !0
  16809. }
  16810. ,
  16811. e.prototype.markAsLightDirty = function(e) {
  16812. void 0 === e && (e = !1),
  16813. this._areLightsDirty = !0,
  16814. this._areLightsDisposed = this._areLightsDisposed || e,
  16815. this._isDirty = !0
  16816. }
  16817. ,
  16818. e.prototype.markAsAttributesDirty = function() {
  16819. this._areAttributesDirty = !0,
  16820. this._isDirty = !0
  16821. }
  16822. ,
  16823. e.prototype.markAsTexturesDirty = function() {
  16824. this._areTexturesDirty = !0,
  16825. this._isDirty = !0
  16826. }
  16827. ,
  16828. e.prototype.markAsFresnelDirty = function() {
  16829. this._areFresnelDirty = !0,
  16830. this._isDirty = !0
  16831. }
  16832. ,
  16833. e.prototype.markAsMiscDirty = function() {
  16834. this._areMiscDirty = !0,
  16835. this._isDirty = !0
  16836. }
  16837. ,
  16838. e.prototype.markAsPrePassDirty = function() {
  16839. this._arePrePassDirty = !0,
  16840. this._isDirty = !0
  16841. }
  16842. ,
  16843. e.prototype.rebuild = function() {
  16844. this._keys = [];
  16845. for (var e = 0, t = Object.keys(this); e < t.length; e++) {
  16846. var i = t[e];
  16847. "_" !== i[0] && this._keys.push(i)
  16848. }
  16849. if (this._externalProperties)
  16850. for (var n in this._externalProperties)
  16851. this._keys.push(n)
  16852. }
  16853. ,
  16854. e.prototype.isEqual = function(e) {
  16855. if (this._keys.length !== e._keys.length)
  16856. return !1;
  16857. for (var t = 0; t < this._keys.length; t++) {
  16858. var i = this._keys[t];
  16859. if (this[i] !== e[i])
  16860. return !1
  16861. }
  16862. return !0
  16863. }
  16864. ,
  16865. e.prototype.cloneTo = function(e) {
  16866. this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0));
  16867. for (var t = 0; t < this._keys.length; t++) {
  16868. var i = this._keys[t];
  16869. e[i] = this[i]
  16870. }
  16871. }
  16872. ,
  16873. e.prototype.reset = function() {
  16874. var e = this;
  16875. this._keys.forEach((function(t) {
  16876. return e._setDefaultValue(t)
  16877. }
  16878. ))
  16879. }
  16880. ,
  16881. e.prototype._setDefaultValue = function(e) {
  16882. var t, i, n, r, o, a = null !== (n = null === (i = null === (t = this._externalProperties) || void 0 === t ? void 0 : t[e]) || void 0 === i ? void 0 : i.type) && void 0 !== n ? n : typeof this[e], s = null === (o = null === (r = this._externalProperties) || void 0 === r ? void 0 : r[e]) || void 0 === o ? void 0 : o.default;
  16883. switch (a) {
  16884. case "number":
  16885. this[e] = null != s ? s : 0;
  16886. break;
  16887. case "string":
  16888. this[e] = null != s ? s : "";
  16889. break;
  16890. default:
  16891. this[e] = null != s && s
  16892. }
  16893. }
  16894. ,
  16895. e.prototype.toString = function() {
  16896. for (var e = "", t = 0; t < this._keys.length; t++) {
  16897. var i = this._keys[t]
  16898. , n = this[i];
  16899. switch (typeof n) {
  16900. case "number":
  16901. case "string":
  16902. e += "#define " + i + " " + n + "\n";
  16903. break;
  16904. default:
  16905. n && (e += "#define " + i + "\n")
  16906. }
  16907. }
  16908. return e
  16909. }
  16910. ,
  16911. e
  16912. }()
  16913. , Ai = function() {
  16914. function e() {
  16915. this._dirty = !0,
  16916. this._tempColor = new N(0,0,0,0),
  16917. this._globalCurve = new N(0,0,0,0),
  16918. this._highlightsCurve = new N(0,0,0,0),
  16919. this._midtonesCurve = new N(0,0,0,0),
  16920. this._shadowsCurve = new N(0,0,0,0),
  16921. this._positiveCurve = new N(0,0,0,0),
  16922. this._negativeCurve = new N(0,0,0,0),
  16923. this._globalHue = 30,
  16924. this._globalDensity = 0,
  16925. this._globalSaturation = 0,
  16926. this._globalExposure = 0,
  16927. this._highlightsHue = 30,
  16928. this._highlightsDensity = 0,
  16929. this._highlightsSaturation = 0,
  16930. this._highlightsExposure = 0,
  16931. this._midtonesHue = 30,
  16932. this._midtonesDensity = 0,
  16933. this._midtonesSaturation = 0,
  16934. this._midtonesExposure = 0,
  16935. this._shadowsHue = 30,
  16936. this._shadowsDensity = 0,
  16937. this._shadowsSaturation = 0,
  16938. this._shadowsExposure = 0
  16939. }
  16940. return Object.defineProperty(e.prototype, "globalHue", {
  16941. get: function() {
  16942. return this._globalHue
  16943. },
  16944. set: function(e) {
  16945. this._globalHue = e,
  16946. this._dirty = !0
  16947. },
  16948. enumerable: !1,
  16949. configurable: !0
  16950. }),
  16951. Object.defineProperty(e.prototype, "globalDensity", {
  16952. get: function() {
  16953. return this._globalDensity
  16954. },
  16955. set: function(e) {
  16956. this._globalDensity = e,
  16957. this._dirty = !0
  16958. },
  16959. enumerable: !1,
  16960. configurable: !0
  16961. }),
  16962. Object.defineProperty(e.prototype, "globalSaturation", {
  16963. get: function() {
  16964. return this._globalSaturation
  16965. },
  16966. set: function(e) {
  16967. this._globalSaturation = e,
  16968. this._dirty = !0
  16969. },
  16970. enumerable: !1,
  16971. configurable: !0
  16972. }),
  16973. Object.defineProperty(e.prototype, "globalExposure", {
  16974. get: function() {
  16975. return this._globalExposure
  16976. },
  16977. set: function(e) {
  16978. this._globalExposure = e,
  16979. this._dirty = !0
  16980. },
  16981. enumerable: !1,
  16982. configurable: !0
  16983. }),
  16984. Object.defineProperty(e.prototype, "highlightsHue", {
  16985. get: function() {
  16986. return this._highlightsHue
  16987. },
  16988. set: function(e) {
  16989. this._highlightsHue = e,
  16990. this._dirty = !0
  16991. },
  16992. enumerable: !1,
  16993. configurable: !0
  16994. }),
  16995. Object.defineProperty(e.prototype, "highlightsDensity", {
  16996. get: function() {
  16997. return this._highlightsDensity
  16998. },
  16999. set: function(e) {
  17000. this._highlightsDensity = e,
  17001. this._dirty = !0
  17002. },
  17003. enumerable: !1,
  17004. configurable: !0
  17005. }),
  17006. Object.defineProperty(e.prototype, "highlightsSaturation", {
  17007. get: function() {
  17008. return this._highlightsSaturation
  17009. },
  17010. set: function(e) {
  17011. this._highlightsSaturation = e,
  17012. this._dirty = !0
  17013. },
  17014. enumerable: !1,
  17015. configurable: !0
  17016. }),
  17017. Object.defineProperty(e.prototype, "highlightsExposure", {
  17018. get: function() {
  17019. return this._highlightsExposure
  17020. },
  17021. set: function(e) {
  17022. this._highlightsExposure = e,
  17023. this._dirty = !0
  17024. },
  17025. enumerable: !1,
  17026. configurable: !0
  17027. }),
  17028. Object.defineProperty(e.prototype, "midtonesHue", {
  17029. get: function() {
  17030. return this._midtonesHue
  17031. },
  17032. set: function(e) {
  17033. this._midtonesHue = e,
  17034. this._dirty = !0
  17035. },
  17036. enumerable: !1,
  17037. configurable: !0
  17038. }),
  17039. Object.defineProperty(e.prototype, "midtonesDensity", {
  17040. get: function() {
  17041. return this._midtonesDensity
  17042. },
  17043. set: function(e) {
  17044. this._midtonesDensity = e,
  17045. this._dirty = !0
  17046. },
  17047. enumerable: !1,
  17048. configurable: !0
  17049. }),
  17050. Object.defineProperty(e.prototype, "midtonesSaturation", {
  17051. get: function() {
  17052. return this._midtonesSaturation
  17053. },
  17054. set: function(e) {
  17055. this._midtonesSaturation = e,
  17056. this._dirty = !0
  17057. },
  17058. enumerable: !1,
  17059. configurable: !0
  17060. }),
  17061. Object.defineProperty(e.prototype, "midtonesExposure", {
  17062. get: function() {
  17063. return this._midtonesExposure
  17064. },
  17065. set: function(e) {
  17066. this._midtonesExposure = e,
  17067. this._dirty = !0
  17068. },
  17069. enumerable: !1,
  17070. configurable: !0
  17071. }),
  17072. Object.defineProperty(e.prototype, "shadowsHue", {
  17073. get: function() {
  17074. return this._shadowsHue
  17075. },
  17076. set: function(e) {
  17077. this._shadowsHue = e,
  17078. this._dirty = !0
  17079. },
  17080. enumerable: !1,
  17081. configurable: !0
  17082. }),
  17083. Object.defineProperty(e.prototype, "shadowsDensity", {
  17084. get: function() {
  17085. return this._shadowsDensity
  17086. },
  17087. set: function(e) {
  17088. this._shadowsDensity = e,
  17089. this._dirty = !0
  17090. },
  17091. enumerable: !1,
  17092. configurable: !0
  17093. }),
  17094. Object.defineProperty(e.prototype, "shadowsSaturation", {
  17095. get: function() {
  17096. return this._shadowsSaturation
  17097. },
  17098. set: function(e) {
  17099. this._shadowsSaturation = e,
  17100. this._dirty = !0
  17101. },
  17102. enumerable: !1,
  17103. configurable: !0
  17104. }),
  17105. Object.defineProperty(e.prototype, "shadowsExposure", {
  17106. get: function() {
  17107. return this._shadowsExposure
  17108. },
  17109. set: function(e) {
  17110. this._shadowsExposure = e,
  17111. this._dirty = !0
  17112. },
  17113. enumerable: !1,
  17114. configurable: !0
  17115. }),
  17116. e.prototype.getClassName = function() {
  17117. return "ColorCurves"
  17118. }
  17119. ,
  17120. e.Bind = function(e, t, i, n, r) {
  17121. void 0 === i && (i = "vCameraColorCurvePositive"),
  17122. void 0 === n && (n = "vCameraColorCurveNeutral"),
  17123. void 0 === r && (r = "vCameraColorCurveNegative"),
  17124. e._dirty && (e._dirty = !1,
  17125. e._getColorGradingDataToRef(e._globalHue, e._globalDensity, e._globalSaturation, e._globalExposure, e._globalCurve),
  17126. e._getColorGradingDataToRef(e._highlightsHue, e._highlightsDensity, e._highlightsSaturation, e._highlightsExposure, e._tempColor),
  17127. e._tempColor.multiplyToRef(e._globalCurve, e._highlightsCurve),
  17128. e._getColorGradingDataToRef(e._midtonesHue, e._midtonesDensity, e._midtonesSaturation, e._midtonesExposure, e._tempColor),
  17129. e._tempColor.multiplyToRef(e._globalCurve, e._midtonesCurve),
  17130. e._getColorGradingDataToRef(e._shadowsHue, e._shadowsDensity, e._shadowsSaturation, e._shadowsExposure, e._tempColor),
  17131. e._tempColor.multiplyToRef(e._globalCurve, e._shadowsCurve),
  17132. e._highlightsCurve.subtractToRef(e._midtonesCurve, e._positiveCurve),
  17133. e._midtonesCurve.subtractToRef(e._shadowsCurve, e._negativeCurve)),
  17134. t && (t.setFloat4(i, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a),
  17135. t.setFloat4(n, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
  17136. t.setFloat4(r, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a))
  17137. }
  17138. ,
  17139. e.PrepareUniforms = function(e) {
  17140. e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative")
  17141. }
  17142. ,
  17143. e.prototype._getColorGradingDataToRef = function(t, i, n, r, o) {
  17144. null != t && (t = e._Clamp(t, 0, 360),
  17145. i = e._Clamp(i, -100, 100),
  17146. n = e._Clamp(n, -100, 100),
  17147. r = e._Clamp(r, -100, 100),
  17148. i = e._ApplyColorGradingSliderNonlinear(i),
  17149. i *= .5,
  17150. r = e._ApplyColorGradingSliderNonlinear(r),
  17151. i < 0 && (i *= -1,
  17152. t = (t + 180) % 360),
  17153. e._FromHSBToRef(t, i, 50 + .25 * r, o),
  17154. o.scaleToRef(2, o),
  17155. o.a = 1 + .01 * n)
  17156. }
  17157. ,
  17158. e._ApplyColorGradingSliderNonlinear = function(e) {
  17159. e /= 100;
  17160. var t = Math.abs(e);
  17161. return t = Math.pow(t, 2),
  17162. e < 0 && (t *= -1),
  17163. 100 * t
  17164. }
  17165. ,
  17166. e._FromHSBToRef = function(t, i, n, r) {
  17167. var o = e._Clamp(t, 0, 360)
  17168. , a = e._Clamp(i / 100, 0, 1)
  17169. , s = e._Clamp(n / 100, 0, 1);
  17170. if (0 === a)
  17171. r.r = s,
  17172. r.g = s,
  17173. r.b = s;
  17174. else {
  17175. o /= 60;
  17176. var l = Math.floor(o)
  17177. , c = o - l
  17178. , u = s * (1 - a)
  17179. , h = s * (1 - a * c)
  17180. , d = s * (1 - a * (1 - c));
  17181. switch (l) {
  17182. case 0:
  17183. r.r = s,
  17184. r.g = d,
  17185. r.b = u;
  17186. break;
  17187. case 1:
  17188. r.r = h,
  17189. r.g = s,
  17190. r.b = u;
  17191. break;
  17192. case 2:
  17193. r.r = u,
  17194. r.g = s,
  17195. r.b = d;
  17196. break;
  17197. case 3:
  17198. r.r = u,
  17199. r.g = h,
  17200. r.b = s;
  17201. break;
  17202. case 4:
  17203. r.r = d,
  17204. r.g = u,
  17205. r.b = s;
  17206. break;
  17207. default:
  17208. r.r = s,
  17209. r.g = u,
  17210. r.b = h
  17211. }
  17212. }
  17213. r.a = 1
  17214. }
  17215. ,
  17216. e._Clamp = function(e, t, i) {
  17217. return Math.min(Math.max(e, t), i)
  17218. }
  17219. ,
  17220. e.prototype.clone = function() {
  17221. return Ge.Clone((function() {
  17222. return new e
  17223. }
  17224. ), this)
  17225. }
  17226. ,
  17227. e.prototype.serialize = function() {
  17228. return Ge.Serialize(this)
  17229. }
  17230. ,
  17231. e.Parse = function(t) {
  17232. return Ge.Parse((function() {
  17233. return new e
  17234. }
  17235. ), t, null, null)
  17236. }
  17237. ,
  17238. k([Ce()], e.prototype, "_globalHue", void 0),
  17239. k([Ce()], e.prototype, "_globalDensity", void 0),
  17240. k([Ce()], e.prototype, "_globalSaturation", void 0),
  17241. k([Ce()], e.prototype, "_globalExposure", void 0),
  17242. k([Ce()], e.prototype, "_highlightsHue", void 0),
  17243. k([Ce()], e.prototype, "_highlightsDensity", void 0),
  17244. k([Ce()], e.prototype, "_highlightsSaturation", void 0),
  17245. k([Ce()], e.prototype, "_highlightsExposure", void 0),
  17246. k([Ce()], e.prototype, "_midtonesHue", void 0),
  17247. k([Ce()], e.prototype, "_midtonesDensity", void 0),
  17248. k([Ce()], e.prototype, "_midtonesSaturation", void 0),
  17249. k([Ce()], e.prototype, "_midtonesExposure", void 0),
  17250. e
  17251. }();
  17252. Ge._ColorCurvesParser = Ai.Parse;
  17253. var xi = function(e) {
  17254. function t() {
  17255. var t = e.call(this) || this;
  17256. return t.IMAGEPROCESSING = !1,
  17257. t.VIGNETTE = !1,
  17258. t.VIGNETTEBLENDMODEMULTIPLY = !1,
  17259. t.VIGNETTEBLENDMODEOPAQUE = !1,
  17260. t.TONEMAPPING = !1,
  17261. t.TONEMAPPING_ACES = !1,
  17262. t.CONTRAST = !1,
  17263. t.COLORCURVES = !1,
  17264. t.COLORGRADING = !1,
  17265. t.COLORGRADING3D = !1,
  17266. t.SAMPLER3DGREENDEPTH = !1,
  17267. t.SAMPLER3DBGRMAP = !1,
  17268. t.IMAGEPROCESSINGPOSTPROCESS = !1,
  17269. t.EXPOSURE = !1,
  17270. t.SKIPFINALCOLORCLAMP = !1,
  17271. t.rebuild(),
  17272. t
  17273. }
  17274. return U(t, e),
  17275. t
  17276. }(Si)
  17277. , Ri = function() {
  17278. function e() {
  17279. this.colorCurves = new Ai,
  17280. this._colorCurvesEnabled = !1,
  17281. this._colorGradingEnabled = !1,
  17282. this._colorGradingWithGreenDepth = !0,
  17283. this._colorGradingBGR = !0,
  17284. this._exposure = 1,
  17285. this._toneMappingEnabled = !1,
  17286. this._toneMappingType = e.TONEMAPPING_STANDARD,
  17287. this._contrast = 1,
  17288. this.vignetteStretch = 0,
  17289. this.vignetteCentreX = 0,
  17290. this.vignetteCentreY = 0,
  17291. this.vignetteWeight = 1.5,
  17292. this.vignetteColor = new N(0,0,0,0),
  17293. this.vignetteCameraFov = .5,
  17294. this._vignetteBlendMode = e.VIGNETTEMODE_MULTIPLY,
  17295. this._vignetteEnabled = !1,
  17296. this._skipFinalColorClamp = !1,
  17297. this._applyByPostProcess = !1,
  17298. this._isEnabled = !0,
  17299. this.onUpdateParameters = new h
  17300. }
  17301. return Object.defineProperty(e.prototype, "colorCurvesEnabled", {
  17302. get: function() {
  17303. return this._colorCurvesEnabled
  17304. },
  17305. set: function(e) {
  17306. this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e,
  17307. this._updateParameters())
  17308. },
  17309. enumerable: !1,
  17310. configurable: !0
  17311. }),
  17312. Object.defineProperty(e.prototype, "colorGradingTexture", {
  17313. get: function() {
  17314. return this._colorGradingTexture
  17315. },
  17316. set: function(e) {
  17317. this._colorGradingTexture !== e && (this._colorGradingTexture = e,
  17318. this._updateParameters())
  17319. },
  17320. enumerable: !1,
  17321. configurable: !0
  17322. }),
  17323. Object.defineProperty(e.prototype, "colorGradingEnabled", {
  17324. get: function() {
  17325. return this._colorGradingEnabled
  17326. },
  17327. set: function(e) {
  17328. this._colorGradingEnabled !== e && (this._colorGradingEnabled = e,
  17329. this._updateParameters())
  17330. },
  17331. enumerable: !1,
  17332. configurable: !0
  17333. }),
  17334. Object.defineProperty(e.prototype, "colorGradingWithGreenDepth", {
  17335. get: function() {
  17336. return this._colorGradingWithGreenDepth
  17337. },
  17338. set: function(e) {
  17339. this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e,
  17340. this._updateParameters())
  17341. },
  17342. enumerable: !1,
  17343. configurable: !0
  17344. }),
  17345. Object.defineProperty(e.prototype, "colorGradingBGR", {
  17346. get: function() {
  17347. return this._colorGradingBGR
  17348. },
  17349. set: function(e) {
  17350. this._colorGradingBGR !== e && (this._colorGradingBGR = e,
  17351. this._updateParameters())
  17352. },
  17353. enumerable: !1,
  17354. configurable: !0
  17355. }),
  17356. Object.defineProperty(e.prototype, "exposure", {
  17357. get: function() {
  17358. return this._exposure
  17359. },
  17360. set: function(e) {
  17361. this._exposure !== e && (this._exposure = e,
  17362. this._updateParameters())
  17363. },
  17364. enumerable: !1,
  17365. configurable: !0
  17366. }),
  17367. Object.defineProperty(e.prototype, "toneMappingEnabled", {
  17368. get: function() {
  17369. return this._toneMappingEnabled
  17370. },
  17371. set: function(e) {
  17372. this._toneMappingEnabled !== e && (this._toneMappingEnabled = e,
  17373. this._updateParameters())
  17374. },
  17375. enumerable: !1,
  17376. configurable: !0
  17377. }),
  17378. Object.defineProperty(e.prototype, "toneMappingType", {
  17379. get: function() {
  17380. return this._toneMappingType
  17381. },
  17382. set: function(e) {
  17383. this._toneMappingType !== e && (this._toneMappingType = e,
  17384. this._updateParameters())
  17385. },
  17386. enumerable: !1,
  17387. configurable: !0
  17388. }),
  17389. Object.defineProperty(e.prototype, "contrast", {
  17390. get: function() {
  17391. return this._contrast
  17392. },
  17393. set: function(e) {
  17394. this._contrast !== e && (this._contrast = e,
  17395. this._updateParameters())
  17396. },
  17397. enumerable: !1,
  17398. configurable: !0
  17399. }),
  17400. Object.defineProperty(e.prototype, "vignetteBlendMode", {
  17401. get: function() {
  17402. return this._vignetteBlendMode
  17403. },
  17404. set: function(e) {
  17405. this._vignetteBlendMode !== e && (this._vignetteBlendMode = e,
  17406. this._updateParameters())
  17407. },
  17408. enumerable: !1,
  17409. configurable: !0
  17410. }),
  17411. Object.defineProperty(e.prototype, "vignetteEnabled", {
  17412. get: function() {
  17413. return this._vignetteEnabled
  17414. },
  17415. set: function(e) {
  17416. this._vignetteEnabled !== e && (this._vignetteEnabled = e,
  17417. this._updateParameters())
  17418. },
  17419. enumerable: !1,
  17420. configurable: !0
  17421. }),
  17422. Object.defineProperty(e.prototype, "skipFinalColorClamp", {
  17423. get: function() {
  17424. return this._skipFinalColorClamp
  17425. },
  17426. set: function(e) {
  17427. this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e,
  17428. this._updateParameters())
  17429. },
  17430. enumerable: !1,
  17431. configurable: !0
  17432. }),
  17433. Object.defineProperty(e.prototype, "applyByPostProcess", {
  17434. get: function() {
  17435. return this._applyByPostProcess
  17436. },
  17437. set: function(e) {
  17438. this._applyByPostProcess !== e && (this._applyByPostProcess = e,
  17439. this._updateParameters())
  17440. },
  17441. enumerable: !1,
  17442. configurable: !0
  17443. }),
  17444. Object.defineProperty(e.prototype, "isEnabled", {
  17445. get: function() {
  17446. return this._isEnabled
  17447. },
  17448. set: function(e) {
  17449. this._isEnabled !== e && (this._isEnabled = e,
  17450. this._updateParameters())
  17451. },
  17452. enumerable: !1,
  17453. configurable: !0
  17454. }),
  17455. e.prototype._updateParameters = function() {
  17456. this.onUpdateParameters.notifyObservers(this)
  17457. }
  17458. ,
  17459. e.prototype.getClassName = function() {
  17460. return "ImageProcessingConfiguration"
  17461. }
  17462. ,
  17463. e.PrepareUniforms = function(e, t) {
  17464. t.EXPOSURE && e.push("exposureLinear"),
  17465. t.CONTRAST && e.push("contrast"),
  17466. t.COLORGRADING && e.push("colorTransformSettings"),
  17467. t.VIGNETTE && (e.push("vInverseScreenSize"),
  17468. e.push("vignetteSettings1"),
  17469. e.push("vignetteSettings2")),
  17470. t.COLORCURVES && Ai.PrepareUniforms(e)
  17471. }
  17472. ,
  17473. e.PrepareSamplers = function(e, t) {
  17474. t.COLORGRADING && e.push("txColorTransform")
  17475. }
  17476. ,
  17477. e.prototype.prepareDefines = function(t, i) {
  17478. if (void 0 === i && (i = !1),
  17479. i !== this.applyByPostProcess || !this._isEnabled)
  17480. return t.VIGNETTE = !1,
  17481. t.TONEMAPPING = !1,
  17482. t.TONEMAPPING_ACES = !1,
  17483. t.CONTRAST = !1,
  17484. t.EXPOSURE = !1,
  17485. t.COLORCURVES = !1,
  17486. t.COLORGRADING = !1,
  17487. t.COLORGRADING3D = !1,
  17488. t.IMAGEPROCESSING = !1,
  17489. t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
  17490. void (t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled);
  17491. t.VIGNETTE = this.vignetteEnabled,
  17492. t.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === e._VIGNETTEMODE_MULTIPLY,
  17493. t.VIGNETTEBLENDMODEOPAQUE = !t.VIGNETTEBLENDMODEMULTIPLY,
  17494. t.TONEMAPPING = this.toneMappingEnabled,
  17495. this._toneMappingType === e.TONEMAPPING_ACES ? t.TONEMAPPING_ACES = !0 : t.TONEMAPPING_ACES = !1,
  17496. t.CONTRAST = 1 !== this.contrast,
  17497. t.EXPOSURE = 1 !== this.exposure,
  17498. t.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves,
  17499. t.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture,
  17500. t.COLORGRADING ? t.COLORGRADING3D = this.colorGradingTexture.is3D : t.COLORGRADING3D = !1,
  17501. t.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth,
  17502. t.SAMPLER3DBGRMAP = this.colorGradingBGR,
  17503. t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
  17504. t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
  17505. t.IMAGEPROCESSING = t.VIGNETTE || t.TONEMAPPING || t.CONTRAST || t.EXPOSURE || t.COLORCURVES || t.COLORGRADING
  17506. }
  17507. ,
  17508. e.prototype.isReady = function() {
  17509. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
  17510. }
  17511. ,
  17512. e.prototype.bind = function(e, t) {
  17513. if (this._colorCurvesEnabled && this.colorCurves && Ai.Bind(this.colorCurves, e),
  17514. this._vignetteEnabled) {
  17515. var i = 1 / e.getEngine().getRenderWidth()
  17516. , n = 1 / e.getEngine().getRenderHeight();
  17517. e.setFloat2("vInverseScreenSize", i, n);
  17518. var r = null != t ? t : n / i
  17519. , o = Math.tan(.5 * this.vignetteCameraFov)
  17520. , a = o * r
  17521. , s = Math.sqrt(a * o);
  17522. a = gi.Mix(a, s, this.vignetteStretch),
  17523. o = gi.Mix(o, s, this.vignetteStretch),
  17524. e.setFloat4("vignetteSettings1", a, o, -a * this.vignetteCentreX, -o * this.vignetteCentreY);
  17525. var l = -2 * this.vignetteWeight;
  17526. e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, l)
  17527. }
  17528. if (e.setFloat("exposureLinear", this.exposure),
  17529. e.setFloat("contrast", this.contrast),
  17530. this.colorGradingTexture) {
  17531. e.setTexture("txColorTransform", this.colorGradingTexture);
  17532. var c = this.colorGradingTexture.getSize().height;
  17533. e.setFloat4("colorTransformSettings", (c - 1) / c, .5 / c, c, this.colorGradingTexture.level)
  17534. }
  17535. }
  17536. ,
  17537. e.prototype.clone = function() {
  17538. return Ge.Clone((function() {
  17539. return new e
  17540. }
  17541. ), this)
  17542. }
  17543. ,
  17544. e.prototype.serialize = function() {
  17545. return Ge.Serialize(this)
  17546. }
  17547. ,
  17548. e.Parse = function(t) {
  17549. return Ge.Parse((function() {
  17550. return new e
  17551. }
  17552. ), t, null, null)
  17553. }
  17554. ,
  17555. Object.defineProperty(e, "VIGNETTEMODE_MULTIPLY", {
  17556. get: function() {
  17557. return this._VIGNETTEMODE_MULTIPLY
  17558. },
  17559. enumerable: !1,
  17560. configurable: !0
  17561. }),
  17562. Object.defineProperty(e, "VIGNETTEMODE_OPAQUE", {
  17563. get: function() {
  17564. return this._VIGNETTEMODE_OPAQUE
  17565. },
  17566. enumerable: !1,
  17567. configurable: !0
  17568. }),
  17569. e.TONEMAPPING_STANDARD = 0,
  17570. e.TONEMAPPING_ACES = 1,
  17571. e._VIGNETTEMODE_MULTIPLY = 0,
  17572. e._VIGNETTEMODE_OPAQUE = 1,
  17573. k([Le()], e.prototype, "colorCurves", void 0),
  17574. k([Ce()], e.prototype, "_colorCurvesEnabled", void 0),
  17575. k([Pe("colorGradingTexture")], e.prototype, "_colorGradingTexture", void 0),
  17576. k([Ce()], e.prototype, "_colorGradingEnabled", void 0),
  17577. k([Ce()], e.prototype, "_colorGradingWithGreenDepth", void 0),
  17578. k([Ce()], e.prototype, "_colorGradingBGR", void 0),
  17579. k([Ce()], e.prototype, "_exposure", void 0),
  17580. k([Ce()], e.prototype, "_toneMappingEnabled", void 0),
  17581. k([Ce()], e.prototype, "_toneMappingType", void 0),
  17582. k([Ce()], e.prototype, "_contrast", void 0),
  17583. k([Ce()], e.prototype, "vignetteStretch", void 0),
  17584. k([Ce()], e.prototype, "vignetteCentreX", void 0),
  17585. k([Ce()], e.prototype, "vignetteCentreY", void 0),
  17586. k([Ce()], e.prototype, "vignetteWeight", void 0),
  17587. k([Fe()], e.prototype, "vignetteColor", void 0),
  17588. k([Ce()], e.prototype, "vignetteCameraFov", void 0),
  17589. k([Ce()], e.prototype, "_vignetteBlendMode", void 0),
  17590. k([Ce()], e.prototype, "_vignetteEnabled", void 0),
  17591. k([Ce()], e.prototype, "_skipFinalColorClamp", void 0),
  17592. k([Ce()], e.prototype, "_applyByPostProcess", void 0),
  17593. k([Ce()], e.prototype, "_isEnabled", void 0),
  17594. e
  17595. }();
  17596. Ge._ImageProcessingConfigurationParser = Ri.Parse,
  17597. Ht.prototype.createUniformBuffer = function(e) {
  17598. var t = this._gl.createBuffer();
  17599. if (!t)
  17600. throw new Error("Unable to create uniform buffer");
  17601. var i = new Ut(t);
  17602. return this.bindUniformBuffer(i),
  17603. e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.STATIC_DRAW),
  17604. this.bindUniformBuffer(null),
  17605. i.references = 1,
  17606. i
  17607. }
  17608. ,
  17609. Ht.prototype.createDynamicUniformBuffer = function(e) {
  17610. var t = this._gl.createBuffer();
  17611. if (!t)
  17612. throw new Error("Unable to create dynamic uniform buffer");
  17613. var i = new Ut(t);
  17614. return this.bindUniformBuffer(i),
  17615. e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.DYNAMIC_DRAW),
  17616. this.bindUniformBuffer(null),
  17617. i.references = 1,
  17618. i
  17619. }
  17620. ,
  17621. Ht.prototype.updateUniformBuffer = function(e, t, i, n) {
  17622. this.bindUniformBuffer(e),
  17623. void 0 === i && (i = 0),
  17624. void 0 === n ? t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, t) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, new Float32Array(t)) : t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, t.subarray(i, i + n)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(t).subarray(i, i + n)),
  17625. this.bindUniformBuffer(null)
  17626. }
  17627. ,
  17628. Ht.prototype.bindUniformBuffer = function(e) {
  17629. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, e ? e.underlyingResource : null)
  17630. }
  17631. ,
  17632. Ht.prototype.bindUniformBufferBase = function(e, t, i) {
  17633. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, t, e ? e.underlyingResource : null)
  17634. }
  17635. ,
  17636. Ht.prototype.bindUniformBlock = function(e, t, i) {
  17637. var n = e.program
  17638. , r = this._gl.getUniformBlockIndex(n, t);
  17639. 4294967295 !== r && this._gl.uniformBlockBinding(n, r, i)
  17640. }
  17641. ;
  17642. var Ci, Pi, Mi, Ii, Oi, Di, Ni, Li, Fi = function() {
  17643. function e(e, t, i, n, r) {
  17644. void 0 === r && (r = !1),
  17645. this._valueCache = {},
  17646. this._engine = e,
  17647. this._noUBO = !e.supportsUniformBuffers || r,
  17648. this._dynamic = i,
  17649. this._name = null != n ? n : "no-name",
  17650. this._data = t || [],
  17651. this._uniformLocations = {},
  17652. this._uniformSizes = {},
  17653. this._uniformArraySizes = {},
  17654. this._uniformLocationPointer = 0,
  17655. this._needSync = !1,
  17656. this._engine._features.trackUbosInFrame && (this._buffers = [],
  17657. this._bufferIndex = -1,
  17658. this._createBufferOnWrite = !1,
  17659. this._currentFrameId = 0),
  17660. this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect,
  17661. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect,
  17662. this.updateFloat = this._updateFloatForEffect,
  17663. this.updateFloat2 = this._updateFloat2ForEffect,
  17664. this.updateFloat3 = this._updateFloat3ForEffect,
  17665. this.updateFloat4 = this._updateFloat4ForEffect,
  17666. this.updateFloatArray = this._updateFloatArrayForEffect,
  17667. this.updateArray = this._updateArrayForEffect,
  17668. this.updateIntArray = this._updateIntArrayForEffect,
  17669. this.updateMatrix = this._updateMatrixForEffect,
  17670. this.updateMatrices = this._updateMatricesForEffect,
  17671. this.updateVector3 = this._updateVector3ForEffect,
  17672. this.updateVector4 = this._updateVector4ForEffect,
  17673. this.updateColor3 = this._updateColor3ForEffect,
  17674. this.updateColor4 = this._updateColor4ForEffect,
  17675. this.updateDirectColor4 = this._updateDirectColor4ForEffect,
  17676. this.updateInt = this._updateIntForEffect,
  17677. this.updateInt2 = this._updateInt2ForEffect,
  17678. this.updateInt3 = this._updateInt3ForEffect,
  17679. this.updateInt4 = this._updateInt4ForEffect) : (this._engine._uniformBuffers.push(this),
  17680. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform,
  17681. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform,
  17682. this.updateFloat = this._updateFloatForUniform,
  17683. this.updateFloat2 = this._updateFloat2ForUniform,
  17684. this.updateFloat3 = this._updateFloat3ForUniform,
  17685. this.updateFloat4 = this._updateFloat4ForUniform,
  17686. this.updateFloatArray = this._updateFloatArrayForUniform,
  17687. this.updateArray = this._updateArrayForUniform,
  17688. this.updateIntArray = this._updateIntArrayForUniform,
  17689. this.updateMatrix = this._updateMatrixForUniform,
  17690. this.updateMatrices = this._updateMatricesForUniform,
  17691. this.updateVector3 = this._updateVector3ForUniform,
  17692. this.updateVector4 = this._updateVector4ForUniform,
  17693. this.updateColor3 = this._updateColor3ForUniform,
  17694. this.updateColor4 = this._updateColor4ForUniform,
  17695. this.updateDirectColor4 = this._updateDirectColor4ForUniform,
  17696. this.updateInt = this._updateIntForUniform,
  17697. this.updateInt2 = this._updateInt2ForUniform,
  17698. this.updateInt3 = this._updateInt3ForUniform,
  17699. this.updateInt4 = this._updateInt4ForUniform)
  17700. }
  17701. return Object.defineProperty(e.prototype, "useUbo", {
  17702. get: function() {
  17703. return !this._noUBO
  17704. },
  17705. enumerable: !1,
  17706. configurable: !0
  17707. }),
  17708. Object.defineProperty(e.prototype, "isSync", {
  17709. get: function() {
  17710. return !this._needSync
  17711. },
  17712. enumerable: !1,
  17713. configurable: !0
  17714. }),
  17715. e.prototype.isDynamic = function() {
  17716. return void 0 !== this._dynamic
  17717. }
  17718. ,
  17719. e.prototype.getData = function() {
  17720. return this._bufferData
  17721. }
  17722. ,
  17723. e.prototype.getBuffer = function() {
  17724. return this._buffer
  17725. }
  17726. ,
  17727. e.prototype._fillAlignment = function(e) {
  17728. var t;
  17729. if (t = e <= 2 ? e : 4,
  17730. this._uniformLocationPointer % t != 0) {
  17731. var i = this._uniformLocationPointer;
  17732. this._uniformLocationPointer += t - this._uniformLocationPointer % t;
  17733. for (var n = this._uniformLocationPointer - i, r = 0; r < n; r++)
  17734. this._data.push(0)
  17735. }
  17736. }
  17737. ,
  17738. e.prototype.addUniform = function(e, t, i) {
  17739. if (void 0 === i && (i = 0),
  17740. !this._noUBO && void 0 === this._uniformLocations[e]) {
  17741. var n;
  17742. if (i > 0) {
  17743. if (t instanceof Array)
  17744. throw "addUniform should not be use with Array in UBO: " + e;
  17745. this._fillAlignment(4),
  17746. this._uniformArraySizes[e] = {
  17747. strideSize: t,
  17748. arraySize: i
  17749. },
  17750. 16 == t ? t *= i : t = t * i + (4 - t) * i,
  17751. n = [];
  17752. for (var r = 0; r < t; r++)
  17753. n.push(0)
  17754. } else {
  17755. if (t instanceof Array)
  17756. t = (n = t).length;
  17757. else
  17758. for (t = t,
  17759. n = [],
  17760. r = 0; r < t; r++)
  17761. n.push(0);
  17762. this._fillAlignment(t)
  17763. }
  17764. for (this._uniformSizes[e] = t,
  17765. this._uniformLocations[e] = this._uniformLocationPointer,
  17766. this._uniformLocationPointer += t,
  17767. r = 0; r < t; r++)
  17768. this._data.push(n[r]);
  17769. this._needSync = !0
  17770. }
  17771. }
  17772. ,
  17773. e.prototype.addMatrix = function(e, t) {
  17774. this.addUniform(e, Array.prototype.slice.call(t.toArray()))
  17775. }
  17776. ,
  17777. e.prototype.addFloat2 = function(e, t, i) {
  17778. var n = [t, i];
  17779. this.addUniform(e, n)
  17780. }
  17781. ,
  17782. e.prototype.addFloat3 = function(e, t, i, n) {
  17783. var r = [t, i, n];
  17784. this.addUniform(e, r)
  17785. }
  17786. ,
  17787. e.prototype.addColor3 = function(e, t) {
  17788. var i = [t.r, t.g, t.b];
  17789. this.addUniform(e, i)
  17790. }
  17791. ,
  17792. e.prototype.addColor4 = function(e, t, i) {
  17793. var n = [t.r, t.g, t.b, i];
  17794. this.addUniform(e, n)
  17795. }
  17796. ,
  17797. e.prototype.addVector3 = function(e, t) {
  17798. var i = [t.x, t.y, t.z];
  17799. this.addUniform(e, i)
  17800. }
  17801. ,
  17802. e.prototype.addMatrix3x3 = function(e) {
  17803. this.addUniform(e, 12)
  17804. }
  17805. ,
  17806. e.prototype.addMatrix2x2 = function(e) {
  17807. this.addUniform(e, 8)
  17808. }
  17809. ,
  17810. e.prototype.create = function() {
  17811. this._noUBO || this._buffer || (this._fillAlignment(4),
  17812. this._bufferData = new Float32Array(this._data),
  17813. this._rebuild(),
  17814. this._needSync = !0)
  17815. }
  17816. ,
  17817. e.prototype._rebuild = function() {
  17818. !this._noUBO && this._bufferData && (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData),
  17819. this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]),
  17820. this._bufferIndex = this._buffers.length - 1,
  17821. this._createBufferOnWrite = !1))
  17822. }
  17823. ,
  17824. Object.defineProperty(e.prototype, "_numBuffers", {
  17825. get: function() {
  17826. return this._buffers.length
  17827. },
  17828. enumerable: !1,
  17829. configurable: !0
  17830. }),
  17831. Object.defineProperty(e.prototype, "_indexBuffer", {
  17832. get: function() {
  17833. return this._bufferIndex
  17834. },
  17835. enumerable: !1,
  17836. configurable: !0
  17837. }),
  17838. Object.defineProperty(e.prototype, "name", {
  17839. get: function() {
  17840. return this._name
  17841. },
  17842. enumerable: !1,
  17843. configurable: !0
  17844. }),
  17845. e.prototype._buffersEqual = function(e, t) {
  17846. for (var i = 0; i < e.length; ++i)
  17847. if (e[i] !== t[i])
  17848. return !1;
  17849. return !0
  17850. }
  17851. ,
  17852. e.prototype._copyBuffer = function(e, t) {
  17853. for (var i = 0; i < e.length; ++i)
  17854. t[i] = e[i]
  17855. }
  17856. ,
  17857. e.prototype.update = function() {
  17858. if (!this._noUBO)
  17859. if (this.bindUniformBuffer(),
  17860. this._buffer)
  17861. if (this._dynamic || this._needSync) {
  17862. if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1]) {
  17863. if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1]))
  17864. return this._needSync = !1,
  17865. void (this._createBufferOnWrite = this._engine._features.trackUbosInFrame);
  17866. this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1])
  17867. }
  17868. this._engine.updateUniformBuffer(this._buffer, this._bufferData),
  17869. this._engine._features._collectUbosUpdatedInFrame && (e._UpdatedUbosInFrame[this._name] || (e._UpdatedUbosInFrame[this._name] = 0),
  17870. e._UpdatedUbosInFrame[this._name]++),
  17871. this._needSync = !1,
  17872. this._createBufferOnWrite = this._engine._features.trackUbosInFrame
  17873. } else
  17874. this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
  17875. else
  17876. this.create()
  17877. }
  17878. ,
  17879. e.prototype._createNewBuffer = function() {
  17880. this._bufferIndex + 1 < this._buffers.length ? (this._bufferIndex++,
  17881. this._buffer = this._buffers[this._bufferIndex][0],
  17882. this._createBufferOnWrite = !1,
  17883. this._needSync = !0) : this._rebuild()
  17884. }
  17885. ,
  17886. e.prototype._checkNewFrame = function() {
  17887. this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId,
  17888. this._createBufferOnWrite = !1,
  17889. this._buffers && this._buffers.length > 0 ? (this._needSync = 0 !== this._bufferIndex,
  17890. this._bufferIndex = 0,
  17891. this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1)
  17892. }
  17893. ,
  17894. e.prototype.updateUniform = function(e, t, i) {
  17895. this._checkNewFrame();
  17896. var n = this._uniformLocations[e];
  17897. if (void 0 === n) {
  17898. if (this._buffer)
  17899. return void K.Error("Cannot add an uniform after UBO has been created.");
  17900. this.addUniform(e, i),
  17901. n = this._uniformLocations[e]
  17902. }
  17903. if (this._buffer || this.create(),
  17904. this._dynamic)
  17905. for (o = 0; o < i; o++)
  17906. this._bufferData[n + o] = t[o];
  17907. else {
  17908. for (var r = !1, o = 0; o < i; o++)
  17909. (16 === i && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[n + o] !== gi.FloatRound(t[o])) && (r = !0,
  17910. this._createBufferOnWrite && this._createNewBuffer(),
  17911. this._bufferData[n + o] = t[o]);
  17912. this._needSync = this._needSync || r
  17913. }
  17914. }
  17915. ,
  17916. e.prototype.updateUniformArray = function(e, t, i) {
  17917. this._checkNewFrame();
  17918. var n = this._uniformLocations[e];
  17919. if (void 0 !== n) {
  17920. this._buffer || this.create();
  17921. var r = this._uniformArraySizes[e];
  17922. if (this._dynamic)
  17923. for (l = 0; l < i; l++)
  17924. this._bufferData[n + l] = t[l];
  17925. else {
  17926. for (var o = !1, a = 0, s = 0, l = 0; l < i; l++)
  17927. if (this._bufferData[n + 4 * s + a] !== gi.FloatRound(t[l]) && (o = !0,
  17928. this._createBufferOnWrite && this._createNewBuffer(),
  17929. this._bufferData[n + 4 * s + a] = t[l]),
  17930. ++a === r.strideSize) {
  17931. for (; a < 4; a++)
  17932. this._bufferData[n + 4 * s + a] = 0;
  17933. a = 0,
  17934. s++
  17935. }
  17936. this._needSync = this._needSync || o
  17937. }
  17938. } else
  17939. K.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.")
  17940. }
  17941. ,
  17942. e.prototype._cacheMatrix = function(e, t) {
  17943. this._checkNewFrame();
  17944. var i = this._valueCache[e]
  17945. , n = t.updateFlag;
  17946. return (void 0 === i || i !== n) && (this._valueCache[e] = n,
  17947. !0)
  17948. }
  17949. ,
  17950. e.prototype._updateMatrix3x3ForUniform = function(t, i) {
  17951. for (var n = 0; n < 3; n++)
  17952. e._TempBuffer[4 * n] = i[3 * n],
  17953. e._TempBuffer[4 * n + 1] = i[3 * n + 1],
  17954. e._TempBuffer[4 * n + 2] = i[3 * n + 2],
  17955. e._TempBuffer[4 * n + 3] = 0;
  17956. this.updateUniform(t, e._TempBuffer, 12)
  17957. }
  17958. ,
  17959. e.prototype._updateMatrix3x3ForEffect = function(e, t) {
  17960. this._currentEffect.setMatrix3x3(e, t)
  17961. }
  17962. ,
  17963. e.prototype._updateMatrix2x2ForEffect = function(e, t) {
  17964. this._currentEffect.setMatrix2x2(e, t)
  17965. }
  17966. ,
  17967. e.prototype._updateMatrix2x2ForUniform = function(t, i) {
  17968. for (var n = 0; n < 2; n++)
  17969. e._TempBuffer[4 * n] = i[2 * n],
  17970. e._TempBuffer[4 * n + 1] = i[2 * n + 1],
  17971. e._TempBuffer[4 * n + 2] = 0,
  17972. e._TempBuffer[4 * n + 3] = 0;
  17973. this.updateUniform(t, e._TempBuffer, 8)
  17974. }
  17975. ,
  17976. e.prototype._updateFloatForEffect = function(e, t) {
  17977. this._currentEffect.setFloat(e, t)
  17978. }
  17979. ,
  17980. e.prototype._updateFloatForUniform = function(t, i) {
  17981. e._TempBuffer[0] = i,
  17982. this.updateUniform(t, e._TempBuffer, 1)
  17983. }
  17984. ,
  17985. e.prototype._updateFloat2ForEffect = function(e, t, i, n) {
  17986. void 0 === n && (n = ""),
  17987. this._currentEffect.setFloat2(e + n, t, i)
  17988. }
  17989. ,
  17990. e.prototype._updateFloat2ForUniform = function(t, i, n) {
  17991. e._TempBuffer[0] = i,
  17992. e._TempBuffer[1] = n,
  17993. this.updateUniform(t, e._TempBuffer, 2)
  17994. }
  17995. ,
  17996. e.prototype._updateFloat3ForEffect = function(e, t, i, n, r) {
  17997. void 0 === r && (r = ""),
  17998. this._currentEffect.setFloat3(e + r, t, i, n)
  17999. }
  18000. ,
  18001. e.prototype._updateFloat3ForUniform = function(t, i, n, r) {
  18002. e._TempBuffer[0] = i,
  18003. e._TempBuffer[1] = n,
  18004. e._TempBuffer[2] = r,
  18005. this.updateUniform(t, e._TempBuffer, 3)
  18006. }
  18007. ,
  18008. e.prototype._updateFloat4ForEffect = function(e, t, i, n, r, o) {
  18009. void 0 === o && (o = ""),
  18010. this._currentEffect.setFloat4(e + o, t, i, n, r)
  18011. }
  18012. ,
  18013. e.prototype._updateFloat4ForUniform = function(t, i, n, r, o) {
  18014. e._TempBuffer[0] = i,
  18015. e._TempBuffer[1] = n,
  18016. e._TempBuffer[2] = r,
  18017. e._TempBuffer[3] = o,
  18018. this.updateUniform(t, e._TempBuffer, 4)
  18019. }
  18020. ,
  18021. e.prototype._updateFloatArrayForEffect = function(e, t) {
  18022. this._currentEffect.setFloatArray(e, t)
  18023. }
  18024. ,
  18025. e.prototype._updateFloatArrayForUniform = function(e, t) {
  18026. this.updateUniformArray(e, t, t.length)
  18027. }
  18028. ,
  18029. e.prototype._updateArrayForEffect = function(e, t) {
  18030. this._currentEffect.setArray(e, t)
  18031. }
  18032. ,
  18033. e.prototype._updateArrayForUniform = function(e, t) {
  18034. this.updateUniformArray(e, t, t.length)
  18035. }
  18036. ,
  18037. e.prototype._updateIntArrayForEffect = function(e, t) {
  18038. this._currentEffect.setIntArray(e, t)
  18039. }
  18040. ,
  18041. e.prototype._updateIntArrayForUniform = function(t, i) {
  18042. e._TempBufferInt32View.set(i),
  18043. this.updateUniformArray(t, e._TempBuffer, i.length)
  18044. }
  18045. ,
  18046. e.prototype._updateMatrixForEffect = function(e, t) {
  18047. this._currentEffect.setMatrix(e, t)
  18048. }
  18049. ,
  18050. e.prototype._updateMatrixForUniform = function(e, t) {
  18051. this._cacheMatrix(e, t) && this.updateUniform(e, t.toArray(), 16)
  18052. }
  18053. ,
  18054. e.prototype._updateMatricesForEffect = function(e, t) {
  18055. this._currentEffect.setMatrices(e, t)
  18056. }
  18057. ,
  18058. e.prototype._updateMatricesForUniform = function(e, t) {
  18059. this.updateUniform(e, t, t.length)
  18060. }
  18061. ,
  18062. e.prototype._updateVector3ForEffect = function(e, t) {
  18063. this._currentEffect.setVector3(e, t)
  18064. }
  18065. ,
  18066. e.prototype._updateVector3ForUniform = function(t, i) {
  18067. e._TempBuffer[0] = i.x,
  18068. e._TempBuffer[1] = i.y,
  18069. e._TempBuffer[2] = i.z,
  18070. this.updateUniform(t, e._TempBuffer, 3)
  18071. }
  18072. ,
  18073. e.prototype._updateVector4ForEffect = function(e, t) {
  18074. this._currentEffect.setVector4(e, t)
  18075. }
  18076. ,
  18077. e.prototype._updateVector4ForUniform = function(t, i) {
  18078. e._TempBuffer[0] = i.x,
  18079. e._TempBuffer[1] = i.y,
  18080. e._TempBuffer[2] = i.z,
  18081. e._TempBuffer[3] = i.w,
  18082. this.updateUniform(t, e._TempBuffer, 4)
  18083. }
  18084. ,
  18085. e.prototype._updateColor3ForEffect = function(e, t, i) {
  18086. void 0 === i && (i = ""),
  18087. this._currentEffect.setColor3(e + i, t)
  18088. }
  18089. ,
  18090. e.prototype._updateColor3ForUniform = function(t, i) {
  18091. e._TempBuffer[0] = i.r,
  18092. e._TempBuffer[1] = i.g,
  18093. e._TempBuffer[2] = i.b,
  18094. this.updateUniform(t, e._TempBuffer, 3)
  18095. }
  18096. ,
  18097. e.prototype._updateColor4ForEffect = function(e, t, i, n) {
  18098. void 0 === n && (n = ""),
  18099. this._currentEffect.setColor4(e + n, t, i)
  18100. }
  18101. ,
  18102. e.prototype._updateDirectColor4ForEffect = function(e, t, i) {
  18103. void 0 === i && (i = ""),
  18104. this._currentEffect.setDirectColor4(e + i, t)
  18105. }
  18106. ,
  18107. e.prototype._updateColor4ForUniform = function(t, i, n) {
  18108. e._TempBuffer[0] = i.r,
  18109. e._TempBuffer[1] = i.g,
  18110. e._TempBuffer[2] = i.b,
  18111. e._TempBuffer[3] = n,
  18112. this.updateUniform(t, e._TempBuffer, 4)
  18113. }
  18114. ,
  18115. e.prototype._updateDirectColor4ForUniform = function(t, i) {
  18116. e._TempBuffer[0] = i.r,
  18117. e._TempBuffer[1] = i.g,
  18118. e._TempBuffer[2] = i.b,
  18119. e._TempBuffer[3] = i.a,
  18120. this.updateUniform(t, e._TempBuffer, 4)
  18121. }
  18122. ,
  18123. e.prototype._updateIntForEffect = function(e, t, i) {
  18124. void 0 === i && (i = ""),
  18125. this._currentEffect.setInt(e + i, t)
  18126. }
  18127. ,
  18128. e.prototype._updateIntForUniform = function(t, i) {
  18129. e._TempBufferInt32View[0] = i,
  18130. this.updateUniform(t, e._TempBuffer, 1)
  18131. }
  18132. ,
  18133. e.prototype._updateInt2ForEffect = function(e, t, i, n) {
  18134. void 0 === n && (n = ""),
  18135. this._currentEffect.setInt2(e + n, t, i)
  18136. }
  18137. ,
  18138. e.prototype._updateInt2ForUniform = function(t, i, n) {
  18139. e._TempBufferInt32View[0] = i,
  18140. e._TempBufferInt32View[1] = n,
  18141. this.updateUniform(t, e._TempBuffer, 2)
  18142. }
  18143. ,
  18144. e.prototype._updateInt3ForEffect = function(e, t, i, n, r) {
  18145. void 0 === r && (r = ""),
  18146. this._currentEffect.setInt3(e + r, t, i, n)
  18147. }
  18148. ,
  18149. e.prototype._updateInt3ForUniform = function(t, i, n, r) {
  18150. e._TempBufferInt32View[0] = i,
  18151. e._TempBufferInt32View[1] = n,
  18152. e._TempBufferInt32View[2] = r,
  18153. this.updateUniform(t, e._TempBuffer, 3)
  18154. }
  18155. ,
  18156. e.prototype._updateInt4ForEffect = function(e, t, i, n, r, o) {
  18157. void 0 === o && (o = ""),
  18158. this._currentEffect.setInt4(e + o, t, i, n, r)
  18159. }
  18160. ,
  18161. e.prototype._updateInt4ForUniform = function(t, i, n, r, o) {
  18162. e._TempBufferInt32View[0] = i,
  18163. e._TempBufferInt32View[1] = n,
  18164. e._TempBufferInt32View[2] = r,
  18165. e._TempBufferInt32View[3] = o,
  18166. this.updateUniform(t, e._TempBuffer, 4)
  18167. }
  18168. ,
  18169. e.prototype.setTexture = function(e, t) {
  18170. this._currentEffect.setTexture(e, t)
  18171. }
  18172. ,
  18173. e.prototype.updateUniformDirectly = function(e, t) {
  18174. this.updateUniform(e, t, t.length),
  18175. this.update()
  18176. }
  18177. ,
  18178. e.prototype.bindToEffect = function(e, t) {
  18179. this._currentEffect = e,
  18180. this._currentEffectName = t
  18181. }
  18182. ,
  18183. e.prototype.bindUniformBuffer = function() {
  18184. !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName)
  18185. }
  18186. ,
  18187. e.prototype.unbindEffect = function() {
  18188. this._currentEffect = void 0,
  18189. this._currentEffectName = void 0
  18190. }
  18191. ,
  18192. e.prototype.setDataBuffer = function(e) {
  18193. if (!this._buffers)
  18194. return this._buffer === e;
  18195. for (var t = 0; t < this._buffers.length; ++t)
  18196. if (this._buffers[t][0] === e)
  18197. return this._bufferIndex = t,
  18198. this._buffer = e,
  18199. this._createBufferOnWrite = !1,
  18200. this._currentEffect = void 0,
  18201. !0;
  18202. return !1
  18203. }
  18204. ,
  18205. e.prototype.dispose = function() {
  18206. if (!this._noUBO) {
  18207. var e = this._engine._uniformBuffers
  18208. , t = e.indexOf(this);
  18209. if (-1 !== t && (e[t] = e[e.length - 1],
  18210. e.pop()),
  18211. this._engine._features.trackUbosInFrame && this._buffers)
  18212. for (var i = 0; i < this._buffers.length; ++i) {
  18213. var n = this._buffers[i][0];
  18214. this._engine._releaseBuffer(n)
  18215. }
  18216. else
  18217. this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null)
  18218. }
  18219. }
  18220. ,
  18221. e._UpdatedUbosInFrame = {},
  18222. e._MAX_UNIFORM_SIZE = 256,
  18223. e._TempBuffer = new Float32Array(e._MAX_UNIFORM_SIZE),
  18224. e._TempBufferInt32View = new Uint32Array(e._TempBuffer.buffer),
  18225. e
  18226. }(), wi = function() {
  18227. function e(e, t, i, n, r, o, a, s) {
  18228. void 0 === n && (n = 0),
  18229. void 0 === r && (r = !1),
  18230. void 0 === o && (o = !1),
  18231. void 0 === a && (a = !1),
  18232. this._isAlreadyOwned = !1,
  18233. e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e,
  18234. this._updatable = i,
  18235. this._instanced = o,
  18236. this._divisor = s || 1,
  18237. t instanceof Bt ? (this._data = null,
  18238. this._buffer = t) : (this._data = t,
  18239. this._buffer = null),
  18240. this.byteStride = a ? n : n * Float32Array.BYTES_PER_ELEMENT,
  18241. r || this.create()
  18242. }
  18243. return e.prototype.createVertexBuffer = function(e, t, i, n, r, o, a) {
  18244. void 0 === o && (o = !1);
  18245. var s = o ? t : t * Float32Array.BYTES_PER_ELEMENT
  18246. , l = n ? o ? n : n * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
  18247. return new Bi(this._engine,this,e,this._updatable,!0,l,void 0 === r ? this._instanced : r,s,i,void 0,void 0,!0,this._divisor || a)
  18248. }
  18249. ,
  18250. e.prototype.isUpdatable = function() {
  18251. return this._updatable
  18252. }
  18253. ,
  18254. e.prototype.getData = function() {
  18255. return this._data
  18256. }
  18257. ,
  18258. e.prototype.getBuffer = function() {
  18259. return this._buffer
  18260. }
  18261. ,
  18262. e.prototype.getStrideSize = function() {
  18263. return this.byteStride / Float32Array.BYTES_PER_ELEMENT
  18264. }
  18265. ,
  18266. e.prototype.create = function(e) {
  18267. void 0 === e && (e = null),
  18268. !e && this._buffer || (e = e || this._data) && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e),
  18269. this._data = e) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(e),
  18270. this._data = e) : this._buffer = this._engine.createVertexBuffer(e))
  18271. }
  18272. ,
  18273. e.prototype._rebuild = function() {
  18274. this._buffer = null,
  18275. this.create(this._data)
  18276. }
  18277. ,
  18278. e.prototype.update = function(e) {
  18279. this.create(e)
  18280. }
  18281. ,
  18282. e.prototype.updateDirectly = function(e, t, i, n) {
  18283. void 0 === n && (n = !1),
  18284. this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, n ? t : t * Float32Array.BYTES_PER_ELEMENT, i ? i * this.byteStride : void 0),
  18285. this._data = 0 === t && void 0 === i ? e : null)
  18286. }
  18287. ,
  18288. e.prototype._increaseReferences = function() {
  18289. this._buffer && (this._isAlreadyOwned ? this._buffer.references++ : this._isAlreadyOwned = !0)
  18290. }
  18291. ,
  18292. e.prototype.dispose = function() {
  18293. this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null,
  18294. this._data = null)
  18295. }
  18296. ,
  18297. e
  18298. }(), Bi = function() {
  18299. function e(t, i, n, r, o, a, s, l, c, u, h, d, p, f) {
  18300. if (void 0 === h && (h = !1),
  18301. void 0 === d && (d = !1),
  18302. void 0 === p && (p = 1),
  18303. void 0 === f && (f = !1),
  18304. i instanceof wi ? (this._buffer = i,
  18305. this._ownsBuffer = f) : (this._buffer = new wi(t,i,r,a,o,s,d),
  18306. this._ownsBuffer = !0),
  18307. this.uniqueId = e._Counter++,
  18308. this._kind = n,
  18309. null == u) {
  18310. var _ = this.getData();
  18311. this.type = e.FLOAT,
  18312. _ instanceof Int8Array ? this.type = e.BYTE : _ instanceof Uint8Array ? this.type = e.UNSIGNED_BYTE : _ instanceof Int16Array ? this.type = e.SHORT : _ instanceof Uint16Array ? this.type = e.UNSIGNED_SHORT : _ instanceof Int32Array ? this.type = e.INT : _ instanceof Uint32Array && (this.type = e.UNSIGNED_INT)
  18313. } else
  18314. this.type = u;
  18315. var m = e.GetTypeByteLength(this.type);
  18316. d ? (this._size = c || (a ? a / m : e.DeduceStride(n)),
  18317. this.byteStride = a || this._buffer.byteStride || this._size * m,
  18318. this.byteOffset = l || 0) : (this._size = c || a || e.DeduceStride(n),
  18319. this.byteStride = a ? a * m : this._buffer.byteStride || this._size * m,
  18320. this.byteOffset = (l || 0) * m),
  18321. this.normalized = h,
  18322. this._instanced = void 0 !== s && s,
  18323. this._instanceDivisor = s ? p : 0,
  18324. this._computeHashCode()
  18325. }
  18326. return Object.defineProperty(e.prototype, "instanceDivisor", {
  18327. get: function() {
  18328. return this._instanceDivisor
  18329. },
  18330. set: function(e) {
  18331. this._instanceDivisor = e,
  18332. this._instanced = 0 != e,
  18333. this._computeHashCode()
  18334. },
  18335. enumerable: !1,
  18336. configurable: !0
  18337. }),
  18338. e.prototype._computeHashCode = function() {
  18339. this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12)
  18340. }
  18341. ,
  18342. e.prototype._rebuild = function() {
  18343. this._buffer && this._buffer._rebuild()
  18344. }
  18345. ,
  18346. e.prototype.getKind = function() {
  18347. return this._kind
  18348. }
  18349. ,
  18350. e.prototype.isUpdatable = function() {
  18351. return this._buffer.isUpdatable()
  18352. }
  18353. ,
  18354. e.prototype.getData = function() {
  18355. return this._buffer.getData()
  18356. }
  18357. ,
  18358. e.prototype.getFloatData = function(t, i) {
  18359. var n = this.getData();
  18360. if (!n)
  18361. return null;
  18362. var r = this.getSize() * e.GetTypeByteLength(this.type)
  18363. , o = t * this.getSize();
  18364. if (this.type !== e.FLOAT || this.byteStride !== r) {
  18365. var a = new Float32Array(o);
  18366. return this.forEach(o, (function(e, t) {
  18367. return a[t] = e
  18368. }
  18369. )),
  18370. a
  18371. }
  18372. if (!(n instanceof Array || n instanceof Float32Array) || 0 !== this.byteOffset || n.length !== o) {
  18373. if (n instanceof Array) {
  18374. var s = this.byteOffset / 4;
  18375. return mi.Slice(n, s, s + o)
  18376. }
  18377. if (n instanceof ArrayBuffer)
  18378. return new Float32Array(n,this.byteOffset,o);
  18379. if (s = n.byteOffset + this.byteOffset,
  18380. i) {
  18381. var l = new Float32Array(o)
  18382. , c = new Float32Array(n.buffer,s,o);
  18383. return l.set(c),
  18384. l
  18385. }
  18386. var u = s % 4;
  18387. return u && (s = Math.max(0, s - u)),
  18388. new Float32Array(n.buffer,s,o)
  18389. }
  18390. return i ? mi.Slice(n) : n
  18391. }
  18392. ,
  18393. e.prototype.getBuffer = function() {
  18394. return this._buffer.getBuffer()
  18395. }
  18396. ,
  18397. e.prototype.getStrideSize = function() {
  18398. return this.byteStride / e.GetTypeByteLength(this.type)
  18399. }
  18400. ,
  18401. e.prototype.getOffset = function() {
  18402. return this.byteOffset / e.GetTypeByteLength(this.type)
  18403. }
  18404. ,
  18405. e.prototype.getSize = function(t) {
  18406. return void 0 === t && (t = !1),
  18407. t ? this._size * e.GetTypeByteLength(this.type) : this._size
  18408. }
  18409. ,
  18410. e.prototype.getIsInstanced = function() {
  18411. return this._instanced
  18412. }
  18413. ,
  18414. e.prototype.getInstanceDivisor = function() {
  18415. return this._instanceDivisor
  18416. }
  18417. ,
  18418. e.prototype.create = function(e) {
  18419. this._buffer.create(e)
  18420. }
  18421. ,
  18422. e.prototype.update = function(e) {
  18423. this._buffer.update(e)
  18424. }
  18425. ,
  18426. e.prototype.updateDirectly = function(e, t, i) {
  18427. void 0 === i && (i = !1),
  18428. this._buffer.updateDirectly(e, t, void 0, i)
  18429. }
  18430. ,
  18431. e.prototype.dispose = function() {
  18432. this._ownsBuffer && this._buffer.dispose()
  18433. }
  18434. ,
  18435. e.prototype.forEach = function(t, i) {
  18436. e.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, t, this.normalized, i)
  18437. }
  18438. ,
  18439. e.DeduceStride = function(t) {
  18440. switch (t) {
  18441. case e.UVKind:
  18442. case e.UV2Kind:
  18443. case e.UV3Kind:
  18444. case e.UV4Kind:
  18445. case e.UV5Kind:
  18446. case e.UV6Kind:
  18447. return 2;
  18448. case e.NormalKind:
  18449. case e.PositionKind:
  18450. return 3;
  18451. case e.ColorKind:
  18452. case e.MatricesIndicesKind:
  18453. case e.MatricesIndicesExtraKind:
  18454. case e.MatricesWeightsKind:
  18455. case e.MatricesWeightsExtraKind:
  18456. case e.TangentKind:
  18457. return 4;
  18458. default:
  18459. throw new Error("Invalid kind '" + t + "'")
  18460. }
  18461. }
  18462. ,
  18463. e.GetTypeByteLength = function(t) {
  18464. switch (t) {
  18465. case e.BYTE:
  18466. case e.UNSIGNED_BYTE:
  18467. return 1;
  18468. case e.SHORT:
  18469. case e.UNSIGNED_SHORT:
  18470. return 2;
  18471. case e.INT:
  18472. case e.UNSIGNED_INT:
  18473. case e.FLOAT:
  18474. return 4;
  18475. default:
  18476. throw new Error("Invalid type '".concat(t, "'"))
  18477. }
  18478. }
  18479. ,
  18480. e.ForEach = function(t, i, n, r, o, a, s, l) {
  18481. if (t instanceof Array)
  18482. for (var c = i / 4, u = n / 4, h = 0; h < a; h += r) {
  18483. for (var d = 0; d < r; d++)
  18484. l(t[c + d], h + d);
  18485. c += u
  18486. }
  18487. else {
  18488. var p = t instanceof ArrayBuffer ? new DataView(t) : new DataView(t.buffer,t.byteOffset,t.byteLength)
  18489. , f = e.GetTypeByteLength(o);
  18490. for (h = 0; h < a; h += r) {
  18491. var _ = i;
  18492. for (d = 0; d < r; d++)
  18493. l(e._GetFloatValue(p, o, _, s), h + d),
  18494. _ += f;
  18495. i += n
  18496. }
  18497. }
  18498. }
  18499. ,
  18500. e._GetFloatValue = function(t, i, n, r) {
  18501. switch (i) {
  18502. case e.BYTE:
  18503. var o = t.getInt8(n);
  18504. return r && (o = Math.max(o / 127, -1)),
  18505. o;
  18506. case e.UNSIGNED_BYTE:
  18507. return o = t.getUint8(n),
  18508. r && (o /= 255),
  18509. o;
  18510. case e.SHORT:
  18511. return o = t.getInt16(n, !0),
  18512. r && (o = Math.max(o / 32767, -1)),
  18513. o;
  18514. case e.UNSIGNED_SHORT:
  18515. return o = t.getUint16(n, !0),
  18516. r && (o /= 65535),
  18517. o;
  18518. case e.INT:
  18519. return t.getInt32(n, !0);
  18520. case e.UNSIGNED_INT:
  18521. return t.getUint32(n, !0);
  18522. case e.FLOAT:
  18523. return t.getFloat32(n, !0);
  18524. default:
  18525. throw new Error("Invalid component type ".concat(i))
  18526. }
  18527. }
  18528. ,
  18529. e._Counter = 0,
  18530. e.BYTE = 5120,
  18531. e.UNSIGNED_BYTE = 5121,
  18532. e.SHORT = 5122,
  18533. e.UNSIGNED_SHORT = 5123,
  18534. e.INT = 5124,
  18535. e.UNSIGNED_INT = 5125,
  18536. e.FLOAT = 5126,
  18537. e.PositionKind = "position",
  18538. e.NormalKind = "normal",
  18539. e.TangentKind = "tangent",
  18540. e.UVKind = "uv",
  18541. e.UV2Kind = "uv2",
  18542. e.UV3Kind = "uv3",
  18543. e.UV4Kind = "uv4",
  18544. e.UV5Kind = "uv5",
  18545. e.UV6Kind = "uv6",
  18546. e.ColorKind = "color",
  18547. e.ColorInstanceKind = "instanceColor",
  18548. e.MatricesIndicesKind = "matricesIndices",
  18549. e.MatricesWeightsKind = "matricesWeights",
  18550. e.MatricesIndicesExtraKind = "matricesIndicesExtra",
  18551. e.MatricesWeightsExtraKind = "matricesWeightsExtra",
  18552. e
  18553. }(), Ui = function() {
  18554. function e() {
  18555. this._pickingUnavailable = !1,
  18556. this.hit = !1,
  18557. this.distance = 0,
  18558. this.pickedPoint = null,
  18559. this.pickedMesh = null,
  18560. this.bu = 0,
  18561. this.bv = 0,
  18562. this.faceId = -1,
  18563. this.subMeshFaceId = -1,
  18564. this.subMeshId = 0,
  18565. this.pickedSprite = null,
  18566. this.thinInstanceIndex = -1,
  18567. this.ray = null,
  18568. this.originMesh = null,
  18569. this.aimTransform = null,
  18570. this.gripTransform = null
  18571. }
  18572. return e.prototype.getNormal = function(e, t) {
  18573. if (void 0 === e && (e = !1),
  18574. void 0 === t && (t = !0),
  18575. !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(Bi.NormalKind))
  18576. return null;
  18577. var i, n = this.pickedMesh.getIndices();
  18578. if (!n)
  18579. return null;
  18580. if (t) {
  18581. var r = this.pickedMesh.getVerticesData(Bi.NormalKind)
  18582. , o = x.FromArray(r, 3 * n[3 * this.faceId])
  18583. , a = x.FromArray(r, 3 * n[3 * this.faceId + 1])
  18584. , s = x.FromArray(r, 3 * n[3 * this.faceId + 2]);
  18585. o = o.scale(this.bu),
  18586. a = a.scale(this.bv),
  18587. s = s.scale(1 - this.bu - this.bv),
  18588. i = new x(o.x + a.x + s.x,o.y + a.y + s.y,o.z + a.z + s.z)
  18589. } else {
  18590. var l = this.pickedMesh.getVerticesData(Bi.PositionKind)
  18591. , c = x.FromArray(l, 3 * n[3 * this.faceId])
  18592. , u = x.FromArray(l, 3 * n[3 * this.faceId + 1])
  18593. , h = x.FromArray(l, 3 * n[3 * this.faceId + 2])
  18594. , d = c.subtract(u)
  18595. , p = h.subtract(u);
  18596. i = x.Cross(d, p)
  18597. }
  18598. if (e) {
  18599. var f = this.pickedMesh.getWorldMatrix();
  18600. this.pickedMesh.nonUniformScaling && (I.Matrix[0].copyFrom(f),
  18601. (f = I.Matrix[0]).setTranslationFromFloats(0, 0, 0),
  18602. f.invert(),
  18603. f.transposeToRef(I.Matrix[1]),
  18604. f = I.Matrix[1]),
  18605. i = x.TransformNormal(i, f)
  18606. }
  18607. return i.normalize(),
  18608. i
  18609. }
  18610. ,
  18611. e.prototype.getTextureCoordinates = function() {
  18612. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(Bi.UVKind))
  18613. return null;
  18614. var e = this.pickedMesh.getIndices();
  18615. if (!e)
  18616. return null;
  18617. var t = this.pickedMesh.getVerticesData(Bi.UVKind);
  18618. if (!t)
  18619. return null;
  18620. var i = A.FromArray(t, 2 * e[3 * this.faceId])
  18621. , n = A.FromArray(t, 2 * e[3 * this.faceId + 1])
  18622. , r = A.FromArray(t, 2 * e[3 * this.faceId + 2]);
  18623. return i = i.scale(this.bu),
  18624. n = n.scale(this.bv),
  18625. r = r.scale(1 - this.bu - this.bv),
  18626. new A(i.x + n.x + r.x,i.y + n.y + r.y)
  18627. }
  18628. ,
  18629. e
  18630. }(), Vi = function() {
  18631. function e(e) {
  18632. this._vertexBuffers = {},
  18633. this._scene = e
  18634. }
  18635. return e.prototype._prepareBuffers = function() {
  18636. if (!this._vertexBuffers[Bi.PositionKind]) {
  18637. var e = [];
  18638. e.push(1, 1),
  18639. e.push(-1, 1),
  18640. e.push(-1, -1),
  18641. e.push(1, -1),
  18642. this._vertexBuffers[Bi.PositionKind] = new Bi(this._scene.getEngine(),e,Bi.PositionKind,!1,!1,2),
  18643. this._buildIndexBuffer()
  18644. }
  18645. }
  18646. ,
  18647. e.prototype._buildIndexBuffer = function() {
  18648. var e = [];
  18649. e.push(0),
  18650. e.push(1),
  18651. e.push(2),
  18652. e.push(0),
  18653. e.push(2),
  18654. e.push(3),
  18655. this._indexBuffer = this._scene.getEngine().createIndexBuffer(e)
  18656. }
  18657. ,
  18658. e.prototype._rebuild = function() {
  18659. var e = this._vertexBuffers[Bi.PositionKind];
  18660. e && (e._rebuild(),
  18661. this._buildIndexBuffer())
  18662. }
  18663. ,
  18664. e.prototype._prepareFrame = function(e, t) {
  18665. void 0 === e && (e = null),
  18666. void 0 === t && (t = null);
  18667. var i = this._scene.activeCamera;
  18668. return !(!i || !(t = t || i._postProcesses.filter((function(e) {
  18669. return null != e
  18670. }
  18671. ))) || 0 === t.length || !this._scene.postProcessesEnabled || (t[0].activate(i, e, null != t),
  18672. 0))
  18673. }
  18674. ,
  18675. e.prototype.directRender = function(e, t, i, n, r, o) {
  18676. var s;
  18677. void 0 === t && (t = null),
  18678. void 0 === i && (i = !1),
  18679. void 0 === n && (n = 0),
  18680. void 0 === r && (r = 0),
  18681. void 0 === o && (o = !1);
  18682. for (var l = this._scene.getEngine(), c = 0; c < e.length; c++) {
  18683. c < e.length - 1 ? e[c + 1].activate(this._scene.activeCamera, null == t ? void 0 : t.texture) : (t ? l.bindFramebuffer(t, n, void 0, void 0, i, r) : o || l.restoreDefaultFramebuffer(),
  18684. null === (s = l._debugInsertMarker) || void 0 === s || s.call(l, "post process ".concat(e[c].name, " output")));
  18685. var u = e[c]
  18686. , h = u.apply();
  18687. h && (u.onBeforeRenderObservable.notifyObservers(h),
  18688. this._prepareBuffers(),
  18689. l.bindBuffers(this._vertexBuffers, this._indexBuffer, h),
  18690. l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6),
  18691. u.onAfterRenderObservable.notifyObservers(h))
  18692. }
  18693. l.setDepthBuffer(!0),
  18694. l.setDepthWrite(!0)
  18695. }
  18696. ,
  18697. e.prototype._finalizeFrame = function(e, t, i, n, r) {
  18698. var o;
  18699. void 0 === r && (r = !1);
  18700. var s = this._scene.activeCamera;
  18701. if (s && (n = n || s._postProcesses.filter((function(e) {
  18702. return null != e
  18703. }
  18704. )),
  18705. 0 !== n.length && this._scene.postProcessesEnabled)) {
  18706. for (var l = this._scene.getEngine(), c = 0, u = n.length; c < u; c++) {
  18707. var h = n[c];
  18708. if (c < u - 1 ? h._outputTexture = n[c + 1].activate(s, null == t ? void 0 : t.texture) : (t ? (l.bindFramebuffer(t, i, void 0, void 0, r),
  18709. h._outputTexture = t) : (l.restoreDefaultFramebuffer(),
  18710. h._outputTexture = null),
  18711. null === (o = l._debugInsertMarker) || void 0 === o || o.call(l, "post process ".concat(n[c].name, " output"))),
  18712. e)
  18713. break;
  18714. var d = h.apply();
  18715. d && (h.onBeforeRenderObservable.notifyObservers(d),
  18716. this._prepareBuffers(),
  18717. l.bindBuffers(this._vertexBuffers, this._indexBuffer, d),
  18718. l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6),
  18719. h.onAfterRenderObservable.notifyObservers(d))
  18720. }
  18721. l.setDepthBuffer(!0),
  18722. l.setDepthWrite(!0),
  18723. l.setAlphaMode(a.ALPHA_DISABLE)
  18724. }
  18725. }
  18726. ,
  18727. e.prototype.dispose = function() {
  18728. var e = this._vertexBuffers[Bi.PositionKind];
  18729. e && (e.dispose(),
  18730. this._vertexBuffers[Bi.PositionKind] = null),
  18731. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  18732. this._indexBuffer = null)
  18733. }
  18734. ,
  18735. e
  18736. }(), ki = function() {
  18737. function e(e, t, i, n, r) {
  18738. void 0 === i && (i = null),
  18739. void 0 === n && (n = null),
  18740. void 0 === r && (r = null),
  18741. this.index = e,
  18742. this._opaqueSubMeshes = new bi(256),
  18743. this._transparentSubMeshes = new bi(256),
  18744. this._alphaTestSubMeshes = new bi(256),
  18745. this._depthOnlySubMeshes = new bi(256),
  18746. this._particleSystems = new bi(256),
  18747. this._spriteManagers = new bi(256),
  18748. this._empty = !0,
  18749. this._edgesRenderers = new Ti(16),
  18750. this._scene = t,
  18751. this.opaqueSortCompareFn = i,
  18752. this.alphaTestSortCompareFn = n,
  18753. this.transparentSortCompareFn = r
  18754. }
  18755. return Object.defineProperty(e.prototype, "opaqueSortCompareFn", {
  18756. set: function(t) {
  18757. this._opaqueSortCompareFn = t,
  18758. this._renderOpaque = t ? this._renderOpaqueSorted : e._RenderUnsorted
  18759. },
  18760. enumerable: !1,
  18761. configurable: !0
  18762. }),
  18763. Object.defineProperty(e.prototype, "alphaTestSortCompareFn", {
  18764. set: function(t) {
  18765. this._alphaTestSortCompareFn = t,
  18766. this._renderAlphaTest = t ? this._renderAlphaTestSorted : e._RenderUnsorted
  18767. },
  18768. enumerable: !1,
  18769. configurable: !0
  18770. }),
  18771. Object.defineProperty(e.prototype, "transparentSortCompareFn", {
  18772. set: function(t) {
  18773. this._transparentSortCompareFn = t || e.defaultTransparentSortCompare,
  18774. this._renderTransparent = this._renderTransparentSorted
  18775. },
  18776. enumerable: !1,
  18777. configurable: !0
  18778. }),
  18779. e.prototype.render = function(e, t, i, n) {
  18780. if (e)
  18781. e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  18782. else {
  18783. var r = this._scene.getEngine();
  18784. 0 !== this._depthOnlySubMeshes.length && (r.setColorWrite(!1),
  18785. this._renderAlphaTest(this._depthOnlySubMeshes),
  18786. r.setColorWrite(!0)),
  18787. 0 !== this._opaqueSubMeshes.length && this._renderOpaque(this._opaqueSubMeshes),
  18788. 0 !== this._alphaTestSubMeshes.length && this._renderAlphaTest(this._alphaTestSubMeshes);
  18789. var o = r.getStencilBuffer();
  18790. if (r.setStencilBuffer(!1),
  18791. t && this._renderSprites(),
  18792. i && this._renderParticles(n),
  18793. this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
  18794. 0 !== this._transparentSubMeshes.length || this._scene.useOrderIndependentTransparency) {
  18795. if (r.setStencilBuffer(o),
  18796. this._scene.useOrderIndependentTransparency) {
  18797. var s = this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);
  18798. s.length && this._renderTransparent(s)
  18799. } else
  18800. this._renderTransparent(this._transparentSubMeshes);
  18801. r.setAlphaMode(a.ALPHA_DISABLE)
  18802. }
  18803. if (r.setStencilBuffer(!1),
  18804. this._edgesRenderers.length) {
  18805. for (var l = 0; l < this._edgesRenderers.length; l++)
  18806. this._edgesRenderers.data[l].render();
  18807. r.setAlphaMode(a.ALPHA_DISABLE)
  18808. }
  18809. r.setStencilBuffer(o)
  18810. }
  18811. }
  18812. ,
  18813. e.prototype._renderOpaqueSorted = function(t) {
  18814. return e._RenderSorted(t, this._opaqueSortCompareFn, this._scene.activeCamera, !1)
  18815. }
  18816. ,
  18817. e.prototype._renderAlphaTestSorted = function(t) {
  18818. return e._RenderSorted(t, this._alphaTestSortCompareFn, this._scene.activeCamera, !1)
  18819. }
  18820. ,
  18821. e.prototype._renderTransparentSorted = function(t) {
  18822. return e._RenderSorted(t, this._transparentSortCompareFn, this._scene.activeCamera, !0)
  18823. }
  18824. ,
  18825. e._RenderSorted = function(t, i, n, r) {
  18826. for (var o, s = 0, l = n ? n.globalPosition : e._ZeroVector; s < t.length; s++)
  18827. (o = t.data[s])._alphaIndex = o.getMesh().alphaIndex,
  18828. o._distanceToCamera = x.Distance(o.getBoundingInfo().boundingSphere.centerWorld, l);
  18829. var c = t.data.slice(0, t.length);
  18830. for (i && c.sort(i),
  18831. s = 0; s < c.length; s++) {
  18832. if (o = c[s],
  18833. r) {
  18834. var u = o.getMaterial();
  18835. if (u && u.needDepthPrePass) {
  18836. var h = u.getScene().getEngine();
  18837. h.setColorWrite(!1),
  18838. h.setAlphaMode(a.ALPHA_DISABLE),
  18839. o.render(!1),
  18840. h.setColorWrite(!0)
  18841. }
  18842. }
  18843. o.render(r)
  18844. }
  18845. }
  18846. ,
  18847. e._RenderUnsorted = function(e) {
  18848. for (var t = 0; t < e.length; t++)
  18849. e.data[t].render(!1)
  18850. }
  18851. ,
  18852. e.defaultTransparentSortCompare = function(t, i) {
  18853. return t._alphaIndex > i._alphaIndex ? 1 : t._alphaIndex < i._alphaIndex ? -1 : e.backToFrontSortCompare(t, i)
  18854. }
  18855. ,
  18856. e.backToFrontSortCompare = function(e, t) {
  18857. return e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0
  18858. }
  18859. ,
  18860. e.frontToBackSortCompare = function(e, t) {
  18861. return e._distanceToCamera < t._distanceToCamera ? -1 : e._distanceToCamera > t._distanceToCamera ? 1 : 0
  18862. }
  18863. ,
  18864. e.prototype.prepare = function() {
  18865. this._opaqueSubMeshes.reset(),
  18866. this._transparentSubMeshes.reset(),
  18867. this._alphaTestSubMeshes.reset(),
  18868. this._depthOnlySubMeshes.reset(),
  18869. this._particleSystems.reset(),
  18870. this._spriteManagers.reset(),
  18871. this._edgesRenderers.reset(),
  18872. this._empty = !0
  18873. }
  18874. ,
  18875. e.prototype.dispose = function() {
  18876. this._opaqueSubMeshes.dispose(),
  18877. this._transparentSubMeshes.dispose(),
  18878. this._alphaTestSubMeshes.dispose(),
  18879. this._depthOnlySubMeshes.dispose(),
  18880. this._particleSystems.dispose(),
  18881. this._spriteManagers.dispose(),
  18882. this._edgesRenderers.dispose()
  18883. }
  18884. ,
  18885. e.prototype.dispatch = function(e, t, i) {
  18886. void 0 === t && (t = e.getMesh()),
  18887. void 0 === i && (i = e.getMaterial()),
  18888. null != i && (i.needAlphaBlendingForMesh(t) ? this._transparentSubMeshes.push(e) : i.needAlphaTesting() ? (i.needDepthPrePass && this._depthOnlySubMeshes.push(e),
  18889. this._alphaTestSubMeshes.push(e)) : (i.needDepthPrePass && this._depthOnlySubMeshes.push(e),
  18890. this._opaqueSubMeshes.push(e)),
  18891. t._renderingGroup = this,
  18892. t._edgesRenderer && t._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),
  18893. this._empty = !1)
  18894. }
  18895. ,
  18896. e.prototype.dispatchSprites = function(e) {
  18897. this._spriteManagers.push(e),
  18898. this._empty = !1
  18899. }
  18900. ,
  18901. e.prototype.dispatchParticles = function(e) {
  18902. this._particleSystems.push(e),
  18903. this._empty = !1
  18904. }
  18905. ,
  18906. e.prototype._renderParticles = function(e) {
  18907. if (0 !== this._particleSystems.length) {
  18908. var t = this._scene.activeCamera;
  18909. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  18910. for (var i = 0; i < this._particleSystems.length; i++) {
  18911. var n = this._particleSystems.data[i];
  18912. if (0 !== (t && t.layerMask & n.layerMask)) {
  18913. var r = n.emitter;
  18914. r.position && e && -1 === e.indexOf(r) || this._scene._activeParticles.addCount(n.render(), !1)
  18915. }
  18916. }
  18917. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)
  18918. }
  18919. }
  18920. ,
  18921. e.prototype._renderSprites = function() {
  18922. if (this._scene.spritesEnabled && 0 !== this._spriteManagers.length) {
  18923. var e = this._scene.activeCamera;
  18924. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  18925. for (var t = 0; t < this._spriteManagers.length; t++) {
  18926. var i = this._spriteManagers.data[t];
  18927. 0 !== (e && e.layerMask & i.layerMask) && i.render()
  18928. }
  18929. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)
  18930. }
  18931. }
  18932. ,
  18933. e._ZeroVector = x.Zero(),
  18934. e
  18935. }(), Gi = function() {}, zi = function() {
  18936. function e(t) {
  18937. this._useSceneAutoClearSetup = !1,
  18938. this._renderingGroups = new Array,
  18939. this._autoClearDepthStencil = {},
  18940. this._customOpaqueSortCompareFn = {},
  18941. this._customAlphaTestSortCompareFn = {},
  18942. this._customTransparentSortCompareFn = {},
  18943. this._renderingGroupInfo = new Gi,
  18944. this._scene = t;
  18945. for (var i = e.MIN_RENDERINGGROUPS; i < e.MAX_RENDERINGGROUPS; i++)
  18946. this._autoClearDepthStencil[i] = {
  18947. autoClear: !0,
  18948. depth: !0,
  18949. stencil: !0
  18950. }
  18951. }
  18952. return e.prototype._clearDepthStencilBuffer = function(e, t) {
  18953. void 0 === e && (e = !0),
  18954. void 0 === t && (t = !0),
  18955. this._depthStencilBufferAlreadyCleaned || (this._scene.getEngine().clear(null, !1, e, t),
  18956. this._depthStencilBufferAlreadyCleaned = !0)
  18957. }
  18958. ,
  18959. e.prototype.render = function(t, i, n, r) {
  18960. var o = this._renderingGroupInfo;
  18961. if (o.scene = this._scene,
  18962. o.camera = this._scene.activeCamera,
  18963. this._scene.spriteManagers && r)
  18964. for (var a = 0; a < this._scene.spriteManagers.length; a++) {
  18965. var s = this._scene.spriteManagers[a];
  18966. this.dispatchSprites(s)
  18967. }
  18968. for (a = e.MIN_RENDERINGGROUPS; a < e.MAX_RENDERINGGROUPS; a++) {
  18969. this._depthStencilBufferAlreadyCleaned = a === e.MIN_RENDERINGGROUPS;
  18970. var l = this._renderingGroups[a];
  18971. if (l && !l._empty) {
  18972. var c = Math.pow(2, a);
  18973. if (o.renderingGroupId = a,
  18974. this._scene.onBeforeRenderingGroupObservable.notifyObservers(o, c),
  18975. e.AUTOCLEAR) {
  18976. var u = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(a) : this._autoClearDepthStencil[a];
  18977. u && u.autoClear && this._clearDepthStencilBuffer(u.depth, u.stencil)
  18978. }
  18979. for (var h = 0, d = this._scene._beforeRenderingGroupDrawStage; h < d.length; h++)
  18980. d[h].action(a);
  18981. l.render(t, r, n, i);
  18982. for (var p = 0, f = this._scene._afterRenderingGroupDrawStage; p < f.length; p++)
  18983. f[p].action(a);
  18984. this._scene.onAfterRenderingGroupObservable.notifyObservers(o, c)
  18985. }
  18986. }
  18987. }
  18988. ,
  18989. e.prototype.reset = function() {
  18990. for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) {
  18991. var i = this._renderingGroups[t];
  18992. i && i.prepare()
  18993. }
  18994. }
  18995. ,
  18996. e.prototype.dispose = function() {
  18997. this.freeRenderingGroups(),
  18998. this._renderingGroups.length = 0,
  18999. this._renderingGroupInfo = null
  19000. }
  19001. ,
  19002. e.prototype.freeRenderingGroups = function() {
  19003. for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) {
  19004. var i = this._renderingGroups[t];
  19005. i && i.dispose()
  19006. }
  19007. }
  19008. ,
  19009. e.prototype._prepareRenderingGroup = function(e) {
  19010. void 0 === this._renderingGroups[e] && (this._renderingGroups[e] = new ki(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
  19011. }
  19012. ,
  19013. e.prototype.dispatchSprites = function(e) {
  19014. var t = e.renderingGroupId || 0;
  19015. this._prepareRenderingGroup(t),
  19016. this._renderingGroups[t].dispatchSprites(e)
  19017. }
  19018. ,
  19019. e.prototype.dispatchParticles = function(e) {
  19020. var t = e.renderingGroupId || 0;
  19021. this._prepareRenderingGroup(t),
  19022. this._renderingGroups[t].dispatchParticles(e)
  19023. }
  19024. ,
  19025. e.prototype.dispatch = function(e, t, i) {
  19026. void 0 === t && (t = e.getMesh());
  19027. var n = t.renderingGroupId || 0;
  19028. this._prepareRenderingGroup(n),
  19029. this._renderingGroups[n].dispatch(e, t, i)
  19030. }
  19031. ,
  19032. e.prototype.setRenderingOrder = function(e, t, i, n) {
  19033. if (void 0 === t && (t = null),
  19034. void 0 === i && (i = null),
  19035. void 0 === n && (n = null),
  19036. this._customOpaqueSortCompareFn[e] = t,
  19037. this._customAlphaTestSortCompareFn[e] = i,
  19038. this._customTransparentSortCompareFn[e] = n,
  19039. this._renderingGroups[e]) {
  19040. var r = this._renderingGroups[e];
  19041. r.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
  19042. r.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
  19043. r.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
  19044. }
  19045. }
  19046. ,
  19047. e.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
  19048. void 0 === i && (i = !0),
  19049. void 0 === n && (n = !0),
  19050. this._autoClearDepthStencil[e] = {
  19051. autoClear: t,
  19052. depth: i,
  19053. stencil: n
  19054. }
  19055. }
  19056. ,
  19057. e.prototype.getAutoClearDepthStencilSetup = function(e) {
  19058. return this._autoClearDepthStencil[e]
  19059. }
  19060. ,
  19061. e.MAX_RENDERINGGROUPS = 4,
  19062. e.MIN_RENDERINGGROUPS = 0,
  19063. e.AUTOCLEAR = !0,
  19064. e
  19065. }(), Wi = function() {
  19066. function e() {}
  19067. return e.NAME_EFFECTLAYER = "EffectLayer",
  19068. e.NAME_LAYER = "Layer",
  19069. e.NAME_LENSFLARESYSTEM = "LensFlareSystem",
  19070. e.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer",
  19071. e.NAME_PARTICLESYSTEM = "ParticleSystem",
  19072. e.NAME_GAMEPAD = "Gamepad",
  19073. e.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue",
  19074. e.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer",
  19075. e.NAME_PREPASSRENDERER = "PrePassRenderer",
  19076. e.NAME_DEPTHRENDERER = "DepthRenderer",
  19077. e.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer",
  19078. e.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager",
  19079. e.NAME_SPRITE = "Sprite",
  19080. e.NAME_SUBSURFACE = "SubSurface",
  19081. e.NAME_OUTLINERENDERER = "Outline",
  19082. e.NAME_PROCEDURALTEXTURE = "ProceduralTexture",
  19083. e.NAME_SHADOWGENERATOR = "ShadowGenerator",
  19084. e.NAME_OCTREE = "Octree",
  19085. e.NAME_PHYSICSENGINE = "PhysicsEngine",
  19086. e.NAME_AUDIO = "Audio",
  19087. e.STEP_ISREADYFORMESH_EFFECTLAYER = 0,
  19088. e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0,
  19089. e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0,
  19090. e.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0,
  19091. e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1,
  19092. e.STEP_BEFORECAMERADRAW_PREPASS = 0,
  19093. e.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1,
  19094. e.STEP_BEFORECAMERADRAW_LAYER = 2,
  19095. e.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0,
  19096. e.STEP_BEFORERENDERTARGETDRAW_LAYER = 1,
  19097. e.STEP_BEFORERENDERINGMESH_PREPASS = 0,
  19098. e.STEP_BEFORERENDERINGMESH_OUTLINE = 1,
  19099. e.STEP_AFTERRENDERINGMESH_PREPASS = 0,
  19100. e.STEP_AFTERRENDERINGMESH_OUTLINE = 1,
  19101. e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0,
  19102. e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1,
  19103. e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0,
  19104. e.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1,
  19105. e.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0,
  19106. e.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0,
  19107. e.STEP_AFTERRENDERTARGETDRAW_LAYER = 1,
  19108. e.STEP_AFTERCAMERADRAW_PREPASS = 0,
  19109. e.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1,
  19110. e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2,
  19111. e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3,
  19112. e.STEP_AFTERCAMERADRAW_LAYER = 4,
  19113. e.STEP_AFTERRENDER_AUDIO = 0,
  19114. e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0,
  19115. e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1,
  19116. e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2,
  19117. e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3,
  19118. e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0,
  19119. e.STEP_BEFORECLEARSTAGE_PREPASS = 0,
  19120. e.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
  19121. e.STEP_POINTERMOVE_SPRITE = 0,
  19122. e.STEP_POINTERDOWN_SPRITE = 0,
  19123. e.STEP_POINTERUP_SPRITE = 0,
  19124. e
  19125. }(), Hi = function(e) {
  19126. function t(t) {
  19127. return e.apply(this, t) || this
  19128. }
  19129. return U(t, e),
  19130. t.Create = function() {
  19131. return Object.create(t.prototype)
  19132. }
  19133. ,
  19134. t.prototype.registerStep = function(e, t, i) {
  19135. var n = 0;
  19136. for (Number.MAX_VALUE; n < this.length && !(e < this[n].index); n++)
  19137. ;
  19138. this.splice(n, 0, {
  19139. index: e,
  19140. component: t,
  19141. action: i.bind(t)
  19142. })
  19143. }
  19144. ,
  19145. t.prototype.clear = function() {
  19146. this.length = 0
  19147. }
  19148. ,
  19149. t
  19150. }(Array), Xi = function() {
  19151. function e() {}
  19152. return e.POINTERDOWN = 1,
  19153. e.POINTERUP = 2,
  19154. e.POINTERMOVE = 4,
  19155. e.POINTERWHEEL = 8,
  19156. e.POINTERPICK = 16,
  19157. e.POINTERTAP = 32,
  19158. e.POINTERDOUBLETAP = 64,
  19159. e
  19160. }(), ji = function(e, t) {
  19161. this.type = e,
  19162. this.event = t
  19163. }, Yi = function(e) {
  19164. function t(t, i, n, r) {
  19165. var o = e.call(this, t, i) || this;
  19166. return o.ray = null,
  19167. o.skipOnPointerObservable = !1,
  19168. o.localPosition = new A(n,r),
  19169. o
  19170. }
  19171. return U(t, e),
  19172. t
  19173. }(ji), Ki = function(e) {
  19174. function t(t, i, n) {
  19175. var r = e.call(this, t, i) || this;
  19176. return r.pickInfo = n,
  19177. r
  19178. }
  19179. return U(t, e),
  19180. t
  19181. }(ji), Qi = function() {
  19182. function e() {}
  19183. return e.KEYDOWN = 1,
  19184. e.KEYUP = 2,
  19185. e
  19186. }(), qi = function(e, t) {
  19187. this.type = e,
  19188. this.event = t
  19189. }, Zi = function(e) {
  19190. function t(t, i) {
  19191. var n = e.call(this, t, i) || this;
  19192. return n.type = t,
  19193. n.event = i,
  19194. n.skipOnKeyboardObservable = !1,
  19195. n
  19196. }
  19197. return U(t, e),
  19198. Object.defineProperty(t.prototype, "skipOnPointerObservable", {
  19199. get: function() {
  19200. return this.skipOnKeyboardObservable
  19201. },
  19202. set: function(e) {
  19203. this.skipOnKeyboardObservable = e
  19204. },
  19205. enumerable: !1,
  19206. configurable: !0
  19207. }),
  19208. t
  19209. }(qi);
  19210. !function(e) {
  19211. e[e.Generic = 0] = "Generic",
  19212. e[e.Keyboard = 1] = "Keyboard",
  19213. e[e.Mouse = 2] = "Mouse",
  19214. e[e.Touch = 3] = "Touch",
  19215. e[e.DualShock = 4] = "DualShock",
  19216. e[e.Xbox = 5] = "Xbox",
  19217. e[e.Switch = 6] = "Switch",
  19218. e[e.DualSense = 7] = "DualSense"
  19219. }(Ci || (Ci = {})),
  19220. function(e) {
  19221. e[e.Horizontal = 0] = "Horizontal",
  19222. e[e.Vertical = 1] = "Vertical",
  19223. e[e.LeftClick = 2] = "LeftClick",
  19224. e[e.MiddleClick = 3] = "MiddleClick",
  19225. e[e.RightClick = 4] = "RightClick",
  19226. e[e.BrowserBack = 5] = "BrowserBack",
  19227. e[e.BrowserForward = 6] = "BrowserForward",
  19228. e[e.MouseWheelX = 7] = "MouseWheelX",
  19229. e[e.MouseWheelY = 8] = "MouseWheelY",
  19230. e[e.MouseWheelZ = 9] = "MouseWheelZ",
  19231. e[e.Move = 12] = "Move"
  19232. }(Pi || (Pi = {})),
  19233. function(e) {
  19234. e[e.Horizontal = 0] = "Horizontal",
  19235. e[e.Vertical = 1] = "Vertical",
  19236. e[e.LeftClick = 2] = "LeftClick",
  19237. e[e.MiddleClick = 3] = "MiddleClick",
  19238. e[e.RightClick = 4] = "RightClick",
  19239. e[e.BrowserBack = 5] = "BrowserBack",
  19240. e[e.BrowserForward = 6] = "BrowserForward",
  19241. e[e.MouseWheelX = 7] = "MouseWheelX",
  19242. e[e.MouseWheelY = 8] = "MouseWheelY",
  19243. e[e.MouseWheelZ = 9] = "MouseWheelZ",
  19244. e[e.DeltaHorizontal = 10] = "DeltaHorizontal",
  19245. e[e.DeltaVertical = 11] = "DeltaVertical"
  19246. }(Mi || (Mi = {})),
  19247. function(e) {
  19248. e[e.Cross = 0] = "Cross",
  19249. e[e.Circle = 1] = "Circle",
  19250. e[e.Square = 2] = "Square",
  19251. e[e.Triangle = 3] = "Triangle",
  19252. e[e.L1 = 4] = "L1",
  19253. e[e.R1 = 5] = "R1",
  19254. e[e.L2 = 6] = "L2",
  19255. e[e.R2 = 7] = "R2",
  19256. e[e.Share = 8] = "Share",
  19257. e[e.Options = 9] = "Options",
  19258. e[e.L3 = 10] = "L3",
  19259. e[e.R3 = 11] = "R3",
  19260. e[e.DPadUp = 12] = "DPadUp",
  19261. e[e.DPadDown = 13] = "DPadDown",
  19262. e[e.DPadLeft = 14] = "DPadLeft",
  19263. e[e.DPadRight = 15] = "DPadRight",
  19264. e[e.Home = 16] = "Home",
  19265. e[e.TouchPad = 17] = "TouchPad",
  19266. e[e.LStickXAxis = 18] = "LStickXAxis",
  19267. e[e.LStickYAxis = 19] = "LStickYAxis",
  19268. e[e.RStickXAxis = 20] = "RStickXAxis",
  19269. e[e.RStickYAxis = 21] = "RStickYAxis"
  19270. }(Ii || (Ii = {})),
  19271. function(e) {
  19272. e[e.Cross = 0] = "Cross",
  19273. e[e.Circle = 1] = "Circle",
  19274. e[e.Square = 2] = "Square",
  19275. e[e.Triangle = 3] = "Triangle",
  19276. e[e.L1 = 4] = "L1",
  19277. e[e.R1 = 5] = "R1",
  19278. e[e.L2 = 6] = "L2",
  19279. e[e.R2 = 7] = "R2",
  19280. e[e.Create = 8] = "Create",
  19281. e[e.Options = 9] = "Options",
  19282. e[e.L3 = 10] = "L3",
  19283. e[e.R3 = 11] = "R3",
  19284. e[e.DPadUp = 12] = "DPadUp",
  19285. e[e.DPadDown = 13] = "DPadDown",
  19286. e[e.DPadLeft = 14] = "DPadLeft",
  19287. e[e.DPadRight = 15] = "DPadRight",
  19288. e[e.Home = 16] = "Home",
  19289. e[e.TouchPad = 17] = "TouchPad",
  19290. e[e.LStickXAxis = 18] = "LStickXAxis",
  19291. e[e.LStickYAxis = 19] = "LStickYAxis",
  19292. e[e.RStickXAxis = 20] = "RStickXAxis",
  19293. e[e.RStickYAxis = 21] = "RStickYAxis"
  19294. }(Oi || (Oi = {})),
  19295. function(e) {
  19296. e[e.A = 0] = "A",
  19297. e[e.B = 1] = "B",
  19298. e[e.X = 2] = "X",
  19299. e[e.Y = 3] = "Y",
  19300. e[e.LB = 4] = "LB",
  19301. e[e.RB = 5] = "RB",
  19302. e[e.LT = 6] = "LT",
  19303. e[e.RT = 7] = "RT",
  19304. e[e.Back = 8] = "Back",
  19305. e[e.Start = 9] = "Start",
  19306. e[e.LS = 10] = "LS",
  19307. e[e.RS = 11] = "RS",
  19308. e[e.DPadUp = 12] = "DPadUp",
  19309. e[e.DPadDown = 13] = "DPadDown",
  19310. e[e.DPadLeft = 14] = "DPadLeft",
  19311. e[e.DPadRight = 15] = "DPadRight",
  19312. e[e.Home = 16] = "Home",
  19313. e[e.LStickXAxis = 17] = "LStickXAxis",
  19314. e[e.LStickYAxis = 18] = "LStickYAxis",
  19315. e[e.RStickXAxis = 19] = "RStickXAxis",
  19316. e[e.RStickYAxis = 20] = "RStickYAxis"
  19317. }(Di || (Di = {})),
  19318. function(e) {
  19319. e[e.B = 0] = "B",
  19320. e[e.A = 1] = "A",
  19321. e[e.Y = 2] = "Y",
  19322. e[e.X = 3] = "X",
  19323. e[e.L = 4] = "L",
  19324. e[e.R = 5] = "R",
  19325. e[e.ZL = 6] = "ZL",
  19326. e[e.ZR = 7] = "ZR",
  19327. e[e.Minus = 8] = "Minus",
  19328. e[e.Plus = 9] = "Plus",
  19329. e[e.LS = 10] = "LS",
  19330. e[e.RS = 11] = "RS",
  19331. e[e.DPadUp = 12] = "DPadUp",
  19332. e[e.DPadDown = 13] = "DPadDown",
  19333. e[e.DPadLeft = 14] = "DPadLeft",
  19334. e[e.DPadRight = 15] = "DPadRight",
  19335. e[e.Home = 16] = "Home",
  19336. e[e.Capture = 17] = "Capture",
  19337. e[e.LStickXAxis = 18] = "LStickXAxis",
  19338. e[e.LStickYAxis = 19] = "LStickYAxis",
  19339. e[e.RStickXAxis = 20] = "RStickXAxis",
  19340. e[e.RStickYAxis = 21] = "RStickYAxis"
  19341. }(Ni || (Ni = {})),
  19342. function(e) {
  19343. e[e.PointerMove = 0] = "PointerMove",
  19344. e[e.PointerDown = 1] = "PointerDown",
  19345. e[e.PointerUp = 2] = "PointerUp"
  19346. }(Li || (Li = {}));
  19347. var Ji, $i = function() {
  19348. function e() {}
  19349. return e.DOM_DELTA_PIXEL = 0,
  19350. e.DOM_DELTA_LINE = 1,
  19351. e.DOM_DELTA_PAGE = 2,
  19352. e
  19353. }(), en = function() {
  19354. function e() {}
  19355. return e.CreateDeviceEvent = function(e, t, i, n, r, o) {
  19356. switch (e) {
  19357. case Ci.Keyboard:
  19358. return this._CreateKeyboardEvent(i, n, r, o);
  19359. case Ci.Mouse:
  19360. if (i === Pi.MouseWheelX || i === Pi.MouseWheelY || i === Pi.MouseWheelZ)
  19361. return this._CreateWheelEvent(e, t, i, n, r, o);
  19362. case Ci.Touch:
  19363. return this._CreatePointerEvent(e, t, i, n, r, o);
  19364. default:
  19365. throw "Unable to generate event for device ".concat(Ci[e])
  19366. }
  19367. }
  19368. ,
  19369. e._CreatePointerEvent = function(e, t, i, n, r, o) {
  19370. var a = this._CreateMouseEvent(e, t, i, n, r, o);
  19371. return e === Ci.Mouse ? (a.deviceType = Ci.Mouse,
  19372. a.pointerId = 1,
  19373. a.pointerType = "mouse") : (a.deviceType = Ci.Touch,
  19374. a.pointerId = t,
  19375. a.pointerType = "touch"),
  19376. i === Pi.Move ? a.type = "pointermove" : i >= Pi.LeftClick && i <= Pi.RightClick && (a.type = 1 === n ? "pointerdown" : "pointerup",
  19377. a.button = i - 2),
  19378. a
  19379. }
  19380. ,
  19381. e._CreateWheelEvent = function(e, t, i, n, r, o) {
  19382. var a = this._CreateMouseEvent(e, t, i, n, r, o);
  19383. return a.type = "wheel",
  19384. a.deltaMode = $i.DOM_DELTA_PIXEL,
  19385. a.deltaX = i === Pi.MouseWheelX ? n : r.pollInput(e, t, Pi.MouseWheelX),
  19386. a.deltaY = i === Pi.MouseWheelY ? n : r.pollInput(e, t, Pi.MouseWheelY),
  19387. a.deltaZ = i === Pi.MouseWheelZ ? n : r.pollInput(e, t, Pi.MouseWheelZ),
  19388. a
  19389. }
  19390. ,
  19391. e._CreateMouseEvent = function(e, t, i, n, r, o) {
  19392. var a = this._CreateEvent(o)
  19393. , s = r.pollInput(e, t, Pi.Horizontal)
  19394. , l = r.pollInput(e, t, Pi.Vertical);
  19395. return o ? (a.movementX = 0,
  19396. a.movementY = 0,
  19397. a.offsetX = a.movementX - o.getBoundingClientRect().x,
  19398. a.offsetY = a.movementY - o.getBoundingClientRect().y) : (a.movementX = r.pollInput(e, t, Mi.DeltaHorizontal),
  19399. a.movementY = r.pollInput(e, t, Mi.DeltaVertical),
  19400. a.offsetX = 0,
  19401. a.offsetY = 0),
  19402. this._CheckNonCharacterKeys(a, r),
  19403. a.clientX = s,
  19404. a.clientY = l,
  19405. a.x = s,
  19406. a.y = l,
  19407. a.deviceType = e,
  19408. a.deviceSlot = t,
  19409. a.inputIndex = i,
  19410. a
  19411. }
  19412. ,
  19413. e._CreateKeyboardEvent = function(e, t, i, n) {
  19414. var r = this._CreateEvent(n);
  19415. return this._CheckNonCharacterKeys(r, i),
  19416. r.deviceType = Ci.Keyboard,
  19417. r.deviceSlot = 0,
  19418. r.inputIndex = e,
  19419. r.type = 1 === t ? "keydown" : "keyup",
  19420. r.key = String.fromCharCode(e),
  19421. r.keyCode = e,
  19422. r
  19423. }
  19424. ,
  19425. e._CheckNonCharacterKeys = function(e, t) {
  19426. var i = t.isDeviceAvailable(Ci.Keyboard)
  19427. , n = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_ALT_KEY)
  19428. , r = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_CTRL_KEY)
  19429. , o = i && (1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY1) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY2) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY3))
  19430. , s = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_SHIFT_KEY);
  19431. e.altKey = n,
  19432. e.ctrlKey = r,
  19433. e.metaKey = o,
  19434. e.shiftKey = s
  19435. }
  19436. ,
  19437. e._CreateEvent = function(e) {
  19438. var t = {
  19439. preventDefault: function() {}
  19440. };
  19441. return t.target = e,
  19442. t
  19443. }
  19444. ,
  19445. e
  19446. }(), tn = function() {
  19447. function e(e, t, i) {
  19448. var n = this;
  19449. this._nativeInput = _native.DeviceInputSystem ? new _native.DeviceInputSystem(e,t,(function(e, t, r, o) {
  19450. var a = r === Mi.Horizontal || r === Mi.Vertical || r === Mi.DeltaHorizontal || r === Mi.DeltaVertical ? Pi.Move : r
  19451. , s = en.CreateDeviceEvent(e, t, a, o, n);
  19452. i(e, t, s)
  19453. }
  19454. )) : this._createDummyNativeInput()
  19455. }
  19456. return e.prototype.pollInput = function(e, t, i) {
  19457. return this._nativeInput.pollInput(e, t, i)
  19458. }
  19459. ,
  19460. e.prototype.isDeviceAvailable = function(e) {
  19461. return e === Ci.Mouse || e === Ci.Touch
  19462. }
  19463. ,
  19464. e.prototype.dispose = function() {
  19465. this._nativeInput.dispose()
  19466. }
  19467. ,
  19468. e.prototype._createDummyNativeInput = function() {
  19469. return {
  19470. pollInput: function() {
  19471. return 0
  19472. },
  19473. isDeviceAvailable: function() {
  19474. return !1
  19475. },
  19476. dispose: function() {}
  19477. }
  19478. }
  19479. ,
  19480. e
  19481. }(), nn = Object.keys(Pi).length / 2, rn = function() {
  19482. function e(e, t, i, n) {
  19483. var r = this;
  19484. this._inputs = [],
  19485. this._keyboardActive = !1,
  19486. this._pointerActive = !1,
  19487. this._usingSafari = gi.IsSafari(),
  19488. this._keyboardDownEvent = function(e) {}
  19489. ,
  19490. this._keyboardUpEvent = function(e) {}
  19491. ,
  19492. this._keyboardBlurEvent = function(e) {}
  19493. ,
  19494. this._pointerMoveEvent = function(e) {}
  19495. ,
  19496. this._pointerDownEvent = function(e) {}
  19497. ,
  19498. this._pointerUpEvent = function(e) {}
  19499. ,
  19500. this._pointerCancelEvent = function(e) {}
  19501. ,
  19502. this._pointerWheelEvent = function(e) {}
  19503. ,
  19504. this._pointerBlurEvent = function(e) {}
  19505. ,
  19506. this._eventsAttached = !1,
  19507. this._mouseId = -1,
  19508. this._isUsingFirefox = lt.IsNavigatorAvailable() && navigator.userAgent && -1 !== navigator.userAgent.indexOf("Firefox"),
  19509. this._maxTouchPoints = 0,
  19510. this._pointerInputClearObserver = null,
  19511. this._gamepadConnectedEvent = function(e) {}
  19512. ,
  19513. this._gamepadDisconnectedEvent = function(e) {}
  19514. ,
  19515. this._eventPrefix = gi.GetPointerPrefix(e),
  19516. this._engine = e,
  19517. this._onDeviceConnected = t,
  19518. this._onDeviceDisconnected = i,
  19519. this._onInputChanged = n,
  19520. this._enableEvents(),
  19521. this._engine._onEngineViewChanged || (this._engine._onEngineViewChanged = function() {
  19522. r._enableEvents()
  19523. }
  19524. )
  19525. }
  19526. return e.prototype.pollInput = function(e, t, i) {
  19527. var n = this._inputs[e][t];
  19528. if (!n)
  19529. throw "Unable to find device ".concat(Ci[e]);
  19530. e >= Ci.DualShock && e <= Ci.DualSense && navigator.getGamepads && this._updateDevice(e, t, i);
  19531. var r = n[i];
  19532. if (void 0 === r)
  19533. throw "Unable to find input ".concat(i, " for device ").concat(Ci[e], " in slot ").concat(t);
  19534. return i === Pi.Move && gi.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),
  19535. r
  19536. }
  19537. ,
  19538. e.prototype.isDeviceAvailable = function(e) {
  19539. return void 0 !== this._inputs[e]
  19540. }
  19541. ,
  19542. e.prototype.dispose = function() {
  19543. this._onDeviceConnected = function() {}
  19544. ,
  19545. this._onDeviceDisconnected = function() {}
  19546. ,
  19547. this._onInputChanged = function() {}
  19548. ,
  19549. delete this._engine._onEngineViewChanged,
  19550. this._elementToAttachTo && this._disableEvents()
  19551. }
  19552. ,
  19553. e.prototype._enableEvents = function() {
  19554. var e = null == this ? void 0 : this._engine.getInputElement();
  19555. if (e && (!this._eventsAttached || this._elementToAttachTo !== e)) {
  19556. if (this._disableEvents(),
  19557. this._inputs)
  19558. for (var t = 0, i = this._inputs; t < i.length; t++) {
  19559. var n = i[t];
  19560. if (n)
  19561. for (var r in n) {
  19562. var o = n[+r];
  19563. if (o)
  19564. for (var a = 0; a < o.length; a++)
  19565. o[a] = 0
  19566. }
  19567. }
  19568. this._elementToAttachTo = e,
  19569. this._elementToAttachTo.tabIndex = -1 !== this._elementToAttachTo.tabIndex ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex,
  19570. this._handleKeyActions(),
  19571. this._handlePointerActions(),
  19572. this._handleGamepadActions(),
  19573. this._eventsAttached = !0,
  19574. this._checkForConnectedDevices()
  19575. }
  19576. }
  19577. ,
  19578. e.prototype._disableEvents = function() {
  19579. this._elementToAttachTo && (this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent),
  19580. this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent),
  19581. this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent),
  19582. this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent),
  19583. this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
  19584. this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent),
  19585. this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent),
  19586. this._elementToAttachTo.removeEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent),
  19587. this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent),
  19588. window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent),
  19589. window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)),
  19590. this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),
  19591. this._eventsAttached = !1
  19592. }
  19593. ,
  19594. e.prototype._checkForConnectedDevices = function() {
  19595. if (navigator.getGamepads)
  19596. for (var e = 0, t = navigator.getGamepads(); e < t.length; e++) {
  19597. var i = t[e];
  19598. i && this._addGamePad(i)
  19599. }
  19600. matchMedia("(pointer:fine)").matches && this._addPointerDevice(Ci.Mouse, 0, 0, 0)
  19601. }
  19602. ,
  19603. e.prototype._addGamePad = function(e) {
  19604. var t = this._getGamepadDeviceType(e.id)
  19605. , i = e.index;
  19606. this._gamepads = this._gamepads || new Array(e.index + 1),
  19607. this._registerDevice(t, i, e.buttons.length + e.axes.length),
  19608. this._gamepads[i] = t
  19609. }
  19610. ,
  19611. e.prototype._addPointerDevice = function(e, t, i, n) {
  19612. this._pointerActive || (this._pointerActive = !0),
  19613. this._registerDevice(e, t, nn);
  19614. var r = this._inputs[e][t];
  19615. r[0] = i,
  19616. r[1] = n
  19617. }
  19618. ,
  19619. e.prototype._registerDevice = function(e, t, i) {
  19620. if (void 0 === t)
  19621. throw "Unable to register device ".concat(Ci[e], " to undefined slot.");
  19622. if (this._inputs[e] || (this._inputs[e] = {}),
  19623. !this._inputs[e][t]) {
  19624. for (var n = new Array(i), r = 0; r < i; r++)
  19625. n[r] = 0;
  19626. this._inputs[e][t] = n,
  19627. this._onDeviceConnected(e, t)
  19628. }
  19629. }
  19630. ,
  19631. e.prototype._unregisterDevice = function(e, t) {
  19632. this._inputs[e][t] && (delete this._inputs[e][t],
  19633. this._onDeviceDisconnected(e, t))
  19634. }
  19635. ,
  19636. e.prototype._handleKeyActions = function() {
  19637. var e = this;
  19638. this._keyboardDownEvent = function(t) {
  19639. e._keyboardActive || (e._keyboardActive = !0,
  19640. e._registerDevice(Ci.Keyboard, 0, 255));
  19641. var i = e._inputs[Ci.Keyboard][0];
  19642. if (i) {
  19643. i[t.keyCode] = 1;
  19644. var n = t;
  19645. n.inputIndex = t.keyCode,
  19646. e._onInputChanged(Ci.Keyboard, 0, n)
  19647. }
  19648. }
  19649. ,
  19650. this._keyboardUpEvent = function(t) {
  19651. e._keyboardActive || (e._keyboardActive = !0,
  19652. e._registerDevice(Ci.Keyboard, 0, 255));
  19653. var i = e._inputs[Ci.Keyboard][0];
  19654. if (i) {
  19655. i[t.keyCode] = 0;
  19656. var n = t;
  19657. n.inputIndex = t.keyCode,
  19658. e._onInputChanged(Ci.Keyboard, 0, n)
  19659. }
  19660. }
  19661. ,
  19662. this._keyboardBlurEvent = function() {
  19663. if (e._keyboardActive)
  19664. for (var t = e._inputs[Ci.Keyboard][0], i = 0; i < t.length; i++)
  19665. if (0 !== t[i]) {
  19666. t[i] = 0;
  19667. var n = en.CreateDeviceEvent(Ci.Keyboard, 0, i, 0, e, e._elementToAttachTo);
  19668. e._onInputChanged(Ci.Keyboard, 0, n)
  19669. }
  19670. }
  19671. ,
  19672. this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent),
  19673. this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent),
  19674. this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent)
  19675. }
  19676. ,
  19677. e.prototype._handlePointerActions = function() {
  19678. var e = this;
  19679. this._maxTouchPoints = lt.IsNavigatorAvailable() && navigator.maxTouchPoints || 2,
  19680. this._activeTouchIds || (this._activeTouchIds = new Array(this._maxTouchPoints));
  19681. for (var t = 0; t < this._maxTouchPoints; t++)
  19682. this._activeTouchIds[t] = -1;
  19683. this._pointerMoveEvent = function(t) {
  19684. var i = e._getPointerType(t)
  19685. , n = i === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
  19686. e._inputs[i] || (e._inputs[i] = {}),
  19687. e._inputs[i][n] || e._addPointerDevice(i, n, t.clientX, t.clientY);
  19688. var r = e._inputs[i][n];
  19689. if (r) {
  19690. r[Pi.Horizontal] = t.clientX,
  19691. r[Pi.Vertical] = t.clientY;
  19692. var o = t;
  19693. o.inputIndex = Pi.Move,
  19694. e._onInputChanged(i, n, o),
  19695. e._usingSafari || -1 === t.button || (o.inputIndex = t.button + 2,
  19696. r[t.button + 2] = r[t.button + 2] ? 0 : 1,
  19697. e._onInputChanged(i, n, o))
  19698. }
  19699. }
  19700. ,
  19701. this._pointerDownEvent = function(t) {
  19702. var i = e._getPointerType(t)
  19703. , n = i === Ci.Mouse ? 0 : t.pointerId;
  19704. if (i === Ci.Touch) {
  19705. var r = e._activeTouchIds.indexOf(-1);
  19706. if (!(r >= 0))
  19707. return void gi.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));
  19708. n = r,
  19709. e._activeTouchIds[r] = t.pointerId
  19710. }
  19711. e._inputs[i] || (e._inputs[i] = {}),
  19712. e._inputs[i][n] ? i === Ci.Touch && e._onDeviceConnected(i, n) : e._addPointerDevice(i, n, t.clientX, t.clientY);
  19713. var o = e._inputs[i][n];
  19714. if (o) {
  19715. var a = o[Pi.Horizontal]
  19716. , s = o[Pi.Vertical];
  19717. if (i === Ci.Mouse) {
  19718. if (-1 === e._mouseId && (void 0 === t.pointerId ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = t.pointerId),
  19719. !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
  19720. try {
  19721. e._elementToAttachTo.setPointerCapture(e._mouseId)
  19722. } catch (e) {}
  19723. } else if (t.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
  19724. try {
  19725. e._elementToAttachTo.setPointerCapture(t.pointerId)
  19726. } catch (e) {}
  19727. o[Pi.Horizontal] = t.clientX,
  19728. o[Pi.Vertical] = t.clientY,
  19729. o[t.button + 2] = 1;
  19730. var l = t;
  19731. l.inputIndex = t.button + 2,
  19732. e._onInputChanged(i, n, l),
  19733. a === t.clientX && s === t.clientY || (l.inputIndex = Pi.Move,
  19734. e._onInputChanged(i, n, l))
  19735. }
  19736. }
  19737. ,
  19738. this._pointerUpEvent = function(t) {
  19739. var i, n, r, o, a, s = e._getPointerType(t), l = s === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
  19740. if (s === Ci.Touch) {
  19741. if (-1 === l)
  19742. return;
  19743. e._activeTouchIds[l] = -1
  19744. }
  19745. var c = null === (i = e._inputs[s]) || void 0 === i ? void 0 : i[l];
  19746. if (c && 0 !== c[t.button + 2]) {
  19747. var u = c[Pi.Horizontal]
  19748. , h = c[Pi.Vertical];
  19749. c[Pi.Horizontal] = t.clientX,
  19750. c[Pi.Vertical] = t.clientY,
  19751. c[t.button + 2] = 0;
  19752. var d = t;
  19753. u === t.clientX && h === t.clientY || (d.inputIndex = Pi.Move,
  19754. e._onInputChanged(s, l, d)),
  19755. d.inputIndex = t.button + 2,
  19756. s === Ci.Mouse && e._mouseId >= 0 && (null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, e._mouseId)) ? e._elementToAttachTo.releasePointerCapture(e._mouseId) : t.pointerId && (null === (a = (o = e._elementToAttachTo).hasPointerCapture) || void 0 === a ? void 0 : a.call(o, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId),
  19757. e._onInputChanged(s, l, d),
  19758. s === Ci.Touch && e._onDeviceDisconnected(s, l)
  19759. }
  19760. }
  19761. ,
  19762. this._pointerCancelEvent = function(t) {
  19763. var i, n, r, o;
  19764. if ("mouse" === t.pointerType) {
  19765. var a = e._inputs[Ci.Mouse][0];
  19766. e._mouseId >= 0 && (null === (n = (i = e._elementToAttachTo).hasPointerCapture) || void 0 === n ? void 0 : n.call(i, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
  19767. for (var s = Pi.LeftClick; s <= Pi.BrowserForward; s++)
  19768. if (1 === a[s]) {
  19769. a[s] = 0;
  19770. var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
  19771. e._onInputChanged(Ci.Mouse, 0, l)
  19772. }
  19773. } else {
  19774. var c = e._activeTouchIds.indexOf(t.pointerId);
  19775. (null === (o = (r = e._elementToAttachTo).hasPointerCapture) || void 0 === o ? void 0 : o.call(r, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId),
  19776. e._inputs[Ci.Touch][c][Pi.LeftClick] = 0,
  19777. l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
  19778. e._onInputChanged(Ci.Touch, c, l),
  19779. e._activeTouchIds[c] = -1,
  19780. e._onDeviceDisconnected(Ci.Touch, c)
  19781. }
  19782. }
  19783. ,
  19784. this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : void 0 !== document.onmousewheel ? "mousewheel" : "DOMMouseScroll";
  19785. var i = !1
  19786. , n = function() {};
  19787. try {
  19788. var r = {
  19789. passive: {
  19790. get: function() {
  19791. i = !0
  19792. }
  19793. }
  19794. };
  19795. this._elementToAttachTo.addEventListener("test", n, r),
  19796. this._elementToAttachTo.removeEventListener("test", n, r)
  19797. } catch (e) {}
  19798. this._pointerBlurEvent = function() {
  19799. var t, i, n, r, o;
  19800. if (e.isDeviceAvailable(Ci.Mouse)) {
  19801. var a = e._inputs[Ci.Mouse][0];
  19802. e._mouseId >= 0 && (null === (i = (t = e._elementToAttachTo).hasPointerCapture) || void 0 === i ? void 0 : i.call(t, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
  19803. for (var s = Pi.LeftClick; s <= Pi.BrowserForward; s++)
  19804. if (1 === a[s]) {
  19805. a[s] = 0;
  19806. var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
  19807. e._onInputChanged(Ci.Mouse, 0, l)
  19808. }
  19809. }
  19810. if (e.isDeviceAvailable(Ci.Touch)) {
  19811. a = e._inputs[Ci.Touch];
  19812. for (var c = 0; c < e._activeTouchIds.length; c++) {
  19813. var u = e._activeTouchIds[c];
  19814. (null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, u)) && e._elementToAttachTo.releasePointerCapture(u),
  19815. -1 !== u && 1 === (null === (o = a[c]) || void 0 === o ? void 0 : o[Pi.LeftClick]) && (a[c][Pi.LeftClick] = 0,
  19816. l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
  19817. e._onInputChanged(Ci.Touch, c, l),
  19818. e._activeTouchIds[c] = -1,
  19819. e._onDeviceDisconnected(Ci.Touch, c))
  19820. }
  19821. }
  19822. }
  19823. ,
  19824. this._pointerWheelEvent = function(t) {
  19825. var i = Ci.Mouse;
  19826. e._inputs[i] || (e._inputs[i] = []),
  19827. e._inputs[i][0] || (e._pointerActive = !0,
  19828. e._registerDevice(i, 0, nn));
  19829. var n = e._inputs[i][0];
  19830. if (n) {
  19831. n[Pi.MouseWheelX] = t.deltaX || 0,
  19832. n[Pi.MouseWheelY] = t.deltaY || t.wheelDelta || 0,
  19833. n[Pi.MouseWheelZ] = t.deltaZ || 0;
  19834. var r = t;
  19835. 0 !== n[Pi.MouseWheelX] && (r.inputIndex = Pi.MouseWheelX,
  19836. e._onInputChanged(i, 0, r)),
  19837. 0 !== n[Pi.MouseWheelY] && (r.inputIndex = Pi.MouseWheelY,
  19838. e._onInputChanged(i, 0, r)),
  19839. 0 !== n[Pi.MouseWheelZ] && (r.inputIndex = Pi.MouseWheelZ,
  19840. e._onInputChanged(i, 0, r))
  19841. }
  19842. }
  19843. ,
  19844. this._elementToAttachTo.addEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
  19845. this._elementToAttachTo.addEventListener(this._eventPrefix + "down", this._pointerDownEvent),
  19846. this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent),
  19847. this._elementToAttachTo.addEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent),
  19848. this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent),
  19849. this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, !!i && {
  19850. passive: !1
  19851. }),
  19852. this._pointerInputClearObserver = this._engine.onEndFrameObservable.add((function() {
  19853. if (e.isDeviceAvailable(Ci.Mouse)) {
  19854. var t = e._inputs[Ci.Mouse][0];
  19855. t[Pi.MouseWheelX] = 0,
  19856. t[Pi.MouseWheelY] = 0,
  19857. t[Pi.MouseWheelZ] = 0
  19858. }
  19859. }
  19860. ))
  19861. }
  19862. ,
  19863. e.prototype._handleGamepadActions = function() {
  19864. var e = this;
  19865. this._gamepadConnectedEvent = function(t) {
  19866. e._addGamePad(t.gamepad)
  19867. }
  19868. ,
  19869. this._gamepadDisconnectedEvent = function(t) {
  19870. if (e._gamepads) {
  19871. var i = e._getGamepadDeviceType(t.gamepad.id)
  19872. , n = t.gamepad.index;
  19873. e._unregisterDevice(i, n),
  19874. delete e._gamepads[n]
  19875. }
  19876. }
  19877. ,
  19878. window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
  19879. window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
  19880. }
  19881. ,
  19882. e.prototype._updateDevice = function(e, t, i) {
  19883. var n = navigator.getGamepads()[t];
  19884. if (n && e === this._gamepads[t]) {
  19885. var r = this._inputs[e][t];
  19886. i >= n.buttons.length ? r[i] = n.axes[i - n.buttons.length].valueOf() : r[i] = n.buttons[i].value
  19887. }
  19888. }
  19889. ,
  19890. e.prototype._getGamepadDeviceType = function(e) {
  19891. return -1 !== e.indexOf("054c") ? -1 !== e.indexOf("0ce6") ? Ci.DualSense : Ci.DualShock : -1 !== e.indexOf("Xbox One") || -1 !== e.search("Xbox 360") || -1 !== e.search("xinput") ? Ci.Xbox : -1 !== e.indexOf("057e") ? Ci.Switch : Ci.Generic
  19892. }
  19893. ,
  19894. e.prototype._getPointerType = function(e) {
  19895. var t = Ci.Mouse;
  19896. return ("touch" === e.pointerType || "pen" === e.pointerType || e.touches) && (t = Ci.Touch),
  19897. t
  19898. }
  19899. ,
  19900. e
  19901. }(), on = function() {
  19902. function e(e, t, i) {
  19903. void 0 === i && (i = 0),
  19904. this.deviceType = t,
  19905. this.deviceSlot = i,
  19906. this.onInputChangedObservable = new h,
  19907. this._deviceInputSystem = e
  19908. }
  19909. return e.prototype.getInput = function(e) {
  19910. return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, e)
  19911. }
  19912. ,
  19913. e
  19914. }(), an = function() {
  19915. function e(e) {
  19916. var t = this;
  19917. this._registeredManagers = new Array,
  19918. this._refCount = 0,
  19919. this.registerManager = function(e) {
  19920. for (var i = 0; i < t._devices.length; i++) {
  19921. var n = t._devices[i];
  19922. for (var r in n) {
  19923. var o = +r;
  19924. e._addDevice(new on(t._deviceInputSystem,i,o))
  19925. }
  19926. }
  19927. t._registeredManagers.push(e)
  19928. }
  19929. ,
  19930. this.unregisterManager = function(e) {
  19931. var i = t._registeredManagers.indexOf(e);
  19932. i > -1 && t._registeredManagers.splice(i, 1)
  19933. }
  19934. ;
  19935. var i = Object.keys(Ci).length / 2;
  19936. this._devices = new Array(i);
  19937. var n = function(e, i) {
  19938. t._devices[e] || (t._devices[e] = new Array),
  19939. t._devices[e][i] || (t._devices[e][i] = i);
  19940. for (var n = 0, r = t._registeredManagers; n < r.length; n++) {
  19941. var o = r[n]
  19942. , a = new on(t._deviceInputSystem,e,i);
  19943. o._addDevice(a)
  19944. }
  19945. }
  19946. , r = function(e, i) {
  19947. var n;
  19948. (null === (n = t._devices[e]) || void 0 === n ? void 0 : n[i]) && delete t._devices[e][i];
  19949. for (var r = 0, o = t._registeredManagers; r < o.length; r++)
  19950. o[r]._removeDevice(e, i)
  19951. }
  19952. , o = function(e, i, n) {
  19953. if (n)
  19954. for (var r = 0, o = t._registeredManagers; r < o.length; r++)
  19955. o[r]._onInputChanged(e, i, n)
  19956. };
  19957. "undefined" != typeof _native ? this._deviceInputSystem = new tn(n,r,o) : this._deviceInputSystem = new rn(e,n,r,o)
  19958. }
  19959. return e.prototype.dispose = function() {
  19960. this._deviceInputSystem.dispose()
  19961. }
  19962. ,
  19963. e
  19964. }(), sn = function() {
  19965. function e(e) {
  19966. var t = this
  19967. , i = Object.keys(Ci).length / 2;
  19968. this._devices = new Array(i),
  19969. this._firstDevice = new Array(i),
  19970. this._engine = e,
  19971. this._engine._deviceSourceManager || (this._engine._deviceSourceManager = new an(e)),
  19972. this._engine._deviceSourceManager._refCount++,
  19973. this.onDeviceConnectedObservable = new h((function(e) {
  19974. t.getDevices().forEach((function(i) {
  19975. t.onDeviceConnectedObservable.notifyObserver(e, i)
  19976. }
  19977. ))
  19978. }
  19979. )),
  19980. this.onDeviceDisconnectedObservable = new h,
  19981. this._engine._deviceSourceManager.registerManager(this),
  19982. this._onDisposeObserver = e.onDisposeObservable.add((function() {
  19983. t.dispose()
  19984. }
  19985. ))
  19986. }
  19987. return e.prototype.getDeviceSource = function(e, t) {
  19988. if (void 0 === t) {
  19989. if (void 0 === this._firstDevice[e])
  19990. return null;
  19991. t = this._firstDevice[e]
  19992. }
  19993. return this._devices[e] && void 0 !== this._devices[e][t] ? this._devices[e][t] : null
  19994. }
  19995. ,
  19996. e.prototype.getDeviceSources = function(e) {
  19997. return this._devices[e].filter((function(e) {
  19998. return !!e
  19999. }
  20000. ))
  20001. }
  20002. ,
  20003. e.prototype.getDevices = function() {
  20004. for (var e = new Array, t = 0, i = this._devices; t < i.length; t++) {
  20005. var n = i[t];
  20006. e.push.apply(e, n)
  20007. }
  20008. return e
  20009. }
  20010. ,
  20011. e.prototype.dispose = function() {
  20012. this.onDeviceConnectedObservable.clear(),
  20013. this.onDeviceDisconnectedObservable.clear(),
  20014. this._engine._deviceSourceManager && (this._engine._deviceSourceManager.unregisterManager(this),
  20015. --this._engine._deviceSourceManager._refCount < 1 && (this._engine._deviceSourceManager.dispose(),
  20016. delete this._engine._deviceSourceManager)),
  20017. this._engine.onDisposeObservable.remove(this._onDisposeObserver)
  20018. }
  20019. ,
  20020. e.prototype._addDevice = function(e) {
  20021. this._devices[e.deviceType] || (this._devices[e.deviceType] = new Array),
  20022. this._devices[e.deviceType][e.deviceSlot] || (this._devices[e.deviceType][e.deviceSlot] = e,
  20023. this._updateFirstDevices(e.deviceType)),
  20024. this.onDeviceConnectedObservable.notifyObservers(e)
  20025. }
  20026. ,
  20027. e.prototype._removeDevice = function(e, t) {
  20028. var i, n, r = null === (i = this._devices[e]) || void 0 === i ? void 0 : i[t];
  20029. this.onDeviceDisconnectedObservable.notifyObservers(r),
  20030. (null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) && delete this._devices[e][t],
  20031. this._updateFirstDevices(e)
  20032. }
  20033. ,
  20034. e.prototype._onInputChanged = function(e, t, i) {
  20035. var n, r;
  20036. null === (r = null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) || void 0 === r || r.onInputChangedObservable.notifyObservers(i)
  20037. }
  20038. ,
  20039. e.prototype._updateFirstDevices = function(e) {
  20040. switch (e) {
  20041. case Ci.Keyboard:
  20042. case Ci.Mouse:
  20043. this._firstDevice[e] = 0;
  20044. break;
  20045. case Ci.Touch:
  20046. case Ci.DualSense:
  20047. case Ci.DualShock:
  20048. case Ci.Xbox:
  20049. case Ci.Switch:
  20050. case Ci.Generic:
  20051. delete this._firstDevice[e];
  20052. var t = this._devices[e];
  20053. if (t)
  20054. for (var i = 0; i < t.length; i++)
  20055. if (t[i]) {
  20056. this._firstDevice[e] = i;
  20057. break
  20058. }
  20059. }
  20060. }
  20061. ,
  20062. e
  20063. }(), ln = function() {
  20064. function e() {
  20065. this._singleClick = !1,
  20066. this._doubleClick = !1,
  20067. this._hasSwiped = !1,
  20068. this._ignore = !1
  20069. }
  20070. return Object.defineProperty(e.prototype, "singleClick", {
  20071. get: function() {
  20072. return this._singleClick
  20073. },
  20074. set: function(e) {
  20075. this._singleClick = e
  20076. },
  20077. enumerable: !1,
  20078. configurable: !0
  20079. }),
  20080. Object.defineProperty(e.prototype, "doubleClick", {
  20081. get: function() {
  20082. return this._doubleClick
  20083. },
  20084. set: function(e) {
  20085. this._doubleClick = e
  20086. },
  20087. enumerable: !1,
  20088. configurable: !0
  20089. }),
  20090. Object.defineProperty(e.prototype, "hasSwiped", {
  20091. get: function() {
  20092. return this._hasSwiped
  20093. },
  20094. set: function(e) {
  20095. this._hasSwiped = e
  20096. },
  20097. enumerable: !1,
  20098. configurable: !0
  20099. }),
  20100. Object.defineProperty(e.prototype, "ignore", {
  20101. get: function() {
  20102. return this._ignore
  20103. },
  20104. set: function(e) {
  20105. this._ignore = e
  20106. },
  20107. enumerable: !1,
  20108. configurable: !0
  20109. }),
  20110. e
  20111. }(), cn = function() {
  20112. function e(e) {
  20113. this._alreadyAttached = !1,
  20114. this._meshPickProceed = !1,
  20115. this._currentPickResult = null,
  20116. this._previousPickResult = null,
  20117. this._totalPointersPressed = 0,
  20118. this._doubleClickOccured = !1,
  20119. this._pointerX = 0,
  20120. this._pointerY = 0,
  20121. this._startingPointerPosition = new A(0,0),
  20122. this._previousStartingPointerPosition = new A(0,0),
  20123. this._startingPointerTime = 0,
  20124. this._previousStartingPointerTime = 0,
  20125. this._pointerCaptures = {},
  20126. this._meshUnderPointerId = {},
  20127. this._deviceSourceManager = null,
  20128. this._scene = e || E.LastCreatedScene,
  20129. this._scene
  20130. }
  20131. return Object.defineProperty(e.prototype, "meshUnderPointer", {
  20132. get: function() {
  20133. return this._pointerOverMesh
  20134. },
  20135. enumerable: !1,
  20136. configurable: !0
  20137. }),
  20138. e.prototype.getMeshUnderPointerByPointerId = function(e) {
  20139. return this._meshUnderPointerId[e] || null
  20140. }
  20141. ,
  20142. Object.defineProperty(e.prototype, "unTranslatedPointer", {
  20143. get: function() {
  20144. return new A(this._unTranslatedPointerX,this._unTranslatedPointerY)
  20145. },
  20146. enumerable: !1,
  20147. configurable: !0
  20148. }),
  20149. Object.defineProperty(e.prototype, "pointerX", {
  20150. get: function() {
  20151. return this._pointerX
  20152. },
  20153. set: function(e) {
  20154. this._pointerX = e
  20155. },
  20156. enumerable: !1,
  20157. configurable: !0
  20158. }),
  20159. Object.defineProperty(e.prototype, "pointerY", {
  20160. get: function() {
  20161. return this._pointerY
  20162. },
  20163. set: function(e) {
  20164. this._pointerY = e
  20165. },
  20166. enumerable: !1,
  20167. configurable: !0
  20168. }),
  20169. e.prototype._updatePointerPosition = function(e) {
  20170. var t = this._scene.getEngine().getInputElementClientRect();
  20171. t && (this._pointerX = e.clientX - t.left,
  20172. this._pointerY = e.clientY - t.top,
  20173. this._unTranslatedPointerX = this._pointerX,
  20174. this._unTranslatedPointerY = this._pointerY)
  20175. }
  20176. ,
  20177. e.prototype._processPointerMove = function(e, t) {
  20178. var i = this._scene
  20179. , n = i.getEngine()
  20180. , r = n.getInputElement();
  20181. r && (r.tabIndex = n.canvasTabIndex,
  20182. i.doNotHandleCursors || (r.style.cursor = i.defaultCursor));
  20183. var o = !!(e && e.hit && e.pickedMesh);
  20184. o ? (i.setPointerOverMesh(e.pickedMesh, t.pointerId, e),
  20185. this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && !i.doNotHandleCursors && r && (this._pointerOverMesh.actionManager.hoverCursor ? r.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : r.style.cursor = i.hoverCursor)) : i.setPointerOverMesh(null, t.pointerId, e);
  20186. for (var a = 0, s = i._pointerMoveStage; a < s.length; a++)
  20187. e = s[a].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, o, r);
  20188. if (e) {
  20189. var l = "wheel" === t.type || "mousewheel" === t.type || "DOMMouseScroll" === t.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE;
  20190. if (i.onPointerMove && i.onPointerMove(t, e, l),
  20191. i.onPointerObservable.hasObservers()) {
  20192. var c = new Ki(l,t,e);
  20193. this._setRayOnPointerInfo(c),
  20194. i.onPointerObservable.notifyObservers(c, l)
  20195. }
  20196. }
  20197. }
  20198. ,
  20199. e.prototype._setRayOnPointerInfo = function(e) {
  20200. var t = this._scene;
  20201. e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = t.createPickingRay(e.event.offsetX, e.event.offsetY, P.Identity(), t.activeCamera)))
  20202. }
  20203. ,
  20204. e.prototype._checkPrePointerObservable = function(e, t, i) {
  20205. var n = this._scene
  20206. , r = new Yi(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);
  20207. return e && (r.ray = e.ray,
  20208. e.originMesh && (r.nearInteractionPickingInfo = e)),
  20209. n.onPrePointerObservable.notifyObservers(r, i),
  20210. !!r.skipOnPointerObservable
  20211. }
  20212. ,
  20213. e.prototype.simulatePointerMove = function(e, t) {
  20214. var i = new PointerEvent("pointermove",t);
  20215. i.inputIndex = Pi.Move,
  20216. this._checkPrePointerObservable(e, i, Xi.POINTERMOVE) || this._processPointerMove(e, i)
  20217. }
  20218. ,
  20219. e.prototype.simulatePointerDown = function(e, t) {
  20220. var i = new PointerEvent("pointerdown",t);
  20221. i.inputIndex = i.button + 2,
  20222. this._checkPrePointerObservable(e, i, Xi.POINTERDOWN) || this._processPointerDown(e, i)
  20223. }
  20224. ,
  20225. e.prototype._processPointerDown = function(t, i) {
  20226. var n = this
  20227. , r = this._scene;
  20228. if (t && t.hit && t.pickedMesh) {
  20229. this._pickedDownMesh = t.pickedMesh;
  20230. var o = t.pickedMesh._getActionManagerForTrigger();
  20231. if (o) {
  20232. if (o.hasPickTriggers)
  20233. switch (o.processTrigger(a.ACTION_OnPickDownTrigger, w.CreateNew(t.pickedMesh, i)),
  20234. i.button) {
  20235. case 0:
  20236. o.processTrigger(a.ACTION_OnLeftPickTrigger, w.CreateNew(t.pickedMesh, i));
  20237. break;
  20238. case 1:
  20239. o.processTrigger(a.ACTION_OnCenterPickTrigger, w.CreateNew(t.pickedMesh, i));
  20240. break;
  20241. case 2:
  20242. o.processTrigger(a.ACTION_OnRightPickTrigger, w.CreateNew(t.pickedMesh, i))
  20243. }
  20244. o.hasSpecificTrigger(a.ACTION_OnLongPressTrigger) && window.setTimeout((function() {
  20245. var t = r.pick(n._unTranslatedPointerX, n._unTranslatedPointerY, (function(e) {
  20246. return e.isPickable && e.isVisible && e.isReady() && e.actionManager && e.actionManager.hasSpecificTrigger(a.ACTION_OnLongPressTrigger) && e === n._pickedDownMesh
  20247. }
  20248. ), !1, r.cameraToUseForPointers);
  20249. t && t.hit && t.pickedMesh && o && 0 !== n._totalPointersPressed && Date.now() - n._startingPointerTime > e.LongPressDelay && !n._isPointerSwiping() && (n._startingPointerTime = 0,
  20250. o.processTrigger(a.ACTION_OnLongPressTrigger, w.CreateNew(t.pickedMesh, i)))
  20251. }
  20252. ), e.LongPressDelay)
  20253. }
  20254. } else
  20255. for (var s = 0, l = r._pointerDownStage; s < l.length; s++)
  20256. t = l[s].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, i);
  20257. if (t) {
  20258. var c = Xi.POINTERDOWN;
  20259. if (r.onPointerDown && r.onPointerDown(i, t, c),
  20260. r.onPointerObservable.hasObservers()) {
  20261. var u = new Ki(c,i,t);
  20262. this._setRayOnPointerInfo(u),
  20263. r.onPointerObservable.notifyObservers(u, c)
  20264. }
  20265. }
  20266. }
  20267. ,
  20268. e.prototype._isPointerSwiping = function() {
  20269. return Math.abs(this._startingPointerPosition.x - this._pointerX) > e.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > e.DragMovementThreshold
  20270. }
  20271. ,
  20272. e.prototype.simulatePointerUp = function(e, t, i) {
  20273. var n = new PointerEvent("pointerup",t);
  20274. n.inputIndex = Pi.Move;
  20275. var r = new ln;
  20276. i ? r.doubleClick = !0 : r.singleClick = !0,
  20277. this._checkPrePointerObservable(e, n, Xi.POINTERUP) || this._processPointerUp(e, n, r)
  20278. }
  20279. ,
  20280. e.prototype._processPointerUp = function(e, t, i) {
  20281. var n = this._scene;
  20282. if (e && e && e.pickedMesh) {
  20283. if (this._pickedUpMesh = e.pickedMesh,
  20284. this._pickedDownMesh === this._pickedUpMesh && (n.onPointerPick && n.onPointerPick(t, e),
  20285. i.singleClick && !i.ignore && n.onPointerObservable.hasObservers())) {
  20286. var r = Xi.POINTERPICK
  20287. , o = new Ki(r,t,e);
  20288. this._setRayOnPointerInfo(o),
  20289. n.onPointerObservable.notifyObservers(o, r)
  20290. }
  20291. var s = e.pickedMesh._getActionManagerForTrigger();
  20292. if (s && !i.ignore) {
  20293. s.processTrigger(a.ACTION_OnPickUpTrigger, w.CreateNew(e.pickedMesh, t, e)),
  20294. !i.hasSwiped && i.singleClick && s.processTrigger(a.ACTION_OnPickTrigger, w.CreateNew(e.pickedMesh, t, e));
  20295. var l = e.pickedMesh._getActionManagerForTrigger(a.ACTION_OnDoublePickTrigger);
  20296. i.doubleClick && l && l.processTrigger(a.ACTION_OnDoublePickTrigger, w.CreateNew(e.pickedMesh, t, e))
  20297. }
  20298. } else if (!i.ignore)
  20299. for (var c = 0, u = n._pointerUpStage; c < u.length; c++)
  20300. e = u[c].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t);
  20301. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  20302. var h = this._pickedDownMesh._getActionManagerForTrigger(a.ACTION_OnPickOutTrigger);
  20303. h && h.processTrigger(a.ACTION_OnPickOutTrigger, w.CreateNew(this._pickedDownMesh, t))
  20304. }
  20305. var d = 0;
  20306. n.onPointerObservable.hasObservers() && (i.ignore || i.hasSwiped || (i.singleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERTAP) ? d = Xi.POINTERTAP : i.doubleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && (d = Xi.POINTERDOUBLETAP),
  20307. !d) || (o = new Ki(d,t,e),
  20308. this._setRayOnPointerInfo(o),
  20309. n.onPointerObservable.notifyObservers(o, d)),
  20310. i.ignore || (d = Xi.POINTERUP,
  20311. o = new Ki(d,t,e),
  20312. this._setRayOnPointerInfo(o),
  20313. n.onPointerObservable.notifyObservers(o, d))),
  20314. n.onPointerUp && !i.ignore && n.onPointerUp(t, e, d)
  20315. }
  20316. ,
  20317. e.prototype.isPointerCaptured = function(e) {
  20318. return void 0 === e && (e = 0),
  20319. this._pointerCaptures[e]
  20320. }
  20321. ,
  20322. e.prototype.attachControl = function(t, i, n, r) {
  20323. var o = this;
  20324. void 0 === t && (t = !0),
  20325. void 0 === i && (i = !0),
  20326. void 0 === n && (n = !0),
  20327. void 0 === r && (r = null);
  20328. var l = this._scene
  20329. , c = l.getEngine();
  20330. r || (r = c.getInputElement()),
  20331. this._alreadyAttached && this.detachControl(),
  20332. r && (this._alreadyAttachedTo = r),
  20333. this._deviceSourceManager = new sn(c),
  20334. this._initActionManager = function(e) {
  20335. if (!o._meshPickProceed) {
  20336. var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, l.cameraToUseForPointers);
  20337. o._currentPickResult = t,
  20338. t && (e = t.hit && t.pickedMesh ? t.pickedMesh._getActionManagerForTrigger() : null),
  20339. o._meshPickProceed = !0
  20340. }
  20341. return e
  20342. }
  20343. ,
  20344. this._delayedSimpleClick = function(t, i, n) {
  20345. (Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay && !o._doubleClickOccured || t !== o._previousButtonPressed) && (o._doubleClickOccured = !1,
  20346. i.singleClick = !0,
  20347. i.ignore = !1,
  20348. n(i, o._currentPickResult))
  20349. }
  20350. ,
  20351. this._initClickEvent = function(t, i, n, r) {
  20352. var l = new ln;
  20353. o._currentPickResult = null;
  20354. var c = null
  20355. , u = t.hasSpecificMask(Xi.POINTERPICK) || i.hasSpecificMask(Xi.POINTERPICK) || t.hasSpecificMask(Xi.POINTERTAP) || i.hasSpecificMask(Xi.POINTERTAP) || t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
  20356. !u && s && (c = o._initActionManager(c, l)) && (u = c.hasPickTriggers);
  20357. var h = !1;
  20358. if (u) {
  20359. var d = n.button;
  20360. if (l.hasSwiped = o._isPointerSwiping(),
  20361. !l.hasSwiped) {
  20362. var p = !e.ExclusiveDoubleClickMode;
  20363. p || (p = !t.hasSpecificMask(Xi.POINTERDOUBLETAP) && !i.hasSpecificMask(Xi.POINTERDOUBLETAP)) && !s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (p = !c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
  20364. p ? (Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay || d !== o._previousButtonPressed) && (l.singleClick = !0,
  20365. r(l, o._currentPickResult),
  20366. h = !0) : (o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
  20367. o._delayedSimpleClickTimeout = window.setTimeout(o._delayedSimpleClick.bind(o, d, l, r), e.DoubleClickDelay));
  20368. var f = t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
  20369. !f && s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (f = c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
  20370. f && (d === o._previousButtonPressed && Date.now() - o._previousStartingPointerTime < e.DoubleClickDelay && !o._doubleClickOccured ? (l.hasSwiped || o._isPointerSwiping() ? (o._doubleClickOccured = !1,
  20371. o._previousStartingPointerTime = o._startingPointerTime,
  20372. o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
  20373. o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
  20374. o._previousButtonPressed = d,
  20375. e.ExclusiveDoubleClickMode ? (o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
  20376. o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
  20377. r(l, o._previousPickResult)) : r(l, o._currentPickResult)) : (o._previousStartingPointerTime = 0,
  20378. o._doubleClickOccured = !0,
  20379. l.doubleClick = !0,
  20380. l.ignore = !1,
  20381. e.ExclusiveDoubleClickMode && o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
  20382. o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
  20383. r(l, o._currentPickResult)),
  20384. h = !0) : (o._doubleClickOccured = !1,
  20385. o._previousStartingPointerTime = o._startingPointerTime,
  20386. o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
  20387. o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
  20388. o._previousButtonPressed = d))
  20389. }
  20390. }
  20391. h || r(l, o._currentPickResult)
  20392. }
  20393. ,
  20394. this._onPointerMove = function(e) {
  20395. if (void 0 === e.pointerId && (e.pointerId = 0),
  20396. o._updatePointerPosition(e),
  20397. !o._checkPrePointerObservable(null, e, "wheel" === e.type || "mousewheel" === e.type || "DOMMouseScroll" === e.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE) && (l.cameraToUseForPointers || l.activeCamera))
  20398. if (l.skipPointerMovePicking)
  20399. o._processPointerMove(new Ui, e);
  20400. else {
  20401. l.pointerMovePredicate || (l.pointerMovePredicate = function(e) {
  20402. return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (e.enablePointerMoveEvents || l.constantlyUpdateMeshUnderPointer || null !== e._getActionManagerForTrigger()) && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
  20403. }
  20404. );
  20405. var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerMovePredicate, !1, l.cameraToUseForPointers, l.pointerMoveTrianglePredicate);
  20406. o._processPointerMove(t, e)
  20407. }
  20408. }
  20409. ,
  20410. this._onPointerDown = function(e) {
  20411. if (o._totalPointersPressed++,
  20412. o._pickedDownMesh = null,
  20413. o._meshPickProceed = !1,
  20414. void 0 === e.pointerId && (e.pointerId = 0),
  20415. o._updatePointerPosition(e),
  20416. l.preventDefaultOnPointerDown && r && (e.preventDefault(),
  20417. r.focus()),
  20418. o._startingPointerPosition.x = o._pointerX,
  20419. o._startingPointerPosition.y = o._pointerY,
  20420. o._startingPointerTime = Date.now(),
  20421. !o._checkPrePointerObservable(null, e, Xi.POINTERDOWN) && (l.cameraToUseForPointers || l.activeCamera)) {
  20422. o._pointerCaptures[e.pointerId] = !0,
  20423. l.pointerDownPredicate || (l.pointerDownPredicate = function(e) {
  20424. return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
  20425. }
  20426. ),
  20427. o._pickedDownMesh = null;
  20428. var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, l.cameraToUseForPointers);
  20429. o._processPointerDown(t, e)
  20430. }
  20431. }
  20432. ,
  20433. this._onPointerUp = function(e) {
  20434. 0 !== o._totalPointersPressed && (o._totalPointersPressed--,
  20435. o._pickedUpMesh = null,
  20436. o._meshPickProceed = !1,
  20437. void 0 === e.pointerId && (e.pointerId = 0),
  20438. o._updatePointerPosition(e),
  20439. l.preventDefaultOnPointerUp && r && (e.preventDefault(),
  20440. r.focus()),
  20441. o._initClickEvent(l.onPrePointerObservable, l.onPointerObservable, e, (function(t, i) {
  20442. if (l.onPrePointerObservable.hasObservers() && !t.ignore) {
  20443. if (!t.hasSwiped) {
  20444. if (t.singleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERTAP) && o._checkPrePointerObservable(null, e, Xi.POINTERTAP))
  20445. return;
  20446. if (t.doubleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, e, Xi.POINTERDOUBLETAP))
  20447. return
  20448. }
  20449. if (o._checkPrePointerObservable(null, e, Xi.POINTERUP))
  20450. return
  20451. }
  20452. !o._pointerCaptures[e.pointerId] && e.buttons > 0 || (o._pointerCaptures[e.pointerId] = !1,
  20453. (l.cameraToUseForPointers || l.activeCamera) && (l.pointerUpPredicate || (l.pointerUpPredicate = function(e) {
  20454. return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
  20455. }
  20456. ),
  20457. !o._meshPickProceed && (s && s.HasTriggers || l.onPointerObservable.hasObservers()) && o._initActionManager(null, t),
  20458. i || (i = o._currentPickResult),
  20459. o._processPointerUp(i, e, t),
  20460. o._previousPickResult = o._currentPickResult))
  20461. }
  20462. )))
  20463. }
  20464. ,
  20465. this._onKeyDown = function(e) {
  20466. var t = Qi.KEYDOWN;
  20467. if (l.onPreKeyboardObservable.hasObservers()) {
  20468. var i = new Zi(t,e);
  20469. if (l.onPreKeyboardObservable.notifyObservers(i, t),
  20470. i.skipOnKeyboardObservable)
  20471. return
  20472. }
  20473. l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
  20474. l.onKeyboardObservable.notifyObservers(i, t)),
  20475. l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyDownTrigger, w.CreateNewFromScene(l, e))
  20476. }
  20477. ,
  20478. this._onKeyUp = function(e) {
  20479. var t = Qi.KEYUP;
  20480. if (l.onPreKeyboardObservable.hasObservers()) {
  20481. var i = new Zi(t,e);
  20482. if (l.onPreKeyboardObservable.notifyObservers(i, t),
  20483. i.skipOnKeyboardObservable)
  20484. return
  20485. }
  20486. l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
  20487. l.onKeyboardObservable.notifyObservers(i, t)),
  20488. l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyUpTrigger, w.CreateNewFromScene(l, e))
  20489. }
  20490. ,
  20491. this._deviceSourceManager.onDeviceConnectedObservable.add((function(e) {
  20492. e.deviceType === Ci.Mouse ? e.onInputChangedObservable.add((function(r) {
  20493. if (r.inputIndex === Pi.LeftClick || r.inputIndex === Pi.MiddleClick || r.inputIndex === Pi.RightClick) {
  20494. var a = r;
  20495. i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(a) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(a)
  20496. } else
  20497. n && (r.inputIndex === Pi.Move ? o._onPointerMove(r) : r.inputIndex !== Pi.MouseWheelX && r.inputIndex !== Pi.MouseWheelY && r.inputIndex !== Pi.MouseWheelZ || o._onPointerMove(r))
  20498. }
  20499. )) : e.deviceType === Ci.Touch ? e.onInputChangedObservable.add((function(r) {
  20500. var a = r;
  20501. r.inputIndex === Pi.LeftClick && (i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(r) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(r)),
  20502. n && r.inputIndex === Pi.Move && o._onPointerMove(r)
  20503. }
  20504. )) : e.deviceType === Ci.Keyboard && e.onInputChangedObservable.add((function(e) {
  20505. var t = e;
  20506. "keydown" === t.type ? o._onKeyDown(t) : "keyup" === t.type && o._onKeyUp(t)
  20507. }
  20508. ))
  20509. }
  20510. )),
  20511. this._alreadyAttached = !0
  20512. }
  20513. ,
  20514. e.prototype.detachControl = function() {
  20515. this._alreadyAttached && (this._deviceSourceManager.dispose(),
  20516. this._deviceSourceManager = null,
  20517. this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor),
  20518. this._alreadyAttached = !1,
  20519. this._alreadyAttachedTo = null)
  20520. }
  20521. ,
  20522. e.prototype.setPointerOverMesh = function(e, t, i) {
  20523. if (void 0 === t && (t = 0),
  20524. this._meshUnderPointerId[t] !== e) {
  20525. var n, r = this._meshUnderPointerId[t];
  20526. r && (n = r._getActionManagerForTrigger(a.ACTION_OnPointerOutTrigger)) && n.processTrigger(a.ACTION_OnPointerOutTrigger, w.CreateNew(r, void 0, {
  20527. pointerId: t
  20528. })),
  20529. e ? (this._meshUnderPointerId[t] = e,
  20530. this._pointerOverMesh = e,
  20531. (n = e._getActionManagerForTrigger(a.ACTION_OnPointerOverTrigger)) && n.processTrigger(a.ACTION_OnPointerOverTrigger, w.CreateNew(e, void 0, {
  20532. pointerId: t,
  20533. pickResult: i
  20534. }))) : (delete this._meshUnderPointerId[t],
  20535. this._pointerOverMesh = null)
  20536. }
  20537. }
  20538. ,
  20539. e.prototype.getPointerOverMesh = function() {
  20540. return this._pointerOverMesh
  20541. }
  20542. ,
  20543. e.prototype._invalidateMesh = function(e) {
  20544. for (var t in this._pointerOverMesh === e && (this._pointerOverMesh = null),
  20545. this._pickedDownMesh === e && (this._pickedDownMesh = null),
  20546. this._pickedUpMesh === e && (this._pickedUpMesh = null),
  20547. this._meshUnderPointerId)
  20548. this._meshUnderPointerId[t] === e && delete this._meshUnderPointerId[t]
  20549. }
  20550. ,
  20551. e.DragMovementThreshold = 10,
  20552. e.LongPressDelay = 500,
  20553. e.DoubleClickDelay = 300,
  20554. e.ExclusiveDoubleClickMode = !1,
  20555. e
  20556. }(), un = function() {
  20557. function e() {
  20558. this._startMonitoringTime = 0,
  20559. this._min = 0,
  20560. this._max = 0,
  20561. this._average = 0,
  20562. this._lastSecAverage = 0,
  20563. this._current = 0,
  20564. this._totalValueCount = 0,
  20565. this._totalAccumulated = 0,
  20566. this._lastSecAccumulated = 0,
  20567. this._lastSecTime = 0,
  20568. this._lastSecValueCount = 0
  20569. }
  20570. return Object.defineProperty(e.prototype, "min", {
  20571. get: function() {
  20572. return this._min
  20573. },
  20574. enumerable: !1,
  20575. configurable: !0
  20576. }),
  20577. Object.defineProperty(e.prototype, "max", {
  20578. get: function() {
  20579. return this._max
  20580. },
  20581. enumerable: !1,
  20582. configurable: !0
  20583. }),
  20584. Object.defineProperty(e.prototype, "average", {
  20585. get: function() {
  20586. return this._average
  20587. },
  20588. enumerable: !1,
  20589. configurable: !0
  20590. }),
  20591. Object.defineProperty(e.prototype, "lastSecAverage", {
  20592. get: function() {
  20593. return this._lastSecAverage
  20594. },
  20595. enumerable: !1,
  20596. configurable: !0
  20597. }),
  20598. Object.defineProperty(e.prototype, "current", {
  20599. get: function() {
  20600. return this._current
  20601. },
  20602. enumerable: !1,
  20603. configurable: !0
  20604. }),
  20605. Object.defineProperty(e.prototype, "total", {
  20606. get: function() {
  20607. return this._totalAccumulated
  20608. },
  20609. enumerable: !1,
  20610. configurable: !0
  20611. }),
  20612. Object.defineProperty(e.prototype, "count", {
  20613. get: function() {
  20614. return this._totalValueCount
  20615. },
  20616. enumerable: !1,
  20617. configurable: !0
  20618. }),
  20619. e.prototype.fetchNewFrame = function() {
  20620. this._totalValueCount++,
  20621. this._current = 0,
  20622. this._lastSecValueCount++
  20623. }
  20624. ,
  20625. e.prototype.addCount = function(t, i) {
  20626. e.Enabled && (this._current += t,
  20627. i && this._fetchResult())
  20628. }
  20629. ,
  20630. e.prototype.beginMonitoring = function() {
  20631. e.Enabled && (this._startMonitoringTime = ct.Now)
  20632. }
  20633. ,
  20634. e.prototype.endMonitoring = function(t) {
  20635. if (void 0 === t && (t = !0),
  20636. e.Enabled) {
  20637. t && this.fetchNewFrame();
  20638. var i = ct.Now;
  20639. this._current = i - this._startMonitoringTime,
  20640. t && this._fetchResult()
  20641. }
  20642. }
  20643. ,
  20644. e.prototype._fetchResult = function() {
  20645. this._totalAccumulated += this._current,
  20646. this._lastSecAccumulated += this._current,
  20647. this._min = Math.min(this._min, this._current),
  20648. this._max = Math.max(this._max, this._current),
  20649. this._average = this._totalAccumulated / this._totalValueCount;
  20650. var e = ct.Now;
  20651. e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
  20652. this._lastSecTime = e,
  20653. this._lastSecAccumulated = 0,
  20654. this._lastSecValueCount = 0)
  20655. }
  20656. ,
  20657. e.Enabled = !0,
  20658. e
  20659. }(), hn = function() {
  20660. function e(e, t, i, n) {
  20661. this.normal = new x(e,t,i),
  20662. this.d = n
  20663. }
  20664. return e.prototype.asArray = function() {
  20665. return [this.normal.x, this.normal.y, this.normal.z, this.d]
  20666. }
  20667. ,
  20668. e.prototype.clone = function() {
  20669. return new e(this.normal.x,this.normal.y,this.normal.z,this.d)
  20670. }
  20671. ,
  20672. e.prototype.getClassName = function() {
  20673. return "Plane"
  20674. }
  20675. ,
  20676. e.prototype.getHashCode = function() {
  20677. var e = this.normal.getHashCode();
  20678. return 397 * e ^ (0 | this.d)
  20679. }
  20680. ,
  20681. e.prototype.normalize = function() {
  20682. var e = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z)
  20683. , t = 0;
  20684. return 0 !== e && (t = 1 / e),
  20685. this.normal.x *= t,
  20686. this.normal.y *= t,
  20687. this.normal.z *= t,
  20688. this.d *= t,
  20689. this
  20690. }
  20691. ,
  20692. e.prototype.transform = function(t) {
  20693. var i = e._TmpMatrix;
  20694. t.invertToRef(i);
  20695. var n = i.m
  20696. , r = this.normal.x
  20697. , o = this.normal.y
  20698. , a = this.normal.z
  20699. , s = this.d;
  20700. return new e(r * n[0] + o * n[1] + a * n[2] + s * n[3],r * n[4] + o * n[5] + a * n[6] + s * n[7],r * n[8] + o * n[9] + a * n[10] + s * n[11],r * n[12] + o * n[13] + a * n[14] + s * n[15])
  20701. }
  20702. ,
  20703. e.prototype.dotCoordinate = function(e) {
  20704. return this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z + this.d
  20705. }
  20706. ,
  20707. e.prototype.copyFromPoints = function(e, t, i) {
  20708. var n, r = t.x - e.x, o = t.y - e.y, a = t.z - e.z, s = i.x - e.x, l = i.y - e.y, c = i.z - e.z, u = o * c - a * l, h = a * s - r * c, d = r * l - o * s, p = Math.sqrt(u * u + h * h + d * d);
  20709. return n = 0 !== p ? 1 / p : 0,
  20710. this.normal.x = u * n,
  20711. this.normal.y = h * n,
  20712. this.normal.z = d * n,
  20713. this.d = -(this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z),
  20714. this
  20715. }
  20716. ,
  20717. e.prototype.isFrontFacingTo = function(e, t) {
  20718. return x.Dot(this.normal, e) <= t
  20719. }
  20720. ,
  20721. e.prototype.signedDistanceTo = function(e) {
  20722. return x.Dot(e, this.normal) + this.d
  20723. }
  20724. ,
  20725. e.FromArray = function(t) {
  20726. return new e(t[0],t[1],t[2],t[3])
  20727. }
  20728. ,
  20729. e.FromPoints = function(t, i, n) {
  20730. var r = new e(0,0,0,0);
  20731. return r.copyFromPoints(t, i, n),
  20732. r
  20733. }
  20734. ,
  20735. e.FromPositionAndNormal = function(t, i) {
  20736. var n = new e(0,0,0,0);
  20737. return i.normalize(),
  20738. n.normal = i,
  20739. n.d = -(i.x * t.x + i.y * t.y + i.z * t.z),
  20740. n
  20741. }
  20742. ,
  20743. e.SignedDistanceToPlaneFromPositionAndNormal = function(e, t, i) {
  20744. var n = -(t.x * e.x + t.y * e.y + t.z * e.z);
  20745. return x.Dot(i, t) + n
  20746. }
  20747. ,
  20748. e._TmpMatrix = P.Identity(),
  20749. e
  20750. }(), dn = function() {
  20751. function e() {}
  20752. return e.GetPlanes = function(t) {
  20753. for (var i = [], n = 0; n < 6; n++)
  20754. i.push(new hn(0,0,0,0));
  20755. return e.GetPlanesToRef(t, i),
  20756. i
  20757. }
  20758. ,
  20759. e.GetNearPlaneToRef = function(e, t) {
  20760. var i = e.m;
  20761. t.normal.x = i[3] + i[2],
  20762. t.normal.y = i[7] + i[6],
  20763. t.normal.z = i[11] + i[10],
  20764. t.d = i[15] + i[14],
  20765. t.normalize()
  20766. }
  20767. ,
  20768. e.GetFarPlaneToRef = function(e, t) {
  20769. var i = e.m;
  20770. t.normal.x = i[3] - i[2],
  20771. t.normal.y = i[7] - i[6],
  20772. t.normal.z = i[11] - i[10],
  20773. t.d = i[15] - i[14],
  20774. t.normalize()
  20775. }
  20776. ,
  20777. e.GetLeftPlaneToRef = function(e, t) {
  20778. var i = e.m;
  20779. t.normal.x = i[3] + i[0],
  20780. t.normal.y = i[7] + i[4],
  20781. t.normal.z = i[11] + i[8],
  20782. t.d = i[15] + i[12],
  20783. t.normalize()
  20784. }
  20785. ,
  20786. e.GetRightPlaneToRef = function(e, t) {
  20787. var i = e.m;
  20788. t.normal.x = i[3] - i[0],
  20789. t.normal.y = i[7] - i[4],
  20790. t.normal.z = i[11] - i[8],
  20791. t.d = i[15] - i[12],
  20792. t.normalize()
  20793. }
  20794. ,
  20795. e.GetTopPlaneToRef = function(e, t) {
  20796. var i = e.m;
  20797. t.normal.x = i[3] - i[1],
  20798. t.normal.y = i[7] - i[5],
  20799. t.normal.z = i[11] - i[9],
  20800. t.d = i[15] - i[13],
  20801. t.normalize()
  20802. }
  20803. ,
  20804. e.GetBottomPlaneToRef = function(e, t) {
  20805. var i = e.m;
  20806. t.normal.x = i[3] + i[1],
  20807. t.normal.y = i[7] + i[5],
  20808. t.normal.z = i[11] + i[9],
  20809. t.d = i[15] + i[13],
  20810. t.normalize()
  20811. }
  20812. ,
  20813. e.GetPlanesToRef = function(t, i) {
  20814. e.GetNearPlaneToRef(t, i[0]),
  20815. e.GetFarPlaneToRef(t, i[1]),
  20816. e.GetLeftPlaneToRef(t, i[2]),
  20817. e.GetRightPlaneToRef(t, i[3]),
  20818. e.GetTopPlaneToRef(t, i[4]),
  20819. e.GetBottomPlaneToRef(t, i[5])
  20820. }
  20821. ,
  20822. e
  20823. }(), pn = function() {
  20824. function e() {}
  20825. return Object.defineProperty(e, "UniqueId", {
  20826. get: function() {
  20827. var e = this._UniqueIdCounter;
  20828. return this._UniqueIdCounter++,
  20829. e
  20830. },
  20831. enumerable: !1,
  20832. configurable: !0
  20833. }),
  20834. e._UniqueIdCounter = 1,
  20835. e
  20836. }(), fn = function() {
  20837. function e() {}
  20838. return e.CompareLightsPriority = function(e, t) {
  20839. return e.shadowEnabled !== t.shadowEnabled ? (t.shadowEnabled ? 1 : 0) - (e.shadowEnabled ? 1 : 0) : t.renderPriority - e.renderPriority
  20840. }
  20841. ,
  20842. e.FALLOFF_DEFAULT = 0,
  20843. e.FALLOFF_PHYSICAL = 1,
  20844. e.FALLOFF_GLTF = 2,
  20845. e.FALLOFF_STANDARD = 3,
  20846. e.LIGHTMAP_DEFAULT = 0,
  20847. e.LIGHTMAP_SPECULAR = 1,
  20848. e.LIGHTMAP_SHADOWSONLY = 2,
  20849. e.INTENSITYMODE_AUTOMATIC = 0,
  20850. e.INTENSITYMODE_LUMINOUSPOWER = 1,
  20851. e.INTENSITYMODE_LUMINOUSINTENSITY = 2,
  20852. e.INTENSITYMODE_ILLUMINANCE = 3,
  20853. e.INTENSITYMODE_LUMINANCE = 4,
  20854. e.LIGHTTYPEID_POINTLIGHT = 0,
  20855. e.LIGHTTYPEID_DIRECTIONALLIGHT = 1,
  20856. e.LIGHTTYPEID_SPOTLIGHT = 2,
  20857. e.LIGHTTYPEID_HEMISPHERICLIGHT = 3,
  20858. e
  20859. }(), _n = function() {
  20860. function e(t, i) {
  20861. e.IsAvailable && (this._observer = new window.ComputePressureObserver(t,i))
  20862. }
  20863. return Object.defineProperty(e, "IsAvailable", {
  20864. get: function() {
  20865. return nt() && "ComputePressureObserver"in window
  20866. },
  20867. enumerable: !1,
  20868. configurable: !0
  20869. }),
  20870. e.prototype.observe = function() {
  20871. var e, t;
  20872. (null === (e = this._observer) || void 0 === e ? void 0 : e.observe) && (null === (t = this._observer) || void 0 === t || t.observe())
  20873. }
  20874. ,
  20875. e.prototype.unobserve = function() {
  20876. var e, t;
  20877. (null === (e = this._observer) || void 0 === e ? void 0 : e.unobserve) && (null === (t = this._observer) || void 0 === t || t.unobserve())
  20878. }
  20879. ,
  20880. e
  20881. }(), mn = function(e) {
  20882. function t(i, n) {
  20883. var r = e.call(this) || this;
  20884. r._inputManager = new cn(r),
  20885. r.cameraToUseForPointers = null,
  20886. r._isScene = !0,
  20887. r._blockEntityCollection = !1,
  20888. r.autoClear = !0,
  20889. r.autoClearDepthAndStencil = !0,
  20890. r.clearColor = new N(.2,.2,.3,1),
  20891. r.ambientColor = new D(0,0,0),
  20892. r.environmentIntensity = 1,
  20893. r._forceWireframe = !1,
  20894. r._skipFrustumClipping = !1,
  20895. r._forcePointsCloud = !1,
  20896. r.animationsEnabled = !0,
  20897. r._animationPropertiesOverride = null,
  20898. r.useConstantAnimationDeltaTime = !1,
  20899. r.constantlyUpdateMeshUnderPointer = !1,
  20900. r.hoverCursor = "pointer",
  20901. r.defaultCursor = "",
  20902. r.doNotHandleCursors = !1,
  20903. r.preventDefaultOnPointerDown = !0,
  20904. r.preventDefaultOnPointerUp = !0,
  20905. r.metadata = null,
  20906. r.reservedDataStore = null,
  20907. r.disableOfflineSupportExceptionRules = new Array,
  20908. r.onDisposeObservable = new h,
  20909. r._onDisposeObserver = null,
  20910. r.onBeforeRenderObservable = new h,
  20911. r._onBeforeRenderObserver = null,
  20912. r.onAfterRenderObservable = new h,
  20913. r.onBeforeRunRegisterBeforeRenderObservable = new h,
  20914. r.onAfterRunRegisterBeforeRenderObservable = new h,
  20915. r.onBeforeRunRegisterAfterRenderObservable = new h,
  20916. r.onAfterRunRegisterAfterRenderObservable = new h,
  20917. r.onBeforeRTT1Observable = new h,
  20918. r.onAfterRTT1Observable = new h,
  20919. r.onAfterRenderCameraObservable = new h,
  20920. r._onAfterRenderObserver = null,
  20921. r.onBeforeAnimationsObservable = new h,
  20922. r.onAfterAnimationsObservable = new h,
  20923. r.onBeforeDrawPhaseObservable = new h,
  20924. r.onAfterDrawPhaseObservable = new h,
  20925. r.onReadyObservable = new h,
  20926. r.onBeforeCameraRenderObservable = new h,
  20927. r._onBeforeCameraRenderObserver = null,
  20928. r.onAfterCameraRenderObservable = new h,
  20929. r._onAfterCameraRenderObserver = null,
  20930. r.onBeforeActiveMeshesEvaluationObservable = new h,
  20931. r.onAfterActiveMeshesEvaluationObservable = new h,
  20932. r.onBeforeParticlesRenderingObservable = new h,
  20933. r.onAfterParticlesRenderingObservable = new h,
  20934. r.onDataLoadedObservable = new h,
  20935. r.onNewCameraAddedObservable = new h,
  20936. r.onCameraRemovedObservable = new h,
  20937. r.onNewLightAddedObservable = new h,
  20938. r.onLightRemovedObservable = new h,
  20939. r.onNewGeometryAddedObservable = new h,
  20940. r.onGeometryRemovedObservable = new h,
  20941. r.onNewTransformNodeAddedObservable = new h,
  20942. r.onTransformNodeRemovedObservable = new h,
  20943. r.onNewMeshAddedObservable = new h,
  20944. r.onMeshRemovedObservable = new h,
  20945. r.onNewSkeletonAddedObservable = new h,
  20946. r.onSkeletonRemovedObservable = new h,
  20947. r.onNewMaterialAddedObservable = new h,
  20948. r.onNewMultiMaterialAddedObservable = new h,
  20949. r.onMaterialRemovedObservable = new h,
  20950. r.onMultiMaterialRemovedObservable = new h,
  20951. r.onNewTextureAddedObservable = new h,
  20952. r.onTextureRemovedObservable = new h,
  20953. r.onBeforeRenderTargetsRenderObservable = new h,
  20954. r.onAfterRenderTargetsRenderObservable = new h,
  20955. r.onBeforeStepObservable = new h,
  20956. r.onAfterStepObservable = new h,
  20957. r.onActiveCameraChanged = new h,
  20958. r.onBeforeRenderingGroupObservable = new h,
  20959. r.onAfterRenderingGroupObservable = new h,
  20960. r.onMeshImportedObservable = new h,
  20961. r.onAnimationFileImportedObservable = new h,
  20962. r._registeredForLateAnimationBindings = new Ti(256),
  20963. r.skipPointerMovePicking = !1,
  20964. r.onPrePointerObservable = new h,
  20965. r.onPointerObservable = new h,
  20966. r.onPreKeyboardObservable = new h,
  20967. r.onKeyboardObservable = new h,
  20968. r._useRightHandedSystem = !1,
  20969. r._timeAccumulator = 0,
  20970. r._currentStepId = 0,
  20971. r._currentInternalStep = 0,
  20972. r._fogEnabled = !0,
  20973. r._fogMode = t.FOGMODE_NONE,
  20974. r.fogColor = new D(.2,.2,.3),
  20975. r.fogDensity = .1,
  20976. r.fogStart = 0,
  20977. r.fogEnd = 1e3,
  20978. r.needsPreviousWorldMatrices = !1,
  20979. r._shadowsEnabled = !0,
  20980. r._lightsEnabled = !0,
  20981. r.activeCameras = new Array,
  20982. r._texturesEnabled = !0,
  20983. r.physicsEnabled = !0,
  20984. r.particlesEnabled = !0,
  20985. r.spritesEnabled = !0,
  20986. r._skeletonsEnabled = !0,
  20987. r.lensFlaresEnabled = !0,
  20988. r.collisionsEnabled = !0,
  20989. r.gravity = new x(0,-9.807,0),
  20990. r.postProcessesEnabled = !0,
  20991. r.renderTargetsEnabled = !0,
  20992. r.dumpNextRenderTargets = !1,
  20993. r.customRenderTargets = new Array,
  20994. r.importedMeshesFiles = new Array,
  20995. r.probesEnabled = !0,
  20996. r._meshesForIntersections = new Ti(256),
  20997. r.proceduralTexturesEnabled = !0,
  20998. r._totalVertices = new un,
  20999. r._activeIndices = new un,
  21000. r._activeParticles = new un,
  21001. r._activeBones = new un,
  21002. r._animationTime = 0,
  21003. r.animationTimeScale = 1,
  21004. r._renderId = 0,
  21005. r._frameId = 0,
  21006. r._executeWhenReadyTimeoutId = null,
  21007. r._intermediateRendering = !1,
  21008. r._defaultFrameBufferCleared = !1,
  21009. r._viewUpdateFlag = -1,
  21010. r._projectionUpdateFlag = -1,
  21011. r._toBeDisposed = new Array(256),
  21012. r._activeRequests = new Array,
  21013. r._pendingData = new Array,
  21014. r._isDisposed = !1,
  21015. r.dispatchAllSubMeshesOfActiveMeshes = !1,
  21016. r._activeMeshes = new bi(256),
  21017. r._processedMaterials = new bi(256),
  21018. r._renderTargets = new Ti(256),
  21019. r._materialsRenderTargets = new Ti(256),
  21020. r._activeParticleSystems = new bi(256),
  21021. r._activeSkeletons = new Ti(32),
  21022. r._softwareSkinnedMeshes = new Ti(32),
  21023. r._activeAnimatables = new Array,
  21024. r._transformMatrix = P.Zero(),
  21025. r.requireLightSorting = !1,
  21026. r._components = [],
  21027. r._serializableComponents = [],
  21028. r._transientComponents = [],
  21029. r._beforeCameraUpdateStage = Hi.Create(),
  21030. r._beforeClearStage = Hi.Create(),
  21031. r._beforeRenderTargetClearStage = Hi.Create(),
  21032. r._gatherRenderTargetsStage = Hi.Create(),
  21033. r._gatherActiveCameraRenderTargetsStage = Hi.Create(),
  21034. r._isReadyForMeshStage = Hi.Create(),
  21035. r._beforeEvaluateActiveMeshStage = Hi.Create(),
  21036. r._evaluateSubMeshStage = Hi.Create(),
  21037. r._preActiveMeshStage = Hi.Create(),
  21038. r._cameraDrawRenderTargetStage = Hi.Create(),
  21039. r._beforeCameraDrawStage = Hi.Create(),
  21040. r._beforeRenderTargetDrawStage = Hi.Create(),
  21041. r._beforeRenderingGroupDrawStage = Hi.Create(),
  21042. r._beforeRenderingMeshStage = Hi.Create(),
  21043. r._afterRenderingMeshStage = Hi.Create(),
  21044. r._afterRenderingGroupDrawStage = Hi.Create(),
  21045. r._afterCameraDrawStage = Hi.Create(),
  21046. r._afterRenderTargetDrawStage = Hi.Create(),
  21047. r._afterRenderStage = Hi.Create(),
  21048. r._pointerMoveStage = Hi.Create(),
  21049. r._pointerDownStage = Hi.Create(),
  21050. r._pointerUpStage = Hi.Create(),
  21051. r._geometriesByUniqueId = null,
  21052. r._defaultMeshCandidates = {
  21053. data: [],
  21054. length: 0
  21055. },
  21056. r._defaultSubMeshCandidates = {
  21057. data: [],
  21058. length: 0
  21059. },
  21060. r._preventFreeActiveMeshesAndRenderingGroups = !1,
  21061. r._activeMeshesFrozen = !1,
  21062. r._skipEvaluateActiveMeshesCompletely = !1,
  21063. r._allowPostProcessClearColor = !0,
  21064. r.getDeterministicFrameTime = function() {
  21065. return r._engine.getTimeStep()
  21066. }
  21067. ,
  21068. r._blockMaterialDirtyMechanism = !1,
  21069. r._perfCollector = null,
  21070. r.onComputePressureChanged = new h;
  21071. var o = V({
  21072. useGeometryUniqueIdsMap: !0,
  21073. useMaterialMeshMap: !0,
  21074. useClonedMeshMap: !0,
  21075. virtual: !1
  21076. }, n);
  21077. return r._engine = i || E.LastCreatedEngine,
  21078. o.virtual ? r._engine._virtualScenes.push(r) : (E._LastCreatedScene = r,
  21079. r._engine.scenes.push(r)),
  21080. r._uid = null,
  21081. r._renderingManager = new zi(r),
  21082. Vi && (r.postProcessManager = new Vi(r)),
  21083. nt() && r.attachControl(),
  21084. r._createUbo(),
  21085. Ri && (r._imageProcessingConfiguration = new Ri),
  21086. r.setDefaultCandidateProviders(),
  21087. o.useGeometryUniqueIdsMap && (r._geometriesByUniqueId = {}),
  21088. r.useMaterialMeshMap = o.useMaterialMeshMap,
  21089. r.useClonedMeshMap = o.useClonedMeshMap,
  21090. n && n.virtual || r._engine.onNewSceneAddedObservable.notifyObservers(r),
  21091. _n.IsAvailable && (r._computePressureObserver = new _n((function(e) {
  21092. r.onComputePressureChanged.notifyObservers(e)
  21093. }
  21094. ),{
  21095. cpuUtilizationThresholds: [.25, .5, .75, .9],
  21096. cpuSpeedThresholds: [.5]
  21097. }),
  21098. r._computePressureObserver.observe()),
  21099. r
  21100. }
  21101. return U(t, e),
  21102. t.DefaultMaterialFactory = function(e) {
  21103. throw be("StandardMaterial")
  21104. }
  21105. ,
  21106. t.CollisionCoordinatorFactory = function() {
  21107. throw be("DefaultCollisionCoordinator")
  21108. }
  21109. ,
  21110. Object.defineProperty(t.prototype, "environmentTexture", {
  21111. get: function() {
  21112. return this._environmentTexture
  21113. },
  21114. set: function(e) {
  21115. this._environmentTexture !== e && (this._environmentTexture = e,
  21116. this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  21117. },
  21118. enumerable: !1,
  21119. configurable: !0
  21120. }),
  21121. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  21122. get: function() {
  21123. return this._imageProcessingConfiguration
  21124. },
  21125. enumerable: !1,
  21126. configurable: !0
  21127. }),
  21128. Object.defineProperty(t.prototype, "forceWireframe", {
  21129. get: function() {
  21130. return this._forceWireframe
  21131. },
  21132. set: function(e) {
  21133. this._forceWireframe !== e && (this._forceWireframe = e,
  21134. this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
  21135. },
  21136. enumerable: !1,
  21137. configurable: !0
  21138. }),
  21139. Object.defineProperty(t.prototype, "skipFrustumClipping", {
  21140. get: function() {
  21141. return this._skipFrustumClipping
  21142. },
  21143. set: function(e) {
  21144. this._skipFrustumClipping !== e && (this._skipFrustumClipping = e)
  21145. },
  21146. enumerable: !1,
  21147. configurable: !0
  21148. }),
  21149. Object.defineProperty(t.prototype, "forcePointsCloud", {
  21150. get: function() {
  21151. return this._forcePointsCloud
  21152. },
  21153. set: function(e) {
  21154. this._forcePointsCloud !== e && (this._forcePointsCloud = e,
  21155. this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
  21156. },
  21157. enumerable: !1,
  21158. configurable: !0
  21159. }),
  21160. Object.defineProperty(t.prototype, "animationPropertiesOverride", {
  21161. get: function() {
  21162. return this._animationPropertiesOverride
  21163. },
  21164. set: function(e) {
  21165. this._animationPropertiesOverride = e
  21166. },
  21167. enumerable: !1,
  21168. configurable: !0
  21169. }),
  21170. Object.defineProperty(t.prototype, "onDispose", {
  21171. set: function(e) {
  21172. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  21173. this._onDisposeObserver = this.onDisposeObservable.add(e)
  21174. },
  21175. enumerable: !1,
  21176. configurable: !0
  21177. }),
  21178. Object.defineProperty(t.prototype, "beforeRender", {
  21179. set: function(e) {
  21180. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  21181. e && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e))
  21182. },
  21183. enumerable: !1,
  21184. configurable: !0
  21185. }),
  21186. Object.defineProperty(t.prototype, "afterRender", {
  21187. set: function(e) {
  21188. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  21189. e && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(e))
  21190. },
  21191. enumerable: !1,
  21192. configurable: !0
  21193. }),
  21194. Object.defineProperty(t.prototype, "beforeCameraRender", {
  21195. set: function(e) {
  21196. this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  21197. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(e)
  21198. },
  21199. enumerable: !1,
  21200. configurable: !0
  21201. }),
  21202. Object.defineProperty(t.prototype, "afterCameraRender", {
  21203. set: function(e) {
  21204. this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  21205. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(e)
  21206. },
  21207. enumerable: !1,
  21208. configurable: !0
  21209. }),
  21210. Object.defineProperty(t.prototype, "unTranslatedPointer", {
  21211. get: function() {
  21212. return this._inputManager.unTranslatedPointer
  21213. },
  21214. enumerable: !1,
  21215. configurable: !0
  21216. }),
  21217. Object.defineProperty(t, "DragMovementThreshold", {
  21218. get: function() {
  21219. return cn.DragMovementThreshold
  21220. },
  21221. set: function(e) {
  21222. cn.DragMovementThreshold = e
  21223. },
  21224. enumerable: !1,
  21225. configurable: !0
  21226. }),
  21227. Object.defineProperty(t, "LongPressDelay", {
  21228. get: function() {
  21229. return cn.LongPressDelay
  21230. },
  21231. set: function(e) {
  21232. cn.LongPressDelay = e
  21233. },
  21234. enumerable: !1,
  21235. configurable: !0
  21236. }),
  21237. Object.defineProperty(t, "DoubleClickDelay", {
  21238. get: function() {
  21239. return cn.DoubleClickDelay
  21240. },
  21241. set: function(e) {
  21242. cn.DoubleClickDelay = e
  21243. },
  21244. enumerable: !1,
  21245. configurable: !0
  21246. }),
  21247. Object.defineProperty(t, "ExclusiveDoubleClickMode", {
  21248. get: function() {
  21249. return cn.ExclusiveDoubleClickMode
  21250. },
  21251. set: function(e) {
  21252. cn.ExclusiveDoubleClickMode = e
  21253. },
  21254. enumerable: !1,
  21255. configurable: !0
  21256. }),
  21257. t.prototype.bindEyePosition = function(e, t, i) {
  21258. var n;
  21259. void 0 === t && (t = "vEyePosition"),
  21260. void 0 === i && (i = !1);
  21261. var r = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : null !== (n = this.activeCamera.globalPosition) && void 0 !== n ? n : this.activeCamera.devicePosition
  21262. , o = this.useRightHandedSystem === (null != this._mirroredCameraPosition);
  21263. return I.Vector4[0].set(r.x, r.y, r.z, o ? -1 : 1),
  21264. e && (i ? e.setFloat3(t, I.Vector4[0].x, I.Vector4[0].y, I.Vector4[0].z) : e.setVector4(t, I.Vector4[0])),
  21265. I.Vector4[0]
  21266. }
  21267. ,
  21268. t.prototype.finalizeSceneUbo = function() {
  21269. var e = this.getSceneUniformBuffer()
  21270. , t = this.bindEyePosition(null);
  21271. return e.updateFloat4("vEyePosition", t.x, t.y, t.z, t.w),
  21272. e.update(),
  21273. e
  21274. }
  21275. ,
  21276. Object.defineProperty(t.prototype, "useRightHandedSystem", {
  21277. get: function() {
  21278. return this._useRightHandedSystem
  21279. },
  21280. set: function(e) {
  21281. this._useRightHandedSystem !== e && (this._useRightHandedSystem = e,
  21282. this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
  21283. },
  21284. enumerable: !1,
  21285. configurable: !0
  21286. }),
  21287. t.prototype.setStepId = function(e) {
  21288. this._currentStepId = e
  21289. }
  21290. ,
  21291. t.prototype.getStepId = function() {
  21292. return this._currentStepId
  21293. }
  21294. ,
  21295. t.prototype.getInternalStep = function() {
  21296. return this._currentInternalStep
  21297. }
  21298. ,
  21299. Object.defineProperty(t.prototype, "fogEnabled", {
  21300. get: function() {
  21301. return this._fogEnabled
  21302. },
  21303. set: function(e) {
  21304. this._fogEnabled !== e && (this._fogEnabled = e,
  21305. this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
  21306. },
  21307. enumerable: !1,
  21308. configurable: !0
  21309. }),
  21310. Object.defineProperty(t.prototype, "fogMode", {
  21311. get: function() {
  21312. return this._fogMode
  21313. },
  21314. set: function(e) {
  21315. this._fogMode !== e && (this._fogMode = e,
  21316. this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
  21317. },
  21318. enumerable: !1,
  21319. configurable: !0
  21320. }),
  21321. Object.defineProperty(t.prototype, "prePass", {
  21322. get: function() {
  21323. return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled
  21324. },
  21325. enumerable: !1,
  21326. configurable: !0
  21327. }),
  21328. Object.defineProperty(t.prototype, "shadowsEnabled", {
  21329. get: function() {
  21330. return this._shadowsEnabled
  21331. },
  21332. set: function(e) {
  21333. this._shadowsEnabled !== e && (this._shadowsEnabled = e,
  21334. this.markAllMaterialsAsDirty(a.MATERIAL_LightDirtyFlag))
  21335. },
  21336. enumerable: !1,
  21337. configurable: !0
  21338. }),
  21339. Object.defineProperty(t.prototype, "lightsEnabled", {
  21340. get: function() {
  21341. return this._lightsEnabled
  21342. },
  21343. set: function(e) {
  21344. this._lightsEnabled !== e && (this._lightsEnabled = e,
  21345. this.markAllMaterialsAsDirty(a.MATERIAL_LightDirtyFlag))
  21346. },
  21347. enumerable: !1,
  21348. configurable: !0
  21349. }),
  21350. Object.defineProperty(t.prototype, "activeCamera", {
  21351. get: function() {
  21352. return this._activeCamera
  21353. },
  21354. set: function(e) {
  21355. e !== this._activeCamera && (this._activeCamera = e,
  21356. this.onActiveCameraChanged.notifyObservers(this))
  21357. },
  21358. enumerable: !1,
  21359. configurable: !0
  21360. }),
  21361. Object.defineProperty(t.prototype, "defaultMaterial", {
  21362. get: function() {
  21363. return this._defaultMaterial || (this._defaultMaterial = t.DefaultMaterialFactory(this)),
  21364. this._defaultMaterial
  21365. },
  21366. set: function(e) {
  21367. this._defaultMaterial = e
  21368. },
  21369. enumerable: !1,
  21370. configurable: !0
  21371. }),
  21372. Object.defineProperty(t.prototype, "texturesEnabled", {
  21373. get: function() {
  21374. return this._texturesEnabled
  21375. },
  21376. set: function(e) {
  21377. this._texturesEnabled !== e && (this._texturesEnabled = e,
  21378. this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  21379. },
  21380. enumerable: !1,
  21381. configurable: !0
  21382. }),
  21383. Object.defineProperty(t.prototype, "skeletonsEnabled", {
  21384. get: function() {
  21385. return this._skeletonsEnabled
  21386. },
  21387. set: function(e) {
  21388. this._skeletonsEnabled !== e && (this._skeletonsEnabled = e,
  21389. this.markAllMaterialsAsDirty(a.MATERIAL_AttributesDirtyFlag))
  21390. },
  21391. enumerable: !1,
  21392. configurable: !0
  21393. }),
  21394. Object.defineProperty(t.prototype, "collisionCoordinator", {
  21395. get: function() {
  21396. return this._collisionCoordinator || (this._collisionCoordinator = t.CollisionCoordinatorFactory(),
  21397. this._collisionCoordinator.init(this)),
  21398. this._collisionCoordinator
  21399. },
  21400. enumerable: !1,
  21401. configurable: !0
  21402. }),
  21403. Object.defineProperty(t.prototype, "frustumPlanes", {
  21404. get: function() {
  21405. return this._frustumPlanes
  21406. },
  21407. enumerable: !1,
  21408. configurable: !0
  21409. }),
  21410. t.prototype._registerTransientComponents = function() {
  21411. if (this._transientComponents.length > 0) {
  21412. for (var e = 0, t = this._transientComponents; e < t.length; e++)
  21413. t[e].register();
  21414. this._transientComponents = []
  21415. }
  21416. }
  21417. ,
  21418. t.prototype._addComponent = function(e) {
  21419. this._components.push(e),
  21420. this._transientComponents.push(e);
  21421. var t = e;
  21422. t.addFromContainer && t.serialize && this._serializableComponents.push(t)
  21423. }
  21424. ,
  21425. t.prototype._getComponent = function(e) {
  21426. for (var t = 0, i = this._components; t < i.length; t++) {
  21427. var n = i[t];
  21428. if (n.name === e)
  21429. return n
  21430. }
  21431. return null
  21432. }
  21433. ,
  21434. t.prototype.getClassName = function() {
  21435. return "Scene"
  21436. }
  21437. ,
  21438. t.prototype._getDefaultMeshCandidates = function() {
  21439. return this._defaultMeshCandidates.data = this.meshes,
  21440. this._defaultMeshCandidates.length = this.meshes.length,
  21441. this._defaultMeshCandidates
  21442. }
  21443. ,
  21444. t.prototype._getDefaultSubMeshCandidates = function(e) {
  21445. return this._defaultSubMeshCandidates.data = e.subMeshes,
  21446. this._defaultSubMeshCandidates.length = e.subMeshes.length,
  21447. this._defaultSubMeshCandidates
  21448. }
  21449. ,
  21450. t.prototype.setDefaultCandidateProviders = function() {
  21451. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this),
  21452. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
  21453. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
  21454. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this)
  21455. }
  21456. ,
  21457. Object.defineProperty(t.prototype, "meshUnderPointer", {
  21458. get: function() {
  21459. return this._inputManager.meshUnderPointer
  21460. },
  21461. enumerable: !1,
  21462. configurable: !0
  21463. }),
  21464. Object.defineProperty(t.prototype, "pointerX", {
  21465. get: function() {
  21466. return this._inputManager.pointerX
  21467. },
  21468. set: function(e) {
  21469. this._inputManager.pointerX = e
  21470. },
  21471. enumerable: !1,
  21472. configurable: !0
  21473. }),
  21474. Object.defineProperty(t.prototype, "pointerY", {
  21475. get: function() {
  21476. return this._inputManager.pointerY
  21477. },
  21478. set: function(e) {
  21479. this._inputManager.pointerY = e
  21480. },
  21481. enumerable: !1,
  21482. configurable: !0
  21483. }),
  21484. t.prototype.getCachedMaterial = function() {
  21485. return this._cachedMaterial
  21486. }
  21487. ,
  21488. t.prototype.getCachedEffect = function() {
  21489. return this._cachedEffect
  21490. }
  21491. ,
  21492. t.prototype.getCachedVisibility = function() {
  21493. return this._cachedVisibility
  21494. }
  21495. ,
  21496. t.prototype.isCachedMaterialInvalid = function(e, t, i) {
  21497. return void 0 === i && (i = 1),
  21498. this._cachedEffect !== t || this._cachedMaterial !== e || this._cachedVisibility !== i
  21499. }
  21500. ,
  21501. t.prototype.getEngine = function() {
  21502. return this._engine
  21503. }
  21504. ,
  21505. t.prototype.getTotalVertices = function() {
  21506. return this._totalVertices.current
  21507. }
  21508. ,
  21509. Object.defineProperty(t.prototype, "totalVerticesPerfCounter", {
  21510. get: function() {
  21511. return this._totalVertices
  21512. },
  21513. enumerable: !1,
  21514. configurable: !0
  21515. }),
  21516. t.prototype.getActiveIndices = function() {
  21517. return this._activeIndices.current
  21518. }
  21519. ,
  21520. Object.defineProperty(t.prototype, "totalActiveIndicesPerfCounter", {
  21521. get: function() {
  21522. return this._activeIndices
  21523. },
  21524. enumerable: !1,
  21525. configurable: !0
  21526. }),
  21527. t.prototype.getActiveParticles = function() {
  21528. return this._activeParticles.current
  21529. }
  21530. ,
  21531. Object.defineProperty(t.prototype, "activeParticlesPerfCounter", {
  21532. get: function() {
  21533. return this._activeParticles
  21534. },
  21535. enumerable: !1,
  21536. configurable: !0
  21537. }),
  21538. t.prototype.getActiveBones = function() {
  21539. return this._activeBones.current
  21540. }
  21541. ,
  21542. Object.defineProperty(t.prototype, "activeBonesPerfCounter", {
  21543. get: function() {
  21544. return this._activeBones
  21545. },
  21546. enumerable: !1,
  21547. configurable: !0
  21548. }),
  21549. t.prototype.getActiveMeshes = function() {
  21550. return this._activeMeshes
  21551. }
  21552. ,
  21553. t.prototype.getAnimationRatio = function() {
  21554. return void 0 !== this._animationRatio ? this._animationRatio : 1
  21555. }
  21556. ,
  21557. t.prototype.getRenderId = function() {
  21558. return this._renderId
  21559. }
  21560. ,
  21561. t.prototype.getFrameId = function() {
  21562. return this._frameId
  21563. }
  21564. ,
  21565. t.prototype.incrementRenderId = function() {
  21566. this._renderId++
  21567. }
  21568. ,
  21569. t.prototype._createUbo = function() {
  21570. this.setSceneUniformBuffer(this.createSceneUniformBuffer())
  21571. }
  21572. ,
  21573. t.prototype.simulatePointerMove = function(e, t) {
  21574. return this._inputManager.simulatePointerMove(e, t),
  21575. this
  21576. }
  21577. ,
  21578. t.prototype.simulatePointerDown = function(e, t) {
  21579. return this._inputManager.simulatePointerDown(e, t),
  21580. this
  21581. }
  21582. ,
  21583. t.prototype.simulatePointerUp = function(e, t, i) {
  21584. return this._inputManager.simulatePointerUp(e, t, i),
  21585. this
  21586. }
  21587. ,
  21588. t.prototype.isPointerCaptured = function(e) {
  21589. return void 0 === e && (e = 0),
  21590. this._inputManager.isPointerCaptured(e)
  21591. }
  21592. ,
  21593. t.prototype.attachControl = function(e, t, i) {
  21594. void 0 === e && (e = !0),
  21595. void 0 === t && (t = !0),
  21596. void 0 === i && (i = !0),
  21597. this._inputManager.attachControl(e, t, i)
  21598. }
  21599. ,
  21600. t.prototype.detachControl = function() {
  21601. this._inputManager.detachControl()
  21602. }
  21603. ,
  21604. t.prototype.isReady = function(e) {
  21605. if (void 0 === e && (e = !0),
  21606. this._isDisposed)
  21607. return !1;
  21608. var t, i = this.getEngine();
  21609. if (this._pendingData.length > 0)
  21610. return !1;
  21611. e && (this._processedMaterials.reset(),
  21612. this._materialsRenderTargets.reset());
  21613. var n = !0;
  21614. for (t = 0; t < this.meshes.length; t++) {
  21615. var r = this.meshes[t];
  21616. if (r.isEnabled() && r.subMeshes && 0 !== r.subMeshes.length)
  21617. if (r.isReady(!0)) {
  21618. for (var o = r.hasThinInstances || "InstancedMesh" === r.getClassName() || "InstancedLinesMesh" === r.getClassName() || i.getCaps().instancedArrays && r.instances.length > 0, s = 0, l = this._isReadyForMeshStage; s < l.length; s++)
  21619. l[s].action(r, o) || (n = !1);
  21620. if (e) {
  21621. var c = r.material || this.defaultMaterial;
  21622. if (c)
  21623. if (c._storeEffectOnSubMeshes)
  21624. for (var u = 0, h = r.subMeshes; u < h.length; u++) {
  21625. var d = h[u].getMaterial();
  21626. d && d.hasRenderTargetTextures && null != d.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(d) && (this._processedMaterials.push(d),
  21627. this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))
  21628. }
  21629. else
  21630. c.hasRenderTargetTextures && null != c.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(c) && (this._processedMaterials.push(c),
  21631. this._materialsRenderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))
  21632. }
  21633. } else
  21634. n = !1
  21635. }
  21636. if (!n)
  21637. return !1;
  21638. if (!i.areAllEffectsReady())
  21639. return !1;
  21640. if (e)
  21641. for (t = 0; t < this._materialsRenderTargets.length; ++t)
  21642. if (!this._materialsRenderTargets.data[t].isReadyForRendering())
  21643. return !1;
  21644. for (t = 0; t < this.geometries.length; t++)
  21645. if (this.geometries[t].delayLoadState === a.DELAYLOADSTATE_LOADING)
  21646. return !1;
  21647. if (this.activeCameras && this.activeCameras.length > 0) {
  21648. for (var p = 0, f = this.activeCameras; p < f.length; p++)
  21649. if (!f[p].isReady(!0))
  21650. return !1
  21651. } else if (this.activeCamera && !this.activeCamera.isReady(!0))
  21652. return !1;
  21653. for (var _ = 0, m = this.particleSystems; _ < m.length; _++)
  21654. if (!m[_].isReady())
  21655. return !1;
  21656. return !0
  21657. }
  21658. ,
  21659. t.prototype.resetCachedMaterial = function() {
  21660. this._cachedMaterial = null,
  21661. this._cachedEffect = null,
  21662. this._cachedVisibility = null
  21663. }
  21664. ,
  21665. t.prototype.registerBeforeRender = function(e) {
  21666. this.onBeforeRenderObservable.add(e)
  21667. }
  21668. ,
  21669. t.prototype.unregisterBeforeRender = function(e) {
  21670. this.onBeforeRenderObservable.removeCallback(e)
  21671. }
  21672. ,
  21673. t.prototype.registerAfterRender = function(e) {
  21674. this.onAfterRenderObservable.add(e)
  21675. }
  21676. ,
  21677. t.prototype.unregisterAfterRender = function(e) {
  21678. this.onAfterRenderObservable.removeCallback(e)
  21679. }
  21680. ,
  21681. t.prototype._executeOnceBeforeRender = function(e) {
  21682. var t = this
  21683. , i = function() {
  21684. e(),
  21685. setTimeout((function() {
  21686. t.unregisterBeforeRender(i)
  21687. }
  21688. ))
  21689. };
  21690. this.registerBeforeRender(i)
  21691. }
  21692. ,
  21693. t.prototype.executeOnceBeforeRender = function(e, t) {
  21694. var i = this;
  21695. void 0 !== t ? setTimeout((function() {
  21696. i._executeOnceBeforeRender(e)
  21697. }
  21698. ), t) : this._executeOnceBeforeRender(e)
  21699. }
  21700. ,
  21701. t.prototype._addPendingData = function(e) {
  21702. this._pendingData.push(e)
  21703. }
  21704. ,
  21705. t.prototype._removePendingData = function(e) {
  21706. var t = this.isLoading
  21707. , i = this._pendingData.indexOf(e);
  21708. -1 !== i && this._pendingData.splice(i, 1),
  21709. t && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this)
  21710. }
  21711. ,
  21712. t.prototype.getWaitingItemsCount = function() {
  21713. return this._pendingData.length
  21714. }
  21715. ,
  21716. Object.defineProperty(t.prototype, "isLoading", {
  21717. get: function() {
  21718. return this._pendingData.length > 0
  21719. },
  21720. enumerable: !1,
  21721. configurable: !0
  21722. }),
  21723. t.prototype.executeWhenReady = function(e, t) {
  21724. var i = this;
  21725. void 0 === t && (t = !1),
  21726. this.onReadyObservable.add(e),
  21727. null === this._executeWhenReadyTimeoutId && (this._executeWhenReadyTimeoutId = setTimeout((function() {
  21728. i._checkIsReady(t)
  21729. }
  21730. ), 150))
  21731. }
  21732. ,
  21733. t.prototype.whenReadyAsync = function(e) {
  21734. var t = this;
  21735. return void 0 === e && (e = !1),
  21736. new Promise((function(i) {
  21737. t.executeWhenReady((function() {
  21738. i()
  21739. }
  21740. ), e)
  21741. }
  21742. ))
  21743. }
  21744. ,
  21745. t.prototype._checkIsReady = function(e) {
  21746. var t = this;
  21747. return void 0 === e && (e = !1),
  21748. this._registerTransientComponents(),
  21749. this.isReady(e) ? (this.onReadyObservable.notifyObservers(this),
  21750. this.onReadyObservable.clear(),
  21751. void (this._executeWhenReadyTimeoutId = null)) : this._isDisposed ? (this.onReadyObservable.clear(),
  21752. void (this._executeWhenReadyTimeoutId = null)) : void (this._executeWhenReadyTimeoutId = setTimeout((function() {
  21753. t._checkIsReady(e)
  21754. }
  21755. ), 100))
  21756. }
  21757. ,
  21758. Object.defineProperty(t.prototype, "animatables", {
  21759. get: function() {
  21760. return this._activeAnimatables
  21761. },
  21762. enumerable: !1,
  21763. configurable: !0
  21764. }),
  21765. t.prototype.resetLastAnimationTimeFrame = function() {
  21766. this._animationTimeLast = ct.Now
  21767. }
  21768. ,
  21769. t.prototype.getViewMatrix = function() {
  21770. return this._viewMatrix
  21771. }
  21772. ,
  21773. t.prototype.getProjectionMatrix = function() {
  21774. return this._projectionMatrix
  21775. }
  21776. ,
  21777. t.prototype.getTransformMatrix = function() {
  21778. return this._transformMatrix
  21779. }
  21780. ,
  21781. t.prototype.setTransformMatrix = function(e, t, i, n) {
  21782. i || n || !this._multiviewSceneUbo || (this._multiviewSceneUbo.dispose(),
  21783. this._multiviewSceneUbo = null),
  21784. this._viewUpdateFlag === e.updateFlag && this._projectionUpdateFlag === t.updateFlag || (this._viewUpdateFlag = e.updateFlag,
  21785. this._projectionUpdateFlag = t.updateFlag,
  21786. this._viewMatrix = e,
  21787. this._projectionMatrix = t,
  21788. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
  21789. this._frustumPlanes ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.GetPlanes(this._transformMatrix),
  21790. this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(i, n) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix),
  21791. this._sceneUbo.updateMatrix("view", this._viewMatrix),
  21792. this._sceneUbo.updateMatrix("projection", this._projectionMatrix)))
  21793. }
  21794. ,
  21795. t.prototype.getSceneUniformBuffer = function() {
  21796. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo
  21797. }
  21798. ,
  21799. t.prototype.createSceneUniformBuffer = function(e) {
  21800. var t = new Fi(this._engine,void 0,!1,null != e ? e : "scene");
  21801. return t.addUniform("viewProjection", 16),
  21802. t.addUniform("view", 16),
  21803. t.addUniform("projection", 16),
  21804. t.addUniform("vEyePosition", 4),
  21805. t
  21806. }
  21807. ,
  21808. t.prototype.setSceneUniformBuffer = function(e) {
  21809. this._sceneUbo = e,
  21810. this._viewUpdateFlag = -1,
  21811. this._projectionUpdateFlag = -1
  21812. }
  21813. ,
  21814. t.prototype.getUniqueId = function() {
  21815. return pn.UniqueId
  21816. }
  21817. ,
  21818. t.prototype.addMesh = function(e, t) {
  21819. var i = this;
  21820. void 0 === t && (t = !1),
  21821. this._blockEntityCollection || (this.meshes.push(e),
  21822. e._resyncLightSources(),
  21823. e.parent || e._addToSceneRootNodes(),
  21824. this.onNewMeshAddedObservable.notifyObservers(e),
  21825. t && e.getChildMeshes().forEach((function(e) {
  21826. i.addMesh(e)
  21827. }
  21828. )))
  21829. }
  21830. ,
  21831. t.prototype.removeMesh = function(e, t) {
  21832. var i = this;
  21833. void 0 === t && (t = !1);
  21834. var n = this.meshes.indexOf(e);
  21835. return -1 !== n && (this.meshes[n] = this.meshes[this.meshes.length - 1],
  21836. this.meshes.pop(),
  21837. e.parent || e._removeFromSceneRootNodes()),
  21838. this._inputManager._invalidateMesh(e),
  21839. this.onMeshRemovedObservable.notifyObservers(e),
  21840. t && e.getChildMeshes().forEach((function(e) {
  21841. i.removeMesh(e)
  21842. }
  21843. )),
  21844. n
  21845. }
  21846. ,
  21847. t.prototype.addTransformNode = function(e) {
  21848. this._blockEntityCollection || (e._indexInSceneTransformNodesArray = this.transformNodes.length,
  21849. this.transformNodes.push(e),
  21850. e.parent || e._addToSceneRootNodes(),
  21851. this.onNewTransformNodeAddedObservable.notifyObservers(e))
  21852. }
  21853. ,
  21854. t.prototype.removeTransformNode = function(e) {
  21855. var t = e._indexInSceneTransformNodesArray;
  21856. if (-1 !== t) {
  21857. if (t !== this.transformNodes.length - 1) {
  21858. var i = this.transformNodes[this.transformNodes.length - 1];
  21859. this.transformNodes[t] = i,
  21860. i._indexInSceneTransformNodesArray = t
  21861. }
  21862. e._indexInSceneTransformNodesArray = -1,
  21863. this.transformNodes.pop(),
  21864. e.parent || e._removeFromSceneRootNodes()
  21865. }
  21866. return this.onTransformNodeRemovedObservable.notifyObservers(e),
  21867. t
  21868. }
  21869. ,
  21870. t.prototype.removeSkeleton = function(e) {
  21871. var t = this.skeletons.indexOf(e);
  21872. return -1 !== t && (this.skeletons.splice(t, 1),
  21873. this.onSkeletonRemovedObservable.notifyObservers(e),
  21874. this._executeActiveContainerCleanup(this._activeSkeletons)),
  21875. t
  21876. }
  21877. ,
  21878. t.prototype.removeMorphTargetManager = function(e) {
  21879. var t = this.morphTargetManagers.indexOf(e);
  21880. return -1 !== t && this.morphTargetManagers.splice(t, 1),
  21881. t
  21882. }
  21883. ,
  21884. t.prototype.removeLight = function(e) {
  21885. var t = this.lights.indexOf(e);
  21886. if (-1 !== t) {
  21887. for (var i = 0, n = this.meshes; i < n.length; i++)
  21888. n[i]._removeLightSource(e, !1);
  21889. this.lights.splice(t, 1),
  21890. this.sortLightsByPriority(),
  21891. e.parent || e._removeFromSceneRootNodes()
  21892. }
  21893. return this.onLightRemovedObservable.notifyObservers(e),
  21894. t
  21895. }
  21896. ,
  21897. t.prototype.removeCamera = function(e) {
  21898. var t = this.cameras.indexOf(e);
  21899. if (-1 !== t && (this.cameras.splice(t, 1),
  21900. e.parent || e._removeFromSceneRootNodes()),
  21901. this.activeCameras) {
  21902. var i = this.activeCameras.indexOf(e);
  21903. -1 !== i && this.activeCameras.splice(i, 1)
  21904. }
  21905. return this.activeCamera === e && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null),
  21906. this.onCameraRemovedObservable.notifyObservers(e),
  21907. t
  21908. }
  21909. ,
  21910. t.prototype.removeParticleSystem = function(e) {
  21911. var t = this.particleSystems.indexOf(e);
  21912. return -1 !== t && (this.particleSystems.splice(t, 1),
  21913. this._executeActiveContainerCleanup(this._activeParticleSystems)),
  21914. t
  21915. }
  21916. ,
  21917. t.prototype.removeAnimation = function(e) {
  21918. var t = this.animations.indexOf(e);
  21919. return -1 !== t && this.animations.splice(t, 1),
  21920. t
  21921. }
  21922. ,
  21923. t.prototype.stopAnimation = function(e, t, i) {}
  21924. ,
  21925. t.prototype.removeAnimationGroup = function(e) {
  21926. var t = this.animationGroups.indexOf(e);
  21927. return -1 !== t && this.animationGroups.splice(t, 1),
  21928. t
  21929. }
  21930. ,
  21931. t.prototype.removeMultiMaterial = function(e) {
  21932. var t = this.multiMaterials.indexOf(e);
  21933. return -1 !== t && this.multiMaterials.splice(t, 1),
  21934. this.onMultiMaterialRemovedObservable.notifyObservers(e),
  21935. t
  21936. }
  21937. ,
  21938. t.prototype.removeMaterial = function(e) {
  21939. var t = e._indexInSceneMaterialArray;
  21940. if (-1 !== t && t < this.materials.length) {
  21941. if (t !== this.materials.length - 1) {
  21942. var i = this.materials[this.materials.length - 1];
  21943. this.materials[t] = i,
  21944. i._indexInSceneMaterialArray = t
  21945. }
  21946. e._indexInSceneMaterialArray = -1,
  21947. this.materials.pop()
  21948. }
  21949. return this.onMaterialRemovedObservable.notifyObservers(e),
  21950. t
  21951. }
  21952. ,
  21953. t.prototype.removeActionManager = function(e) {
  21954. var t = this.actionManagers.indexOf(e);
  21955. return -1 !== t && this.actionManagers.splice(t, 1),
  21956. t
  21957. }
  21958. ,
  21959. t.prototype.removeTexture = function(e) {
  21960. var t = this.textures.indexOf(e);
  21961. return -1 !== t && this.textures.splice(t, 1),
  21962. this.onTextureRemovedObservable.notifyObservers(e),
  21963. t
  21964. }
  21965. ,
  21966. t.prototype.addLight = function(e) {
  21967. if (!this._blockEntityCollection) {
  21968. this.lights.push(e),
  21969. this.sortLightsByPriority(),
  21970. e.parent || e._addToSceneRootNodes();
  21971. for (var t = 0, i = this.meshes; t < i.length; t++) {
  21972. var n = i[t];
  21973. -1 === n.lightSources.indexOf(e) && (n.lightSources.push(e),
  21974. n._resyncLightSources())
  21975. }
  21976. this.onNewLightAddedObservable.notifyObservers(e)
  21977. }
  21978. }
  21979. ,
  21980. t.prototype.sortLightsByPriority = function() {
  21981. this.requireLightSorting && this.lights.sort(fn.CompareLightsPriority)
  21982. }
  21983. ,
  21984. t.prototype.addCamera = function(e) {
  21985. this._blockEntityCollection || (this.cameras.push(e),
  21986. this.onNewCameraAddedObservable.notifyObservers(e),
  21987. e.parent || e._addToSceneRootNodes())
  21988. }
  21989. ,
  21990. t.prototype.addSkeleton = function(e) {
  21991. this._blockEntityCollection || (this.skeletons.push(e),
  21992. this.onNewSkeletonAddedObservable.notifyObservers(e))
  21993. }
  21994. ,
  21995. t.prototype.addParticleSystem = function(e) {
  21996. this._blockEntityCollection || this.particleSystems.push(e)
  21997. }
  21998. ,
  21999. t.prototype.addAnimation = function(e) {
  22000. this._blockEntityCollection || this.animations.push(e)
  22001. }
  22002. ,
  22003. t.prototype.addAnimationGroup = function(e) {
  22004. this._blockEntityCollection || this.animationGroups.push(e)
  22005. }
  22006. ,
  22007. t.prototype.addMultiMaterial = function(e) {
  22008. this._blockEntityCollection || (this.multiMaterials.push(e),
  22009. this.onNewMultiMaterialAddedObservable.notifyObservers(e))
  22010. }
  22011. ,
  22012. t.prototype.addMaterial = function(e) {
  22013. this._blockEntityCollection || (e._indexInSceneMaterialArray = this.materials.length,
  22014. this.materials.push(e),
  22015. this.onNewMaterialAddedObservable.notifyObservers(e))
  22016. }
  22017. ,
  22018. t.prototype.addMorphTargetManager = function(e) {
  22019. this._blockEntityCollection || this.morphTargetManagers.push(e)
  22020. }
  22021. ,
  22022. t.prototype.addGeometry = function(e) {
  22023. this._blockEntityCollection || (this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = this.geometries.length),
  22024. this.geometries.push(e))
  22025. }
  22026. ,
  22027. t.prototype.addActionManager = function(e) {
  22028. this.actionManagers.push(e)
  22029. }
  22030. ,
  22031. t.prototype.addTexture = function(e) {
  22032. this._blockEntityCollection || (this.textures.push(e),
  22033. this.onNewTextureAddedObservable.notifyObservers(e))
  22034. }
  22035. ,
  22036. t.prototype.switchActiveCamera = function(e, t) {
  22037. void 0 === t && (t = !0),
  22038. this._engine.getInputElement() && (this.activeCamera && this.activeCamera.detachControl(),
  22039. this.activeCamera = e,
  22040. t && e.attachControl())
  22041. }
  22042. ,
  22043. t.prototype.setActiveCameraById = function(e) {
  22044. var t = this.getCameraById(e);
  22045. return t ? (this.activeCamera = t,
  22046. t) : null
  22047. }
  22048. ,
  22049. t.prototype.setActiveCameraByName = function(e) {
  22050. var t = this.getCameraByName(e);
  22051. return t ? (this.activeCamera = t,
  22052. t) : null
  22053. }
  22054. ,
  22055. t.prototype.getAnimationGroupByName = function(e) {
  22056. for (var t = 0; t < this.animationGroups.length; t++)
  22057. if (this.animationGroups[t].name === e)
  22058. return this.animationGroups[t];
  22059. return null
  22060. }
  22061. ,
  22062. t.prototype.getMaterialByUniqueID = function(e) {
  22063. for (var t = 0; t < this.materials.length; t++)
  22064. if (this.materials[t].uniqueId === e)
  22065. return this.materials[t];
  22066. return null
  22067. }
  22068. ,
  22069. t.prototype.getMaterialById = function(e) {
  22070. for (var t = 0; t < this.materials.length; t++)
  22071. if (this.materials[t].id === e)
  22072. return this.materials[t];
  22073. return null
  22074. }
  22075. ,
  22076. t.prototype.getLastMaterialById = function(e, t) {
  22077. void 0 === t && (t = !1);
  22078. for (var i = this.materials.length - 1; i >= 0; i--)
  22079. if (this.materials[i].id === e)
  22080. return this.materials[i];
  22081. if (t)
  22082. for (i = this.multiMaterials.length - 1; i >= 0; i--)
  22083. if (this.multiMaterials[i].id === e)
  22084. return this.multiMaterials[i];
  22085. return null
  22086. }
  22087. ,
  22088. t.prototype.getMaterialByName = function(e) {
  22089. for (var t = 0; t < this.materials.length; t++)
  22090. if (this.materials[t].name === e)
  22091. return this.materials[t];
  22092. return null
  22093. }
  22094. ,
  22095. t.prototype.getTextureByUniqueId = function(e) {
  22096. for (var t = 0; t < this.textures.length; t++)
  22097. if (this.textures[t].uniqueId === e)
  22098. return this.textures[t];
  22099. return null
  22100. }
  22101. ,
  22102. t.prototype.getTextureByName = function(e) {
  22103. for (var t = 0; t < this.textures.length; t++)
  22104. if (this.textures[t].name === e)
  22105. return this.textures[t];
  22106. return null
  22107. }
  22108. ,
  22109. t.prototype.getCameraById = function(e) {
  22110. for (var t = 0; t < this.cameras.length; t++)
  22111. if (this.cameras[t].id === e)
  22112. return this.cameras[t];
  22113. return null
  22114. }
  22115. ,
  22116. t.prototype.getCameraByUniqueId = function(e) {
  22117. for (var t = 0; t < this.cameras.length; t++)
  22118. if (this.cameras[t].uniqueId === e)
  22119. return this.cameras[t];
  22120. return null
  22121. }
  22122. ,
  22123. t.prototype.getCameraByName = function(e) {
  22124. for (var t = 0; t < this.cameras.length; t++)
  22125. if (this.cameras[t].name === e)
  22126. return this.cameras[t];
  22127. return null
  22128. }
  22129. ,
  22130. t.prototype.getBoneById = function(e) {
  22131. for (var t = 0; t < this.skeletons.length; t++)
  22132. for (var i = this.skeletons[t], n = 0; n < i.bones.length; n++)
  22133. if (i.bones[n].id === e)
  22134. return i.bones[n];
  22135. return null
  22136. }
  22137. ,
  22138. t.prototype.getBoneByName = function(e) {
  22139. for (var t = 0; t < this.skeletons.length; t++)
  22140. for (var i = this.skeletons[t], n = 0; n < i.bones.length; n++)
  22141. if (i.bones[n].name === e)
  22142. return i.bones[n];
  22143. return null
  22144. }
  22145. ,
  22146. t.prototype.getLightByName = function(e) {
  22147. for (var t = 0; t < this.lights.length; t++)
  22148. if (this.lights[t].name === e)
  22149. return this.lights[t];
  22150. return null
  22151. }
  22152. ,
  22153. t.prototype.getLightById = function(e) {
  22154. for (var t = 0; t < this.lights.length; t++)
  22155. if (this.lights[t].id === e)
  22156. return this.lights[t];
  22157. return null
  22158. }
  22159. ,
  22160. t.prototype.getLightByUniqueId = function(e) {
  22161. for (var t = 0; t < this.lights.length; t++)
  22162. if (this.lights[t].uniqueId === e)
  22163. return this.lights[t];
  22164. return null
  22165. }
  22166. ,
  22167. t.prototype.getParticleSystemById = function(e) {
  22168. for (var t = 0; t < this.particleSystems.length; t++)
  22169. if (this.particleSystems[t].id === e)
  22170. return this.particleSystems[t];
  22171. return null
  22172. }
  22173. ,
  22174. t.prototype.getGeometryById = function(e) {
  22175. for (var t = 0; t < this.geometries.length; t++)
  22176. if (this.geometries[t].id === e)
  22177. return this.geometries[t];
  22178. return null
  22179. }
  22180. ,
  22181. t.prototype._getGeometryByUniqueId = function(e) {
  22182. if (this._geometriesByUniqueId) {
  22183. if (void 0 !== (t = this._geometriesByUniqueId[e]))
  22184. return this.geometries[t]
  22185. } else
  22186. for (var t = 0; t < this.geometries.length; t++)
  22187. if (this.geometries[t].uniqueId === e)
  22188. return this.geometries[t];
  22189. return null
  22190. }
  22191. ,
  22192. t.prototype.pushGeometry = function(e, t) {
  22193. return !(!t && this._getGeometryByUniqueId(e.uniqueId) || (this.addGeometry(e),
  22194. this.onNewGeometryAddedObservable.notifyObservers(e),
  22195. 0))
  22196. }
  22197. ,
  22198. t.prototype.removeGeometry = function(e) {
  22199. var t;
  22200. if (this._geometriesByUniqueId) {
  22201. if (void 0 === (t = this._geometriesByUniqueId[e.uniqueId]))
  22202. return !1
  22203. } else if ((t = this.geometries.indexOf(e)) < 0)
  22204. return !1;
  22205. if (t !== this.geometries.length - 1) {
  22206. var i = this.geometries[this.geometries.length - 1];
  22207. i && (this.geometries[t] = i,
  22208. this._geometriesByUniqueId && (this._geometriesByUniqueId[i.uniqueId] = t,
  22209. this._geometriesByUniqueId[e.uniqueId] = void 0))
  22210. }
  22211. return this.geometries.pop(),
  22212. this.onGeometryRemovedObservable.notifyObservers(e),
  22213. !0
  22214. }
  22215. ,
  22216. t.prototype.getGeometries = function() {
  22217. return this.geometries
  22218. }
  22219. ,
  22220. t.prototype.getMeshById = function(e) {
  22221. for (var t = 0; t < this.meshes.length; t++)
  22222. if (this.meshes[t].id === e)
  22223. return this.meshes[t];
  22224. return null
  22225. }
  22226. ,
  22227. t.prototype.getMeshesById = function(e) {
  22228. return this.meshes.filter((function(t) {
  22229. return t.id === e
  22230. }
  22231. ))
  22232. }
  22233. ,
  22234. t.prototype.getTransformNodeById = function(e) {
  22235. for (var t = 0; t < this.transformNodes.length; t++)
  22236. if (this.transformNodes[t].id === e)
  22237. return this.transformNodes[t];
  22238. return null
  22239. }
  22240. ,
  22241. t.prototype.getTransformNodeByUniqueId = function(e) {
  22242. for (var t = 0; t < this.transformNodes.length; t++)
  22243. if (this.transformNodes[t].uniqueId === e)
  22244. return this.transformNodes[t];
  22245. return null
  22246. }
  22247. ,
  22248. t.prototype.getTransformNodesById = function(e) {
  22249. return this.transformNodes.filter((function(t) {
  22250. return t.id === e
  22251. }
  22252. ))
  22253. }
  22254. ,
  22255. t.prototype.getMeshByUniqueId = function(e) {
  22256. for (var t = 0; t < this.meshes.length; t++)
  22257. if (this.meshes[t].uniqueId === e)
  22258. return this.meshes[t];
  22259. return null
  22260. }
  22261. ,
  22262. t.prototype.getLastMeshById = function(e) {
  22263. for (var t = this.meshes.length - 1; t >= 0; t--)
  22264. if (this.meshes[t].id === e)
  22265. return this.meshes[t];
  22266. return null
  22267. }
  22268. ,
  22269. t.prototype.getLastEntryById = function(e) {
  22270. var t;
  22271. for (t = this.meshes.length - 1; t >= 0; t--)
  22272. if (this.meshes[t].id === e)
  22273. return this.meshes[t];
  22274. for (t = this.transformNodes.length - 1; t >= 0; t--)
  22275. if (this.transformNodes[t].id === e)
  22276. return this.transformNodes[t];
  22277. for (t = this.cameras.length - 1; t >= 0; t--)
  22278. if (this.cameras[t].id === e)
  22279. return this.cameras[t];
  22280. for (t = this.lights.length - 1; t >= 0; t--)
  22281. if (this.lights[t].id === e)
  22282. return this.lights[t];
  22283. return null
  22284. }
  22285. ,
  22286. t.prototype.getNodeById = function(e) {
  22287. var t = this.getMeshById(e);
  22288. if (t)
  22289. return t;
  22290. var i = this.getTransformNodeById(e);
  22291. if (i)
  22292. return i;
  22293. var n = this.getLightById(e);
  22294. if (n)
  22295. return n;
  22296. var r = this.getCameraById(e);
  22297. return r || (this.getBoneById(e) || null)
  22298. }
  22299. ,
  22300. t.prototype.getNodeByName = function(e) {
  22301. var t = this.getMeshByName(e);
  22302. if (t)
  22303. return t;
  22304. var i = this.getTransformNodeByName(e);
  22305. if (i)
  22306. return i;
  22307. var n = this.getLightByName(e);
  22308. if (n)
  22309. return n;
  22310. var r = this.getCameraByName(e);
  22311. return r || (this.getBoneByName(e) || null)
  22312. }
  22313. ,
  22314. t.prototype.getMeshByName = function(e) {
  22315. for (var t = 0; t < this.meshes.length; t++)
  22316. if (this.meshes[t].name === e)
  22317. return this.meshes[t];
  22318. return null
  22319. }
  22320. ,
  22321. t.prototype.getTransformNodeByName = function(e) {
  22322. for (var t = 0; t < this.transformNodes.length; t++)
  22323. if (this.transformNodes[t].name === e)
  22324. return this.transformNodes[t];
  22325. return null
  22326. }
  22327. ,
  22328. t.prototype.getLastSkeletonById = function(e) {
  22329. for (var t = this.skeletons.length - 1; t >= 0; t--)
  22330. if (this.skeletons[t].id === e)
  22331. return this.skeletons[t];
  22332. return null
  22333. }
  22334. ,
  22335. t.prototype.getSkeletonByUniqueId = function(e) {
  22336. for (var t = 0; t < this.skeletons.length; t++)
  22337. if (this.skeletons[t].uniqueId === e)
  22338. return this.skeletons[t];
  22339. return null
  22340. }
  22341. ,
  22342. t.prototype.getSkeletonById = function(e) {
  22343. for (var t = 0; t < this.skeletons.length; t++)
  22344. if (this.skeletons[t].id === e)
  22345. return this.skeletons[t];
  22346. return null
  22347. }
  22348. ,
  22349. t.prototype.getSkeletonByName = function(e) {
  22350. for (var t = 0; t < this.skeletons.length; t++)
  22351. if (this.skeletons[t].name === e)
  22352. return this.skeletons[t];
  22353. return null
  22354. }
  22355. ,
  22356. t.prototype.getMorphTargetManagerById = function(e) {
  22357. for (var t = 0; t < this.morphTargetManagers.length; t++)
  22358. if (this.morphTargetManagers[t].uniqueId === e)
  22359. return this.morphTargetManagers[t];
  22360. return null
  22361. }
  22362. ,
  22363. t.prototype.getMorphTargetById = function(e) {
  22364. for (var t = 0; t < this.morphTargetManagers.length; ++t)
  22365. for (var i = this.morphTargetManagers[t], n = 0; n < i.numTargets; ++n) {
  22366. var r = i.getTarget(n);
  22367. if (r.id === e)
  22368. return r
  22369. }
  22370. return null
  22371. }
  22372. ,
  22373. t.prototype.getMorphTargetByName = function(e) {
  22374. for (var t = 0; t < this.morphTargetManagers.length; ++t)
  22375. for (var i = this.morphTargetManagers[t], n = 0; n < i.numTargets; ++n) {
  22376. var r = i.getTarget(n);
  22377. if (r.name === e)
  22378. return r
  22379. }
  22380. return null
  22381. }
  22382. ,
  22383. t.prototype.getPostProcessByName = function(e) {
  22384. for (var t = 0; t < this.postProcesses.length; ++t) {
  22385. var i = this.postProcesses[t];
  22386. if (i.name === e)
  22387. return i
  22388. }
  22389. return null
  22390. }
  22391. ,
  22392. t.prototype.isActiveMesh = function(e) {
  22393. return -1 !== this._activeMeshes.indexOf(e)
  22394. }
  22395. ,
  22396. Object.defineProperty(t.prototype, "uid", {
  22397. get: function() {
  22398. return this._uid || (this._uid = gi.RandomId()),
  22399. this._uid
  22400. },
  22401. enumerable: !1,
  22402. configurable: !0
  22403. }),
  22404. t.prototype.addExternalData = function(e, t) {
  22405. return this._externalData || (this._externalData = new Ei),
  22406. this._externalData.add(e, t)
  22407. }
  22408. ,
  22409. t.prototype.getExternalData = function(e) {
  22410. return this._externalData ? this._externalData.get(e) : null
  22411. }
  22412. ,
  22413. t.prototype.getOrAddExternalDataWithFactory = function(e, t) {
  22414. return this._externalData || (this._externalData = new Ei),
  22415. this._externalData.getOrAddWithFactory(e, t)
  22416. }
  22417. ,
  22418. t.prototype.removeExternalData = function(e) {
  22419. return this._externalData.remove(e)
  22420. }
  22421. ,
  22422. t.prototype._evaluateSubMesh = function(e, t, i) {
  22423. if (i.hasInstances || i.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || t.alwaysSelectAsActiveMesh || 1 === t.subMeshes.length || e.isInFrustum(this._frustumPlanes)) {
  22424. for (var n = 0, r = this._evaluateSubMeshStage; n < r.length; n++)
  22425. r[n].action(t, e);
  22426. var o = e.getMaterial();
  22427. null != o && (o.hasRenderTargetTextures && null != o.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(o) && (this._processedMaterials.push(o),
  22428. this._materialsRenderTargets.concatWithNoDuplicate(o.getRenderTargetTextures())),
  22429. this._renderingManager.dispatch(e, t, o))
  22430. }
  22431. }
  22432. ,
  22433. t.prototype.freeProcessedMaterials = function() {
  22434. this._processedMaterials.dispose()
  22435. }
  22436. ,
  22437. Object.defineProperty(t.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  22438. get: function() {
  22439. return this._preventFreeActiveMeshesAndRenderingGroups
  22440. },
  22441. set: function(e) {
  22442. this._preventFreeActiveMeshesAndRenderingGroups !== e && (e && (this.freeActiveMeshes(),
  22443. this.freeRenderingGroups()),
  22444. this._preventFreeActiveMeshesAndRenderingGroups = e)
  22445. },
  22446. enumerable: !1,
  22447. configurable: !0
  22448. }),
  22449. t.prototype.freeActiveMeshes = function() {
  22450. if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(),
  22451. this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(),
  22452. this.activeCameras))
  22453. for (var e = 0; e < this.activeCameras.length; e++) {
  22454. var t = this.activeCameras[e];
  22455. t && t._activeMeshes && t._activeMeshes.dispose()
  22456. }
  22457. }
  22458. ,
  22459. t.prototype.freeRenderingGroups = function() {
  22460. if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(),
  22461. this.textures))
  22462. for (var e = 0; e < this.textures.length; e++) {
  22463. var t = this.textures[e];
  22464. t && t.renderList && t.freeRenderingGroups()
  22465. }
  22466. }
  22467. ,
  22468. t.prototype._isInIntermediateRendering = function() {
  22469. return this._intermediateRendering
  22470. }
  22471. ,
  22472. t.prototype.freezeActiveMeshes = function(e, t, i, n) {
  22473. var r = this;
  22474. return void 0 === e && (e = !1),
  22475. void 0 === n && (n = !0),
  22476. this.executeWhenReady((function() {
  22477. if (r.activeCamera) {
  22478. if (r._frustumPlanes || r.updateTransformMatrix(),
  22479. r._evaluateActiveMeshes(),
  22480. r._activeMeshesFrozen = !0,
  22481. r._skipEvaluateActiveMeshesCompletely = e,
  22482. n)
  22483. for (var o = 0; o < r._activeMeshes.length; o++)
  22484. r._activeMeshes.data[o]._freeze();
  22485. t && t()
  22486. } else
  22487. i && i("No active camera found")
  22488. }
  22489. )),
  22490. this
  22491. }
  22492. ,
  22493. t.prototype.unfreezeActiveMeshes = function() {
  22494. for (var e = 0; e < this.meshes.length; e++) {
  22495. var t = this.meshes[e];
  22496. t._internalAbstractMeshDataInfo && (t._internalAbstractMeshDataInfo._isActive = !1)
  22497. }
  22498. for (e = 0; e < this._activeMeshes.length; e++)
  22499. this._activeMeshes.data[e]._unFreeze();
  22500. return this._activeMeshesFrozen = !1,
  22501. this
  22502. }
  22503. ,
  22504. t.prototype._executeActiveContainerCleanup = function(e) {
  22505. (!this._engine.snapshotRendering || this._engine.snapshotRenderingMode !== a.SNAPSHOTRENDERING_FAST) && this._activeMeshesFrozen && this._activeMeshes.length || this.onBeforeRenderObservable.addOnce((function() {
  22506. return e.dispose()
  22507. }
  22508. ))
  22509. }
  22510. ,
  22511. t.prototype._evaluateActiveMeshes = function() {
  22512. var e;
  22513. if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST)
  22514. this._activeMeshes.length > 0 && (null === (e = this.activeCamera) || void 0 === e || e._activeMeshes.reset(),
  22515. this._activeMeshes.reset(),
  22516. this._renderingManager.reset(),
  22517. this._processedMaterials.reset(),
  22518. this._activeParticleSystems.reset(),
  22519. this._activeSkeletons.reset(),
  22520. this._softwareSkinnedMeshes.reset());
  22521. else if (this._activeMeshesFrozen && this._activeMeshes.length) {
  22522. if (!this._skipEvaluateActiveMeshesCompletely)
  22523. for (var t = this._activeMeshes.length, i = 0; i < t; i++)
  22524. (c = this._activeMeshes.data[i]).computeWorldMatrix();
  22525. if (this._activeParticleSystems) {
  22526. var n = this._activeParticleSystems.length;
  22527. for (i = 0; i < n; i++)
  22528. this._activeParticleSystems.data[i].animate()
  22529. }
  22530. } else if (this.activeCamera) {
  22531. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),
  22532. this.activeCamera._activeMeshes.reset(),
  22533. this._activeMeshes.reset(),
  22534. this._renderingManager.reset(),
  22535. this._processedMaterials.reset(),
  22536. this._activeParticleSystems.reset(),
  22537. this._activeSkeletons.reset(),
  22538. this._softwareSkinnedMeshes.reset(),
  22539. this._materialsRenderTargets.reset();
  22540. for (var r = 0, o = this._beforeEvaluateActiveMeshStage; r < o.length; r++)
  22541. o[r].action();
  22542. var s = this.getActiveMeshCandidates()
  22543. , l = s.length;
  22544. for (i = 0; i < l; i++) {
  22545. var c;
  22546. if ((c = s.data[i])._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1,
  22547. !c.isBlocked && (this._totalVertices.addCount(c.getTotalVertices(), !1),
  22548. c.isReady() && c.isEnabled() && 0 !== c.scaling.lengthSquared())) {
  22549. c.computeWorldMatrix(),
  22550. c.actionManager && c.actionManager.hasSpecificTriggers2(a.ACTION_OnIntersectionEnterTrigger, a.ACTION_OnIntersectionExitTrigger) && this._meshesForIntersections.pushNoDuplicate(c);
  22551. var u = this.customLODSelector ? this.customLODSelector(c, this.activeCamera) : c.getLOD(this.activeCamera);
  22552. if (c._internalAbstractMeshDataInfo._currentLOD = u,
  22553. c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0,
  22554. null != u && (u !== c && 0 !== u.billboardMode && u.computeWorldMatrix(),
  22555. c._preActivate(),
  22556. c.isVisible && c.visibility > 0 && 0 != (c.layerMask & this.activeCamera.layerMask) && (this._skipFrustumClipping || c.alwaysSelectAsActiveMesh || c.isInFrustum(this._frustumPlanes)))) {
  22557. this._activeMeshes.push(c),
  22558. this.activeCamera._activeMeshes.push(c),
  22559. u !== c && u._activate(this._renderId, !1);
  22560. for (var h = 0, d = this._preActiveMeshStage; h < d.length; h++)
  22561. d[h].action(c);
  22562. c._activate(this._renderId, !1) && (c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (u = c) : u._internalAbstractMeshDataInfo._onlyForInstances = !1,
  22563. u._internalAbstractMeshDataInfo._isActive = !0,
  22564. this._activeMesh(c, u)),
  22565. c._postActivate()
  22566. }
  22567. }
  22568. }
  22569. if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),
  22570. this.particlesEnabled) {
  22571. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  22572. for (var p = 0; p < this.particleSystems.length; p++) {
  22573. var f = this.particleSystems[p];
  22574. if (f.isStarted() && f.emitter) {
  22575. var _ = f.emitter;
  22576. _.position && !_.isEnabled() || (this._activeParticleSystems.push(f),
  22577. f.animate(),
  22578. this._renderingManager.dispatchParticles(f))
  22579. }
  22580. }
  22581. this.onAfterParticlesRenderingObservable.notifyObservers(this)
  22582. }
  22583. }
  22584. }
  22585. ,
  22586. t.prototype._activeMesh = function(e, t) {
  22587. if (this._skeletonsEnabled && null !== t.skeleton && void 0 !== t.skeleton && (this._activeSkeletons.pushNoDuplicate(t.skeleton) && (t.skeleton.prepare(),
  22588. this._activeBones.addCount(t.skeleton.bones.length, !1)),
  22589. t.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(t)),
  22590. null != t && void 0 !== t.subMeshes && null !== t.subMeshes && t.subMeshes.length > 0)
  22591. for (var i = this.getActiveSubMeshCandidates(t), n = i.length, r = 0; r < n; r++) {
  22592. var o = i.data[r];
  22593. this._evaluateSubMesh(o, t, e)
  22594. }
  22595. }
  22596. ,
  22597. t.prototype.updateTransformMatrix = function(e) {
  22598. if (this.activeCamera)
  22599. if (this.activeCamera._renderingMultiview) {
  22600. var t = this.activeCamera._rigCameras[0]
  22601. , i = this.activeCamera._rigCameras[1];
  22602. this.setTransformMatrix(t.getViewMatrix(), t.getProjectionMatrix(e), i.getViewMatrix(), i.getProjectionMatrix(e))
  22603. } else
  22604. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(e))
  22605. }
  22606. ,
  22607. t.prototype._bindFrameBuffer = function(e, t) {
  22608. void 0 === t && (t = !0),
  22609. e && e._multiviewTexture ? e._multiviewTexture._bindFrameBuffer() : e && e.outputRenderTarget ? e.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(),
  22610. t && this._clearFrameBuffer(e)
  22611. }
  22612. ,
  22613. t.prototype._clearFrameBuffer = function(e) {
  22614. if (e && e._multiviewTexture)
  22615. ;
  22616. else if (e && e.outputRenderTarget) {
  22617. var t = e.outputRenderTarget;
  22618. t.onClearObservable.hasObservers() ? t.onClearObservable.notifyObservers(this._engine) : t.skipInitialClear || (this._engine.clear(t.clearColor || this.clearColor, !t._cleared, !0, !0),
  22619. t._cleared = !0)
  22620. } else
  22621. this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0,
  22622. this._clear())
  22623. }
  22624. ,
  22625. t.prototype._renderForCamera = function(e, t, i) {
  22626. var n, r, o;
  22627. if (void 0 === i && (i = !0),
  22628. !e || !e._skipRendering) {
  22629. var s = this._engine;
  22630. if (this._activeCamera = e,
  22631. !this.activeCamera)
  22632. throw new Error("Active camera not set");
  22633. if (s.setViewport(this.activeCamera.viewport),
  22634. this.resetCachedMaterial(),
  22635. this._renderId++,
  22636. !this.prePass && i) {
  22637. var l = !0;
  22638. e._renderingMultiview && e.outputRenderTarget && (l = e.outputRenderTarget.skipInitialClear,
  22639. this.autoClear && (e.outputRenderTarget.skipInitialClear = !1)),
  22640. this._bindFrameBuffer(this._activeCamera),
  22641. e._renderingMultiview && e.outputRenderTarget && (e.outputRenderTarget.skipInitialClear = l)
  22642. }
  22643. this.updateTransformMatrix(),
  22644. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),
  22645. this._evaluateActiveMeshes();
  22646. for (var c = 0; c < this._softwareSkinnedMeshes.length; c++) {
  22647. var u = this._softwareSkinnedMeshes.data[c];
  22648. u.applySkeleton(u.skeleton)
  22649. }
  22650. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),
  22651. this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),
  22652. e.customRenderTargets && e.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),
  22653. t && t.customRenderTargets && t.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),
  22654. this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
  22655. for (var h = 0, d = this._gatherActiveCameraRenderTargetsStage; h < d.length; h++)
  22656. d[h].action(this._renderTargets);
  22657. var p = !1;
  22658. if (this.renderTargetsEnabled) {
  22659. if (this._intermediateRendering = !0,
  22660. this._renderTargets.length > 0) {
  22661. gi.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  22662. for (var f = 0; f < this._renderTargets.length; f++) {
  22663. var _ = this._renderTargets.data[f];
  22664. if (_._shouldRender()) {
  22665. this._renderId++;
  22666. var m = _.activeCamera && _.activeCamera !== this.activeCamera;
  22667. _.render(m, this.dumpNextRenderTargets),
  22668. p = !0
  22669. }
  22670. }
  22671. gi.EndPerformanceCounter("Render targets", this._renderTargets.length > 0),
  22672. this._renderId++
  22673. }
  22674. for (var g = 0, v = this._cameraDrawRenderTargetStage; g < v.length; g++)
  22675. p = v[g].action(this.activeCamera) || p;
  22676. this._intermediateRendering = !1
  22677. }
  22678. this._engine.currentRenderPassId = null !== (o = null !== (r = null === (n = e.outputRenderTarget) || void 0 === n ? void 0 : n.renderPassId) && void 0 !== r ? r : e.renderPassId) && void 0 !== o ? o : a.RENDERPASS_MAIN,
  22679. p && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
  22680. this.onAfterRenderTargetsRenderObservable.notifyObservers(this),
  22681. !this.postProcessManager || e._multiviewTexture || this.prePass || this.postProcessManager._prepareFrame();
  22682. for (var y = 0, b = this._beforeCameraDrawStage; y < b.length; y++)
  22683. b[y].action(this.activeCamera);
  22684. this.onBeforeDrawPhaseObservable.notifyObservers(this),
  22685. s.snapshotRendering && s.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this.finalizeSceneUbo(),
  22686. this._renderingManager.render(null, null, !0, !0),
  22687. this.onAfterDrawPhaseObservable.notifyObservers(this);
  22688. for (var T = 0, E = this._afterCameraDrawStage; T < E.length; T++)
  22689. E[T].action(this.activeCamera);
  22690. if (this.postProcessManager && !e._multiviewTexture) {
  22691. var S = e.outputRenderTarget ? e.outputRenderTarget.renderTarget : void 0;
  22692. this.postProcessManager._finalizeFrame(e.isIntermediate, S)
  22693. }
  22694. this._renderTargets.reset(),
  22695. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)
  22696. }
  22697. }
  22698. ,
  22699. t.prototype._processSubCameras = function(e, t) {
  22700. if (void 0 === t && (t = !0),
  22701. e.cameraRigMode === a.RIG_MODE_NONE || e._renderingMultiview)
  22702. return e._renderingMultiview && !this._multiviewSceneUbo && this._createMultiviewUbo(),
  22703. this._renderForCamera(e, void 0, t),
  22704. void this.onAfterRenderCameraObservable.notifyObservers(e);
  22705. if (e._useMultiviewToSingleView)
  22706. this._renderMultiviewToSingleView(e);
  22707. else {
  22708. this.onBeforeCameraRenderObservable.notifyObservers(e);
  22709. for (var i = 0; i < e._rigCameras.length; i++)
  22710. this._renderForCamera(e._rigCameras[i], e)
  22711. }
  22712. this._activeCamera = e,
  22713. this.updateTransformMatrix(),
  22714. this.onAfterRenderCameraObservable.notifyObservers(e)
  22715. }
  22716. ,
  22717. t.prototype._checkIntersections = function() {
  22718. for (var e = 0; e < this._meshesForIntersections.length; e++) {
  22719. var t = this._meshesForIntersections.data[e];
  22720. if (t.actionManager)
  22721. for (var i = function(e) {
  22722. var i = t.actionManager.actions[e];
  22723. if (i.trigger === a.ACTION_OnIntersectionEnterTrigger || i.trigger === a.ACTION_OnIntersectionExitTrigger) {
  22724. var n = i.getTriggerParameter()
  22725. , r = n.mesh ? n.mesh : n
  22726. , o = r.intersectsMesh(t, n.usePreciseIntersection)
  22727. , s = t._intersectionsInProgress.indexOf(r);
  22728. o && -1 === s ? i.trigger === a.ACTION_OnIntersectionEnterTrigger ? (i._executeCurrent(w.CreateNew(t, void 0, r)),
  22729. t._intersectionsInProgress.push(r)) : i.trigger === a.ACTION_OnIntersectionExitTrigger && t._intersectionsInProgress.push(r) : !o && s > -1 && (i.trigger === a.ACTION_OnIntersectionExitTrigger && i._executeCurrent(w.CreateNew(t, void 0, r)),
  22730. t.actionManager.hasSpecificTrigger(a.ACTION_OnIntersectionExitTrigger, (function(e) {
  22731. var t = e.mesh ? e.mesh : e;
  22732. return r === t
  22733. }
  22734. )) && i.trigger !== a.ACTION_OnIntersectionExitTrigger || t._intersectionsInProgress.splice(s, 1))
  22735. }
  22736. }, n = 0; t.actionManager && n < t.actionManager.actions.length; n++)
  22737. i(n)
  22738. }
  22739. }
  22740. ,
  22741. t.prototype._advancePhysicsEngineStep = function(e) {}
  22742. ,
  22743. t.prototype._animate = function() {}
  22744. ,
  22745. t.prototype.animate = function() {
  22746. if (this._engine.isDeterministicLockStep()) {
  22747. var e = Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)) + this._timeAccumulator
  22748. , i = this._engine.getTimeStep()
  22749. , n = 1e3 / i / 1e3
  22750. , r = 0
  22751. , o = this._engine.getLockstepMaxSteps()
  22752. , a = Math.floor(e / i);
  22753. for (a = Math.min(a, o); e > 0 && r < a; )
  22754. this.onBeforeStepObservable.notifyObservers(this),
  22755. this._animationRatio = i * n,
  22756. this._animate(),
  22757. this.onAfterAnimationsObservable.notifyObservers(this),
  22758. this.physicsEnabled && this._advancePhysicsEngineStep(i),
  22759. this.onAfterStepObservable.notifyObservers(this),
  22760. this._currentStepId++,
  22761. r++,
  22762. e -= i;
  22763. this._timeAccumulator = e < 0 ? 0 : e
  22764. } else
  22765. e = this.useConstantAnimationDeltaTime ? 16 : Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)),
  22766. this._animationRatio = .06 * e,
  22767. this._animate(),
  22768. this.onAfterAnimationsObservable.notifyObservers(this),
  22769. this.physicsEnabled && this._advancePhysicsEngineStep(e)
  22770. }
  22771. ,
  22772. t.prototype._clear = function() {
  22773. (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil)
  22774. }
  22775. ,
  22776. t.prototype._checkCameraRenderTarget = function(e) {
  22777. var t;
  22778. if ((null == e ? void 0 : e.outputRenderTarget) && !(null == e ? void 0 : e.isRigCamera) && (e.outputRenderTarget._cleared = !1),
  22779. null === (t = null == e ? void 0 : e.rigCameras) || void 0 === t ? void 0 : t.length)
  22780. for (var i = 0; i < e.rigCameras.length; ++i) {
  22781. var n = e.rigCameras[i].outputRenderTarget;
  22782. n && (n._cleared = !1)
  22783. }
  22784. }
  22785. ,
  22786. t.prototype.resetDrawCache = function(e) {
  22787. if (this.meshes)
  22788. for (var t = 0, i = this.meshes; t < i.length; t++)
  22789. i[t].resetDrawCache(e)
  22790. }
  22791. ,
  22792. t.prototype.render = function(e, t) {
  22793. var i, n, r;
  22794. if (void 0 === e && (e = !0),
  22795. void 0 === t && (t = !1),
  22796. !this.isDisposed) {
  22797. this.onReadyObservable.hasObservers() && null === this._executeWhenReadyTimeoutId && this._checkIsReady(),
  22798. this._frameId++,
  22799. this._defaultFrameBufferCleared = !1,
  22800. this._checkCameraRenderTarget(this.activeCamera),
  22801. (null === (i = this.activeCameras) || void 0 === i ? void 0 : i.length) && this.activeCameras.forEach(this._checkCameraRenderTarget),
  22802. this._registerTransientComponents(),
  22803. this._activeParticles.fetchNewFrame(),
  22804. this._totalVertices.fetchNewFrame(),
  22805. this._activeIndices.fetchNewFrame(),
  22806. this._activeBones.fetchNewFrame(),
  22807. this._meshesForIntersections.reset(),
  22808. this.resetCachedMaterial(),
  22809. this.onBeforeAnimationsObservable.notifyObservers(this),
  22810. this.actionManager && this.actionManager.processTrigger(a.ACTION_OnEveryFrameTrigger),
  22811. t || this.animate();
  22812. for (var o = 0, s = this._beforeCameraUpdateStage; o < s.length; o++)
  22813. s[o].action();
  22814. if (e)
  22815. if (this.activeCameras && this.activeCameras.length > 0)
  22816. for (var l = 0; l < this.activeCameras.length; l++) {
  22817. var c = this.activeCameras[l];
  22818. if (c.update(),
  22819. c.cameraRigMode !== a.RIG_MODE_NONE)
  22820. for (var u = 0; u < c._rigCameras.length; u++)
  22821. c._rigCameras[u].update()
  22822. }
  22823. else if (this.activeCamera && (this.activeCamera.update(),
  22824. this.activeCamera.cameraRigMode !== a.RIG_MODE_NONE))
  22825. for (u = 0; u < this.activeCamera._rigCameras.length; u++)
  22826. this.activeCamera._rigCameras[u].update();
  22827. this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
  22828. this.onBeforeRenderObservable.notifyObservers(this),
  22829. this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
  22830. this.onBeforeRenderObservable.notifyObservers(this);
  22831. var h = this.getEngine();
  22832. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  22833. var d = (null === (n = this.activeCameras) || void 0 === n ? void 0 : n.length) ? this.activeCameras[0] : this.activeCamera;
  22834. if (this.renderTargetsEnabled) {
  22835. gi.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
  22836. this._intermediateRendering = !0;
  22837. for (var p = 0; p < this.customRenderTargets.length; p++) {
  22838. var f = this.customRenderTargets[p];
  22839. if (f._shouldRender()) {
  22840. if (this._renderId++,
  22841. this.activeCamera = f.activeCamera || this.activeCamera,
  22842. !this.activeCamera)
  22843. throw new Error("Active camera not set");
  22844. h.setViewport(this.activeCamera.viewport),
  22845. this.updateTransformMatrix(),
  22846. f.render(d !== this.activeCamera, this.dumpNextRenderTargets)
  22847. }
  22848. }
  22849. gi.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
  22850. this._intermediateRendering = !1,
  22851. this._renderId++
  22852. }
  22853. this._engine.currentRenderPassId = null !== (r = null == d ? void 0 : d.renderPassId) && void 0 !== r ? r : a.RENDERPASS_MAIN,
  22854. this.activeCamera = d,
  22855. this._activeCamera && this._activeCamera.cameraRigMode !== a.RIG_MODE_CUSTOM && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
  22856. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  22857. for (var _ = 0, m = this._beforeClearStage; _ < m.length; _++)
  22858. m[_].action();
  22859. this._clearFrameBuffer(this.activeCamera);
  22860. for (var g = 0, v = this._gatherRenderTargetsStage; g < v.length; g++)
  22861. v[g].action(this._renderTargets);
  22862. if (this.activeCameras && this.activeCameras.length > 0)
  22863. for (l = 0; l < this.activeCameras.length; l++)
  22864. this._processSubCameras(this.activeCameras[l], l > 0);
  22865. else {
  22866. if (!this.activeCamera)
  22867. throw new Error("No camera defined");
  22868. this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget)
  22869. }
  22870. this._checkIntersections();
  22871. for (var y = 0, b = this._afterRenderStage; y < b.length; y++)
  22872. b[y].action();
  22873. if (this.afterRender && this.afterRender(),
  22874. this.onAfterRenderObservable.notifyObservers(this),
  22875. this._toBeDisposed.length) {
  22876. for (u = 0; u < this._toBeDisposed.length; u++) {
  22877. var T = this._toBeDisposed[u];
  22878. T && T.dispose()
  22879. }
  22880. this._toBeDisposed = []
  22881. }
  22882. this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1),
  22883. this._activeBones.addCount(0, !0),
  22884. this._activeIndices.addCount(0, !0),
  22885. this._activeParticles.addCount(0, !0),
  22886. this._engine.restoreDefaultFramebuffer()
  22887. }
  22888. }
  22889. ,
  22890. t.prototype.freezeMaterials = function() {
  22891. for (var e = 0; e < this.materials.length; e++)
  22892. this.materials[e].freeze()
  22893. }
  22894. ,
  22895. t.prototype.unfreezeMaterials = function() {
  22896. for (var e = 0; e < this.materials.length; e++)
  22897. this.materials[e].unfreeze()
  22898. }
  22899. ,
  22900. t.prototype.dispose = function() {
  22901. var e;
  22902. if (!this.isDisposed) {
  22903. this.beforeRender = null,
  22904. this.afterRender = null,
  22905. this.metadata = null,
  22906. this.skeletons = [],
  22907. this.morphTargetManagers = [],
  22908. this._transientComponents = [],
  22909. this._isReadyForMeshStage.clear(),
  22910. this._beforeEvaluateActiveMeshStage.clear(),
  22911. this._evaluateSubMeshStage.clear(),
  22912. this._preActiveMeshStage.clear(),
  22913. this._cameraDrawRenderTargetStage.clear(),
  22914. this._beforeCameraDrawStage.clear(),
  22915. this._beforeRenderTargetDrawStage.clear(),
  22916. this._beforeRenderingGroupDrawStage.clear(),
  22917. this._beforeRenderingMeshStage.clear(),
  22918. this._afterRenderingMeshStage.clear(),
  22919. this._afterRenderingGroupDrawStage.clear(),
  22920. this._afterCameraDrawStage.clear(),
  22921. this._afterRenderTargetDrawStage.clear(),
  22922. this._afterRenderStage.clear(),
  22923. this._beforeCameraUpdateStage.clear(),
  22924. this._beforeClearStage.clear(),
  22925. this._gatherRenderTargetsStage.clear(),
  22926. this._gatherActiveCameraRenderTargetsStage.clear(),
  22927. this._pointerMoveStage.clear(),
  22928. this._pointerDownStage.clear(),
  22929. this._pointerUpStage.clear(),
  22930. this.importedMeshesFiles = new Array,
  22931. this.stopAllAnimations && this.stopAllAnimations(),
  22932. this.resetCachedMaterial(),
  22933. this.activeCamera && (this.activeCamera._activeMeshes.dispose(),
  22934. this.activeCamera = null),
  22935. this._activeMeshes.dispose(),
  22936. this._renderingManager.dispose(),
  22937. this._processedMaterials.dispose(),
  22938. this._activeParticleSystems.dispose(),
  22939. this._activeSkeletons.dispose(),
  22940. this._softwareSkinnedMeshes.dispose(),
  22941. this._renderTargets.dispose(),
  22942. this._materialsRenderTargets.dispose(),
  22943. this._registeredForLateAnimationBindings.dispose(),
  22944. this._meshesForIntersections.dispose(),
  22945. this._toBeDisposed = [];
  22946. for (var t = 0, i = this._activeRequests.slice(); t < i.length; t++)
  22947. i[t].abort();
  22948. this.onBeforeRunRegisterBeforeRenderObservable.clear(),
  22949. this.onAfterRunRegisterBeforeRenderObservable.clear(),
  22950. this.onBeforeRTT1Observable.clear(),
  22951. this.onAfterRTT1Observable.clear(),
  22952. this.onBeforeRunRegisterAfterRenderObservable.clear(),
  22953. this.onAfterRunRegisterAfterRenderObservable.clear()
  22954. if (this._activeRequests = [],
  22955. this.onDisposeObservable.notifyObservers(this),
  22956. this.onDisposeObservable.clear(),
  22957. this.onBeforeRenderObservable.clear(),
  22958. this.onAfterRenderObservable.clear(),
  22959. this.onBeforeRenderTargetsRenderObservable.clear(),
  22960. this.onAfterRenderTargetsRenderObservable.clear(),
  22961. this.onAfterStepObservable.clear(),
  22962. this.onBeforeStepObservable.clear(),
  22963. this.onBeforeActiveMeshesEvaluationObservable.clear(),
  22964. this.onAfterActiveMeshesEvaluationObservable.clear(),
  22965. this.onBeforeParticlesRenderingObservable.clear(),
  22966. this.onAfterParticlesRenderingObservable.clear(),
  22967. this.onBeforeDrawPhaseObservable.clear(),
  22968. this.onAfterDrawPhaseObservable.clear(),
  22969. this.onBeforeAnimationsObservable.clear(),
  22970. this.onAfterAnimationsObservable.clear(),
  22971. this.onDataLoadedObservable.clear(),
  22972. this.onBeforeRenderingGroupObservable.clear(),
  22973. this.onAfterRenderingGroupObservable.clear(),
  22974. this.onMeshImportedObservable.clear(),
  22975. this.onBeforeCameraRenderObservable.clear(),
  22976. this.onAfterCameraRenderObservable.clear(),
  22977. this.onReadyObservable.clear(),
  22978. this.onNewCameraAddedObservable.clear(),
  22979. this.onCameraRemovedObservable.clear(),
  22980. this.onNewLightAddedObservable.clear(),
  22981. this.onLightRemovedObservable.clear(),
  22982. this.onNewGeometryAddedObservable.clear(),
  22983. this.onGeometryRemovedObservable.clear(),
  22984. this.onNewTransformNodeAddedObservable.clear(),
  22985. this.onTransformNodeRemovedObservable.clear(),
  22986. this.onNewMeshAddedObservable.clear(),
  22987. this.onMeshRemovedObservable.clear(),
  22988. this.onNewSkeletonAddedObservable.clear(),
  22989. this.onSkeletonRemovedObservable.clear(),
  22990. this.onNewMaterialAddedObservable.clear(),
  22991. this.onNewMultiMaterialAddedObservable.clear(),
  22992. this.onMaterialRemovedObservable.clear(),
  22993. this.onMultiMaterialRemovedObservable.clear(),
  22994. this.onNewTextureAddedObservable.clear(),
  22995. this.onTextureRemovedObservable.clear(),
  22996. this.onPrePointerObservable.clear(),
  22997. this.onPointerObservable.clear(),
  22998. this.onPreKeyboardObservable.clear(),
  22999. this.onKeyboardObservable.clear(),
  23000. this.onActiveCameraChanged.clear(),
  23001. this.onComputePressureChanged.clear(),
  23002. null === (e = this._computePressureObserver) || void 0 === e || e.unobserve(),
  23003. this._computePressureObserver = void 0,
  23004. this.detachControl(),
  23005. this._engine.getInputElement())
  23006. for (var n = 0; n < this.cameras.length; n++)
  23007. this.cameras[n].detachControl();
  23008. for (; this.animationGroups.length; )
  23009. this.animationGroups[0].dispose();
  23010. for (; this.lights.length; )
  23011. this.lights[0].dispose();
  23012. for (; this.meshes.length; )
  23013. this.meshes[0].dispose(!0);
  23014. for (; this.transformNodes.length; )
  23015. this.transformNodes[0].dispose(!0);
  23016. for (; this.cameras.length; )
  23017. this.cameras[0].dispose();
  23018. for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
  23019. this.multiMaterials[0].dispose();
  23020. for (; this.materials.length; )
  23021. this.materials[0].dispose();
  23022. for (; this.particleSystems.length; )
  23023. this.particleSystems[0].dispose();
  23024. for (; this.postProcesses.length; )
  23025. this.postProcesses[0].dispose();
  23026. for (; this.textures.length; )
  23027. this.textures[0].dispose();
  23028. for (; this.morphTargetManagers.length; )
  23029. this.morphTargetManagers[0].dispose();
  23030. this._sceneUbo.dispose(),
  23031. this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(),
  23032. this.postProcessManager.dispose();
  23033. for (var r = 0, o = this._components; r < o.length; r++)
  23034. o[r].dispose();
  23035. var a = this._engine.scenes.indexOf(this);
  23036. a > -1 && this._engine.scenes.splice(a, 1),
  23037. E._LastCreatedScene === this && (this._engine.scenes.length > 0 ? E._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : E._LastCreatedScene = null),
  23038. (a = this._engine._virtualScenes.indexOf(this)) > -1 && this._engine._virtualScenes.splice(a, 1),
  23039. this._engine.wipeCaches(!0),
  23040. this._isDisposed = !0
  23041. }
  23042. }
  23043. ,
  23044. Object.defineProperty(t.prototype, "isDisposed", {
  23045. get: function() {
  23046. return this._isDisposed
  23047. },
  23048. enumerable: !1,
  23049. configurable: !0
  23050. }),
  23051. t.prototype.clearCachedVertexData = function() {
  23052. for (var e = 0; e < this.meshes.length; e++) {
  23053. var t = this.meshes[e].geometry;
  23054. t && t.clearCachedData()
  23055. }
  23056. }
  23057. ,
  23058. t.prototype.cleanCachedTextureBuffer = function() {
  23059. for (var e = 0, t = this.textures; e < t.length; e++) {
  23060. var i = t[e];
  23061. i._buffer && (i._buffer = null)
  23062. }
  23063. }
  23064. ,
  23065. t.prototype.getWorldExtends = function(e) {
  23066. var t = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  23067. , i = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  23068. return e = e || function() {
  23069. return !0
  23070. }
  23071. ,
  23072. this.meshes.filter(e).forEach((function(e) {
  23073. if (e.computeWorldMatrix(!0),
  23074. e.subMeshes && 0 !== e.subMeshes.length && !e.infiniteDistance) {
  23075. var n = e.getBoundingInfo()
  23076. , r = n.boundingBox.minimumWorld
  23077. , o = n.boundingBox.maximumWorld;
  23078. x.CheckExtends(r, t, i),
  23079. x.CheckExtends(o, t, i)
  23080. }
  23081. }
  23082. )),
  23083. {
  23084. min: t,
  23085. max: i
  23086. }
  23087. }
  23088. ,
  23089. t.prototype.createPickingRay = function(e, t, i, n, r) {
  23090. throw void 0 === r && (r = !1),
  23091. be("Ray")
  23092. }
  23093. ,
  23094. t.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
  23095. throw void 0 === o && (o = !1),
  23096. void 0 === a && (a = !1),
  23097. be("Ray")
  23098. }
  23099. ,
  23100. t.prototype.createPickingRayInCameraSpace = function(e, t, i) {
  23101. throw be("Ray")
  23102. }
  23103. ,
  23104. t.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
  23105. throw be("Ray")
  23106. }
  23107. ,
  23108. t.prototype.pick = function(e, t, i, n, r, o) {
  23109. var a = new Ui;
  23110. return a._pickingUnavailable = !0,
  23111. a
  23112. }
  23113. ,
  23114. t.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
  23115. var o = new Ui;
  23116. return o._pickingUnavailable = !0,
  23117. o
  23118. }
  23119. ,
  23120. t.prototype.pickWithRay = function(e, t, i, n) {
  23121. throw be("Ray")
  23122. }
  23123. ,
  23124. t.prototype.multiPick = function(e, t, i, n, r) {
  23125. throw be("Ray")
  23126. }
  23127. ,
  23128. t.prototype.multiPickWithRay = function(e, t, i) {
  23129. throw be("Ray")
  23130. }
  23131. ,
  23132. t.prototype.setPointerOverMesh = function(e, t, i) {
  23133. this._inputManager.setPointerOverMesh(e, t, i)
  23134. }
  23135. ,
  23136. t.prototype.getPointerOverMesh = function() {
  23137. return this._inputManager.getPointerOverMesh()
  23138. }
  23139. ,
  23140. t.prototype._rebuildGeometries = function() {
  23141. for (var e = 0, t = this.geometries; e < t.length; e++)
  23142. t[e]._rebuild();
  23143. for (var i = 0, n = this.meshes; i < n.length; i++)
  23144. n[i]._rebuild();
  23145. this.postProcessManager && this.postProcessManager._rebuild();
  23146. for (var r = 0, o = this._components; r < o.length; r++)
  23147. o[r].rebuild();
  23148. for (var a = 0, s = this.particleSystems; a < s.length; a++)
  23149. s[a].rebuild();
  23150. if (this.spriteManagers)
  23151. for (var l = 0, c = this.spriteManagers; l < c.length; l++)
  23152. c[l].rebuild()
  23153. }
  23154. ,
  23155. t.prototype._rebuildTextures = function() {
  23156. for (var e = 0, t = this.textures; e < t.length; e++)
  23157. t[e]._rebuild();
  23158. this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
  23159. }
  23160. ,
  23161. t.prototype._getByTags = function(e, t, i) {
  23162. if (void 0 === t)
  23163. return e;
  23164. var n = [];
  23165. for (var r in i = i || function(e) {}
  23166. ,
  23167. e) {
  23168. var o = e[r];
  23169. ye && ye.MatchesQuery(o, t) && (n.push(o),
  23170. i(o))
  23171. }
  23172. return n
  23173. }
  23174. ,
  23175. t.prototype.getMeshesByTags = function(e, t) {
  23176. return this._getByTags(this.meshes, e, t)
  23177. }
  23178. ,
  23179. t.prototype.getCamerasByTags = function(e, t) {
  23180. return this._getByTags(this.cameras, e, t)
  23181. }
  23182. ,
  23183. t.prototype.getLightsByTags = function(e, t) {
  23184. return this._getByTags(this.lights, e, t)
  23185. }
  23186. ,
  23187. t.prototype.getMaterialByTags = function(e, t) {
  23188. return this._getByTags(this.materials, e, t).concat(this._getByTags(this.multiMaterials, e, t))
  23189. }
  23190. ,
  23191. t.prototype.getTransformNodesByTags = function(e, t) {
  23192. return this._getByTags(this.transformNodes, e, t)
  23193. }
  23194. ,
  23195. t.prototype.setRenderingOrder = function(e, t, i, n) {
  23196. void 0 === t && (t = null),
  23197. void 0 === i && (i = null),
  23198. void 0 === n && (n = null),
  23199. this._renderingManager.setRenderingOrder(e, t, i, n)
  23200. }
  23201. ,
  23202. t.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
  23203. void 0 === i && (i = !0),
  23204. void 0 === n && (n = !0),
  23205. this._renderingManager.setRenderingAutoClearDepthStencil(e, t, i, n)
  23206. }
  23207. ,
  23208. t.prototype.getAutoClearDepthStencilSetup = function(e) {
  23209. return this._renderingManager.getAutoClearDepthStencilSetup(e)
  23210. }
  23211. ,
  23212. Object.defineProperty(t.prototype, "blockMaterialDirtyMechanism", {
  23213. get: function() {
  23214. return this._blockMaterialDirtyMechanism
  23215. },
  23216. set: function(e) {
  23217. this._blockMaterialDirtyMechanism !== e && (this._blockMaterialDirtyMechanism = e,
  23218. e || this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag))
  23219. },
  23220. enumerable: !1,
  23221. configurable: !0
  23222. }),
  23223. t.prototype.markAllMaterialsAsDirty = function(e, t) {
  23224. if (!this._blockMaterialDirtyMechanism)
  23225. for (var i = 0, n = this.materials; i < n.length; i++) {
  23226. var r = n[i];
  23227. t && !t(r) || r.markAsDirty(e)
  23228. }
  23229. }
  23230. ,
  23231. t.prototype._loadFile = function(e, t, i, n, r, o, a) {
  23232. var s = this
  23233. , l = ti(e, t, i, n ? this.offlineProvider : void 0, r, o, a);
  23234. return this._activeRequests.push(l),
  23235. l.onCompleteObservable.add((function(e) {
  23236. s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
  23237. }
  23238. )),
  23239. l
  23240. }
  23241. ,
  23242. t.prototype._loadFileAsync = function(e, t, i, n, r) {
  23243. var o = this;
  23244. return new Promise((function(a, s) {
  23245. o._loadFile(e, (function(e) {
  23246. a(e)
  23247. }
  23248. ), t, i, n, (function(e, t) {
  23249. s(t)
  23250. }
  23251. ), r)
  23252. }
  23253. ))
  23254. }
  23255. ,
  23256. t.prototype._requestFile = function(e, t, i, n, r, o, a) {
  23257. var s = this
  23258. , l = ii(e, t, i, n ? this.offlineProvider : void 0, r, o, a);
  23259. return this._activeRequests.push(l),
  23260. l.onCompleteObservable.add((function(e) {
  23261. s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
  23262. }
  23263. )),
  23264. l
  23265. }
  23266. ,
  23267. t.prototype._requestFileAsync = function(e, t, i, n, r) {
  23268. var o = this;
  23269. return new Promise((function(a, s) {
  23270. o._requestFile(e, (function(e) {
  23271. a(e)
  23272. }
  23273. ), t, i, n, (function(e) {
  23274. s(e)
  23275. }
  23276. ), r)
  23277. }
  23278. ))
  23279. }
  23280. ,
  23281. t.prototype._readFile = function(e, t, i, n, r) {
  23282. var o = this
  23283. , a = ei(e, t, i, n, r);
  23284. return this._activeRequests.push(a),
  23285. a.onCompleteObservable.add((function(e) {
  23286. o._activeRequests.splice(o._activeRequests.indexOf(e), 1)
  23287. }
  23288. )),
  23289. a
  23290. }
  23291. ,
  23292. t.prototype._readFileAsync = function(e, t, i) {
  23293. var n = this;
  23294. return new Promise((function(r, o) {
  23295. n._readFile(e, (function(e) {
  23296. r(e)
  23297. }
  23298. ), t, i, (function(e) {
  23299. o(e)
  23300. }
  23301. ))
  23302. }
  23303. ))
  23304. }
  23305. ,
  23306. t.prototype.getPerfCollector = function() {
  23307. throw be("performanceViewerSceneExtension")
  23308. }
  23309. ,
  23310. t.FOGMODE_NONE = 0,
  23311. t.FOGMODE_EXP = 1,
  23312. t.FOGMODE_EXP2 = 2,
  23313. t.FOGMODE_LINEAR = 3,
  23314. t.MinDeltaTime = 1,
  23315. t.MaxDeltaTime = 1e3,
  23316. t
  23317. }(o);
  23318. mn.prototype.setActiveCameraByID = function(e) {
  23319. return this.setActiveCameraById(e)
  23320. }
  23321. ,
  23322. mn.prototype.getLastMaterialByID = function(e) {
  23323. return this.getLastMaterialById(e)
  23324. }
  23325. ,
  23326. mn.prototype.getMaterialByID = function(e) {
  23327. return this.getMaterialById(e)
  23328. }
  23329. ,
  23330. mn.prototype.getTextureByUniqueID = function(e) {
  23331. return this.getTextureByUniqueId(e)
  23332. }
  23333. ,
  23334. mn.prototype.getCameraByID = function(e) {
  23335. return this.getCameraById(e)
  23336. }
  23337. ,
  23338. mn.prototype.getCameraByUniqueID = function(e) {
  23339. return this.getCameraByUniqueId(e)
  23340. }
  23341. ,
  23342. mn.prototype.getBoneByID = function(e) {
  23343. return this.getBoneById(e)
  23344. }
  23345. ,
  23346. mn.prototype.getLightByID = function(e) {
  23347. return this.getLightById(e)
  23348. }
  23349. ,
  23350. mn.prototype.getLightByUniqueID = function(e) {
  23351. return this.getLightByUniqueId(e)
  23352. }
  23353. ,
  23354. mn.prototype.getParticleSystemByID = function(e) {
  23355. return this.getParticleSystemById(e)
  23356. }
  23357. ,
  23358. mn.prototype.getGeometryByID = function(e) {
  23359. return this.getGeometryById(e)
  23360. }
  23361. ,
  23362. mn.prototype.getMeshByID = function(e) {
  23363. return this.getMeshById(e)
  23364. }
  23365. ,
  23366. mn.prototype.getMeshesByID = function(e) {
  23367. return this.getMeshesById(e)
  23368. }
  23369. ,
  23370. mn.prototype.getTransformNodeByID = function(e) {
  23371. return this.getTransformNodeById(e)
  23372. }
  23373. ,
  23374. mn.prototype.getTransformNodeByUniqueID = function(e) {
  23375. return this.getTransformNodeByUniqueId(e)
  23376. }
  23377. ,
  23378. mn.prototype.getTransformNodesByID = function(e) {
  23379. return this.getTransformNodesById(e)
  23380. }
  23381. ,
  23382. mn.prototype.getMeshByUniqueID = function(e) {
  23383. return this.getMeshByUniqueId(e)
  23384. }
  23385. ,
  23386. mn.prototype.getLastMeshByID = function(e) {
  23387. return this.getLastMeshById(e)
  23388. }
  23389. ,
  23390. mn.prototype.getLastEntryByID = function(e) {
  23391. return this.getLastEntryById(e)
  23392. }
  23393. ,
  23394. mn.prototype.getNodeByID = function(e) {
  23395. return this.getNodeById(e)
  23396. }
  23397. ,
  23398. mn.prototype.getLastSkeletonByID = function(e) {
  23399. return this.getLastSkeletonById(e)
  23400. }
  23401. ,
  23402. function(e) {
  23403. e[e.LOCAL = 0] = "LOCAL",
  23404. e[e.WORLD = 1] = "WORLD",
  23405. e[e.BONE = 2] = "BONE"
  23406. }(Ji || (Ji = {}));
  23407. var gn, vn = function() {
  23408. function e() {}
  23409. return e.X = new x(1,0,0),
  23410. e.Y = new x(0,1,0),
  23411. e.Z = new x(0,0,1),
  23412. e
  23413. }();
  23414. !function(e) {
  23415. e[e.X = 0] = "X",
  23416. e[e.Y = 1] = "Y",
  23417. e[e.Z = 2] = "Z"
  23418. }(gn || (gn = {}));
  23419. var yn = function(e) {
  23420. function t(t, i, n, r, o, a, s) {
  23421. void 0 === n && (n = null),
  23422. void 0 === r && (r = null),
  23423. void 0 === o && (o = null),
  23424. void 0 === a && (a = null),
  23425. void 0 === s && (s = null);
  23426. var l = e.call(this, t, i.getScene()) || this;
  23427. return l.name = t,
  23428. l.children = new Array,
  23429. l.animations = new Array,
  23430. l._index = null,
  23431. l._absoluteTransform = new P,
  23432. l._invertedAbsoluteTransform = new P,
  23433. l._scalingDeterminant = 1,
  23434. l._worldTransform = new P,
  23435. l._needToDecompose = !0,
  23436. l._needToCompose = !1,
  23437. l._linkedTransformNode = null,
  23438. l._waitingTransformNodeId = null,
  23439. l._skeleton = i,
  23440. l._localMatrix = r ? r.clone() : P.Identity(),
  23441. l._restPose = o || l._localMatrix.clone(),
  23442. l._baseMatrix = a || l._localMatrix.clone(),
  23443. l._index = s,
  23444. i.bones.push(l),
  23445. l.setParent(n, !1),
  23446. (a || r) && l._updateDifferenceMatrix(),
  23447. l
  23448. }
  23449. return U(t, e),
  23450. Object.defineProperty(t.prototype, "_matrix", {
  23451. get: function() {
  23452. return this._compose(),
  23453. this._localMatrix
  23454. },
  23455. set: function(e) {
  23456. this._needToCompose = !1,
  23457. e.updateFlag !== this._localMatrix.updateFlag && (this._localMatrix.copyFrom(e),
  23458. this._markAsDirtyAndDecompose())
  23459. },
  23460. enumerable: !1,
  23461. configurable: !0
  23462. }),
  23463. t.prototype.getClassName = function() {
  23464. return "Bone"
  23465. }
  23466. ,
  23467. t.prototype.getSkeleton = function() {
  23468. return this._skeleton
  23469. }
  23470. ,
  23471. Object.defineProperty(t.prototype, "parent", {
  23472. get: function() {
  23473. return this._parentNode
  23474. },
  23475. set: function(e) {
  23476. this.setParent(e)
  23477. },
  23478. enumerable: !1,
  23479. configurable: !0
  23480. }),
  23481. t.prototype.getParent = function() {
  23482. return this.parent
  23483. }
  23484. ,
  23485. t.prototype.getChildren = function() {
  23486. return this.children
  23487. }
  23488. ,
  23489. t.prototype.getIndex = function() {
  23490. return null === this._index ? this.getSkeleton().bones.indexOf(this) : this._index
  23491. }
  23492. ,
  23493. t.prototype.setParent = function(e, t) {
  23494. if (void 0 === t && (t = !0),
  23495. this.parent !== e) {
  23496. if (this.parent) {
  23497. var i = this.parent.children.indexOf(this);
  23498. -1 !== i && this.parent.children.splice(i, 1)
  23499. }
  23500. this._parentNode = e,
  23501. this.parent && this.parent.children.push(this),
  23502. t && this._updateDifferenceMatrix(),
  23503. this.markAsDirty()
  23504. }
  23505. }
  23506. ,
  23507. t.prototype.getLocalMatrix = function() {
  23508. return this._compose(),
  23509. this._localMatrix
  23510. }
  23511. ,
  23512. t.prototype.getBaseMatrix = function() {
  23513. return this._baseMatrix
  23514. }
  23515. ,
  23516. t.prototype.getRestPose = function() {
  23517. return this._restPose
  23518. }
  23519. ,
  23520. t.prototype.setRestPose = function(e) {
  23521. this._restPose.copyFrom(e)
  23522. }
  23523. ,
  23524. t.prototype.getBindPose = function() {
  23525. return this._baseMatrix
  23526. }
  23527. ,
  23528. t.prototype.setBindPose = function(e) {
  23529. this.updateMatrix(e)
  23530. }
  23531. ,
  23532. t.prototype.getWorldMatrix = function() {
  23533. return this._worldTransform
  23534. }
  23535. ,
  23536. t.prototype.returnToRest = function() {
  23537. var e;
  23538. if (this._linkedTransformNode) {
  23539. var t = I.Vector3[0]
  23540. , i = I.Quaternion[0]
  23541. , n = I.Vector3[1];
  23542. this.getRestPose().decompose(t, i, n),
  23543. this._linkedTransformNode.position.copyFrom(n),
  23544. this._linkedTransformNode.rotationQuaternion = null !== (e = this._linkedTransformNode.rotationQuaternion) && void 0 !== e ? e : C.Identity(),
  23545. this._linkedTransformNode.rotationQuaternion.copyFrom(i),
  23546. this._linkedTransformNode.scaling.copyFrom(t)
  23547. } else
  23548. this._matrix = this._restPose
  23549. }
  23550. ,
  23551. t.prototype.getInvertedAbsoluteTransform = function() {
  23552. return this._invertedAbsoluteTransform
  23553. }
  23554. ,
  23555. t.prototype.getAbsoluteTransform = function() {
  23556. return this._absoluteTransform
  23557. }
  23558. ,
  23559. t.prototype.linkTransformNode = function(e) {
  23560. this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--,
  23561. this._linkedTransformNode = e,
  23562. this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++
  23563. }
  23564. ,
  23565. t.prototype.getTransformNode = function() {
  23566. return this._linkedTransformNode
  23567. }
  23568. ,
  23569. Object.defineProperty(t.prototype, "position", {
  23570. get: function() {
  23571. return this._decompose(),
  23572. this._localPosition
  23573. },
  23574. set: function(e) {
  23575. this._decompose(),
  23576. this._localPosition.copyFrom(e),
  23577. this._markAsDirtyAndCompose()
  23578. },
  23579. enumerable: !1,
  23580. configurable: !0
  23581. }),
  23582. Object.defineProperty(t.prototype, "rotation", {
  23583. get: function() {
  23584. return this.getRotation()
  23585. },
  23586. set: function(e) {
  23587. this.setRotation(e)
  23588. },
  23589. enumerable: !1,
  23590. configurable: !0
  23591. }),
  23592. Object.defineProperty(t.prototype, "rotationQuaternion", {
  23593. get: function() {
  23594. return this._decompose(),
  23595. this._localRotation
  23596. },
  23597. set: function(e) {
  23598. this.setRotationQuaternion(e)
  23599. },
  23600. enumerable: !1,
  23601. configurable: !0
  23602. }),
  23603. Object.defineProperty(t.prototype, "scaling", {
  23604. get: function() {
  23605. return this.getScale()
  23606. },
  23607. set: function(e) {
  23608. this.setScale(e)
  23609. },
  23610. enumerable: !1,
  23611. configurable: !0
  23612. }),
  23613. Object.defineProperty(t.prototype, "animationPropertiesOverride", {
  23614. get: function() {
  23615. return this._skeleton.animationPropertiesOverride
  23616. },
  23617. enumerable: !1,
  23618. configurable: !0
  23619. }),
  23620. t.prototype._decompose = function() {
  23621. this._needToDecompose && (this._needToDecompose = !1,
  23622. this._localScaling || (this._localScaling = x.Zero(),
  23623. this._localRotation = C.Zero(),
  23624. this._localPosition = x.Zero()),
  23625. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
  23626. }
  23627. ,
  23628. t.prototype._compose = function() {
  23629. this._needToCompose && (this._localScaling ? (this._needToCompose = !1,
  23630. P.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)) : this._needToCompose = !1)
  23631. }
  23632. ,
  23633. t.prototype.updateMatrix = function(e, t, i) {
  23634. void 0 === t && (t = !0),
  23635. void 0 === i && (i = !0),
  23636. this._baseMatrix.copyFrom(e),
  23637. t && this._updateDifferenceMatrix(),
  23638. i ? this._matrix = e : this.markAsDirty()
  23639. }
  23640. ,
  23641. t.prototype._updateDifferenceMatrix = function(e, t) {
  23642. if (void 0 === t && (t = !0),
  23643. e || (e = this._baseMatrix),
  23644. this.parent ? e.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(e),
  23645. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
  23646. t)
  23647. for (var i = 0; i < this.children.length; i++)
  23648. this.children[i]._updateDifferenceMatrix();
  23649. this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1
  23650. }
  23651. ,
  23652. t.prototype.markAsDirty = function() {
  23653. return this._currentRenderId++,
  23654. this._childUpdateId++,
  23655. this._skeleton._markAsDirty(),
  23656. this
  23657. }
  23658. ,
  23659. t.prototype._markAsDirtyAndCompose = function() {
  23660. this.markAsDirty(),
  23661. this._needToCompose = !0
  23662. }
  23663. ,
  23664. t.prototype._markAsDirtyAndDecompose = function() {
  23665. this.markAsDirty(),
  23666. this._needToDecompose = !0
  23667. }
  23668. ,
  23669. t.prototype.translate = function(e, i, n) {
  23670. void 0 === i && (i = Ji.LOCAL);
  23671. var r = this.getLocalMatrix();
  23672. if (i == Ji.LOCAL)
  23673. r.addAtIndex(12, e.x),
  23674. r.addAtIndex(13, e.y),
  23675. r.addAtIndex(14, e.z);
  23676. else {
  23677. var o = null;
  23678. n && (o = n.getWorldMatrix()),
  23679. this._skeleton.computeAbsoluteTransforms();
  23680. var a = t._TmpMats[0]
  23681. , s = t._TmpVecs[0];
  23682. this.parent ? n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
  23683. a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()) : P.IdentityToRef(a),
  23684. a.setTranslationFromFloats(0, 0, 0),
  23685. a.invert(),
  23686. x.TransformCoordinatesToRef(e, a, s),
  23687. r.addAtIndex(12, s.x),
  23688. r.addAtIndex(13, s.y),
  23689. r.addAtIndex(14, s.z)
  23690. }
  23691. this._markAsDirtyAndDecompose()
  23692. }
  23693. ,
  23694. t.prototype.setPosition = function(e, i, n) {
  23695. void 0 === i && (i = Ji.LOCAL);
  23696. var r = this.getLocalMatrix();
  23697. if (i == Ji.LOCAL)
  23698. r.setTranslationFromFloats(e.x, e.y, e.z);
  23699. else {
  23700. var o = null;
  23701. n && (o = n.getWorldMatrix()),
  23702. this._skeleton.computeAbsoluteTransforms();
  23703. var a = t._TmpMats[0]
  23704. , s = t._TmpVecs[0];
  23705. this.parent ? (n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
  23706. a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()),
  23707. a.invert()) : P.IdentityToRef(a),
  23708. x.TransformCoordinatesToRef(e, a, s),
  23709. r.setTranslationFromFloats(s.x, s.y, s.z)
  23710. }
  23711. this._markAsDirtyAndDecompose()
  23712. }
  23713. ,
  23714. t.prototype.setAbsolutePosition = function(e, t) {
  23715. this.setPosition(e, Ji.WORLD, t)
  23716. }
  23717. ,
  23718. t.prototype.scale = function(e, i, n, r) {
  23719. void 0 === r && (r = !1);
  23720. var o = this.getLocalMatrix()
  23721. , a = t._TmpMats[0];
  23722. P.ScalingToRef(e, i, n, a),
  23723. a.multiplyToRef(o, o),
  23724. a.invert();
  23725. for (var s = 0, l = this.children; s < l.length; s++) {
  23726. var c = (d = l[s]).getLocalMatrix();
  23727. c.multiplyToRef(a, c),
  23728. c.multiplyAtIndex(12, e),
  23729. c.multiplyAtIndex(13, i),
  23730. c.multiplyAtIndex(14, n),
  23731. d._markAsDirtyAndDecompose()
  23732. }
  23733. if (this._markAsDirtyAndDecompose(),
  23734. r)
  23735. for (var u = 0, h = this.children; u < h.length; u++) {
  23736. var d;
  23737. (d = h[u]).scale(e, i, n, r)
  23738. }
  23739. }
  23740. ,
  23741. t.prototype.setScale = function(e) {
  23742. this._decompose(),
  23743. this._localScaling.copyFrom(e),
  23744. this._markAsDirtyAndCompose()
  23745. }
  23746. ,
  23747. t.prototype.getScale = function() {
  23748. return this._decompose(),
  23749. this._localScaling
  23750. }
  23751. ,
  23752. t.prototype.getScaleToRef = function(e) {
  23753. this._decompose(),
  23754. e.copyFrom(this._localScaling)
  23755. }
  23756. ,
  23757. t.prototype.setYawPitchRoll = function(e, i, n, r, o) {
  23758. if (void 0 === r && (r = Ji.LOCAL),
  23759. r === Ji.LOCAL) {
  23760. var a = t._TmpQuat;
  23761. return C.RotationYawPitchRollToRef(e, i, n, a),
  23762. void this.setRotationQuaternion(a, r, o)
  23763. }
  23764. var s = t._TmpMats[0];
  23765. if (this._getNegativeRotationToRef(s, o)) {
  23766. var l = t._TmpMats[1];
  23767. P.RotationYawPitchRollToRef(e, i, n, l),
  23768. s.multiplyToRef(l, l),
  23769. this._rotateWithMatrix(l, r, o)
  23770. }
  23771. }
  23772. ,
  23773. t.prototype.rotate = function(e, i, n, r) {
  23774. void 0 === n && (n = Ji.LOCAL);
  23775. var o = t._TmpMats[0];
  23776. o.setTranslationFromFloats(0, 0, 0),
  23777. P.RotationAxisToRef(e, i, o),
  23778. this._rotateWithMatrix(o, n, r)
  23779. }
  23780. ,
  23781. t.prototype.setAxisAngle = function(e, i, n, r) {
  23782. if (void 0 === n && (n = Ji.LOCAL),
  23783. n === Ji.LOCAL) {
  23784. var o = t._TmpQuat;
  23785. return C.RotationAxisToRef(e, i, o),
  23786. void this.setRotationQuaternion(o, n, r)
  23787. }
  23788. var a = t._TmpMats[0];
  23789. if (this._getNegativeRotationToRef(a, r)) {
  23790. var s = t._TmpMats[1];
  23791. P.RotationAxisToRef(e, i, s),
  23792. a.multiplyToRef(s, s),
  23793. this._rotateWithMatrix(s, n, r)
  23794. }
  23795. }
  23796. ,
  23797. t.prototype.setRotation = function(e, t, i) {
  23798. void 0 === t && (t = Ji.LOCAL),
  23799. this.setYawPitchRoll(e.y, e.x, e.z, t, i)
  23800. }
  23801. ,
  23802. t.prototype.setRotationQuaternion = function(e, i, n) {
  23803. if (void 0 === i && (i = Ji.LOCAL),
  23804. i === Ji.LOCAL)
  23805. return this._decompose(),
  23806. this._localRotation.copyFrom(e),
  23807. void this._markAsDirtyAndCompose();
  23808. var r = t._TmpMats[0];
  23809. if (this._getNegativeRotationToRef(r, n)) {
  23810. var o = t._TmpMats[1];
  23811. P.FromQuaternionToRef(e, o),
  23812. r.multiplyToRef(o, o),
  23813. this._rotateWithMatrix(o, i, n)
  23814. }
  23815. }
  23816. ,
  23817. t.prototype.setRotationMatrix = function(e, i, n) {
  23818. if (void 0 === i && (i = Ji.LOCAL),
  23819. i === Ji.LOCAL) {
  23820. var r = t._TmpQuat;
  23821. return C.FromRotationMatrixToRef(e, r),
  23822. void this.setRotationQuaternion(r, i, n)
  23823. }
  23824. var o = t._TmpMats[0];
  23825. if (this._getNegativeRotationToRef(o, n)) {
  23826. var a = t._TmpMats[1];
  23827. a.copyFrom(e),
  23828. o.multiplyToRef(e, a),
  23829. this._rotateWithMatrix(a, i, n)
  23830. }
  23831. }
  23832. ,
  23833. t.prototype._rotateWithMatrix = function(e, i, n) {
  23834. void 0 === i && (i = Ji.LOCAL);
  23835. var r = this.getLocalMatrix()
  23836. , o = r.m[12]
  23837. , a = r.m[13]
  23838. , s = r.m[14]
  23839. , l = this.getParent()
  23840. , c = t._TmpMats[3]
  23841. , u = t._TmpMats[4];
  23842. l && i == Ji.WORLD ? (n ? (c.copyFrom(n.getWorldMatrix()),
  23843. l.getAbsoluteTransform().multiplyToRef(c, c)) : c.copyFrom(l.getAbsoluteTransform()),
  23844. u.copyFrom(c),
  23845. u.invert(),
  23846. r.multiplyToRef(c, r),
  23847. r.multiplyToRef(e, r),
  23848. r.multiplyToRef(u, r)) : i == Ji.WORLD && n ? (c.copyFrom(n.getWorldMatrix()),
  23849. u.copyFrom(c),
  23850. u.invert(),
  23851. r.multiplyToRef(c, r),
  23852. r.multiplyToRef(e, r),
  23853. r.multiplyToRef(u, r)) : r.multiplyToRef(e, r),
  23854. r.setTranslationFromFloats(o, a, s),
  23855. this.computeAbsoluteTransforms(),
  23856. this._markAsDirtyAndDecompose()
  23857. }
  23858. ,
  23859. t.prototype._getNegativeRotationToRef = function(e, i) {
  23860. var n = t._TmpMats[2];
  23861. return e.copyFrom(this.getAbsoluteTransform()),
  23862. i ? (e.multiplyToRef(i.getWorldMatrix(), e),
  23863. P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, n)) : P.IdentityToRef(n),
  23864. e.invert(),
  23865. !isNaN(e.m[0]) && (n.multiplyAtIndex(0, this._scalingDeterminant),
  23866. e.multiplyToRef(n, e),
  23867. !0)
  23868. }
  23869. ,
  23870. t.prototype.getPosition = function(e, t) {
  23871. void 0 === e && (e = Ji.LOCAL),
  23872. void 0 === t && (t = null);
  23873. var i = x.Zero();
  23874. return this.getPositionToRef(e, t, i),
  23875. i
  23876. }
  23877. ,
  23878. t.prototype.getPositionToRef = function(e, i, n) {
  23879. if (void 0 === e && (e = Ji.LOCAL),
  23880. e == Ji.LOCAL) {
  23881. var r = this.getLocalMatrix();
  23882. n.x = r.m[12],
  23883. n.y = r.m[13],
  23884. n.z = r.m[14]
  23885. } else {
  23886. var o = null;
  23887. i && (o = i.getWorldMatrix()),
  23888. this._skeleton.computeAbsoluteTransforms();
  23889. var a = t._TmpMats[0];
  23890. i && o ? (a.copyFrom(this.getAbsoluteTransform()),
  23891. a.multiplyToRef(o, a)) : a = this.getAbsoluteTransform(),
  23892. n.x = a.m[12],
  23893. n.y = a.m[13],
  23894. n.z = a.m[14]
  23895. }
  23896. }
  23897. ,
  23898. t.prototype.getAbsolutePosition = function(e) {
  23899. void 0 === e && (e = null);
  23900. var t = x.Zero();
  23901. return this.getPositionToRef(Ji.WORLD, e, t),
  23902. t
  23903. }
  23904. ,
  23905. t.prototype.getAbsolutePositionToRef = function(e, t) {
  23906. this.getPositionToRef(Ji.WORLD, e, t)
  23907. }
  23908. ,
  23909. t.prototype.computeAbsoluteTransforms = function() {
  23910. if (this._compose(),
  23911. this.parent)
  23912. this._localMatrix.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform);
  23913. else {
  23914. this._absoluteTransform.copyFrom(this._localMatrix);
  23915. var e = this._skeleton.getPoseMatrix();
  23916. e && this._absoluteTransform.multiplyToRef(e, this._absoluteTransform)
  23917. }
  23918. for (var t = this.children, i = t.length, n = 0; n < i; n++)
  23919. t[n].computeAbsoluteTransforms()
  23920. }
  23921. ,
  23922. t.prototype.getDirection = function(e, t) {
  23923. void 0 === t && (t = null);
  23924. var i = x.Zero();
  23925. return this.getDirectionToRef(e, t, i),
  23926. i
  23927. }
  23928. ,
  23929. t.prototype.getDirectionToRef = function(e, i, n) {
  23930. void 0 === i && (i = null);
  23931. var r = null;
  23932. i && (r = i.getWorldMatrix()),
  23933. this._skeleton.computeAbsoluteTransforms();
  23934. var o = t._TmpMats[0];
  23935. o.copyFrom(this.getAbsoluteTransform()),
  23936. i && r && o.multiplyToRef(r, o),
  23937. x.TransformNormalToRef(e, o, n),
  23938. n.normalize()
  23939. }
  23940. ,
  23941. t.prototype.getRotation = function(e, t) {
  23942. void 0 === e && (e = Ji.LOCAL),
  23943. void 0 === t && (t = null);
  23944. var i = x.Zero();
  23945. return this.getRotationToRef(e, t, i),
  23946. i
  23947. }
  23948. ,
  23949. t.prototype.getRotationToRef = function(e, i, n) {
  23950. void 0 === e && (e = Ji.LOCAL),
  23951. void 0 === i && (i = null);
  23952. var r = t._TmpQuat;
  23953. this.getRotationQuaternionToRef(e, i, r),
  23954. r.toEulerAnglesToRef(n)
  23955. }
  23956. ,
  23957. t.prototype.getRotationQuaternion = function(e, t) {
  23958. void 0 === e && (e = Ji.LOCAL),
  23959. void 0 === t && (t = null);
  23960. var i = C.Identity();
  23961. return this.getRotationQuaternionToRef(e, t, i),
  23962. i
  23963. }
  23964. ,
  23965. t.prototype.getRotationQuaternionToRef = function(e, i, n) {
  23966. if (void 0 === e && (e = Ji.LOCAL),
  23967. void 0 === i && (i = null),
  23968. e == Ji.LOCAL)
  23969. this._decompose(),
  23970. n.copyFrom(this._localRotation);
  23971. else {
  23972. var r = t._TmpMats[0]
  23973. , o = this.getAbsoluteTransform();
  23974. i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
  23975. r.multiplyAtIndex(0, this._scalingDeterminant),
  23976. r.multiplyAtIndex(1, this._scalingDeterminant),
  23977. r.multiplyAtIndex(2, this._scalingDeterminant),
  23978. r.decompose(void 0, n, void 0)
  23979. }
  23980. }
  23981. ,
  23982. t.prototype.getRotationMatrix = function(e, t) {
  23983. void 0 === e && (e = Ji.LOCAL);
  23984. var i = P.Identity();
  23985. return this.getRotationMatrixToRef(e, t, i),
  23986. i
  23987. }
  23988. ,
  23989. t.prototype.getRotationMatrixToRef = function(e, i, n) {
  23990. if (void 0 === e && (e = Ji.LOCAL),
  23991. e == Ji.LOCAL)
  23992. this.getLocalMatrix().getRotationMatrixToRef(n);
  23993. else {
  23994. var r = t._TmpMats[0]
  23995. , o = this.getAbsoluteTransform();
  23996. i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
  23997. r.multiplyAtIndex(0, this._scalingDeterminant),
  23998. r.multiplyAtIndex(1, this._scalingDeterminant),
  23999. r.multiplyAtIndex(2, this._scalingDeterminant),
  24000. r.getRotationMatrixToRef(n)
  24001. }
  24002. }
  24003. ,
  24004. t.prototype.getAbsolutePositionFromLocal = function(e, t) {
  24005. void 0 === t && (t = null);
  24006. var i = x.Zero();
  24007. return this.getAbsolutePositionFromLocalToRef(e, t, i),
  24008. i
  24009. }
  24010. ,
  24011. t.prototype.getAbsolutePositionFromLocalToRef = function(e, i, n) {
  24012. void 0 === i && (i = null);
  24013. var r = null;
  24014. i && (r = i.getWorldMatrix()),
  24015. this._skeleton.computeAbsoluteTransforms();
  24016. var o = t._TmpMats[0];
  24017. i && r ? (o.copyFrom(this.getAbsoluteTransform()),
  24018. o.multiplyToRef(r, o)) : o = this.getAbsoluteTransform(),
  24019. x.TransformCoordinatesToRef(e, o, n)
  24020. }
  24021. ,
  24022. t.prototype.getLocalPositionFromAbsolute = function(e, t) {
  24023. void 0 === t && (t = null);
  24024. var i = x.Zero();
  24025. return this.getLocalPositionFromAbsoluteToRef(e, t, i),
  24026. i
  24027. }
  24028. ,
  24029. t.prototype.getLocalPositionFromAbsoluteToRef = function(e, i, n) {
  24030. void 0 === i && (i = null);
  24031. var r = null;
  24032. i && (r = i.getWorldMatrix()),
  24033. this._skeleton.computeAbsoluteTransforms();
  24034. var o = t._TmpMats[0];
  24035. o.copyFrom(this.getAbsoluteTransform()),
  24036. i && r && o.multiplyToRef(r, o),
  24037. o.invert(),
  24038. x.TransformCoordinatesToRef(e, o, n)
  24039. }
  24040. ,
  24041. t.prototype.setCurrentPoseAsRest = function() {
  24042. this.setRestPose(this.getLocalMatrix())
  24043. }
  24044. ,
  24045. t._TmpVecs = g.BuildArray(2, x.Zero),
  24046. t._TmpQuat = C.Identity(),
  24047. t._TmpMats = g.BuildArray(5, P.Identity),
  24048. t
  24049. }(Xe)
  24050. , bn = function() {
  24051. function e(e, t, i, n, r, o, a, s, l, c) {
  24052. void 0 === i && (i = 0),
  24053. void 0 === n && (n = 100),
  24054. void 0 === r && (r = !1),
  24055. void 0 === o && (o = 1),
  24056. void 0 === c && (c = !1),
  24057. this.target = t,
  24058. this.fromFrame = i,
  24059. this.toFrame = n,
  24060. this.loopAnimation = r,
  24061. this.onAnimationEnd = a,
  24062. this.onAnimationLoop = l,
  24063. this.isAdditive = c,
  24064. this._localDelayOffset = null,
  24065. this._pausedDelay = null,
  24066. this._manualJumpDelay = null,
  24067. this._runtimeAnimations = new Array,
  24068. this._paused = !1,
  24069. this._speedRatio = 1,
  24070. this._weight = -1,
  24071. this._syncRoot = null,
  24072. this._frameToSyncFromJump = 0,
  24073. this.disposeOnEnd = !0,
  24074. this.animationStarted = !1,
  24075. this.onAnimationEndObservable = new h,
  24076. this.onAnimationLoopObservable = new h,
  24077. this._scene = e,
  24078. s && this.appendAnimations(t, s),
  24079. this._speedRatio = o,
  24080. e._activeAnimatables.push(this)
  24081. }
  24082. return Object.defineProperty(e.prototype, "syncRoot", {
  24083. get: function() {
  24084. return this._syncRoot
  24085. },
  24086. enumerable: !1,
  24087. configurable: !0
  24088. }),
  24089. Object.defineProperty(e.prototype, "masterFrame", {
  24090. get: function() {
  24091. return 0 === this._runtimeAnimations.length ? 0 : this._runtimeAnimations[0].currentFrame
  24092. },
  24093. enumerable: !1,
  24094. configurable: !0
  24095. }),
  24096. Object.defineProperty(e.prototype, "weight", {
  24097. get: function() {
  24098. return this._weight
  24099. },
  24100. set: function(e) {
  24101. this._weight = -1 !== e ? Math.min(Math.max(e, 0), 1) : -1
  24102. },
  24103. enumerable: !1,
  24104. configurable: !0
  24105. }),
  24106. Object.defineProperty(e.prototype, "speedRatio", {
  24107. get: function() {
  24108. return this._speedRatio
  24109. },
  24110. set: function(e) {
  24111. for (var t = 0; t < this._runtimeAnimations.length; t++)
  24112. this._runtimeAnimations[t]._prepareForSpeedRatioChange(e);
  24113. this._speedRatio = e
  24114. },
  24115. enumerable: !1,
  24116. configurable: !0
  24117. }),
  24118. e.prototype.syncWith = function(e) {
  24119. if (this._syncRoot = e,
  24120. e) {
  24121. var t = this._scene._activeAnimatables.indexOf(this);
  24122. t > -1 && (this._scene._activeAnimatables.splice(t, 1),
  24123. this._scene._activeAnimatables.push(this))
  24124. }
  24125. return this
  24126. }
  24127. ,
  24128. e.prototype.getAnimations = function() {
  24129. return this._runtimeAnimations
  24130. }
  24131. ,
  24132. e.prototype.appendAnimations = function(e, t) {
  24133. for (var i = this, n = 0; n < t.length; n++) {
  24134. var r = t[n]
  24135. , o = new it(e,r,this._scene,this);
  24136. o._onLoop = function() {
  24137. i.onAnimationLoopObservable.notifyObservers(i),
  24138. i.onAnimationLoop && i.onAnimationLoop()
  24139. }
  24140. ,
  24141. this._runtimeAnimations.push(o)
  24142. }
  24143. }
  24144. ,
  24145. e.prototype.getAnimationByTargetProperty = function(e) {
  24146. for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
  24147. if (t[i].animation.targetProperty === e)
  24148. return t[i].animation;
  24149. return null
  24150. }
  24151. ,
  24152. e.prototype.getRuntimeAnimationByTargetProperty = function(e) {
  24153. for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
  24154. if (t[i].animation.targetProperty === e)
  24155. return t[i];
  24156. return null
  24157. }
  24158. ,
  24159. e.prototype.reset = function() {
  24160. for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
  24161. e[t].reset(!0);
  24162. this._localDelayOffset = null,
  24163. this._pausedDelay = null
  24164. }
  24165. ,
  24166. e.prototype.enableBlending = function(e) {
  24167. for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
  24168. t[i].animation.enableBlending = !0,
  24169. t[i].animation.blendingSpeed = e
  24170. }
  24171. ,
  24172. e.prototype.disableBlending = function() {
  24173. for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
  24174. e[t].animation.enableBlending = !1
  24175. }
  24176. ,
  24177. e.prototype.goToFrame = function(e) {
  24178. var t, i = this._runtimeAnimations;
  24179. if (i[0]) {
  24180. var n = i[0].animation.framePerSecond;
  24181. this._frameToSyncFromJump = null !== (t = this._frameToSyncFromJump) && void 0 !== t ? t : i[0].currentFrame;
  24182. var r = 0 === this.speedRatio ? 0 : (e - this._frameToSyncFromJump) / n * 1e3 / this.speedRatio;
  24183. this._manualJumpDelay = -r
  24184. }
  24185. for (var o = 0; o < i.length; o++)
  24186. i[o].goToFrame(e)
  24187. }
  24188. ,
  24189. e.prototype.pause = function() {
  24190. this._paused || (this._paused = !0)
  24191. }
  24192. ,
  24193. e.prototype.restart = function() {
  24194. this._paused = !1
  24195. }
  24196. ,
  24197. e.prototype._raiseOnAnimationEnd = function() {
  24198. this.onAnimationEnd && this.onAnimationEnd(),
  24199. this.onAnimationEndObservable.notifyObservers(this)
  24200. }
  24201. ,
  24202. e.prototype.stop = function(e, t) {
  24203. if (e || t) {
  24204. var i = this._scene._activeAnimatables.indexOf(this);
  24205. if (i > -1) {
  24206. for (var n = (o = this._runtimeAnimations).length - 1; n >= 0; n--) {
  24207. var r = o[n];
  24208. e && r.animation.name != e || t && !t(r.target) || (r.dispose(),
  24209. o.splice(n, 1))
  24210. }
  24211. 0 == o.length && (this._scene._activeAnimatables.splice(i, 1),
  24212. this._raiseOnAnimationEnd())
  24213. }
  24214. } else if ((n = this._scene._activeAnimatables.indexOf(this)) > -1) {
  24215. this._scene._activeAnimatables.splice(n, 1);
  24216. for (var o = this._runtimeAnimations, a = 0; a < o.length; a++)
  24217. o[a].dispose();
  24218. this._raiseOnAnimationEnd()
  24219. }
  24220. }
  24221. ,
  24222. e.prototype.waitAsync = function() {
  24223. var e = this;
  24224. return new Promise((function(t) {
  24225. e.onAnimationEndObservable.add((function() {
  24226. t(e)
  24227. }
  24228. ), void 0, void 0, e, !0)
  24229. }
  24230. ))
  24231. }
  24232. ,
  24233. e.prototype._animate = function(e) {
  24234. if (this._paused)
  24235. return this.animationStarted = !1,
  24236. null === this._pausedDelay && (this._pausedDelay = e),
  24237. !0;
  24238. if (null === this._localDelayOffset ? (this._localDelayOffset = e,
  24239. this._pausedDelay = null) : null !== this._pausedDelay && (this._localDelayOffset += e - this._pausedDelay,
  24240. this._pausedDelay = null),
  24241. null !== this._manualJumpDelay && (this._localDelayOffset += this._manualJumpDelay,
  24242. this._manualJumpDelay = null,
  24243. this._frameToSyncFromJump = null),
  24244. 0 === this._weight)
  24245. return !0;
  24246. var t, i = !1, n = this._runtimeAnimations;
  24247. for (t = 0; t < n.length; t++) {
  24248. var r = n[t].animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  24249. i = i || r
  24250. }
  24251. if (this.animationStarted = i,
  24252. !i) {
  24253. if (this.disposeOnEnd)
  24254. for (t = this._scene._activeAnimatables.indexOf(this),
  24255. this._scene._activeAnimatables.splice(t, 1),
  24256. t = 0; t < n.length; t++)
  24257. n[t].dispose();
  24258. this._raiseOnAnimationEnd(),
  24259. this.disposeOnEnd && (this.onAnimationEnd = null,
  24260. this.onAnimationLoop = null,
  24261. this.onAnimationLoopObservable.clear(),
  24262. this.onAnimationEndObservable.clear())
  24263. }
  24264. return i
  24265. }
  24266. ,
  24267. e
  24268. }();
  24269. mn.prototype._animate = function() {
  24270. if (this.animationsEnabled) {
  24271. var e = ct.Now;
  24272. if (!this._animationTimeLast) {
  24273. if (this._pendingData.length > 0)
  24274. return;
  24275. this._animationTimeLast = e
  24276. }
  24277. this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (e - this._animationTimeLast) * this.animationTimeScale,
  24278. this._animationTimeLast = e;
  24279. var t = this._activeAnimatables;
  24280. if (0 !== t.length) {
  24281. this._animationTime += this.deltaTime;
  24282. for (var i = this._animationTime, n = 0; n < t.length; n++) {
  24283. var r = t[n];
  24284. !r._animate(i) && r.disposeOnEnd && n--
  24285. }
  24286. this._processLateAnimationBindings()
  24287. }
  24288. }
  24289. }
  24290. ,
  24291. mn.prototype.beginWeightedAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
  24292. void 0 === n && (n = 1),
  24293. void 0 === o && (o = 1),
  24294. void 0 === u && (u = !1);
  24295. var h = this.beginAnimation(e, t, i, r, o, a, s, !1, l, c, u);
  24296. return h.weight = n,
  24297. h
  24298. }
  24299. ,
  24300. mn.prototype.beginAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
  24301. void 0 === r && (r = 1),
  24302. void 0 === s && (s = !0),
  24303. void 0 === u && (u = !1),
  24304. t > i && r > 0 && (r *= -1),
  24305. s && this.stopAnimation(e, void 0, l),
  24306. a || (a = new bn(this,e,t,i,n,r,o,void 0,c,u));
  24307. var h = !l || l(e);
  24308. if (e.animations && h && a.appendAnimations(e, e.animations),
  24309. e.getAnimatables)
  24310. for (var d = e.getAnimatables(), p = 0; p < d.length; p++)
  24311. this.beginAnimation(d[p], t, i, n, r, o, a, s, l, c);
  24312. return a.reset(),
  24313. a
  24314. }
  24315. ,
  24316. mn.prototype.beginHierarchyAnimation = function(e, t, i, n, r, o, a, s, l, c, u, h) {
  24317. void 0 === o && (o = 1),
  24318. void 0 === l && (l = !0),
  24319. void 0 === h && (h = !1);
  24320. var d = e.getDescendants(t)
  24321. , p = [];
  24322. p.push(this.beginAnimation(e, i, n, r, o, a, s, l, c, void 0, h));
  24323. for (var f = 0, _ = d; f < _.length; f++) {
  24324. var m = _[f];
  24325. p.push(this.beginAnimation(m, i, n, r, o, a, s, l, c, void 0, h))
  24326. }
  24327. return p
  24328. }
  24329. ,
  24330. mn.prototype.beginDirectAnimation = function(e, t, i, n, r, o, a, s, l) {
  24331. if (void 0 === l && (l = !1),
  24332. void 0 === o && (o = 1),
  24333. i > n && o > 0)
  24334. o *= -1;
  24335. else if (n > i && o < 0) {
  24336. var c = n;
  24337. n = i,
  24338. i = c
  24339. }
  24340. return new bn(this,e,i,n,r,o,a,t,s,l)
  24341. }
  24342. ,
  24343. mn.prototype.beginDirectHierarchyAnimation = function(e, t, i, n, r, o, a, s, l, c) {
  24344. void 0 === c && (c = !1);
  24345. var u = e.getDescendants(t)
  24346. , h = [];
  24347. h.push(this.beginDirectAnimation(e, i, n, r, o, a, s, l, c));
  24348. for (var d = 0, p = u; d < p.length; d++) {
  24349. var f = p[d];
  24350. h.push(this.beginDirectAnimation(f, i, n, r, o, a, s, l, c))
  24351. }
  24352. return h
  24353. }
  24354. ,
  24355. mn.prototype.getAnimatableByTarget = function(e) {
  24356. for (var t = 0; t < this._activeAnimatables.length; t++)
  24357. if (this._activeAnimatables[t].target === e)
  24358. return this._activeAnimatables[t];
  24359. return null
  24360. }
  24361. ,
  24362. mn.prototype.getAllAnimatablesByTarget = function(e) {
  24363. for (var t = [], i = 0; i < this._activeAnimatables.length; i++)
  24364. this._activeAnimatables[i].target === e && t.push(this._activeAnimatables[i]);
  24365. return t
  24366. }
  24367. ,
  24368. mn.prototype.stopAnimation = function(e, t, i) {
  24369. for (var n = 0, r = this.getAllAnimatablesByTarget(e); n < r.length; n++)
  24370. r[n].stop(t, i)
  24371. }
  24372. ,
  24373. mn.prototype.stopAllAnimations = function() {
  24374. if (this._activeAnimatables) {
  24375. for (var e = 0; e < this._activeAnimatables.length; e++)
  24376. this._activeAnimatables[e].stop();
  24377. this._activeAnimatables = []
  24378. }
  24379. for (var t = 0, i = this.animationGroups; t < i.length; t++)
  24380. i[t].stop()
  24381. }
  24382. ,
  24383. mn.prototype._registerTargetForLateAnimationBinding = function(e, t) {
  24384. var i = e.target;
  24385. this._registeredForLateAnimationBindings.pushNoDuplicate(i),
  24386. i._lateAnimationHolders || (i._lateAnimationHolders = {}),
  24387. i._lateAnimationHolders[e.targetPath] || (i._lateAnimationHolders[e.targetPath] = {
  24388. totalWeight: 0,
  24389. totalAdditiveWeight: 0,
  24390. animations: [],
  24391. additiveAnimations: [],
  24392. originalValue: t
  24393. }),
  24394. e.isAdditive ? (i._lateAnimationHolders[e.targetPath].additiveAnimations.push(e),
  24395. i._lateAnimationHolders[e.targetPath].totalAdditiveWeight += e.weight) : (i._lateAnimationHolders[e.targetPath].animations.push(e),
  24396. i._lateAnimationHolders[e.targetPath].totalWeight += e.weight)
  24397. }
  24398. ,
  24399. mn.prototype._processLateAnimationBindingsForMatrices = function(e) {
  24400. if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
  24401. return e.originalValue;
  24402. var t = 1
  24403. , i = I.Vector3[0]
  24404. , n = I.Vector3[1]
  24405. , r = I.Quaternion[0]
  24406. , o = 0
  24407. , a = e.animations[0]
  24408. , s = e.originalValue
  24409. , l = 1
  24410. , c = !1;
  24411. if (e.totalWeight < 1)
  24412. l = 1 - e.totalWeight,
  24413. s.decompose(n, r, i);
  24414. else {
  24415. if (o = 1,
  24416. t = e.totalWeight,
  24417. 1 == (l = a.weight / t)) {
  24418. if (!e.totalAdditiveWeight)
  24419. return a.currentValue;
  24420. c = !0
  24421. }
  24422. a.currentValue.decompose(n, r, i)
  24423. }
  24424. if (!c) {
  24425. n.scaleInPlace(l),
  24426. i.scaleInPlace(l),
  24427. r.scaleInPlace(l);
  24428. for (var u = o; u < e.animations.length; u++)
  24429. if (0 !== (f = e.animations[u]).weight) {
  24430. l = f.weight / t;
  24431. var h = I.Vector3[2]
  24432. , d = I.Vector3[3]
  24433. , p = I.Quaternion[1];
  24434. f.currentValue.decompose(d, p, h),
  24435. d.scaleAndAddToRef(l, n),
  24436. p.scaleAndAddToRef(l, r),
  24437. h.scaleAndAddToRef(l, i)
  24438. }
  24439. }
  24440. for (u = 0; u < e.additiveAnimations.length; u++) {
  24441. var f;
  24442. 0 !== (f = e.additiveAnimations[u]).weight && (h = I.Vector3[2],
  24443. d = I.Vector3[3],
  24444. p = I.Quaternion[1],
  24445. f.currentValue.decompose(d, p, h),
  24446. d.multiplyToRef(n, d),
  24447. x.LerpToRef(n, d, f.weight, n),
  24448. r.multiplyToRef(p, p),
  24449. C.SlerpToRef(r, p, f.weight, r),
  24450. h.scaleAndAddToRef(f.weight, i))
  24451. }
  24452. var _ = a ? a._animationState.workValue : I.Matrix[0].clone();
  24453. return P.ComposeToRef(n, r, i, _),
  24454. _
  24455. }
  24456. ,
  24457. mn.prototype._processLateAnimationBindingsForQuaternions = function(e, t) {
  24458. if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
  24459. return t;
  24460. var i = e.animations[0]
  24461. , n = e.originalValue
  24462. , r = t;
  24463. if (0 === e.totalWeight && e.totalAdditiveWeight > 0)
  24464. r.copyFrom(n);
  24465. else if (1 === e.animations.length) {
  24466. if (C.SlerpToRef(n, i.currentValue, Math.min(1, e.totalWeight), r),
  24467. 0 === e.totalAdditiveWeight)
  24468. return r
  24469. } else if (e.animations.length > 1) {
  24470. var o = 1
  24471. , a = void 0
  24472. , s = void 0;
  24473. if (e.totalWeight < 1) {
  24474. var l = 1 - e.totalWeight;
  24475. s = [],
  24476. (a = []).push(n),
  24477. s.push(l)
  24478. } else {
  24479. if (2 === e.animations.length && (C.SlerpToRef(e.animations[0].currentValue, e.animations[1].currentValue, e.animations[1].weight / e.totalWeight, t),
  24480. 0 === e.totalAdditiveWeight))
  24481. return t;
  24482. a = [],
  24483. s = [],
  24484. o = e.totalWeight
  24485. }
  24486. for (var c = 0; c < e.animations.length; c++) {
  24487. var u = e.animations[c];
  24488. a.push(u.currentValue),
  24489. s.push(u.weight / o)
  24490. }
  24491. for (var h = 0, d = 0; d < a.length; )
  24492. d ? (h += s[d],
  24493. C.SlerpToRef(r, a[d], s[d] / h, r),
  24494. d++) : (C.SlerpToRef(a[d], a[d + 1], s[d + 1] / (s[d] + s[d + 1]), t),
  24495. r = t,
  24496. h = s[d] + s[d + 1],
  24497. d += 2)
  24498. }
  24499. for (c = 0; c < e.additiveAnimations.length; c++)
  24500. 0 !== (u = e.additiveAnimations[c]).weight && (r.multiplyToRef(u.currentValue, I.Quaternion[0]),
  24501. C.SlerpToRef(r, I.Quaternion[0], u.weight, r));
  24502. return r
  24503. }
  24504. ,
  24505. mn.prototype._processLateAnimationBindings = function() {
  24506. if (this._registeredForLateAnimationBindings.length) {
  24507. for (var e = 0; e < this._registeredForLateAnimationBindings.length; e++) {
  24508. var t = this._registeredForLateAnimationBindings.data[e];
  24509. for (var i in t._lateAnimationHolders) {
  24510. var n = t._lateAnimationHolders[i]
  24511. , r = n.animations[0]
  24512. , o = n.originalValue
  24513. , a = Qe.AllowMatrixDecomposeForInterpolation && o.m
  24514. , s = t[i];
  24515. if (a)
  24516. s = this._processLateAnimationBindingsForMatrices(n);
  24517. else if (void 0 !== o.w)
  24518. s = this._processLateAnimationBindingsForQuaternions(n, s || C.Identity());
  24519. else {
  24520. var l = 0
  24521. , c = 1;
  24522. n.totalWeight < 1 ? s = r && o.scale ? o.scale(1 - n.totalWeight) : r ? o * (1 - n.totalWeight) : o.clone ? o.clone() : o : r && (c = n.totalWeight,
  24523. s = 1 != (d = r.weight / c) ? r.currentValue.scale ? r.currentValue.scale(d) : r.currentValue * d : r.currentValue,
  24524. l = 1);
  24525. for (var u = l; u < n.animations.length; u++)
  24526. (d = (h = n.animations[u]).weight / c) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d);
  24527. for (u = 0; u < n.additiveAnimations.length; u++) {
  24528. var h, d;
  24529. (d = (h = n.additiveAnimations[u]).weight) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d)
  24530. }
  24531. }
  24532. t[i] = s
  24533. }
  24534. t._lateAnimationHolders = {}
  24535. }
  24536. this._registeredForLateAnimationBindings.reset()
  24537. }
  24538. }
  24539. ,
  24540. yn.prototype.copyAnimationRange = function(e, t, i, n, r) {
  24541. void 0 === n && (n = !1),
  24542. void 0 === r && (r = null),
  24543. 0 === this.animations.length && (this.animations.push(new Qe(this.name,"_matrix",e.animations[0].framePerSecond,Qe.ANIMATIONTYPE_MATRIX,0)),
  24544. this.animations[0].setKeys([]));
  24545. var o = e.animations[0].getRange(t);
  24546. if (!o)
  24547. return !1;
  24548. for (var a, s, l, c = o.from, u = o.to, h = e.animations[0].getKeys(), d = e.length, p = e.getParent(), f = this.getParent(), _ = n && p && d && this.length && d !== this.length, m = _ && f && p ? f.length / p.length : 1, g = n && !f && r && (1 !== r.x || 1 !== r.y || 1 !== r.z), v = this.animations[0].getKeys(), y = 0, b = h.length; y < b; y++)
  24549. (a = h[y]).frame >= c && a.frame <= u && (n ? (l = a.value.clone(),
  24550. _ ? (s = l.getTranslation(),
  24551. l.setTranslation(s.scaleInPlace(m))) : g && r ? (s = l.getTranslation(),
  24552. l.setTranslation(s.multiplyInPlace(r))) : l = a.value) : l = a.value,
  24553. v.push({
  24554. frame: a.frame + i,
  24555. value: l
  24556. }));
  24557. return this.animations[0].createRange(t, c + i, u + i),
  24558. !0
  24559. }
  24560. ;
  24561. var Tn, En = function() {
  24562. this.enableBlending = !1,
  24563. this.blendingSpeed = .01,
  24564. this.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE
  24565. };
  24566. !function(e) {
  24567. e[e.CW = 0] = "CW",
  24568. e[e.CCW = 1] = "CCW"
  24569. }(Tn || (Tn = {}));
  24570. var Sn = function() {
  24571. function e() {}
  24572. return e.Interpolate = function(e, t, i, n, r) {
  24573. for (var o = 1 - 3 * n + 3 * t, a = 3 * n - 6 * t, s = 3 * t, l = e, c = 0; c < 5; c++) {
  24574. var u = l * l;
  24575. l -= 1 / (3 * o * u + 2 * a * l + s) * (o * (u * l) + a * u + s * l - e),
  24576. l = Math.min(1, Math.max(0, l))
  24577. }
  24578. return 3 * Math.pow(1 - l, 2) * l * i + 3 * (1 - l) * Math.pow(l, 2) * r + Math.pow(l, 3)
  24579. }
  24580. ,
  24581. e
  24582. }()
  24583. , An = function() {
  24584. function e(e) {
  24585. this._radians = e,
  24586. this._radians < 0 && (this._radians += 2 * Math.PI)
  24587. }
  24588. return e.prototype.degrees = function() {
  24589. return 180 * this._radians / Math.PI
  24590. }
  24591. ,
  24592. e.prototype.radians = function() {
  24593. return this._radians
  24594. }
  24595. ,
  24596. e.BetweenTwoPoints = function(t, i) {
  24597. var n = i.subtract(t);
  24598. return new e(Math.atan2(n.y, n.x))
  24599. }
  24600. ,
  24601. e.FromRadians = function(t) {
  24602. return new e(t)
  24603. }
  24604. ,
  24605. e.FromDegrees = function(t) {
  24606. return new e(t * Math.PI / 180)
  24607. }
  24608. ,
  24609. e
  24610. }()
  24611. , xn = function(e, t, i) {
  24612. this.startPoint = e,
  24613. this.midPoint = t,
  24614. this.endPoint = i;
  24615. var n = Math.pow(t.x, 2) + Math.pow(t.y, 2)
  24616. , r = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - n) / 2
  24617. , o = (n - Math.pow(i.x, 2) - Math.pow(i.y, 2)) / 2
  24618. , a = (e.x - t.x) * (t.y - i.y) - (t.x - i.x) * (e.y - t.y);
  24619. this.centerPoint = new A((r * (t.y - i.y) - o * (e.y - t.y)) / a,((e.x - t.x) * o - (t.x - i.x) * r) / a),
  24620. this.radius = this.centerPoint.subtract(this.startPoint).length(),
  24621. this.startAngle = An.BetweenTwoPoints(this.centerPoint, this.startPoint);
  24622. var s = this.startAngle.degrees()
  24623. , l = An.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
  24624. , c = An.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  24625. l - s > 180 && (l -= 360),
  24626. l - s < -180 && (l += 360),
  24627. c - l > 180 && (c -= 360),
  24628. c - l < -180 && (c += 360),
  24629. this.orientation = l - s < 0 ? Tn.CW : Tn.CCW,
  24630. this.angle = An.FromDegrees(this.orientation === Tn.CW ? s - c : c - s)
  24631. }
  24632. , Rn = function() {
  24633. function e(e, t) {
  24634. this._points = new Array,
  24635. this._length = 0,
  24636. this.closed = !1,
  24637. this._points.push(new A(e,t))
  24638. }
  24639. return e.prototype.addLineTo = function(e, t) {
  24640. if (this.closed)
  24641. return this;
  24642. var i = new A(e,t)
  24643. , n = this._points[this._points.length - 1];
  24644. return this._points.push(i),
  24645. this._length += i.subtract(n).length(),
  24646. this
  24647. }
  24648. ,
  24649. e.prototype.addArcTo = function(e, t, i, n, r) {
  24650. if (void 0 === r && (r = 36),
  24651. this.closed)
  24652. return this;
  24653. var o = this._points[this._points.length - 1]
  24654. , a = new A(e,t)
  24655. , s = new A(i,n)
  24656. , l = new xn(o,a,s)
  24657. , c = l.angle.radians() / r;
  24658. l.orientation === Tn.CW && (c *= -1);
  24659. for (var u = l.startAngle.radians() + c, h = 0; h < r; h++) {
  24660. var d = Math.cos(u) * l.radius + l.centerPoint.x
  24661. , p = Math.sin(u) * l.radius + l.centerPoint.y;
  24662. this.addLineTo(d, p),
  24663. u += c
  24664. }
  24665. return this
  24666. }
  24667. ,
  24668. e.prototype.close = function() {
  24669. return this.closed = !0,
  24670. this
  24671. }
  24672. ,
  24673. e.prototype.length = function() {
  24674. var e = this._length;
  24675. if (this.closed) {
  24676. var t = this._points[this._points.length - 1];
  24677. e += this._points[0].subtract(t).length()
  24678. }
  24679. return e
  24680. }
  24681. ,
  24682. e.prototype.getPoints = function() {
  24683. return this._points
  24684. }
  24685. ,
  24686. e.prototype.getPointAtLengthPosition = function(e) {
  24687. if (e < 0 || e > 1)
  24688. return A.Zero();
  24689. for (var t = e * this.length(), i = 0, n = 0; n < this._points.length; n++) {
  24690. var r = (n + 1) % this._points.length
  24691. , o = this._points[n]
  24692. , a = this._points[r].subtract(o)
  24693. , s = a.length() + i;
  24694. if (t >= i && t <= s) {
  24695. var l = a.normalize()
  24696. , c = t - i;
  24697. return new A(o.x + l.x * c,o.y + l.y * c)
  24698. }
  24699. i = s
  24700. }
  24701. return A.Zero()
  24702. }
  24703. ,
  24704. e.StartingAt = function(t, i) {
  24705. return new e(t,i)
  24706. }
  24707. ,
  24708. e
  24709. }()
  24710. , Cn = function() {
  24711. function e(e, t, i, n) {
  24712. void 0 === t && (t = null),
  24713. void 0 === n && (n = !1),
  24714. this.path = e,
  24715. this._curve = new Array,
  24716. this._distances = new Array,
  24717. this._tangents = new Array,
  24718. this._normals = new Array,
  24719. this._binormals = new Array,
  24720. this._pointAtData = {
  24721. id: 0,
  24722. point: x.Zero(),
  24723. previousPointArrayIndex: 0,
  24724. position: 0,
  24725. subPosition: 0,
  24726. interpolateReady: !1,
  24727. interpolationMatrix: P.Identity()
  24728. };
  24729. for (var r = 0; r < e.length; r++)
  24730. this._curve[r] = e[r].clone();
  24731. this._raw = i || !1,
  24732. this._alignTangentsWithPath = n,
  24733. this._compute(t, n)
  24734. }
  24735. return e.prototype.getCurve = function() {
  24736. return this._curve
  24737. }
  24738. ,
  24739. e.prototype.getPoints = function() {
  24740. return this._curve
  24741. }
  24742. ,
  24743. e.prototype.length = function() {
  24744. return this._distances[this._distances.length - 1]
  24745. }
  24746. ,
  24747. e.prototype.getTangents = function() {
  24748. return this._tangents
  24749. }
  24750. ,
  24751. e.prototype.getNormals = function() {
  24752. return this._normals
  24753. }
  24754. ,
  24755. e.prototype.getBinormals = function() {
  24756. return this._binormals
  24757. }
  24758. ,
  24759. e.prototype.getDistances = function() {
  24760. return this._distances
  24761. }
  24762. ,
  24763. e.prototype.getPointAt = function(e) {
  24764. return this._updatePointAtData(e).point
  24765. }
  24766. ,
  24767. e.prototype.getTangentAt = function(e, t) {
  24768. return void 0 === t && (t = !1),
  24769. this._updatePointAtData(e, t),
  24770. t ? x.TransformCoordinates(x.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex]
  24771. }
  24772. ,
  24773. e.prototype.getNormalAt = function(e, t) {
  24774. return void 0 === t && (t = !1),
  24775. this._updatePointAtData(e, t),
  24776. t ? x.TransformCoordinates(x.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex]
  24777. }
  24778. ,
  24779. e.prototype.getBinormalAt = function(e, t) {
  24780. return void 0 === t && (t = !1),
  24781. this._updatePointAtData(e, t),
  24782. t ? x.TransformCoordinates(x.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex]
  24783. }
  24784. ,
  24785. e.prototype.getDistanceAt = function(e) {
  24786. return this.length() * e
  24787. }
  24788. ,
  24789. e.prototype.getPreviousPointIndexAt = function(e) {
  24790. return this._updatePointAtData(e),
  24791. this._pointAtData.previousPointArrayIndex
  24792. }
  24793. ,
  24794. e.prototype.getSubPositionAt = function(e) {
  24795. return this._updatePointAtData(e),
  24796. this._pointAtData.subPosition
  24797. }
  24798. ,
  24799. e.prototype.getClosestPositionTo = function(e) {
  24800. for (var t = Number.MAX_VALUE, i = 0, n = 0; n < this._curve.length - 1; n++) {
  24801. var r = this._curve[n + 0]
  24802. , o = this._curve[n + 1].subtract(r).normalize()
  24803. , a = this._distances[n + 1] - this._distances[n + 0]
  24804. , s = Math.min(Math.max(x.Dot(o, e.subtract(r).normalize()), 0) * x.Distance(r, e) / a, 1)
  24805. , l = x.Distance(r.add(o.scale(s * a)), e);
  24806. l < t && (t = l,
  24807. i = (this._distances[n + 0] + a * s) / this.length())
  24808. }
  24809. return i
  24810. }
  24811. ,
  24812. e.prototype.slice = function(t, i) {
  24813. if (void 0 === t && (t = 0),
  24814. void 0 === i && (i = 1),
  24815. t < 0 && (t = 1 - -1 * t % 1),
  24816. i < 0 && (i = 1 - -1 * i % 1),
  24817. t > i) {
  24818. var n = t;
  24819. t = i,
  24820. i = n
  24821. }
  24822. var r = this.getCurve()
  24823. , o = this.getPointAt(t)
  24824. , a = this.getPreviousPointIndexAt(t)
  24825. , s = this.getPointAt(i)
  24826. , l = this.getPreviousPointIndexAt(i) + 1
  24827. , c = [];
  24828. return 0 !== t && (a++,
  24829. c.push(o)),
  24830. c.push.apply(c, r.slice(a, l)),
  24831. 1 === i && 1 !== t || c.push(s),
  24832. new e(c,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)
  24833. }
  24834. ,
  24835. e.prototype.update = function(e, t, i) {
  24836. void 0 === t && (t = null),
  24837. void 0 === i && (i = !1);
  24838. for (var n = 0; n < e.length; n++)
  24839. this._curve[n].x = e[n].x,
  24840. this._curve[n].y = e[n].y,
  24841. this._curve[n].z = e[n].z;
  24842. return this._compute(t, i),
  24843. this
  24844. }
  24845. ,
  24846. e.prototype._compute = function(e, t) {
  24847. void 0 === t && (t = !1);
  24848. var i = this._curve.length;
  24849. if (!(i < 2)) {
  24850. this._tangents[0] = this._getFirstNonNullVector(0),
  24851. this._raw || this._tangents[0].normalize(),
  24852. this._tangents[i - 1] = this._curve[i - 1].subtract(this._curve[i - 2]),
  24853. this._raw || this._tangents[i - 1].normalize();
  24854. var n, r, o, a, s, l = this._tangents[0], c = this._normalVector(l, e);
  24855. this._normals[0] = c,
  24856. this._raw || this._normals[0].normalize(),
  24857. this._binormals[0] = x.Cross(l, this._normals[0]),
  24858. this._raw || this._binormals[0].normalize(),
  24859. this._distances[0] = 0;
  24860. for (var u = 1; u < i; u++)
  24861. n = this._getLastNonNullVector(u),
  24862. u < i - 1 && (r = this._getFirstNonNullVector(u),
  24863. this._tangents[u] = t ? r : n.add(r),
  24864. this._tangents[u].normalize()),
  24865. this._distances[u] = this._distances[u - 1] + this._curve[u].subtract(this._curve[u - 1]).length(),
  24866. o = this._tangents[u],
  24867. s = this._binormals[u - 1],
  24868. this._normals[u] = x.Cross(s, o),
  24869. this._raw || (0 === this._normals[u].length() ? (a = this._normals[u - 1],
  24870. this._normals[u] = a.clone()) : this._normals[u].normalize()),
  24871. this._binormals[u] = x.Cross(o, this._normals[u]),
  24872. this._raw || this._binormals[u].normalize();
  24873. this._pointAtData.id = NaN
  24874. }
  24875. }
  24876. ,
  24877. e.prototype._getFirstNonNullVector = function(e) {
  24878. for (var t = 1, i = this._curve[e + t].subtract(this._curve[e]); 0 === i.length() && e + t + 1 < this._curve.length; )
  24879. t++,
  24880. i = this._curve[e + t].subtract(this._curve[e]);
  24881. return i
  24882. }
  24883. ,
  24884. e.prototype._getLastNonNullVector = function(e) {
  24885. for (var t = 1, i = this._curve[e].subtract(this._curve[e - t]); 0 === i.length() && e > t + 1; )
  24886. t++,
  24887. i = this._curve[e].subtract(this._curve[e - t]);
  24888. return i
  24889. }
  24890. ,
  24891. e.prototype._normalVector = function(e, t) {
  24892. var i, n = e.length();
  24893. if (0 === n && (n = 1),
  24894. null == t) {
  24895. var r;
  24896. r = d.WithinEpsilon(Math.abs(e.y) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.x) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.z) / n, 1, m) ? x.Zero() : new x(0,0,1) : new x(1,0,0) : new x(0,-1,0),
  24897. i = x.Cross(e, r)
  24898. } else
  24899. i = x.Cross(e, t),
  24900. x.CrossToRef(i, e, i);
  24901. return i.normalize(),
  24902. i
  24903. }
  24904. ,
  24905. e.prototype._updatePointAtData = function(e, t) {
  24906. if (void 0 === t && (t = !1),
  24907. this._pointAtData.id === e)
  24908. return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(),
  24909. this._pointAtData;
  24910. this._pointAtData.id = e;
  24911. var i = this.getPoints();
  24912. if (e <= 0)
  24913. return this._setPointAtData(0, 0, i[0], 0, t);
  24914. if (e >= 1)
  24915. return this._setPointAtData(1, 1, i[i.length - 1], i.length - 1, t);
  24916. for (var n, r = i[0], o = 0, a = e * this.length(), s = 1; s < i.length; s++) {
  24917. n = i[s];
  24918. var l = x.Distance(r, n);
  24919. if ((o += l) === a)
  24920. return this._setPointAtData(e, 1, n, s, t);
  24921. if (o > a) {
  24922. var c = (o - a) / l
  24923. , u = r.subtract(n)
  24924. , h = n.add(u.scaleInPlace(c));
  24925. return this._setPointAtData(e, 1 - c, h, s - 1, t)
  24926. }
  24927. r = n
  24928. }
  24929. return this._pointAtData
  24930. }
  24931. ,
  24932. e.prototype._setPointAtData = function(e, t, i, n, r) {
  24933. return this._pointAtData.point = i,
  24934. this._pointAtData.position = e,
  24935. this._pointAtData.subPosition = t,
  24936. this._pointAtData.previousPointArrayIndex = n,
  24937. this._pointAtData.interpolateReady = r,
  24938. r && this._updateInterpolationMatrix(),
  24939. this._pointAtData
  24940. }
  24941. ,
  24942. e.prototype._updateInterpolationMatrix = function() {
  24943. this._pointAtData.interpolationMatrix = P.Identity();
  24944. var e = this._pointAtData.previousPointArrayIndex;
  24945. if (e !== this._tangents.length - 1) {
  24946. var t = e + 1
  24947. , i = this._tangents[e].clone()
  24948. , n = this._normals[e].clone()
  24949. , r = this._binormals[e].clone()
  24950. , o = this._tangents[t].clone()
  24951. , a = this._normals[t].clone()
  24952. , s = this._binormals[t].clone()
  24953. , l = C.RotationQuaternionFromAxis(n, r, i)
  24954. , c = C.RotationQuaternionFromAxis(a, s, o);
  24955. C.Slerp(l, c, this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)
  24956. }
  24957. }
  24958. ,
  24959. e
  24960. }()
  24961. , Pn = function() {
  24962. function e(e) {
  24963. this._length = 0,
  24964. this._points = e,
  24965. this._length = this._computeLength(e)
  24966. }
  24967. return e.CreateQuadraticBezier = function(t, i, n, r) {
  24968. r = r > 2 ? r : 3;
  24969. for (var o = new Array, a = function(e, t, i, n) {
  24970. return (1 - e) * (1 - e) * t + 2 * e * (1 - e) * i + e * e * n
  24971. }, s = 0; s <= r; s++)
  24972. o.push(new x(a(s / r, t.x, i.x, n.x),a(s / r, t.y, i.y, n.y),a(s / r, t.z, i.z, n.z)));
  24973. return new e(o)
  24974. }
  24975. ,
  24976. e.CreateCubicBezier = function(t, i, n, r, o) {
  24977. o = o > 3 ? o : 4;
  24978. for (var a = new Array, s = function(e, t, i, n, r) {
  24979. return (1 - e) * (1 - e) * (1 - e) * t + 3 * e * (1 - e) * (1 - e) * i + 3 * e * e * (1 - e) * n + e * e * e * r
  24980. }, l = 0; l <= o; l++)
  24981. a.push(new x(s(l / o, t.x, i.x, n.x, r.x),s(l / o, t.y, i.y, n.y, r.y),s(l / o, t.z, i.z, n.z, r.z)));
  24982. return new e(a)
  24983. }
  24984. ,
  24985. e.CreateHermiteSpline = function(t, i, n, r, o) {
  24986. for (var a = new Array, s = 1 / o, l = 0; l <= o; l++)
  24987. a.push(x.Hermite(t, i, n, r, l * s));
  24988. return new e(a)
  24989. }
  24990. ,
  24991. e.CreateCatmullRomSpline = function(t, i, n) {
  24992. var r = new Array
  24993. , o = 1 / i
  24994. , a = 0;
  24995. if (n) {
  24996. for (var s = t.length, l = 0; l < s; l++) {
  24997. a = 0;
  24998. for (var c = 0; c < i; c++)
  24999. r.push(x.CatmullRom(t[l % s], t[(l + 1) % s], t[(l + 2) % s], t[(l + 3) % s], a)),
  25000. a += o
  25001. }
  25002. r.push(r[0])
  25003. } else {
  25004. var u = new Array;
  25005. for (u.push(t[0].clone()),
  25006. Array.prototype.push.apply(u, t),
  25007. u.push(t[t.length - 1].clone()),
  25008. l = 0; l < u.length - 3; l++)
  25009. for (a = 0,
  25010. c = 0; c < i; c++)
  25011. r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)),
  25012. a += o;
  25013. l--,
  25014. r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a))
  25015. }
  25016. return new e(r)
  25017. }
  25018. ,
  25019. e.prototype.getPoints = function() {
  25020. return this._points
  25021. }
  25022. ,
  25023. e.prototype.length = function() {
  25024. return this._length
  25025. }
  25026. ,
  25027. e.prototype.continue = function(t) {
  25028. for (var i = this._points[this._points.length - 1], n = this._points.slice(), r = t.getPoints(), o = 1; o < r.length; o++)
  25029. n.push(r[o].subtract(r[0]).add(i));
  25030. return new e(n)
  25031. }
  25032. ,
  25033. e.prototype._computeLength = function(e) {
  25034. for (var t = 0, i = 1; i < e.length; i++)
  25035. t += e[i].subtract(e[i - 1]).length();
  25036. return t
  25037. }
  25038. ,
  25039. e
  25040. }()
  25041. , Mn = function() {
  25042. function e() {
  25043. this._easingMode = e.EASINGMODE_EASEIN
  25044. }
  25045. return e.prototype.setEasingMode = function(e) {
  25046. var t = Math.min(Math.max(e, 0), 2);
  25047. this._easingMode = t
  25048. }
  25049. ,
  25050. e.prototype.getEasingMode = function() {
  25051. return this._easingMode
  25052. }
  25053. ,
  25054. e.prototype.easeInCore = function(e) {
  25055. throw new Error("You must implement this method")
  25056. }
  25057. ,
  25058. e.prototype.ease = function(t) {
  25059. switch (this._easingMode) {
  25060. case e.EASINGMODE_EASEIN:
  25061. return this.easeInCore(t);
  25062. case e.EASINGMODE_EASEOUT:
  25063. return 1 - this.easeInCore(1 - t)
  25064. }
  25065. return t >= .5 ? .5 * (1 - this.easeInCore(2 * (1 - t))) + .5 : .5 * this.easeInCore(2 * t)
  25066. }
  25067. ,
  25068. e.EASINGMODE_EASEIN = 0,
  25069. e.EASINGMODE_EASEOUT = 1,
  25070. e.EASINGMODE_EASEINOUT = 2,
  25071. e
  25072. }()
  25073. , In = function(e) {
  25074. function t() {
  25075. return null !== e && e.apply(this, arguments) || this
  25076. }
  25077. return U(t, e),
  25078. t.prototype.easeInCore = function(e) {
  25079. return e = Math.max(0, Math.min(1, e)),
  25080. 1 - Math.sqrt(1 - e * e)
  25081. }
  25082. ,
  25083. t
  25084. }(Mn)
  25085. , On = function(e) {
  25086. function t(t) {
  25087. void 0 === t && (t = 1);
  25088. var i = e.call(this) || this;
  25089. return i.amplitude = t,
  25090. i
  25091. }
  25092. return U(t, e),
  25093. t.prototype.easeInCore = function(e) {
  25094. var t = Math.max(0, this.amplitude);
  25095. return Math.pow(e, 3) - e * t * Math.sin(3.141592653589793 * e)
  25096. }
  25097. ,
  25098. t
  25099. }(Mn)
  25100. , Dn = function(e) {
  25101. function t(t, i) {
  25102. void 0 === t && (t = 3),
  25103. void 0 === i && (i = 2);
  25104. var n = e.call(this) || this;
  25105. return n.bounces = t,
  25106. n.bounciness = i,
  25107. n
  25108. }
  25109. return U(t, e),
  25110. t.prototype.easeInCore = function(e) {
  25111. var t = Math.max(0, this.bounces)
  25112. , i = this.bounciness;
  25113. i <= 1 && (i = 1.001);
  25114. var n = Math.pow(i, t)
  25115. , r = 1 - i
  25116. , o = (1 - n) / r + .5 * n
  25117. , a = e * o
  25118. , s = Math.log(-a * (1 - i) + 1) / Math.log(i)
  25119. , l = Math.floor(s)
  25120. , c = l + 1
  25121. , u = (1 - Math.pow(i, l)) / (r * o)
  25122. , h = .5 * (u + (1 - Math.pow(i, c)) / (r * o))
  25123. , d = e - h
  25124. , p = h - u;
  25125. return -Math.pow(1 / i, t - l) / (p * p) * (d - p) * (d + p)
  25126. }
  25127. ,
  25128. t
  25129. }(Mn)
  25130. , Nn = function(e) {
  25131. function t() {
  25132. return null !== e && e.apply(this, arguments) || this
  25133. }
  25134. return U(t, e),
  25135. t.prototype.easeInCore = function(e) {
  25136. return e * e * e
  25137. }
  25138. ,
  25139. t
  25140. }(Mn)
  25141. , Ln = function(e) {
  25142. function t(t, i) {
  25143. void 0 === t && (t = 3),
  25144. void 0 === i && (i = 3);
  25145. var n = e.call(this) || this;
  25146. return n.oscillations = t,
  25147. n.springiness = i,
  25148. n
  25149. }
  25150. return U(t, e),
  25151. t.prototype.easeInCore = function(e) {
  25152. var t = Math.max(0, this.oscillations)
  25153. , i = Math.max(0, this.springiness);
  25154. return (0 == i ? e : (Math.exp(i * e) - 1) / (Math.exp(i) - 1)) * Math.sin((6.283185307179586 * t + 1.5707963267948966) * e)
  25155. }
  25156. ,
  25157. t
  25158. }(Mn)
  25159. , Fn = function(e) {
  25160. function t(t) {
  25161. void 0 === t && (t = 2);
  25162. var i = e.call(this) || this;
  25163. return i.exponent = t,
  25164. i
  25165. }
  25166. return U(t, e),
  25167. t.prototype.easeInCore = function(e) {
  25168. return this.exponent <= 0 ? e : (Math.exp(this.exponent * e) - 1) / (Math.exp(this.exponent) - 1)
  25169. }
  25170. ,
  25171. t
  25172. }(Mn)
  25173. , wn = function(e) {
  25174. function t(t) {
  25175. void 0 === t && (t = 2);
  25176. var i = e.call(this) || this;
  25177. return i.power = t,
  25178. i
  25179. }
  25180. return U(t, e),
  25181. t.prototype.easeInCore = function(e) {
  25182. var t = Math.max(0, this.power);
  25183. return Math.pow(e, t)
  25184. }
  25185. ,
  25186. t
  25187. }(Mn)
  25188. , Bn = function(e) {
  25189. function t() {
  25190. return null !== e && e.apply(this, arguments) || this
  25191. }
  25192. return U(t, e),
  25193. t.prototype.easeInCore = function(e) {
  25194. return e * e
  25195. }
  25196. ,
  25197. t
  25198. }(Mn)
  25199. , Un = function(e) {
  25200. function t() {
  25201. return null !== e && e.apply(this, arguments) || this
  25202. }
  25203. return U(t, e),
  25204. t.prototype.easeInCore = function(e) {
  25205. return e * e * e * e
  25206. }
  25207. ,
  25208. t
  25209. }(Mn)
  25210. , Vn = function(e) {
  25211. function t() {
  25212. return null !== e && e.apply(this, arguments) || this
  25213. }
  25214. return U(t, e),
  25215. t.prototype.easeInCore = function(e) {
  25216. return e * e * e * e * e
  25217. }
  25218. ,
  25219. t
  25220. }(Mn)
  25221. , kn = function(e) {
  25222. function t() {
  25223. return null !== e && e.apply(this, arguments) || this
  25224. }
  25225. return U(t, e),
  25226. t.prototype.easeInCore = function(e) {
  25227. return 1 - Math.sin(1.5707963267948966 * (1 - e))
  25228. }
  25229. ,
  25230. t
  25231. }(Mn)
  25232. , Gn = function(e) {
  25233. function t(t, i, n, r) {
  25234. void 0 === t && (t = 0),
  25235. void 0 === i && (i = 0),
  25236. void 0 === n && (n = 1),
  25237. void 0 === r && (r = 1);
  25238. var o = e.call(this) || this;
  25239. return o.x1 = t,
  25240. o.y1 = i,
  25241. o.x2 = n,
  25242. o.y2 = r,
  25243. o
  25244. }
  25245. return U(t, e),
  25246. t.prototype.easeInCore = function(e) {
  25247. return Sn.Interpolate(e, this.x1, this.y1, this.x2, this.y2)
  25248. }
  25249. ,
  25250. t
  25251. }(Mn)
  25252. , zn = function() {
  25253. function e(e, t, i) {
  25254. this.frame = e,
  25255. this.action = t,
  25256. this.onlyOnce = i,
  25257. this.isDone = !1
  25258. }
  25259. return e.prototype._clone = function() {
  25260. return new e(this.frame,this.action,this.onlyOnce)
  25261. }
  25262. ,
  25263. e
  25264. }()
  25265. , Wn = function() {
  25266. function e() {}
  25267. return e.prototype.getClassName = function() {
  25268. return "TargetedAnimation"
  25269. }
  25270. ,
  25271. e.prototype.serialize = function() {
  25272. var e = {};
  25273. return e.animation = this.animation.serialize(),
  25274. e.targetId = this.target.id,
  25275. e
  25276. }
  25277. ,
  25278. e
  25279. }()
  25280. , Hn = function() {
  25281. function e(e, t) {
  25282. void 0 === t && (t = null),
  25283. this.name = e,
  25284. this._targetedAnimations = new Array,
  25285. this._animatables = new Array,
  25286. this._from = Number.MAX_VALUE,
  25287. this._to = -Number.MAX_VALUE,
  25288. this._speedRatio = 1,
  25289. this._loopAnimation = !1,
  25290. this._isAdditive = !1,
  25291. this._parentContainer = null,
  25292. this.onAnimationEndObservable = new h,
  25293. this.onAnimationLoopObservable = new h,
  25294. this.onAnimationGroupLoopObservable = new h,
  25295. this.onAnimationGroupEndObservable = new h,
  25296. this.onAnimationGroupPauseObservable = new h,
  25297. this.onAnimationGroupPlayObservable = new h,
  25298. this.metadata = null,
  25299. this._scene = t || E.LastCreatedScene,
  25300. this.uniqueId = this._scene.getUniqueId(),
  25301. this._scene.addAnimationGroup(this)
  25302. }
  25303. return Object.defineProperty(e.prototype, "from", {
  25304. get: function() {
  25305. return this._from
  25306. },
  25307. enumerable: !1,
  25308. configurable: !0
  25309. }),
  25310. Object.defineProperty(e.prototype, "to", {
  25311. get: function() {
  25312. return this._to
  25313. },
  25314. enumerable: !1,
  25315. configurable: !0
  25316. }),
  25317. Object.defineProperty(e.prototype, "isStarted", {
  25318. get: function() {
  25319. return this._isStarted
  25320. },
  25321. enumerable: !1,
  25322. configurable: !0
  25323. }),
  25324. Object.defineProperty(e.prototype, "isPlaying", {
  25325. get: function() {
  25326. return this._isStarted && !this._isPaused
  25327. },
  25328. enumerable: !1,
  25329. configurable: !0
  25330. }),
  25331. Object.defineProperty(e.prototype, "speedRatio", {
  25332. get: function() {
  25333. return this._speedRatio
  25334. },
  25335. set: function(e) {
  25336. if (this._speedRatio !== e) {
  25337. this._speedRatio = e;
  25338. for (var t = 0; t < this._animatables.length; t++)
  25339. this._animatables[t].speedRatio = this._speedRatio
  25340. }
  25341. },
  25342. enumerable: !1,
  25343. configurable: !0
  25344. }),
  25345. Object.defineProperty(e.prototype, "loopAnimation", {
  25346. get: function() {
  25347. return this._loopAnimation
  25348. },
  25349. set: function(e) {
  25350. if (this._loopAnimation !== e) {
  25351. this._loopAnimation = e;
  25352. for (var t = 0; t < this._animatables.length; t++)
  25353. this._animatables[t].loopAnimation = this._loopAnimation
  25354. }
  25355. },
  25356. enumerable: !1,
  25357. configurable: !0
  25358. }),
  25359. Object.defineProperty(e.prototype, "isAdditive", {
  25360. get: function() {
  25361. return this._isAdditive
  25362. },
  25363. set: function(e) {
  25364. if (this._isAdditive !== e) {
  25365. this._isAdditive = e;
  25366. for (var t = 0; t < this._animatables.length; t++)
  25367. this._animatables[t].isAdditive = this._isAdditive
  25368. }
  25369. },
  25370. enumerable: !1,
  25371. configurable: !0
  25372. }),
  25373. Object.defineProperty(e.prototype, "targetedAnimations", {
  25374. get: function() {
  25375. return this._targetedAnimations
  25376. },
  25377. enumerable: !1,
  25378. configurable: !0
  25379. }),
  25380. Object.defineProperty(e.prototype, "animatables", {
  25381. get: function() {
  25382. return this._animatables
  25383. },
  25384. enumerable: !1,
  25385. configurable: !0
  25386. }),
  25387. Object.defineProperty(e.prototype, "children", {
  25388. get: function() {
  25389. return this._targetedAnimations
  25390. },
  25391. enumerable: !1,
  25392. configurable: !0
  25393. }),
  25394. e.prototype.addTargetedAnimation = function(e, t) {
  25395. var i = new Wn;
  25396. i.animation = e,
  25397. i.target = t;
  25398. var n = e.getKeys();
  25399. return this._from > n[0].frame && (this._from = n[0].frame),
  25400. this._to < n[n.length - 1].frame && (this._to = n[n.length - 1].frame),
  25401. this._targetedAnimations.push(i),
  25402. i
  25403. }
  25404. ,
  25405. e.prototype.normalize = function(e, t) {
  25406. void 0 === e && (e = null),
  25407. void 0 === t && (t = null),
  25408. null == e && (e = this._from),
  25409. null == t && (t = this._to);
  25410. for (var i = 0; i < this._targetedAnimations.length; i++) {
  25411. var n = this._targetedAnimations[i].animation.getKeys()
  25412. , r = n[0]
  25413. , o = n[n.length - 1];
  25414. if (r.frame > e) {
  25415. var a = {
  25416. frame: e,
  25417. value: r.value,
  25418. inTangent: r.inTangent,
  25419. outTangent: r.outTangent,
  25420. interpolation: r.interpolation
  25421. };
  25422. n.splice(0, 0, a)
  25423. }
  25424. o.frame < t && (a = {
  25425. frame: t,
  25426. value: o.value,
  25427. inTangent: o.inTangent,
  25428. outTangent: o.outTangent,
  25429. interpolation: o.interpolation
  25430. },
  25431. n.push(a))
  25432. }
  25433. return this._from = e,
  25434. this._to = t,
  25435. this
  25436. }
  25437. ,
  25438. e.prototype._processLoop = function(e, t, i) {
  25439. var n = this;
  25440. e.onAnimationLoop = function() {
  25441. n.onAnimationLoopObservable.notifyObservers(t),
  25442. n._animationLoopFlags[i] || (n._animationLoopFlags[i] = !0,
  25443. n._animationLoopCount++,
  25444. n._animationLoopCount === n._targetedAnimations.length && (n.onAnimationGroupLoopObservable.notifyObservers(n),
  25445. n._animationLoopCount = 0,
  25446. n._animationLoopFlags = []))
  25447. }
  25448. }
  25449. ,
  25450. e.prototype.start = function(e, t, i, n, r) {
  25451. var o = this;
  25452. if (void 0 === e && (e = !1),
  25453. void 0 === t && (t = 1),
  25454. this._isStarted || 0 === this._targetedAnimations.length)
  25455. return this;
  25456. this._loopAnimation = e,
  25457. this._animationLoopCount = 0,
  25458. this._animationLoopFlags = [];
  25459. for (var a = function(a) {
  25460. var l = s._targetedAnimations[a]
  25461. , c = s._scene.beginDirectAnimation(l.target, [l.animation], void 0 !== i ? i : s._from, void 0 !== n ? n : s._to, e, t, void 0, void 0, void 0 !== r ? r : s._isAdditive);
  25462. c.onAnimationEnd = function() {
  25463. o.onAnimationEndObservable.notifyObservers(l),
  25464. o._checkAnimationGroupEnded(c)
  25465. }
  25466. ,
  25467. s._processLoop(c, l, a),
  25468. s._animatables.push(c)
  25469. }, s = this, l = 0; l < this._targetedAnimations.length; l++)
  25470. a(l);
  25471. return this._speedRatio = t,
  25472. this._isStarted = !0,
  25473. this._isPaused = !1,
  25474. this.onAnimationGroupPlayObservable.notifyObservers(this),
  25475. this
  25476. }
  25477. ,
  25478. e.prototype.pause = function() {
  25479. if (!this._isStarted)
  25480. return this;
  25481. this._isPaused = !0;
  25482. for (var e = 0; e < this._animatables.length; e++)
  25483. this._animatables[e].pause();
  25484. return this.onAnimationGroupPauseObservable.notifyObservers(this),
  25485. this
  25486. }
  25487. ,
  25488. e.prototype.play = function(e) {
  25489. return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (void 0 !== e && (this.loopAnimation = e),
  25490. this.restart()) : (this.stop(),
  25491. this.start(e, this._speedRatio)),
  25492. this._isPaused = !1,
  25493. this
  25494. }
  25495. ,
  25496. e.prototype.reset = function() {
  25497. if (!this._isStarted)
  25498. return this.play(),
  25499. this.goToFrame(0),
  25500. this.stop(),
  25501. this;
  25502. for (var e = 0; e < this._animatables.length; e++)
  25503. this._animatables[e].reset();
  25504. return this
  25505. }
  25506. ,
  25507. e.prototype.restart = function() {
  25508. if (!this._isStarted)
  25509. return this;
  25510. for (var e = 0; e < this._animatables.length; e++)
  25511. this._animatables[e].restart();
  25512. return this.onAnimationGroupPlayObservable.notifyObservers(this),
  25513. this
  25514. }
  25515. ,
  25516. e.prototype.stop = function() {
  25517. if (!this._isStarted)
  25518. return this;
  25519. for (var e = this._animatables.slice(), t = 0; t < e.length; t++)
  25520. e[t].stop();
  25521. return this._isStarted = !1,
  25522. this
  25523. }
  25524. ,
  25525. e.prototype.setWeightForAllAnimatables = function(e) {
  25526. for (var t = 0; t < this._animatables.length; t++)
  25527. this._animatables[t].weight = e;
  25528. return this
  25529. }
  25530. ,
  25531. e.prototype.syncAllAnimationsWith = function(e) {
  25532. for (var t = 0; t < this._animatables.length; t++)
  25533. this._animatables[t].syncWith(e);
  25534. return this
  25535. }
  25536. ,
  25537. e.prototype.goToFrame = function(e) {
  25538. if (!this._isStarted)
  25539. return this;
  25540. for (var t = 0; t < this._animatables.length; t++)
  25541. this._animatables[t].goToFrame(e);
  25542. return this
  25543. }
  25544. ,
  25545. e.prototype.dispose = function() {
  25546. this._targetedAnimations = [],
  25547. this._animatables = [];
  25548. var e = this._scene.animationGroups.indexOf(this);
  25549. if (e > -1 && this._scene.animationGroups.splice(e, 1),
  25550. this._parentContainer) {
  25551. var t = this._parentContainer.animationGroups.indexOf(this);
  25552. t > -1 && this._parentContainer.animationGroups.splice(t, 1),
  25553. this._parentContainer = null
  25554. }
  25555. this.onAnimationEndObservable.clear(),
  25556. this.onAnimationGroupEndObservable.clear(),
  25557. this.onAnimationGroupPauseObservable.clear(),
  25558. this.onAnimationGroupPlayObservable.clear(),
  25559. this.onAnimationLoopObservable.clear(),
  25560. this.onAnimationGroupLoopObservable.clear()
  25561. }
  25562. ,
  25563. e.prototype._checkAnimationGroupEnded = function(e) {
  25564. var t = this._animatables.indexOf(e);
  25565. t > -1 && this._animatables.splice(t, 1),
  25566. 0 === this._animatables.length && (this._isStarted = !1,
  25567. this.onAnimationGroupEndObservable.notifyObservers(this))
  25568. }
  25569. ,
  25570. e.prototype.clone = function(t, i, n) {
  25571. void 0 === n && (n = !1);
  25572. for (var r = new e(t || this.name,this._scene), o = 0, a = this._targetedAnimations; o < a.length; o++) {
  25573. var s = a[o];
  25574. r.addTargetedAnimation(n ? s.animation.clone() : s.animation, i ? i(s.target) : s.target)
  25575. }
  25576. return r
  25577. }
  25578. ,
  25579. e.prototype.serialize = function() {
  25580. var e = {};
  25581. e.name = this.name,
  25582. e.from = this.from,
  25583. e.to = this.to,
  25584. e.targetedAnimations = [];
  25585. for (var t = 0; t < this.targetedAnimations.length; t++) {
  25586. var i = this.targetedAnimations[t];
  25587. e.targetedAnimations[t] = i.serialize()
  25588. }
  25589. return ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
  25590. this.metadata && (e.metadata = this.metadata),
  25591. e
  25592. }
  25593. ,
  25594. e.Parse = function(t, i) {
  25595. for (var n = new e(t.name,i), r = 0; r < t.targetedAnimations.length; r++) {
  25596. var o = t.targetedAnimations[r]
  25597. , a = Qe.Parse(o.animation)
  25598. , s = o.targetId;
  25599. if ("influence" === o.animation.property) {
  25600. var l = i.getMorphTargetById(s);
  25601. l && n.addTargetedAnimation(a, l)
  25602. } else {
  25603. var c = i.getNodeById(s);
  25604. null != c && n.addTargetedAnimation(a, c)
  25605. }
  25606. }
  25607. return null !== t.from && null !== t.to && n.normalize(t.from, t.to),
  25608. ye && ye.AddTagsTo(n, t.tags),
  25609. void 0 !== t.metadata && (n.metadata = t.metadata),
  25610. n
  25611. }
  25612. ,
  25613. e.MakeAnimationAdditive = function(e, t, i, n, r) {
  25614. void 0 === t && (t = 0),
  25615. void 0 === n && (n = !1);
  25616. var o = e;
  25617. n && (o = e.clone(r || o.name));
  25618. for (var a = o.targetedAnimations, s = 0; s < a.length; s++) {
  25619. var l = a[s];
  25620. Qe.MakeAnimationAdditive(l.animation, t, i)
  25621. }
  25622. return o.isAdditive = !0,
  25623. o
  25624. }
  25625. ,
  25626. e.prototype.getClassName = function() {
  25627. return "AnimationGroup"
  25628. }
  25629. ,
  25630. e.prototype.toString = function(e) {
  25631. var t = "Name: " + this.name;
  25632. return t += ", type: " + this.getClassName(),
  25633. e && (t += ", from: " + this._from,
  25634. t += ", to: " + this._to,
  25635. t += ", isStarted: " + this._isStarted,
  25636. t += ", speedRatio: " + this._speedRatio,
  25637. t += ", targetedAnimations length: " + this._targetedAnimations.length,
  25638. t += ", animatables length: " + this._animatables),
  25639. t
  25640. }
  25641. ,
  25642. e
  25643. }()
  25644. , Xn = function() {
  25645. function e(e) {
  25646. this._path = e,
  25647. this._onchange = new Array,
  25648. this.value = 0,
  25649. this.animations = new Array
  25650. }
  25651. return e.prototype.getPoint = function() {
  25652. var e = this._path.getPointAtLengthPosition(this.value);
  25653. return new x(e.x,0,e.y)
  25654. }
  25655. ,
  25656. e.prototype.moveAhead = function(e) {
  25657. return void 0 === e && (e = .002),
  25658. this.move(e),
  25659. this
  25660. }
  25661. ,
  25662. e.prototype.moveBack = function(e) {
  25663. return void 0 === e && (e = .002),
  25664. this.move(-e),
  25665. this
  25666. }
  25667. ,
  25668. e.prototype.move = function(e) {
  25669. if (Math.abs(e) > 1)
  25670. throw "step size should be less than 1.";
  25671. return this.value += e,
  25672. this._ensureLimits(),
  25673. this._raiseOnChange(),
  25674. this
  25675. }
  25676. ,
  25677. e.prototype._ensureLimits = function() {
  25678. for (; this.value > 1; )
  25679. this.value -= 1;
  25680. for (; this.value < 0; )
  25681. this.value += 1;
  25682. return this
  25683. }
  25684. ,
  25685. e.prototype._raiseOnChange = function() {
  25686. var e = this;
  25687. return this._onchange.forEach((function(t) {
  25688. return t(e)
  25689. }
  25690. )),
  25691. this
  25692. }
  25693. ,
  25694. e.prototype.onchange = function(e) {
  25695. return this._onchange.push(e),
  25696. this
  25697. }
  25698. ,
  25699. e
  25700. }();
  25701. function jn(e, t, i) {
  25702. try {
  25703. var n = e.next();
  25704. n.done ? t(n) : n.value ? n.value.then((function() {
  25705. n.value = void 0,
  25706. t(n)
  25707. }
  25708. ), i) : t(n)
  25709. } catch (e) {
  25710. i(e)
  25711. }
  25712. }
  25713. function Yn(e) {
  25714. var t;
  25715. return void 0 === e && (e = 25),
  25716. function(i, n, r) {
  25717. var o = performance.now();
  25718. void 0 === t || o - t > e ? (t = o,
  25719. setTimeout((function() {
  25720. jn(i, n, r)
  25721. }
  25722. ), 0)) : jn(i, n, r)
  25723. }
  25724. }
  25725. function Kn(e, t, i, n, r) {
  25726. var o = function() {
  25727. var a, s = function(e) {
  25728. e.done ? i(e.value) : void 0 === a ? a = !0 : o()
  25729. };
  25730. do {
  25731. a = void 0,
  25732. r && r.aborted ? n(new Error("Aborted")) : t(e, s, n),
  25733. void 0 === a && (a = !1)
  25734. } while (a)
  25735. };
  25736. o()
  25737. }
  25738. function Qn(e, t) {
  25739. var i;
  25740. return Kn(e, jn, (function(e) {
  25741. return i = e
  25742. }
  25743. ), (function(e) {
  25744. throw e
  25745. }
  25746. ), t),
  25747. i
  25748. }
  25749. function qn(e, t, i) {
  25750. return new Promise((function(n, r) {
  25751. Kn(e, t, n, r, i)
  25752. }
  25753. ))
  25754. }
  25755. function Zn(e, t) {
  25756. return function() {
  25757. for (var i = [], n = 0; n < arguments.length; n++)
  25758. i[n] = arguments[n];
  25759. return Qn(e.apply(void 0, i), t)
  25760. }
  25761. }
  25762. function Jn(e, t, i) {
  25763. return function() {
  25764. for (var n = [], r = 0; r < arguments.length; r++)
  25765. n[r] = arguments[r];
  25766. return qn(e.apply(void 0, n), t, i)
  25767. }
  25768. }
  25769. var $n = function() {
  25770. function e() {
  25771. this._applyTo = Zn(this._applyToCoroutine.bind(this))
  25772. }
  25773. return e.prototype.set = function(e, t) {
  25774. switch (e.length || K.Warn("Setting vertex data kind '".concat(t, "' with an empty array")),
  25775. t) {
  25776. case Bi.PositionKind:
  25777. this.positions = e;
  25778. break;
  25779. case Bi.NormalKind:
  25780. this.normals = e;
  25781. break;
  25782. case Bi.TangentKind:
  25783. this.tangents = e;
  25784. break;
  25785. case Bi.UVKind:
  25786. this.uvs = e;
  25787. break;
  25788. case Bi.UV2Kind:
  25789. this.uvs2 = e;
  25790. break;
  25791. case Bi.UV3Kind:
  25792. this.uvs3 = e;
  25793. break;
  25794. case Bi.UV4Kind:
  25795. this.uvs4 = e;
  25796. break;
  25797. case Bi.UV5Kind:
  25798. this.uvs5 = e;
  25799. break;
  25800. case Bi.UV6Kind:
  25801. this.uvs6 = e;
  25802. break;
  25803. case Bi.ColorKind:
  25804. this.colors = e;
  25805. break;
  25806. case Bi.MatricesIndicesKind:
  25807. this.matricesIndices = e;
  25808. break;
  25809. case Bi.MatricesWeightsKind:
  25810. this.matricesWeights = e;
  25811. break;
  25812. case Bi.MatricesIndicesExtraKind:
  25813. this.matricesIndicesExtra = e;
  25814. break;
  25815. case Bi.MatricesWeightsExtraKind:
  25816. this.matricesWeightsExtra = e
  25817. }
  25818. }
  25819. ,
  25820. e.prototype.applyToMesh = function(e, t) {
  25821. return this._applyTo(e, t, !1),
  25822. this
  25823. }
  25824. ,
  25825. e.prototype.applyToGeometry = function(e, t) {
  25826. return this._applyTo(e, t, !1),
  25827. this
  25828. }
  25829. ,
  25830. e.prototype.updateMesh = function(e) {
  25831. return this._update(e),
  25832. this
  25833. }
  25834. ,
  25835. e.prototype.updateGeometry = function(e) {
  25836. return this._update(e),
  25837. this
  25838. }
  25839. ,
  25840. e.prototype._applyToCoroutine = function(e, t, i) {
  25841. return void 0 === t && (t = !1),
  25842. z(this, (function(n) {
  25843. switch (n.label) {
  25844. case 0:
  25845. return this.positions ? (e.setVerticesData(Bi.PositionKind, this.positions, t),
  25846. i ? [4] : [3, 2]) : [3, 2];
  25847. case 1:
  25848. n.sent(),
  25849. n.label = 2;
  25850. case 2:
  25851. return this.normals ? (e.setVerticesData(Bi.NormalKind, this.normals, t),
  25852. i ? [4] : [3, 4]) : [3, 4];
  25853. case 3:
  25854. n.sent(),
  25855. n.label = 4;
  25856. case 4:
  25857. return this.tangents ? (e.setVerticesData(Bi.TangentKind, this.tangents, t),
  25858. i ? [4] : [3, 6]) : [3, 6];
  25859. case 5:
  25860. n.sent(),
  25861. n.label = 6;
  25862. case 6:
  25863. return this.uvs ? (e.setVerticesData(Bi.UVKind, this.uvs, t),
  25864. i ? [4] : [3, 8]) : [3, 8];
  25865. case 7:
  25866. n.sent(),
  25867. n.label = 8;
  25868. case 8:
  25869. return this.uvs2 ? (e.setVerticesData(Bi.UV2Kind, this.uvs2, t),
  25870. i ? [4] : [3, 10]) : [3, 10];
  25871. case 9:
  25872. n.sent(),
  25873. n.label = 10;
  25874. case 10:
  25875. return this.uvs3 ? (e.setVerticesData(Bi.UV3Kind, this.uvs3, t),
  25876. i ? [4] : [3, 12]) : [3, 12];
  25877. case 11:
  25878. n.sent(),
  25879. n.label = 12;
  25880. case 12:
  25881. return this.uvs4 ? (e.setVerticesData(Bi.UV4Kind, this.uvs4, t),
  25882. i ? [4] : [3, 14]) : [3, 14];
  25883. case 13:
  25884. n.sent(),
  25885. n.label = 14;
  25886. case 14:
  25887. return this.uvs5 ? (e.setVerticesData(Bi.UV5Kind, this.uvs5, t),
  25888. i ? [4] : [3, 16]) : [3, 16];
  25889. case 15:
  25890. n.sent(),
  25891. n.label = 16;
  25892. case 16:
  25893. return this.uvs6 ? (e.setVerticesData(Bi.UV6Kind, this.uvs6, t),
  25894. i ? [4] : [3, 18]) : [3, 18];
  25895. case 17:
  25896. n.sent(),
  25897. n.label = 18;
  25898. case 18:
  25899. return this.colors ? (e.setVerticesData(Bi.ColorKind, this.colors, t),
  25900. i ? [4] : [3, 20]) : [3, 20];
  25901. case 19:
  25902. n.sent(),
  25903. n.label = 20;
  25904. case 20:
  25905. return this.matricesIndices ? (e.setVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t),
  25906. i ? [4] : [3, 22]) : [3, 22];
  25907. case 21:
  25908. n.sent(),
  25909. n.label = 22;
  25910. case 22:
  25911. return this.matricesWeights ? (e.setVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t),
  25912. i ? [4] : [3, 24]) : [3, 24];
  25913. case 23:
  25914. n.sent(),
  25915. n.label = 24;
  25916. case 24:
  25917. return this.matricesIndicesExtra ? (e.setVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t),
  25918. i ? [4] : [3, 26]) : [3, 26];
  25919. case 25:
  25920. n.sent(),
  25921. n.label = 26;
  25922. case 26:
  25923. return this.matricesWeightsExtra ? (e.setVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t),
  25924. i ? [4] : [3, 28]) : [3, 28];
  25925. case 27:
  25926. n.sent(),
  25927. n.label = 28;
  25928. case 28:
  25929. return this.indices ? (e.setIndices(this.indices, null, t),
  25930. i ? [4] : [3, 30]) : [3, 31];
  25931. case 29:
  25932. n.sent(),
  25933. n.label = 30;
  25934. case 30:
  25935. return [3, 32];
  25936. case 31:
  25937. e.setIndices([], null),
  25938. n.label = 32;
  25939. case 32:
  25940. return [2, this]
  25941. }
  25942. }
  25943. ))
  25944. }
  25945. ,
  25946. e.prototype._update = function(e, t, i) {
  25947. return this.positions && e.updateVerticesData(Bi.PositionKind, this.positions, t, i),
  25948. this.normals && e.updateVerticesData(Bi.NormalKind, this.normals, t, i),
  25949. this.tangents && e.updateVerticesData(Bi.TangentKind, this.tangents, t, i),
  25950. this.uvs && e.updateVerticesData(Bi.UVKind, this.uvs, t, i),
  25951. this.uvs2 && e.updateVerticesData(Bi.UV2Kind, this.uvs2, t, i),
  25952. this.uvs3 && e.updateVerticesData(Bi.UV3Kind, this.uvs3, t, i),
  25953. this.uvs4 && e.updateVerticesData(Bi.UV4Kind, this.uvs4, t, i),
  25954. this.uvs5 && e.updateVerticesData(Bi.UV5Kind, this.uvs5, t, i),
  25955. this.uvs6 && e.updateVerticesData(Bi.UV6Kind, this.uvs6, t, i),
  25956. this.colors && e.updateVerticesData(Bi.ColorKind, this.colors, t, i),
  25957. this.matricesIndices && e.updateVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t, i),
  25958. this.matricesWeights && e.updateVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t, i),
  25959. this.matricesIndicesExtra && e.updateVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i),
  25960. this.matricesWeightsExtra && e.updateVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i),
  25961. this.indices && e.setIndices(this.indices, null),
  25962. this
  25963. }
  25964. ,
  25965. e._TransformVector3Coordinates = function(e, t, i, n) {
  25966. void 0 === i && (i = 0),
  25967. void 0 === n && (n = e.length);
  25968. for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
  25969. x.FromArrayToRef(e, a, r),
  25970. x.TransformCoordinatesToRef(r, t, o),
  25971. e[a] = o.x,
  25972. e[a + 1] = o.y,
  25973. e[a + 2] = o.z
  25974. }
  25975. ,
  25976. e._TransformVector3Normals = function(e, t, i, n) {
  25977. void 0 === i && (i = 0),
  25978. void 0 === n && (n = e.length);
  25979. for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
  25980. x.FromArrayToRef(e, a, r),
  25981. x.TransformNormalToRef(r, t, o),
  25982. e[a] = o.x,
  25983. e[a + 1] = o.y,
  25984. e[a + 2] = o.z
  25985. }
  25986. ,
  25987. e._TransformVector4Normals = function(e, t, i, n) {
  25988. void 0 === i && (i = 0),
  25989. void 0 === n && (n = e.length);
  25990. for (var r = I.Vector4[0], o = I.Vector4[1], a = i; a < i + n; a += 4)
  25991. R.FromArrayToRef(e, a, r),
  25992. R.TransformNormalToRef(r, t, o),
  25993. e[a] = o.x,
  25994. e[a + 1] = o.y,
  25995. e[a + 2] = o.z,
  25996. e[a + 3] = o.w
  25997. }
  25998. ,
  25999. e._FlipFaces = function(e, t, i) {
  26000. void 0 === t && (t = 0),
  26001. void 0 === i && (i = e.length);
  26002. for (var n = t; n < t + i; n += 3) {
  26003. var r = e[n + 1];
  26004. e[n + 1] = e[n + 2],
  26005. e[n + 2] = r
  26006. }
  26007. }
  26008. ,
  26009. e.prototype.transform = function(t) {
  26010. var i = t.determinant() < 0;
  26011. return this.positions && e._TransformVector3Coordinates(this.positions, t),
  26012. this.normals && e._TransformVector3Normals(this.normals, t),
  26013. this.tangents && e._TransformVector4Normals(this.tangents, t),
  26014. i && this.indices && e._FlipFaces(this.indices),
  26015. this
  26016. }
  26017. ,
  26018. e.prototype.merge = function(e, t, i) {
  26019. void 0 === t && (t = !1),
  26020. void 0 === i && (i = !1);
  26021. var n = Array.isArray(e) ? e.map((function(e) {
  26022. return [e, void 0]
  26023. }
  26024. )) : [[e, void 0]];
  26025. return Qn(this._mergeCoroutine(void 0, n, t, !1, i))
  26026. }
  26027. ,
  26028. e.prototype._mergeCoroutine = function(t, i, n, r, o) {
  26029. var a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x = this;
  26030. return void 0 === n && (n = !1),
  26031. z(this, (function(R) {
  26032. switch (R.label) {
  26033. case 0:
  26034. for (this._validate(),
  26035. a = i.map((function(e) {
  26036. return e[0]
  26037. }
  26038. )),
  26039. s = 0,
  26040. l = a; s < l.length; s++)
  26041. if ((v = l[s])._validate(),
  26042. !this.normals != !v.normals || !this.tangents != !v.tangents || !this.uvs != !v.uvs || !this.uvs2 != !v.uvs2 || !this.uvs3 != !v.uvs3 || !this.uvs4 != !v.uvs4 || !this.uvs5 != !v.uvs5 || !this.uvs6 != !v.uvs6 || !this.colors != !v.colors || !this.matricesIndices != !v.matricesIndices || !this.matricesWeights != !v.matricesWeights || !this.matricesIndicesExtra != !v.matricesIndicesExtra || !this.matricesWeightsExtra != !v.matricesWeightsExtra)
  26043. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  26044. if (c = a.reduce((function(e, t) {
  26045. var i, n;
  26046. return e + (null !== (n = null === (i = t.indices) || void 0 === i ? void 0 : i.length) && void 0 !== n ? n : 0)
  26047. }
  26048. ), null !== (E = null === (T = this.indices) || void 0 === T ? void 0 : T.length) && void 0 !== E ? E : 0),
  26049. u = o || a.some((function(e) {
  26050. return e.indices === x.indices
  26051. }
  26052. )),
  26053. h = u ? null === (S = this.indices) || void 0 === S ? void 0 : S.slice() : this.indices,
  26054. !(c > 0))
  26055. return [3, 4];
  26056. d = null !== (A = null == h ? void 0 : h.length) && void 0 !== A ? A : 0,
  26057. h || (h = new Array(c)),
  26058. h.length !== c && (Array.isArray(h) ? h.length = c : ((p = n || h instanceof Uint32Array ? new Uint32Array(c) : new Uint16Array(c)).set(h),
  26059. h = p),
  26060. t && t.determinant() < 0 && e._FlipFaces(h, 0, d)),
  26061. f = this.positions ? this.positions.length / 3 : 0,
  26062. _ = 0,
  26063. m = i,
  26064. R.label = 1;
  26065. case 1:
  26066. if (!(_ < m.length))
  26067. return [3, 4];
  26068. if (g = m[_],
  26069. v = g[0],
  26070. y = g[1],
  26071. !v.indices)
  26072. return [3, 3];
  26073. for (b = 0; b < v.indices.length; b++)
  26074. h[d + b] = v.indices[b] + f;
  26075. return y && y.determinant() < 0 && e._FlipFaces(h, d, v.indices.length),
  26076. f += v.positions.length / 3,
  26077. d += v.indices.length,
  26078. r ? [4] : [3, 3];
  26079. case 2:
  26080. R.sent(),
  26081. R.label = 3;
  26082. case 3:
  26083. return _++,
  26084. [3, 1];
  26085. case 4:
  26086. return this.indices = h,
  26087. this.positions = e._MergeElement(Bi.PositionKind, this.positions, t, i.map((function(e) {
  26088. return [e[0].positions, e[1]]
  26089. }
  26090. ))),
  26091. r ? [4] : [3, 6];
  26092. case 5:
  26093. R.sent(),
  26094. R.label = 6;
  26095. case 6:
  26096. return this.normals = e._MergeElement(Bi.NormalKind, this.normals, t, i.map((function(e) {
  26097. return [e[0].normals, e[1]]
  26098. }
  26099. ))),
  26100. r ? [4] : [3, 8];
  26101. case 7:
  26102. R.sent(),
  26103. R.label = 8;
  26104. case 8:
  26105. return this.tangents = e._MergeElement(Bi.TangentKind, this.tangents, t, i.map((function(e) {
  26106. return [e[0].tangents, e[1]]
  26107. }
  26108. ))),
  26109. r ? [4] : [3, 10];
  26110. case 9:
  26111. R.sent(),
  26112. R.label = 10;
  26113. case 10:
  26114. return this.uvs = e._MergeElement(Bi.UVKind, this.uvs, t, i.map((function(e) {
  26115. return [e[0].uvs, e[1]]
  26116. }
  26117. ))),
  26118. r ? [4] : [3, 12];
  26119. case 11:
  26120. R.sent(),
  26121. R.label = 12;
  26122. case 12:
  26123. return this.uvs2 = e._MergeElement(Bi.UV2Kind, this.uvs2, t, i.map((function(e) {
  26124. return [e[0].uvs2, e[1]]
  26125. }
  26126. ))),
  26127. r ? [4] : [3, 14];
  26128. case 13:
  26129. R.sent(),
  26130. R.label = 14;
  26131. case 14:
  26132. return this.uvs3 = e._MergeElement(Bi.UV3Kind, this.uvs3, t, i.map((function(e) {
  26133. return [e[0].uvs3, e[1]]
  26134. }
  26135. ))),
  26136. r ? [4] : [3, 16];
  26137. case 15:
  26138. R.sent(),
  26139. R.label = 16;
  26140. case 16:
  26141. return this.uvs4 = e._MergeElement(Bi.UV4Kind, this.uvs4, t, i.map((function(e) {
  26142. return [e[0].uvs4, e[1]]
  26143. }
  26144. ))),
  26145. r ? [4] : [3, 18];
  26146. case 17:
  26147. R.sent(),
  26148. R.label = 18;
  26149. case 18:
  26150. return this.uvs5 = e._MergeElement(Bi.UV5Kind, this.uvs5, t, i.map((function(e) {
  26151. return [e[0].uvs5, e[1]]
  26152. }
  26153. ))),
  26154. r ? [4] : [3, 20];
  26155. case 19:
  26156. R.sent(),
  26157. R.label = 20;
  26158. case 20:
  26159. return this.uvs6 = e._MergeElement(Bi.UV6Kind, this.uvs6, t, i.map((function(e) {
  26160. return [e[0].uvs6, e[1]]
  26161. }
  26162. ))),
  26163. r ? [4] : [3, 22];
  26164. case 21:
  26165. R.sent(),
  26166. R.label = 22;
  26167. case 22:
  26168. return this.colors = e._MergeElement(Bi.ColorKind, this.colors, t, i.map((function(e) {
  26169. return [e[0].colors, e[1]]
  26170. }
  26171. ))),
  26172. r ? [4] : [3, 24];
  26173. case 23:
  26174. R.sent(),
  26175. R.label = 24;
  26176. case 24:
  26177. return this.matricesIndices = e._MergeElement(Bi.MatricesIndicesKind, this.matricesIndices, t, i.map((function(e) {
  26178. return [e[0].matricesIndices, e[1]]
  26179. }
  26180. ))),
  26181. r ? [4] : [3, 26];
  26182. case 25:
  26183. R.sent(),
  26184. R.label = 26;
  26185. case 26:
  26186. return this.matricesWeights = e._MergeElement(Bi.MatricesWeightsKind, this.matricesWeights, t, i.map((function(e) {
  26187. return [e[0].matricesWeights, e[1]]
  26188. }
  26189. ))),
  26190. r ? [4] : [3, 28];
  26191. case 27:
  26192. R.sent(),
  26193. R.label = 28;
  26194. case 28:
  26195. return this.matricesIndicesExtra = e._MergeElement(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i.map((function(e) {
  26196. return [e[0].matricesIndicesExtra, e[1]]
  26197. }
  26198. ))),
  26199. r ? [4] : [3, 30];
  26200. case 29:
  26201. R.sent(),
  26202. R.label = 30;
  26203. case 30:
  26204. return this.matricesWeightsExtra = e._MergeElement(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i.map((function(e) {
  26205. return [e[0].matricesWeightsExtra, e[1]]
  26206. }
  26207. ))),
  26208. [2, this]
  26209. }
  26210. }
  26211. ))
  26212. }
  26213. ,
  26214. e._MergeElement = function(t, i, n, r) {
  26215. var o = r.filter((function(e) {
  26216. return null !== e[0] && void 0 !== e[0]
  26217. }
  26218. ));
  26219. if (0 === o.length)
  26220. return i;
  26221. if (!i)
  26222. return this._MergeElement(t, o[0][0], o[0][1], o.slice(1));
  26223. var a = o.reduce((function(e, t) {
  26224. return e + t[0].length
  26225. }
  26226. ), i.length)
  26227. , s = t === Bi.PositionKind ? e._TransformVector3Coordinates : t === Bi.NormalKind ? e._TransformVector3Normals : t === Bi.TangentKind ? e._TransformVector4Normals : function() {}
  26228. ;
  26229. if (i instanceof Float32Array) {
  26230. var l = new Float32Array(a);
  26231. l.set(i),
  26232. n && s(l, n, 0, i.length);
  26233. for (var c = i.length, u = 0, h = o; u < h.length; u++) {
  26234. var d = h[u]
  26235. , p = d[0]
  26236. , f = d[1];
  26237. l.set(p, c),
  26238. f && s(l, f, c, p.length),
  26239. c += p.length
  26240. }
  26241. return l
  26242. }
  26243. for (var _ = new Array(a), m = 0; m < i.length; m++)
  26244. _[m] = i[m];
  26245. n && s(_, n, 0, i.length),
  26246. c = i.length;
  26247. for (var g = 0, v = o; g < v.length; g++) {
  26248. var y = v[g]
  26249. , b = (p = y[0],
  26250. y[1]);
  26251. for (m = 0; m < p.length; m++)
  26252. _[c + m] = p[m];
  26253. b && s(_, b, c, p.length),
  26254. c += p.length
  26255. }
  26256. return _
  26257. }
  26258. ,
  26259. e.prototype._validate = function() {
  26260. if (!this.positions)
  26261. throw new ft("Positions are required",pt.MeshInvalidPositionsError);
  26262. var e = function(e, t) {
  26263. var i = Bi.DeduceStride(e);
  26264. if (t.length % i != 0)
  26265. throw new Error("The " + e + "s array count must be a multiple of " + i);
  26266. return t.length / i
  26267. }
  26268. , t = e(Bi.PositionKind, this.positions)
  26269. , i = function(i, n) {
  26270. var r = e(i, n);
  26271. if (r !== t)
  26272. throw new Error("The " + i + "s element count (" + r + ") does not match the positions count (" + t + ")")
  26273. };
  26274. this.normals && i(Bi.NormalKind, this.normals),
  26275. this.tangents && i(Bi.TangentKind, this.tangents),
  26276. this.uvs && i(Bi.UVKind, this.uvs),
  26277. this.uvs2 && i(Bi.UV2Kind, this.uvs2),
  26278. this.uvs3 && i(Bi.UV3Kind, this.uvs3),
  26279. this.uvs4 && i(Bi.UV4Kind, this.uvs4),
  26280. this.uvs5 && i(Bi.UV5Kind, this.uvs5),
  26281. this.uvs6 && i(Bi.UV6Kind, this.uvs6),
  26282. this.colors && i(Bi.ColorKind, this.colors),
  26283. this.matricesIndices && i(Bi.MatricesIndicesKind, this.matricesIndices),
  26284. this.matricesWeights && i(Bi.MatricesWeightsKind, this.matricesWeights),
  26285. this.matricesIndicesExtra && i(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra),
  26286. this.matricesWeightsExtra && i(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra)
  26287. }
  26288. ,
  26289. e.prototype.serialize = function() {
  26290. var e = {};
  26291. return this.positions && (e.positions = this.positions),
  26292. this.normals && (e.normals = this.normals),
  26293. this.tangents && (e.tangents = this.tangents),
  26294. this.uvs && (e.uvs = this.uvs),
  26295. this.uvs2 && (e.uvs2 = this.uvs2),
  26296. this.uvs3 && (e.uvs3 = this.uvs3),
  26297. this.uvs4 && (e.uvs4 = this.uvs4),
  26298. this.uvs5 && (e.uvs5 = this.uvs5),
  26299. this.uvs6 && (e.uvs6 = this.uvs6),
  26300. this.colors && (e.colors = this.colors),
  26301. this.matricesIndices && (e.matricesIndices = this.matricesIndices,
  26302. e.matricesIndices._isExpanded = !0),
  26303. this.matricesWeights && (e.matricesWeights = this.matricesWeights),
  26304. this.matricesIndicesExtra && (e.matricesIndicesExtra = this.matricesIndicesExtra,
  26305. e.matricesIndicesExtra._isExpanded = !0),
  26306. this.matricesWeightsExtra && (e.matricesWeightsExtra = this.matricesWeightsExtra),
  26307. e.indices = this.indices,
  26308. e
  26309. }
  26310. ,
  26311. e.ExtractFromMesh = function(t, i, n) {
  26312. return e._ExtractFrom(t, i, n)
  26313. }
  26314. ,
  26315. e.ExtractFromGeometry = function(t, i, n) {
  26316. return e._ExtractFrom(t, i, n)
  26317. }
  26318. ,
  26319. e._ExtractFrom = function(t, i, n) {
  26320. var r = new e;
  26321. return t.isVerticesDataPresent(Bi.PositionKind) && (r.positions = t.getVerticesData(Bi.PositionKind, i, n)),
  26322. t.isVerticesDataPresent(Bi.NormalKind) && (r.normals = t.getVerticesData(Bi.NormalKind, i, n)),
  26323. t.isVerticesDataPresent(Bi.TangentKind) && (r.tangents = t.getVerticesData(Bi.TangentKind, i, n)),
  26324. t.isVerticesDataPresent(Bi.UVKind) && (r.uvs = t.getVerticesData(Bi.UVKind, i, n)),
  26325. t.isVerticesDataPresent(Bi.UV2Kind) && (r.uvs2 = t.getVerticesData(Bi.UV2Kind, i, n)),
  26326. t.isVerticesDataPresent(Bi.UV3Kind) && (r.uvs3 = t.getVerticesData(Bi.UV3Kind, i, n)),
  26327. t.isVerticesDataPresent(Bi.UV4Kind) && (r.uvs4 = t.getVerticesData(Bi.UV4Kind, i, n)),
  26328. t.isVerticesDataPresent(Bi.UV5Kind) && (r.uvs5 = t.getVerticesData(Bi.UV5Kind, i, n)),
  26329. t.isVerticesDataPresent(Bi.UV6Kind) && (r.uvs6 = t.getVerticesData(Bi.UV6Kind, i, n)),
  26330. t.isVerticesDataPresent(Bi.ColorKind) && (r.colors = t.getVerticesData(Bi.ColorKind, i, n)),
  26331. t.isVerticesDataPresent(Bi.MatricesIndicesKind) && (r.matricesIndices = t.getVerticesData(Bi.MatricesIndicesKind, i, n)),
  26332. t.isVerticesDataPresent(Bi.MatricesWeightsKind) && (r.matricesWeights = t.getVerticesData(Bi.MatricesWeightsKind, i, n)),
  26333. t.isVerticesDataPresent(Bi.MatricesIndicesExtraKind) && (r.matricesIndicesExtra = t.getVerticesData(Bi.MatricesIndicesExtraKind, i, n)),
  26334. t.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) && (r.matricesWeightsExtra = t.getVerticesData(Bi.MatricesWeightsExtraKind, i, n)),
  26335. r.indices = t.getIndices(i, n),
  26336. r
  26337. }
  26338. ,
  26339. e.CreateRibbon = function(e) {
  26340. throw be("ribbonBuilder")
  26341. }
  26342. ,
  26343. e.CreateBox = function(e) {
  26344. throw be("boxBuilder")
  26345. }
  26346. ,
  26347. e.CreateTiledBox = function(e) {
  26348. throw be("tiledBoxBuilder")
  26349. }
  26350. ,
  26351. e.CreateTiledPlane = function(e) {
  26352. throw be("tiledPlaneBuilder")
  26353. }
  26354. ,
  26355. e.CreateSphere = function(e) {
  26356. throw be("sphereBuilder")
  26357. }
  26358. ,
  26359. e.CreateCylinder = function(e) {
  26360. throw be("cylinderBuilder")
  26361. }
  26362. ,
  26363. e.CreateTorus = function(e) {
  26364. throw be("torusBuilder")
  26365. }
  26366. ,
  26367. e.CreateLineSystem = function(e) {
  26368. throw be("linesBuilder")
  26369. }
  26370. ,
  26371. e.CreateDashedLines = function(e) {
  26372. throw be("linesBuilder")
  26373. }
  26374. ,
  26375. e.CreateGround = function(e) {
  26376. throw be("groundBuilder")
  26377. }
  26378. ,
  26379. e.CreateTiledGround = function(e) {
  26380. throw be("groundBuilder")
  26381. }
  26382. ,
  26383. e.CreateGroundFromHeightMap = function(e) {
  26384. throw be("groundBuilder")
  26385. }
  26386. ,
  26387. e.CreatePlane = function(e) {
  26388. throw be("planeBuilder")
  26389. }
  26390. ,
  26391. e.CreateDisc = function(e) {
  26392. throw be("discBuilder")
  26393. }
  26394. ,
  26395. e.CreatePolygon = function(e, t, i, n, r, o, a) {
  26396. throw be("polygonBuilder")
  26397. }
  26398. ,
  26399. e.CreateIcoSphere = function(e) {
  26400. throw be("icoSphereBuilder")
  26401. }
  26402. ,
  26403. e.CreatePolyhedron = function(e) {
  26404. throw be("polyhedronBuilder")
  26405. }
  26406. ,
  26407. e.CreateCapsule = function(e) {
  26408. throw void 0 === e && (e = {
  26409. orientation: x.Up(),
  26410. subdivisions: 2,
  26411. tessellation: 16,
  26412. height: 1,
  26413. radius: .25,
  26414. capSubdivisions: 6
  26415. }),
  26416. be("capsuleBuilder")
  26417. }
  26418. ,
  26419. e.CreateTorusKnot = function(e) {
  26420. throw be("torusKnotBuilder")
  26421. }
  26422. ,
  26423. e.ComputeNormals = function(e, t, i, n) {
  26424. var r = 0
  26425. , o = 0
  26426. , a = 0
  26427. , s = 0
  26428. , l = 0
  26429. , c = 0
  26430. , u = 0
  26431. , h = 0
  26432. , d = 0
  26433. , p = 0
  26434. , f = 0
  26435. , _ = 0
  26436. , m = 0
  26437. , g = 0
  26438. , v = 0
  26439. , y = 0
  26440. , b = 0
  26441. , T = 0
  26442. , E = 0
  26443. , S = 0
  26444. , A = !1
  26445. , R = !1
  26446. , C = !1
  26447. , P = !1
  26448. , M = 1
  26449. , I = 0
  26450. , O = null;
  26451. n && (A = !!n.facetNormals,
  26452. R = !!n.facetPositions,
  26453. C = !!n.facetPartitioning,
  26454. M = !0 === n.useRightHandedSystem ? -1 : 1,
  26455. I = n.ratio || 0,
  26456. P = !!n.depthSort,
  26457. O = n.distanceTo,
  26458. P && void 0 === O && (O = x.Zero()));
  26459. var D = 0
  26460. , N = 0
  26461. , L = 0
  26462. , F = 0;
  26463. for (C && n && n.bbSize && (D = n.subDiv.X * I / n.bbSize.x,
  26464. N = n.subDiv.Y * I / n.bbSize.y,
  26465. L = n.subDiv.Z * I / n.bbSize.z,
  26466. F = n.subDiv.max * n.subDiv.max,
  26467. n.facetPartitioning.length = 0),
  26468. r = 0; r < e.length; r++)
  26469. i[r] = 0;
  26470. var w = t.length / 3 | 0;
  26471. for (r = 0; r < w; r++) {
  26472. if (m = 1 + (_ = 3 * t[3 * r]),
  26473. g = _ + 2,
  26474. y = 1 + (v = 3 * t[3 * r + 1]),
  26475. b = v + 2,
  26476. E = 1 + (T = 3 * t[3 * r + 2]),
  26477. S = T + 2,
  26478. o = e[_] - e[v],
  26479. a = e[m] - e[y],
  26480. s = e[g] - e[b],
  26481. l = e[T] - e[v],
  26482. c = e[E] - e[y],
  26483. h = M * (a * (u = e[S] - e[b]) - s * c),
  26484. d = M * (s * l - o * u),
  26485. p = M * (o * c - a * l),
  26486. h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
  26487. d /= f,
  26488. p /= f,
  26489. A && n && (n.facetNormals[r].x = h,
  26490. n.facetNormals[r].y = d,
  26491. n.facetNormals[r].z = p),
  26492. R && n && (n.facetPositions[r].x = (e[_] + e[v] + e[T]) / 3,
  26493. n.facetPositions[r].y = (e[m] + e[y] + e[E]) / 3,
  26494. n.facetPositions[r].z = (e[g] + e[b] + e[S]) / 3),
  26495. C && n) {
  26496. var B = Math.floor((n.facetPositions[r].x - n.bInfo.minimum.x * I) * D)
  26497. , U = Math.floor((n.facetPositions[r].y - n.bInfo.minimum.y * I) * N)
  26498. , V = Math.floor((n.facetPositions[r].z - n.bInfo.minimum.z * I) * L)
  26499. , k = Math.floor((e[_] - n.bInfo.minimum.x * I) * D)
  26500. , G = Math.floor((e[m] - n.bInfo.minimum.y * I) * N)
  26501. , z = Math.floor((e[g] - n.bInfo.minimum.z * I) * L)
  26502. , W = Math.floor((e[v] - n.bInfo.minimum.x * I) * D)
  26503. , H = Math.floor((e[y] - n.bInfo.minimum.y * I) * N)
  26504. , X = Math.floor((e[b] - n.bInfo.minimum.z * I) * L)
  26505. , j = Math.floor((e[T] - n.bInfo.minimum.x * I) * D)
  26506. , Y = Math.floor((e[E] - n.bInfo.minimum.y * I) * N)
  26507. , K = Math.floor((e[S] - n.bInfo.minimum.z * I) * L)
  26508. , Q = k + n.subDiv.max * G + F * z
  26509. , q = W + n.subDiv.max * H + F * X
  26510. , Z = j + n.subDiv.max * Y + F * K
  26511. , J = B + n.subDiv.max * U + F * V;
  26512. n.facetPartitioning[J] = n.facetPartitioning[J] ? n.facetPartitioning[J] : new Array,
  26513. n.facetPartitioning[Q] = n.facetPartitioning[Q] ? n.facetPartitioning[Q] : new Array,
  26514. n.facetPartitioning[q] = n.facetPartitioning[q] ? n.facetPartitioning[q] : new Array,
  26515. n.facetPartitioning[Z] = n.facetPartitioning[Z] ? n.facetPartitioning[Z] : new Array,
  26516. n.facetPartitioning[Q].push(r),
  26517. q != Q && n.facetPartitioning[q].push(r),
  26518. Z != q && Z != Q && n.facetPartitioning[Z].push(r),
  26519. J != Q && J != q && J != Z && n.facetPartitioning[J].push(r)
  26520. }
  26521. if (P && n && n.facetPositions) {
  26522. var $ = n.depthSortedFacets[r];
  26523. $.ind = 3 * r,
  26524. $.sqDistance = x.DistanceSquared(n.facetPositions[r], O)
  26525. }
  26526. i[_] += h,
  26527. i[m] += d,
  26528. i[g] += p,
  26529. i[v] += h,
  26530. i[y] += d,
  26531. i[b] += p,
  26532. i[T] += h,
  26533. i[E] += d,
  26534. i[S] += p
  26535. }
  26536. for (r = 0; r < i.length / 3; r++)
  26537. h = i[3 * r],
  26538. d = i[3 * r + 1],
  26539. p = i[3 * r + 2],
  26540. h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
  26541. d /= f,
  26542. p /= f,
  26543. i[3 * r] = h,
  26544. i[3 * r + 1] = d,
  26545. i[3 * r + 2] = p
  26546. }
  26547. ,
  26548. e._ComputeSides = function(t, i, n, r, o, a, s) {
  26549. var l, c, u = n.length, h = r.length;
  26550. switch (t = t || e.DEFAULTSIDE) {
  26551. case e.FRONTSIDE:
  26552. break;
  26553. case e.BACKSIDE:
  26554. for (l = 0; l < u; l += 3) {
  26555. var d = n[l];
  26556. n[l] = n[l + 2],
  26557. n[l + 2] = d
  26558. }
  26559. for (c = 0; c < h; c++)
  26560. r[c] = -r[c];
  26561. break;
  26562. case e.DOUBLESIDE:
  26563. for (var p = i.length, f = p / 3, _ = 0; _ < p; _++)
  26564. i[p + _] = i[_];
  26565. for (l = 0; l < u; l += 3)
  26566. n[l + u] = n[l + 2] + f,
  26567. n[l + 1 + u] = n[l + 1] + f,
  26568. n[l + 2 + u] = n[l] + f;
  26569. for (c = 0; c < h; c++)
  26570. r[h + c] = -r[c];
  26571. var m = o.length
  26572. , g = 0;
  26573. for (g = 0; g < m; g++)
  26574. o[g + m] = o[g];
  26575. for (a = a || new R(0,0,1,1),
  26576. s = s || new R(0,0,1,1),
  26577. g = 0,
  26578. l = 0; l < m / 2; l++)
  26579. o[g] = a.x + (a.z - a.x) * o[g],
  26580. o[g + 1] = a.y + (a.w - a.y) * o[g + 1],
  26581. o[g + m] = s.x + (s.z - s.x) * o[g + m],
  26582. o[g + m + 1] = s.y + (s.w - s.y) * o[g + m + 1],
  26583. g += 2
  26584. }
  26585. }
  26586. ,
  26587. e.ImportVertexData = function(t, i) {
  26588. var n = new e
  26589. , r = t.positions;
  26590. r && n.set(r, Bi.PositionKind);
  26591. var o = t.normals;
  26592. o && n.set(o, Bi.NormalKind);
  26593. var a = t.tangents;
  26594. a && n.set(a, Bi.TangentKind);
  26595. var s = t.uvs;
  26596. s && n.set(s, Bi.UVKind);
  26597. var l = t.uv2s;
  26598. l && n.set(l, Bi.UV2Kind);
  26599. var c = t.uv3s;
  26600. c && n.set(c, Bi.UV3Kind);
  26601. var u = t.uv4s;
  26602. u && n.set(u, Bi.UV4Kind);
  26603. var h = t.uv5s;
  26604. h && n.set(h, Bi.UV5Kind);
  26605. var d = t.uv6s;
  26606. d && n.set(d, Bi.UV6Kind);
  26607. var p = t.colors;
  26608. p && n.set(N.CheckColors4(p, r.length / 3), Bi.ColorKind);
  26609. var f = t.matricesIndices;
  26610. f && n.set(f, Bi.MatricesIndicesKind);
  26611. var _ = t.matricesWeights;
  26612. _ && n.set(_, Bi.MatricesWeightsKind);
  26613. var m = t.indices;
  26614. m && (n.indices = m),
  26615. i.setAllVerticesData(n, t.updatable)
  26616. }
  26617. ,
  26618. e.FRONTSIDE = 0,
  26619. e.BACKSIDE = 1,
  26620. e.DOUBLESIDE = 2,
  26621. e.DEFAULTSIDE = 0,
  26622. k([ze.filter((function() {
  26623. for (var e = [], t = 0; t < arguments.length; t++)
  26624. e[t] = arguments[t];
  26625. var i = e[0];
  26626. return !Array.isArray(i)
  26627. }
  26628. ))], e, "_TransformVector3Coordinates", null),
  26629. k([ze.filter((function() {
  26630. for (var e = [], t = 0; t < arguments.length; t++)
  26631. e[t] = arguments[t];
  26632. var i = e[0];
  26633. return !Array.isArray(i)
  26634. }
  26635. ))], e, "_TransformVector3Normals", null),
  26636. k([ze.filter((function() {
  26637. for (var e = [], t = 0; t < arguments.length; t++)
  26638. e[t] = arguments[t];
  26639. var i = e[0];
  26640. return !Array.isArray(i)
  26641. }
  26642. ))], e, "_TransformVector4Normals", null),
  26643. k([ze.filter((function() {
  26644. for (var e = [], t = 0; t < arguments.length; t++)
  26645. e[t] = arguments[t];
  26646. var i = e[0];
  26647. return !Array.isArray(i)
  26648. }
  26649. ))], e, "_FlipFaces", null),
  26650. e
  26651. }()
  26652. , er = function(e, t, i) {
  26653. this.bu = e,
  26654. this.bv = t,
  26655. this.distance = i,
  26656. this.faceId = 0,
  26657. this.subMeshId = 0
  26658. }
  26659. , tr = function() {
  26660. function e(e, t, i) {
  26661. this.vectors = g.BuildArray(8, x.Zero),
  26662. this.center = x.Zero(),
  26663. this.centerWorld = x.Zero(),
  26664. this.extendSize = x.Zero(),
  26665. this.extendSizeWorld = x.Zero(),
  26666. this.directions = g.BuildArray(3, x.Zero),
  26667. this.vectorsWorld = g.BuildArray(8, x.Zero),
  26668. this.minimumWorld = x.Zero(),
  26669. this.maximumWorld = x.Zero(),
  26670. this.minimum = x.Zero(),
  26671. this.maximum = x.Zero(),
  26672. this._drawWrapperFront = null,
  26673. this._drawWrapperBack = null,
  26674. this.reConstruct(e, t, i)
  26675. }
  26676. return e.prototype.reConstruct = function(e, t, i) {
  26677. var n = e.x
  26678. , r = e.y
  26679. , o = e.z
  26680. , a = t.x
  26681. , s = t.y
  26682. , l = t.z
  26683. , c = this.vectors;
  26684. this.minimum.copyFromFloats(n, r, o),
  26685. this.maximum.copyFromFloats(a, s, l),
  26686. c[0].copyFromFloats(n, r, o),
  26687. c[1].copyFromFloats(a, s, l),
  26688. c[2].copyFromFloats(a, r, o),
  26689. c[3].copyFromFloats(n, s, o),
  26690. c[4].copyFromFloats(n, r, l),
  26691. c[5].copyFromFloats(a, s, o),
  26692. c[6].copyFromFloats(n, s, l),
  26693. c[7].copyFromFloats(a, r, l),
  26694. t.addToRef(e, this.center).scaleInPlace(.5),
  26695. t.subtractToRef(e, this.extendSize).scaleInPlace(.5),
  26696. this._worldMatrix = i || P.IdentityReadOnly,
  26697. this._update(this._worldMatrix)
  26698. }
  26699. ,
  26700. e.prototype.scale = function(t) {
  26701. var i = e._TmpVector3
  26702. , n = this.maximum.subtractToRef(this.minimum, i[0])
  26703. , r = n.length();
  26704. n.normalizeFromLength(r);
  26705. var o = r * t
  26706. , a = n.scaleInPlace(.5 * o)
  26707. , s = this.center.subtractToRef(a, i[1])
  26708. , l = this.center.addToRef(a, i[2]);
  26709. return this.reConstruct(s, l, this._worldMatrix),
  26710. this
  26711. }
  26712. ,
  26713. e.prototype.getWorldMatrix = function() {
  26714. return this._worldMatrix
  26715. }
  26716. ,
  26717. e.prototype._update = function(e) {
  26718. var t = this.minimumWorld
  26719. , i = this.maximumWorld
  26720. , n = this.directions
  26721. , r = this.vectorsWorld
  26722. , o = this.vectors;
  26723. if (e.isIdentity()) {
  26724. for (t.copyFrom(this.minimum),
  26725. i.copyFrom(this.maximum),
  26726. a = 0; a < 8; ++a)
  26727. r[a].copyFrom(o[a]);
  26728. this.extendSizeWorld.copyFrom(this.extendSize),
  26729. this.centerWorld.copyFrom(this.center)
  26730. } else {
  26731. t.setAll(Number.MAX_VALUE),
  26732. i.setAll(-Number.MAX_VALUE);
  26733. for (var a = 0; a < 8; ++a) {
  26734. var s = r[a];
  26735. x.TransformCoordinatesToRef(o[a], e, s),
  26736. t.minimizeInPlace(s),
  26737. i.maximizeInPlace(s)
  26738. }
  26739. i.subtractToRef(t, this.extendSizeWorld).scaleInPlace(.5),
  26740. i.addToRef(t, this.centerWorld).scaleInPlace(.5)
  26741. }
  26742. x.FromArrayToRef(e.m, 0, n[0]),
  26743. x.FromArrayToRef(e.m, 4, n[1]),
  26744. x.FromArrayToRef(e.m, 8, n[2]),
  26745. this._worldMatrix = e
  26746. }
  26747. ,
  26748. e.prototype.isInFrustum = function(t) {
  26749. return e.IsInFrustum(this.vectorsWorld, t)
  26750. }
  26751. ,
  26752. e.prototype.isCompletelyInFrustum = function(t) {
  26753. return e.IsCompletelyInFrustum(this.vectorsWorld, t)
  26754. }
  26755. ,
  26756. e.prototype.intersectsPoint = function(e) {
  26757. var t = this.minimumWorld
  26758. , i = this.maximumWorld
  26759. , n = t.x
  26760. , r = t.y
  26761. , o = t.z
  26762. , a = i.x
  26763. , s = i.y
  26764. , l = i.z
  26765. , c = e.x
  26766. , u = e.y
  26767. , h = e.z
  26768. , d = -m;
  26769. return !(a - c < d || d > c - n || s - u < d || d > u - r || l - h < d || d > h - o)
  26770. }
  26771. ,
  26772. e.prototype.intersectsSphere = function(t) {
  26773. return e.IntersectsSphere(this.minimumWorld, this.maximumWorld, t.centerWorld, t.radiusWorld)
  26774. }
  26775. ,
  26776. e.prototype.intersectsMinMax = function(e, t) {
  26777. var i = this.minimumWorld
  26778. , n = this.maximumWorld
  26779. , r = i.x
  26780. , o = i.y
  26781. , a = i.z
  26782. , s = n.x
  26783. , l = n.y
  26784. , c = n.z
  26785. , u = e.x
  26786. , h = e.y
  26787. , d = e.z
  26788. , p = t.x
  26789. , f = t.y
  26790. , _ = t.z;
  26791. return !(s < u || r > p || l < h || o > f || c < d || a > _)
  26792. }
  26793. ,
  26794. e.prototype.dispose = function() {
  26795. var e, t;
  26796. null === (e = this._drawWrapperFront) || void 0 === e || e.dispose(),
  26797. null === (t = this._drawWrapperBack) || void 0 === t || t.dispose()
  26798. }
  26799. ,
  26800. e.Intersects = function(e, t) {
  26801. return e.intersectsMinMax(t.minimumWorld, t.maximumWorld)
  26802. }
  26803. ,
  26804. e.IntersectsSphere = function(t, i, n, r) {
  26805. var o = e._TmpVector3[0];
  26806. return x.ClampToRef(n, t, i, o),
  26807. x.DistanceSquared(n, o) <= r * r
  26808. }
  26809. ,
  26810. e.IsCompletelyInFrustum = function(e, t) {
  26811. for (var i = 0; i < 6; ++i)
  26812. for (var n = t[i], r = 0; r < 8; ++r)
  26813. if (n.dotCoordinate(e[r]) < 0)
  26814. return !1;
  26815. return !0
  26816. }
  26817. ,
  26818. e.IsInFrustum = function(e, t) {
  26819. for (var i = 0; i < 6; ++i) {
  26820. for (var n = !0, r = t[i], o = 0; o < 8; ++o)
  26821. if (r.dotCoordinate(e[o]) >= 0) {
  26822. n = !1;
  26823. break
  26824. }
  26825. if (n)
  26826. return !1
  26827. }
  26828. return !0
  26829. }
  26830. ,
  26831. e._TmpVector3 = g.BuildArray(3, x.Zero),
  26832. e
  26833. }()
  26834. , ir = function() {
  26835. function e(e, t, i) {
  26836. this.center = x.Zero(),
  26837. this.centerWorld = x.Zero(),
  26838. this.minimum = x.Zero(),
  26839. this.maximum = x.Zero(),
  26840. this.reConstruct(e, t, i)
  26841. }
  26842. return e.prototype.reConstruct = function(e, t, i) {
  26843. this.minimum.copyFrom(e),
  26844. this.maximum.copyFrom(t);
  26845. var n = x.Distance(e, t);
  26846. t.addToRef(e, this.center).scaleInPlace(.5),
  26847. this.radius = .5 * n,
  26848. this._update(i || P.IdentityReadOnly)
  26849. }
  26850. ,
  26851. e.prototype.scale = function(t) {
  26852. var i = this.radius * t
  26853. , n = e._TmpVector3
  26854. , r = n[0].setAll(i)
  26855. , o = this.center.subtractToRef(r, n[1])
  26856. , a = this.center.addToRef(r, n[2]);
  26857. return this.reConstruct(o, a, this._worldMatrix),
  26858. this
  26859. }
  26860. ,
  26861. e.prototype.getWorldMatrix = function() {
  26862. return this._worldMatrix
  26863. }
  26864. ,
  26865. e.prototype._update = function(t) {
  26866. if (t.isIdentity())
  26867. this.centerWorld.copyFrom(this.center),
  26868. this.radiusWorld = this.radius;
  26869. else {
  26870. x.TransformCoordinatesToRef(this.center, t, this.centerWorld);
  26871. var i = e._TmpVector3[0];
  26872. x.TransformNormalFromFloatsToRef(1, 1, 1, t, i),
  26873. this.radiusWorld = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)) * this.radius
  26874. }
  26875. }
  26876. ,
  26877. e.prototype.isInFrustum = function(e) {
  26878. for (var t = this.centerWorld, i = this.radiusWorld, n = 0; n < 6; n++)
  26879. if (e[n].dotCoordinate(t) <= -i)
  26880. return !1;
  26881. return !0
  26882. }
  26883. ,
  26884. e.prototype.isCenterInFrustum = function(e) {
  26885. for (var t = this.centerWorld, i = 0; i < 6; i++)
  26886. if (e[i].dotCoordinate(t) < 0)
  26887. return !1;
  26888. return !0
  26889. }
  26890. ,
  26891. e.prototype.intersectsPoint = function(e) {
  26892. var t = x.DistanceSquared(this.centerWorld, e);
  26893. return !(this.radiusWorld * this.radiusWorld < t)
  26894. }
  26895. ,
  26896. e.Intersects = function(e, t) {
  26897. var i = x.DistanceSquared(e.centerWorld, t.centerWorld)
  26898. , n = e.radiusWorld + t.radiusWorld;
  26899. return !(n * n < i)
  26900. }
  26901. ,
  26902. e.CreateFromCenterAndRadius = function(t, i, n) {
  26903. this._TmpVector3[0].copyFrom(t),
  26904. this._TmpVector3[1].copyFromFloats(0, 0, i),
  26905. this._TmpVector3[2].copyFrom(t),
  26906. this._TmpVector3[0].addInPlace(this._TmpVector3[1]),
  26907. this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);
  26908. var r = new e(this._TmpVector3[0],this._TmpVector3[2]);
  26909. return r._worldMatrix = n || P.Identity(),
  26910. r
  26911. }
  26912. ,
  26913. e._TmpVector3 = g.BuildArray(3, x.Zero),
  26914. e
  26915. }()
  26916. , nr = {
  26917. min: 0,
  26918. max: 0
  26919. }
  26920. , rr = {
  26921. min: 0,
  26922. max: 0
  26923. }
  26924. , or = function(e, t, i) {
  26925. var n = x.Dot(t.centerWorld, e)
  26926. , r = Math.abs(x.Dot(t.directions[0], e)) * t.extendSize.x + Math.abs(x.Dot(t.directions[1], e)) * t.extendSize.y + Math.abs(x.Dot(t.directions[2], e)) * t.extendSize.z;
  26927. i.min = n - r,
  26928. i.max = n + r
  26929. }
  26930. , ar = function(e, t, i) {
  26931. return or(e, t, nr),
  26932. or(e, i, rr),
  26933. !(nr.min > rr.max || rr.min > nr.max)
  26934. }
  26935. , sr = function() {
  26936. function e(e, t, i) {
  26937. this._isLocked = !1,
  26938. this.boundingBox = new tr(e,t,i),
  26939. this.boundingSphere = new ir(e,t,i)
  26940. }
  26941. return e.prototype.reConstruct = function(e, t, i) {
  26942. this.boundingBox.reConstruct(e, t, i),
  26943. this.boundingSphere.reConstruct(e, t, i)
  26944. }
  26945. ,
  26946. Object.defineProperty(e.prototype, "minimum", {
  26947. get: function() {
  26948. return this.boundingBox.minimum
  26949. },
  26950. enumerable: !1,
  26951. configurable: !0
  26952. }),
  26953. Object.defineProperty(e.prototype, "maximum", {
  26954. get: function() {
  26955. return this.boundingBox.maximum
  26956. },
  26957. enumerable: !1,
  26958. configurable: !0
  26959. }),
  26960. Object.defineProperty(e.prototype, "isLocked", {
  26961. get: function() {
  26962. return this._isLocked
  26963. },
  26964. set: function(e) {
  26965. this._isLocked = e
  26966. },
  26967. enumerable: !1,
  26968. configurable: !0
  26969. }),
  26970. e.prototype.update = function(e) {
  26971. this._isLocked || (this.boundingBox._update(e),
  26972. this.boundingSphere._update(e))
  26973. }
  26974. ,
  26975. e.prototype.centerOn = function(t, i) {
  26976. var n = e._TmpVector3[0].copyFrom(t).subtractInPlace(i)
  26977. , r = e._TmpVector3[1].copyFrom(t).addInPlace(i);
  26978. return this.boundingBox.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
  26979. this.boundingSphere.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
  26980. this
  26981. }
  26982. ,
  26983. e.prototype.encapsulate = function(e) {
  26984. var t = x.Minimize(this.minimum, e)
  26985. , i = x.Maximize(this.maximum, e);
  26986. return this.reConstruct(t, i, this.boundingBox.getWorldMatrix()),
  26987. this
  26988. }
  26989. ,
  26990. e.prototype.encapsulateBoundingInfo = function(e) {
  26991. return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
  26992. this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
  26993. this
  26994. }
  26995. ,
  26996. e.prototype.scale = function(e) {
  26997. return this.boundingBox.scale(e),
  26998. this.boundingSphere.scale(e),
  26999. this
  27000. }
  27001. ,
  27002. e.prototype.isInFrustum = function(e, t) {
  27003. return void 0 === t && (t = a.MESHES_CULLINGSTRATEGY_STANDARD),
  27004. !(t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION && t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY || !this.boundingSphere.isCenterInFrustum(e)) || !!this.boundingSphere.isInFrustum(e) && (!(t !== a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY && t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY) || this.boundingBox.isInFrustum(e))
  27005. }
  27006. ,
  27007. Object.defineProperty(e.prototype, "diagonalLength", {
  27008. get: function() {
  27009. var t = this.boundingBox;
  27010. return t.maximumWorld.subtractToRef(t.minimumWorld, e._TmpVector3[0]).length()
  27011. },
  27012. enumerable: !1,
  27013. configurable: !0
  27014. }),
  27015. e.prototype.isCompletelyInFrustum = function(e) {
  27016. return this.boundingBox.isCompletelyInFrustum(e)
  27017. }
  27018. ,
  27019. e.prototype._checkCollision = function(e) {
  27020. return e._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld)
  27021. }
  27022. ,
  27023. e.prototype.intersectsPoint = function(e) {
  27024. return !!this.boundingSphere.centerWorld && !!this.boundingSphere.intersectsPoint(e) && !!this.boundingBox.intersectsPoint(e)
  27025. }
  27026. ,
  27027. e.prototype.intersects = function(e, t) {
  27028. if (!ir.Intersects(this.boundingSphere, e.boundingSphere))
  27029. return !1;
  27030. if (!tr.Intersects(this.boundingBox, e.boundingBox))
  27031. return !1;
  27032. if (!t)
  27033. return !0;
  27034. var i = this.boundingBox
  27035. , n = e.boundingBox;
  27036. return !!(ar(i.directions[0], i, n) && ar(i.directions[1], i, n) && ar(i.directions[2], i, n) && ar(n.directions[0], i, n) && ar(n.directions[1], i, n) && ar(n.directions[2], i, n) && ar(x.Cross(i.directions[0], n.directions[0]), i, n) && ar(x.Cross(i.directions[0], n.directions[1]), i, n) && ar(x.Cross(i.directions[0], n.directions[2]), i, n) && ar(x.Cross(i.directions[1], n.directions[0]), i, n) && ar(x.Cross(i.directions[1], n.directions[1]), i, n) && ar(x.Cross(i.directions[1], n.directions[2]), i, n) && ar(x.Cross(i.directions[2], n.directions[0]), i, n) && ar(x.Cross(i.directions[2], n.directions[1]), i, n) && ar(x.Cross(i.directions[2], n.directions[2]), i, n))
  27037. }
  27038. ,
  27039. e._TmpVector3 = g.BuildArray(2, x.Zero),
  27040. e
  27041. }()
  27042. , lr = function() {
  27043. function e() {}
  27044. return e.extractMinAndMaxIndexed = function(e, t, i, n, r, o) {
  27045. for (var a = i; a < i + n; a++) {
  27046. var s = 3 * t[a]
  27047. , l = e[s]
  27048. , c = e[s + 1]
  27049. , u = e[s + 2];
  27050. r.minimizeInPlaceFromFloats(l, c, u),
  27051. o.maximizeInPlaceFromFloats(l, c, u)
  27052. }
  27053. }
  27054. ,
  27055. e.extractMinAndMax = function(e, t, i, n, r, o) {
  27056. for (var a = t, s = t * n; a < t + i; a++,
  27057. s += n) {
  27058. var l = e[s]
  27059. , c = e[s + 1]
  27060. , u = e[s + 2];
  27061. r.minimizeInPlaceFromFloats(l, c, u),
  27062. o.maximizeInPlaceFromFloats(l, c, u)
  27063. }
  27064. }
  27065. ,
  27066. k([ze.filter((function() {
  27067. for (var e = [], t = 0; t < arguments.length; t++)
  27068. e[t] = arguments[t];
  27069. var i = e[0]
  27070. , n = e[1];
  27071. return !Array.isArray(i) && !Array.isArray(n)
  27072. }
  27073. ))], e, "extractMinAndMaxIndexed", null),
  27074. k([ze.filter((function() {
  27075. for (var e = [], t = 0; t < arguments.length; t++)
  27076. e[t] = arguments[t];
  27077. var i = e[0];
  27078. return !Array.isArray(i)
  27079. }
  27080. ))], e, "extractMinAndMax", null),
  27081. e
  27082. }();
  27083. function cr(e, t, i, n, r) {
  27084. void 0 === r && (r = null);
  27085. var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  27086. , a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  27087. return lr.extractMinAndMaxIndexed(e, t, i, n, o, a),
  27088. r && (o.x -= o.x * r.x + r.y,
  27089. o.y -= o.y * r.x + r.y,
  27090. o.z -= o.z * r.x + r.y,
  27091. a.x += a.x * r.x + r.y,
  27092. a.y += a.y * r.x + r.y,
  27093. a.z += a.z * r.x + r.y),
  27094. {
  27095. minimum: o,
  27096. maximum: a
  27097. }
  27098. }
  27099. function ur(e, t, i, n, r) {
  27100. void 0 === n && (n = null);
  27101. var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  27102. , a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
  27103. return r || (r = 3),
  27104. lr.extractMinAndMax(e, t, i, r, o, a),
  27105. n && (o.x -= o.x * n.x + n.y,
  27106. o.y -= o.y * n.x + n.y,
  27107. o.z -= o.z * n.x + n.y,
  27108. a.x += a.x * n.x + n.y,
  27109. a.y += a.y * n.x + n.y,
  27110. a.z += a.z * n.x + n.y),
  27111. {
  27112. minimum: o,
  27113. maximum: a
  27114. }
  27115. }
  27116. var hr = function() {
  27117. function e(e, t, i, n, r, o, a, s, l) {
  27118. void 0 === s && (s = !0),
  27119. void 0 === l && (l = !0),
  27120. this.materialIndex = e,
  27121. this.verticesStart = t,
  27122. this.verticesCount = i,
  27123. this.indexStart = n,
  27124. this.indexCount = r,
  27125. this._mainDrawWrapperOverride = null,
  27126. this._linesIndexCount = 0,
  27127. this._linesIndexBuffer = null,
  27128. this._lastColliderWorldVertices = null,
  27129. this._lastColliderTransformMatrix = null,
  27130. this._renderId = 0,
  27131. this._alphaIndex = 0,
  27132. this._distanceToCamera = 0,
  27133. this._currentMaterial = null,
  27134. this._mesh = o,
  27135. this._renderingMesh = a || o,
  27136. l && o.subMeshes.push(this),
  27137. this._engine = this._mesh.getScene().getEngine(),
  27138. this.resetDrawCache(),
  27139. this._trianglePlanes = [],
  27140. this._id = o.subMeshes.length - 1,
  27141. s && (this.refreshBoundingInfo(),
  27142. o.computeWorldMatrix(!0))
  27143. }
  27144. return Object.defineProperty(e.prototype, "materialDefines", {
  27145. get: function() {
  27146. var e;
  27147. return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.defines
  27148. },
  27149. set: function(e) {
  27150. var t;
  27151. (null !== (t = this._mainDrawWrapperOverride) && void 0 !== t ? t : this._getDrawWrapper(void 0, !0)).defines = e
  27152. },
  27153. enumerable: !1,
  27154. configurable: !0
  27155. }),
  27156. e.prototype._getDrawWrapper = function(e, t) {
  27157. void 0 === t && (t = !1),
  27158. e = null != e ? e : this._engine.currentRenderPassId;
  27159. var i = this._drawWrappers[e];
  27160. return !i && t && (this._drawWrappers[e] = i = new Gt(this._mesh.getScene().getEngine())),
  27161. i
  27162. }
  27163. ,
  27164. e.prototype._removeDrawWrapper = function(e, t) {
  27165. var i;
  27166. void 0 === t && (t = !0),
  27167. t && (null === (i = this._drawWrappers[e]) || void 0 === i || i.dispose()),
  27168. this._drawWrappers[e] = void 0
  27169. }
  27170. ,
  27171. Object.defineProperty(e.prototype, "effect", {
  27172. get: function() {
  27173. var e, t;
  27174. return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : null !== (t = null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.effect) && void 0 !== t ? t : null
  27175. },
  27176. enumerable: !1,
  27177. configurable: !0
  27178. }),
  27179. Object.defineProperty(e.prototype, "_drawWrapper", {
  27180. get: function() {
  27181. var e;
  27182. return null !== (e = this._mainDrawWrapperOverride) && void 0 !== e ? e : this._getDrawWrapper(void 0, !0)
  27183. },
  27184. enumerable: !1,
  27185. configurable: !0
  27186. }),
  27187. Object.defineProperty(e.prototype, "_drawWrapperOverride", {
  27188. get: function() {
  27189. return this._mainDrawWrapperOverride
  27190. },
  27191. enumerable: !1,
  27192. configurable: !0
  27193. }),
  27194. e.prototype._setMainDrawWrapperOverride = function(e) {
  27195. this._mainDrawWrapperOverride = e
  27196. }
  27197. ,
  27198. e.prototype.setEffect = function(e, t, i, n) {
  27199. void 0 === t && (t = null),
  27200. void 0 === n && (n = !0);
  27201. var r = this._drawWrapper;
  27202. r.setEffect(e, t, n),
  27203. void 0 !== i && (r.materialContext = i),
  27204. e || (r.defines = null,
  27205. r.materialContext = void 0)
  27206. }
  27207. ,
  27208. e.prototype.resetDrawCache = function(e) {
  27209. if (this._drawWrappers) {
  27210. if (void 0 !== e)
  27211. return void this._removeDrawWrapper(e);
  27212. for (var t = 0, i = this._drawWrappers; t < i.length; t++) {
  27213. var n = i[t];
  27214. null == n || n.dispose()
  27215. }
  27216. }
  27217. this._drawWrappers = []
  27218. }
  27219. ,
  27220. e.AddToMesh = function(t, i, n, r, o, a, s, l) {
  27221. return void 0 === l && (l = !0),
  27222. new e(t,i,n,r,o,a,s,l)
  27223. }
  27224. ,
  27225. Object.defineProperty(e.prototype, "IsGlobal", {
  27226. get: function() {
  27227. return 0 === this.verticesStart && this.verticesCount === this._mesh.getTotalVertices()
  27228. },
  27229. enumerable: !1,
  27230. configurable: !0
  27231. }),
  27232. e.prototype.getBoundingInfo = function() {
  27233. return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo
  27234. }
  27235. ,
  27236. e.prototype.setBoundingInfo = function(e) {
  27237. return this._boundingInfo = e,
  27238. this
  27239. }
  27240. ,
  27241. e.prototype.getMesh = function() {
  27242. return this._mesh
  27243. }
  27244. ,
  27245. e.prototype.getRenderingMesh = function() {
  27246. return this._renderingMesh
  27247. }
  27248. ,
  27249. e.prototype.getReplacementMesh = function() {
  27250. return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null
  27251. }
  27252. ,
  27253. e.prototype.getEffectiveMesh = function() {
  27254. return (this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null) || this._renderingMesh
  27255. }
  27256. ,
  27257. e.prototype.getMaterial = function() {
  27258. var e, t = null !== (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) && void 0 !== e ? e : this._renderingMesh.material;
  27259. if (null == t)
  27260. return this._mesh.getScene().defaultMaterial;
  27261. if (this._isMultiMaterial(t)) {
  27262. var i = t.getSubMaterial(this.materialIndex);
  27263. return this._currentMaterial !== i && (this._currentMaterial = i,
  27264. this.resetDrawCache()),
  27265. i
  27266. }
  27267. return t
  27268. }
  27269. ,
  27270. e.prototype._isMultiMaterial = function(e) {
  27271. return void 0 !== e.getSubMaterial
  27272. }
  27273. ,
  27274. e.prototype.refreshBoundingInfo = function(e) {
  27275. if (void 0 === e && (e = null),
  27276. this._lastColliderWorldVertices = null,
  27277. this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
  27278. return this;
  27279. if (e || (e = this._renderingMesh.getVerticesData(Bi.PositionKind)),
  27280. !e)
  27281. return this._boundingInfo = this._mesh.getBoundingInfo(),
  27282. this;
  27283. var t, i = this._renderingMesh.getIndices();
  27284. if (0 === this.indexStart && this.indexCount === i.length) {
  27285. var n = this._renderingMesh.getBoundingInfo();
  27286. t = {
  27287. minimum: n.minimum.clone(),
  27288. maximum: n.maximum.clone()
  27289. }
  27290. } else
  27291. t = cr(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  27292. return this._boundingInfo ? this._boundingInfo.reConstruct(t.minimum, t.maximum) : this._boundingInfo = new sr(t.minimum,t.maximum),
  27293. this
  27294. }
  27295. ,
  27296. e.prototype._checkCollision = function(e) {
  27297. return this.getBoundingInfo()._checkCollision(e)
  27298. }
  27299. ,
  27300. e.prototype.updateBoundingInfo = function(e) {
  27301. var t = this.getBoundingInfo();
  27302. return t || (this.refreshBoundingInfo(),
  27303. t = this.getBoundingInfo()),
  27304. t && t.update(e),
  27305. this
  27306. }
  27307. ,
  27308. e.prototype.isInFrustum = function(e) {
  27309. var t = this.getBoundingInfo();
  27310. return !!t && t.isInFrustum(e, this._mesh.cullingStrategy)
  27311. }
  27312. ,
  27313. e.prototype.isCompletelyInFrustum = function(e) {
  27314. var t = this.getBoundingInfo();
  27315. return !!t && t.isCompletelyInFrustum(e)
  27316. }
  27317. ,
  27318. e.prototype.render = function(e) {
  27319. return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0),
  27320. this
  27321. }
  27322. ,
  27323. e.prototype._getLinesIndexBuffer = function(e, t) {
  27324. if (!this._linesIndexBuffer) {
  27325. for (var i = [], n = this.indexStart; n < this.indexStart + this.indexCount; n += 3)
  27326. i.push(e[n], e[n + 1], e[n + 1], e[n + 2], e[n + 2], e[n]);
  27327. this._linesIndexBuffer = t.createIndexBuffer(i),
  27328. this._linesIndexCount = i.length
  27329. }
  27330. return this._linesIndexBuffer
  27331. }
  27332. ,
  27333. e.prototype.canIntersects = function(e) {
  27334. var t = this.getBoundingInfo();
  27335. return !!t && e.intersectsBox(t.boundingBox)
  27336. }
  27337. ,
  27338. e.prototype.intersects = function(e, t, i, n, r) {
  27339. var o = this.getMaterial();
  27340. if (!o)
  27341. return null;
  27342. var s = 3
  27343. , l = !1;
  27344. switch (o.fillMode) {
  27345. case a.MATERIAL_PointListDrawMode:
  27346. case a.MATERIAL_LineLoopDrawMode:
  27347. case a.MATERIAL_LineStripDrawMode:
  27348. case a.MATERIAL_TriangleFanDrawMode:
  27349. return null;
  27350. case a.MATERIAL_TriangleStripDrawMode:
  27351. s = 1,
  27352. l = !0
  27353. }
  27354. return o.fillMode === a.MATERIAL_LineListDrawMode ? i.length ? this._intersectLines(e, t, i, this._mesh.intersectionThreshold, n) : this._intersectUnIndexedLines(e, t, i, this._mesh.intersectionThreshold, n) : !i.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, t, i, n, r) : this._intersectTriangles(e, t, i, s, l, n, r)
  27355. }
  27356. ,
  27357. e.prototype._intersectLines = function(e, t, i, n, r) {
  27358. for (var o = null, a = this.indexStart; a < this.indexStart + this.indexCount; a += 2) {
  27359. var s = t[i[a]]
  27360. , l = t[i[a + 1]]
  27361. , c = e.intersectionSegment(s, l, n);
  27362. if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
  27363. r))
  27364. break
  27365. }
  27366. return o
  27367. }
  27368. ,
  27369. e.prototype._intersectUnIndexedLines = function(e, t, i, n, r) {
  27370. for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 2) {
  27371. var s = t[a]
  27372. , l = t[a + 1]
  27373. , c = e.intersectionSegment(s, l, n);
  27374. if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
  27375. r))
  27376. break
  27377. }
  27378. return o
  27379. }
  27380. ,
  27381. e.prototype._intersectTriangles = function(e, t, i, n, r, o, a) {
  27382. for (var s = null, l = -1, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
  27383. l++;
  27384. var u = i[c]
  27385. , h = i[c + 1]
  27386. , d = i[c + 2];
  27387. if (r && 4294967295 === d)
  27388. c += 2;
  27389. else {
  27390. var p = t[u]
  27391. , f = t[h]
  27392. , _ = t[d];
  27393. if (p && f && _ && (!a || a(p, f, _, e))) {
  27394. var m = e.intersectsTriangle(p, f, _);
  27395. if (m) {
  27396. if (m.distance < 0)
  27397. continue;
  27398. if ((o || !s || m.distance < s.distance) && ((s = m).faceId = l,
  27399. o))
  27400. break
  27401. }
  27402. }
  27403. }
  27404. }
  27405. return s
  27406. }
  27407. ,
  27408. e.prototype._intersectUnIndexedTriangles = function(e, t, i, n, r) {
  27409. for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 3) {
  27410. var s = t[a]
  27411. , l = t[a + 1]
  27412. , c = t[a + 2];
  27413. if (!r || r(s, l, c, e)) {
  27414. var u = e.intersectsTriangle(s, l, c);
  27415. if (u) {
  27416. if (u.distance < 0)
  27417. continue;
  27418. if ((n || !o || u.distance < o.distance) && ((o = u).faceId = a / 3,
  27419. n))
  27420. break
  27421. }
  27422. }
  27423. }
  27424. return o
  27425. }
  27426. ,
  27427. e.prototype._rebuild = function() {
  27428. this._linesIndexBuffer && (this._linesIndexBuffer = null)
  27429. }
  27430. ,
  27431. e.prototype.clone = function(t, i) {
  27432. var n = new e(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);
  27433. if (!this.IsGlobal) {
  27434. var r = this.getBoundingInfo();
  27435. if (!r)
  27436. return n;
  27437. n._boundingInfo = new sr(r.minimum,r.maximum)
  27438. }
  27439. return n
  27440. }
  27441. ,
  27442. e.prototype.dispose = function() {
  27443. this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),
  27444. this._linesIndexBuffer = null);
  27445. var e = this._mesh.subMeshes.indexOf(this);
  27446. this._mesh.subMeshes.splice(e, 1),
  27447. this.resetDrawCache()
  27448. }
  27449. ,
  27450. e.prototype.getClassName = function() {
  27451. return "SubMesh"
  27452. }
  27453. ,
  27454. e.CreateFromIndices = function(t, i, n, r, o, a) {
  27455. void 0 === a && (a = !0);
  27456. for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = (o || r).getIndices(), u = i; u < i + n; u++) {
  27457. var h = c[u];
  27458. h < s && (s = h),
  27459. h > l && (l = h)
  27460. }
  27461. return new e(t,s,l - s + 1,i,n,r,o,a)
  27462. }
  27463. ,
  27464. e
  27465. }()
  27466. , dr = function() {
  27467. function e() {}
  27468. return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", {
  27469. get: function() {
  27470. return e._ForceFullSceneLoadingForIncremental
  27471. },
  27472. set: function(t) {
  27473. e._ForceFullSceneLoadingForIncremental = t
  27474. },
  27475. enumerable: !1,
  27476. configurable: !0
  27477. }),
  27478. Object.defineProperty(e, "ShowLoadingScreen", {
  27479. get: function() {
  27480. return e._ShowLoadingScreen
  27481. },
  27482. set: function(t) {
  27483. e._ShowLoadingScreen = t
  27484. },
  27485. enumerable: !1,
  27486. configurable: !0
  27487. }),
  27488. Object.defineProperty(e, "loggingLevel", {
  27489. get: function() {
  27490. return e._LoggingLevel
  27491. },
  27492. set: function(t) {
  27493. e._LoggingLevel = t
  27494. },
  27495. enumerable: !1,
  27496. configurable: !0
  27497. }),
  27498. Object.defineProperty(e, "CleanBoneMatrixWeights", {
  27499. get: function() {
  27500. return e._CleanBoneMatrixWeights
  27501. },
  27502. set: function(t) {
  27503. e._CleanBoneMatrixWeights = t
  27504. },
  27505. enumerable: !1,
  27506. configurable: !0
  27507. }),
  27508. e._ForceFullSceneLoadingForIncremental = !1,
  27509. e._ShowLoadingScreen = !0,
  27510. e._CleanBoneMatrixWeights = !1,
  27511. e._LoggingLevel = a.SCENELOADER_NO_LOGGING,
  27512. e
  27513. }()
  27514. , pr = function() {
  27515. function e() {}
  27516. return e.UseOpenGLOrientationForUV = !1,
  27517. e
  27518. }()
  27519. , fr = function() {
  27520. function e(e, t, i, n, r) {
  27521. void 0 === n && (n = !1),
  27522. void 0 === r && (r = null),
  27523. this.delayLoadState = a.DELAYLOADSTATE_NONE,
  27524. this._totalVertices = 0,
  27525. this._isDisposed = !1,
  27526. this._indexBufferIsUpdatable = !1,
  27527. this._positionsCache = [],
  27528. this._parentContainer = null,
  27529. this.useBoundingInfoFromGeometry = !1,
  27530. this._scene = t || E.LastCreatedScene,
  27531. this._scene && (this.id = e,
  27532. this.uniqueId = this._scene.getUniqueId(),
  27533. this._engine = this._scene.getEngine(),
  27534. this._meshes = [],
  27535. this._vertexBuffers = {},
  27536. this._indices = [],
  27537. this._updatable = n,
  27538. i ? this.setAllVerticesData(i, n) : (this._totalVertices = 0,
  27539. this._indices = []),
  27540. this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
  27541. r && (this.applyToMesh(r),
  27542. r.computeWorldMatrix(!0)))
  27543. }
  27544. return Object.defineProperty(e.prototype, "boundingBias", {
  27545. get: function() {
  27546. return this._boundingBias
  27547. },
  27548. set: function(e) {
  27549. this._boundingBias ? this._boundingBias.copyFrom(e) : this._boundingBias = e.clone(),
  27550. this._updateBoundingInfo(!0, null)
  27551. },
  27552. enumerable: !1,
  27553. configurable: !0
  27554. }),
  27555. e.CreateGeometryForMesh = function(t) {
  27556. var i = new e(e.RandomId(),t.getScene());
  27557. return i.applyToMesh(t),
  27558. i
  27559. }
  27560. ,
  27561. Object.defineProperty(e.prototype, "meshes", {
  27562. get: function() {
  27563. return this._meshes
  27564. },
  27565. enumerable: !1,
  27566. configurable: !0
  27567. }),
  27568. Object.defineProperty(e.prototype, "extend", {
  27569. get: function() {
  27570. return this._extend
  27571. },
  27572. enumerable: !1,
  27573. configurable: !0
  27574. }),
  27575. e.prototype.getScene = function() {
  27576. return this._scene
  27577. }
  27578. ,
  27579. e.prototype.getEngine = function() {
  27580. return this._engine
  27581. }
  27582. ,
  27583. e.prototype.isReady = function() {
  27584. return this.delayLoadState === a.DELAYLOADSTATE_LOADED || this.delayLoadState === a.DELAYLOADSTATE_NONE
  27585. }
  27586. ,
  27587. Object.defineProperty(e.prototype, "doNotSerialize", {
  27588. get: function() {
  27589. for (var e = 0; e < this._meshes.length; e++)
  27590. if (!this._meshes[e].doNotSerialize)
  27591. return !1;
  27592. return !0
  27593. },
  27594. enumerable: !1,
  27595. configurable: !0
  27596. }),
  27597. e.prototype._rebuild = function() {
  27598. for (var e in this._vertexArrayObjects && (this._vertexArrayObjects = {}),
  27599. 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
  27600. this._vertexBuffers)
  27601. this._vertexBuffers[e]._rebuild()
  27602. }
  27603. ,
  27604. e.prototype.setAllVerticesData = function(e, t) {
  27605. e.applyToGeometry(this, t),
  27606. this._notifyUpdate()
  27607. }
  27608. ,
  27609. e.prototype.setVerticesData = function(e, t, i, n) {
  27610. void 0 === i && (i = !1),
  27611. i && Array.isArray(t) && (t = new Float32Array(t));
  27612. var r = new Bi(this._engine,t,e,i,0 === this._meshes.length,n);
  27613. this.setVerticesBuffer(r)
  27614. }
  27615. ,
  27616. e.prototype.removeVerticesData = function(e) {
  27617. this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(),
  27618. delete this._vertexBuffers[e]),
  27619. this._vertexArrayObjects && this._disposeVertexArrayObjects()
  27620. }
  27621. ,
  27622. e.prototype.setVerticesBuffer = function(e, t, i) {
  27623. void 0 === t && (t = null),
  27624. void 0 === i && (i = !0);
  27625. var n = e.getKind();
  27626. this._vertexBuffers[n] && i && this._vertexBuffers[n].dispose(),
  27627. e._buffer && e._buffer._increaseReferences(),
  27628. this._vertexBuffers[n] = e;
  27629. var r = this._meshes
  27630. , o = r.length;
  27631. if (n === Bi.PositionKind) {
  27632. var a = e.getData();
  27633. null != t ? this._totalVertices = t : null != a && (this._totalVertices = a.length / (e.type === Bi.BYTE ? e.byteStride : e.byteStride / 4)),
  27634. this._updateExtend(a),
  27635. this._resetPointsArrayCache();
  27636. for (var s = 0; s < o; s++) {
  27637. var l = r[s];
  27638. l.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
  27639. l._createGlobalSubMesh(!1),
  27640. l.computeWorldMatrix(!0),
  27641. l.synchronizeInstances()
  27642. }
  27643. }
  27644. this._notifyUpdate(n)
  27645. }
  27646. ,
  27647. e.prototype.updateVerticesDataDirectly = function(e, t, i, n) {
  27648. void 0 === n && (n = !1);
  27649. var r = this.getVertexBuffer(e);
  27650. r && (r.updateDirectly(t, i, n),
  27651. this._notifyUpdate(e))
  27652. }
  27653. ,
  27654. e.prototype.updateVerticesData = function(e, t, i) {
  27655. void 0 === i && (i = !1);
  27656. var n = this.getVertexBuffer(e);
  27657. n && (n.update(t),
  27658. e === Bi.PositionKind && this._updateBoundingInfo(i, t),
  27659. this._notifyUpdate(e))
  27660. }
  27661. ,
  27662. e.prototype._updateBoundingInfo = function(e, t) {
  27663. if (e && this._updateExtend(t),
  27664. this._resetPointsArrayCache(),
  27665. e)
  27666. for (var i = 0, n = this._meshes; i < n.length; i++) {
  27667. var r = n[i];
  27668. r.hasBoundingInfo ? r.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : r.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
  27669. for (var o = 0, a = r.subMeshes; o < a.length; o++)
  27670. a[o].refreshBoundingInfo()
  27671. }
  27672. }
  27673. ,
  27674. e.prototype._bind = function(e, t, i, n) {
  27675. if (e) {
  27676. void 0 === t && (t = this._indexBuffer);
  27677. var r = this.getVertexBuffers();
  27678. if (r)
  27679. if (t == this._indexBuffer && (this._vertexArrayObjects || n)) {
  27680. var o = n || this._vertexArrayObjects;
  27681. o[e.key] || (o[e.key] = this._engine.recordVertexArrayObject(r, t, e, i)),
  27682. this._engine.bindVertexArrayObject(o[e.key], t)
  27683. } else
  27684. this._engine.bindBuffers(r, t, e, i)
  27685. }
  27686. }
  27687. ,
  27688. e.prototype.getTotalVertices = function() {
  27689. return this.isReady() ? this._totalVertices : 0
  27690. }
  27691. ,
  27692. e.prototype.getVerticesData = function(e, t, i) {
  27693. var n = this.getVertexBuffer(e);
  27694. return n ? n.getFloatData(this._totalVertices, i || t && 1 !== this._meshes.length) : null
  27695. }
  27696. ,
  27697. e.prototype.isVertexBufferUpdatable = function(e) {
  27698. var t = this._vertexBuffers[e];
  27699. return !!t && t.isUpdatable()
  27700. }
  27701. ,
  27702. e.prototype.getVertexBuffer = function(e) {
  27703. return this.isReady() ? this._vertexBuffers[e] : null
  27704. }
  27705. ,
  27706. e.prototype.getVertexBuffers = function() {
  27707. return this.isReady() ? this._vertexBuffers : null
  27708. }
  27709. ,
  27710. e.prototype.isVerticesDataPresent = function(e) {
  27711. return this._vertexBuffers ? void 0 !== this._vertexBuffers[e] : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
  27712. }
  27713. ,
  27714. e.prototype.getVerticesDataKinds = function() {
  27715. var e, t = [];
  27716. if (!this._vertexBuffers && this._delayInfo)
  27717. for (e in this._delayInfo)
  27718. t.push(e);
  27719. else
  27720. for (e in this._vertexBuffers)
  27721. t.push(e);
  27722. return t
  27723. }
  27724. ,
  27725. e.prototype.updateIndices = function(e, t, i) {
  27726. if (void 0 === i && (i = !1),
  27727. this._indexBuffer)
  27728. if (this._indexBufferIsUpdatable) {
  27729. var n = e.length !== this._indices.length;
  27730. if (i || (this._indices = e.slice()),
  27731. this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, t),
  27732. n)
  27733. for (var r = 0, o = this._meshes; r < o.length; r++)
  27734. o[r]._createGlobalSubMesh(!0)
  27735. } else
  27736. this.setIndices(e, null, !0)
  27737. }
  27738. ,
  27739. e.prototype.setIndices = function(e, t, i) {
  27740. void 0 === t && (t = null),
  27741. void 0 === i && (i = !1),
  27742. this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
  27743. this._indices = e,
  27744. this._indexBufferIsUpdatable = i,
  27745. 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, i)),
  27746. null != t && (this._totalVertices = t);
  27747. for (var n = 0, r = this._meshes; n < r.length; n++) {
  27748. var o = r[n];
  27749. o._createGlobalSubMesh(!0),
  27750. o.synchronizeInstances()
  27751. }
  27752. this._notifyUpdate()
  27753. }
  27754. ,
  27755. e.prototype.getTotalIndices = function() {
  27756. return this.isReady() ? this._indices.length : 0
  27757. }
  27758. ,
  27759. e.prototype.getIndices = function(e, t) {
  27760. if (!this.isReady())
  27761. return null;
  27762. var i = this._indices;
  27763. return t || e && 1 !== this._meshes.length ? gi.Slice(i) : i
  27764. }
  27765. ,
  27766. e.prototype.getIndexBuffer = function() {
  27767. return this.isReady() ? this._indexBuffer : null
  27768. }
  27769. ,
  27770. e.prototype._releaseVertexArrayObject = function(e) {
  27771. void 0 === e && (e = null),
  27772. e && this._vertexArrayObjects && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),
  27773. delete this._vertexArrayObjects[e.key])
  27774. }
  27775. ,
  27776. e.prototype.releaseForMesh = function(e, t) {
  27777. var i = this._meshes
  27778. , n = i.indexOf(e);
  27779. -1 !== n && (i.splice(n, 1),
  27780. this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(),
  27781. e._geometry = null,
  27782. 0 === i.length && t && this.dispose())
  27783. }
  27784. ,
  27785. e.prototype.applyToMesh = function(e) {
  27786. if (e._geometry !== this) {
  27787. var t = e._geometry;
  27788. t && t.releaseForMesh(e),
  27789. this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject();
  27790. var i = this._meshes;
  27791. e._geometry = this,
  27792. e._internalAbstractMeshDataInfo._positions = null,
  27793. this._scene.pushGeometry(this),
  27794. i.push(e),
  27795. this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo)
  27796. }
  27797. }
  27798. ,
  27799. e.prototype._updateExtend = function(e) {
  27800. if (void 0 === e && (e = null),
  27801. this.useBoundingInfoFromGeometry && this._boundingInfo)
  27802. this._extend = {
  27803. minimum: this._boundingInfo.minimum.clone(),
  27804. maximum: this._boundingInfo.maximum.clone()
  27805. };
  27806. else {
  27807. if (!e && !(e = this.getVerticesData(Bi.PositionKind)))
  27808. return;
  27809. this._extend = ur(e, 0, this._totalVertices, this.boundingBias, 3)
  27810. }
  27811. }
  27812. ,
  27813. e.prototype._applyToMesh = function(e) {
  27814. var t = this._meshes.length;
  27815. for (var i in this._vertexBuffers)
  27816. 1 === t && this._vertexBuffers[i].create(),
  27817. i === Bi.PositionKind && (this._extend || this._updateExtend(),
  27818. e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
  27819. e._createGlobalSubMesh(!1),
  27820. e._updateBoundingInfo());
  27821. 1 === t && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
  27822. e._syncGeometryWithMorphTargetManager(),
  27823. e.synchronizeInstances()
  27824. }
  27825. ,
  27826. e.prototype._notifyUpdate = function(e) {
  27827. this.onGeometryUpdated && this.onGeometryUpdated(this, e),
  27828. this._vertexArrayObjects && this._disposeVertexArrayObjects();
  27829. for (var t = 0, i = this._meshes; t < i.length; t++)
  27830. i[t]._markSubMeshesAsAttributesDirty()
  27831. }
  27832. ,
  27833. e.prototype.load = function(e, t) {
  27834. this.delayLoadState !== a.DELAYLOADSTATE_LOADING && (this.isReady() ? t && t() : (this.delayLoadState = a.DELAYLOADSTATE_LOADING,
  27835. this._queueLoad(e, t)))
  27836. }
  27837. ,
  27838. e.prototype._queueLoad = function(e, t) {
  27839. var i = this;
  27840. this.delayLoadingFile && (e._addPendingData(this),
  27841. e._loadFile(this.delayLoadingFile, (function(n) {
  27842. if (i._delayLoadingFunction) {
  27843. i._delayLoadingFunction(JSON.parse(n), i),
  27844. i.delayLoadState = a.DELAYLOADSTATE_LOADED,
  27845. i._delayInfo = [],
  27846. e._removePendingData(i);
  27847. for (var r = i._meshes, o = r.length, s = 0; s < o; s++)
  27848. i._applyToMesh(r[s]);
  27849. t && t()
  27850. }
  27851. }
  27852. ), void 0, !0))
  27853. }
  27854. ,
  27855. e.prototype.toLeftHanded = function() {
  27856. var e = this.getIndices(!1);
  27857. if (null != e && e.length > 0) {
  27858. for (var t = 0; t < e.length; t += 3) {
  27859. var i = e[t + 0];
  27860. e[t + 0] = e[t + 2],
  27861. e[t + 2] = i
  27862. }
  27863. this.setIndices(e)
  27864. }
  27865. var n = this.getVerticesData(Bi.PositionKind, !1);
  27866. if (null != n && n.length > 0) {
  27867. for (t = 0; t < n.length; t += 3)
  27868. n[t + 2] = -n[t + 2];
  27869. this.setVerticesData(Bi.PositionKind, n, !1)
  27870. }
  27871. var r = this.getVerticesData(Bi.NormalKind, !1);
  27872. if (null != r && r.length > 0) {
  27873. for (t = 0; t < r.length; t += 3)
  27874. r[t + 2] = -r[t + 2];
  27875. this.setVerticesData(Bi.NormalKind, r, !1)
  27876. }
  27877. }
  27878. ,
  27879. e.prototype._resetPointsArrayCache = function() {
  27880. this._positions = null
  27881. }
  27882. ,
  27883. e.prototype._generatePointsArray = function() {
  27884. if (this._positions)
  27885. return !0;
  27886. var e = this.getVerticesData(Bi.PositionKind);
  27887. if (!e || 0 === e.length)
  27888. return !1;
  27889. for (var t = 3 * this._positionsCache.length, i = this._positionsCache.length; t < e.length; t += 3,
  27890. ++i)
  27891. this._positionsCache[i] = x.FromArray(e, t);
  27892. for (t = 0,
  27893. i = 0; t < e.length; t += 3,
  27894. ++i)
  27895. this._positionsCache[i].set(e[0 + t], e[1 + t], e[2 + t]);
  27896. return this._positionsCache.length = e.length / 3,
  27897. this._positions = this._positionsCache,
  27898. !0
  27899. }
  27900. ,
  27901. e.prototype.isDisposed = function() {
  27902. return this._isDisposed
  27903. }
  27904. ,
  27905. e.prototype._disposeVertexArrayObjects = function() {
  27906. if (this._vertexArrayObjects) {
  27907. for (var e in this._vertexArrayObjects)
  27908. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);
  27909. this._vertexArrayObjects = {};
  27910. for (var t = this._meshes, i = t.length, n = 0; n < i; n++)
  27911. t[n]._invalidateInstanceVertexArrayObject()
  27912. }
  27913. }
  27914. ,
  27915. e.prototype.dispose = function() {
  27916. var e, t = this._meshes, i = t.length;
  27917. for (e = 0; e < i; e++)
  27918. this.releaseForMesh(t[e]);
  27919. for (var n in this._meshes = [],
  27920. this._disposeVertexArrayObjects(),
  27921. this._vertexBuffers)
  27922. this._vertexBuffers[n].dispose();
  27923. if (this._vertexBuffers = {},
  27924. this._totalVertices = 0,
  27925. this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
  27926. this._indexBuffer = null,
  27927. this._indices = [],
  27928. this.delayLoadState = a.DELAYLOADSTATE_NONE,
  27929. this.delayLoadingFile = null,
  27930. this._delayLoadingFunction = null,
  27931. this._delayInfo = [],
  27932. this._boundingInfo = null,
  27933. this._scene.removeGeometry(this),
  27934. this._parentContainer) {
  27935. var r = this._parentContainer.geometries.indexOf(this);
  27936. r > -1 && this._parentContainer.geometries.splice(r, 1),
  27937. this._parentContainer = null
  27938. }
  27939. this._isDisposed = !0
  27940. }
  27941. ,
  27942. e.prototype.copy = function(t) {
  27943. var i = new $n;
  27944. i.indices = [];
  27945. var n = this.getIndices();
  27946. if (n)
  27947. for (var r = 0; r < n.length; r++)
  27948. i.indices.push(n[r]);
  27949. var o, a = !1, s = !1;
  27950. for (o in this._vertexBuffers) {
  27951. var l = this.getVerticesData(o);
  27952. if (l && (l instanceof Float32Array ? i.set(new Float32Array(l), o) : i.set(l.slice(0), o),
  27953. !s)) {
  27954. var c = this.getVertexBuffer(o);
  27955. c && (s = !(a = c.isUpdatable()))
  27956. }
  27957. }
  27958. var u = new e(t,this._scene,i,a);
  27959. for (o in u.delayLoadState = this.delayLoadState,
  27960. u.delayLoadingFile = this.delayLoadingFile,
  27961. u._delayLoadingFunction = this._delayLoadingFunction,
  27962. this._delayInfo)
  27963. u._delayInfo = u._delayInfo || [],
  27964. u._delayInfo.push(o);
  27965. return u._boundingInfo = new sr(this._extend.minimum,this._extend.maximum),
  27966. u
  27967. }
  27968. ,
  27969. e.prototype.serialize = function() {
  27970. var e = {};
  27971. return e.id = this.id,
  27972. e.uniqueId = this.uniqueId,
  27973. e.updatable = this._updatable,
  27974. ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
  27975. e
  27976. }
  27977. ,
  27978. e.prototype._toNumberArray = function(e) {
  27979. return Array.isArray(e) ? e : Array.prototype.slice.call(e)
  27980. }
  27981. ,
  27982. e.prototype.clearCachedData = function() {
  27983. for (var e in this._indices = [],
  27984. this._resetPointsArrayCache(),
  27985. this._vertexBuffers)
  27986. Object.prototype.hasOwnProperty.call(this._vertexBuffers, e) && (this._vertexBuffers[e]._buffer._data = null)
  27987. }
  27988. ,
  27989. e.prototype.serializeVerticeData = function() {
  27990. var e = this.serialize();
  27991. return this.isVerticesDataPresent(Bi.PositionKind) && (e.positions = this._toNumberArray(this.getVerticesData(Bi.PositionKind)),
  27992. this.isVertexBufferUpdatable(Bi.PositionKind) && (e.positions._updatable = !0)),
  27993. this.isVerticesDataPresent(Bi.NormalKind) && (e.normals = this._toNumberArray(this.getVerticesData(Bi.NormalKind)),
  27994. this.isVertexBufferUpdatable(Bi.NormalKind) && (e.normals._updatable = !0)),
  27995. this.isVerticesDataPresent(Bi.TangentKind) && (e.tangents = this._toNumberArray(this.getVerticesData(Bi.TangentKind)),
  27996. this.isVertexBufferUpdatable(Bi.TangentKind) && (e.tangents._updatable = !0)),
  27997. this.isVerticesDataPresent(Bi.UVKind) && (e.uvs = this._toNumberArray(this.getVerticesData(Bi.UVKind)),
  27998. this.isVertexBufferUpdatable(Bi.UVKind) && (e.uvs._updatable = !0)),
  27999. this.isVerticesDataPresent(Bi.UV2Kind) && (e.uv2s = this._toNumberArray(this.getVerticesData(Bi.UV2Kind)),
  28000. this.isVertexBufferUpdatable(Bi.UV2Kind) && (e.uv2s._updatable = !0)),
  28001. this.isVerticesDataPresent(Bi.UV3Kind) && (e.uv3s = this._toNumberArray(this.getVerticesData(Bi.UV3Kind)),
  28002. this.isVertexBufferUpdatable(Bi.UV3Kind) && (e.uv3s._updatable = !0)),
  28003. this.isVerticesDataPresent(Bi.UV4Kind) && (e.uv4s = this._toNumberArray(this.getVerticesData(Bi.UV4Kind)),
  28004. this.isVertexBufferUpdatable(Bi.UV4Kind) && (e.uv4s._updatable = !0)),
  28005. this.isVerticesDataPresent(Bi.UV5Kind) && (e.uv5s = this._toNumberArray(this.getVerticesData(Bi.UV5Kind)),
  28006. this.isVertexBufferUpdatable(Bi.UV5Kind) && (e.uv5s._updatable = !0)),
  28007. this.isVerticesDataPresent(Bi.UV6Kind) && (e.uv6s = this._toNumberArray(this.getVerticesData(Bi.UV6Kind)),
  28008. this.isVertexBufferUpdatable(Bi.UV6Kind) && (e.uv6s._updatable = !0)),
  28009. this.isVerticesDataPresent(Bi.ColorKind) && (e.colors = this._toNumberArray(this.getVerticesData(Bi.ColorKind)),
  28010. this.isVertexBufferUpdatable(Bi.ColorKind) && (e.colors._updatable = !0)),
  28011. this.isVerticesDataPresent(Bi.MatricesIndicesKind) && (e.matricesIndices = this._toNumberArray(this.getVerticesData(Bi.MatricesIndicesKind)),
  28012. e.matricesIndices._isExpanded = !0,
  28013. this.isVertexBufferUpdatable(Bi.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
  28014. this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (e.matricesWeights = this._toNumberArray(this.getVerticesData(Bi.MatricesWeightsKind)),
  28015. this.isVertexBufferUpdatable(Bi.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)),
  28016. e.indices = this._toNumberArray(this.getIndices()),
  28017. e
  28018. }
  28019. ,
  28020. e.ExtractFromMesh = function(e, t) {
  28021. var i = e._geometry;
  28022. return i ? i.copy(t) : null
  28023. }
  28024. ,
  28025. e.RandomId = function() {
  28026. return gi.RandomId()
  28027. }
  28028. ,
  28029. e._GetGeometryByLoadedUniqueId = function(e, t) {
  28030. for (var i = 0; i < t.geometries.length; i++)
  28031. if (t.geometries[i]._loadedUniqueId === e)
  28032. return t.geometries[i];
  28033. return null
  28034. }
  28035. ,
  28036. e._ImportGeometry = function(t, i) {
  28037. var n = i.getScene()
  28038. , r = t.geometryUniqueId
  28039. , o = t.geometryId;
  28040. if (r || o) {
  28041. var a = r ? this._GetGeometryByLoadedUniqueId(r, n) : n.getGeometryById(o);
  28042. a && a.applyToMesh(i)
  28043. } else if (t instanceof ArrayBuffer) {
  28044. var s = i._binaryInfo;
  28045. if (s.positionsAttrDesc && s.positionsAttrDesc.count > 0) {
  28046. var l = new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);
  28047. i.setVerticesData(Bi.PositionKind, l, !1)
  28048. }
  28049. if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) {
  28050. var c = new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);
  28051. i.setVerticesData(Bi.NormalKind, c, !1)
  28052. }
  28053. if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) {
  28054. var u = new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);
  28055. i.setVerticesData(Bi.TangentKind, u, !1)
  28056. }
  28057. if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) {
  28058. var h = new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);
  28059. if (pr.UseOpenGLOrientationForUV)
  28060. for (var d = 1; d < h.length; d += 2)
  28061. h[d] = 1 - h[d];
  28062. i.setVerticesData(Bi.UVKind, h, !1)
  28063. }
  28064. if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) {
  28065. var p = new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);
  28066. if (pr.UseOpenGLOrientationForUV)
  28067. for (d = 1; d < p.length; d += 2)
  28068. p[d] = 1 - p[d];
  28069. i.setVerticesData(Bi.UV2Kind, p, !1)
  28070. }
  28071. if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) {
  28072. var f = new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);
  28073. if (pr.UseOpenGLOrientationForUV)
  28074. for (d = 1; d < f.length; d += 2)
  28075. f[d] = 1 - f[d];
  28076. i.setVerticesData(Bi.UV3Kind, f, !1)
  28077. }
  28078. if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) {
  28079. var _ = new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);
  28080. if (pr.UseOpenGLOrientationForUV)
  28081. for (d = 1; d < _.length; d += 2)
  28082. _[d] = 1 - _[d];
  28083. i.setVerticesData(Bi.UV4Kind, _, !1)
  28084. }
  28085. if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) {
  28086. var m = new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);
  28087. if (pr.UseOpenGLOrientationForUV)
  28088. for (d = 1; d < m.length; d += 2)
  28089. m[d] = 1 - m[d];
  28090. i.setVerticesData(Bi.UV5Kind, m, !1)
  28091. }
  28092. if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) {
  28093. var g = new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);
  28094. if (pr.UseOpenGLOrientationForUV)
  28095. for (d = 1; d < g.length; d += 2)
  28096. g[d] = 1 - g[d];
  28097. i.setVerticesData(Bi.UV6Kind, g, !1)
  28098. }
  28099. if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) {
  28100. var v = new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);
  28101. i.setVerticesData(Bi.ColorKind, v, !1, s.colorsAttrDesc.stride)
  28102. }
  28103. if (s.matricesIndicesAttrDesc && s.matricesIndicesAttrDesc.count > 0) {
  28104. for (var y = new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count), b = [], T = 0; T < y.length; T++)
  28105. d = y[T],
  28106. b.push(255 & d),
  28107. b.push((65280 & d) >> 8),
  28108. b.push((16711680 & d) >> 16),
  28109. b.push(d >> 24 & 255);
  28110. i.setVerticesData(Bi.MatricesIndicesKind, b, !1)
  28111. }
  28112. if (s.matricesIndicesExtraAttrDesc && s.matricesIndicesExtraAttrDesc.count > 0) {
  28113. for (y = new Int32Array(t,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),
  28114. b = [],
  28115. T = 0; T < y.length; T++)
  28116. d = y[T],
  28117. b.push(255 & d),
  28118. b.push((65280 & d) >> 8),
  28119. b.push((16711680 & d) >> 16),
  28120. b.push(d >> 24 & 255);
  28121. i.setVerticesData(Bi.MatricesIndicesExtraKind, b, !1)
  28122. }
  28123. if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) {
  28124. var E = new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);
  28125. i.setVerticesData(Bi.MatricesWeightsKind, E, !1)
  28126. }
  28127. if (s.indicesAttrDesc && s.indicesAttrDesc.count > 0) {
  28128. var S = new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);
  28129. i.setIndices(S, null)
  28130. }
  28131. if (s.subMeshesAttrDesc && s.subMeshesAttrDesc.count > 0) {
  28132. var A = new Int32Array(t,s.subMeshesAttrDesc.offset,5 * s.subMeshesAttrDesc.count);
  28133. for (i.subMeshes = [],
  28134. T = 0; T < s.subMeshesAttrDesc.count; T++) {
  28135. var x = A[5 * T + 0]
  28136. , R = A[5 * T + 1]
  28137. , C = A[5 * T + 2]
  28138. , P = A[5 * T + 3]
  28139. , M = A[5 * T + 4];
  28140. hr.AddToMesh(x, R, C, P, M, i)
  28141. }
  28142. }
  28143. } else if (t.positions && t.normals && t.indices) {
  28144. if (i.setVerticesData(Bi.PositionKind, t.positions, t.positions._updatable),
  28145. i.setVerticesData(Bi.NormalKind, t.normals, t.normals._updatable),
  28146. t.tangents && i.setVerticesData(Bi.TangentKind, t.tangents, t.tangents._updatable),
  28147. t.uvs && i.setVerticesData(Bi.UVKind, t.uvs, t.uvs._updatable),
  28148. t.uvs2 && i.setVerticesData(Bi.UV2Kind, t.uvs2, t.uvs2._updatable),
  28149. t.uvs3 && i.setVerticesData(Bi.UV3Kind, t.uvs3, t.uvs3._updatable),
  28150. t.uvs4 && i.setVerticesData(Bi.UV4Kind, t.uvs4, t.uvs4._updatable),
  28151. t.uvs5 && i.setVerticesData(Bi.UV5Kind, t.uvs5, t.uvs5._updatable),
  28152. t.uvs6 && i.setVerticesData(Bi.UV6Kind, t.uvs6, t.uvs6._updatable),
  28153. t.colors && i.setVerticesData(Bi.ColorKind, N.CheckColors4(t.colors, t.positions.length / 3), t.colors._updatable),
  28154. t.matricesIndices)
  28155. if (t.matricesIndices._isExpanded)
  28156. delete t.matricesIndices._isExpanded,
  28157. i.setVerticesData(Bi.MatricesIndicesKind, t.matricesIndices, t.matricesIndices._updatable);
  28158. else {
  28159. for (b = [],
  28160. T = 0; T < t.matricesIndices.length; T++) {
  28161. var I = t.matricesIndices[T];
  28162. b.push(255 & I),
  28163. b.push((65280 & I) >> 8),
  28164. b.push((16711680 & I) >> 16),
  28165. b.push(I >> 24 & 255)
  28166. }
  28167. i.setVerticesData(Bi.MatricesIndicesKind, b, t.matricesIndices._updatable)
  28168. }
  28169. if (t.matricesIndicesExtra)
  28170. if (t.matricesIndicesExtra._isExpanded)
  28171. delete t.matricesIndices._isExpanded,
  28172. i.setVerticesData(Bi.MatricesIndicesExtraKind, t.matricesIndicesExtra, t.matricesIndicesExtra._updatable);
  28173. else {
  28174. for (b = [],
  28175. T = 0; T < t.matricesIndicesExtra.length; T++)
  28176. I = t.matricesIndicesExtra[T],
  28177. b.push(255 & I),
  28178. b.push((65280 & I) >> 8),
  28179. b.push((16711680 & I) >> 16),
  28180. b.push(I >> 24 & 255);
  28181. i.setVerticesData(Bi.MatricesIndicesExtraKind, b, t.matricesIndicesExtra._updatable)
  28182. }
  28183. t.matricesWeights && (e._CleanMatricesWeights(t, i),
  28184. i.setVerticesData(Bi.MatricesWeightsKind, t.matricesWeights, t.matricesWeights._updatable)),
  28185. t.matricesWeightsExtra && i.setVerticesData(Bi.MatricesWeightsExtraKind, t.matricesWeightsExtra, t.matricesWeights._updatable),
  28186. i.setIndices(t.indices, null)
  28187. }
  28188. if (t.subMeshes) {
  28189. i.subMeshes = [];
  28190. for (var O = 0; O < t.subMeshes.length; O++) {
  28191. var D = t.subMeshes[O];
  28192. hr.AddToMesh(D.materialIndex, D.verticesStart, D.verticesCount, D.indexStart, D.indexCount, i)
  28193. }
  28194. }
  28195. i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(),
  28196. i._shouldGenerateFlatShading = !1),
  28197. i.computeWorldMatrix(!0),
  28198. n.onMeshImportedObservable.notifyObservers(i)
  28199. }
  28200. ,
  28201. e._CleanMatricesWeights = function(e, t) {
  28202. var i = .001;
  28203. if (dr.CleanBoneMatrixWeights) {
  28204. var n = 0;
  28205. if (e.skeletonId > -1) {
  28206. var r = t.getScene().getLastSkeletonById(e.skeletonId);
  28207. if (r) {
  28208. n = r.bones.length;
  28209. for (var o = t.getVerticesData(Bi.MatricesIndicesKind), a = t.getVerticesData(Bi.MatricesIndicesExtraKind), s = e.matricesWeights, l = e.matricesWeightsExtra, c = e.numBoneInfluencer, u = s.length, h = 0; h < u; h += 4) {
  28210. for (var d = 0, p = -1, f = 0; f < 4; f++)
  28211. d += _ = s[h + f],
  28212. _ < i && p < 0 && (p = f);
  28213. if (l)
  28214. for (f = 0; f < 4; f++) {
  28215. var _;
  28216. d += _ = l[h + f],
  28217. _ < i && p < 0 && (p = f + 4)
  28218. }
  28219. if ((p < 0 || p > c - 1) && (p = c - 1),
  28220. d > i) {
  28221. var m = 1 / d;
  28222. for (f = 0; f < 4; f++)
  28223. s[h + f] *= m;
  28224. if (l)
  28225. for (f = 0; f < 4; f++)
  28226. l[h + f] *= m
  28227. } else
  28228. p >= 4 ? (l[h + p - 4] = 1 - d,
  28229. a[h + p - 4] = n) : (s[h + p] = 1 - d,
  28230. o[h + p] = n)
  28231. }
  28232. t.setVerticesData(Bi.MatricesIndicesKind, o),
  28233. e.matricesWeightsExtra && t.setVerticesData(Bi.MatricesIndicesExtraKind, a)
  28234. }
  28235. }
  28236. }
  28237. }
  28238. ,
  28239. e.Parse = function(t, i, n) {
  28240. var r = new e(t.id,i,void 0,t.updatable);
  28241. return r._loadedUniqueId = t.uniqueId,
  28242. ye && ye.AddTagsTo(r, t.tags),
  28243. t.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
  28244. r.delayLoadingFile = n + t.delayLoadingFile,
  28245. r._boundingInfo = new sr(x.FromArray(t.boundingBoxMinimum),x.FromArray(t.boundingBoxMaximum)),
  28246. r._delayInfo = [],
  28247. t.hasUVs && r._delayInfo.push(Bi.UVKind),
  28248. t.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
  28249. t.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
  28250. t.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
  28251. t.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
  28252. t.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
  28253. t.hasColors && r._delayInfo.push(Bi.ColorKind),
  28254. t.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
  28255. t.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
  28256. r._delayLoadingFunction = $n.ImportVertexData) : $n.ImportVertexData(t, r),
  28257. i.pushGeometry(r, !0),
  28258. r
  28259. }
  28260. ,
  28261. e
  28262. }()
  28263. , _r = function() {
  28264. function e(e) {
  28265. void 0 === e && (e = 30),
  28266. this._enabled = !0,
  28267. this._rollingFrameTime = new mr(e)
  28268. }
  28269. return e.prototype.sampleFrame = function(e) {
  28270. if (void 0 === e && (e = ct.Now),
  28271. this._enabled) {
  28272. if (null != this._lastFrameTimeMs) {
  28273. var t = e - this._lastFrameTimeMs;
  28274. this._rollingFrameTime.add(t)
  28275. }
  28276. this._lastFrameTimeMs = e
  28277. }
  28278. }
  28279. ,
  28280. Object.defineProperty(e.prototype, "averageFrameTime", {
  28281. get: function() {
  28282. return this._rollingFrameTime.average
  28283. },
  28284. enumerable: !1,
  28285. configurable: !0
  28286. }),
  28287. Object.defineProperty(e.prototype, "averageFrameTimeVariance", {
  28288. get: function() {
  28289. return this._rollingFrameTime.variance
  28290. },
  28291. enumerable: !1,
  28292. configurable: !0
  28293. }),
  28294. Object.defineProperty(e.prototype, "instantaneousFrameTime", {
  28295. get: function() {
  28296. return this._rollingFrameTime.history(0)
  28297. },
  28298. enumerable: !1,
  28299. configurable: !0
  28300. }),
  28301. Object.defineProperty(e.prototype, "averageFPS", {
  28302. get: function() {
  28303. return 1e3 / this._rollingFrameTime.average
  28304. },
  28305. enumerable: !1,
  28306. configurable: !0
  28307. }),
  28308. Object.defineProperty(e.prototype, "instantaneousFPS", {
  28309. get: function() {
  28310. var e = this._rollingFrameTime.history(0);
  28311. return 0 === e ? 0 : 1e3 / e
  28312. },
  28313. enumerable: !1,
  28314. configurable: !0
  28315. }),
  28316. Object.defineProperty(e.prototype, "isSaturated", {
  28317. get: function() {
  28318. return this._rollingFrameTime.isSaturated()
  28319. },
  28320. enumerable: !1,
  28321. configurable: !0
  28322. }),
  28323. e.prototype.enable = function() {
  28324. this._enabled = !0
  28325. }
  28326. ,
  28327. e.prototype.disable = function() {
  28328. this._enabled = !1,
  28329. this._lastFrameTimeMs = null
  28330. }
  28331. ,
  28332. Object.defineProperty(e.prototype, "isEnabled", {
  28333. get: function() {
  28334. return this._enabled
  28335. },
  28336. enumerable: !1,
  28337. configurable: !0
  28338. }),
  28339. e.prototype.reset = function() {
  28340. this._lastFrameTimeMs = null,
  28341. this._rollingFrameTime.reset()
  28342. }
  28343. ,
  28344. e
  28345. }()
  28346. , mr = function() {
  28347. function e(e) {
  28348. this._samples = new Array(e),
  28349. this.reset()
  28350. }
  28351. return e.prototype.add = function(e) {
  28352. var t;
  28353. if (this.isSaturated()) {
  28354. var i = this._samples[this._pos];
  28355. t = i - this.average,
  28356. this.average -= t / (this._sampleCount - 1),
  28357. this._m2 -= t * (i - this.average)
  28358. } else
  28359. this._sampleCount++;
  28360. t = e - this.average,
  28361. this.average += t / this._sampleCount,
  28362. this._m2 += t * (e - this.average),
  28363. this.variance = this._m2 / (this._sampleCount - 1),
  28364. this._samples[this._pos] = e,
  28365. this._pos++,
  28366. this._pos %= this._samples.length
  28367. }
  28368. ,
  28369. e.prototype.history = function(e) {
  28370. if (e >= this._sampleCount || e >= this._samples.length)
  28371. return 0;
  28372. var t = this._wrapPosition(this._pos - 1);
  28373. return this._samples[this._wrapPosition(t - e)]
  28374. }
  28375. ,
  28376. e.prototype.isSaturated = function() {
  28377. return this._sampleCount >= this._samples.length
  28378. }
  28379. ,
  28380. e.prototype.reset = function() {
  28381. this.average = 0,
  28382. this.variance = 0,
  28383. this._sampleCount = 0,
  28384. this._pos = 0,
  28385. this._m2 = 0
  28386. }
  28387. ,
  28388. e.prototype._wrapPosition = function(e) {
  28389. var t = this._samples.length;
  28390. return (e % t + t) % t
  28391. }
  28392. ,
  28393. e
  28394. }();
  28395. function gr(e, t, i, n) {
  28396. switch (void 0 === i && (i = !1),
  28397. e) {
  28398. case a.TEXTURETYPE_BYTE:
  28399. var r = (ArrayBuffer,
  28400. new Int8Array(t));
  28401. return n && r.set(new Int8Array(n)),
  28402. r;
  28403. case a.TEXTURETYPE_UNSIGNED_BYTE:
  28404. var o = (ArrayBuffer,
  28405. new Uint8Array(t));
  28406. return n && o.set(new Uint8Array(n)),
  28407. o;
  28408. case a.TEXTURETYPE_SHORT:
  28409. var s = t instanceof ArrayBuffer ? new Int16Array(t) : new Int16Array(i ? t / 2 : t);
  28410. return n && s.set(new Int16Array(n)),
  28411. s;
  28412. case a.TEXTURETYPE_UNSIGNED_SHORT:
  28413. case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  28414. case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  28415. case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  28416. case a.TEXTURETYPE_HALF_FLOAT:
  28417. var l = t instanceof ArrayBuffer ? new Uint16Array(t) : new Uint16Array(i ? t / 2 : t);
  28418. return n && l.set(new Uint16Array(n)),
  28419. l;
  28420. case a.TEXTURETYPE_INT:
  28421. var c = t instanceof ArrayBuffer ? new Int32Array(t) : new Int32Array(i ? t / 4 : t);
  28422. return n && c.set(new Int32Array(n)),
  28423. c;
  28424. case a.TEXTURETYPE_UNSIGNED_INTEGER:
  28425. case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  28426. case a.TEXTURETYPE_UNSIGNED_INT_24_8:
  28427. case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  28428. case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  28429. case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  28430. var u = t instanceof ArrayBuffer ? new Uint32Array(t) : new Uint32Array(i ? t / 4 : t);
  28431. return n && u.set(new Uint32Array(n)),
  28432. u;
  28433. case a.TEXTURETYPE_FLOAT:
  28434. var h = t instanceof ArrayBuffer ? new Float32Array(t) : new Float32Array(i ? t / 4 : t);
  28435. return n && h.set(new Float32Array(n)),
  28436. h
  28437. }
  28438. var d = (ArrayBuffer,
  28439. new Uint8Array(t));
  28440. return n && d.set(new Uint8Array(n)),
  28441. d
  28442. }
  28443. Ht.prototype.setAlphaConstants = function(e, t, i, n) {
  28444. this._alphaState.setAlphaBlendConstants(e, t, i, n)
  28445. }
  28446. ,
  28447. Ht.prototype.setAlphaMode = function(e, t) {
  28448. if (void 0 === t && (t = !1),
  28449. this._alphaMode !== e) {
  28450. switch (e) {
  28451. case a.ALPHA_DISABLE:
  28452. this._alphaState.alphaBlend = !1;
  28453. break;
  28454. case a.ALPHA_PREMULTIPLIED:
  28455. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
  28456. this._alphaState.alphaBlend = !0;
  28457. break;
  28458. case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
  28459. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  28460. this._alphaState.alphaBlend = !0;
  28461. break;
  28462. case a.ALPHA_COMBINE:
  28463. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
  28464. this._alphaState.alphaBlend = !0;
  28465. break;
  28466. case a.ALPHA_ONEONE:
  28467. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
  28468. this._alphaState.alphaBlend = !0;
  28469. break;
  28470. case a.ALPHA_ADD:
  28471. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
  28472. this._alphaState.alphaBlend = !0;
  28473. break;
  28474. case a.ALPHA_SUBTRACT:
  28475. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
  28476. this._alphaState.alphaBlend = !0;
  28477. break;
  28478. case a.ALPHA_MULTIPLY:
  28479. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE),
  28480. this._alphaState.alphaBlend = !0;
  28481. break;
  28482. case a.ALPHA_MAXIMIZED:
  28483. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
  28484. this._alphaState.alphaBlend = !0;
  28485. break;
  28486. case a.ALPHA_INTERPOLATE:
  28487. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA),
  28488. this._alphaState.alphaBlend = !0;
  28489. break;
  28490. case a.ALPHA_SCREENMODE:
  28491. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  28492. this._alphaState.alphaBlend = !0;
  28493. break;
  28494. case a.ALPHA_ONEONE_ONEONE:
  28495. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE),
  28496. this._alphaState.alphaBlend = !0;
  28497. break;
  28498. case a.ALPHA_ALPHATOCOLOR:
  28499. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO),
  28500. this._alphaState.alphaBlend = !0;
  28501. break;
  28502. case a.ALPHA_REVERSEONEMINUS:
  28503. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE_MINUS_DST_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA),
  28504. this._alphaState.alphaBlend = !0;
  28505. break;
  28506. case a.ALPHA_SRC_DSTONEMINUSSRCALPHA:
  28507. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  28508. this._alphaState.alphaBlend = !0;
  28509. break;
  28510. case a.ALPHA_ONEONE_ONEZERO:
  28511. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO),
  28512. this._alphaState.alphaBlend = !0;
  28513. break;
  28514. case a.ALPHA_EXCLUSION:
  28515. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE),
  28516. this._alphaState.alphaBlend = !0;
  28517. break;
  28518. case a.ALPHA_LAYER_ACCUMULATE:
  28519. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
  28520. this._alphaState.alphaBlend = !0
  28521. }
  28522. t || (this.depthCullingState.depthMask = e === a.ALPHA_DISABLE),
  28523. this._alphaMode = e
  28524. }
  28525. }
  28526. ,
  28527. Ht.prototype.getAlphaMode = function() {
  28528. return this._alphaMode
  28529. }
  28530. ,
  28531. Ht.prototype.setAlphaEquation = function(e) {
  28532. if (this._alphaEquation !== e) {
  28533. switch (e) {
  28534. case a.ALPHA_EQUATION_ADD:
  28535. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_ADD, a.GL_ALPHA_EQUATION_ADD);
  28536. break;
  28537. case a.ALPHA_EQUATION_SUBSTRACT:
  28538. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_SUBTRACT, a.GL_ALPHA_EQUATION_SUBTRACT);
  28539. break;
  28540. case a.ALPHA_EQUATION_REVERSE_SUBTRACT:
  28541. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT, a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);
  28542. break;
  28543. case a.ALPHA_EQUATION_MAX:
  28544. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MAX, a.GL_ALPHA_EQUATION_MAX);
  28545. break;
  28546. case a.ALPHA_EQUATION_MIN:
  28547. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN, a.GL_ALPHA_EQUATION_MIN);
  28548. break;
  28549. case a.ALPHA_EQUATION_DARKEN:
  28550. this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN, a.GL_ALPHA_EQUATION_ADD)
  28551. }
  28552. this._alphaEquation = e
  28553. }
  28554. }
  28555. ,
  28556. Ht.prototype.getAlphaEquation = function() {
  28557. return this._alphaEquation
  28558. }
  28559. ,
  28560. Ht.prototype._readTexturePixelsSync = function(e, t, i, n, r, o, a, s) {
  28561. var l, c;
  28562. void 0 === n && (n = -1),
  28563. void 0 === r && (r = 0),
  28564. void 0 === o && (o = null),
  28565. void 0 === a && (a = !0),
  28566. void 0 === s && (s = !1);
  28567. var u = this._gl;
  28568. if (!u)
  28569. throw new Error("Engine does not have gl rendering context.");
  28570. if (!this._dummyFramebuffer) {
  28571. var h = u.createFramebuffer();
  28572. if (!h)
  28573. throw new Error("Unable to create dummy framebuffer");
  28574. this._dummyFramebuffer = h
  28575. }
  28576. u.bindFramebuffer(u.FRAMEBUFFER, this._dummyFramebuffer),
  28577. n > -1 ? u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_CUBE_MAP_POSITIVE_X + n, null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, r) : u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_2D, null === (c = e._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, r);
  28578. var d = void 0 !== e.type ? this._getWebGLTextureType(e.type) : u.UNSIGNED_BYTE;
  28579. return s ? o || (o = gr(e.type, 4 * t * i)) : d === u.UNSIGNED_BYTE ? (o || (o = new Uint8Array(4 * t * i)),
  28580. d = u.UNSIGNED_BYTE) : (o || (o = new Float32Array(4 * t * i)),
  28581. d = u.FLOAT),
  28582. a && this.flushFramebuffer(),
  28583. u.readPixels(0, 0, t, i, u.RGBA, d, o),
  28584. u.bindFramebuffer(u.FRAMEBUFFER, this._currentFramebuffer),
  28585. o
  28586. }
  28587. ,
  28588. Ht.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
  28589. return void 0 === n && (n = -1),
  28590. void 0 === r && (r = 0),
  28591. void 0 === o && (o = null),
  28592. void 0 === a && (a = !0),
  28593. void 0 === s && (s = !1),
  28594. Promise.resolve(this._readTexturePixelsSync(e, t, i, n, r, o, a, s))
  28595. }
  28596. ,
  28597. Ht.prototype.updateDynamicIndexBuffer = function(e, t, i) {
  28598. var n;
  28599. void 0 === i && (i = 0),
  28600. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
  28601. this.bindIndexBuffer(e),
  28602. n = t instanceof Uint16Array || t instanceof Uint32Array ? t : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
  28603. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, n, this._gl.DYNAMIC_DRAW),
  28604. this._resetIndexBufferBinding()
  28605. }
  28606. ,
  28607. Ht.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
  28608. this.bindArrayBuffer(e),
  28609. void 0 === i && (i = 0);
  28610. var r = t.length || t.byteLength;
  28611. void 0 === n || n >= r && 0 === i ? t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, new Float32Array(t)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, t) : t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(t).subarray(i, i + n)) : (t = t instanceof ArrayBuffer ? new Uint8Array(t,i,n) : new Uint8Array(t.buffer,t.byteOffset + i,n),
  28612. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t)),
  28613. this._resetVertexBufferBinding()
  28614. }
  28615. ;
  28616. var vr = function(e) {
  28617. function t(i, n, r, o) {
  28618. void 0 === o && (o = !1);
  28619. var s = e.call(this, i, n, r, o) || this;
  28620. if (s.enableOfflineSupport = !1,
  28621. s.disableManifestCheck = !1,
  28622. s.scenes = new Array,
  28623. s._virtualScenes = new Array,
  28624. s.onNewSceneAddedObservable = new h,
  28625. s.postProcesses = new Array,
  28626. s.isPointerLock = !1,
  28627. s.onResizeObservable = new h,
  28628. s.onCanvasBlurObservable = new h,
  28629. s.onCanvasFocusObservable = new h,
  28630. s.onCanvasPointerOutObservable = new h,
  28631. s.onBeginFrameObservable = new h,
  28632. s.customAnimationFrameRequester = null,
  28633. s.onEndFrameObservable = new h,
  28634. s.onBeforeShaderCompilationObservable = new h,
  28635. s.onAfterShaderCompilationObservable = new h,
  28636. s._deterministicLockstep = !1,
  28637. s._lockstepMaxSteps = 4,
  28638. s._timeStep = 1 / 60,
  28639. s._fps = 60,
  28640. s._deltaTime = 0,
  28641. s._drawCalls = new un,
  28642. s.canvasTabIndex = 1,
  28643. s.disablePerformanceMonitorInBackground = !1,
  28644. s._performanceMonitor = new _r,
  28645. s._compatibilityMode = !0,
  28646. s.currentRenderPassId = a.RENDERPASS_MAIN,
  28647. s._renderPassNames = ["main"],
  28648. t.Instances.push(s),
  28649. !i)
  28650. return s;
  28651. if (s._features.supportRenderPasses = !0,
  28652. r = s._creationOptions,
  28653. i.getContext) {
  28654. var l = i;
  28655. if (s._sharedInit(l, !!r.doNotHandleTouchAction, r.audioEngine),
  28656. nt()) {
  28657. var c = document;
  28658. s._onFullscreenChange = function() {
  28659. void 0 !== c.fullscreen ? s.isFullscreen = c.fullscreen : void 0 !== c.mozFullScreen ? s.isFullscreen = c.mozFullScreen : void 0 !== c.webkitIsFullScreen ? s.isFullscreen = c.webkitIsFullScreen : void 0 !== c.msIsFullScreen && (s.isFullscreen = c.msIsFullScreen),
  28660. s.isFullscreen && s._pointerLockRequested && l && t._RequestPointerlock(l)
  28661. }
  28662. ,
  28663. document.addEventListener("fullscreenchange", s._onFullscreenChange, !1),
  28664. document.addEventListener("mozfullscreenchange", s._onFullscreenChange, !1),
  28665. document.addEventListener("webkitfullscreenchange", s._onFullscreenChange, !1),
  28666. document.addEventListener("msfullscreenchange", s._onFullscreenChange, !1),
  28667. s._onPointerLockChange = function() {
  28668. s.isPointerLock = c.mozPointerLockElement === l || c.webkitPointerLockElement === l || c.msPointerLockElement === l || c.pointerLockElement === l
  28669. }
  28670. ,
  28671. document.addEventListener("pointerlockchange", s._onPointerLockChange, !1),
  28672. document.addEventListener("mspointerlockchange", s._onPointerLockChange, !1),
  28673. document.addEventListener("mozpointerlockchange", s._onPointerLockChange, !1),
  28674. document.addEventListener("webkitpointerlockchange", s._onPointerLockChange, !1),
  28675. !t.audioEngine && r.audioEngine && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(s.getRenderingCanvas(), s.getAudioContext(), s.getAudioDestination()))
  28676. }
  28677. s._connectVREvents(),
  28678. s.enableOfflineSupport = void 0 !== t.OfflineProviderFactory,
  28679. s._deterministicLockstep = !!r.deterministicLockstep,
  28680. s._lockstepMaxSteps = r.lockstepMaxSteps || 0,
  28681. s._timeStep = r.timeStep || 1 / 60
  28682. }
  28683. return s._prepareVRComponent(),
  28684. r.autoEnableWebVR && s.initWebVR(),
  28685. s
  28686. }
  28687. return U(t, e),
  28688. Object.defineProperty(t, "NpmPackage", {
  28689. get: function() {
  28690. return Ht.NpmPackage
  28691. },
  28692. enumerable: !1,
  28693. configurable: !0
  28694. }),
  28695. Object.defineProperty(t, "Version", {
  28696. get: function() {
  28697. return Ht.Version
  28698. },
  28699. enumerable: !1,
  28700. configurable: !0
  28701. }),
  28702. Object.defineProperty(t, "Instances", {
  28703. get: function() {
  28704. return E.Instances
  28705. },
  28706. enumerable: !1,
  28707. configurable: !0
  28708. }),
  28709. Object.defineProperty(t, "LastCreatedEngine", {
  28710. get: function() {
  28711. return E.LastCreatedEngine
  28712. },
  28713. enumerable: !1,
  28714. configurable: !0
  28715. }),
  28716. Object.defineProperty(t, "LastCreatedScene", {
  28717. get: function() {
  28718. return E.LastCreatedScene
  28719. },
  28720. enumerable: !1,
  28721. configurable: !0
  28722. }),
  28723. t.prototype.createImageBitmapFromSource = function(e, t) {
  28724. var i = this;
  28725. return new Promise((function(n, r) {
  28726. var o = new Image;
  28727. o.onload = function() {
  28728. o.decode().then((function() {
  28729. i.createImageBitmap(o, t).then((function(e) {
  28730. n(e)
  28731. }
  28732. ))
  28733. }
  28734. ))
  28735. }
  28736. ,
  28737. o.onerror = function() {
  28738. r("Error loading image ".concat(o.src))
  28739. }
  28740. ,
  28741. o.src = e
  28742. }
  28743. ))
  28744. }
  28745. ,
  28746. t.prototype.createImageBitmap = function(e, t) {
  28747. return createImageBitmap(e, t)
  28748. }
  28749. ,
  28750. t.prototype.resizeImageBitmap = function(e, t, i) {
  28751. var n = this.createCanvas(t, i).getContext("2d");
  28752. if (!n)
  28753. throw new Error("Unable to get 2d context for resizeImageBitmap");
  28754. return n.drawImage(e, 0, 0),
  28755. n.getImageData(0, 0, t, i).data
  28756. }
  28757. ,
  28758. t.MarkAllMaterialsAsDirty = function(e, i) {
  28759. for (var n = 0; n < t.Instances.length; n++)
  28760. for (var r = t.Instances[n], o = 0; o < r.scenes.length; o++)
  28761. r.scenes[o].markAllMaterialsAsDirty(e, i)
  28762. }
  28763. ,
  28764. t.DefaultLoadingScreenFactory = function(e) {
  28765. throw be("LoadingScreen")
  28766. }
  28767. ,
  28768. Object.defineProperty(t.prototype, "_supportsHardwareTextureRescaling", {
  28769. get: function() {
  28770. return !!t._RescalePostProcessFactory
  28771. },
  28772. enumerable: !1,
  28773. configurable: !0
  28774. }),
  28775. Object.defineProperty(t.prototype, "performanceMonitor", {
  28776. get: function() {
  28777. return this._performanceMonitor
  28778. },
  28779. enumerable: !1,
  28780. configurable: !0
  28781. }),
  28782. Object.defineProperty(t.prototype, "compatibilityMode", {
  28783. get: function() {
  28784. return this._compatibilityMode
  28785. },
  28786. set: function(e) {
  28787. this._compatibilityMode = !0
  28788. },
  28789. enumerable: !1,
  28790. configurable: !0
  28791. }),
  28792. t.prototype.getInputElement = function() {
  28793. return this._renderingCanvas
  28794. }
  28795. ,
  28796. t.prototype._sharedInit = function(i, n, r) {
  28797. var o = this;
  28798. if (e.prototype._sharedInit.call(this, i, n, r),
  28799. this._onCanvasFocus = function() {
  28800. o.onCanvasFocusObservable.notifyObservers(o)
  28801. }
  28802. ,
  28803. this._onCanvasBlur = function() {
  28804. o.onCanvasBlurObservable.notifyObservers(o)
  28805. }
  28806. ,
  28807. i.addEventListener("focus", this._onCanvasFocus),
  28808. i.addEventListener("blur", this._onCanvasBlur),
  28809. this._onBlur = function() {
  28810. o.disablePerformanceMonitorInBackground && o._performanceMonitor.disable(),
  28811. o._windowIsBackground = !0
  28812. }
  28813. ,
  28814. this._onFocus = function() {
  28815. o.disablePerformanceMonitorInBackground && o._performanceMonitor.enable(),
  28816. o._windowIsBackground = !1
  28817. }
  28818. ,
  28819. this._onCanvasPointerOut = function(e) {
  28820. document.elementFromPoint(e.clientX, e.clientY) !== i && o.onCanvasPointerOutObservable.notifyObservers(e)
  28821. }
  28822. ,
  28823. nt()) {
  28824. var a = this.getHostWindow();
  28825. a && (a.addEventListener("blur", this._onBlur),
  28826. a.addEventListener("focus", this._onFocus))
  28827. }
  28828. i.addEventListener("pointerout", this._onCanvasPointerOut),
  28829. n || this._disableTouchAction(),
  28830. !t.audioEngine && r && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
  28831. }
  28832. ,
  28833. t.prototype.getAspectRatio = function(e, t) {
  28834. void 0 === t && (t = !1);
  28835. var i = e.viewport;
  28836. return this.getRenderWidth(t) * i.width / (this.getRenderHeight(t) * i.height)
  28837. }
  28838. ,
  28839. t.prototype.getScreenAspectRatio = function() {
  28840. return this.getRenderWidth(!0) / this.getRenderHeight(!0)
  28841. }
  28842. ,
  28843. t.prototype.getRenderingCanvasClientRect = function() {
  28844. return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null
  28845. }
  28846. ,
  28847. t.prototype.getInputElementClientRect = function() {
  28848. return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null
  28849. }
  28850. ,
  28851. t.prototype.isDeterministicLockStep = function() {
  28852. return this._deterministicLockstep
  28853. }
  28854. ,
  28855. t.prototype.getLockstepMaxSteps = function() {
  28856. return this._lockstepMaxSteps
  28857. }
  28858. ,
  28859. t.prototype.getTimeStep = function() {
  28860. return 1e3 * this._timeStep
  28861. }
  28862. ,
  28863. t.prototype.generateMipMapsForCubemap = function(e, t) {
  28864. if (void 0 === t && (t = !0),
  28865. e.generateMipMaps) {
  28866. var i = this._gl;
  28867. this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, e, !0),
  28868. i.generateMipmap(i.TEXTURE_CUBE_MAP),
  28869. t && this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null)
  28870. }
  28871. }
  28872. ,
  28873. t.prototype.getDepthBuffer = function() {
  28874. return this._depthCullingState.depthTest
  28875. }
  28876. ,
  28877. t.prototype.setDepthBuffer = function(e) {
  28878. this._depthCullingState.depthTest = e
  28879. }
  28880. ,
  28881. t.prototype.getDepthWrite = function() {
  28882. return this._depthCullingState.depthMask
  28883. }
  28884. ,
  28885. t.prototype.setDepthWrite = function(e) {
  28886. this._depthCullingState.depthMask = e
  28887. }
  28888. ,
  28889. t.prototype.getStencilBuffer = function() {
  28890. return this._stencilState.stencilTest
  28891. }
  28892. ,
  28893. t.prototype.setStencilBuffer = function(e) {
  28894. this._stencilState.stencilTest = e
  28895. }
  28896. ,
  28897. t.prototype.getStencilMask = function() {
  28898. return this._stencilState.stencilMask
  28899. }
  28900. ,
  28901. t.prototype.setStencilMask = function(e) {
  28902. this._stencilState.stencilMask = e
  28903. }
  28904. ,
  28905. t.prototype.getStencilFunction = function() {
  28906. return this._stencilState.stencilFunc
  28907. }
  28908. ,
  28909. t.prototype.getStencilFunctionReference = function() {
  28910. return this._stencilState.stencilFuncRef
  28911. }
  28912. ,
  28913. t.prototype.getStencilFunctionMask = function() {
  28914. return this._stencilState.stencilFuncMask
  28915. }
  28916. ,
  28917. t.prototype.setStencilFunction = function(e) {
  28918. this._stencilState.stencilFunc = e
  28919. }
  28920. ,
  28921. t.prototype.setStencilFunctionReference = function(e) {
  28922. this._stencilState.stencilFuncRef = e
  28923. }
  28924. ,
  28925. t.prototype.setStencilFunctionMask = function(e) {
  28926. this._stencilState.stencilFuncMask = e
  28927. }
  28928. ,
  28929. t.prototype.getStencilOperationFail = function() {
  28930. return this._stencilState.stencilOpStencilFail
  28931. }
  28932. ,
  28933. t.prototype.getStencilOperationDepthFail = function() {
  28934. return this._stencilState.stencilOpDepthFail
  28935. }
  28936. ,
  28937. t.prototype.getStencilOperationPass = function() {
  28938. return this._stencilState.stencilOpStencilDepthPass
  28939. }
  28940. ,
  28941. t.prototype.setStencilOperationFail = function(e) {
  28942. this._stencilState.stencilOpStencilFail = e
  28943. }
  28944. ,
  28945. t.prototype.setStencilOperationDepthFail = function(e) {
  28946. this._stencilState.stencilOpDepthFail = e
  28947. }
  28948. ,
  28949. t.prototype.setStencilOperationPass = function(e) {
  28950. this._stencilState.stencilOpStencilDepthPass = e
  28951. }
  28952. ,
  28953. t.prototype.setDitheringState = function(e) {
  28954. e ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER)
  28955. }
  28956. ,
  28957. t.prototype.setRasterizerState = function(e) {
  28958. e ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD)
  28959. }
  28960. ,
  28961. t.prototype.getDepthFunction = function() {
  28962. return this._depthCullingState.depthFunc
  28963. }
  28964. ,
  28965. t.prototype.setDepthFunction = function(e) {
  28966. this._depthCullingState.depthFunc = e
  28967. }
  28968. ,
  28969. t.prototype.setDepthFunctionToGreater = function() {
  28970. this.setDepthFunction(a.GREATER)
  28971. }
  28972. ,
  28973. t.prototype.setDepthFunctionToGreaterOrEqual = function() {
  28974. this.setDepthFunction(a.GEQUAL)
  28975. }
  28976. ,
  28977. t.prototype.setDepthFunctionToLess = function() {
  28978. this.setDepthFunction(a.LESS)
  28979. }
  28980. ,
  28981. t.prototype.setDepthFunctionToLessOrEqual = function() {
  28982. this.setDepthFunction(a.LEQUAL)
  28983. }
  28984. ,
  28985. t.prototype.cacheStencilState = function() {
  28986. this._cachedStencilBuffer = this.getStencilBuffer(),
  28987. this._cachedStencilFunction = this.getStencilFunction(),
  28988. this._cachedStencilMask = this.getStencilMask(),
  28989. this._cachedStencilOperationPass = this.getStencilOperationPass(),
  28990. this._cachedStencilOperationFail = this.getStencilOperationFail(),
  28991. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(),
  28992. this._cachedStencilReference = this.getStencilFunctionReference()
  28993. }
  28994. ,
  28995. t.prototype.restoreStencilState = function() {
  28996. this.setStencilFunction(this._cachedStencilFunction),
  28997. this.setStencilMask(this._cachedStencilMask),
  28998. this.setStencilBuffer(this._cachedStencilBuffer),
  28999. this.setStencilOperationPass(this._cachedStencilOperationPass),
  29000. this.setStencilOperationFail(this._cachedStencilOperationFail),
  29001. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),
  29002. this.setStencilFunctionReference(this._cachedStencilReference)
  29003. }
  29004. ,
  29005. t.prototype.setDirectViewport = function(e, t, i, n) {
  29006. var r = this._cachedViewport;
  29007. return this._cachedViewport = null,
  29008. this._viewport(e, t, i, n),
  29009. r
  29010. }
  29011. ,
  29012. t.prototype.scissorClear = function(e, t, i, n, r) {
  29013. this.enableScissor(e, t, i, n),
  29014. this.clear(r, !0, !0, !0),
  29015. this.disableScissor()
  29016. }
  29017. ,
  29018. t.prototype.enableScissor = function(e, t, i, n) {
  29019. var r = this._gl;
  29020. r.enable(r.SCISSOR_TEST),
  29021. r.scissor(e, t, i, n)
  29022. }
  29023. ,
  29024. t.prototype.disableScissor = function() {
  29025. var e = this._gl;
  29026. e.disable(e.SCISSOR_TEST)
  29027. }
  29028. ,
  29029. t.prototype._reportDrawCall = function(e) {
  29030. void 0 === e && (e = 1),
  29031. this._drawCalls.addCount(e, !1)
  29032. }
  29033. ,
  29034. t.prototype.initWebVR = function() {
  29035. throw be("WebVRCamera")
  29036. }
  29037. ,
  29038. t.prototype._prepareVRComponent = function() {}
  29039. ,
  29040. t.prototype._connectVREvents = function(e, t) {}
  29041. ,
  29042. t.prototype._submitVRFrame = function() {}
  29043. ,
  29044. t.prototype.disableVR = function() {}
  29045. ,
  29046. t.prototype.isVRPresenting = function() {
  29047. return !1
  29048. }
  29049. ,
  29050. t.prototype._requestVRFrame = function() {}
  29051. ,
  29052. t.prototype._loadFileAsync = function(e, t, i) {
  29053. var n = this;
  29054. return new Promise((function(r, o) {
  29055. n._loadFile(e, (function(e) {
  29056. r(e)
  29057. }
  29058. ), void 0, t, i, (function(e, t) {
  29059. o(t)
  29060. }
  29061. ))
  29062. }
  29063. ))
  29064. }
  29065. ,
  29066. t.prototype.getVertexShaderSource = function(e) {
  29067. var t = this._gl.getAttachedShaders(e);
  29068. return t ? this._gl.getShaderSource(t[0]) : null
  29069. }
  29070. ,
  29071. t.prototype.getFragmentShaderSource = function(e) {
  29072. var t = this._gl.getAttachedShaders(e);
  29073. return t ? this._gl.getShaderSource(t[1]) : null
  29074. }
  29075. ,
  29076. t.prototype.setDepthStencilTexture = function(e, t, i, n) {
  29077. void 0 !== e && (t && (this._boundUniforms[e] = t),
  29078. i && i.depthStencilTexture ? this._setTexture(e, i, !1, !0, n) : this._setTexture(e, null, void 0, void 0, n))
  29079. }
  29080. ,
  29081. t.prototype.setTextureFromPostProcess = function(e, t, i) {
  29082. var n, r = null;
  29083. t && (t._textures.data[t._currentRenderTextureInd] ? r = t._textures.data[t._currentRenderTextureInd] : t._forcedOutputTexture && (r = t._forcedOutputTexture)),
  29084. this._bindTexture(e, null !== (n = null == r ? void 0 : r.texture) && void 0 !== n ? n : null, i)
  29085. }
  29086. ,
  29087. t.prototype.setTextureFromPostProcessOutput = function(e, t, i) {
  29088. var n, r;
  29089. this._bindTexture(e, null !== (r = null === (n = null == t ? void 0 : t._outputTexture) || void 0 === n ? void 0 : n.texture) && void 0 !== r ? r : null, i)
  29090. }
  29091. ,
  29092. t.prototype._rebuildBuffers = function() {
  29093. for (var t = 0, i = this.scenes; t < i.length; t++)
  29094. (o = i[t]).resetCachedMaterial(),
  29095. o._rebuildGeometries(),
  29096. o._rebuildTextures();
  29097. for (var n = 0, r = this._virtualScenes; n < r.length; n++) {
  29098. var o;
  29099. (o = r[n]).resetCachedMaterial(),
  29100. o._rebuildGeometries(),
  29101. o._rebuildTextures()
  29102. }
  29103. e.prototype._rebuildBuffers.call(this)
  29104. }
  29105. ,
  29106. t.prototype._renderFrame = function() {
  29107. for (var e = 0; e < this._activeRenderLoops.length; e++)
  29108. (0,
  29109. this._activeRenderLoops[e])()
  29110. }
  29111. ,
  29112. t.prototype._renderLoop = function() {
  29113. if (!this._contextWasLost) {
  29114. var e = !0;
  29115. !this.renderEvenInBackground && this._windowIsBackground && (e = !1),
  29116. e && (this.beginFrame(),
  29117. this._renderViews() || this._renderFrame(),
  29118. this.endFrame())
  29119. }
  29120. this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester),
  29121. this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
  29122. }
  29123. ,
  29124. t.prototype._renderViews = function() {
  29125. return !1
  29126. }
  29127. ,
  29128. t.prototype.switchFullscreen = function(e) {
  29129. this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(e)
  29130. }
  29131. ,
  29132. t.prototype.enterFullscreen = function(e) {
  29133. this.isFullscreen || (this._pointerLockRequested = e,
  29134. this._renderingCanvas && t._RequestFullscreen(this._renderingCanvas))
  29135. }
  29136. ,
  29137. t.prototype.exitFullscreen = function() {
  29138. this.isFullscreen && t._ExitFullscreen()
  29139. }
  29140. ,
  29141. t.prototype.enterPointerlock = function() {
  29142. this._renderingCanvas && t._RequestPointerlock(this._renderingCanvas)
  29143. }
  29144. ,
  29145. t.prototype.exitPointerlock = function() {
  29146. t._ExitPointerlock()
  29147. }
  29148. ,
  29149. t.prototype.beginFrame = function() {
  29150. this._measureFps(),
  29151. this.onBeginFrameObservable.notifyObservers(this),
  29152. e.prototype.beginFrame.call(this)
  29153. }
  29154. ,
  29155. t.prototype.endFrame = function() {
  29156. e.prototype.endFrame.call(this),
  29157. this._submitVRFrame(),
  29158. this.onEndFrameObservable.notifyObservers(this)
  29159. }
  29160. ,
  29161. t.prototype.resize = function(t) {
  29162. void 0 === t && (t = !1),
  29163. this.isVRPresenting() || e.prototype.resize.call(this, t)
  29164. }
  29165. ,
  29166. t.prototype.setSize = function(t, i, n) {
  29167. if (void 0 === n && (n = !1),
  29168. !this._renderingCanvas)
  29169. return !1;
  29170. if (!e.prototype.setSize.call(this, t, i, n))
  29171. return !1;
  29172. if (this.scenes) {
  29173. for (var r = 0; r < this.scenes.length; r++)
  29174. for (var o = this.scenes[r], a = 0; a < o.cameras.length; a++)
  29175. o.cameras[a]._currentRenderId = 0;
  29176. this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this)
  29177. }
  29178. return !0
  29179. }
  29180. ,
  29181. t.prototype._deletePipelineContext = function(t) {
  29182. var i = t;
  29183. i && i.program && i.transformFeedback && (this.deleteTransformFeedback(i.transformFeedback),
  29184. i.transformFeedback = null),
  29185. e.prototype._deletePipelineContext.call(this, t)
  29186. }
  29187. ,
  29188. t.prototype.createShaderProgram = function(t, i, n, r, o, a) {
  29189. void 0 === a && (a = null),
  29190. o = o || this._gl,
  29191. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29192. var s = e.prototype.createShaderProgram.call(this, t, i, n, r, o, a);
  29193. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  29194. s
  29195. }
  29196. ,
  29197. t.prototype._createShaderProgram = function(e, t, i, n, r) {
  29198. void 0 === r && (r = null);
  29199. var o = n.createProgram();
  29200. if (e.program = o,
  29201. !o)
  29202. throw new Error("Unable to create program");
  29203. if (n.attachShader(o, t),
  29204. n.attachShader(o, i),
  29205. this.webGLVersion > 1 && r) {
  29206. var a = this.createTransformFeedback();
  29207. this.bindTransformFeedback(a),
  29208. this.setTranformFeedbackVaryings(o, r),
  29209. e.transformFeedback = a
  29210. }
  29211. return n.linkProgram(o),
  29212. this.webGLVersion > 1 && r && this.bindTransformFeedback(null),
  29213. e.context = n,
  29214. e.vertexShader = t,
  29215. e.fragmentShader = i,
  29216. e.isParallelCompiled || this._finalizePipelineContext(e),
  29217. o
  29218. }
  29219. ,
  29220. t.prototype._releaseTexture = function(t) {
  29221. e.prototype._releaseTexture.call(this, t)
  29222. }
  29223. ,
  29224. t.prototype._releaseRenderTargetWrapper = function(t) {
  29225. e.prototype._releaseRenderTargetWrapper.call(this, t),
  29226. this.scenes.forEach((function(e) {
  29227. e.postProcesses.forEach((function(e) {
  29228. e._outputTexture === t && (e._outputTexture = null)
  29229. }
  29230. )),
  29231. e.cameras.forEach((function(e) {
  29232. e._postProcesses.forEach((function(e) {
  29233. e && e._outputTexture === t && (e._outputTexture = null)
  29234. }
  29235. ))
  29236. }
  29237. ))
  29238. }
  29239. ))
  29240. }
  29241. ,
  29242. t.prototype.getRenderPassNames = function() {
  29243. return this._renderPassNames
  29244. }
  29245. ,
  29246. t.prototype.getCurrentRenderPassName = function() {
  29247. return this._renderPassNames[this.currentRenderPassId]
  29248. }
  29249. ,
  29250. t.prototype.createRenderPassId = function(e) {
  29251. var i = ++t._RenderPassIdCounter;
  29252. return this._renderPassNames[i] = null != e ? e : "NONAME",
  29253. i
  29254. }
  29255. ,
  29256. t.prototype.releaseRenderPassId = function(e) {
  29257. this._renderPassNames[e] = void 0;
  29258. for (var t = 0; t < this.scenes.length; ++t)
  29259. for (var i = this.scenes[t], n = 0; n < i.meshes.length; ++n) {
  29260. var r = i.meshes[n];
  29261. if (r.subMeshes)
  29262. for (var o = 0; o < r.subMeshes.length; ++o)
  29263. r.subMeshes[o]._removeDrawWrapper(e)
  29264. }
  29265. }
  29266. ,
  29267. t.prototype._rescaleTexture = function(e, i, n, r, o) {
  29268. var s = this;
  29269. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR),
  29270. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR),
  29271. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE),
  29272. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
  29273. var l = this.createRenderTargetTexture({
  29274. width: i.width,
  29275. height: i.height
  29276. }, {
  29277. generateMipMaps: !1,
  29278. type: a.TEXTURETYPE_UNSIGNED_INT,
  29279. samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE,
  29280. generateDepthBuffer: !1,
  29281. generateStencilBuffer: !1
  29282. });
  29283. !this._rescalePostProcess && t._RescalePostProcessFactory && (this._rescalePostProcess = t._RescalePostProcessFactory(this)),
  29284. this._rescalePostProcess.externalTextureSamplerBinding = !0,
  29285. this._rescalePostProcess.getEffect().executeWhenCompiled((function() {
  29286. s._rescalePostProcess.onApply = function(t) {
  29287. t._bindTexture("textureSampler", e)
  29288. }
  29289. ;
  29290. var t = n;
  29291. t || (t = s.scenes[s.scenes.length - 1]),
  29292. t.postProcessManager.directRender([s._rescalePostProcess], l, !0),
  29293. s._bindTextureDirectly(s._gl.TEXTURE_2D, i, !0),
  29294. s._gl.copyTexImage2D(s._gl.TEXTURE_2D, 0, r, 0, 0, i.width, i.height, 0),
  29295. s.unBindFramebuffer(l),
  29296. l.dispose(),
  29297. o && o()
  29298. }
  29299. ))
  29300. }
  29301. ,
  29302. t.prototype.getFps = function() {
  29303. return this._fps
  29304. }
  29305. ,
  29306. t.prototype.getDeltaTime = function() {
  29307. return this._deltaTime
  29308. }
  29309. ,
  29310. t.prototype._measureFps = function() {
  29311. this._performanceMonitor.sampleFrame(),
  29312. this._fps = this._performanceMonitor.averageFPS,
  29313. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0
  29314. }
  29315. ,
  29316. t.prototype._uploadImageToTexture = function(e, t, i, n) {
  29317. void 0 === i && (i = 0),
  29318. void 0 === n && (n = 0);
  29319. var r = this._gl
  29320. , o = this._getWebGLTextureType(e.type)
  29321. , a = this._getInternalFormat(e.format)
  29322. , s = this._getRGBABufferInternalSizedFormat(e.type, a)
  29323. , l = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
  29324. this._bindTextureDirectly(l, e, !0),
  29325. this._unpackFlipY(e.invertY);
  29326. var c = r.TEXTURE_2D;
  29327. e.isCube && (c = r.TEXTURE_CUBE_MAP_POSITIVE_X + i),
  29328. r.texImage2D(c, n, s, a, o, t),
  29329. this._bindTextureDirectly(l, null, !0)
  29330. }
  29331. ,
  29332. t.prototype.updateTextureComparisonFunction = function(e, t) {
  29333. if (1 !== this.webGLVersion) {
  29334. var i = this._gl;
  29335. e.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, e, !0),
  29336. 0 === t ? (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, a.LEQUAL),
  29337. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, t),
  29338. i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)),
  29339. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
  29340. 0 === t ? (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, a.LEQUAL),
  29341. i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, t),
  29342. i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)),
  29343. this._bindTextureDirectly(this._gl.TEXTURE_2D, null)),
  29344. e._comparisonFunction = t
  29345. } else
  29346. K.Error("WebGL 1 does not support texture comparison.")
  29347. }
  29348. ,
  29349. t.prototype.createInstancesBuffer = function(e) {
  29350. var t = this._gl.createBuffer();
  29351. if (!t)
  29352. throw new Error("Unable to create instance buffer");
  29353. var i = new Ut(t);
  29354. return i.capacity = e,
  29355. this.bindArrayBuffer(i),
  29356. this._gl.bufferData(this._gl.ARRAY_BUFFER, e, this._gl.DYNAMIC_DRAW),
  29357. i.references = 1,
  29358. i
  29359. }
  29360. ,
  29361. t.prototype.deleteInstancesBuffer = function(e) {
  29362. this._gl.deleteBuffer(e)
  29363. }
  29364. ,
  29365. t.prototype._clientWaitAsync = function(e, t, i) {
  29366. void 0 === t && (t = 0),
  29367. void 0 === i && (i = 10);
  29368. var n = this._gl;
  29369. return new Promise((function(r, o) {
  29370. var a = function() {
  29371. var s = n.clientWaitSync(e, t, 0);
  29372. s != n.WAIT_FAILED ? s != n.TIMEOUT_EXPIRED ? r() : setTimeout(a, i) : o()
  29373. };
  29374. a()
  29375. }
  29376. ))
  29377. }
  29378. ,
  29379. t.prototype._readPixelsAsync = function(e, t, i, n, r, o, a) {
  29380. if (this._webGLVersion < 2)
  29381. throw new Error("_readPixelsAsync only work on WebGL2+");
  29382. var s = this._gl
  29383. , l = s.createBuffer();
  29384. s.bindBuffer(s.PIXEL_PACK_BUFFER, l),
  29385. s.bufferData(s.PIXEL_PACK_BUFFER, a.byteLength, s.STREAM_READ),
  29386. s.readPixels(e, t, i, n, r, o, 0),
  29387. s.bindBuffer(s.PIXEL_PACK_BUFFER, null);
  29388. var c = s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE, 0);
  29389. return c ? (s.flush(),
  29390. this._clientWaitAsync(c, 0, 10).then((function() {
  29391. return s.deleteSync(c),
  29392. s.bindBuffer(s.PIXEL_PACK_BUFFER, l),
  29393. s.getBufferSubData(s.PIXEL_PACK_BUFFER, 0, a),
  29394. s.bindBuffer(s.PIXEL_PACK_BUFFER, null),
  29395. s.deleteBuffer(l),
  29396. a
  29397. }
  29398. ))) : null
  29399. }
  29400. ,
  29401. t.prototype.dispose = function() {
  29402. for (this.hideLoadingUI(),
  29403. this.onNewSceneAddedObservable.clear(); this.postProcesses.length; )
  29404. this.postProcesses[0].dispose();
  29405. for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length; )
  29406. this.scenes[0].dispose();
  29407. for (; this._virtualScenes.length; )
  29408. this._virtualScenes[0].dispose();
  29409. 1 === t.Instances.length && t.audioEngine && (t.audioEngine.dispose(),
  29410. t.audioEngine = null),
  29411. this.disableVR(),
  29412. nt() && (window.removeEventListener("blur", this._onBlur),
  29413. window.removeEventListener("focus", this._onFocus),
  29414. this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus),
  29415. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur),
  29416. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut)),
  29417. ot() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange),
  29418. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
  29419. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
  29420. document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
  29421. document.removeEventListener("pointerlockchange", this._onPointerLockChange),
  29422. document.removeEventListener("mspointerlockchange", this._onPointerLockChange),
  29423. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange),
  29424. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange))),
  29425. e.prototype.dispose.call(this);
  29426. var i = t.Instances.indexOf(this);
  29427. i >= 0 && t.Instances.splice(i, 1),
  29428. this.onResizeObservable.clear(),
  29429. this.onCanvasBlurObservable.clear(),
  29430. this.onCanvasFocusObservable.clear(),
  29431. this.onCanvasPointerOutObservable.clear(),
  29432. this.onBeginFrameObservable.clear(),
  29433. this.onEndFrameObservable.clear()
  29434. }
  29435. ,
  29436. t.prototype._disableTouchAction = function() {
  29437. this._renderingCanvas && this._renderingCanvas.setAttribute && (this._renderingCanvas.setAttribute("touch-action", "none"),
  29438. this._renderingCanvas.style.touchAction = "none",
  29439. this._renderingCanvas.style.msTouchAction = "none")
  29440. }
  29441. ,
  29442. t.prototype.displayLoadingUI = function() {
  29443. if (nt()) {
  29444. var e = this.loadingScreen;
  29445. e && e.displayLoadingUI()
  29446. }
  29447. }
  29448. ,
  29449. t.prototype.hideLoadingUI = function() {
  29450. if (nt()) {
  29451. var e = this._loadingScreen;
  29452. e && e.hideLoadingUI()
  29453. }
  29454. }
  29455. ,
  29456. Object.defineProperty(t.prototype, "loadingScreen", {
  29457. get: function() {
  29458. return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = t.DefaultLoadingScreenFactory(this._renderingCanvas)),
  29459. this._loadingScreen
  29460. },
  29461. set: function(e) {
  29462. this._loadingScreen = e
  29463. },
  29464. enumerable: !1,
  29465. configurable: !0
  29466. }),
  29467. Object.defineProperty(t.prototype, "loadingUIText", {
  29468. set: function(e) {
  29469. this.loadingScreen.loadingUIText = e
  29470. },
  29471. enumerable: !1,
  29472. configurable: !0
  29473. }),
  29474. Object.defineProperty(t.prototype, "loadingUIBackgroundColor", {
  29475. set: function(e) {
  29476. this.loadingScreen.loadingUIBackgroundColor = e
  29477. },
  29478. enumerable: !1,
  29479. configurable: !0
  29480. }),
  29481. t.prototype.createVideoElement = function(e) {
  29482. return document.createElement("video")
  29483. }
  29484. ,
  29485. t._RequestPointerlock = function(e) {
  29486. e.requestPointerLock = e.requestPointerLock || e.msRequestPointerLock || e.mozRequestPointerLock || e.webkitRequestPointerLock,
  29487. e.requestPointerLock && e.requestPointerLock()
  29488. }
  29489. ,
  29490. t._ExitPointerlock = function() {
  29491. var e = document;
  29492. document.exitPointerLock = document.exitPointerLock || e.msExitPointerLock || e.mozExitPointerLock || e.webkitExitPointerLock,
  29493. document.exitPointerLock && document.exitPointerLock()
  29494. }
  29495. ,
  29496. t._RequestFullscreen = function(e) {
  29497. var t = e.requestFullscreen || e.msRequestFullscreen || e.webkitRequestFullscreen || e.mozRequestFullScreen;
  29498. t && t.call(e)
  29499. }
  29500. ,
  29501. t._ExitFullscreen = function() {
  29502. var e = document;
  29503. document.exitFullscreen ? document.exitFullscreen() : e.mozCancelFullScreen ? e.mozCancelFullScreen() : e.webkitCancelFullScreen ? e.webkitCancelFullScreen() : e.msCancelFullScreen && e.msCancelFullScreen()
  29504. }
  29505. ,
  29506. t.prototype.getFontOffset = function(e) {
  29507. var t = document.createElement("span");
  29508. t.innerHTML = "Hg",
  29509. t.setAttribute("style", "font: ".concat(e, " !important"));
  29510. var i = document.createElement("div");
  29511. i.style.display = "inline-block",
  29512. i.style.width = "1px",
  29513. i.style.height = "0px",
  29514. i.style.verticalAlign = "bottom";
  29515. var n = document.createElement("div");
  29516. n.style.whiteSpace = "nowrap",
  29517. n.appendChild(t),
  29518. n.appendChild(i),
  29519. document.body.appendChild(n);
  29520. var r = 0
  29521. , o = 0;
  29522. try {
  29523. o = i.getBoundingClientRect().top - t.getBoundingClientRect().top,
  29524. i.style.verticalAlign = "baseline",
  29525. r = i.getBoundingClientRect().top - t.getBoundingClientRect().top
  29526. } finally {
  29527. document.body.removeChild(n)
  29528. }
  29529. return {
  29530. ascent: r,
  29531. height: o,
  29532. descent: o - r
  29533. }
  29534. }
  29535. ,
  29536. t.ALPHA_DISABLE = a.ALPHA_DISABLE,
  29537. t.ALPHA_ADD = a.ALPHA_ADD,
  29538. t.ALPHA_COMBINE = a.ALPHA_COMBINE,
  29539. t.ALPHA_SUBTRACT = a.ALPHA_SUBTRACT,
  29540. t.ALPHA_MULTIPLY = a.ALPHA_MULTIPLY,
  29541. t.ALPHA_MAXIMIZED = a.ALPHA_MAXIMIZED,
  29542. t.ALPHA_ONEONE = a.ALPHA_ONEONE,
  29543. t.ALPHA_PREMULTIPLIED = a.ALPHA_PREMULTIPLIED,
  29544. t.ALPHA_PREMULTIPLIED_PORTERDUFF = a.ALPHA_PREMULTIPLIED_PORTERDUFF,
  29545. t.ALPHA_INTERPOLATE = a.ALPHA_INTERPOLATE,
  29546. t.ALPHA_SCREENMODE = a.ALPHA_SCREENMODE,
  29547. t.DELAYLOADSTATE_NONE = a.DELAYLOADSTATE_NONE,
  29548. t.DELAYLOADSTATE_LOADED = a.DELAYLOADSTATE_LOADED,
  29549. t.DELAYLOADSTATE_LOADING = a.DELAYLOADSTATE_LOADING,
  29550. t.DELAYLOADSTATE_NOTLOADED = a.DELAYLOADSTATE_NOTLOADED,
  29551. t.NEVER = a.NEVER,
  29552. t.ALWAYS = a.ALWAYS,
  29553. t.LESS = a.LESS,
  29554. t.EQUAL = a.EQUAL,
  29555. t.LEQUAL = a.LEQUAL,
  29556. t.GREATER = a.GREATER,
  29557. t.GEQUAL = a.GEQUAL,
  29558. t.NOTEQUAL = a.NOTEQUAL,
  29559. t.KEEP = a.KEEP,
  29560. t.REPLACE = a.REPLACE,
  29561. t.INCR = a.INCR,
  29562. t.DECR = a.DECR,
  29563. t.INVERT = a.INVERT,
  29564. t.INCR_WRAP = a.INCR_WRAP,
  29565. t.DECR_WRAP = a.DECR_WRAP,
  29566. t.TEXTURE_CLAMP_ADDRESSMODE = a.TEXTURE_CLAMP_ADDRESSMODE,
  29567. t.TEXTURE_WRAP_ADDRESSMODE = a.TEXTURE_WRAP_ADDRESSMODE,
  29568. t.TEXTURE_MIRROR_ADDRESSMODE = a.TEXTURE_MIRROR_ADDRESSMODE,
  29569. t.TEXTUREFORMAT_ALPHA = a.TEXTUREFORMAT_ALPHA,
  29570. t.TEXTUREFORMAT_LUMINANCE = a.TEXTUREFORMAT_LUMINANCE,
  29571. t.TEXTUREFORMAT_LUMINANCE_ALPHA = a.TEXTUREFORMAT_LUMINANCE_ALPHA,
  29572. t.TEXTUREFORMAT_RGB = a.TEXTUREFORMAT_RGB,
  29573. t.TEXTUREFORMAT_RGBA = a.TEXTUREFORMAT_RGBA,
  29574. t.TEXTUREFORMAT_RED = a.TEXTUREFORMAT_RED,
  29575. t.TEXTUREFORMAT_R = a.TEXTUREFORMAT_R,
  29576. t.TEXTUREFORMAT_RG = a.TEXTUREFORMAT_RG,
  29577. t.TEXTUREFORMAT_RED_INTEGER = a.TEXTUREFORMAT_RED_INTEGER,
  29578. t.TEXTUREFORMAT_R_INTEGER = a.TEXTUREFORMAT_R_INTEGER,
  29579. t.TEXTUREFORMAT_RG_INTEGER = a.TEXTUREFORMAT_RG_INTEGER,
  29580. t.TEXTUREFORMAT_RGB_INTEGER = a.TEXTUREFORMAT_RGB_INTEGER,
  29581. t.TEXTUREFORMAT_RGBA_INTEGER = a.TEXTUREFORMAT_RGBA_INTEGER,
  29582. t.TEXTURETYPE_UNSIGNED_BYTE = a.TEXTURETYPE_UNSIGNED_BYTE,
  29583. t.TEXTURETYPE_UNSIGNED_INT = a.TEXTURETYPE_UNSIGNED_INT,
  29584. t.TEXTURETYPE_FLOAT = a.TEXTURETYPE_FLOAT,
  29585. t.TEXTURETYPE_HALF_FLOAT = a.TEXTURETYPE_HALF_FLOAT,
  29586. t.TEXTURETYPE_BYTE = a.TEXTURETYPE_BYTE,
  29587. t.TEXTURETYPE_SHORT = a.TEXTURETYPE_SHORT,
  29588. t.TEXTURETYPE_UNSIGNED_SHORT = a.TEXTURETYPE_UNSIGNED_SHORT,
  29589. t.TEXTURETYPE_INT = a.TEXTURETYPE_INT,
  29590. t.TEXTURETYPE_UNSIGNED_INTEGER = a.TEXTURETYPE_UNSIGNED_INTEGER,
  29591. t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,
  29592. t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,
  29593. t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
  29594. t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,
  29595. t.TEXTURETYPE_UNSIGNED_INT_24_8 = a.TEXTURETYPE_UNSIGNED_INT_24_8,
  29596. t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,
  29597. t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,
  29598. t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,
  29599. t.TEXTURE_NEAREST_SAMPLINGMODE = a.TEXTURE_NEAREST_SAMPLINGMODE,
  29600. t.TEXTURE_BILINEAR_SAMPLINGMODE = a.TEXTURE_BILINEAR_SAMPLINGMODE,
  29601. t.TEXTURE_TRILINEAR_SAMPLINGMODE = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  29602. t.TEXTURE_NEAREST_NEAREST_MIPLINEAR = a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,
  29603. t.TEXTURE_LINEAR_LINEAR_MIPNEAREST = a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,
  29604. t.TEXTURE_LINEAR_LINEAR_MIPLINEAR = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
  29605. t.TEXTURE_NEAREST_NEAREST_MIPNEAREST = a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,
  29606. t.TEXTURE_NEAREST_LINEAR_MIPNEAREST = a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,
  29607. t.TEXTURE_NEAREST_LINEAR_MIPLINEAR = a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,
  29608. t.TEXTURE_NEAREST_LINEAR = a.TEXTURE_NEAREST_LINEAR,
  29609. t.TEXTURE_NEAREST_NEAREST = a.TEXTURE_NEAREST_NEAREST,
  29610. t.TEXTURE_LINEAR_NEAREST_MIPNEAREST = a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,
  29611. t.TEXTURE_LINEAR_NEAREST_MIPLINEAR = a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,
  29612. t.TEXTURE_LINEAR_LINEAR = a.TEXTURE_LINEAR_LINEAR,
  29613. t.TEXTURE_LINEAR_NEAREST = a.TEXTURE_LINEAR_NEAREST,
  29614. t.TEXTURE_EXPLICIT_MODE = a.TEXTURE_EXPLICIT_MODE,
  29615. t.TEXTURE_SPHERICAL_MODE = a.TEXTURE_SPHERICAL_MODE,
  29616. t.TEXTURE_PLANAR_MODE = a.TEXTURE_PLANAR_MODE,
  29617. t.TEXTURE_CUBIC_MODE = a.TEXTURE_CUBIC_MODE,
  29618. t.TEXTURE_PROJECTION_MODE = a.TEXTURE_PROJECTION_MODE,
  29619. t.TEXTURE_SKYBOX_MODE = a.TEXTURE_SKYBOX_MODE,
  29620. t.TEXTURE_INVCUBIC_MODE = a.TEXTURE_INVCUBIC_MODE,
  29621. t.TEXTURE_EQUIRECTANGULAR_MODE = a.TEXTURE_EQUIRECTANGULAR_MODE,
  29622. t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,
  29623. t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
  29624. t.SCALEMODE_FLOOR = a.SCALEMODE_FLOOR,
  29625. t.SCALEMODE_NEAREST = a.SCALEMODE_NEAREST,
  29626. t.SCALEMODE_CEILING = a.SCALEMODE_CEILING,
  29627. t._RescalePostProcessFactory = null,
  29628. t._RenderPassIdCounter = 0,
  29629. t
  29630. }(Ht)
  29631. , yr = function(e) {
  29632. function t(i, n, r) {
  29633. void 0 === n && (n = null),
  29634. void 0 === r && (r = !0);
  29635. var o = e.call(this, i, n) || this;
  29636. return o._forward = new x(0,0,1),
  29637. o._up = new x(0,1,0),
  29638. o._right = new x(1,0,0),
  29639. o._position = x.Zero(),
  29640. o._rotation = x.Zero(),
  29641. o._rotationQuaternion = null,
  29642. o._scaling = x.One(),
  29643. o._transformToBoneReferal = null,
  29644. o._isAbsoluteSynced = !1,
  29645. o._billboardMode = t.BILLBOARDMODE_NONE,
  29646. o._preserveParentRotationForBillboard = !1,
  29647. o.scalingDeterminant = 1,
  29648. o._infiniteDistance = !1,
  29649. o.ignoreNonUniformScaling = !1,
  29650. o.reIntegrateRotationIntoRotationQuaternion = !1,
  29651. o._poseMatrix = null,
  29652. o._localMatrix = P.Zero(),
  29653. o._usePivotMatrix = !1,
  29654. o._absolutePosition = x.Zero(),
  29655. o._absoluteScaling = x.Zero(),
  29656. o._absoluteRotationQuaternion = C.Identity(),
  29657. o._pivotMatrix = P.Identity(),
  29658. o._postMultiplyPivotMatrix = !1,
  29659. o._isWorldMatrixFrozen = !1,
  29660. o._indexInSceneTransformNodesArray = -1,
  29661. o.onAfterWorldMatrixUpdateObservable = new h,
  29662. o._nonUniformScaling = !1,
  29663. r && o.getScene().addTransformNode(o),
  29664. o
  29665. }
  29666. return U(t, e),
  29667. Object.defineProperty(t.prototype, "billboardMode", {
  29668. get: function() {
  29669. return this._billboardMode
  29670. },
  29671. set: function(e) {
  29672. this._billboardMode !== e && (this._billboardMode = e)
  29673. },
  29674. enumerable: !1,
  29675. configurable: !0
  29676. }),
  29677. Object.defineProperty(t.prototype, "preserveParentRotationForBillboard", {
  29678. get: function() {
  29679. return this._preserveParentRotationForBillboard
  29680. },
  29681. set: function(e) {
  29682. e !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = e)
  29683. },
  29684. enumerable: !1,
  29685. configurable: !0
  29686. }),
  29687. Object.defineProperty(t.prototype, "infiniteDistance", {
  29688. get: function() {
  29689. return this._infiniteDistance
  29690. },
  29691. set: function(e) {
  29692. this._infiniteDistance !== e && (this._infiniteDistance = e)
  29693. },
  29694. enumerable: !1,
  29695. configurable: !0
  29696. }),
  29697. t.prototype.getClassName = function() {
  29698. return "TransformNode"
  29699. }
  29700. ,
  29701. Object.defineProperty(t.prototype, "position", {
  29702. get: function() {
  29703. return this._position
  29704. },
  29705. set: function(e) {
  29706. this._position = e,
  29707. this._isDirty = !0
  29708. },
  29709. enumerable: !1,
  29710. configurable: !0
  29711. }),
  29712. t.prototype.isUsingPivotMatrix = function() {
  29713. return this._usePivotMatrix
  29714. }
  29715. ,
  29716. Object.defineProperty(t.prototype, "rotation", {
  29717. get: function() {
  29718. return this._rotation
  29719. },
  29720. set: function(e) {
  29721. this._rotation = e,
  29722. this._rotationQuaternion = null,
  29723. this._isDirty = !0
  29724. },
  29725. enumerable: !1,
  29726. configurable: !0
  29727. }),
  29728. Object.defineProperty(t.prototype, "scaling", {
  29729. get: function() {
  29730. return this._scaling
  29731. },
  29732. set: function(e) {
  29733. this._scaling = e,
  29734. this._isDirty = !0
  29735. },
  29736. enumerable: !1,
  29737. configurable: !0
  29738. }),
  29739. Object.defineProperty(t.prototype, "rotationQuaternion", {
  29740. get: function() {
  29741. return this._rotationQuaternion
  29742. },
  29743. set: function(e) {
  29744. this._rotationQuaternion = e,
  29745. e && this._rotation.setAll(0),
  29746. this._isDirty = !0
  29747. },
  29748. enumerable: !1,
  29749. configurable: !0
  29750. }),
  29751. Object.defineProperty(t.prototype, "forward", {
  29752. get: function() {
  29753. return x.TransformNormalFromFloatsToRef(0, 0, this.getScene().useRightHandedSystem ? -1 : 1, this.getWorldMatrix(), this._forward),
  29754. this._forward.normalize()
  29755. },
  29756. enumerable: !1,
  29757. configurable: !0
  29758. }),
  29759. Object.defineProperty(t.prototype, "up", {
  29760. get: function() {
  29761. return x.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up),
  29762. this._up.normalize()
  29763. },
  29764. enumerable: !1,
  29765. configurable: !0
  29766. }),
  29767. Object.defineProperty(t.prototype, "right", {
  29768. get: function() {
  29769. return x.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem ? -1 : 1, 0, 0, this.getWorldMatrix(), this._right),
  29770. this._right.normalize()
  29771. },
  29772. enumerable: !1,
  29773. configurable: !0
  29774. }),
  29775. t.prototype.updatePoseMatrix = function(e) {
  29776. return this._poseMatrix ? (this._poseMatrix.copyFrom(e),
  29777. this) : (this._poseMatrix = e.clone(),
  29778. this)
  29779. }
  29780. ,
  29781. t.prototype.getPoseMatrix = function() {
  29782. return this._poseMatrix || (this._poseMatrix = P.Identity()),
  29783. this._poseMatrix
  29784. }
  29785. ,
  29786. t.prototype._isSynchronized = function() {
  29787. var e = this._cache;
  29788. return !(this.billboardMode !== e.billboardMode || this.billboardMode !== t.BILLBOARDMODE_NONE || e.pivotMatrixUpdated || this.infiniteDistance || this.position._isDirty || this.scaling._isDirty || this._rotationQuaternion && this._rotationQuaternion._isDirty || this.rotation._isDirty)
  29789. }
  29790. ,
  29791. t.prototype._initCache = function() {
  29792. e.prototype._initCache.call(this);
  29793. var t = this._cache;
  29794. t.localMatrixUpdated = !1,
  29795. t.billboardMode = -1,
  29796. t.infiniteDistance = !1
  29797. }
  29798. ,
  29799. Object.defineProperty(t.prototype, "absolutePosition", {
  29800. get: function() {
  29801. return this.getAbsolutePosition()
  29802. },
  29803. enumerable: !1,
  29804. configurable: !0
  29805. }),
  29806. Object.defineProperty(t.prototype, "absoluteScaling", {
  29807. get: function() {
  29808. return this._syncAbsoluteScalingAndRotation(),
  29809. this._absoluteScaling
  29810. },
  29811. enumerable: !1,
  29812. configurable: !0
  29813. }),
  29814. Object.defineProperty(t.prototype, "absoluteRotationQuaternion", {
  29815. get: function() {
  29816. return this._syncAbsoluteScalingAndRotation(),
  29817. this._absoluteRotationQuaternion
  29818. },
  29819. enumerable: !1,
  29820. configurable: !0
  29821. }),
  29822. t.prototype.setPreTransformMatrix = function(e) {
  29823. return this.setPivotMatrix(e, !1)
  29824. }
  29825. ,
  29826. t.prototype.setPivotMatrix = function(e, t) {
  29827. return void 0 === t && (t = !0),
  29828. this._pivotMatrix.copyFrom(e),
  29829. this._usePivotMatrix = !this._pivotMatrix.isIdentity(),
  29830. this._cache.pivotMatrixUpdated = !0,
  29831. this._postMultiplyPivotMatrix = t,
  29832. this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = P.Invert(this._pivotMatrix)),
  29833. this
  29834. }
  29835. ,
  29836. t.prototype.getPivotMatrix = function() {
  29837. return this._pivotMatrix
  29838. }
  29839. ,
  29840. t.prototype.instantiateHierarchy = function(e, t, i) {
  29841. void 0 === e && (e = null);
  29842. var n = this.clone("Clone of " + (this.name || this.id), e || this.parent, !0);
  29843. n && i && i(this, n);
  29844. for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
  29845. o[r].instantiateHierarchy(n, t, i);
  29846. return n
  29847. }
  29848. ,
  29849. t.prototype.freezeWorldMatrix = function(e, t) {
  29850. return void 0 === e && (e = null),
  29851. void 0 === t && (t = !1),
  29852. e ? t ? (this._rotation.setAll(0),
  29853. this._rotationQuaternion = this._rotationQuaternion || C.Identity(),
  29854. e.decompose(this._scaling, this._rotationQuaternion, this._position),
  29855. this.computeWorldMatrix(!0)) : (this._worldMatrix = e,
  29856. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
  29857. this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1,
  29858. this.computeWorldMatrix(!0)),
  29859. this._isDirty = !1,
  29860. this._isWorldMatrixFrozen = !0,
  29861. this
  29862. }
  29863. ,
  29864. t.prototype.unfreezeWorldMatrix = function() {
  29865. return this._isWorldMatrixFrozen = !1,
  29866. this.computeWorldMatrix(!0),
  29867. this
  29868. }
  29869. ,
  29870. Object.defineProperty(t.prototype, "isWorldMatrixFrozen", {
  29871. get: function() {
  29872. return this._isWorldMatrixFrozen
  29873. },
  29874. enumerable: !1,
  29875. configurable: !0
  29876. }),
  29877. t.prototype.getAbsolutePosition = function() {
  29878. return this.computeWorldMatrix(),
  29879. this._absolutePosition
  29880. }
  29881. ,
  29882. t.prototype.setAbsolutePosition = function(e) {
  29883. if (!e)
  29884. return this;
  29885. var t, i, n;
  29886. if (void 0 === e.x) {
  29887. if (arguments.length < 3)
  29888. return this;
  29889. t = arguments[0],
  29890. i = arguments[1],
  29891. n = arguments[2]
  29892. } else
  29893. t = e.x,
  29894. i = e.y,
  29895. n = e.z;
  29896. if (this.parent) {
  29897. var r = I.Matrix[0];
  29898. this.parent.getWorldMatrix().invertToRef(r),
  29899. x.TransformCoordinatesFromFloatsToRef(t, i, n, r, this.position)
  29900. } else
  29901. this.position.x = t,
  29902. this.position.y = i,
  29903. this.position.z = n;
  29904. return this._absolutePosition.copyFrom(e),
  29905. this
  29906. }
  29907. ,
  29908. t.prototype.setPositionWithLocalVector = function(e) {
  29909. return this.computeWorldMatrix(),
  29910. this.position = x.TransformNormal(e, this._localMatrix),
  29911. this
  29912. }
  29913. ,
  29914. t.prototype.getPositionExpressedInLocalSpace = function() {
  29915. this.computeWorldMatrix();
  29916. var e = I.Matrix[0];
  29917. return this._localMatrix.invertToRef(e),
  29918. x.TransformNormal(this.position, e)
  29919. }
  29920. ,
  29921. t.prototype.locallyTranslate = function(e) {
  29922. return this.computeWorldMatrix(!0),
  29923. this.position = x.TransformCoordinates(e, this._localMatrix),
  29924. this
  29925. }
  29926. ,
  29927. t.prototype.lookAt = function(e, i, n, r, o) {
  29928. void 0 === i && (i = 0),
  29929. void 0 === n && (n = 0),
  29930. void 0 === r && (r = 0),
  29931. void 0 === o && (o = Ji.LOCAL);
  29932. var a = t._LookAtVectorCache
  29933. , s = o === Ji.LOCAL ? this.position : this.getAbsolutePosition();
  29934. if (e.subtractToRef(s, a),
  29935. this.setDirection(a, i, n, r),
  29936. o === Ji.WORLD && this.parent)
  29937. if (this.rotationQuaternion) {
  29938. var l = I.Matrix[0];
  29939. this.rotationQuaternion.toRotationMatrix(l);
  29940. var c = I.Matrix[1];
  29941. this.parent.getWorldMatrix().getRotationMatrixToRef(c),
  29942. c.invert(),
  29943. l.multiplyToRef(c, l),
  29944. this.rotationQuaternion.fromRotationMatrix(l)
  29945. } else {
  29946. var u = I.Quaternion[0];
  29947. C.FromEulerVectorToRef(this.rotation, u),
  29948. l = I.Matrix[0],
  29949. u.toRotationMatrix(l),
  29950. c = I.Matrix[1],
  29951. this.parent.getWorldMatrix().getRotationMatrixToRef(c),
  29952. c.invert(),
  29953. l.multiplyToRef(c, l),
  29954. u.fromRotationMatrix(l),
  29955. u.toEulerAnglesToRef(this.rotation)
  29956. }
  29957. return this
  29958. }
  29959. ,
  29960. t.prototype.getDirection = function(e) {
  29961. var t = x.Zero();
  29962. return this.getDirectionToRef(e, t),
  29963. t
  29964. }
  29965. ,
  29966. t.prototype.getDirectionToRef = function(e, t) {
  29967. return x.TransformNormalToRef(e, this.getWorldMatrix(), t),
  29968. this
  29969. }
  29970. ,
  29971. t.prototype.setDirection = function(e, t, i, n) {
  29972. void 0 === t && (t = 0),
  29973. void 0 === i && (i = 0),
  29974. void 0 === n && (n = 0);
  29975. var r = -Math.atan2(e.z, e.x) + Math.PI / 2
  29976. , o = Math.sqrt(e.x * e.x + e.z * e.z)
  29977. , a = -Math.atan2(e.y, o);
  29978. return this.rotationQuaternion ? C.RotationYawPitchRollToRef(r + t, a + i, n, this.rotationQuaternion) : (this.rotation.x = a + i,
  29979. this.rotation.y = r + t,
  29980. this.rotation.z = n),
  29981. this
  29982. }
  29983. ,
  29984. t.prototype.setPivotPoint = function(e, t) {
  29985. void 0 === t && (t = Ji.LOCAL),
  29986. 0 == this.getScene().getRenderId() && this.computeWorldMatrix(!0);
  29987. var i = this.getWorldMatrix();
  29988. if (t == Ji.WORLD) {
  29989. var n = I.Matrix[0];
  29990. i.invertToRef(n),
  29991. e = x.TransformCoordinates(e, n)
  29992. }
  29993. return this.setPivotMatrix(P.Translation(-e.x, -e.y, -e.z), !0)
  29994. }
  29995. ,
  29996. t.prototype.getPivotPoint = function() {
  29997. var e = x.Zero();
  29998. return this.getPivotPointToRef(e),
  29999. e
  30000. }
  30001. ,
  30002. t.prototype.getPivotPointToRef = function(e) {
  30003. return e.x = -this._pivotMatrix.m[12],
  30004. e.y = -this._pivotMatrix.m[13],
  30005. e.z = -this._pivotMatrix.m[14],
  30006. this
  30007. }
  30008. ,
  30009. t.prototype.getAbsolutePivotPoint = function() {
  30010. var e = x.Zero();
  30011. return this.getAbsolutePivotPointToRef(e),
  30012. e
  30013. }
  30014. ,
  30015. t.prototype.getAbsolutePivotPointToRef = function(e) {
  30016. return this.getPivotPointToRef(e),
  30017. x.TransformCoordinatesToRef(e, this.getWorldMatrix(), e),
  30018. this
  30019. }
  30020. ,
  30021. t.prototype.markAsDirty = function(t) {
  30022. if (this._children)
  30023. for (var i = 0, n = this._children; i < n.length; i++)
  30024. n[i].markAsDirty(t);
  30025. return e.prototype.markAsDirty.call(this, t)
  30026. }
  30027. ,
  30028. t.prototype.setParent = function(e, i) {
  30029. if (void 0 === i && (i = !1),
  30030. !e && !this.parent)
  30031. return this;
  30032. var n = I.Quaternion[0]
  30033. , r = I.Vector3[0]
  30034. , o = I.Vector3[1]
  30035. , a = I.Matrix[1];
  30036. P.IdentityToRef(a);
  30037. var s = I.Matrix[0];
  30038. this.computeWorldMatrix(!0);
  30039. var l = this.rotationQuaternion;
  30040. return l || (l = t._TmpRotation,
  30041. C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, l)),
  30042. P.ComposeToRef(this.scaling, l, this.position, s),
  30043. this.parent && s.multiplyToRef(this.parent.computeWorldMatrix(!0), s),
  30044. e && (e.computeWorldMatrix(!0).invertToRef(a),
  30045. s.multiplyToRef(a, s)),
  30046. s.decompose(o, n, r, i ? this : void 0),
  30047. this.rotationQuaternion ? this.rotationQuaternion.copyFrom(n) : n.toEulerAnglesToRef(this.rotation),
  30048. this.scaling.copyFrom(o),
  30049. this.position.copyFrom(r),
  30050. this.parent = e,
  30051. this
  30052. }
  30053. ,
  30054. Object.defineProperty(t.prototype, "nonUniformScaling", {
  30055. get: function() {
  30056. return this._nonUniformScaling
  30057. },
  30058. enumerable: !1,
  30059. configurable: !0
  30060. }),
  30061. t.prototype._updateNonUniformScalingState = function(e) {
  30062. return this._nonUniformScaling !== e && (this._nonUniformScaling = e,
  30063. !0)
  30064. }
  30065. ,
  30066. t.prototype.attachToBone = function(e, t) {
  30067. return this._currentParentWhenAttachingToBone = this.parent,
  30068. this._transformToBoneReferal = t,
  30069. this.parent = e,
  30070. e.getSkeleton().prepare(),
  30071. e.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
  30072. this
  30073. }
  30074. ,
  30075. t.prototype.detachFromBone = function(e) {
  30076. return void 0 === e && (e = !1),
  30077. this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
  30078. this._transformToBoneReferal = null,
  30079. this.parent = e ? this._currentParentWhenAttachingToBone : null,
  30080. this) : (e && (this.parent = this._currentParentWhenAttachingToBone),
  30081. this)
  30082. }
  30083. ,
  30084. t.prototype.rotate = function(e, i, n) {
  30085. var r;
  30086. if (e.normalize(),
  30087. this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
  30088. this.rotation.setAll(0)),
  30089. n && n !== Ji.LOCAL) {
  30090. if (this.parent) {
  30091. var o = I.Matrix[0];
  30092. this.parent.getWorldMatrix().invertToRef(o),
  30093. e = x.TransformNormal(e, o)
  30094. }
  30095. (r = C.RotationAxisToRef(e, i, t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
  30096. } else
  30097. r = C.RotationAxisToRef(e, i, t._RotationAxisCache),
  30098. this.rotationQuaternion.multiplyToRef(r, this.rotationQuaternion);
  30099. return this
  30100. }
  30101. ,
  30102. t.prototype.rotateAround = function(e, t, i) {
  30103. t.normalize(),
  30104. this.rotationQuaternion || (this.rotationQuaternion = C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
  30105. this.rotation.setAll(0));
  30106. var n = I.Vector3[0]
  30107. , r = I.Vector3[1]
  30108. , o = I.Vector3[2]
  30109. , a = I.Quaternion[0]
  30110. , s = I.Matrix[0]
  30111. , l = I.Matrix[1]
  30112. , c = I.Matrix[2]
  30113. , u = I.Matrix[3];
  30114. return e.subtractToRef(this.position, n),
  30115. P.TranslationToRef(n.x, n.y, n.z, s),
  30116. P.TranslationToRef(-n.x, -n.y, -n.z, l),
  30117. P.RotationAxisToRef(t, i, c),
  30118. l.multiplyToRef(c, u),
  30119. u.multiplyToRef(s, u),
  30120. u.decompose(r, a, o),
  30121. this.position.addInPlace(o),
  30122. a.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
  30123. this
  30124. }
  30125. ,
  30126. t.prototype.translate = function(e, t, i) {
  30127. var n = e.scale(t);
  30128. if (i && i !== Ji.LOCAL)
  30129. this.setAbsolutePosition(this.getAbsolutePosition().add(n));
  30130. else {
  30131. var r = this.getPositionExpressedInLocalSpace().add(n);
  30132. this.setPositionWithLocalVector(r)
  30133. }
  30134. return this
  30135. }
  30136. ,
  30137. t.prototype.addRotation = function(e, t, i) {
  30138. var n;
  30139. this.rotationQuaternion ? n = this.rotationQuaternion : (n = I.Quaternion[1],
  30140. C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, n));
  30141. var r = I.Quaternion[0];
  30142. return C.RotationYawPitchRollToRef(t, e, i, r),
  30143. n.multiplyInPlace(r),
  30144. this.rotationQuaternion || n.toEulerAnglesToRef(this.rotation),
  30145. this
  30146. }
  30147. ,
  30148. t.prototype._getEffectiveParent = function() {
  30149. return this.parent
  30150. }
  30151. ,
  30152. t.prototype.computeWorldMatrix = function(e) {
  30153. if (this._isWorldMatrixFrozen && !this._isDirty)
  30154. return this._worldMatrix;
  30155. var i = this.getScene().getRenderId();
  30156. if (!this._isDirty && !e && this.isSynchronized())
  30157. return this._currentRenderId = i,
  30158. this._worldMatrix;
  30159. var n = this.getScene().activeCamera
  30160. , r = 0 != (this._billboardMode & t.BILLBOARDMODE_USE_POSITION)
  30161. , o = this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  30162. this._updateCache();
  30163. var a = this._cache;
  30164. a.pivotMatrixUpdated = !1,
  30165. a.billboardMode = this.billboardMode,
  30166. a.infiniteDistance = this.infiniteDistance,
  30167. this._currentRenderId = i,
  30168. this._childUpdateId += 1,
  30169. this._isDirty = !1,
  30170. this._position._isDirty = !1,
  30171. this._rotation._isDirty = !1,
  30172. this._scaling._isDirty = !1;
  30173. var s, l = this._getEffectiveParent(), c = t._TmpScaling, u = this._position;
  30174. if (this._infiniteDistance && !this.parent && n) {
  30175. var h = n.getWorldMatrix()
  30176. , d = new x(h.m[12],h.m[13],h.m[14]);
  30177. (u = t._TmpTranslation).copyFromFloats(this._position.x + d.x, this._position.y + d.y, this._position.z + d.z)
  30178. }
  30179. if (c.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant),
  30180. this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1,
  30181. s = this._rotationQuaternion,
  30182. this.reIntegrateRotationIntoRotationQuaternion && (E = this.rotation.lengthSquared()) && (this._rotationQuaternion.multiplyInPlace(C.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
  30183. this._rotation.copyFromFloats(0, 0, 0))) : (s = t._TmpRotation,
  30184. C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, s)),
  30185. this._usePivotMatrix) {
  30186. var p = I.Matrix[1];
  30187. P.ScalingToRef(c.x, c.y, c.z, p);
  30188. var f = I.Matrix[0];
  30189. s.toRotationMatrix(f),
  30190. this._pivotMatrix.multiplyToRef(p, I.Matrix[4]),
  30191. I.Matrix[4].multiplyToRef(f, this._localMatrix),
  30192. this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
  30193. this._localMatrix.addTranslationFromFloats(u.x, u.y, u.z)
  30194. } else
  30195. P.ComposeToRef(c, s, u, this._localMatrix);
  30196. if (l && l.getWorldMatrix) {
  30197. if (e && l.computeWorldMatrix(e),
  30198. o) {
  30199. this._transformToBoneReferal ? l.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), I.Matrix[7]) : I.Matrix[7].copyFrom(l.getWorldMatrix());
  30200. var _ = I.Vector3[5]
  30201. , m = I.Vector3[6];
  30202. I.Matrix[7].decompose(m, void 0, _),
  30203. P.ScalingToRef(m.x, m.y, m.z, I.Matrix[7]),
  30204. I.Matrix[7].setTranslation(_),
  30205. this._localMatrix.multiplyToRef(I.Matrix[7], this._worldMatrix)
  30206. } else
  30207. this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(l.getWorldMatrix(), I.Matrix[6]),
  30208. I.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(l.getWorldMatrix(), this._worldMatrix);
  30209. this._markSyncedWithParent()
  30210. } else
  30211. this._worldMatrix.copyFrom(this._localMatrix);
  30212. if (o && n && this.billboardMode && !r) {
  30213. var g = I.Vector3[0];
  30214. if (this._worldMatrix.getTranslationToRef(g),
  30215. I.Matrix[1].copyFrom(n.getViewMatrix()),
  30216. I.Matrix[1].setTranslationFromFloats(0, 0, 0),
  30217. I.Matrix[1].invertToRef(I.Matrix[0]),
  30218. (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL) {
  30219. I.Matrix[0].decompose(void 0, I.Quaternion[0], void 0);
  30220. var v = I.Vector3[1];
  30221. I.Quaternion[0].toEulerAnglesToRef(v),
  30222. (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
  30223. (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
  30224. (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
  30225. P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])
  30226. }
  30227. this._worldMatrix.setTranslationFromFloats(0, 0, 0),
  30228. this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
  30229. this._worldMatrix.setTranslation(I.Vector3[0])
  30230. } else if (o && n && this.billboardMode && r) {
  30231. g = I.Vector3[0],
  30232. this._worldMatrix.getTranslationToRef(g);
  30233. var y = n.globalPosition;
  30234. this._worldMatrix.invertToRef(I.Matrix[1]);
  30235. var b = I.Vector3[1];
  30236. x.TransformCoordinatesToRef(y, I.Matrix[1], b),
  30237. b.normalize();
  30238. var T = -Math.atan2(b.z, b.x) + Math.PI / 2
  30239. , E = Math.sqrt(b.x * b.x + b.z * b.z)
  30240. , S = -Math.atan2(b.y, E);
  30241. C.RotationYawPitchRollToRef(T, S, 0, I.Quaternion[0]),
  30242. (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL ? (v = I.Vector3[1],
  30243. I.Quaternion[0].toEulerAnglesToRef(v),
  30244. (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
  30245. (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
  30246. (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
  30247. P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])) : P.FromQuaternionToRef(I.Quaternion[0], I.Matrix[0]),
  30248. this._worldMatrix.setTranslationFromFloats(0, 0, 0),
  30249. this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
  30250. this._worldMatrix.setTranslation(I.Vector3[0])
  30251. }
  30252. return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : l && l._nonUniformScaling ? this._updateNonUniformScalingState(l._nonUniformScaling) : this._updateNonUniformScalingState(!1),
  30253. this._afterComputeWorldMatrix(),
  30254. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
  30255. this._isAbsoluteSynced = !1,
  30256. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),
  30257. this._poseMatrix || (this._poseMatrix = P.Invert(this._worldMatrix)),
  30258. this._worldMatrixDeterminantIsDirty = !0,
  30259. this._worldMatrix
  30260. }
  30261. ,
  30262. t.prototype.resetLocalMatrix = function(e) {
  30263. if (void 0 === e && (e = !0),
  30264. this.computeWorldMatrix(),
  30265. e)
  30266. for (var t = this.getChildren(), i = 0; i < t.length; ++i) {
  30267. var n = t[i];
  30268. if (n) {
  30269. n.computeWorldMatrix();
  30270. var r = I.Matrix[0];
  30271. n._localMatrix.multiplyToRef(this._localMatrix, r);
  30272. var o = I.Quaternion[0];
  30273. r.decompose(n.scaling, o, n.position),
  30274. n.rotationQuaternion ? n.rotationQuaternion.copyFrom(o) : o.toEulerAnglesToRef(n.rotation)
  30275. }
  30276. }
  30277. this.scaling.copyFromFloats(1, 1, 1),
  30278. this.position.copyFromFloats(0, 0, 0),
  30279. this.rotation.copyFromFloats(0, 0, 0),
  30280. this.rotationQuaternion && (this.rotationQuaternion = C.Identity()),
  30281. this._worldMatrix = P.Identity()
  30282. }
  30283. ,
  30284. t.prototype._afterComputeWorldMatrix = function() {}
  30285. ,
  30286. t.prototype.registerAfterWorldMatrixUpdate = function(e) {
  30287. return this.onAfterWorldMatrixUpdateObservable.add(e),
  30288. this
  30289. }
  30290. ,
  30291. t.prototype.unregisterAfterWorldMatrixUpdate = function(e) {
  30292. return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),
  30293. this
  30294. }
  30295. ,
  30296. t.prototype.getPositionInCameraSpace = function(e) {
  30297. return void 0 === e && (e = null),
  30298. e || (e = this.getScene().activeCamera),
  30299. x.TransformCoordinates(this.getAbsolutePosition(), e.getViewMatrix())
  30300. }
  30301. ,
  30302. t.prototype.getDistanceToCamera = function(e) {
  30303. return void 0 === e && (e = null),
  30304. e || (e = this.getScene().activeCamera),
  30305. this.getAbsolutePosition().subtract(e.globalPosition).length()
  30306. }
  30307. ,
  30308. t.prototype.clone = function(e, i, n) {
  30309. var r = this
  30310. , o = Ge.Clone((function() {
  30311. return new t(e,r.getScene())
  30312. }
  30313. ), this);
  30314. if (o.name = e,
  30315. o.id = e,
  30316. i && (o.parent = i),
  30317. !n)
  30318. for (var a = this.getDescendants(!0), s = 0; s < a.length; s++) {
  30319. var l = a[s];
  30320. l.clone && l.clone(e + "." + l.name, o)
  30321. }
  30322. return o
  30323. }
  30324. ,
  30325. t.prototype.serialize = function(e) {
  30326. var t = Ge.Serialize(this, e);
  30327. return t.type = this.getClassName(),
  30328. t.uniqueId = this.uniqueId,
  30329. this.parent && (t.parentId = this.parent.uniqueId),
  30330. t.localMatrix = this.getPivotMatrix().asArray(),
  30331. t.isEnabled = this.isEnabled(),
  30332. this.parent && (t.parentId = this.parent.uniqueId),
  30333. t
  30334. }
  30335. ,
  30336. t.Parse = function(e, i, n) {
  30337. var r = Ge.Parse((function() {
  30338. return new t(e.name,i)
  30339. }
  30340. ), e, i, n);
  30341. return e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
  30342. r.setEnabled(e.isEnabled),
  30343. void 0 !== e.parentId && (r._waitingParentId = e.parentId),
  30344. r
  30345. }
  30346. ,
  30347. t.prototype.getChildTransformNodes = function(e, i) {
  30348. var n = [];
  30349. return this._getDescendants(n, e, (function(e) {
  30350. return (!i || i(e)) && e instanceof t
  30351. }
  30352. )),
  30353. n
  30354. }
  30355. ,
  30356. t.prototype.dispose = function(t, i) {
  30357. if (void 0 === i && (i = !1),
  30358. this.getScene().stopAnimation(this),
  30359. this.getScene().removeTransformNode(this),
  30360. this._parentContainer) {
  30361. var n = this._parentContainer.transformNodes.indexOf(this);
  30362. n > -1 && this._parentContainer.transformNodes.splice(n, 1),
  30363. this._parentContainer = null
  30364. }
  30365. if (this.onAfterWorldMatrixUpdateObservable.clear(),
  30366. t)
  30367. for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++) {
  30368. var a = o[r];
  30369. a.parent = null,
  30370. a.computeWorldMatrix(!0)
  30371. }
  30372. e.prototype.dispose.call(this, t, i)
  30373. }
  30374. ,
  30375. t.prototype.normalizeToUnitCube = function(e, t, i) {
  30376. void 0 === e && (e = !0),
  30377. void 0 === t && (t = !1);
  30378. var n = null
  30379. , r = null;
  30380. t && (this.rotationQuaternion ? (r = this.rotationQuaternion.clone(),
  30381. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (n = this.rotation.clone(),
  30382. this.rotation.copyFromFloats(0, 0, 0)));
  30383. var o = this.getHierarchyBoundingVectors(e, i)
  30384. , a = o.max.subtract(o.min)
  30385. , s = Math.max(a.x, a.y, a.z);
  30386. if (0 === s)
  30387. return this;
  30388. var l = 1 / s;
  30389. return this.scaling.scaleInPlace(l),
  30390. t && (this.rotationQuaternion && r ? this.rotationQuaternion.copyFrom(r) : this.rotation && n && this.rotation.copyFrom(n)),
  30391. this
  30392. }
  30393. ,
  30394. t.prototype._syncAbsoluteScalingAndRotation = function() {
  30395. this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion),
  30396. this._isAbsoluteSynced = !0)
  30397. }
  30398. ,
  30399. t.BILLBOARDMODE_NONE = 0,
  30400. t.BILLBOARDMODE_X = 1,
  30401. t.BILLBOARDMODE_Y = 2,
  30402. t.BILLBOARDMODE_Z = 4,
  30403. t.BILLBOARDMODE_ALL = 7,
  30404. t.BILLBOARDMODE_USE_POSITION = 128,
  30405. t._TmpRotation = C.Zero(),
  30406. t._TmpScaling = x.Zero(),
  30407. t._TmpTranslation = x.Zero(),
  30408. t._LookAtVectorCache = new x(0,0,0),
  30409. t._RotationAxisCache = new C,
  30410. k([De("position")], t.prototype, "_position", void 0),
  30411. k([De("rotation")], t.prototype, "_rotation", void 0),
  30412. k([Be("rotationQuaternion")], t.prototype, "_rotationQuaternion", void 0),
  30413. k([De("scaling")], t.prototype, "_scaling", void 0),
  30414. k([Ce("billboardMode")], t.prototype, "_billboardMode", void 0),
  30415. k([Ce()], t.prototype, "scalingDeterminant", void 0),
  30416. k([Ce("infiniteDistance")], t.prototype, "_infiniteDistance", void 0),
  30417. k([Ce()], t.prototype, "ignoreNonUniformScaling", void 0),
  30418. k([Ce()], t.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
  30419. t
  30420. }(Xe)
  30421. , br = function() {
  30422. this._checkCollisions = !1,
  30423. this._collisionMask = -1,
  30424. this._collisionGroup = -1,
  30425. this._surroundingMeshes = null,
  30426. this._collider = null,
  30427. this._oldPositionForCollisions = new x(0,0,0),
  30428. this._diffPositionForCollisions = new x(0,0,0),
  30429. this._collisionResponse = !0
  30430. }
  30431. , Tr = function() {
  30432. this.facetNb = 0,
  30433. this.partitioningSubdivisions = 10,
  30434. this.partitioningBBoxRatio = 1.01,
  30435. this.facetDataEnabled = !1,
  30436. this.facetParameters = {},
  30437. this.bbSize = x.Zero(),
  30438. this.subDiv = {
  30439. max: 1,
  30440. X: 1,
  30441. Y: 1,
  30442. Z: 1
  30443. },
  30444. this.facetDepthSort = !1,
  30445. this.facetDepthSortEnabled = !1
  30446. }
  30447. , Er = function() {
  30448. this._hasVertexAlpha = !1,
  30449. this._useVertexColors = !0,
  30450. this._numBoneInfluencers = 4,
  30451. this._applyFog = !0,
  30452. this._receiveShadows = !1,
  30453. this._facetData = new Tr,
  30454. this._visibility = 1,
  30455. this._skeleton = null,
  30456. this._layerMask = 268435455,
  30457. this._computeBonesUsingShaders = !0,
  30458. this._isActive = !1,
  30459. this._onlyForInstances = !1,
  30460. this._isActiveIntermediate = !1,
  30461. this._onlyForInstancesIntermediate = !1,
  30462. this._actAsRegularMesh = !1,
  30463. this._currentLOD = null,
  30464. this._currentLODIsUpToDate = !1,
  30465. this._collisionRetryCount = 3,
  30466. this._morphTargetManager = null,
  30467. this._renderingGroupId = 0,
  30468. this._bakedVertexAnimationManager = null,
  30469. this._material = null,
  30470. this._positions = null,
  30471. this._meshCollisionData = new br,
  30472. this._enableDistantPicking = !1
  30473. }
  30474. , Sr = function(e) {
  30475. function t(i, n) {
  30476. void 0 === n && (n = null);
  30477. var r = e.call(this, i, n, !1) || this;
  30478. return r._internalAbstractMeshDataInfo = new Er,
  30479. r._waitingMaterialId = null,
  30480. r.cullingStrategy = t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
  30481. r.onCollideObservable = new h,
  30482. r.onCollisionPositionChangeObservable = new h,
  30483. r.onMaterialChangedObservable = new h,
  30484. r.definedFacingForward = !0,
  30485. r._occlusionQuery = null,
  30486. r._renderingGroup = null,
  30487. r.alphaIndex = Number.MAX_VALUE,
  30488. r.isVisible = !0,
  30489. r.isPickable = !0,
  30490. r.isNearPickable = !1,
  30491. r.isNearGrabbable = !1,
  30492. r.showSubMeshesBoundingBox = !1,
  30493. r.isBlocker = !1,
  30494. r.enablePointerMoveEvents = !1,
  30495. r.outlineColor = D.Red(),
  30496. r.outlineWidth = .02,
  30497. r.overlayColor = D.Red(),
  30498. r.overlayAlpha = .5,
  30499. r.useOctreeForRenderingSelection = !0,
  30500. r.useOctreeForPicking = !0,
  30501. r.useOctreeForCollisions = !0,
  30502. r.alwaysSelectAsActiveMesh = !1,
  30503. r.doNotSyncBoundingInfo = !1,
  30504. r.actionManager = null,
  30505. r.ellipsoid = new x(.5,1,.5),
  30506. r.ellipsoidOffset = new x(0,0,0),
  30507. r.edgesWidth = 1,
  30508. r.edgesColor = new N(1,0,0,1),
  30509. r._edgesRenderer = null,
  30510. r._masterMesh = null,
  30511. r._boundingInfo = null,
  30512. r._boundingInfoIsDirty = !0,
  30513. r._renderId = 0,
  30514. r._intersectionsInProgress = new Array,
  30515. r._unIndexed = !1,
  30516. r._lightSources = new Array,
  30517. r._waitingData = {
  30518. lods: null,
  30519. actions: null,
  30520. freezeWorldMatrix: null
  30521. },
  30522. r._bonesTransformMatrices = null,
  30523. r._transformMatrixTexture = null,
  30524. r.onRebuildObservable = new h,
  30525. r._onCollisionPositionChange = function(e, t, i) {
  30526. void 0 === i && (i = null),
  30527. t.subtractToRef(r._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
  30528. r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > vr.CollisionsEpsilon && r.position.addInPlace(r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
  30529. i && r.onCollideObservable.notifyObservers(i),
  30530. r.onCollisionPositionChangeObservable.notifyObservers(r.position)
  30531. }
  30532. ,
  30533. r.getScene().addMesh(r),
  30534. r._resyncLightSources(),
  30535. r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i,!r.getScene().getEngine().isWebGPU),
  30536. r._buildUniformLayout(),
  30537. r
  30538. }
  30539. return U(t, e),
  30540. Object.defineProperty(t, "BILLBOARDMODE_NONE", {
  30541. get: function() {
  30542. return yr.BILLBOARDMODE_NONE
  30543. },
  30544. enumerable: !1,
  30545. configurable: !0
  30546. }),
  30547. Object.defineProperty(t, "BILLBOARDMODE_X", {
  30548. get: function() {
  30549. return yr.BILLBOARDMODE_X
  30550. },
  30551. enumerable: !1,
  30552. configurable: !0
  30553. }),
  30554. Object.defineProperty(t, "BILLBOARDMODE_Y", {
  30555. get: function() {
  30556. return yr.BILLBOARDMODE_Y
  30557. },
  30558. enumerable: !1,
  30559. configurable: !0
  30560. }),
  30561. Object.defineProperty(t, "BILLBOARDMODE_Z", {
  30562. get: function() {
  30563. return yr.BILLBOARDMODE_Z
  30564. },
  30565. enumerable: !1,
  30566. configurable: !0
  30567. }),
  30568. Object.defineProperty(t, "BILLBOARDMODE_ALL", {
  30569. get: function() {
  30570. return yr.BILLBOARDMODE_ALL
  30571. },
  30572. enumerable: !1,
  30573. configurable: !0
  30574. }),
  30575. Object.defineProperty(t, "BILLBOARDMODE_USE_POSITION", {
  30576. get: function() {
  30577. return yr.BILLBOARDMODE_USE_POSITION
  30578. },
  30579. enumerable: !1,
  30580. configurable: !0
  30581. }),
  30582. Object.defineProperty(t.prototype, "facetNb", {
  30583. get: function() {
  30584. return this._internalAbstractMeshDataInfo._facetData.facetNb
  30585. },
  30586. enumerable: !1,
  30587. configurable: !0
  30588. }),
  30589. Object.defineProperty(t.prototype, "partitioningSubdivisions", {
  30590. get: function() {
  30591. return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions
  30592. },
  30593. set: function(e) {
  30594. this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = e
  30595. },
  30596. enumerable: !1,
  30597. configurable: !0
  30598. }),
  30599. Object.defineProperty(t.prototype, "partitioningBBoxRatio", {
  30600. get: function() {
  30601. return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio
  30602. },
  30603. set: function(e) {
  30604. this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = e
  30605. },
  30606. enumerable: !1,
  30607. configurable: !0
  30608. }),
  30609. Object.defineProperty(t.prototype, "mustDepthSortFacets", {
  30610. get: function() {
  30611. return this._internalAbstractMeshDataInfo._facetData.facetDepthSort
  30612. },
  30613. set: function(e) {
  30614. this._internalAbstractMeshDataInfo._facetData.facetDepthSort = e
  30615. },
  30616. enumerable: !1,
  30617. configurable: !0
  30618. }),
  30619. Object.defineProperty(t.prototype, "facetDepthSortFrom", {
  30620. get: function() {
  30621. return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom
  30622. },
  30623. set: function(e) {
  30624. this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = e
  30625. },
  30626. enumerable: !1,
  30627. configurable: !0
  30628. }),
  30629. Object.defineProperty(t.prototype, "collisionRetryCount", {
  30630. get: function() {
  30631. return this._internalAbstractMeshDataInfo._collisionRetryCount
  30632. },
  30633. set: function(e) {
  30634. this._internalAbstractMeshDataInfo._collisionRetryCount = e
  30635. },
  30636. enumerable: !1,
  30637. configurable: !0
  30638. }),
  30639. Object.defineProperty(t.prototype, "isFacetDataEnabled", {
  30640. get: function() {
  30641. return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled
  30642. },
  30643. enumerable: !1,
  30644. configurable: !0
  30645. }),
  30646. Object.defineProperty(t.prototype, "morphTargetManager", {
  30647. get: function() {
  30648. return this._internalAbstractMeshDataInfo._morphTargetManager
  30649. },
  30650. set: function(e) {
  30651. this._internalAbstractMeshDataInfo._morphTargetManager !== e && (this._internalAbstractMeshDataInfo._morphTargetManager = e,
  30652. this._syncGeometryWithMorphTargetManager())
  30653. },
  30654. enumerable: !1,
  30655. configurable: !0
  30656. }),
  30657. Object.defineProperty(t.prototype, "bakedVertexAnimationManager", {
  30658. get: function() {
  30659. return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager
  30660. },
  30661. set: function(e) {
  30662. this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== e && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = e,
  30663. this._markSubMeshesAsAttributesDirty())
  30664. },
  30665. enumerable: !1,
  30666. configurable: !0
  30667. }),
  30668. t.prototype._syncGeometryWithMorphTargetManager = function() {}
  30669. ,
  30670. t.prototype._updateNonUniformScalingState = function(t) {
  30671. return !!e.prototype._updateNonUniformScalingState.call(this, t) && (this._markSubMeshesAsMiscDirty(),
  30672. !0)
  30673. }
  30674. ,
  30675. Object.defineProperty(t.prototype, "onCollide", {
  30676. set: function(e) {
  30677. this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),
  30678. this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(e)
  30679. },
  30680. enumerable: !1,
  30681. configurable: !0
  30682. }),
  30683. Object.defineProperty(t.prototype, "onCollisionPositionChange", {
  30684. set: function(e) {
  30685. this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),
  30686. this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(e)
  30687. },
  30688. enumerable: !1,
  30689. configurable: !0
  30690. }),
  30691. Object.defineProperty(t.prototype, "visibility", {
  30692. get: function() {
  30693. return this._internalAbstractMeshDataInfo._visibility
  30694. },
  30695. set: function(e) {
  30696. if (this._internalAbstractMeshDataInfo._visibility !== e) {
  30697. var t = this._internalAbstractMeshDataInfo._visibility;
  30698. this._internalAbstractMeshDataInfo._visibility = e,
  30699. (1 === t && 1 !== e || 1 !== t && 1 === e) && this._markSubMeshesAsMiscDirty()
  30700. }
  30701. },
  30702. enumerable: !1,
  30703. configurable: !0
  30704. }),
  30705. Object.defineProperty(t.prototype, "renderingGroupId", {
  30706. get: function() {
  30707. return this._internalAbstractMeshDataInfo._renderingGroupId
  30708. },
  30709. set: function(e) {
  30710. this._internalAbstractMeshDataInfo._renderingGroupId = e
  30711. },
  30712. enumerable: !1,
  30713. configurable: !0
  30714. }),
  30715. Object.defineProperty(t.prototype, "material", {
  30716. get: function() {
  30717. return this._internalAbstractMeshDataInfo._material
  30718. },
  30719. set: function(e) {
  30720. this._internalAbstractMeshDataInfo._material !== e && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
  30721. this._internalAbstractMeshDataInfo._material = e,
  30722. e && e.meshMap && (e.meshMap[this.uniqueId] = this),
  30723. this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this),
  30724. this.subMeshes && (this.resetDrawCache(),
  30725. this._unBindEffect()))
  30726. },
  30727. enumerable: !1,
  30728. configurable: !0
  30729. }),
  30730. t.prototype.getMaterialForRenderPass = function(e) {
  30731. var t;
  30732. return null === (t = this._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === t ? void 0 : t[e]
  30733. }
  30734. ,
  30735. t.prototype.setMaterialForRenderPass = function(e, t) {
  30736. this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []),
  30737. this._internalAbstractMeshDataInfo._materialForRenderPass[e] = t
  30738. }
  30739. ,
  30740. Object.defineProperty(t.prototype, "receiveShadows", {
  30741. get: function() {
  30742. return this._internalAbstractMeshDataInfo._receiveShadows
  30743. },
  30744. set: function(e) {
  30745. this._internalAbstractMeshDataInfo._receiveShadows !== e && (this._internalAbstractMeshDataInfo._receiveShadows = e,
  30746. this._markSubMeshesAsLightDirty())
  30747. },
  30748. enumerable: !1,
  30749. configurable: !0
  30750. }),
  30751. Object.defineProperty(t.prototype, "hasVertexAlpha", {
  30752. get: function() {
  30753. return this._internalAbstractMeshDataInfo._hasVertexAlpha
  30754. },
  30755. set: function(e) {
  30756. this._internalAbstractMeshDataInfo._hasVertexAlpha !== e && (this._internalAbstractMeshDataInfo._hasVertexAlpha = e,
  30757. this._markSubMeshesAsAttributesDirty(),
  30758. this._markSubMeshesAsMiscDirty())
  30759. },
  30760. enumerable: !1,
  30761. configurable: !0
  30762. }),
  30763. Object.defineProperty(t.prototype, "useVertexColors", {
  30764. get: function() {
  30765. return this._internalAbstractMeshDataInfo._useVertexColors
  30766. },
  30767. set: function(e) {
  30768. this._internalAbstractMeshDataInfo._useVertexColors !== e && (this._internalAbstractMeshDataInfo._useVertexColors = e,
  30769. this._markSubMeshesAsAttributesDirty())
  30770. },
  30771. enumerable: !1,
  30772. configurable: !0
  30773. }),
  30774. Object.defineProperty(t.prototype, "computeBonesUsingShaders", {
  30775. get: function() {
  30776. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
  30777. },
  30778. set: function(e) {
  30779. this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e,
  30780. this._markSubMeshesAsAttributesDirty())
  30781. },
  30782. enumerable: !1,
  30783. configurable: !0
  30784. }),
  30785. Object.defineProperty(t.prototype, "numBoneInfluencers", {
  30786. get: function() {
  30787. return this._internalAbstractMeshDataInfo._numBoneInfluencers
  30788. },
  30789. set: function(e) {
  30790. this._internalAbstractMeshDataInfo._numBoneInfluencers !== e && (this._internalAbstractMeshDataInfo._numBoneInfluencers = e,
  30791. this._markSubMeshesAsAttributesDirty())
  30792. },
  30793. enumerable: !1,
  30794. configurable: !0
  30795. }),
  30796. Object.defineProperty(t.prototype, "applyFog", {
  30797. get: function() {
  30798. return this._internalAbstractMeshDataInfo._applyFog
  30799. },
  30800. set: function(e) {
  30801. this._internalAbstractMeshDataInfo._applyFog !== e && (this._internalAbstractMeshDataInfo._applyFog = e,
  30802. this._markSubMeshesAsMiscDirty())
  30803. },
  30804. enumerable: !1,
  30805. configurable: !0
  30806. }),
  30807. Object.defineProperty(t.prototype, "enableDistantPicking", {
  30808. get: function() {
  30809. return this._internalAbstractMeshDataInfo._enableDistantPicking
  30810. },
  30811. set: function(e) {
  30812. this._internalAbstractMeshDataInfo._enableDistantPicking = e
  30813. },
  30814. enumerable: !1,
  30815. configurable: !0
  30816. }),
  30817. Object.defineProperty(t.prototype, "layerMask", {
  30818. get: function() {
  30819. return this._internalAbstractMeshDataInfo._layerMask
  30820. },
  30821. set: function(e) {
  30822. e !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = e,
  30823. this._resyncLightSources())
  30824. },
  30825. enumerable: !1,
  30826. configurable: !0
  30827. }),
  30828. Object.defineProperty(t.prototype, "collisionMask", {
  30829. get: function() {
  30830. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask
  30831. },
  30832. set: function(e) {
  30833. this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(e) ? -1 : e
  30834. },
  30835. enumerable: !1,
  30836. configurable: !0
  30837. }),
  30838. Object.defineProperty(t.prototype, "collisionResponse", {
  30839. get: function() {
  30840. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse
  30841. },
  30842. set: function(e) {
  30843. this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = e
  30844. },
  30845. enumerable: !1,
  30846. configurable: !0
  30847. }),
  30848. Object.defineProperty(t.prototype, "collisionGroup", {
  30849. get: function() {
  30850. return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup
  30851. },
  30852. set: function(e) {
  30853. this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(e) ? -1 : e
  30854. },
  30855. enumerable: !1,
  30856. configurable: !0
  30857. }),
  30858. Object.defineProperty(t.prototype, "surroundingMeshes", {
  30859. get: function() {
  30860. return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes
  30861. },
  30862. set: function(e) {
  30863. this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = e
  30864. },
  30865. enumerable: !1,
  30866. configurable: !0
  30867. }),
  30868. Object.defineProperty(t.prototype, "lightSources", {
  30869. get: function() {
  30870. return this._lightSources
  30871. },
  30872. enumerable: !1,
  30873. configurable: !0
  30874. }),
  30875. Object.defineProperty(t.prototype, "_positions", {
  30876. get: function() {
  30877. return null
  30878. },
  30879. enumerable: !1,
  30880. configurable: !0
  30881. }),
  30882. Object.defineProperty(t.prototype, "skeleton", {
  30883. get: function() {
  30884. return this._internalAbstractMeshDataInfo._skeleton
  30885. },
  30886. set: function(e) {
  30887. var t = this._internalAbstractMeshDataInfo._skeleton;
  30888. t && t.needInitialSkinMatrix && t._unregisterMeshWithPoseMatrix(this),
  30889. e && e.needInitialSkinMatrix && e._registerMeshWithPoseMatrix(this),
  30890. this._internalAbstractMeshDataInfo._skeleton = e,
  30891. this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null),
  30892. this._markSubMeshesAsAttributesDirty()
  30893. },
  30894. enumerable: !1,
  30895. configurable: !0
  30896. }),
  30897. t.prototype._buildUniformLayout = function() {
  30898. this._uniformBuffer.addUniform("world", 16),
  30899. this._uniformBuffer.addUniform("visibility", 1),
  30900. this._uniformBuffer.create()
  30901. }
  30902. ,
  30903. t.prototype.transferToEffect = function(e) {
  30904. var t = this._uniformBuffer;
  30905. t.updateMatrix("world", e),
  30906. t.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility),
  30907. t.update()
  30908. }
  30909. ,
  30910. t.prototype.getMeshUniformBuffer = function() {
  30911. return this._uniformBuffer
  30912. }
  30913. ,
  30914. t.prototype.getClassName = function() {
  30915. return "AbstractMesh"
  30916. }
  30917. ,
  30918. t.prototype.toString = function(e) {
  30919. var t = "Name: " + this.name + ", isInstance: " + ("InstancedMesh" !== this.getClassName() ? "YES" : "NO");
  30920. t += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  30921. var i = this._internalAbstractMeshDataInfo._skeleton;
  30922. return i && (t += ", skeleton: " + i.name),
  30923. e && (t += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode],
  30924. t += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")),
  30925. t
  30926. }
  30927. ,
  30928. t.prototype._getEffectiveParent = function() {
  30929. return this._masterMesh && this.billboardMode !== yr.BILLBOARDMODE_NONE ? this._masterMesh : e.prototype._getEffectiveParent.call(this)
  30930. }
  30931. ,
  30932. t.prototype._getActionManagerForTrigger = function(e, t) {
  30933. if (void 0 === t && (t = !0),
  30934. this.actionManager && (t || this.actionManager.isRecursive)) {
  30935. if (!e)
  30936. return this.actionManager;
  30937. if (this.actionManager.hasSpecificTrigger(e))
  30938. return this.actionManager
  30939. }
  30940. return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
  30941. }
  30942. ,
  30943. t.prototype._rebuild = function(e) {
  30944. if (void 0 === e && (e = !1),
  30945. this.onRebuildObservable.notifyObservers(this),
  30946. null !== this._occlusionQuery && (this._occlusionQuery = null),
  30947. this.subMeshes)
  30948. for (var t = 0, i = this.subMeshes; t < i.length; t++)
  30949. i[t]._rebuild()
  30950. }
  30951. ,
  30952. t.prototype._resyncLightSources = function() {
  30953. this._lightSources.length = 0;
  30954. for (var e = 0, t = this.getScene().lights; e < t.length; e++) {
  30955. var i = t[e];
  30956. i.isEnabled() && i.canAffectMesh(this) && this._lightSources.push(i)
  30957. }
  30958. this._markSubMeshesAsLightDirty()
  30959. }
  30960. ,
  30961. t.prototype._resyncLightSource = function(e) {
  30962. var t = e.isEnabled() && e.canAffectMesh(this)
  30963. , i = this._lightSources.indexOf(e)
  30964. , n = !1;
  30965. if (-1 === i) {
  30966. if (!t)
  30967. return;
  30968. this._lightSources.push(e)
  30969. } else {
  30970. if (t)
  30971. return;
  30972. n = !0,
  30973. this._lightSources.splice(i, 1)
  30974. }
  30975. this._markSubMeshesAsLightDirty(n)
  30976. }
  30977. ,
  30978. t.prototype._unBindEffect = function() {
  30979. for (var e = 0, t = this.subMeshes; e < t.length; e++)
  30980. t[e].setEffect(null)
  30981. }
  30982. ,
  30983. t.prototype._removeLightSource = function(e, t) {
  30984. var i = this._lightSources.indexOf(e);
  30985. -1 !== i && (this._lightSources.splice(i, 1),
  30986. this._markSubMeshesAsLightDirty(t))
  30987. }
  30988. ,
  30989. t.prototype._markSubMeshesAsDirty = function(e) {
  30990. if (this.subMeshes)
  30991. for (var t = 0, i = this.subMeshes; t < i.length; t++)
  30992. for (var n = i[t], r = 0; r < n._drawWrappers.length; ++r) {
  30993. var o = n._drawWrappers[r];
  30994. o && o.defines && o.defines.markAllAsDirty && e(o.defines)
  30995. }
  30996. }
  30997. ,
  30998. t.prototype._markSubMeshesAsLightDirty = function(e) {
  30999. void 0 === e && (e = !1),
  31000. this._markSubMeshesAsDirty((function(t) {
  31001. return t.markAsLightDirty(e)
  31002. }
  31003. ))
  31004. }
  31005. ,
  31006. t.prototype._markSubMeshesAsAttributesDirty = function() {
  31007. this._markSubMeshesAsDirty((function(e) {
  31008. return e.markAsAttributesDirty()
  31009. }
  31010. ))
  31011. }
  31012. ,
  31013. t.prototype._markSubMeshesAsMiscDirty = function() {
  31014. this._markSubMeshesAsDirty((function(e) {
  31015. return e.markAsMiscDirty()
  31016. }
  31017. ))
  31018. }
  31019. ,
  31020. t.prototype.markAsDirty = function(e) {
  31021. return this._currentRenderId = Number.MAX_VALUE,
  31022. this._isDirty = !0,
  31023. this
  31024. }
  31025. ,
  31026. t.prototype.resetDrawCache = function(e) {
  31027. if (this.subMeshes)
  31028. for (var t = 0, i = this.subMeshes; t < i.length; t++)
  31029. i[t].resetDrawCache(e)
  31030. }
  31031. ,
  31032. Object.defineProperty(t.prototype, "scaling", {
  31033. get: function() {
  31034. return this._scaling
  31035. },
  31036. set: function(e) {
  31037. this._scaling = e
  31038. },
  31039. enumerable: !1,
  31040. configurable: !0
  31041. }),
  31042. Object.defineProperty(t.prototype, "isBlocked", {
  31043. get: function() {
  31044. return !1
  31045. },
  31046. enumerable: !1,
  31047. configurable: !0
  31048. }),
  31049. t.prototype.getLOD = function(e) {
  31050. return this
  31051. }
  31052. ,
  31053. t.prototype.getTotalVertices = function() {
  31054. return 0
  31055. }
  31056. ,
  31057. t.prototype.getTotalIndices = function() {
  31058. return 0
  31059. }
  31060. ,
  31061. t.prototype.getIndices = function() {
  31062. return null
  31063. }
  31064. ,
  31065. t.prototype.getVerticesData = function(e) {
  31066. return null
  31067. }
  31068. ,
  31069. t.prototype.setVerticesData = function(e, t, i, n) {
  31070. return this
  31071. }
  31072. ,
  31073. t.prototype.updateVerticesData = function(e, t, i, n) {
  31074. return this
  31075. }
  31076. ,
  31077. t.prototype.setIndices = function(e, t) {
  31078. return this
  31079. }
  31080. ,
  31081. t.prototype.isVerticesDataPresent = function(e) {
  31082. return !1
  31083. }
  31084. ,
  31085. t.prototype.getBoundingInfo = function() {
  31086. return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1,
  31087. this._updateBoundingInfo()),
  31088. this._boundingInfo)
  31089. }
  31090. ,
  31091. t.prototype.setBoundingInfo = function(e) {
  31092. return this._boundingInfo = e,
  31093. this
  31094. }
  31095. ,
  31096. Object.defineProperty(t.prototype, "hasBoundingInfo", {
  31097. get: function() {
  31098. return null !== this._boundingInfo
  31099. },
  31100. enumerable: !1,
  31101. configurable: !0
  31102. }),
  31103. t.prototype.buildBoundingInfo = function(e, t, i) {
  31104. return this._boundingInfo = new sr(e,t,i),
  31105. this._boundingInfo
  31106. }
  31107. ,
  31108. t.prototype.normalizeToUnitCube = function(t, i, n) {
  31109. return void 0 === t && (t = !0),
  31110. void 0 === i && (i = !1),
  31111. e.prototype.normalizeToUnitCube.call(this, t, i, n)
  31112. }
  31113. ,
  31114. Object.defineProperty(t.prototype, "useBones", {
  31115. get: function() {
  31116. return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(Bi.MatricesIndicesKind) && this.isVerticesDataPresent(Bi.MatricesWeightsKind)
  31117. },
  31118. enumerable: !1,
  31119. configurable: !0
  31120. }),
  31121. t.prototype._preActivate = function() {}
  31122. ,
  31123. t.prototype._preActivateForIntermediateRendering = function(e) {}
  31124. ,
  31125. t.prototype._activate = function(e, t) {
  31126. return this._renderId = e,
  31127. !0
  31128. }
  31129. ,
  31130. t.prototype._postActivate = function() {}
  31131. ,
  31132. t.prototype._freeze = function() {}
  31133. ,
  31134. t.prototype._unFreeze = function() {}
  31135. ,
  31136. t.prototype.getWorldMatrix = function() {
  31137. return this._masterMesh && this.billboardMode === yr.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : e.prototype.getWorldMatrix.call(this)
  31138. }
  31139. ,
  31140. t.prototype._getWorldMatrixDeterminant = function() {
  31141. return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : e.prototype._getWorldMatrixDeterminant.call(this)
  31142. }
  31143. ,
  31144. Object.defineProperty(t.prototype, "isAnInstance", {
  31145. get: function() {
  31146. return !1
  31147. },
  31148. enumerable: !1,
  31149. configurable: !0
  31150. }),
  31151. Object.defineProperty(t.prototype, "hasInstances", {
  31152. get: function() {
  31153. return !1
  31154. },
  31155. enumerable: !1,
  31156. configurable: !0
  31157. }),
  31158. Object.defineProperty(t.prototype, "hasThinInstances", {
  31159. get: function() {
  31160. return !1
  31161. },
  31162. enumerable: !1,
  31163. configurable: !0
  31164. }),
  31165. t.prototype.movePOV = function(e, t, i) {
  31166. return this.position.addInPlace(this.calcMovePOV(e, t, i)),
  31167. this
  31168. }
  31169. ,
  31170. t.prototype.calcMovePOV = function(e, t, i) {
  31171. var n = new P;
  31172. (this.rotationQuaternion ? this.rotationQuaternion : C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(n);
  31173. var r = x.Zero()
  31174. , o = this.definedFacingForward ? -1 : 1;
  31175. return x.TransformCoordinatesFromFloatsToRef(e * o, t, i * o, n, r),
  31176. r
  31177. }
  31178. ,
  31179. t.prototype.rotatePOV = function(e, t, i) {
  31180. return this.rotation.addInPlace(this.calcRotatePOV(e, t, i)),
  31181. this
  31182. }
  31183. ,
  31184. t.prototype.calcRotatePOV = function(e, t, i) {
  31185. var n = this.definedFacingForward ? 1 : -1;
  31186. return new x(e * n,t,i * n)
  31187. }
  31188. ,
  31189. t.prototype.refreshBoundingInfo = function(e, t) {
  31190. return void 0 === e && (e = !1),
  31191. void 0 === t && (t = !1),
  31192. this._boundingInfo && this._boundingInfo.isLocked || this._refreshBoundingInfo(this._getPositionData(e, t), null),
  31193. this
  31194. }
  31195. ,
  31196. t.prototype._refreshBoundingInfo = function(e, t) {
  31197. if (e) {
  31198. var i = ur(e, 0, this.getTotalVertices(), t);
  31199. this._boundingInfo ? this._boundingInfo.reConstruct(i.minimum, i.maximum) : this._boundingInfo = new sr(i.minimum,i.maximum)
  31200. }
  31201. if (this.subMeshes)
  31202. for (var n = 0; n < this.subMeshes.length; n++)
  31203. this.subMeshes[n].refreshBoundingInfo(e);
  31204. this._updateBoundingInfo()
  31205. }
  31206. ,
  31207. t.prototype.getPositionData = function(e, t, i) {
  31208. if ((i = null != i ? i : this.getVerticesData(Bi.PositionKind)) && t && this.morphTargetManager)
  31209. for (var n = 0, r = 0, o = 0; o < i.length; o++) {
  31210. for (var a = 0; a < this.morphTargetManager.numTargets; a++) {
  31211. var s = this.morphTargetManager.getTarget(a)
  31212. , l = s.influence;
  31213. if (l > 0) {
  31214. var c = s.getPositions();
  31215. c && (i[o] += (c[o] - i[o]) * l)
  31216. }
  31217. }
  31218. if (n++,
  31219. this._positions && 3 === n) {
  31220. n = 0;
  31221. var u = 3 * r;
  31222. this._positions[r++].copyFromFloats(i[u], i[u + 1], i[u + 2])
  31223. }
  31224. }
  31225. if (i && e && this.skeleton) {
  31226. var h = this.getVerticesData(Bi.MatricesIndicesKind)
  31227. , d = this.getVerticesData(Bi.MatricesWeightsKind);
  31228. if (d && h) {
  31229. var p = this.numBoneInfluencers > 4
  31230. , f = p ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null
  31231. , _ = p ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null
  31232. , m = this.skeleton.getTransformMatrices(this)
  31233. , g = I.Vector3[0]
  31234. , v = I.Matrix[0]
  31235. , y = I.Matrix[1]
  31236. , b = 0;
  31237. for (u = 0; u < i.length; u += 3,
  31238. b += 4) {
  31239. v.reset();
  31240. var T = void 0
  31241. , E = void 0;
  31242. for (T = 0; T < 4; T++)
  31243. (E = d[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * h[b + T]), E, y),
  31244. v.addToSelf(y));
  31245. if (p)
  31246. for (T = 0; T < 4; T++)
  31247. (E = _[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * f[b + T]), E, y),
  31248. v.addToSelf(y));
  31249. x.TransformCoordinatesFromFloatsToRef(i[u], i[u + 1], i[u + 2], v, g),
  31250. g.toArray(i, u),
  31251. this._positions && this._positions[u / 3].copyFrom(g)
  31252. }
  31253. }
  31254. }
  31255. return i
  31256. }
  31257. ,
  31258. t.prototype._getPositionData = function(e, t) {
  31259. var i, n = this.getVerticesData(Bi.PositionKind);
  31260. if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
  31261. n && (e && this.skeleton || t && this.morphTargetManager) && (n = gi.Slice(n),
  31262. this._generatePointsArray(),
  31263. this._positions)) {
  31264. var r = this._positions;
  31265. this._internalAbstractMeshDataInfo._positions = new Array(r.length);
  31266. for (var o = 0; o < r.length; o++)
  31267. this._internalAbstractMeshDataInfo._positions[o] = (null === (i = r[o]) || void 0 === i ? void 0 : i.clone()) || new x
  31268. }
  31269. return this.getPositionData(e, t, n)
  31270. }
  31271. ,
  31272. t.prototype._updateBoundingInfo = function() {
  31273. return this._boundingInfo ? this._boundingInfo.update(this.worldMatrixFromCache) : this._boundingInfo = new sr(this.position,this.position,this.worldMatrixFromCache),
  31274. this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),
  31275. this
  31276. }
  31277. ,
  31278. t.prototype._updateSubMeshesBoundingInfo = function(e) {
  31279. if (!this.subMeshes)
  31280. return this;
  31281. for (var t = this.subMeshes.length, i = 0; i < t; i++) {
  31282. var n = this.subMeshes[i];
  31283. (t > 1 || !n.IsGlobal) && n.updateBoundingInfo(e)
  31284. }
  31285. return this
  31286. }
  31287. ,
  31288. t.prototype._afterComputeWorldMatrix = function() {
  31289. this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0)
  31290. }
  31291. ,
  31292. t.prototype.isInFrustum = function(e) {
  31293. return this.getBoundingInfo().isInFrustum(e, this.cullingStrategy)
  31294. }
  31295. ,
  31296. t.prototype.isCompletelyInFrustum = function(e) {
  31297. return this.getBoundingInfo().isCompletelyInFrustum(e)
  31298. }
  31299. ,
  31300. t.prototype.intersectsMesh = function(e, t, i) {
  31301. void 0 === t && (t = !1);
  31302. var n = this.getBoundingInfo()
  31303. , r = e.getBoundingInfo();
  31304. if (n.intersects(r, t))
  31305. return !0;
  31306. if (i)
  31307. for (var o = 0, a = this.getChildMeshes(); o < a.length; o++)
  31308. if (a[o].intersectsMesh(e, t, !0))
  31309. return !0;
  31310. return !1
  31311. }
  31312. ,
  31313. t.prototype.intersectsPoint = function(e) {
  31314. return this.getBoundingInfo().intersectsPoint(e)
  31315. }
  31316. ,
  31317. Object.defineProperty(t.prototype, "checkCollisions", {
  31318. get: function() {
  31319. return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions
  31320. },
  31321. set: function(e) {
  31322. this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = e
  31323. },
  31324. enumerable: !1,
  31325. configurable: !0
  31326. }),
  31327. Object.defineProperty(t.prototype, "collider", {
  31328. get: function() {
  31329. return this._internalAbstractMeshDataInfo._meshCollisionData._collider
  31330. },
  31331. enumerable: !1,
  31332. configurable: !0
  31333. }),
  31334. t.prototype.moveWithCollisions = function(e) {
  31335. this.getAbsolutePosition().addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
  31336. var t = this.getScene().collisionCoordinator;
  31337. return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = t.createCollider()),
  31338. this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid,
  31339. t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, e, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId),
  31340. this
  31341. }
  31342. ,
  31343. t.prototype._collideForSubMesh = function(e, t, i) {
  31344. var n;
  31345. if (this._generatePointsArray(),
  31346. !this._positions)
  31347. return this;
  31348. if (!e._lastColliderWorldVertices || !e._lastColliderTransformMatrix.equals(t)) {
  31349. e._lastColliderTransformMatrix = t.clone(),
  31350. e._lastColliderWorldVertices = [],
  31351. e._trianglePlanes = [];
  31352. for (var r = e.verticesStart, o = e.verticesStart + e.verticesCount, s = r; s < o; s++)
  31353. e._lastColliderWorldVertices.push(x.TransformCoordinates(this._positions[s], t))
  31354. }
  31355. return i._collide(e._trianglePlanes, e._lastColliderWorldVertices, this.getIndices(), e.indexStart, e.indexStart + e.indexCount, e.verticesStart, !!e.getMaterial(), this, this._shouldConvertRHS(), (null === (n = e.getMaterial()) || void 0 === n ? void 0 : n.fillMode) === a.MATERIAL_TriangleStripDrawMode),
  31356. this
  31357. }
  31358. ,
  31359. t.prototype._processCollisionsForSubMeshes = function(e, t) {
  31360. for (var i = this._scene.getCollidingSubMeshCandidates(this, e), n = i.length, r = 0; r < n; r++) {
  31361. var o = i.data[r];
  31362. n > 1 && !o._checkCollision(e) || this._collideForSubMesh(o, t, e)
  31363. }
  31364. return this
  31365. }
  31366. ,
  31367. t.prototype._shouldConvertRHS = function() {
  31368. return !1
  31369. }
  31370. ,
  31371. t.prototype._checkCollision = function(e) {
  31372. if (!this.getBoundingInfo()._checkCollision(e))
  31373. return this;
  31374. var t = I.Matrix[0]
  31375. , i = I.Matrix[1];
  31376. return P.ScalingToRef(1 / e._radius.x, 1 / e._radius.y, 1 / e._radius.z, t),
  31377. this.worldMatrixFromCache.multiplyToRef(t, i),
  31378. this._processCollisionsForSubMeshes(e, i),
  31379. this
  31380. }
  31381. ,
  31382. t.prototype._generatePointsArray = function() {
  31383. return !1
  31384. }
  31385. ,
  31386. t.prototype.intersects = function(e, t, i, n, r, o) {
  31387. void 0 === n && (n = !1),
  31388. void 0 === o && (o = !1);
  31389. var s = new Ui
  31390. , l = "InstancedLinesMesh" === this.getClassName() || "LinesMesh" === this.getClassName() ? this.intersectionThreshold : 0
  31391. , c = this.getBoundingInfo();
  31392. if (!this.subMeshes)
  31393. return s;
  31394. if (!(o || e.intersectsSphere(c.boundingSphere, l) && e.intersectsBox(c.boundingBox, l)))
  31395. return s;
  31396. if (n)
  31397. return s.hit = !o,
  31398. s.pickedMesh = o ? null : this,
  31399. s.distance = o ? 0 : x.Distance(e.origin, c.boundingSphere.center),
  31400. s.subMeshId = 0,
  31401. s;
  31402. if (!this._generatePointsArray())
  31403. return s;
  31404. for (var u = null, h = this._scene.getIntersectingSubMeshCandidates(this, e), d = h.length, p = !1, f = 0; f < d; f++) {
  31405. var _ = (m = h.data[f]).getMaterial();
  31406. if (_ && (_.fillMode == a.MATERIAL_TriangleStripDrawMode || _.fillMode == a.MATERIAL_TriangleFillMode || _.fillMode == a.MATERIAL_WireFrameFillMode || _.fillMode == a.MATERIAL_PointFillMode || _.fillMode == a.MATERIAL_LineListDrawMode)) {
  31407. p = !0;
  31408. break
  31409. }
  31410. }
  31411. if (!p)
  31412. return s.hit = !0,
  31413. s.pickedMesh = this,
  31414. s.distance = x.Distance(e.origin, c.boundingSphere.center),
  31415. s.subMeshId = -1,
  31416. s;
  31417. for (f = 0; f < d; f++) {
  31418. var m = h.data[f];
  31419. if (!(d > 1) || m.canIntersects(e)) {
  31420. var g = m.intersects(e, this._positions, this.getIndices(), t, i);
  31421. if (g && (t || !u || g.distance < u.distance) && ((u = g).subMeshId = f,
  31422. t))
  31423. break
  31424. }
  31425. }
  31426. if (u) {
  31427. var v = null != r ? r : this.getWorldMatrix()
  31428. , y = I.Vector3[0]
  31429. , b = I.Vector3[1];
  31430. x.TransformCoordinatesToRef(e.origin, v, y),
  31431. e.direction.scaleToRef(u.distance, b);
  31432. var T = x.TransformNormal(b, v).addInPlace(y);
  31433. return s.hit = !0,
  31434. s.distance = x.Distance(y, T),
  31435. s.pickedPoint = T,
  31436. s.pickedMesh = this,
  31437. s.bu = u.bu || 0,
  31438. s.bv = u.bv || 0,
  31439. s.subMeshFaceId = u.faceId,
  31440. s.faceId = u.faceId + h.data[u.subMeshId].indexStart / (-1 !== this.getClassName().indexOf("LinesMesh") ? 2 : 3),
  31441. s.subMeshId = u.subMeshId,
  31442. s
  31443. }
  31444. return s
  31445. }
  31446. ,
  31447. t.prototype.clone = function(e, t, i) {
  31448. return null
  31449. }
  31450. ,
  31451. t.prototype.releaseSubMeshes = function() {
  31452. if (this.subMeshes)
  31453. for (; this.subMeshes.length; )
  31454. this.subMeshes[0].dispose();
  31455. else
  31456. this.subMeshes = new Array;
  31457. return this
  31458. }
  31459. ,
  31460. t.prototype.dispose = function(t, i) {
  31461. var n, r = this;
  31462. for (void 0 === i && (i = !1),
  31463. this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
  31464. this.getScene().freeActiveMeshes(),
  31465. this.getScene().freeRenderingGroups(),
  31466. void 0 !== this.actionManager && null !== this.actionManager && (this.actionManager.dispose(),
  31467. this.actionManager = null),
  31468. this._internalAbstractMeshDataInfo._skeleton = null,
  31469. this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
  31470. this._transformMatrixTexture = null),
  31471. n = 0; n < this._intersectionsInProgress.length; n++) {
  31472. var o = this._intersectionsInProgress[n]
  31473. , a = o._intersectionsInProgress.indexOf(this);
  31474. o._intersectionsInProgress.splice(a, 1)
  31475. }
  31476. this._intersectionsInProgress = [],
  31477. this.getScene().lights.forEach((function(e) {
  31478. var t = e.includedOnlyMeshes.indexOf(r);
  31479. -1 !== t && e.includedOnlyMeshes.splice(t, 1),
  31480. -1 !== (t = e.excludedMeshes.indexOf(r)) && e.excludedMeshes.splice(t, 1);
  31481. var i = e.getShadowGenerator();
  31482. if (i) {
  31483. var n = i.getShadowMap();
  31484. n && n.renderList && -1 !== (t = n.renderList.indexOf(r)) && n.renderList.splice(t, 1)
  31485. }
  31486. }
  31487. )),
  31488. "InstancedMesh" === this.getClassName() && "InstancedLinesMesh" === this.getClassName() || this.releaseSubMeshes();
  31489. var s = this.getScene().getEngine();
  31490. if (null !== this._occlusionQuery && (this.isOcclusionQueryInProgress = !1,
  31491. s.deleteQuery(this._occlusionQuery),
  31492. this._occlusionQuery = null),
  31493. s.wipeCaches(),
  31494. this.getScene().removeMesh(this),
  31495. this._parentContainer) {
  31496. var l = this._parentContainer.meshes.indexOf(this);
  31497. l > -1 && this._parentContainer.meshes.splice(l, 1),
  31498. this._parentContainer = null
  31499. }
  31500. if (i && this.material && ("MultiMaterial" === this.material.getClassName() ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)),
  31501. !t)
  31502. for (n = 0; n < this.getScene().particleSystems.length; n++)
  31503. this.getScene().particleSystems[n].emitter === this && (this.getScene().particleSystems[n].dispose(),
  31504. n--);
  31505. this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(),
  31506. this._uniformBuffer.dispose(),
  31507. this.onAfterWorldMatrixUpdateObservable.clear(),
  31508. this.onCollideObservable.clear(),
  31509. this.onCollisionPositionChangeObservable.clear(),
  31510. this.onRebuildObservable.clear(),
  31511. e.prototype.dispose.call(this, t, i)
  31512. }
  31513. ,
  31514. t.prototype.addChild = function(e, t) {
  31515. return void 0 === t && (t = !1),
  31516. e.setParent(this, t),
  31517. this
  31518. }
  31519. ,
  31520. t.prototype.removeChild = function(e, t) {
  31521. return void 0 === t && (t = !1),
  31522. e.setParent(null, t),
  31523. this
  31524. }
  31525. ,
  31526. t.prototype._initFacetData = function() {
  31527. var e = this._internalAbstractMeshDataInfo._facetData;
  31528. e.facetNormals || (e.facetNormals = new Array),
  31529. e.facetPositions || (e.facetPositions = new Array),
  31530. e.facetPartitioning || (e.facetPartitioning = new Array),
  31531. e.facetNb = this.getIndices().length / 3 | 0,
  31532. e.partitioningSubdivisions = e.partitioningSubdivisions ? e.partitioningSubdivisions : 10,
  31533. e.partitioningBBoxRatio = e.partitioningBBoxRatio ? e.partitioningBBoxRatio : 1.01;
  31534. for (var t = 0; t < e.facetNb; t++)
  31535. e.facetNormals[t] = x.Zero(),
  31536. e.facetPositions[t] = x.Zero();
  31537. return e.facetDataEnabled = !0,
  31538. this
  31539. }
  31540. ,
  31541. t.prototype.updateFacetData = function() {
  31542. var e = this._internalAbstractMeshDataInfo._facetData;
  31543. e.facetDataEnabled || this._initFacetData();
  31544. var t = this.getVerticesData(Bi.PositionKind)
  31545. , i = this.getIndices()
  31546. , n = this.getVerticesData(Bi.NormalKind)
  31547. , r = this.getBoundingInfo();
  31548. if (e.facetDepthSort && !e.facetDepthSortEnabled) {
  31549. if (e.facetDepthSortEnabled = !0,
  31550. i instanceof Uint16Array)
  31551. e.depthSortedIndices = new Uint16Array(i);
  31552. else if (i instanceof Uint32Array)
  31553. e.depthSortedIndices = new Uint32Array(i);
  31554. else {
  31555. for (var o = !1, a = 0; a < i.length; a++)
  31556. if (i[a] > 65535) {
  31557. o = !0;
  31558. break
  31559. }
  31560. e.depthSortedIndices = o ? new Uint32Array(i) : new Uint16Array(i)
  31561. }
  31562. if (e.facetDepthSortFunction = function(e, t) {
  31563. return t.sqDistance - e.sqDistance
  31564. }
  31565. ,
  31566. !e.facetDepthSortFrom) {
  31567. var s = this.getScene().activeCamera;
  31568. e.facetDepthSortFrom = s ? s.position : x.Zero()
  31569. }
  31570. e.depthSortedFacets = [];
  31571. for (var l = 0; l < e.facetNb; l++) {
  31572. var c = {
  31573. ind: 3 * l,
  31574. sqDistance: 0
  31575. };
  31576. e.depthSortedFacets.push(c)
  31577. }
  31578. e.invertedMatrix = P.Identity(),
  31579. e.facetDepthSortOrigin = x.Zero()
  31580. }
  31581. e.bbSize.x = r.maximum.x - r.minimum.x > m ? r.maximum.x - r.minimum.x : m,
  31582. e.bbSize.y = r.maximum.y - r.minimum.y > m ? r.maximum.y - r.minimum.y : m,
  31583. e.bbSize.z = r.maximum.z - r.minimum.z > m ? r.maximum.z - r.minimum.z : m;
  31584. var u = e.bbSize.x > e.bbSize.y ? e.bbSize.x : e.bbSize.y;
  31585. if (u = u > e.bbSize.z ? u : e.bbSize.z,
  31586. e.subDiv.max = e.partitioningSubdivisions,
  31587. e.subDiv.X = Math.floor(e.subDiv.max * e.bbSize.x / u),
  31588. e.subDiv.Y = Math.floor(e.subDiv.max * e.bbSize.y / u),
  31589. e.subDiv.Z = Math.floor(e.subDiv.max * e.bbSize.z / u),
  31590. e.subDiv.X = e.subDiv.X < 1 ? 1 : e.subDiv.X,
  31591. e.subDiv.Y = e.subDiv.Y < 1 ? 1 : e.subDiv.Y,
  31592. e.subDiv.Z = e.subDiv.Z < 1 ? 1 : e.subDiv.Z,
  31593. e.facetParameters.facetNormals = this.getFacetLocalNormals(),
  31594. e.facetParameters.facetPositions = this.getFacetLocalPositions(),
  31595. e.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(),
  31596. e.facetParameters.bInfo = r,
  31597. e.facetParameters.bbSize = e.bbSize,
  31598. e.facetParameters.subDiv = e.subDiv,
  31599. e.facetParameters.ratio = this.partitioningBBoxRatio,
  31600. e.facetParameters.depthSort = e.facetDepthSort,
  31601. e.facetDepthSort && e.facetDepthSortEnabled && (this.computeWorldMatrix(!0),
  31602. this._worldMatrix.invertToRef(e.invertedMatrix),
  31603. x.TransformCoordinatesToRef(e.facetDepthSortFrom, e.invertedMatrix, e.facetDepthSortOrigin),
  31604. e.facetParameters.distanceTo = e.facetDepthSortOrigin),
  31605. e.facetParameters.depthSortedFacets = e.depthSortedFacets,
  31606. n && $n.ComputeNormals(t, i, n, e.facetParameters),
  31607. e.facetDepthSort && e.facetDepthSortEnabled) {
  31608. e.depthSortedFacets.sort(e.facetDepthSortFunction);
  31609. var h = e.depthSortedIndices.length / 3 | 0;
  31610. for (l = 0; l < h; l++) {
  31611. var d = e.depthSortedFacets[l].ind;
  31612. e.depthSortedIndices[3 * l] = i[d],
  31613. e.depthSortedIndices[3 * l + 1] = i[d + 1],
  31614. e.depthSortedIndices[3 * l + 2] = i[d + 2]
  31615. }
  31616. this.updateIndices(e.depthSortedIndices, void 0, !0)
  31617. }
  31618. return this
  31619. }
  31620. ,
  31621. t.prototype.getFacetLocalNormals = function() {
  31622. var e = this._internalAbstractMeshDataInfo._facetData;
  31623. return e.facetNormals || this.updateFacetData(),
  31624. e.facetNormals
  31625. }
  31626. ,
  31627. t.prototype.getFacetLocalPositions = function() {
  31628. var e = this._internalAbstractMeshDataInfo._facetData;
  31629. return e.facetPositions || this.updateFacetData(),
  31630. e.facetPositions
  31631. }
  31632. ,
  31633. t.prototype.getFacetLocalPartitioning = function() {
  31634. var e = this._internalAbstractMeshDataInfo._facetData;
  31635. return e.facetPartitioning || this.updateFacetData(),
  31636. e.facetPartitioning
  31637. }
  31638. ,
  31639. t.prototype.getFacetPosition = function(e) {
  31640. var t = x.Zero();
  31641. return this.getFacetPositionToRef(e, t),
  31642. t
  31643. }
  31644. ,
  31645. t.prototype.getFacetPositionToRef = function(e, t) {
  31646. var i = this.getFacetLocalPositions()[e]
  31647. , n = this.getWorldMatrix();
  31648. return x.TransformCoordinatesToRef(i, n, t),
  31649. this
  31650. }
  31651. ,
  31652. t.prototype.getFacetNormal = function(e) {
  31653. var t = x.Zero();
  31654. return this.getFacetNormalToRef(e, t),
  31655. t
  31656. }
  31657. ,
  31658. t.prototype.getFacetNormalToRef = function(e, t) {
  31659. var i = this.getFacetLocalNormals()[e];
  31660. return x.TransformNormalToRef(i, this.getWorldMatrix(), t),
  31661. this
  31662. }
  31663. ,
  31664. t.prototype.getFacetsAtLocalCoordinates = function(e, t, i) {
  31665. var n = this.getBoundingInfo()
  31666. , r = this._internalAbstractMeshDataInfo._facetData
  31667. , o = Math.floor((e - n.minimum.x * r.partitioningBBoxRatio) * r.subDiv.X * r.partitioningBBoxRatio / r.bbSize.x)
  31668. , a = Math.floor((t - n.minimum.y * r.partitioningBBoxRatio) * r.subDiv.Y * r.partitioningBBoxRatio / r.bbSize.y)
  31669. , s = Math.floor((i - n.minimum.z * r.partitioningBBoxRatio) * r.subDiv.Z * r.partitioningBBoxRatio / r.bbSize.z);
  31670. return o < 0 || o > r.subDiv.max || a < 0 || a > r.subDiv.max || s < 0 || s > r.subDiv.max ? null : r.facetPartitioning[o + r.subDiv.max * a + r.subDiv.max * r.subDiv.max * s]
  31671. }
  31672. ,
  31673. t.prototype.getClosestFacetAtCoordinates = function(e, t, i, n, r, o) {
  31674. void 0 === r && (r = !1),
  31675. void 0 === o && (o = !0);
  31676. var a = this.getWorldMatrix()
  31677. , s = I.Matrix[5];
  31678. a.invertToRef(s);
  31679. var l = I.Vector3[8];
  31680. x.TransformCoordinatesFromFloatsToRef(e, t, i, s, l);
  31681. var c = this.getClosestFacetAtLocalCoordinates(l.x, l.y, l.z, n, r, o);
  31682. return n && x.TransformCoordinatesFromFloatsToRef(n.x, n.y, n.z, a, n),
  31683. c
  31684. }
  31685. ,
  31686. t.prototype.getClosestFacetAtLocalCoordinates = function(e, t, i, n, r, o) {
  31687. void 0 === r && (r = !1),
  31688. void 0 === o && (o = !0);
  31689. var a = null
  31690. , s = 0
  31691. , l = 0
  31692. , c = 0
  31693. , u = 0
  31694. , h = 0
  31695. , d = 0
  31696. , p = 0
  31697. , f = 0
  31698. , _ = this.getFacetLocalPositions()
  31699. , m = this.getFacetLocalNormals()
  31700. , g = this.getFacetsAtLocalCoordinates(e, t, i);
  31701. if (!g)
  31702. return null;
  31703. for (var v, y, b, T = Number.MAX_VALUE, E = T, S = 0; S < g.length; S++)
  31704. y = m[v = g[S]],
  31705. u = (e - (b = _[v]).x) * y.x + (t - b.y) * y.y + (i - b.z) * y.z,
  31706. (!r || r && o && u >= 0 || r && !o && u <= 0) && (u = y.x * b.x + y.y * b.y + y.z * b.z,
  31707. h = -(y.x * e + y.y * t + y.z * i - u) / (y.x * y.x + y.y * y.y + y.z * y.z),
  31708. (E = (s = (d = e + y.x * h) - e) * s + (l = (p = t + y.y * h) - t) * l + (c = (f = i + y.z * h) - i) * c) < T && (T = E,
  31709. a = v,
  31710. n && (n.x = d,
  31711. n.y = p,
  31712. n.z = f)));
  31713. return a
  31714. }
  31715. ,
  31716. t.prototype.getFacetDataParameters = function() {
  31717. return this._internalAbstractMeshDataInfo._facetData.facetParameters
  31718. }
  31719. ,
  31720. t.prototype.disableFacetData = function() {
  31721. var e = this._internalAbstractMeshDataInfo._facetData;
  31722. return e.facetDataEnabled && (e.facetDataEnabled = !1,
  31723. e.facetPositions = new Array,
  31724. e.facetNormals = new Array,
  31725. e.facetPartitioning = new Array,
  31726. e.facetParameters = null,
  31727. e.depthSortedIndices = new Uint32Array(0)),
  31728. this
  31729. }
  31730. ,
  31731. t.prototype.updateIndices = function(e, t, i) {
  31732. return void 0 === i && (i = !1),
  31733. this
  31734. }
  31735. ,
  31736. t.prototype.createNormals = function(e) {
  31737. var t, i = this.getVerticesData(Bi.PositionKind), n = this.getIndices();
  31738. return t = this.isVerticesDataPresent(Bi.NormalKind) ? this.getVerticesData(Bi.NormalKind) : [],
  31739. $n.ComputeNormals(i, n, t, {
  31740. useRightHandedSystem: this.getScene().useRightHandedSystem
  31741. }),
  31742. this.setVerticesData(Bi.NormalKind, t, e),
  31743. this
  31744. }
  31745. ,
  31746. t.prototype.alignWithNormal = function(e, t) {
  31747. t || (t = vn.Y);
  31748. var i = I.Vector3[0]
  31749. , n = I.Vector3[1];
  31750. return x.CrossToRef(t, e, n),
  31751. x.CrossToRef(e, n, i),
  31752. this.rotationQuaternion ? C.RotationQuaternionFromAxisToRef(i, e, n, this.rotationQuaternion) : x.RotationFromAxisToRef(i, e, n, this.rotation),
  31753. this
  31754. }
  31755. ,
  31756. t.prototype._checkOcclusionQuery = function() {
  31757. return !1
  31758. }
  31759. ,
  31760. t.prototype.disableEdgesRendering = function() {
  31761. throw be("EdgesRenderer")
  31762. }
  31763. ,
  31764. t.prototype.enableEdgesRendering = function(e, t, i) {
  31765. throw be("EdgesRenderer")
  31766. }
  31767. ,
  31768. t.prototype.getConnectedParticleSystems = function() {
  31769. var e = this;
  31770. return this._scene.particleSystems.filter((function(t) {
  31771. return t.emitter === e
  31772. }
  31773. ))
  31774. }
  31775. ,
  31776. t.OCCLUSION_TYPE_NONE = 0,
  31777. t.OCCLUSION_TYPE_OPTIMISTIC = 1,
  31778. t.OCCLUSION_TYPE_STRICT = 2,
  31779. t.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
  31780. t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
  31781. t.CULLINGSTRATEGY_STANDARD = a.MESHES_CULLINGSTRATEGY_STANDARD,
  31782. t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
  31783. t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,
  31784. t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,
  31785. t
  31786. }(yr);
  31787. y("BABYLON.AbstractMesh", Sr);
  31788. var Ar, xr = function() {
  31789. function e(e, t, i, n) {
  31790. this.x = e,
  31791. this.y = t,
  31792. this.width = i,
  31793. this.height = n
  31794. }
  31795. return e.prototype.toGlobal = function(t, i) {
  31796. return new e(this.x * t,this.y * i,this.width * t,this.height * i)
  31797. }
  31798. ,
  31799. e.prototype.toGlobalToRef = function(e, t, i) {
  31800. return i.x = this.x * e,
  31801. i.y = this.y * t,
  31802. i.width = this.width * e,
  31803. i.height = this.height * t,
  31804. this
  31805. }
  31806. ,
  31807. e.prototype.clone = function() {
  31808. return new e(this.x,this.y,this.width,this.height)
  31809. }
  31810. ,
  31811. e
  31812. }(), Rr = function(e) {
  31813. function t(i, n, r, o) {
  31814. void 0 === o && (o = !0);
  31815. var a = e.call(this, i, r) || this;
  31816. return a._position = x.Zero(),
  31817. a._upVector = x.Up(),
  31818. a.orthoLeft = null,
  31819. a.orthoRight = null,
  31820. a.orthoBottom = null,
  31821. a.orthoTop = null,
  31822. a.fov = .8,
  31823. a.projectionPlaneTilt = 0,
  31824. a.minZ = 1,
  31825. a.maxZ = 1e4,
  31826. a.inertia = .9,
  31827. a.mode = t.PERSPECTIVE_CAMERA,
  31828. a.isIntermediate = !1,
  31829. a.viewport = new xr(0,0,1,1),
  31830. a.layerMask = 268435455,
  31831. a.fovMode = t.FOVMODE_VERTICAL_FIXED,
  31832. a.cameraRigMode = t.RIG_MODE_NONE,
  31833. a.customRenderTargets = new Array,
  31834. a.outputRenderTarget = null,
  31835. a.onViewMatrixChangedObservable = new h,
  31836. a.onProjectionMatrixChangedObservable = new h,
  31837. a.onAfterCheckInputsObservable = new h,
  31838. a.onRestoreStateObservable = new h,
  31839. a.isRigCamera = !1,
  31840. a._rigCameras = new Array,
  31841. a._webvrViewMatrix = P.Identity(),
  31842. a._skipRendering = !1,
  31843. a._projectionMatrix = new P,
  31844. a._postProcesses = new Array,
  31845. a._activeMeshes = new bi(256),
  31846. a._globalPosition = x.Zero(),
  31847. a._computedViewMatrix = P.Identity(),
  31848. a._doNotComputeProjectionMatrix = !1,
  31849. a._transformMatrix = P.Zero(),
  31850. a._refreshFrustumPlanes = !0,
  31851. a._absoluteRotation = C.Identity(),
  31852. a._isCamera = !0,
  31853. a._isLeftCamera = !1,
  31854. a._isRightCamera = !1,
  31855. a.getScene().addCamera(a),
  31856. o && !a.getScene().activeCamera && (a.getScene().activeCamera = a),
  31857. a.position = n,
  31858. a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera ".concat(i)),
  31859. a
  31860. }
  31861. return U(t, e),
  31862. Object.defineProperty(t.prototype, "position", {
  31863. get: function() {
  31864. return this._position
  31865. },
  31866. set: function(e) {
  31867. this._position = e
  31868. },
  31869. enumerable: !1,
  31870. configurable: !0
  31871. }),
  31872. Object.defineProperty(t.prototype, "upVector", {
  31873. get: function() {
  31874. return this._upVector
  31875. },
  31876. set: function(e) {
  31877. this._upVector = e
  31878. },
  31879. enumerable: !1,
  31880. configurable: !0
  31881. }),
  31882. Object.defineProperty(t.prototype, "screenArea", {
  31883. get: function() {
  31884. var e, i, n, r, o = 0, a = 0;
  31885. if (this.mode === t.PERSPECTIVE_CAMERA)
  31886. this.fovMode === t.FOVMODE_VERTICAL_FIXED ? (a = 2 * this.minZ * Math.tan(this.fov / 2),
  31887. o = this.getEngine().getAspectRatio(this) * a) : a = (o = 2 * this.minZ * Math.tan(this.fov / 2)) / this.getEngine().getAspectRatio(this);
  31888. else {
  31889. var s = this.getEngine().getRenderWidth() / 2
  31890. , l = this.getEngine().getRenderHeight() / 2;
  31891. o = (null !== (e = this.orthoRight) && void 0 !== e ? e : s) - (null !== (i = this.orthoLeft) && void 0 !== i ? i : -s),
  31892. a = (null !== (n = this.orthoTop) && void 0 !== n ? n : l) - (null !== (r = this.orthoBottom) && void 0 !== r ? r : -l)
  31893. }
  31894. return o * a
  31895. },
  31896. enumerable: !1,
  31897. configurable: !0
  31898. }),
  31899. t.prototype.storeState = function() {
  31900. return this._stateStored = !0,
  31901. this._storedFov = this.fov,
  31902. this
  31903. }
  31904. ,
  31905. t.prototype._restoreStateValues = function() {
  31906. return !!this._stateStored && (this.fov = this._storedFov,
  31907. !0)
  31908. }
  31909. ,
  31910. t.prototype.restoreState = function() {
  31911. return !!this._restoreStateValues() && (this.onRestoreStateObservable.notifyObservers(this),
  31912. !0)
  31913. }
  31914. ,
  31915. t.prototype.getClassName = function() {
  31916. return "Camera"
  31917. }
  31918. ,
  31919. t.prototype.toString = function(e) {
  31920. var t = "Name: " + this.name;
  31921. if (t += ", type: " + this.getClassName(),
  31922. this.animations)
  31923. for (var i = 0; i < this.animations.length; i++)
  31924. t += ", animation[0]: " + this.animations[i].toString(e);
  31925. return t
  31926. }
  31927. ,
  31928. t.prototype.applyVerticalCorrection = function() {
  31929. var e = this.absoluteRotation.toEulerAngles();
  31930. this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -e.x : e.x
  31931. }
  31932. ,
  31933. Object.defineProperty(t.prototype, "globalPosition", {
  31934. get: function() {
  31935. return this._globalPosition
  31936. },
  31937. enumerable: !1,
  31938. configurable: !0
  31939. }),
  31940. t.prototype.getActiveMeshes = function() {
  31941. return this._activeMeshes
  31942. }
  31943. ,
  31944. t.prototype.isActiveMesh = function(e) {
  31945. return -1 !== this._activeMeshes.indexOf(e)
  31946. }
  31947. ,
  31948. t.prototype.isReady = function(t) {
  31949. if (void 0 === t && (t = !1),
  31950. t)
  31951. for (var i = 0, n = this._postProcesses; i < n.length; i++) {
  31952. var r = n[i];
  31953. if (r && !r.isReady())
  31954. return !1
  31955. }
  31956. return e.prototype.isReady.call(this, t)
  31957. }
  31958. ,
  31959. t.prototype._initCache = function() {
  31960. e.prototype._initCache.call(this),
  31961. this._cache.position = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  31962. this._cache.upVector = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  31963. this._cache.mode = void 0,
  31964. this._cache.minZ = void 0,
  31965. this._cache.maxZ = void 0,
  31966. this._cache.fov = void 0,
  31967. this._cache.fovMode = void 0,
  31968. this._cache.aspectRatio = void 0,
  31969. this._cache.orthoLeft = void 0,
  31970. this._cache.orthoRight = void 0,
  31971. this._cache.orthoBottom = void 0,
  31972. this._cache.orthoTop = void 0,
  31973. this._cache.renderWidth = void 0,
  31974. this._cache.renderHeight = void 0
  31975. }
  31976. ,
  31977. t.prototype._updateCache = function(t) {
  31978. t || e.prototype._updateCache.call(this),
  31979. this._cache.position.copyFrom(this.position),
  31980. this._cache.upVector.copyFrom(this.upVector)
  31981. }
  31982. ,
  31983. t.prototype._isSynchronized = function() {
  31984. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix()
  31985. }
  31986. ,
  31987. t.prototype._isSynchronizedViewMatrix = function() {
  31988. return !!e.prototype._isSynchronized.call(this) && this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent()
  31989. }
  31990. ,
  31991. t.prototype._isSynchronizedProjectionMatrix = function() {
  31992. var e = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
  31993. if (!e)
  31994. return !1;
  31995. var i = this.getEngine();
  31996. return this.mode === t.PERSPECTIVE_CAMERA ? this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === i.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === i.getRenderWidth() && this._cache.renderHeight === i.getRenderHeight()
  31997. }
  31998. ,
  31999. t.prototype.attachControl = function(e, t) {}
  32000. ,
  32001. t.prototype.detachControl = function(e) {}
  32002. ,
  32003. t.prototype.update = function() {
  32004. this._checkInputs(),
  32005. this.cameraRigMode !== t.RIG_MODE_NONE && this._updateRigCameras()
  32006. }
  32007. ,
  32008. t.prototype._checkInputs = function() {
  32009. this.onAfterCheckInputsObservable.notifyObservers(this)
  32010. }
  32011. ,
  32012. Object.defineProperty(t.prototype, "rigCameras", {
  32013. get: function() {
  32014. return this._rigCameras
  32015. },
  32016. enumerable: !1,
  32017. configurable: !0
  32018. }),
  32019. Object.defineProperty(t.prototype, "rigPostProcess", {
  32020. get: function() {
  32021. return this._rigPostProcess
  32022. },
  32023. enumerable: !1,
  32024. configurable: !0
  32025. }),
  32026. t.prototype._getFirstPostProcess = function() {
  32027. for (var e = 0; e < this._postProcesses.length; e++)
  32028. if (null !== this._postProcesses[e])
  32029. return this._postProcesses[e];
  32030. return null
  32031. }
  32032. ,
  32033. t.prototype._cascadePostProcessesToRigCams = function() {
  32034. var e = this._getFirstPostProcess();
  32035. e && e.markTextureDirty();
  32036. for (var t = 0, i = this._rigCameras.length; t < i; t++) {
  32037. var n = this._rigCameras[t]
  32038. , r = n._rigPostProcess;
  32039. r ? ("pass" === r.getEffectName() && (n.isIntermediate = 0 === this._postProcesses.length),
  32040. n._postProcesses = this._postProcesses.slice(0).concat(r),
  32041. r.markTextureDirty()) : n._postProcesses = this._postProcesses.slice(0)
  32042. }
  32043. }
  32044. ,
  32045. t.prototype.attachPostProcess = function(e, t) {
  32046. return void 0 === t && (t = null),
  32047. !e.isReusable() && this._postProcesses.indexOf(e) > -1 ? (K.Error("You're trying to reuse a post process not defined as reusable."),
  32048. 0) : (null == t || t < 0 ? this._postProcesses.push(e) : null === this._postProcesses[t] ? this._postProcesses[t] = e : this._postProcesses.splice(t, 0, e),
  32049. this._cascadePostProcessesToRigCams(),
  32050. this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
  32051. this._postProcesses.indexOf(e))
  32052. }
  32053. ,
  32054. t.prototype.detachPostProcess = function(e) {
  32055. var t = this._postProcesses.indexOf(e);
  32056. -1 !== t && (this._postProcesses[t] = null),
  32057. this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
  32058. this._cascadePostProcessesToRigCams()
  32059. }
  32060. ,
  32061. t.prototype.getWorldMatrix = function() {
  32062. return this._isSynchronizedViewMatrix() || this.getViewMatrix(),
  32063. this._worldMatrix
  32064. }
  32065. ,
  32066. t.prototype._getViewMatrix = function() {
  32067. return P.Identity()
  32068. }
  32069. ,
  32070. t.prototype.getViewMatrix = function(e) {
  32071. return !e && this._isSynchronizedViewMatrix() || (this.updateCache(),
  32072. this._computedViewMatrix = this._getViewMatrix(),
  32073. this._currentRenderId = this.getScene().getRenderId(),
  32074. this._childUpdateId++,
  32075. this._refreshFrustumPlanes = !0,
  32076. this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix && this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix),
  32077. this.parent && this.parent.onViewMatrixChangedObservable && this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),
  32078. this.onViewMatrixChangedObservable.notifyObservers(this),
  32079. this._computedViewMatrix.invertToRef(this._worldMatrix)),
  32080. this._computedViewMatrix
  32081. }
  32082. ,
  32083. t.prototype.freezeProjectionMatrix = function(e) {
  32084. this._doNotComputeProjectionMatrix = !0,
  32085. void 0 !== e && (this._projectionMatrix = e)
  32086. }
  32087. ,
  32088. t.prototype.unfreezeProjectionMatrix = function() {
  32089. this._doNotComputeProjectionMatrix = !1
  32090. }
  32091. ,
  32092. t.prototype.getProjectionMatrix = function(e) {
  32093. var i, n, r, o, a, s, l, c;
  32094. if (this._doNotComputeProjectionMatrix || !e && this._isSynchronizedProjectionMatrix())
  32095. return this._projectionMatrix;
  32096. this._cache.mode = this.mode,
  32097. this._cache.minZ = this.minZ,
  32098. this._cache.maxZ = this.maxZ,
  32099. this._refreshFrustumPlanes = !0;
  32100. var u = this.getEngine()
  32101. , h = this.getScene();
  32102. if (this.mode === t.PERSPECTIVE_CAMERA) {
  32103. this._cache.fov = this.fov,
  32104. this._cache.fovMode = this.fovMode,
  32105. this._cache.aspectRatio = u.getAspectRatio(this),
  32106. this._cache.projectionPlaneTilt = this.projectionPlaneTilt,
  32107. this.minZ <= 0 && (this.minZ = .1);
  32108. var d = u.useReverseDepthBuffer;
  32109. (h.useRightHandedSystem ? P.PerspectiveFovRHToRef : P.PerspectiveFovLHToRef)(this.fov, u.getAspectRatio(this), d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === t.FOVMODE_VERTICAL_FIXED, u.isNDCHalfZRange, this.projectionPlaneTilt, u.useReverseDepthBuffer)
  32110. } else {
  32111. var p = u.getRenderWidth() / 2
  32112. , f = u.getRenderHeight() / 2;
  32113. h.useRightHandedSystem ? P.OrthoOffCenterRHToRef(null !== (i = this.orthoLeft) && void 0 !== i ? i : -p, null !== (n = this.orthoRight) && void 0 !== n ? n : p, null !== (r = this.orthoBottom) && void 0 !== r ? r : -f, null !== (o = this.orthoTop) && void 0 !== o ? o : f, this.minZ, this.maxZ, this._projectionMatrix, u.isNDCHalfZRange) : P.OrthoOffCenterLHToRef(null !== (a = this.orthoLeft) && void 0 !== a ? a : -p, null !== (s = this.orthoRight) && void 0 !== s ? s : p, null !== (l = this.orthoBottom) && void 0 !== l ? l : -f, null !== (c = this.orthoTop) && void 0 !== c ? c : f, this.minZ, this.maxZ, this._projectionMatrix, u.isNDCHalfZRange),
  32114. this._cache.orthoLeft = this.orthoLeft,
  32115. this._cache.orthoRight = this.orthoRight,
  32116. this._cache.orthoBottom = this.orthoBottom,
  32117. this._cache.orthoTop = this.orthoTop,
  32118. this._cache.renderWidth = u.getRenderWidth(),
  32119. this._cache.renderHeight = u.getRenderHeight()
  32120. }
  32121. return this.onProjectionMatrixChangedObservable.notifyObservers(this),
  32122. this._projectionMatrix
  32123. }
  32124. ,
  32125. t.prototype.getTransformationMatrix = function() {
  32126. return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
  32127. this._transformMatrix
  32128. }
  32129. ,
  32130. t.prototype._updateFrustumPlanes = function() {
  32131. this._refreshFrustumPlanes && (this.getTransformationMatrix(),
  32132. this._frustumPlanes ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.GetPlanes(this._transformMatrix),
  32133. this._refreshFrustumPlanes = !1)
  32134. }
  32135. ,
  32136. t.prototype.isInFrustum = function(e, t) {
  32137. if (void 0 === t && (t = !1),
  32138. this._updateFrustumPlanes(),
  32139. t && this.rigCameras.length > 0) {
  32140. var i = !1;
  32141. return this.rigCameras.forEach((function(t) {
  32142. t._updateFrustumPlanes(),
  32143. i = i || e.isInFrustum(t._frustumPlanes)
  32144. }
  32145. )),
  32146. i
  32147. }
  32148. return e.isInFrustum(this._frustumPlanes)
  32149. }
  32150. ,
  32151. t.prototype.isCompletelyInFrustum = function(e) {
  32152. return this._updateFrustumPlanes(),
  32153. e.isCompletelyInFrustum(this._frustumPlanes)
  32154. }
  32155. ,
  32156. t.prototype.getForwardRay = function(e, t, i) {
  32157. throw void 0 === e && (e = 100),
  32158. be("Ray")
  32159. }
  32160. ,
  32161. t.prototype.getForwardRayToRef = function(e, t, i, n) {
  32162. throw void 0 === t && (t = 100),
  32163. be("Ray")
  32164. }
  32165. ,
  32166. t.prototype.dispose = function(i, n) {
  32167. for (void 0 === n && (n = !1),
  32168. this.onViewMatrixChangedObservable.clear(),
  32169. this.onProjectionMatrixChangedObservable.clear(),
  32170. this.onAfterCheckInputsObservable.clear(),
  32171. this.onRestoreStateObservable.clear(),
  32172. this.inputs && this.inputs.clear(),
  32173. this.getScene().stopAnimation(this),
  32174. this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
  32175. var r = this._rigCameras.pop();
  32176. r && r.dispose()
  32177. }
  32178. if (this._parentContainer) {
  32179. var o = this._parentContainer.cameras.indexOf(this);
  32180. o > -1 && this._parentContainer.cameras.splice(o, 1),
  32181. this._parentContainer = null
  32182. }
  32183. if (this._rigPostProcess)
  32184. this._rigPostProcess.dispose(this),
  32185. this._rigPostProcess = null,
  32186. this._postProcesses = [];
  32187. else if (this.cameraRigMode !== t.RIG_MODE_NONE)
  32188. this._rigPostProcess = null,
  32189. this._postProcesses = [];
  32190. else
  32191. for (var a = this._postProcesses.length; --a >= 0; ) {
  32192. var s = this._postProcesses[a];
  32193. s && s.dispose(this)
  32194. }
  32195. for (var l = this.customRenderTargets.length; --l >= 0; )
  32196. this.customRenderTargets[l].dispose();
  32197. this.customRenderTargets = [],
  32198. this._activeMeshes.dispose(),
  32199. this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
  32200. e.prototype.dispose.call(this, i, n)
  32201. }
  32202. ,
  32203. Object.defineProperty(t.prototype, "isLeftCamera", {
  32204. get: function() {
  32205. return this._isLeftCamera
  32206. },
  32207. enumerable: !1,
  32208. configurable: !0
  32209. }),
  32210. Object.defineProperty(t.prototype, "isRightCamera", {
  32211. get: function() {
  32212. return this._isRightCamera
  32213. },
  32214. enumerable: !1,
  32215. configurable: !0
  32216. }),
  32217. Object.defineProperty(t.prototype, "leftCamera", {
  32218. get: function() {
  32219. return this._rigCameras.length < 1 ? null : this._rigCameras[0]
  32220. },
  32221. enumerable: !1,
  32222. configurable: !0
  32223. }),
  32224. Object.defineProperty(t.prototype, "rightCamera", {
  32225. get: function() {
  32226. return this._rigCameras.length < 2 ? null : this._rigCameras[1]
  32227. },
  32228. enumerable: !1,
  32229. configurable: !0
  32230. }),
  32231. t.prototype.getLeftTarget = function() {
  32232. return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget()
  32233. }
  32234. ,
  32235. t.prototype.getRightTarget = function() {
  32236. return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget()
  32237. }
  32238. ,
  32239. t.prototype.setCameraRigMode = function(e, i) {
  32240. if (this.cameraRigMode !== e) {
  32241. for (; this._rigCameras.length > 0; ) {
  32242. var n = this._rigCameras.pop();
  32243. n && n.dispose()
  32244. }
  32245. if (this.cameraRigMode = e,
  32246. this._cameraRigParams = {},
  32247. this._cameraRigParams.interaxialDistance = i.interaxialDistance || .0637,
  32248. this._cameraRigParams.stereoHalfAngle = gi.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
  32249. this.cameraRigMode !== t.RIG_MODE_NONE) {
  32250. var r = this.createRigCamera(this.name + "_L", 0);
  32251. r && (r._isLeftCamera = !0);
  32252. var o = this.createRigCamera(this.name + "_R", 1);
  32253. o && (o._isRightCamera = !0),
  32254. r && o && (this._rigCameras.push(r),
  32255. this._rigCameras.push(o))
  32256. }
  32257. this._setRigMode(i),
  32258. this._cascadePostProcessesToRigCams(),
  32259. this.update()
  32260. }
  32261. }
  32262. ,
  32263. t.prototype._setRigMode = function(e) {}
  32264. ,
  32265. t.prototype._getVRProjectionMatrix = function() {
  32266. return P.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix, !0, this.getEngine().isNDCHalfZRange),
  32267. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix),
  32268. this._projectionMatrix
  32269. }
  32270. ,
  32271. t.prototype._updateCameraRotationMatrix = function() {}
  32272. ,
  32273. t.prototype._updateWebVRCameraRotationMatrix = function() {}
  32274. ,
  32275. t.prototype._getWebVRProjectionMatrix = function() {
  32276. return P.Identity()
  32277. }
  32278. ,
  32279. t.prototype._getWebVRViewMatrix = function() {
  32280. return P.Identity()
  32281. }
  32282. ,
  32283. t.prototype.setCameraRigParameter = function(e, t) {
  32284. this._cameraRigParams || (this._cameraRigParams = {}),
  32285. this._cameraRigParams[e] = t,
  32286. "interaxialDistance" === e && (this._cameraRigParams.stereoHalfAngle = gi.ToRadians(t / .0637))
  32287. }
  32288. ,
  32289. t.prototype.createRigCamera = function(e, t) {
  32290. return null
  32291. }
  32292. ,
  32293. t.prototype._updateRigCameras = function() {
  32294. for (var e = 0; e < this._rigCameras.length; e++)
  32295. this._rigCameras[e].minZ = this.minZ,
  32296. this._rigCameras[e].maxZ = this.maxZ,
  32297. this._rigCameras[e].fov = this.fov,
  32298. this._rigCameras[e].upVector.copyFrom(this.upVector);
  32299. this.cameraRigMode === t.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport)
  32300. }
  32301. ,
  32302. t.prototype._setupInputs = function() {}
  32303. ,
  32304. t.prototype.serialize = function() {
  32305. var e = Ge.Serialize(this);
  32306. return e.uniqueId = this.uniqueId,
  32307. e.type = this.getClassName(),
  32308. this.parent && (e.parentId = this.parent.uniqueId),
  32309. this.inputs && this.inputs.serialize(e),
  32310. Ge.AppendSerializedAnimations(this, e),
  32311. e.ranges = this.serializeAnimationRanges(),
  32312. e.isEnabled = this.isEnabled(),
  32313. e
  32314. }
  32315. ,
  32316. t.prototype.clone = function(e) {
  32317. var i = Ge.Clone(t.GetConstructorFromName(this.getClassName(), e, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  32318. return i.name = e,
  32319. this.onClonedObservable.notifyObservers(i),
  32320. i
  32321. }
  32322. ,
  32323. t.prototype.getDirection = function(e) {
  32324. var t = x.Zero();
  32325. return this.getDirectionToRef(e, t),
  32326. t
  32327. }
  32328. ,
  32329. Object.defineProperty(t.prototype, "absoluteRotation", {
  32330. get: function() {
  32331. return this.getWorldMatrix().decompose(void 0, this._absoluteRotation),
  32332. this._absoluteRotation
  32333. },
  32334. enumerable: !1,
  32335. configurable: !0
  32336. }),
  32337. t.prototype.getDirectionToRef = function(e, t) {
  32338. x.TransformNormalToRef(e, this.getWorldMatrix(), t)
  32339. }
  32340. ,
  32341. t.GetConstructorFromName = function(e, i, n, r, o) {
  32342. return void 0 === r && (r = 0),
  32343. void 0 === o && (o = !0),
  32344. Xe.Construct(e, i, n, {
  32345. interaxial_distance: r,
  32346. isStereoscopicSideBySide: o
  32347. }) || function() {
  32348. return t._CreateDefaultParsedCamera(i, n)
  32349. }
  32350. }
  32351. ,
  32352. t.prototype.computeWorldMatrix = function() {
  32353. return this.getWorldMatrix()
  32354. }
  32355. ,
  32356. t.Parse = function(e, i) {
  32357. var n = e.type
  32358. , r = t.GetConstructorFromName(n, e.name, i, e.interaxial_distance, e.isStereoscopicSideBySide)
  32359. , o = Ge.Parse(r, e, i);
  32360. if (void 0 !== e.parentId && (o._waitingParentId = e.parentId),
  32361. o.inputs && (o.inputs.parse(e),
  32362. o._setupInputs()),
  32363. e.upVector && (o.upVector = x.FromArray(e.upVector)),
  32364. o.setPosition && (o.position.copyFromFloats(0, 0, 0),
  32365. o.setPosition(x.FromArray(e.position))),
  32366. e.target && o.setTarget && o.setTarget(x.FromArray(e.target)),
  32367. e.cameraRigMode) {
  32368. var a = e.interaxial_distance ? {
  32369. interaxialDistance: e.interaxial_distance
  32370. } : {};
  32371. o.setCameraRigMode(e.cameraRigMode, a)
  32372. }
  32373. if (e.animations) {
  32374. for (var s = 0; s < e.animations.length; s++) {
  32375. var l = e.animations[s]
  32376. , c = b("BABYLON.Animation");
  32377. c && o.animations.push(c.Parse(l))
  32378. }
  32379. Xe.ParseAnimationRanges(o, e, i)
  32380. }
  32381. return e.autoAnimate && i.beginAnimation(o, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
  32382. void 0 !== e.isEnabled && o.setEnabled(e.isEnabled),
  32383. o
  32384. }
  32385. ,
  32386. t._CreateDefaultParsedCamera = function(e, t) {
  32387. throw be("UniversalCamera")
  32388. }
  32389. ,
  32390. t.PERSPECTIVE_CAMERA = a.PERSPECTIVE_CAMERA,
  32391. t.ORTHOGRAPHIC_CAMERA = a.ORTHOGRAPHIC_CAMERA,
  32392. t.FOVMODE_VERTICAL_FIXED = a.FOVMODE_VERTICAL_FIXED,
  32393. t.FOVMODE_HORIZONTAL_FIXED = a.FOVMODE_HORIZONTAL_FIXED,
  32394. t.RIG_MODE_NONE = a.RIG_MODE_NONE,
  32395. t.RIG_MODE_STEREOSCOPIC_ANAGLYPH = a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,
  32396. t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,
  32397. t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,
  32398. t.RIG_MODE_STEREOSCOPIC_OVERUNDER = a.RIG_MODE_STEREOSCOPIC_OVERUNDER,
  32399. t.RIG_MODE_STEREOSCOPIC_INTERLACED = a.RIG_MODE_STEREOSCOPIC_INTERLACED,
  32400. t.RIG_MODE_VR = a.RIG_MODE_VR,
  32401. t.RIG_MODE_WEBVR = a.RIG_MODE_WEBVR,
  32402. t.RIG_MODE_CUSTOM = a.RIG_MODE_CUSTOM,
  32403. t.ForceAttachControlToAlwaysPreventDefault = !1,
  32404. k([De("position")], t.prototype, "_position", void 0),
  32405. k([De("upVector")], t.prototype, "_upVector", void 0),
  32406. k([Ce()], t.prototype, "orthoLeft", void 0),
  32407. k([Ce()], t.prototype, "orthoRight", void 0),
  32408. k([Ce()], t.prototype, "orthoBottom", void 0),
  32409. k([Ce()], t.prototype, "orthoTop", void 0),
  32410. k([Ce()], t.prototype, "fov", void 0),
  32411. k([Ce()], t.prototype, "projectionPlaneTilt", void 0),
  32412. k([Ce()], t.prototype, "minZ", void 0),
  32413. k([Ce()], t.prototype, "maxZ", void 0),
  32414. k([Ce()], t.prototype, "inertia", void 0),
  32415. k([Ce()], t.prototype, "mode", void 0),
  32416. k([Ce()], t.prototype, "layerMask", void 0),
  32417. k([Ce()], t.prototype, "fovMode", void 0),
  32418. k([Ce()], t.prototype, "cameraRigMode", void 0),
  32419. k([Ce()], t.prototype, "interaxialDistance", void 0),
  32420. k([Ce()], t.prototype, "isStereoscopicSideBySide", void 0),
  32421. t
  32422. }(Xe), Cr = function(e) {
  32423. function t(i, n) {
  32424. var r = e.call(this, i, n) || this;
  32425. return r.diffuse = new D(1,1,1),
  32426. r.specular = new D(1,1,1),
  32427. r.falloffType = t.FALLOFF_DEFAULT,
  32428. r.intensity = 1,
  32429. r._range = Number.MAX_VALUE,
  32430. r._inverseSquaredRange = 0,
  32431. r._photometricScale = 1,
  32432. r._intensityMode = t.INTENSITYMODE_AUTOMATIC,
  32433. r._radius = 1e-5,
  32434. r.renderPriority = 0,
  32435. r._shadowEnabled = !0,
  32436. r._excludeWithLayerMask = 0,
  32437. r._includeOnlyWithLayerMask = 0,
  32438. r._lightmapMode = 0,
  32439. r._excludedMeshesIds = new Array,
  32440. r._includedOnlyMeshesIds = new Array,
  32441. r._isLight = !0,
  32442. r.getScene().addLight(r),
  32443. r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i),
  32444. r._buildUniformLayout(),
  32445. r.includedOnlyMeshes = new Array,
  32446. r.excludedMeshes = new Array,
  32447. r._resyncMeshes(),
  32448. r
  32449. }
  32450. return U(t, e),
  32451. Object.defineProperty(t.prototype, "range", {
  32452. get: function() {
  32453. return this._range
  32454. },
  32455. set: function(e) {
  32456. this._range = e,
  32457. this._inverseSquaredRange = 1 / (this.range * this.range)
  32458. },
  32459. enumerable: !1,
  32460. configurable: !0
  32461. }),
  32462. Object.defineProperty(t.prototype, "intensityMode", {
  32463. get: function() {
  32464. return this._intensityMode
  32465. },
  32466. set: function(e) {
  32467. this._intensityMode = e,
  32468. this._computePhotometricScale()
  32469. },
  32470. enumerable: !1,
  32471. configurable: !0
  32472. }),
  32473. Object.defineProperty(t.prototype, "radius", {
  32474. get: function() {
  32475. return this._radius
  32476. },
  32477. set: function(e) {
  32478. this._radius = e,
  32479. this._computePhotometricScale()
  32480. },
  32481. enumerable: !1,
  32482. configurable: !0
  32483. }),
  32484. Object.defineProperty(t.prototype, "shadowEnabled", {
  32485. get: function() {
  32486. return this._shadowEnabled
  32487. },
  32488. set: function(e) {
  32489. this._shadowEnabled !== e && (this._shadowEnabled = e,
  32490. this._markMeshesAsLightDirty())
  32491. },
  32492. enumerable: !1,
  32493. configurable: !0
  32494. }),
  32495. Object.defineProperty(t.prototype, "includedOnlyMeshes", {
  32496. get: function() {
  32497. return this._includedOnlyMeshes
  32498. },
  32499. set: function(e) {
  32500. this._includedOnlyMeshes = e,
  32501. this._hookArrayForIncludedOnly(e)
  32502. },
  32503. enumerable: !1,
  32504. configurable: !0
  32505. }),
  32506. Object.defineProperty(t.prototype, "excludedMeshes", {
  32507. get: function() {
  32508. return this._excludedMeshes
  32509. },
  32510. set: function(e) {
  32511. this._excludedMeshes = e,
  32512. this._hookArrayForExcluded(e)
  32513. },
  32514. enumerable: !1,
  32515. configurable: !0
  32516. }),
  32517. Object.defineProperty(t.prototype, "excludeWithLayerMask", {
  32518. get: function() {
  32519. return this._excludeWithLayerMask
  32520. },
  32521. set: function(e) {
  32522. this._excludeWithLayerMask = e,
  32523. this._resyncMeshes()
  32524. },
  32525. enumerable: !1,
  32526. configurable: !0
  32527. }),
  32528. Object.defineProperty(t.prototype, "includeOnlyWithLayerMask", {
  32529. get: function() {
  32530. return this._includeOnlyWithLayerMask
  32531. },
  32532. set: function(e) {
  32533. this._includeOnlyWithLayerMask = e,
  32534. this._resyncMeshes()
  32535. },
  32536. enumerable: !1,
  32537. configurable: !0
  32538. }),
  32539. Object.defineProperty(t.prototype, "lightmapMode", {
  32540. get: function() {
  32541. return this._lightmapMode
  32542. },
  32543. set: function(e) {
  32544. this._lightmapMode !== e && (this._lightmapMode = e,
  32545. this._markMeshesAsLightDirty())
  32546. },
  32547. enumerable: !1,
  32548. configurable: !0
  32549. }),
  32550. t.prototype.transferTexturesToEffect = function(e, t) {
  32551. return this
  32552. }
  32553. ,
  32554. t.prototype._bindLight = function(e, t, i, n, r) {
  32555. void 0 === r && (r = !0);
  32556. var o = e.toString()
  32557. , a = !1;
  32558. if (this._uniformBuffer.bindToEffect(i, "Light" + o),
  32559. this._renderId !== t.getRenderId() || this._lastUseSpecular !== n || !this._uniformBuffer.useUbo) {
  32560. this._renderId = t.getRenderId(),
  32561. this._lastUseSpecular = n;
  32562. var s = this.getScaledIntensity();
  32563. this.transferToEffect(i, o),
  32564. this.diffuse.scaleToRef(s, L.Color3[0]),
  32565. this._uniformBuffer.updateColor4("vLightDiffuse", L.Color3[0], this.range, o),
  32566. n && (this.specular.scaleToRef(s, L.Color3[1]),
  32567. this._uniformBuffer.updateColor4("vLightSpecular", L.Color3[1], this.radius, o)),
  32568. a = !0
  32569. }
  32570. if (this.transferTexturesToEffect(i, o),
  32571. t.shadowsEnabled && this.shadowEnabled && r) {
  32572. var l = this.getShadowGenerator();
  32573. l && (l.bindShadowLight(o, i),
  32574. a = !0)
  32575. }
  32576. a ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer()
  32577. }
  32578. ,
  32579. t.prototype.getClassName = function() {
  32580. return "Light"
  32581. }
  32582. ,
  32583. t.prototype.toString = function(e) {
  32584. var t = "Name: " + this.name;
  32585. if (t += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()],
  32586. this.animations)
  32587. for (var i = 0; i < this.animations.length; i++)
  32588. t += ", animation[0]: " + this.animations[i].toString(e);
  32589. return t
  32590. }
  32591. ,
  32592. t.prototype._syncParentEnabledState = function() {
  32593. e.prototype._syncParentEnabledState.call(this),
  32594. this.isDisposed() || this._resyncMeshes()
  32595. }
  32596. ,
  32597. t.prototype.setEnabled = function(t) {
  32598. e.prototype.setEnabled.call(this, t),
  32599. this._resyncMeshes()
  32600. }
  32601. ,
  32602. t.prototype.getShadowGenerator = function() {
  32603. return this._shadowGenerator
  32604. }
  32605. ,
  32606. t.prototype.getAbsolutePosition = function() {
  32607. return x.Zero()
  32608. }
  32609. ,
  32610. t.prototype.canAffectMesh = function(e) {
  32611. return !(e && (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && -1 === this.includedOnlyMeshes.indexOf(e) || this.excludedMeshes && this.excludedMeshes.length > 0 && -1 !== this.excludedMeshes.indexOf(e) || 0 !== this.includeOnlyWithLayerMask && 0 == (this.includeOnlyWithLayerMask & e.layerMask) || 0 !== this.excludeWithLayerMask && this.excludeWithLayerMask & e.layerMask))
  32612. }
  32613. ,
  32614. t.prototype.dispose = function(t, i) {
  32615. if (void 0 === i && (i = !1),
  32616. this._shadowGenerator && (this._shadowGenerator.dispose(),
  32617. this._shadowGenerator = null),
  32618. this.getScene().stopAnimation(this),
  32619. this._parentContainer) {
  32620. var n = this._parentContainer.lights.indexOf(this);
  32621. n > -1 && this._parentContainer.lights.splice(n, 1),
  32622. this._parentContainer = null
  32623. }
  32624. for (var r = 0, o = this.getScene().meshes; r < o.length; r++)
  32625. o[r]._removeLightSource(this, !0);
  32626. this._uniformBuffer.dispose(),
  32627. this.getScene().removeLight(this),
  32628. e.prototype.dispose.call(this, t, i)
  32629. }
  32630. ,
  32631. t.prototype.getTypeID = function() {
  32632. return 0
  32633. }
  32634. ,
  32635. t.prototype.getScaledIntensity = function() {
  32636. return this._photometricScale * this.intensity
  32637. }
  32638. ,
  32639. t.prototype.clone = function(e, i) {
  32640. void 0 === i && (i = null);
  32641. var n = t.GetConstructorFromName(this.getTypeID(), e, this.getScene());
  32642. if (!n)
  32643. return null;
  32644. var r = Ge.Clone(n, this);
  32645. return e && (r.name = e),
  32646. i && (r.parent = i),
  32647. r.setEnabled(this.isEnabled()),
  32648. this.onClonedObservable.notifyObservers(r),
  32649. r
  32650. }
  32651. ,
  32652. t.prototype.serialize = function() {
  32653. var e = Ge.Serialize(this);
  32654. return e.uniqueId = this.uniqueId,
  32655. e.type = this.getTypeID(),
  32656. this.parent && (e.parentId = this.parent.uniqueId),
  32657. this.excludedMeshes.length > 0 && (e.excludedMeshesIds = [],
  32658. this.excludedMeshes.forEach((function(t) {
  32659. e.excludedMeshesIds.push(t.id)
  32660. }
  32661. ))),
  32662. this.includedOnlyMeshes.length > 0 && (e.includedOnlyMeshesIds = [],
  32663. this.includedOnlyMeshes.forEach((function(t) {
  32664. e.includedOnlyMeshesIds.push(t.id)
  32665. }
  32666. ))),
  32667. Ge.AppendSerializedAnimations(this, e),
  32668. e.ranges = this.serializeAnimationRanges(),
  32669. e.isEnabled = this.isEnabled(),
  32670. e
  32671. }
  32672. ,
  32673. t.GetConstructorFromName = function(e, t, i) {
  32674. return Xe.Construct("Light_Type_" + e, t, i) || null
  32675. }
  32676. ,
  32677. t.Parse = function(e, i) {
  32678. var n = t.GetConstructorFromName(e.type, e.name, i);
  32679. if (!n)
  32680. return null;
  32681. var r = Ge.Parse(n, e, i);
  32682. if (e.excludedMeshesIds && (r._excludedMeshesIds = e.excludedMeshesIds),
  32683. e.includedOnlyMeshesIds && (r._includedOnlyMeshesIds = e.includedOnlyMeshesIds),
  32684. void 0 !== e.parentId && (r._waitingParentId = e.parentId),
  32685. void 0 !== e.falloffType && (r.falloffType = e.falloffType),
  32686. void 0 !== e.lightmapMode && (r.lightmapMode = e.lightmapMode),
  32687. e.animations) {
  32688. for (var o = 0; o < e.animations.length; o++) {
  32689. var a = e.animations[o]
  32690. , s = b("BABYLON.Animation");
  32691. s && r.animations.push(s.Parse(a))
  32692. }
  32693. Xe.ParseAnimationRanges(r, e, i)
  32694. }
  32695. return e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
  32696. void 0 !== e.isEnabled && r.setEnabled(e.isEnabled),
  32697. r
  32698. }
  32699. ,
  32700. t.prototype._hookArrayForExcluded = function(e) {
  32701. var t = this
  32702. , i = e.push;
  32703. e.push = function() {
  32704. for (var n = [], r = 0; r < arguments.length; r++)
  32705. n[r] = arguments[r];
  32706. for (var o = i.apply(e, n), a = 0, s = n; a < s.length; a++) {
  32707. var l = s[a];
  32708. l._resyncLightSource(t)
  32709. }
  32710. return o
  32711. }
  32712. ;
  32713. var n = e.splice;
  32714. e.splice = function(i, r) {
  32715. for (var o = n.apply(e, [i, r]), a = 0, s = o; a < s.length; a++)
  32716. s[a]._resyncLightSource(t);
  32717. return o
  32718. }
  32719. ;
  32720. for (var r = 0, o = e; r < o.length; r++)
  32721. o[r]._resyncLightSource(this)
  32722. }
  32723. ,
  32724. t.prototype._hookArrayForIncludedOnly = function(e) {
  32725. var t = this
  32726. , i = e.push;
  32727. e.push = function() {
  32728. for (var n = [], r = 0; r < arguments.length; r++)
  32729. n[r] = arguments[r];
  32730. var o = i.apply(e, n);
  32731. return t._resyncMeshes(),
  32732. o
  32733. }
  32734. ;
  32735. var n = e.splice;
  32736. e.splice = function(i, r) {
  32737. var o = n.apply(e, [i, r]);
  32738. return t._resyncMeshes(),
  32739. o
  32740. }
  32741. ,
  32742. this._resyncMeshes()
  32743. }
  32744. ,
  32745. t.prototype._resyncMeshes = function() {
  32746. for (var e = 0, t = this.getScene().meshes; e < t.length; e++)
  32747. t[e]._resyncLightSource(this)
  32748. }
  32749. ,
  32750. t.prototype._markMeshesAsLightDirty = function() {
  32751. for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
  32752. var i = t[e];
  32753. -1 !== i.lightSources.indexOf(this) && i._markSubMeshesAsLightDirty()
  32754. }
  32755. }
  32756. ,
  32757. t.prototype._computePhotometricScale = function() {
  32758. this._photometricScale = this._getPhotometricScale(),
  32759. this.getScene().resetCachedMaterial()
  32760. }
  32761. ,
  32762. t.prototype._getPhotometricScale = function() {
  32763. var e = 0
  32764. , i = this.getTypeID()
  32765. , n = this.intensityMode;
  32766. switch (n === t.INTENSITYMODE_AUTOMATIC && (n = i === t.LIGHTTYPEID_DIRECTIONALLIGHT ? t.INTENSITYMODE_ILLUMINANCE : t.INTENSITYMODE_LUMINOUSINTENSITY),
  32767. i) {
  32768. case t.LIGHTTYPEID_POINTLIGHT:
  32769. case t.LIGHTTYPEID_SPOTLIGHT:
  32770. switch (n) {
  32771. case t.INTENSITYMODE_LUMINOUSPOWER:
  32772. e = 1 / (4 * Math.PI);
  32773. break;
  32774. case t.INTENSITYMODE_LUMINOUSINTENSITY:
  32775. e = 1;
  32776. break;
  32777. case t.INTENSITYMODE_LUMINANCE:
  32778. e = this.radius * this.radius
  32779. }
  32780. break;
  32781. case t.LIGHTTYPEID_DIRECTIONALLIGHT:
  32782. switch (n) {
  32783. case t.INTENSITYMODE_ILLUMINANCE:
  32784. e = 1;
  32785. break;
  32786. case t.INTENSITYMODE_LUMINANCE:
  32787. var r = this.radius;
  32788. r = Math.max(r, .001),
  32789. e = 2 * Math.PI * (1 - Math.cos(r))
  32790. }
  32791. break;
  32792. case t.LIGHTTYPEID_HEMISPHERICLIGHT:
  32793. e = 1
  32794. }
  32795. return e
  32796. }
  32797. ,
  32798. t.prototype._reorderLightsInScene = function() {
  32799. var e = this.getScene();
  32800. 0 != this._renderPriority && (e.requireLightSorting = !0),
  32801. this.getScene().sortLightsByPriority()
  32802. }
  32803. ,
  32804. t.FALLOFF_DEFAULT = fn.FALLOFF_DEFAULT,
  32805. t.FALLOFF_PHYSICAL = fn.FALLOFF_PHYSICAL,
  32806. t.FALLOFF_GLTF = fn.FALLOFF_GLTF,
  32807. t.FALLOFF_STANDARD = fn.FALLOFF_STANDARD,
  32808. t.LIGHTMAP_DEFAULT = fn.LIGHTMAP_DEFAULT,
  32809. t.LIGHTMAP_SPECULAR = fn.LIGHTMAP_SPECULAR,
  32810. t.LIGHTMAP_SHADOWSONLY = fn.LIGHTMAP_SHADOWSONLY,
  32811. t.INTENSITYMODE_AUTOMATIC = fn.INTENSITYMODE_AUTOMATIC,
  32812. t.INTENSITYMODE_LUMINOUSPOWER = fn.INTENSITYMODE_LUMINOUSPOWER,
  32813. t.INTENSITYMODE_LUMINOUSINTENSITY = fn.INTENSITYMODE_LUMINOUSINTENSITY,
  32814. t.INTENSITYMODE_ILLUMINANCE = fn.INTENSITYMODE_ILLUMINANCE,
  32815. t.INTENSITYMODE_LUMINANCE = fn.INTENSITYMODE_LUMINANCE,
  32816. t.LIGHTTYPEID_POINTLIGHT = fn.LIGHTTYPEID_POINTLIGHT,
  32817. t.LIGHTTYPEID_DIRECTIONALLIGHT = fn.LIGHTTYPEID_DIRECTIONALLIGHT,
  32818. t.LIGHTTYPEID_SPOTLIGHT = fn.LIGHTTYPEID_SPOTLIGHT,
  32819. t.LIGHTTYPEID_HEMISPHERICLIGHT = fn.LIGHTTYPEID_HEMISPHERICLIGHT,
  32820. k([Me()], t.prototype, "diffuse", void 0),
  32821. k([Me()], t.prototype, "specular", void 0),
  32822. k([Ce()], t.prototype, "falloffType", void 0),
  32823. k([Ce()], t.prototype, "intensity", void 0),
  32824. k([Ce()], t.prototype, "range", null),
  32825. k([Ce()], t.prototype, "intensityMode", null),
  32826. k([Ce()], t.prototype, "radius", null),
  32827. k([Ce()], t.prototype, "_renderPriority", void 0),
  32828. k([Re("_reorderLightsInScene")], t.prototype, "renderPriority", void 0),
  32829. k([Ce("shadowEnabled")], t.prototype, "_shadowEnabled", void 0),
  32830. k([Ce("excludeWithLayerMask")], t.prototype, "_excludeWithLayerMask", void 0),
  32831. k([Ce("includeOnlyWithLayerMask")], t.prototype, "_includeOnlyWithLayerMask", void 0),
  32832. k([Ce("lightmapMode")], t.prototype, "_lightmapMode", void 0),
  32833. t
  32834. }(Xe), Pr = function() {
  32835. function e() {}
  32836. return e.BindClipPlane = function(e, t) {
  32837. if (t.clipPlane) {
  32838. var i = t.clipPlane;
  32839. e.setFloat4("vClipPlane", i.normal.x, i.normal.y, i.normal.z, i.d)
  32840. }
  32841. t.clipPlane2 && (i = t.clipPlane2,
  32842. e.setFloat4("vClipPlane2", i.normal.x, i.normal.y, i.normal.z, i.d)),
  32843. t.clipPlane3 && (i = t.clipPlane3,
  32844. e.setFloat4("vClipPlane3", i.normal.x, i.normal.y, i.normal.z, i.d)),
  32845. t.clipPlane4 && (i = t.clipPlane4,
  32846. e.setFloat4("vClipPlane4", i.normal.x, i.normal.y, i.normal.z, i.d)),
  32847. t.clipPlane5 && (i = t.clipPlane5,
  32848. e.setFloat4("vClipPlane5", i.normal.x, i.normal.y, i.normal.z, i.d)),
  32849. t.clipPlane6 && (i = t.clipPlane6,
  32850. e.setFloat4("vClipPlane6", i.normal.x, i.normal.y, i.normal.z, i.d))
  32851. }
  32852. ,
  32853. e
  32854. }(), Mr = function() {
  32855. function e() {}
  32856. return e.BindSceneUniformBuffer = function(e, t) {
  32857. t.bindToEffect(e, "Scene")
  32858. }
  32859. ,
  32860. e.PrepareDefinesForMergedUV = function(e, t, i) {
  32861. t._needUVs = !0,
  32862. t[i] = !0,
  32863. e.getTextureMatrix().isIdentityAs3x2() ? (t[i + "DIRECTUV"] = e.coordinatesIndex + 1,
  32864. t["MAINUV" + (e.coordinatesIndex + 1)] = !0) : t[i + "DIRECTUV"] = 0
  32865. }
  32866. ,
  32867. e.BindTextureMatrix = function(e, t, i) {
  32868. var n = e.getTextureMatrix();
  32869. t.updateMatrix(i + "Matrix", n)
  32870. }
  32871. ,
  32872. e.GetFogState = function(e, t) {
  32873. return t.fogEnabled && e.applyFog && t.fogMode !== mn.FOGMODE_NONE
  32874. }
  32875. ,
  32876. e.PrepareDefinesForMisc = function(e, t, i, n, r, o, a) {
  32877. a._areMiscDirty && (a.LOGARITHMICDEPTH = i,
  32878. a.POINTSIZE = n,
  32879. a.FOG = r && this.GetFogState(e, t),
  32880. a.NONUNIFORMSCALING = e.nonUniformScaling,
  32881. a.ALPHATEST = o)
  32882. }
  32883. ,
  32884. e.PrepareDefinesForFrameBoundValues = function(e, t, i, n, r, o) {
  32885. void 0 === r && (r = null),
  32886. void 0 === o && (o = !1);
  32887. var a, s, l, c, u, h, d = !1;
  32888. a = null == r ? void 0 !== e.clipPlane && null !== e.clipPlane : r,
  32889. s = null == r ? void 0 !== e.clipPlane2 && null !== e.clipPlane2 : r,
  32890. l = null == r ? void 0 !== e.clipPlane3 && null !== e.clipPlane3 : r,
  32891. c = null == r ? void 0 !== e.clipPlane4 && null !== e.clipPlane4 : r,
  32892. u = null == r ? void 0 !== e.clipPlane5 && null !== e.clipPlane5 : r,
  32893. h = null == r ? void 0 !== e.clipPlane6 && null !== e.clipPlane6 : r,
  32894. i.CLIPPLANE !== a && (i.CLIPPLANE = a,
  32895. d = !0),
  32896. i.CLIPPLANE2 !== s && (i.CLIPPLANE2 = s,
  32897. d = !0),
  32898. i.CLIPPLANE3 !== l && (i.CLIPPLANE3 = l,
  32899. d = !0),
  32900. i.CLIPPLANE4 !== c && (i.CLIPPLANE4 = c,
  32901. d = !0),
  32902. i.CLIPPLANE5 !== u && (i.CLIPPLANE5 = u,
  32903. d = !0),
  32904. i.CLIPPLANE6 !== h && (i.CLIPPLANE6 = h,
  32905. d = !0),
  32906. i.DEPTHPREPASS !== !t.getColorWrite() && (i.DEPTHPREPASS = !i.DEPTHPREPASS,
  32907. d = !0),
  32908. i.INSTANCES !== n && (i.INSTANCES = n,
  32909. d = !0),
  32910. i.INSTANCESCOLOR && !i.INSTANCES && (i.INSTANCESCOLOR = !1,
  32911. d = !0),
  32912. i.THIN_INSTANCES !== o && (i.THIN_INSTANCES = o,
  32913. d = !0),
  32914. d && i.markAsUnprocessed()
  32915. }
  32916. ,
  32917. e.PrepareDefinesForBones = function(e, t) {
  32918. if (e.useBones && e.computeBonesUsingShaders && e.skeleton) {
  32919. t.NUM_BONE_INFLUENCERS = e.numBoneInfluencers;
  32920. var i = void 0 !== t.BONETEXTURE;
  32921. if (e.skeleton.isUsingTextureForMatrices && i)
  32922. t.BONETEXTURE = !0;
  32923. else {
  32924. t.BonesPerMesh = e.skeleton.bones.length + 1,
  32925. t.BONETEXTURE = !i && void 0;
  32926. var n = e.getScene().prePassRenderer;
  32927. if (n && n.enabled) {
  32928. var r = -1 === n.excludedSkinnedMesh.indexOf(e);
  32929. t.BONES_VELOCITY_ENABLED = r
  32930. }
  32931. }
  32932. } else
  32933. t.NUM_BONE_INFLUENCERS = 0,
  32934. t.BonesPerMesh = 0
  32935. }
  32936. ,
  32937. e.PrepareDefinesForMorphTargets = function(e, t) {
  32938. var i = e.morphTargetManager;
  32939. i ? (t.MORPHTARGETS_UV = i.supportsUVs && t.UV1,
  32940. t.MORPHTARGETS_TANGENT = i.supportsTangents && t.TANGENT,
  32941. t.MORPHTARGETS_NORMAL = i.supportsNormals && t.NORMAL,
  32942. t.MORPHTARGETS = i.numInfluencers > 0,
  32943. t.NUM_MORPH_INFLUENCERS = i.numInfluencers,
  32944. t.MORPHTARGETS_TEXTURE = i.isUsingTextureForTargets) : (t.MORPHTARGETS_UV = !1,
  32945. t.MORPHTARGETS_TANGENT = !1,
  32946. t.MORPHTARGETS_NORMAL = !1,
  32947. t.MORPHTARGETS = !1,
  32948. t.NUM_MORPH_INFLUENCERS = 0)
  32949. }
  32950. ,
  32951. e.PrepareDefinesForBakedVertexAnimation = function(e, t) {
  32952. var i = e.bakedVertexAnimationManager;
  32953. t.BAKED_VERTEX_ANIMATION_TEXTURE = !(!i || !i.isEnabled)
  32954. }
  32955. ,
  32956. e.PrepareDefinesForAttributes = function(e, t, i, n, r, o, s) {
  32957. if (void 0 === r && (r = !1),
  32958. void 0 === o && (o = !0),
  32959. void 0 === s && (s = !0),
  32960. !t._areAttributesDirty && t._needNormals === t._normals && t._needUVs === t._uvs)
  32961. return !1;
  32962. t._normals = t._needNormals,
  32963. t._uvs = t._needUVs,
  32964. t.NORMAL = t._needNormals && e.isVerticesDataPresent(Bi.NormalKind),
  32965. t._needNormals && e.isVerticesDataPresent(Bi.TangentKind) && (t.TANGENT = !0);
  32966. for (var l = 1; l <= a.MAX_SUPPORTED_UV_SETS; ++l)
  32967. t["UV" + l] = !!t._needUVs && e.isVerticesDataPresent("uv".concat(1 === l ? "" : l));
  32968. if (i) {
  32969. var c = e.useVertexColors && e.isVerticesDataPresent(Bi.ColorKind);
  32970. t.VERTEXCOLOR = c,
  32971. t.VERTEXALPHA = e.hasVertexAlpha && c && o
  32972. }
  32973. return e.isVerticesDataPresent(Bi.ColorInstanceKind) && (t.INSTANCESCOLOR = !0),
  32974. n && this.PrepareDefinesForBones(e, t),
  32975. r && this.PrepareDefinesForMorphTargets(e, t),
  32976. s && this.PrepareDefinesForBakedVertexAnimation(e, t),
  32977. !0
  32978. }
  32979. ,
  32980. e.PrepareDefinesForMultiview = function(e, t) {
  32981. if (e.activeCamera) {
  32982. var i = t.MULTIVIEW;
  32983. t.MULTIVIEW = null !== e.activeCamera.outputRenderTarget && e.activeCamera.outputRenderTarget.getViewCount() > 1,
  32984. t.MULTIVIEW != i && t.markAsUnprocessed()
  32985. }
  32986. }
  32987. ,
  32988. e.PrepareDefinesForOIT = function(e, t, i) {
  32989. var n = t.ORDER_INDEPENDENT_TRANSPARENCY
  32990. , r = t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
  32991. t.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && i,
  32992. t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
  32993. n === t.ORDER_INDEPENDENT_TRANSPARENCY && r === t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS || t.markAsUnprocessed()
  32994. }
  32995. ,
  32996. e.PrepareDefinesForPrePass = function(e, t, i) {
  32997. var n = t.PREPASS;
  32998. if (t._arePrePassDirty) {
  32999. var r = [{
  33000. type: a.PREPASS_POSITION_TEXTURE_TYPE,
  33001. define: "PREPASS_POSITION",
  33002. index: "PREPASS_POSITION_INDEX"
  33003. }, {
  33004. type: a.PREPASS_VELOCITY_TEXTURE_TYPE,
  33005. define: "PREPASS_VELOCITY",
  33006. index: "PREPASS_VELOCITY_INDEX"
  33007. }, {
  33008. type: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
  33009. define: "PREPASS_REFLECTIVITY",
  33010. index: "PREPASS_REFLECTIVITY_INDEX"
  33011. }, {
  33012. type: a.PREPASS_IRRADIANCE_TEXTURE_TYPE,
  33013. define: "PREPASS_IRRADIANCE",
  33014. index: "PREPASS_IRRADIANCE_INDEX"
  33015. }, {
  33016. type: a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,
  33017. define: "PREPASS_ALBEDO_SQRT",
  33018. index: "PREPASS_ALBEDO_SQRT_INDEX"
  33019. }, {
  33020. type: a.PREPASS_DEPTH_TEXTURE_TYPE,
  33021. define: "PREPASS_DEPTH",
  33022. index: "PREPASS_DEPTH_INDEX"
  33023. }, {
  33024. type: a.PREPASS_NORMAL_TEXTURE_TYPE,
  33025. define: "PREPASS_NORMAL",
  33026. index: "PREPASS_NORMAL_INDEX"
  33027. }];
  33028. if (e.prePassRenderer && e.prePassRenderer.enabled && i) {
  33029. t.PREPASS = !0,
  33030. t.SCENE_MRT_COUNT = e.prePassRenderer.mrtCount;
  33031. for (var o = 0; o < r.length; o++) {
  33032. var s = e.prePassRenderer.getIndex(r[o].type);
  33033. -1 !== s ? (t[r[o].define] = !0,
  33034. t[r[o].index] = s) : t[r[o].define] = !1
  33035. }
  33036. } else
  33037. for (t.PREPASS = !1,
  33038. o = 0; o < r.length; o++)
  33039. t[r[o].define] = !1;
  33040. t.PREPASS != n && (t.markAsUnprocessed(),
  33041. t.markAsImageProcessingDirty())
  33042. }
  33043. }
  33044. ,
  33045. e.PrepareDefinesForLight = function(e, t, i, n, r, o, a) {
  33046. switch (a.needNormals = !0,
  33047. void 0 === r["LIGHT" + n] && (a.needRebuild = !0),
  33048. r["LIGHT" + n] = !0,
  33049. r["SPOTLIGHT" + n] = !1,
  33050. r["HEMILIGHT" + n] = !1,
  33051. r["POINTLIGHT" + n] = !1,
  33052. r["DIRLIGHT" + n] = !1,
  33053. i.prepareLightSpecificDefines(r, n),
  33054. r["LIGHT_FALLOFF_PHYSICAL" + n] = !1,
  33055. r["LIGHT_FALLOFF_GLTF" + n] = !1,
  33056. r["LIGHT_FALLOFF_STANDARD" + n] = !1,
  33057. i.falloffType) {
  33058. case Cr.FALLOFF_GLTF:
  33059. r["LIGHT_FALLOFF_GLTF" + n] = !0;
  33060. break;
  33061. case Cr.FALLOFF_PHYSICAL:
  33062. r["LIGHT_FALLOFF_PHYSICAL" + n] = !0;
  33063. break;
  33064. case Cr.FALLOFF_STANDARD:
  33065. r["LIGHT_FALLOFF_STANDARD" + n] = !0
  33066. }
  33067. if (o && !i.specular.equalsFloats(0, 0, 0) && (a.specularEnabled = !0),
  33068. r["SHADOW" + n] = !1,
  33069. r["SHADOWCSM" + n] = !1,
  33070. r["SHADOWCSMDEBUG" + n] = !1,
  33071. r["SHADOWCSMNUM_CASCADES" + n] = !1,
  33072. r["SHADOWCSMUSESHADOWMAXZ" + n] = !1,
  33073. r["SHADOWCSMNOBLEND" + n] = !1,
  33074. r["SHADOWCSM_RIGHTHANDED" + n] = !1,
  33075. r["SHADOWPCF" + n] = !1,
  33076. r["SHADOWPCSS" + n] = !1,
  33077. r["SHADOWPOISSON" + n] = !1,
  33078. r["SHADOWESM" + n] = !1,
  33079. r["SHADOWCLOSEESM" + n] = !1,
  33080. r["SHADOWCUBE" + n] = !1,
  33081. r["SHADOWLOWQUALITY" + n] = !1,
  33082. r["SHADOWMEDIUMQUALITY" + n] = !1,
  33083. t && t.receiveShadows && e.shadowsEnabled && i.shadowEnabled) {
  33084. var s = i.getShadowGenerator();
  33085. if (s) {
  33086. var l = s.getShadowMap();
  33087. l && l.renderList && l.renderList.length > 0 && (a.shadowEnabled = !0,
  33088. s.prepareDefines(r, n))
  33089. }
  33090. }
  33091. i.lightmapMode != Cr.LIGHTMAP_DEFAULT ? (a.lightmapMode = !0,
  33092. r["LIGHTMAPEXCLUDED" + n] = !0,
  33093. r["LIGHTMAPNOSPECULAR" + n] = i.lightmapMode == Cr.LIGHTMAP_SHADOWSONLY) : (r["LIGHTMAPEXCLUDED" + n] = !1,
  33094. r["LIGHTMAPNOSPECULAR" + n] = !1)
  33095. }
  33096. ,
  33097. e.PrepareDefinesForLights = function(e, t, i, n, r, o) {
  33098. if (void 0 === r && (r = 4),
  33099. void 0 === o && (o = !1),
  33100. !i._areLightsDirty)
  33101. return i._needNormals;
  33102. var a = 0
  33103. , s = {
  33104. needNormals: !1,
  33105. needRebuild: !1,
  33106. lightmapMode: !1,
  33107. shadowEnabled: !1,
  33108. specularEnabled: !1
  33109. };
  33110. if (e.lightsEnabled && !o)
  33111. for (var l = 0, c = t.lightSources; l < c.length; l++) {
  33112. var u = c[l];
  33113. if (this.PrepareDefinesForLight(e, t, u, a, i, n, s),
  33114. ++a === r)
  33115. break
  33116. }
  33117. i.SPECULARTERM = s.specularEnabled,
  33118. i.SHADOWS = s.shadowEnabled;
  33119. for (var h = a; h < r; h++)
  33120. void 0 !== i["LIGHT" + h] && (i["LIGHT" + h] = !1,
  33121. i["HEMILIGHT" + h] = !1,
  33122. i["POINTLIGHT" + h] = !1,
  33123. i["DIRLIGHT" + h] = !1,
  33124. i["SPOTLIGHT" + h] = !1,
  33125. i["SHADOW" + h] = !1,
  33126. i["SHADOWCSM" + h] = !1,
  33127. i["SHADOWCSMDEBUG" + h] = !1,
  33128. i["SHADOWCSMNUM_CASCADES" + h] = !1,
  33129. i["SHADOWCSMUSESHADOWMAXZ" + h] = !1,
  33130. i["SHADOWCSMNOBLEND" + h] = !1,
  33131. i["SHADOWCSM_RIGHTHANDED" + h] = !1,
  33132. i["SHADOWPCF" + h] = !1,
  33133. i["SHADOWPCSS" + h] = !1,
  33134. i["SHADOWPOISSON" + h] = !1,
  33135. i["SHADOWESM" + h] = !1,
  33136. i["SHADOWCLOSEESM" + h] = !1,
  33137. i["SHADOWCUBE" + h] = !1,
  33138. i["SHADOWLOWQUALITY" + h] = !1,
  33139. i["SHADOWMEDIUMQUALITY" + h] = !1);
  33140. var d = e.getEngine().getCaps();
  33141. return void 0 === i.SHADOWFLOAT && (s.needRebuild = !0),
  33142. i.SHADOWFLOAT = s.shadowEnabled && (d.textureFloatRender && d.textureFloatLinearFiltering || d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering),
  33143. i.LIGHTMAPEXCLUDED = s.lightmapMode,
  33144. s.needRebuild && i.rebuild(),
  33145. s.needNormals
  33146. }
  33147. ,
  33148. e.PrepareUniformsAndSamplersForLight = function(e, t, i, n, r, o) {
  33149. void 0 === r && (r = null),
  33150. void 0 === o && (o = !1),
  33151. r && r.push("Light" + e),
  33152. o || (t.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e),
  33153. i.push("shadowSampler" + e),
  33154. i.push("depthSampler" + e),
  33155. t.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e),
  33156. n && (i.push("projectionLightSampler" + e),
  33157. t.push("textureProjectionMatrix" + e)))
  33158. }
  33159. ,
  33160. e.PrepareUniformsAndSamplersList = function(e, t, i, n) {
  33161. var r;
  33162. void 0 === n && (n = 4);
  33163. var o = null;
  33164. if (e.uniformsNames) {
  33165. var a = e;
  33166. r = a.uniformsNames,
  33167. o = a.uniformBuffersNames,
  33168. t = a.samplers,
  33169. i = a.defines,
  33170. n = a.maxSimultaneousLights || 0
  33171. } else
  33172. r = e,
  33173. t || (t = []);
  33174. for (var s = 0; s < n && i["LIGHT" + s]; s++)
  33175. this.PrepareUniformsAndSamplersForLight(s, r, t, i["PROJECTEDLIGHTTEXTURE" + s], o);
  33176. i.NUM_MORPH_INFLUENCERS && r.push("morphTargetInfluences"),
  33177. i.BAKED_VERTEX_ANIMATION_TEXTURE && (r.push("bakedVertexAnimationSettings"),
  33178. r.push("bakedVertexAnimationTextureSizeInverted"),
  33179. r.push("bakedVertexAnimationTime"),
  33180. t.push("bakedVertexAnimationTexture"))
  33181. }
  33182. ,
  33183. e.HandleFallbacksForShadows = function(e, t, i, n) {
  33184. void 0 === i && (i = 4),
  33185. void 0 === n && (n = 0);
  33186. for (var r = 0, o = 0; o < i && e["LIGHT" + o]; o++)
  33187. o > 0 && (r = n + o,
  33188. t.addFallback(r, "LIGHT" + o)),
  33189. e.SHADOWS || (e["SHADOW" + o] && t.addFallback(n, "SHADOW" + o),
  33190. e["SHADOWPCF" + o] && t.addFallback(n, "SHADOWPCF" + o),
  33191. e["SHADOWPCSS" + o] && t.addFallback(n, "SHADOWPCSS" + o),
  33192. e["SHADOWPOISSON" + o] && t.addFallback(n, "SHADOWPOISSON" + o),
  33193. e["SHADOWESM" + o] && t.addFallback(n, "SHADOWESM" + o),
  33194. e["SHADOWCLOSEESM" + o] && t.addFallback(n, "SHADOWCLOSEESM" + o));
  33195. return r++
  33196. }
  33197. ,
  33198. e.PrepareAttributesForMorphTargetsInfluencers = function(e, t, i) {
  33199. this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = i,
  33200. this.PrepareAttributesForMorphTargets(e, t, this._TmpMorphInfluencers)
  33201. }
  33202. ,
  33203. e.PrepareAttributesForMorphTargets = function(e, t, i) {
  33204. var n = i.NUM_MORPH_INFLUENCERS;
  33205. if (n > 0 && E.LastCreatedEngine) {
  33206. var r = E.LastCreatedEngine.getCaps().maxVertexAttribs
  33207. , o = t.morphTargetManager;
  33208. if (null == o ? void 0 : o.isUsingTextureForTargets)
  33209. return;
  33210. for (var a = o && o.supportsNormals && i.NORMAL, s = o && o.supportsTangents && i.TANGENT, l = o && o.supportsUVs && i.UV1, c = 0; c < n; c++)
  33211. e.push(Bi.PositionKind + c),
  33212. a && e.push(Bi.NormalKind + c),
  33213. s && e.push(Bi.TangentKind + c),
  33214. l && e.push(Bi.UVKind + "_" + c),
  33215. e.length > r && K.Error("Cannot add more vertex attributes for mesh " + t.name)
  33216. }
  33217. }
  33218. ,
  33219. e.PrepareAttributesForBakedVertexAnimation = function(e, t, i) {
  33220. i.BAKED_VERTEX_ANIMATION_TEXTURE && i.INSTANCES && e.push("bakedVertexAnimationSettingsInstanced")
  33221. }
  33222. ,
  33223. e.PrepareAttributesForBones = function(e, t, i, n) {
  33224. i.NUM_BONE_INFLUENCERS > 0 && (n.addCPUSkinningFallback(0, t),
  33225. e.push(Bi.MatricesIndicesKind),
  33226. e.push(Bi.MatricesWeightsKind),
  33227. i.NUM_BONE_INFLUENCERS > 4 && (e.push(Bi.MatricesIndicesExtraKind),
  33228. e.push(Bi.MatricesWeightsExtraKind)))
  33229. }
  33230. ,
  33231. e.PrepareAttributesForInstances = function(e, t) {
  33232. (t.INSTANCES || t.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!t.PREPASS_VELOCITY)
  33233. }
  33234. ,
  33235. e.PushAttributesForInstances = function(e, t) {
  33236. void 0 === t && (t = !1),
  33237. e.push("world0"),
  33238. e.push("world1"),
  33239. e.push("world2"),
  33240. e.push("world3"),
  33241. t && (e.push("previousWorld0"),
  33242. e.push("previousWorld1"),
  33243. e.push("previousWorld2"),
  33244. e.push("previousWorld3"))
  33245. }
  33246. ,
  33247. e.BindLightProperties = function(e, t, i) {
  33248. e.transferToEffect(t, i + "")
  33249. }
  33250. ,
  33251. e.BindLight = function(e, t, i, n, r, o) {
  33252. void 0 === o && (o = !0),
  33253. e._bindLight(t, i, n, r, o)
  33254. }
  33255. ,
  33256. e.BindLights = function(e, t, i, n, r) {
  33257. void 0 === r && (r = 4);
  33258. for (var o = Math.min(t.lightSources.length, r), a = 0; a < o; a++) {
  33259. var s = t.lightSources[a];
  33260. this.BindLight(s, a, e, i, "boolean" == typeof n ? n : n.SPECULARTERM, t.receiveShadows)
  33261. }
  33262. }
  33263. ,
  33264. e.BindFogParameters = function(e, t, i, n) {
  33265. void 0 === n && (n = !1),
  33266. e.fogEnabled && t.applyFog && e.fogMode !== mn.FOGMODE_NONE && (i.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
  33267. n ? (e.fogColor.toLinearSpaceToRef(this._TempFogColor),
  33268. i.setColor3("vFogColor", this._TempFogColor)) : i.setColor3("vFogColor", e.fogColor))
  33269. }
  33270. ,
  33271. e.BindBonesParameters = function(t, i, n) {
  33272. if (i && t && (t.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (t.computeBonesUsingShaders = !1),
  33273. t.useBones && t.computeBonesUsingShaders && t.skeleton)) {
  33274. var r = t.skeleton;
  33275. if (r.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -1) {
  33276. var o = r.getTransformMatrixTexture(t);
  33277. i.setTexture("boneSampler", o),
  33278. i.setFloat("boneTextureWidth", 4 * (r.bones.length + 1))
  33279. } else {
  33280. var s = r.getTransformMatrices(t);
  33281. s && (i.setMatrices("mBones", s),
  33282. n && t.getScene().prePassRenderer && t.getScene().prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE) && (n.previousBones[t.uniqueId] || (n.previousBones[t.uniqueId] = s.slice()),
  33283. i.setMatrices("mPreviousBones", n.previousBones[t.uniqueId]),
  33284. e._CopyBonesTransformationMatrices(s, n.previousBones[t.uniqueId])))
  33285. }
  33286. }
  33287. }
  33288. ,
  33289. e._CopyBonesTransformationMatrices = function(e, t) {
  33290. return t.set(e),
  33291. t
  33292. }
  33293. ,
  33294. e.BindMorphTargetParameters = function(e, t) {
  33295. var i = e.morphTargetManager;
  33296. e && i && t.setFloatArray("morphTargetInfluences", i.influences)
  33297. }
  33298. ,
  33299. e.BindLogDepth = function(e, t, i) {
  33300. if (!e || e.LOGARITHMICDEPTH) {
  33301. var n = i.activeCamera;
  33302. n.mode === Rr.ORTHOGRAPHIC_CAMERA && K.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
  33303. t.setFloat("logarithmicDepthConstant", 2 / (Math.log(n.maxZ + 1) / Math.LN2))
  33304. }
  33305. }
  33306. ,
  33307. e.BindClipPlane = function(e, t) {
  33308. Pr.BindClipPlane(e, t)
  33309. }
  33310. ,
  33311. e._TmpMorphInfluencers = {
  33312. NUM_MORPH_INFLUENCERS: 0
  33313. },
  33314. e._TempFogColor = D.Black(),
  33315. e
  33316. }(), Ir = function() {
  33317. function e() {
  33318. this.reset()
  33319. }
  33320. return e.prototype.reset = function() {
  33321. this.enabled = !1,
  33322. this.mask = 255,
  33323. this.func = a.ALWAYS,
  33324. this.funcRef = 1,
  33325. this.funcMask = 255,
  33326. this.opStencilFail = a.KEEP,
  33327. this.opDepthFail = a.KEEP,
  33328. this.opStencilDepthPass = a.REPLACE
  33329. }
  33330. ,
  33331. Object.defineProperty(e.prototype, "func", {
  33332. get: function() {
  33333. return this._func
  33334. },
  33335. set: function(e) {
  33336. this._func = e
  33337. },
  33338. enumerable: !1,
  33339. configurable: !0
  33340. }),
  33341. Object.defineProperty(e.prototype, "funcRef", {
  33342. get: function() {
  33343. return this._funcRef
  33344. },
  33345. set: function(e) {
  33346. this._funcRef = e
  33347. },
  33348. enumerable: !1,
  33349. configurable: !0
  33350. }),
  33351. Object.defineProperty(e.prototype, "funcMask", {
  33352. get: function() {
  33353. return this._funcMask
  33354. },
  33355. set: function(e) {
  33356. this._funcMask = e
  33357. },
  33358. enumerable: !1,
  33359. configurable: !0
  33360. }),
  33361. Object.defineProperty(e.prototype, "opStencilFail", {
  33362. get: function() {
  33363. return this._opStencilFail
  33364. },
  33365. set: function(e) {
  33366. this._opStencilFail = e
  33367. },
  33368. enumerable: !1,
  33369. configurable: !0
  33370. }),
  33371. Object.defineProperty(e.prototype, "opDepthFail", {
  33372. get: function() {
  33373. return this._opDepthFail
  33374. },
  33375. set: function(e) {
  33376. this._opDepthFail = e
  33377. },
  33378. enumerable: !1,
  33379. configurable: !0
  33380. }),
  33381. Object.defineProperty(e.prototype, "opStencilDepthPass", {
  33382. get: function() {
  33383. return this._opStencilDepthPass
  33384. },
  33385. set: function(e) {
  33386. this._opStencilDepthPass = e
  33387. },
  33388. enumerable: !1,
  33389. configurable: !0
  33390. }),
  33391. Object.defineProperty(e.prototype, "mask", {
  33392. get: function() {
  33393. return this._mask
  33394. },
  33395. set: function(e) {
  33396. this._mask = e
  33397. },
  33398. enumerable: !1,
  33399. configurable: !0
  33400. }),
  33401. Object.defineProperty(e.prototype, "enabled", {
  33402. get: function() {
  33403. return this._enabled
  33404. },
  33405. set: function(e) {
  33406. this._enabled = e
  33407. },
  33408. enumerable: !1,
  33409. configurable: !0
  33410. }),
  33411. e.prototype.getClassName = function() {
  33412. return "MaterialStencilState"
  33413. }
  33414. ,
  33415. e.prototype.copyTo = function(e) {
  33416. Ge.Clone((function() {
  33417. return e
  33418. }
  33419. ), this)
  33420. }
  33421. ,
  33422. e.prototype.serialize = function() {
  33423. return Ge.Serialize(this)
  33424. }
  33425. ,
  33426. e.prototype.parse = function(e, t, i) {
  33427. var n = this;
  33428. Ge.Parse((function() {
  33429. return n
  33430. }
  33431. ), e, t, i)
  33432. }
  33433. ,
  33434. k([Ce()], e.prototype, "func", null),
  33435. k([Ce()], e.prototype, "funcRef", null),
  33436. k([Ce()], e.prototype, "funcMask", null),
  33437. k([Ce()], e.prototype, "opStencilFail", null),
  33438. k([Ce()], e.prototype, "opDepthFail", null),
  33439. k([Ce()], e.prototype, "opStencilDepthPass", null),
  33440. k([Ce()], e.prototype, "mask", null),
  33441. k([Ce()], e.prototype, "enabled", null),
  33442. e
  33443. }();
  33444. !function(e) {
  33445. e[e.Created = 1] = "Created",
  33446. e[e.Disposed = 2] = "Disposed",
  33447. e[e.GetDefineNames = 4] = "GetDefineNames",
  33448. e[e.PrepareUniformBuffer = 8] = "PrepareUniformBuffer",
  33449. e[e.IsReadyForSubMesh = 16] = "IsReadyForSubMesh",
  33450. e[e.PrepareDefines = 32] = "PrepareDefines",
  33451. e[e.BindForSubMesh = 64] = "BindForSubMesh",
  33452. e[e.PrepareEffect = 128] = "PrepareEffect",
  33453. e[e.GetAnimatables = 256] = "GetAnimatables",
  33454. e[e.GetActiveTextures = 512] = "GetActiveTextures",
  33455. e[e.HasTexture = 1024] = "HasTexture",
  33456. e[e.FillRenderTargetTextures = 2048] = "FillRenderTargetTextures",
  33457. e[e.HasRenderTargetTextures = 4096] = "HasRenderTargetTextures",
  33458. e[e.HardBindForSubMesh = 8192] = "HardBindForSubMesh"
  33459. }(Ar || (Ar = {}));
  33460. var Or = function() {
  33461. function e(t, i, n) {
  33462. this.shadowDepthWrapper = null,
  33463. this.allowShaderHotSwapping = !0,
  33464. this.metadata = null,
  33465. this.reservedDataStore = null,
  33466. this.checkReadyOnEveryCall = !1,
  33467. this.checkReadyOnlyOnce = !1,
  33468. this.state = "",
  33469. this._alpha = 1,
  33470. this._backFaceCulling = !0,
  33471. this._cullBackFaces = !0,
  33472. this.onCompiled = null,
  33473. this.onError = null,
  33474. this.getRenderTargetTextures = null,
  33475. this.doNotSerialize = !1,
  33476. this._storeEffectOnSubMeshes = !1,
  33477. this.animations = null,
  33478. this.onDisposeObservable = new h,
  33479. this._onDisposeObserver = null,
  33480. this._onUnBindObservable = null,
  33481. this._onBindObserver = null,
  33482. this._alphaMode = a.ALPHA_COMBINE,
  33483. this._needDepthPrePass = !1,
  33484. this.disableDepthWrite = !1,
  33485. this.disableColorWrite = !1,
  33486. this.forceDepthWrite = !1,
  33487. this.depthFunction = 0,
  33488. this.separateCullingPass = !1,
  33489. this._fogEnabled = !0,
  33490. this.pointSize = 1,
  33491. this.zOffset = 0,
  33492. this.zOffsetUnits = 0,
  33493. this.stencil = new Ir,
  33494. this._useUBO = !1,
  33495. this._fillMode = e.TriangleFillMode,
  33496. this._cachedDepthWriteState = !1,
  33497. this._cachedColorWriteState = !1,
  33498. this._cachedDepthFunctionState = 0,
  33499. this._indexInSceneMaterialArray = -1,
  33500. this.meshMap = null,
  33501. this._parentContainer = null,
  33502. this._uniformBufferLayoutBuilt = !1,
  33503. this._eventInfo = {},
  33504. this._callbackPluginEventGeneric = function() {}
  33505. ,
  33506. this._callbackPluginEventIsReadyForSubMesh = function() {}
  33507. ,
  33508. this._callbackPluginEventPrepareDefines = function() {}
  33509. ,
  33510. this._callbackPluginEventHardBindForSubMesh = function() {}
  33511. ,
  33512. this._callbackPluginEventBindForSubMesh = function() {}
  33513. ,
  33514. this._callbackPluginEventHasRenderTargetTextures = function() {}
  33515. ,
  33516. this._callbackPluginEventFillRenderTargetTextures = function() {}
  33517. ,
  33518. this._forceAlphaTest = !1,
  33519. this._transparencyMode = null,
  33520. this.name = t;
  33521. var r = i || E.LastCreatedScene;
  33522. r && (this._scene = r,
  33523. this._dirtyCallbacks = {},
  33524. this._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag] = this._markAllSubMeshesAsTexturesDirty.bind(this),
  33525. this._dirtyCallbacks[a.MATERIAL_LightDirtyFlag] = this._markAllSubMeshesAsLightsDirty.bind(this),
  33526. this._dirtyCallbacks[a.MATERIAL_FresnelDirtyFlag] = this._markAllSubMeshesAsFresnelDirty.bind(this),
  33527. this._dirtyCallbacks[a.MATERIAL_AttributesDirtyFlag] = this._markAllSubMeshesAsAttributesDirty.bind(this),
  33528. this._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag] = this._markAllSubMeshesAsMiscDirty.bind(this),
  33529. this._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag] = this._markAllSubMeshesAsPrePassDirty.bind(this),
  33530. this._dirtyCallbacks[a.MATERIAL_AllDirtyFlag] = this._markAllSubMeshesAsAllDirty.bind(this),
  33531. this.id = t || gi.RandomId(),
  33532. this.uniqueId = this._scene.getUniqueId(),
  33533. this._materialContext = this._scene.getEngine().createMaterialContext(),
  33534. this._drawWrapper = new Gt(this._scene.getEngine(),!1),
  33535. this._drawWrapper.materialContext = this._materialContext,
  33536. this._scene.useRightHandedSystem ? this.sideOrientation = e.ClockWiseSideOrientation : this.sideOrientation = e.CounterClockWiseSideOrientation,
  33537. this._uniformBuffer = new Fi(this._scene.getEngine(),void 0,void 0,t),
  33538. this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
  33539. n || this._scene.addMaterial(this),
  33540. this._scene.useMaterialMeshMap && (this.meshMap = {}),
  33541. e.OnEventObservable.notifyObservers(this, Ar.Created))
  33542. }
  33543. return Object.defineProperty(e.prototype, "canRenderToMRT", {
  33544. get: function() {
  33545. return !1
  33546. },
  33547. enumerable: !1,
  33548. configurable: !0
  33549. }),
  33550. Object.defineProperty(e.prototype, "alpha", {
  33551. get: function() {
  33552. return this._alpha
  33553. },
  33554. set: function(t) {
  33555. this._alpha !== t && (this._alpha = t,
  33556. this.markAsDirty(e.MiscDirtyFlag))
  33557. },
  33558. enumerable: !1,
  33559. configurable: !0
  33560. }),
  33561. Object.defineProperty(e.prototype, "backFaceCulling", {
  33562. get: function() {
  33563. return this._backFaceCulling
  33564. },
  33565. set: function(t) {
  33566. this._backFaceCulling !== t && (this._backFaceCulling = t,
  33567. this.markAsDirty(e.TextureDirtyFlag))
  33568. },
  33569. enumerable: !1,
  33570. configurable: !0
  33571. }),
  33572. Object.defineProperty(e.prototype, "cullBackFaces", {
  33573. get: function() {
  33574. return this._cullBackFaces
  33575. },
  33576. set: function(t) {
  33577. this._cullBackFaces !== t && (this._cullBackFaces = t,
  33578. this.markAsDirty(e.TextureDirtyFlag))
  33579. },
  33580. enumerable: !1,
  33581. configurable: !0
  33582. }),
  33583. Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
  33584. get: function() {
  33585. return this._eventInfo.hasRenderTargetTextures = !1,
  33586. this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
  33587. this._eventInfo.hasRenderTargetTextures
  33588. },
  33589. enumerable: !1,
  33590. configurable: !0
  33591. }),
  33592. Object.defineProperty(e.prototype, "onDispose", {
  33593. set: function(e) {
  33594. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  33595. this._onDisposeObserver = this.onDisposeObservable.add(e)
  33596. },
  33597. enumerable: !1,
  33598. configurable: !0
  33599. }),
  33600. Object.defineProperty(e.prototype, "onBindObservable", {
  33601. get: function() {
  33602. return this._onBindObservable || (this._onBindObservable = new h),
  33603. this._onBindObservable
  33604. },
  33605. enumerable: !1,
  33606. configurable: !0
  33607. }),
  33608. Object.defineProperty(e.prototype, "onBind", {
  33609. set: function(e) {
  33610. this._onBindObserver && this.onBindObservable.remove(this._onBindObserver),
  33611. this._onBindObserver = this.onBindObservable.add(e)
  33612. },
  33613. enumerable: !1,
  33614. configurable: !0
  33615. }),
  33616. Object.defineProperty(e.prototype, "onUnBindObservable", {
  33617. get: function() {
  33618. return this._onUnBindObservable || (this._onUnBindObservable = new h),
  33619. this._onUnBindObservable
  33620. },
  33621. enumerable: !1,
  33622. configurable: !0
  33623. }),
  33624. Object.defineProperty(e.prototype, "onEffectCreatedObservable", {
  33625. get: function() {
  33626. return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new h),
  33627. this._onEffectCreatedObservable
  33628. },
  33629. enumerable: !1,
  33630. configurable: !0
  33631. }),
  33632. Object.defineProperty(e.prototype, "alphaMode", {
  33633. get: function() {
  33634. return this._alphaMode
  33635. },
  33636. set: function(t) {
  33637. this._alphaMode !== t && (this._alphaMode = t,
  33638. this.markAsDirty(e.TextureDirtyFlag))
  33639. },
  33640. enumerable: !1,
  33641. configurable: !0
  33642. }),
  33643. Object.defineProperty(e.prototype, "needDepthPrePass", {
  33644. get: function() {
  33645. return this._needDepthPrePass
  33646. },
  33647. set: function(e) {
  33648. this._needDepthPrePass !== e && (this._needDepthPrePass = e,
  33649. this._needDepthPrePass && (this.checkReadyOnEveryCall = !0))
  33650. },
  33651. enumerable: !1,
  33652. configurable: !0
  33653. }),
  33654. Object.defineProperty(e.prototype, "isPrePassCapable", {
  33655. get: function() {
  33656. return !1
  33657. },
  33658. enumerable: !1,
  33659. configurable: !0
  33660. }),
  33661. Object.defineProperty(e.prototype, "fogEnabled", {
  33662. get: function() {
  33663. return this._fogEnabled
  33664. },
  33665. set: function(t) {
  33666. this._fogEnabled !== t && (this._fogEnabled = t,
  33667. this.markAsDirty(e.MiscDirtyFlag))
  33668. },
  33669. enumerable: !1,
  33670. configurable: !0
  33671. }),
  33672. Object.defineProperty(e.prototype, "wireframe", {
  33673. get: function() {
  33674. switch (this._fillMode) {
  33675. case e.WireFrameFillMode:
  33676. case e.LineListDrawMode:
  33677. case e.LineLoopDrawMode:
  33678. case e.LineStripDrawMode:
  33679. return !0
  33680. }
  33681. return this._scene.forceWireframe
  33682. },
  33683. set: function(t) {
  33684. this.fillMode = t ? e.WireFrameFillMode : e.TriangleFillMode
  33685. },
  33686. enumerable: !1,
  33687. configurable: !0
  33688. }),
  33689. Object.defineProperty(e.prototype, "pointsCloud", {
  33690. get: function() {
  33691. switch (this._fillMode) {
  33692. case e.PointFillMode:
  33693. case e.PointListDrawMode:
  33694. return !0
  33695. }
  33696. return this._scene.forcePointsCloud
  33697. },
  33698. set: function(t) {
  33699. this.fillMode = t ? e.PointFillMode : e.TriangleFillMode
  33700. },
  33701. enumerable: !1,
  33702. configurable: !0
  33703. }),
  33704. Object.defineProperty(e.prototype, "fillMode", {
  33705. get: function() {
  33706. return this._fillMode
  33707. },
  33708. set: function(t) {
  33709. this._fillMode !== t && (this._fillMode = t,
  33710. this.markAsDirty(e.MiscDirtyFlag))
  33711. },
  33712. enumerable: !1,
  33713. configurable: !0
  33714. }),
  33715. e.prototype._getDrawWrapper = function() {
  33716. return this._drawWrapper
  33717. }
  33718. ,
  33719. e.prototype._setDrawWrapper = function(e) {
  33720. this._drawWrapper = e
  33721. }
  33722. ,
  33723. e.prototype.toString = function(e) {
  33724. return "Name: " + this.name
  33725. }
  33726. ,
  33727. e.prototype.getClassName = function() {
  33728. return "Material"
  33729. }
  33730. ,
  33731. Object.defineProperty(e.prototype, "isFrozen", {
  33732. get: function() {
  33733. return this.checkReadyOnlyOnce
  33734. },
  33735. enumerable: !1,
  33736. configurable: !0
  33737. }),
  33738. e.prototype.freeze = function() {
  33739. this.markDirty(),
  33740. this.checkReadyOnlyOnce = !0
  33741. }
  33742. ,
  33743. e.prototype.unfreeze = function() {
  33744. this.markDirty(),
  33745. this.checkReadyOnlyOnce = !1
  33746. }
  33747. ,
  33748. e.prototype.isReady = function(e, t) {
  33749. return !0
  33750. }
  33751. ,
  33752. e.prototype.isReadyForSubMesh = function(e, t, i) {
  33753. var n = t.materialDefines;
  33754. return !!n && (this._eventInfo.isReadyForSubMesh = !0,
  33755. this._eventInfo.defines = n,
  33756. this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
  33757. this._eventInfo.isReadyForSubMesh)
  33758. }
  33759. ,
  33760. e.prototype.getEffect = function() {
  33761. return this._drawWrapper.effect
  33762. }
  33763. ,
  33764. e.prototype.getScene = function() {
  33765. return this._scene
  33766. }
  33767. ,
  33768. Object.defineProperty(e.prototype, "transparencyMode", {
  33769. get: function() {
  33770. return this._transparencyMode
  33771. },
  33772. set: function(t) {
  33773. this._transparencyMode !== t && (this._transparencyMode = t,
  33774. this._forceAlphaTest = t === e.MATERIAL_ALPHATESTANDBLEND,
  33775. this._markAllSubMeshesAsTexturesAndMiscDirty())
  33776. },
  33777. enumerable: !1,
  33778. configurable: !0
  33779. }),
  33780. Object.defineProperty(e.prototype, "_disableAlphaBlending", {
  33781. get: function() {
  33782. return this._transparencyMode === e.MATERIAL_OPAQUE || this._transparencyMode === e.MATERIAL_ALPHATEST
  33783. },
  33784. enumerable: !1,
  33785. configurable: !0
  33786. }),
  33787. e.prototype.needAlphaBlending = function() {
  33788. return !this._disableAlphaBlending && this.alpha < 1
  33789. }
  33790. ,
  33791. e.prototype.needAlphaBlendingForMesh = function(e) {
  33792. return !(this._disableAlphaBlending && e.visibility >= 1) && (this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha)
  33793. }
  33794. ,
  33795. e.prototype.needAlphaTesting = function() {
  33796. return !!this._forceAlphaTest
  33797. }
  33798. ,
  33799. e.prototype._shouldTurnAlphaTestOn = function(e) {
  33800. return !this.needAlphaBlendingForMesh(e) && this.needAlphaTesting()
  33801. }
  33802. ,
  33803. e.prototype.getAlphaTestTexture = function() {
  33804. return null
  33805. }
  33806. ,
  33807. e.prototype.markDirty = function() {
  33808. for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
  33809. var i = t[e];
  33810. if (i.subMeshes)
  33811. for (var n = 0, r = i.subMeshes; n < r.length; n++) {
  33812. var o = r[n];
  33813. o.getMaterial() === this && o.effect && (o.effect._wasPreviouslyReady = !1)
  33814. }
  33815. }
  33816. }
  33817. ,
  33818. e.prototype._preBind = function(t, i) {
  33819. void 0 === i && (i = null);
  33820. var n = this._scene.getEngine()
  33821. , r = (null == i ? this.sideOrientation : i) === e.ClockWiseSideOrientation;
  33822. return n.enableEffect(t || this._getDrawWrapper()),
  33823. n.setState(this.backFaceCulling, this.zOffset, !1, r, this.cullBackFaces, this.stencil, this.zOffsetUnits),
  33824. r
  33825. }
  33826. ,
  33827. e.prototype.bind = function(e, t) {}
  33828. ,
  33829. e.prototype.buildUniformLayout = function() {
  33830. var e = this._uniformBuffer;
  33831. this._eventInfo.ubo = e,
  33832. this._callbackPluginEventGeneric(Ar.PrepareUniformBuffer, this._eventInfo),
  33833. e.create(),
  33834. this._uniformBufferLayoutBuilt = !0
  33835. }
  33836. ,
  33837. e.prototype.bindForSubMesh = function(e, t, i) {
  33838. i.effect && (this._eventInfo.subMesh = i,
  33839. this._callbackPluginEventBindForSubMesh(this._eventInfo))
  33840. }
  33841. ,
  33842. e.prototype.bindOnlyWorldMatrix = function(e) {}
  33843. ,
  33844. e.prototype.bindView = function(e) {
  33845. this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix())
  33846. }
  33847. ,
  33848. e.prototype.bindViewProjection = function(e) {
  33849. this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
  33850. e.setMatrix("projection", this.getScene().getProjectionMatrix()))
  33851. }
  33852. ,
  33853. e.prototype.bindEyePosition = function(e, t) {
  33854. this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, t)
  33855. }
  33856. ,
  33857. e.prototype._afterBind = function(e, t) {
  33858. if (void 0 === t && (t = null),
  33859. this._scene._cachedMaterial = this,
  33860. this._needToBindSceneUbo && t && (this._needToBindSceneUbo = !1,
  33861. Mr.BindSceneUniformBuffer(t, this.getScene().getSceneUniformBuffer()),
  33862. this._scene.finalizeSceneUbo()),
  33863. this._scene._cachedVisibility = e ? e.visibility : 1,
  33864. this._onBindObservable && e && this._onBindObservable.notifyObservers(e),
  33865. this.disableDepthWrite) {
  33866. var i = this._scene.getEngine();
  33867. this._cachedDepthWriteState = i.getDepthWrite(),
  33868. i.setDepthWrite(!1)
  33869. }
  33870. this.disableColorWrite && (i = this._scene.getEngine(),
  33871. this._cachedColorWriteState = i.getColorWrite(),
  33872. i.setColorWrite(!1)),
  33873. 0 !== this.depthFunction && (i = this._scene.getEngine(),
  33874. this._cachedDepthFunctionState = i.getDepthFunction() || 0,
  33875. i.setDepthFunction(this.depthFunction))
  33876. }
  33877. ,
  33878. e.prototype.unbind = function() {
  33879. this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this),
  33880. 0 !== this.depthFunction && this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),
  33881. this.disableDepthWrite && this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),
  33882. this.disableColorWrite && this._scene.getEngine().setColorWrite(this._cachedColorWriteState)
  33883. }
  33884. ,
  33885. e.prototype.getAnimatables = function() {
  33886. return this._eventInfo.animatables = [],
  33887. this._callbackPluginEventGeneric(Ar.GetAnimatables, this._eventInfo),
  33888. this._eventInfo.animatables
  33889. }
  33890. ,
  33891. e.prototype.getActiveTextures = function() {
  33892. return this._eventInfo.activeTextures = [],
  33893. this._callbackPluginEventGeneric(Ar.GetActiveTextures, this._eventInfo),
  33894. this._eventInfo.activeTextures
  33895. }
  33896. ,
  33897. e.prototype.hasTexture = function(e) {
  33898. return this._eventInfo.hasTexture = !1,
  33899. this._eventInfo.texture = e,
  33900. this._callbackPluginEventGeneric(Ar.HasTexture, this._eventInfo),
  33901. this._eventInfo.hasTexture
  33902. }
  33903. ,
  33904. e.prototype.clone = function(e) {
  33905. return null
  33906. }
  33907. ,
  33908. e.prototype.getBindedMeshes = function() {
  33909. var e = this;
  33910. if (this.meshMap) {
  33911. var t = new Array;
  33912. for (var i in this.meshMap) {
  33913. var n = this.meshMap[i];
  33914. n && t.push(n)
  33915. }
  33916. return t
  33917. }
  33918. return this._scene.meshes.filter((function(t) {
  33919. return t.material === e
  33920. }
  33921. ))
  33922. }
  33923. ,
  33924. e.prototype.forceCompilation = function(e, t, i, n) {
  33925. var r = this
  33926. , o = V({
  33927. clipPlane: !1,
  33928. useInstances: !1
  33929. }, i)
  33930. , a = this.getScene()
  33931. , s = this.allowShaderHotSwapping;
  33932. this.allowShaderHotSwapping = !1;
  33933. var l = function() {
  33934. if (r._scene && r._scene.getEngine()) {
  33935. var i = a.clipPlane;
  33936. if (o.clipPlane && (a.clipPlane = new hn(0,0,0,1)),
  33937. r._storeEffectOnSubMeshes) {
  33938. var c = !0
  33939. , u = null;
  33940. if (e.subMeshes) {
  33941. var h = new hr(0,0,0,0,0,e,void 0,!1,!1);
  33942. h.materialDefines && (h.materialDefines._renderId = -1),
  33943. r.isReadyForSubMesh(e, h, o.useInstances) || (h.effect && h.effect.getCompilationError() && h.effect.allFallbacksProcessed() ? u = h.effect.getCompilationError() : (c = !1,
  33944. setTimeout(l, 16)))
  33945. }
  33946. c && (r.allowShaderHotSwapping = s,
  33947. u && n && n(u),
  33948. t && t(r))
  33949. } else
  33950. r.isReady() ? (r.allowShaderHotSwapping = s,
  33951. t && t(r)) : setTimeout(l, 16);
  33952. o.clipPlane && (a.clipPlane = i)
  33953. }
  33954. };
  33955. l()
  33956. }
  33957. ,
  33958. e.prototype.forceCompilationAsync = function(e, t) {
  33959. var i = this;
  33960. return new Promise((function(n, r) {
  33961. i.forceCompilation(e, (function() {
  33962. n()
  33963. }
  33964. ), t, (function(e) {
  33965. r(e)
  33966. }
  33967. ))
  33968. }
  33969. ))
  33970. }
  33971. ,
  33972. e.prototype.markAsDirty = function(t) {
  33973. this.getScene().blockMaterialDirtyMechanism || (e._DirtyCallbackArray.length = 0,
  33974. t & e.TextureDirtyFlag && e._DirtyCallbackArray.push(e._TextureDirtyCallBack),
  33975. t & e.LightDirtyFlag && e._DirtyCallbackArray.push(e._LightsDirtyCallBack),
  33976. t & e.FresnelDirtyFlag && e._DirtyCallbackArray.push(e._FresnelDirtyCallBack),
  33977. t & e.AttributesDirtyFlag && e._DirtyCallbackArray.push(e._AttributeDirtyCallBack),
  33978. t & e.MiscDirtyFlag && e._DirtyCallbackArray.push(e._MiscDirtyCallBack),
  33979. t & e.PrePassDirtyFlag && e._DirtyCallbackArray.push(e._PrePassDirtyCallBack),
  33980. e._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(e._RunDirtyCallBacks),
  33981. this.getScene().resetCachedMaterial())
  33982. }
  33983. ,
  33984. e.prototype.resetDrawCache = function() {
  33985. for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
  33986. var i = t[e];
  33987. if (i.subMeshes)
  33988. for (var n = 0, r = i.subMeshes; n < r.length; n++) {
  33989. var o = r[n];
  33990. o.getMaterial() === this && o.resetDrawCache()
  33991. }
  33992. }
  33993. }
  33994. ,
  33995. e.prototype._markAllSubMeshesAsDirty = function(e) {
  33996. if (!this.getScene().blockMaterialDirtyMechanism)
  33997. for (var t = 0, i = this.getScene().meshes; t < i.length; t++) {
  33998. var n = i[t];
  33999. if (n.subMeshes)
  34000. for (var r = 0, o = n.subMeshes; r < o.length; r++) {
  34001. var a = o[r];
  34002. if (0 !== n._renderId && a.getMaterial() === this)
  34003. for (var s = 0, l = a._drawWrappers; s < l.length; s++) {
  34004. var c = l[s];
  34005. c && c.defines && c.defines.markAllAsDirty && this._materialContext === c.materialContext && e(c.defines)
  34006. }
  34007. }
  34008. }
  34009. }
  34010. ,
  34011. e.prototype._markScenePrePassDirty = function() {
  34012. if (!this.getScene().blockMaterialDirtyMechanism) {
  34013. var e = this.getScene().enablePrePassRenderer();
  34014. e && e.markAsDirty()
  34015. }
  34016. }
  34017. ,
  34018. e.prototype._markAllSubMeshesAsAllDirty = function() {
  34019. this._markAllSubMeshesAsDirty(e._AllDirtyCallBack)
  34020. }
  34021. ,
  34022. e.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
  34023. this._markAllSubMeshesAsDirty(e._ImageProcessingDirtyCallBack)
  34024. }
  34025. ,
  34026. e.prototype._markAllSubMeshesAsTexturesDirty = function() {
  34027. this._markAllSubMeshesAsDirty(e._TextureDirtyCallBack)
  34028. }
  34029. ,
  34030. e.prototype._markAllSubMeshesAsFresnelDirty = function() {
  34031. this._markAllSubMeshesAsDirty(e._FresnelDirtyCallBack)
  34032. }
  34033. ,
  34034. e.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
  34035. this._markAllSubMeshesAsDirty(e._FresnelAndMiscDirtyCallBack)
  34036. }
  34037. ,
  34038. e.prototype._markAllSubMeshesAsLightsDirty = function() {
  34039. this._markAllSubMeshesAsDirty(e._LightsDirtyCallBack)
  34040. }
  34041. ,
  34042. e.prototype._markAllSubMeshesAsAttributesDirty = function() {
  34043. this._markAllSubMeshesAsDirty(e._AttributeDirtyCallBack)
  34044. }
  34045. ,
  34046. e.prototype._markAllSubMeshesAsMiscDirty = function() {
  34047. this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)
  34048. }
  34049. ,
  34050. e.prototype._markAllSubMeshesAsPrePassDirty = function() {
  34051. this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)
  34052. }
  34053. ,
  34054. e.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
  34055. this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack)
  34056. }
  34057. ,
  34058. e.prototype.setPrePassRenderer = function(e) {
  34059. return !1
  34060. }
  34061. ,
  34062. e.prototype.dispose = function(e, t, i) {
  34063. var n = this.getScene();
  34064. if (n.stopAnimation(this),
  34065. n.freeProcessedMaterials(),
  34066. n.removeMaterial(this),
  34067. this._eventInfo.forceDisposeTextures = t,
  34068. this._callbackPluginEventGeneric(Ar.Disposed, this._eventInfo),
  34069. this._parentContainer) {
  34070. var r = this._parentContainer.materials.indexOf(this);
  34071. r > -1 && this._parentContainer.materials.splice(r, 1),
  34072. this._parentContainer = null
  34073. }
  34074. if (!0 !== i)
  34075. if (this.meshMap)
  34076. for (var o in this.meshMap)
  34077. (l = this.meshMap[o]) && (l.material = null,
  34078. this.releaseVertexArrayObject(l, e));
  34079. else
  34080. for (var a = 0, s = n.meshes; a < s.length; a++) {
  34081. var l;
  34082. (l = s[a]).material !== this || l.sourceMesh || (l.material = null,
  34083. this.releaseVertexArrayObject(l, e))
  34084. }
  34085. this._uniformBuffer.dispose(),
  34086. e && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(),
  34087. this._drawWrapper.effect = null),
  34088. this.metadata = null,
  34089. this.onDisposeObservable.notifyObservers(this),
  34090. this.onDisposeObservable.clear(),
  34091. this._onBindObservable && this._onBindObservable.clear(),
  34092. this._onUnBindObservable && this._onUnBindObservable.clear(),
  34093. this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear()
  34094. }
  34095. ,
  34096. e.prototype.releaseVertexArrayObject = function(e, t) {
  34097. if (e.geometry) {
  34098. var i = e.geometry;
  34099. if (this._storeEffectOnSubMeshes)
  34100. for (var n = 0, r = e.subMeshes; n < r.length; n++) {
  34101. var o = r[n];
  34102. i._releaseVertexArrayObject(o.effect),
  34103. t && o.effect && o.effect.dispose()
  34104. }
  34105. else
  34106. i._releaseVertexArrayObject(this._drawWrapper.effect)
  34107. }
  34108. }
  34109. ,
  34110. e.prototype.serialize = function() {
  34111. var e = Ge.Serialize(this);
  34112. return e.stencil = this.stencil.serialize(),
  34113. e.uniqueId = this.uniqueId,
  34114. e
  34115. }
  34116. ,
  34117. e.Parse = function(e, t, i) {
  34118. if (e.customType) {
  34119. if ("BABYLON.PBRMaterial" === e.customType && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
  34120. !BABYLON.LegacyPBRMaterial))
  34121. return K.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),
  34122. null
  34123. } else
  34124. e.customType = "BABYLON.StandardMaterial";
  34125. var n = gi.Instantiate(e.customType).Parse(e, t, i);
  34126. return n._loadedUniqueId = e.uniqueId,
  34127. n
  34128. }
  34129. ,
  34130. e.TriangleFillMode = a.MATERIAL_TriangleFillMode,
  34131. e.WireFrameFillMode = a.MATERIAL_WireFrameFillMode,
  34132. e.PointFillMode = a.MATERIAL_PointFillMode,
  34133. e.PointListDrawMode = a.MATERIAL_PointListDrawMode,
  34134. e.LineListDrawMode = a.MATERIAL_LineListDrawMode,
  34135. e.LineLoopDrawMode = a.MATERIAL_LineLoopDrawMode,
  34136. e.LineStripDrawMode = a.MATERIAL_LineStripDrawMode,
  34137. e.TriangleStripDrawMode = a.MATERIAL_TriangleStripDrawMode,
  34138. e.TriangleFanDrawMode = a.MATERIAL_TriangleFanDrawMode,
  34139. e.ClockWiseSideOrientation = a.MATERIAL_ClockWiseSideOrientation,
  34140. e.CounterClockWiseSideOrientation = a.MATERIAL_CounterClockWiseSideOrientation,
  34141. e.TextureDirtyFlag = a.MATERIAL_TextureDirtyFlag,
  34142. e.LightDirtyFlag = a.MATERIAL_LightDirtyFlag,
  34143. e.FresnelDirtyFlag = a.MATERIAL_FresnelDirtyFlag,
  34144. e.AttributesDirtyFlag = a.MATERIAL_AttributesDirtyFlag,
  34145. e.MiscDirtyFlag = a.MATERIAL_MiscDirtyFlag,
  34146. e.PrePassDirtyFlag = a.MATERIAL_PrePassDirtyFlag,
  34147. e.AllDirtyFlag = a.MATERIAL_AllDirtyFlag,
  34148. e.MATERIAL_OPAQUE = 0,
  34149. e.MATERIAL_ALPHATEST = 1,
  34150. e.MATERIAL_ALPHABLEND = 2,
  34151. e.MATERIAL_ALPHATESTANDBLEND = 3,
  34152. e.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
  34153. e.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
  34154. e.OnEventObservable = new h,
  34155. e._AllDirtyCallBack = function(e) {
  34156. return e.markAllAsDirty()
  34157. }
  34158. ,
  34159. e._ImageProcessingDirtyCallBack = function(e) {
  34160. return e.markAsImageProcessingDirty()
  34161. }
  34162. ,
  34163. e._TextureDirtyCallBack = function(e) {
  34164. return e.markAsTexturesDirty()
  34165. }
  34166. ,
  34167. e._FresnelDirtyCallBack = function(e) {
  34168. return e.markAsFresnelDirty()
  34169. }
  34170. ,
  34171. e._MiscDirtyCallBack = function(e) {
  34172. return e.markAsMiscDirty()
  34173. }
  34174. ,
  34175. e._PrePassDirtyCallBack = function(e) {
  34176. return e.markAsPrePassDirty()
  34177. }
  34178. ,
  34179. e._LightsDirtyCallBack = function(e) {
  34180. return e.markAsLightDirty()
  34181. }
  34182. ,
  34183. e._AttributeDirtyCallBack = function(e) {
  34184. return e.markAsAttributesDirty()
  34185. }
  34186. ,
  34187. e._FresnelAndMiscDirtyCallBack = function(t) {
  34188. e._FresnelDirtyCallBack(t),
  34189. e._MiscDirtyCallBack(t)
  34190. }
  34191. ,
  34192. e._TextureAndMiscDirtyCallBack = function(t) {
  34193. e._TextureDirtyCallBack(t),
  34194. e._MiscDirtyCallBack(t)
  34195. }
  34196. ,
  34197. e._DirtyCallbackArray = [],
  34198. e._RunDirtyCallBacks = function(t) {
  34199. for (var i = 0, n = e._DirtyCallbackArray; i < n.length; i++)
  34200. (0,
  34201. n[i])(t)
  34202. }
  34203. ,
  34204. k([Ce()], e.prototype, "id", void 0),
  34205. k([Ce()], e.prototype, "uniqueId", void 0),
  34206. k([Ce()], e.prototype, "name", void 0),
  34207. k([Ce()], e.prototype, "metadata", void 0),
  34208. k([Ce()], e.prototype, "checkReadyOnEveryCall", void 0),
  34209. k([Ce()], e.prototype, "checkReadyOnlyOnce", void 0),
  34210. k([Ce()], e.prototype, "state", void 0),
  34211. k([Ce("alpha")], e.prototype, "_alpha", void 0),
  34212. k([Ce("backFaceCulling")], e.prototype, "_backFaceCulling", void 0),
  34213. k([Ce("cullBackFaces")], e.prototype, "_cullBackFaces", void 0),
  34214. k([Ce()], e.prototype, "sideOrientation", void 0),
  34215. k([Ce("alphaMode")], e.prototype, "_alphaMode", void 0),
  34216. k([Ce()], e.prototype, "_needDepthPrePass", void 0),
  34217. k([Ce()], e.prototype, "disableDepthWrite", void 0),
  34218. k([Ce()], e.prototype, "disableColorWrite", void 0),
  34219. k([Ce()], e.prototype, "forceDepthWrite", void 0),
  34220. k([Ce()], e.prototype, "depthFunction", void 0),
  34221. k([Ce()], e.prototype, "separateCullingPass", void 0),
  34222. k([Ce("fogEnabled")], e.prototype, "_fogEnabled", void 0),
  34223. k([Ce()], e.prototype, "pointSize", void 0),
  34224. k([Ce()], e.prototype, "zOffset", void 0),
  34225. k([Ce()], e.prototype, "zOffsetUnits", void 0),
  34226. k([Ce()], e.prototype, "pointsCloud", null),
  34227. k([Ce()], e.prototype, "fillMode", null),
  34228. k([Ce()], e.prototype, "transparencyMode", null),
  34229. e
  34230. }()
  34231. , Dr = function(e) {
  34232. function t(t, i) {
  34233. var n = e.call(this, t, i, !0) || this;
  34234. return n._waitingSubMaterialsUniqueIds = [],
  34235. n.getScene().multiMaterials.push(n),
  34236. n.subMaterials = new Array,
  34237. n._storeEffectOnSubMeshes = !0,
  34238. n
  34239. }
  34240. return U(t, e),
  34241. Object.defineProperty(t.prototype, "subMaterials", {
  34242. get: function() {
  34243. return this._subMaterials
  34244. },
  34245. set: function(e) {
  34246. this._subMaterials = e,
  34247. this._hookArray(e)
  34248. },
  34249. enumerable: !1,
  34250. configurable: !0
  34251. }),
  34252. t.prototype.getChildren = function() {
  34253. return this.subMaterials
  34254. }
  34255. ,
  34256. t.prototype._hookArray = function(e) {
  34257. var t = this
  34258. , i = e.push;
  34259. e.push = function() {
  34260. for (var n = [], r = 0; r < arguments.length; r++)
  34261. n[r] = arguments[r];
  34262. var o = i.apply(e, n);
  34263. return t._markAllSubMeshesAsTexturesDirty(),
  34264. o
  34265. }
  34266. ;
  34267. var n = e.splice;
  34268. e.splice = function(i, r) {
  34269. var o = n.apply(e, [i, r]);
  34270. return t._markAllSubMeshesAsTexturesDirty(),
  34271. o
  34272. }
  34273. }
  34274. ,
  34275. t.prototype.getSubMaterial = function(e) {
  34276. return e < 0 || e >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[e]
  34277. }
  34278. ,
  34279. t.prototype.getActiveTextures = function() {
  34280. var t;
  34281. return (t = e.prototype.getActiveTextures.call(this)).concat.apply(t, this.subMaterials.map((function(e) {
  34282. return e ? e.getActiveTextures() : []
  34283. }
  34284. )))
  34285. }
  34286. ,
  34287. t.prototype.hasTexture = function(t) {
  34288. var i;
  34289. if (e.prototype.hasTexture.call(this, t))
  34290. return !0;
  34291. for (var n = 0; n < this.subMaterials.length; n++)
  34292. if (null === (i = this.subMaterials[n]) || void 0 === i ? void 0 : i.hasTexture(t))
  34293. return !0;
  34294. return !1
  34295. }
  34296. ,
  34297. t.prototype.getClassName = function() {
  34298. return "MultiMaterial"
  34299. }
  34300. ,
  34301. t.prototype.isReadyForSubMesh = function(e, t, i) {
  34302. for (var n = 0; n < this.subMaterials.length; n++) {
  34303. var r = this.subMaterials[n];
  34304. if (r) {
  34305. if (r._storeEffectOnSubMeshes) {
  34306. if (!r.isReadyForSubMesh(e, t, i))
  34307. return !1;
  34308. continue
  34309. }
  34310. if (!r.isReady(e))
  34311. return !1
  34312. }
  34313. }
  34314. return !0
  34315. }
  34316. ,
  34317. t.prototype.clone = function(e, i) {
  34318. for (var n = new t(e,this.getScene()), r = 0; r < this.subMaterials.length; r++) {
  34319. var o, a = this.subMaterials[r];
  34320. o = i && a ? a.clone(e + "-" + a.name) : this.subMaterials[r],
  34321. n.subMaterials.push(o)
  34322. }
  34323. return n
  34324. }
  34325. ,
  34326. t.prototype.serialize = function() {
  34327. var e = {};
  34328. e.name = this.name,
  34329. e.id = this.id,
  34330. e.uniqueId = this.uniqueId,
  34331. ye && (e.tags = ye.GetTags(this)),
  34332. e.materialsUniqueIds = [],
  34333. e.materials = [];
  34334. for (var t = 0; t < this.subMaterials.length; t++) {
  34335. var i = this.subMaterials[t];
  34336. i ? (e.materialsUniqueIds.push(i.uniqueId),
  34337. e.materials.push(i.id)) : (e.materialsUniqueIds.push(null),
  34338. e.materials.push(null))
  34339. }
  34340. return e
  34341. }
  34342. ,
  34343. t.prototype.dispose = function(t, i, n) {
  34344. var r = this.getScene();
  34345. if (r) {
  34346. if (n)
  34347. for (var o = 0; o < this.subMaterials.length; o++) {
  34348. var a = this.subMaterials[o];
  34349. a && a.dispose(t, i)
  34350. }
  34351. var s = r.multiMaterials.indexOf(this);
  34352. s >= 0 && r.multiMaterials.splice(s, 1),
  34353. e.prototype.dispose.call(this, t, i)
  34354. }
  34355. }
  34356. ,
  34357. t.ParseMultiMaterial = function(e, i) {
  34358. var n = new t(e.name,i);
  34359. return n.id = e.id,
  34360. n._loadedUniqueId = e.uniqueId,
  34361. ye && ye.AddTagsTo(n, e.tags),
  34362. e.materialsUniqueIds ? n._waitingSubMaterialsUniqueIds = e.materialsUniqueIds : e.materials.forEach((function(e) {
  34363. return n.subMaterials.push(i.getLastMaterialById(e))
  34364. }
  34365. )),
  34366. n
  34367. }
  34368. ,
  34369. t
  34370. }(Or);
  34371. y("BABYLON.MultiMaterial", Dr);
  34372. var Nr = function(e, t) {
  34373. this.distanceOrScreenCoverage = e,
  34374. this.mesh = t
  34375. }
  34376. , Lr = function() {}
  34377. , Fr = function() {
  34378. this.visibleInstances = {},
  34379. this.batchCache = new wr,
  34380. this.batchCacheReplacementModeInFrozenMode = new wr,
  34381. this.instancesBufferSize = 2048
  34382. }
  34383. , wr = function() {
  34384. this.mustReturn = !1,
  34385. this.visibleInstances = new Array,
  34386. this.renderSelf = new Array,
  34387. this.hardwareInstancedRendering = new Array
  34388. }
  34389. , Br = function() {
  34390. this.instancesCount = 0,
  34391. this.matrixBuffer = null,
  34392. this.previousMatrixBuffer = null,
  34393. this.matrixBufferSize = 512,
  34394. this.matrixData = null,
  34395. this.boundingVectors = [],
  34396. this.worldMatrices = null
  34397. }
  34398. , Ur = function() {
  34399. this._areNormalsFrozen = !1,
  34400. this._source = null,
  34401. this.meshMap = null,
  34402. this._preActivateId = -1,
  34403. this._LODLevels = new Array,
  34404. this._useLODScreenCoverage = !1,
  34405. this._effectiveMaterial = null,
  34406. this._forcedInstanceCount = 0
  34407. }
  34408. , Vr = function(e) {
  34409. function t(i, n, r, o, s, l) {
  34410. void 0 === n && (n = null),
  34411. void 0 === r && (r = null),
  34412. void 0 === o && (o = null),
  34413. void 0 === l && (l = !0);
  34414. var c = e.call(this, i, n) || this;
  34415. if (c._internalMeshDataInfo = new Ur,
  34416. c.delayLoadState = a.DELAYLOADSTATE_NONE,
  34417. c.instances = new Array,
  34418. c._creationDataStorage = null,
  34419. c._geometry = null,
  34420. c._instanceDataStorage = new Fr,
  34421. c._thinInstanceDataStorage = new Br,
  34422. c._shouldGenerateFlatShading = !1,
  34423. c._originalBuilderSideOrientation = t.DEFAULTSIDE,
  34424. c.overrideMaterialSideOrientation = null,
  34425. c.ignoreCameraMaxZ = !1,
  34426. n = c.getScene(),
  34427. c._onBeforeDraw = function(e, t, i) {
  34428. e && i && (c._uniformBuffer ? c.transferToEffect(t) : i.bindOnlyWorldMatrix(t))
  34429. }
  34430. ,
  34431. o) {
  34432. if (o._geometry && o._geometry.applyToMesh(c),
  34433. fe.DeepCopy(o, c, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "worldMatrixInstancedBuffer", "previousWorldMatrixInstancedBuffer", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen", "facetNb", "isFacetDataEnabled", "lightSources", "useBones", "isAnInstance", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "cloneMeshMap", "hasBoundingInfo"], ["_poseMatrix"]),
  34434. c._internalMeshDataInfo._source = o,
  34435. n.useClonedMeshMap && (o._internalMeshDataInfo.meshMap || (o._internalMeshDataInfo.meshMap = {}),
  34436. o._internalMeshDataInfo.meshMap[c.uniqueId] = c),
  34437. c._originalBuilderSideOrientation = o._originalBuilderSideOrientation,
  34438. c._creationDataStorage = o._creationDataStorage,
  34439. o._ranges) {
  34440. var u = o._ranges;
  34441. for (var d in u)
  34442. Object.prototype.hasOwnProperty.call(u, d) && u[d] && c.createAnimationRange(d, u[d].from, u[d].to)
  34443. }
  34444. if (o.metadata && o.metadata.clone ? c.metadata = o.metadata.clone() : c.metadata = o.metadata,
  34445. ye && ye.HasTags(o) && ye.AddTagsTo(c, ye.GetTags(o, !0)),
  34446. c.setEnabled(o.isEnabled()),
  34447. c.parent = o.parent,
  34448. c.setPivotMatrix(o.getPivotMatrix()),
  34449. c.id = i + "." + o.id,
  34450. c.material = o.material,
  34451. !s)
  34452. for (var p = o.getDescendants(!0), f = 0; f < p.length; f++) {
  34453. var _ = p[f];
  34454. _.clone && _.clone(i + "." + _.name, c)
  34455. }
  34456. if (o.morphTargetManager && (c.morphTargetManager = o.morphTargetManager),
  34457. n.getPhysicsEngine) {
  34458. var m = n.getPhysicsEngine();
  34459. if (l && m) {
  34460. var g = m.getImpostorForPhysicsObject(o);
  34461. g && (c.physicsImpostor = g.clone(c))
  34462. }
  34463. }
  34464. for (f = 0; f < n.particleSystems.length; f++) {
  34465. var v = n.particleSystems[f];
  34466. v.emitter === o && v.clone(v.name, c)
  34467. }
  34468. c.skeleton = o.skeleton,
  34469. c.refreshBoundingInfo(!0, !0),
  34470. c.computeWorldMatrix(!0)
  34471. }
  34472. return null !== r && (c.parent = r),
  34473. c._instanceDataStorage.hardwareInstancedRendering = c.getEngine().getCaps().instancedArrays,
  34474. c._internalMeshDataInfo._onMeshReadyObserverAdded = function(e) {
  34475. e.unregisterOnNextCall = !0,
  34476. c.isReady(!0) ? c.onMeshReadyObservable.notifyObservers(c) : c._internalMeshDataInfo._checkReadinessObserver || (c._internalMeshDataInfo._checkReadinessObserver = c._scene.onBeforeRenderObservable.add((function() {
  34477. c.isReady(!0) && (c._scene.onBeforeRenderObservable.remove(c._internalMeshDataInfo._checkReadinessObserver),
  34478. c._internalMeshDataInfo._checkReadinessObserver = null,
  34479. c.onMeshReadyObservable.notifyObservers(c))
  34480. }
  34481. )))
  34482. }
  34483. ,
  34484. c.onMeshReadyObservable = new h(c._internalMeshDataInfo._onMeshReadyObserverAdded),
  34485. o && o.onClonedObservable.notifyObservers(c),
  34486. c
  34487. }
  34488. return U(t, e),
  34489. t._GetDefaultSideOrientation = function(e) {
  34490. return e || t.FRONTSIDE
  34491. }
  34492. ,
  34493. Object.defineProperty(t.prototype, "useLODScreenCoverage", {
  34494. get: function() {
  34495. return this._internalMeshDataInfo._useLODScreenCoverage
  34496. },
  34497. set: function(e) {
  34498. this._internalMeshDataInfo._useLODScreenCoverage = e
  34499. },
  34500. enumerable: !1,
  34501. configurable: !0
  34502. }),
  34503. Object.defineProperty(t.prototype, "computeBonesUsingShaders", {
  34504. get: function() {
  34505. return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
  34506. },
  34507. set: function(e) {
  34508. this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (e && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(Bi.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
  34509. this._internalMeshDataInfo._sourceNormals && this.setVerticesData(Bi.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
  34510. this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e,
  34511. this._markSubMeshesAsAttributesDirty())
  34512. },
  34513. enumerable: !1,
  34514. configurable: !0
  34515. }),
  34516. Object.defineProperty(t.prototype, "onBeforeRenderObservable", {
  34517. get: function() {
  34518. return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new h),
  34519. this._internalMeshDataInfo._onBeforeRenderObservable
  34520. },
  34521. enumerable: !1,
  34522. configurable: !0
  34523. }),
  34524. Object.defineProperty(t.prototype, "onBeforeBindObservable", {
  34525. get: function() {
  34526. return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new h),
  34527. this._internalMeshDataInfo._onBeforeBindObservable
  34528. },
  34529. enumerable: !1,
  34530. configurable: !0
  34531. }),
  34532. Object.defineProperty(t.prototype, "onAfterRenderObservable", {
  34533. get: function() {
  34534. return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new h),
  34535. this._internalMeshDataInfo._onAfterRenderObservable
  34536. },
  34537. enumerable: !1,
  34538. configurable: !0
  34539. }),
  34540. Object.defineProperty(t.prototype, "onBetweenPassObservable", {
  34541. get: function() {
  34542. return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new h),
  34543. this._internalMeshDataInfo._onBetweenPassObservable
  34544. },
  34545. enumerable: !1,
  34546. configurable: !0
  34547. }),
  34548. Object.defineProperty(t.prototype, "onBeforeDrawObservable", {
  34549. get: function() {
  34550. return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new h),
  34551. this._internalMeshDataInfo._onBeforeDrawObservable
  34552. },
  34553. enumerable: !1,
  34554. configurable: !0
  34555. }),
  34556. Object.defineProperty(t.prototype, "onBeforeDraw", {
  34557. set: function(e) {
  34558. this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),
  34559. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(e)
  34560. },
  34561. enumerable: !1,
  34562. configurable: !0
  34563. }),
  34564. Object.defineProperty(t.prototype, "hasInstances", {
  34565. get: function() {
  34566. return this.instances.length > 0
  34567. },
  34568. enumerable: !1,
  34569. configurable: !0
  34570. }),
  34571. Object.defineProperty(t.prototype, "hasThinInstances", {
  34572. get: function() {
  34573. var e;
  34574. return (null !== (e = this._thinInstanceDataStorage.instancesCount) && void 0 !== e ? e : 0) > 0
  34575. },
  34576. enumerable: !1,
  34577. configurable: !0
  34578. }),
  34579. Object.defineProperty(t.prototype, "forcedInstanceCount", {
  34580. get: function() {
  34581. return this._internalMeshDataInfo._forcedInstanceCount
  34582. },
  34583. set: function(e) {
  34584. this._internalMeshDataInfo._forcedInstanceCount = e
  34585. },
  34586. enumerable: !1,
  34587. configurable: !0
  34588. }),
  34589. Object.defineProperty(t.prototype, "source", {
  34590. get: function() {
  34591. return this._internalMeshDataInfo._source
  34592. },
  34593. enumerable: !1,
  34594. configurable: !0
  34595. }),
  34596. Object.defineProperty(t.prototype, "cloneMeshMap", {
  34597. get: function() {
  34598. return this._internalMeshDataInfo.meshMap
  34599. },
  34600. enumerable: !1,
  34601. configurable: !0
  34602. }),
  34603. Object.defineProperty(t.prototype, "isUnIndexed", {
  34604. get: function() {
  34605. return this._unIndexed
  34606. },
  34607. set: function(e) {
  34608. this._unIndexed !== e && (this._unIndexed = e,
  34609. this._markSubMeshesAsAttributesDirty())
  34610. },
  34611. enumerable: !1,
  34612. configurable: !0
  34613. }),
  34614. Object.defineProperty(t.prototype, "worldMatrixInstancedBuffer", {
  34615. get: function() {
  34616. return this._instanceDataStorage.instancesData
  34617. },
  34618. enumerable: !1,
  34619. configurable: !0
  34620. }),
  34621. Object.defineProperty(t.prototype, "previousWorldMatrixInstancedBuffer", {
  34622. get: function() {
  34623. return this._instanceDataStorage.instancesPreviousData
  34624. },
  34625. enumerable: !1,
  34626. configurable: !0
  34627. }),
  34628. Object.defineProperty(t.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", {
  34629. get: function() {
  34630. return this._instanceDataStorage.manualUpdate
  34631. },
  34632. set: function(e) {
  34633. this._instanceDataStorage.manualUpdate = e
  34634. },
  34635. enumerable: !1,
  34636. configurable: !0
  34637. }),
  34638. Object.defineProperty(t.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", {
  34639. get: function() {
  34640. return this._instanceDataStorage.previousManualUpdate
  34641. },
  34642. set: function(e) {
  34643. this._instanceDataStorage.previousManualUpdate = e
  34644. },
  34645. enumerable: !1,
  34646. configurable: !0
  34647. }),
  34648. t.prototype.instantiateHierarchy = function(e, t, i) {
  34649. void 0 === e && (e = null);
  34650. var n = !(this.getTotalVertices() > 0) || t && t.doNotInstantiate ? this.clone("Clone of " + (this.name || this.id), e || this.parent, !0) : this.createInstance("instance of " + (this.name || this.id));
  34651. n.parent = e || this.parent,
  34652. n.position = this.position.clone(),
  34653. n.scaling = this.scaling.clone(),
  34654. this.rotationQuaternion ? n.rotationQuaternion = this.rotationQuaternion.clone() : n.rotation = this.rotation.clone(),
  34655. i && i(this, n);
  34656. for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
  34657. o[r].instantiateHierarchy(n, t, i);
  34658. return n
  34659. }
  34660. ,
  34661. t.prototype.getClassName = function() {
  34662. return "Mesh"
  34663. }
  34664. ,
  34665. Object.defineProperty(t.prototype, "_isMesh", {
  34666. get: function() {
  34667. return !0
  34668. },
  34669. enumerable: !1,
  34670. configurable: !0
  34671. }),
  34672. t.prototype.toString = function(t) {
  34673. var i = e.prototype.toString.call(this, t);
  34674. if (i += ", n vertices: " + this.getTotalVertices(),
  34675. i += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"),
  34676. this.animations)
  34677. for (var n = 0; n < this.animations.length; n++)
  34678. i += ", animation[0]: " + this.animations[n].toString(t);
  34679. if (t)
  34680. if (this._geometry) {
  34681. var r = this.getIndices()
  34682. , o = this.getVerticesData(Bi.PositionKind);
  34683. o && r && (i += ", flat shading: " + (o.length / 3 === r.length ? "YES" : "NO"))
  34684. } else
  34685. i += ", flat shading: UNKNOWN";
  34686. return i
  34687. }
  34688. ,
  34689. t.prototype._unBindEffect = function() {
  34690. e.prototype._unBindEffect.call(this);
  34691. for (var t = 0, i = this.instances; t < i.length; t++)
  34692. i[t]._unBindEffect()
  34693. }
  34694. ,
  34695. Object.defineProperty(t.prototype, "hasLODLevels", {
  34696. get: function() {
  34697. return this._internalMeshDataInfo._LODLevels.length > 0
  34698. },
  34699. enumerable: !1,
  34700. configurable: !0
  34701. }),
  34702. t.prototype.getLODLevels = function() {
  34703. return this._internalMeshDataInfo._LODLevels
  34704. }
  34705. ,
  34706. t.prototype._sortLODLevels = function() {
  34707. var e = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
  34708. this._internalMeshDataInfo._LODLevels.sort((function(t, i) {
  34709. return t.distanceOrScreenCoverage < i.distanceOrScreenCoverage ? e : t.distanceOrScreenCoverage > i.distanceOrScreenCoverage ? -e : 0
  34710. }
  34711. ))
  34712. }
  34713. ,
  34714. t.prototype.addLODLevel = function(e, t) {
  34715. if (t && t._masterMesh)
  34716. return K.Warn("You cannot use a mesh as LOD level twice"),
  34717. this;
  34718. var i = new Nr(e,t);
  34719. return this._internalMeshDataInfo._LODLevels.push(i),
  34720. t && (t._masterMesh = this),
  34721. this._sortLODLevels(),
  34722. this
  34723. }
  34724. ,
  34725. t.prototype.getLODLevelAtDistance = function(e) {
  34726. for (var t = this._internalMeshDataInfo, i = 0; i < t._LODLevels.length; i++) {
  34727. var n = t._LODLevels[i];
  34728. if (n.distanceOrScreenCoverage === e)
  34729. return n.mesh
  34730. }
  34731. return null
  34732. }
  34733. ,
  34734. t.prototype.removeLODLevel = function(e) {
  34735. for (var t = this._internalMeshDataInfo, i = 0; i < t._LODLevels.length; i++)
  34736. t._LODLevels[i].mesh === e && (t._LODLevels.splice(i, 1),
  34737. e && (e._masterMesh = null));
  34738. return this._sortLODLevels(),
  34739. this
  34740. }
  34741. ,
  34742. t.prototype.getLOD = function(e, t) {
  34743. var i, n = this._internalMeshDataInfo;
  34744. if (!n._LODLevels || 0 === n._LODLevels.length)
  34745. return this;
  34746. var r = (i = t || this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length()
  34747. , o = r
  34748. , s = 1;
  34749. if (n._useLODScreenCoverage) {
  34750. var l = e.screenArea
  34751. , c = i.radiusWorld * e.minZ / r;
  34752. o = (c = c * c * Math.PI) / l,
  34753. s = -1
  34754. }
  34755. if (s * n._LODLevels[n._LODLevels.length - 1].distanceOrScreenCoverage > s * o)
  34756. return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this),
  34757. this;
  34758. for (var u = 0; u < n._LODLevels.length; u++) {
  34759. var h = n._LODLevels[u];
  34760. if (s * h.distanceOrScreenCoverage < s * o) {
  34761. if (h.mesh) {
  34762. if (h.mesh.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
  34763. return h.mesh._checkDelayState(),
  34764. this;
  34765. if (h.mesh.delayLoadState === a.DELAYLOADSTATE_LOADING)
  34766. return this;
  34767. h.mesh._preActivate(),
  34768. h.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)
  34769. }
  34770. return this.onLODLevelSelection && this.onLODLevelSelection(o, this, h.mesh),
  34771. h.mesh
  34772. }
  34773. }
  34774. return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this),
  34775. this
  34776. }
  34777. ,
  34778. Object.defineProperty(t.prototype, "geometry", {
  34779. get: function() {
  34780. return this._geometry
  34781. },
  34782. enumerable: !1,
  34783. configurable: !0
  34784. }),
  34785. t.prototype.getTotalVertices = function() {
  34786. return null === this._geometry || void 0 === this._geometry ? 0 : this._geometry.getTotalVertices()
  34787. }
  34788. ,
  34789. t.prototype.getVerticesData = function(e, t, i) {
  34790. var n, r;
  34791. if (!this._geometry)
  34792. return null;
  34793. var o = null === (r = null === (n = this._userInstancedBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) || void 0 === r ? void 0 : r.getFloatData(this._geometry.getTotalVertices(), i || t && 1 !== this._geometry.meshes.length);
  34794. return o || (o = this._geometry.getVerticesData(e, t, i)),
  34795. o
  34796. }
  34797. ,
  34798. t.prototype.getVertexBuffer = function(e) {
  34799. var t, i;
  34800. return this._geometry ? null !== (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) && void 0 !== i ? i : this._geometry.getVertexBuffer(e) : null
  34801. }
  34802. ,
  34803. t.prototype.isVerticesDataPresent = function(e) {
  34804. var t;
  34805. return this._geometry ? void 0 !== (null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || this._geometry.isVerticesDataPresent(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
  34806. }
  34807. ,
  34808. t.prototype.isVertexBufferUpdatable = function(e) {
  34809. var t, i;
  34810. return this._geometry ? (null === (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || void 0 === i ? void 0 : i.isUpdatable()) || this._geometry.isVertexBufferUpdatable(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
  34811. }
  34812. ,
  34813. t.prototype.getVerticesDataKinds = function() {
  34814. if (!this._geometry) {
  34815. var e = new Array;
  34816. return this._delayInfo && this._delayInfo.forEach((function(t) {
  34817. e.push(t)
  34818. }
  34819. )),
  34820. e
  34821. }
  34822. var t = this._geometry.getVerticesDataKinds();
  34823. if (this._userInstancedBuffersStorage)
  34824. for (var i in this._userInstancedBuffersStorage.vertexBuffers)
  34825. t.push(i);
  34826. return t
  34827. }
  34828. ,
  34829. t.prototype.getTotalIndices = function() {
  34830. return this._geometry ? this._geometry.getTotalIndices() : 0
  34831. }
  34832. ,
  34833. t.prototype.getIndices = function(e, t) {
  34834. return this._geometry ? this._geometry.getIndices(e, t) : []
  34835. }
  34836. ,
  34837. Object.defineProperty(t.prototype, "isBlocked", {
  34838. get: function() {
  34839. return null !== this._masterMesh && void 0 !== this._masterMesh
  34840. },
  34841. enumerable: !1,
  34842. configurable: !0
  34843. }),
  34844. t.prototype.isReady = function(t, i) {
  34845. var n, r, o, s, l, c;
  34846. if (void 0 === t && (t = !1),
  34847. void 0 === i && (i = !1),
  34848. this.delayLoadState === a.DELAYLOADSTATE_LOADING)
  34849. return !1;
  34850. if (!e.prototype.isReady.call(this, t))
  34851. return !1;
  34852. if (!this.subMeshes || 0 === this.subMeshes.length)
  34853. return !0;
  34854. if (!t)
  34855. return !0;
  34856. var u = this.getEngine()
  34857. , h = this.getScene()
  34858. , d = i || u.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
  34859. this.computeWorldMatrix();
  34860. var p = this.material || h.defaultMaterial;
  34861. if (p)
  34862. if (p._storeEffectOnSubMeshes)
  34863. for (var f = 0, _ = this.subMeshes; f < _.length; f++) {
  34864. var m = (S = _[f]).getMaterial();
  34865. if (m)
  34866. if (m._storeEffectOnSubMeshes) {
  34867. if (!m.isReadyForSubMesh(this, S, d))
  34868. return !1
  34869. } else if (!m.isReady(this, d))
  34870. return !1
  34871. }
  34872. else if (!p.isReady(this, d))
  34873. return !1;
  34874. for (var g = u.currentRenderPassId, v = 0, y = this.lightSources; v < y.length; v++) {
  34875. var b = y[v].getShadowGenerator();
  34876. if (b && (!(null === (n = b.getShadowMap()) || void 0 === n ? void 0 : n.renderList) || (null === (r = b.getShadowMap()) || void 0 === r ? void 0 : r.renderList) && -1 !== (null === (s = null === (o = b.getShadowMap()) || void 0 === o ? void 0 : o.renderList) || void 0 === s ? void 0 : s.indexOf(this)))) {
  34877. b.getShadowMap() && (u.currentRenderPassId = b.getShadowMap().renderPassId);
  34878. for (var T = 0, E = this.subMeshes; T < E.length; T++) {
  34879. var S = E[T];
  34880. if (!b.isReady(S, d, null !== (c = null === (l = S.getMaterial()) || void 0 === l ? void 0 : l.needAlphaBlendingForMesh(this)) && void 0 !== c && c))
  34881. return u.currentRenderPassId = g,
  34882. !1
  34883. }
  34884. u.currentRenderPassId = g
  34885. }
  34886. }
  34887. for (var A = 0, x = this._internalMeshDataInfo._LODLevels; A < x.length; A++) {
  34888. var R = x[A];
  34889. if (R.mesh && !R.mesh.isReady(d))
  34890. return !1
  34891. }
  34892. return !0
  34893. }
  34894. ,
  34895. Object.defineProperty(t.prototype, "areNormalsFrozen", {
  34896. get: function() {
  34897. return this._internalMeshDataInfo._areNormalsFrozen
  34898. },
  34899. enumerable: !1,
  34900. configurable: !0
  34901. }),
  34902. t.prototype.freezeNormals = function() {
  34903. return this._internalMeshDataInfo._areNormalsFrozen = !0,
  34904. this
  34905. }
  34906. ,
  34907. t.prototype.unfreezeNormals = function() {
  34908. return this._internalMeshDataInfo._areNormalsFrozen = !1,
  34909. this
  34910. }
  34911. ,
  34912. Object.defineProperty(t.prototype, "overridenInstanceCount", {
  34913. set: function(e) {
  34914. this._instanceDataStorage.overridenInstanceCount = e
  34915. },
  34916. enumerable: !1,
  34917. configurable: !0
  34918. }),
  34919. t.prototype._preActivate = function() {
  34920. var e = this._internalMeshDataInfo
  34921. , t = this.getScene().getRenderId();
  34922. return e._preActivateId === t || (e._preActivateId = t,
  34923. this._instanceDataStorage.visibleInstances = null),
  34924. this
  34925. }
  34926. ,
  34927. t.prototype._preActivateForIntermediateRendering = function(e) {
  34928. return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = e),
  34929. this
  34930. }
  34931. ,
  34932. t.prototype._registerInstanceForRenderId = function(e, t) {
  34933. return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = {
  34934. defaultRenderId: t,
  34935. selfDefaultRenderId: this._renderId
  34936. }),
  34937. this._instanceDataStorage.visibleInstances[t] || (void 0 !== this._instanceDataStorage.previousRenderId && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null),
  34938. this._instanceDataStorage.previousRenderId = t,
  34939. this._instanceDataStorage.visibleInstances[t] = new Array),
  34940. this._instanceDataStorage.visibleInstances[t].push(e),
  34941. this
  34942. }
  34943. ,
  34944. t.prototype._afterComputeWorldMatrix = function() {
  34945. e.prototype._afterComputeWorldMatrix.call(this),
  34946. this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1))
  34947. }
  34948. ,
  34949. t.prototype._postActivate = function() {
  34950. this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),
  34951. this.edgesRenderer.customInstances.push(this.getWorldMatrix()))
  34952. }
  34953. ,
  34954. t.prototype.refreshBoundingInfo = function(e, t) {
  34955. if (void 0 === e && (e = !1),
  34956. void 0 === t && (t = !1),
  34957. this.hasBoundingInfo && this.getBoundingInfo().isLocked)
  34958. return this;
  34959. var i = this.geometry ? this.geometry.boundingBias : null;
  34960. return this._refreshBoundingInfo(this._getPositionData(e, t), i),
  34961. this
  34962. }
  34963. ,
  34964. t.prototype._createGlobalSubMesh = function(e) {
  34965. var t = this.getTotalVertices();
  34966. if (!t || !this.getIndices())
  34967. return null;
  34968. if (this.subMeshes && this.subMeshes.length > 0) {
  34969. var i = this.getIndices();
  34970. if (!i)
  34971. return null;
  34972. var n = i.length
  34973. , r = !1;
  34974. if (e)
  34975. r = !0;
  34976. else
  34977. for (var o = 0, a = this.subMeshes; o < a.length; o++) {
  34978. var s = a[o];
  34979. if (s.indexStart + s.indexCount > n) {
  34980. r = !0;
  34981. break
  34982. }
  34983. if (s.verticesStart + s.verticesCount > t) {
  34984. r = !0;
  34985. break
  34986. }
  34987. }
  34988. if (!r)
  34989. return this.subMeshes[0]
  34990. }
  34991. return this.releaseSubMeshes(),
  34992. new hr(0,0,t,0,this.getTotalIndices(),this)
  34993. }
  34994. ,
  34995. t.prototype.subdivide = function(e) {
  34996. if (!(e < 1)) {
  34997. for (var t = this.getTotalIndices(), i = t / e | 0, n = 0; i % 3 != 0; )
  34998. i++;
  34999. this.releaseSubMeshes();
  35000. for (var r = 0; r < e && !(n >= t); r++)
  35001. hr.CreateFromIndices(0, n, r === e - 1 ? t - n : i, this),
  35002. n += i;
  35003. this.synchronizeInstances()
  35004. }
  35005. }
  35006. ,
  35007. t.prototype.setVerticesData = function(e, t, i, n) {
  35008. if (void 0 === i && (i = !1),
  35009. this._geometry)
  35010. this._geometry.setVerticesData(e, t, i, n);
  35011. else {
  35012. var r = new $n;
  35013. r.set(t, e);
  35014. var o = this.getScene();
  35015. new fr(fr.RandomId(),o,r,i,this)
  35016. }
  35017. return this
  35018. }
  35019. ,
  35020. t.prototype.removeVerticesData = function(e) {
  35021. this._geometry && this._geometry.removeVerticesData(e)
  35022. }
  35023. ,
  35024. t.prototype.markVerticesDataAsUpdatable = function(e, t) {
  35025. void 0 === t && (t = !0);
  35026. var i = this.getVertexBuffer(e);
  35027. i && i.isUpdatable() !== t && this.setVerticesData(e, this.getVerticesData(e), t)
  35028. }
  35029. ,
  35030. t.prototype.setVerticesBuffer = function(e, t) {
  35031. return void 0 === t && (t = !0),
  35032. this._geometry || (this._geometry = fr.CreateGeometryForMesh(this)),
  35033. this._geometry.setVerticesBuffer(e, null, t),
  35034. this
  35035. }
  35036. ,
  35037. t.prototype.updateVerticesData = function(e, t, i, n) {
  35038. return this._geometry ? (n ? (this.makeGeometryUnique(),
  35039. this.updateVerticesData(e, t, i, !1)) : this._geometry.updateVerticesData(e, t, i),
  35040. this) : this
  35041. }
  35042. ,
  35043. t.prototype.updateMeshPositions = function(e, t) {
  35044. void 0 === t && (t = !0);
  35045. var i = this.getVerticesData(Bi.PositionKind);
  35046. if (!i)
  35047. return this;
  35048. if (e(i),
  35049. this.updateVerticesData(Bi.PositionKind, i, !1, !1),
  35050. t) {
  35051. var n = this.getIndices()
  35052. , r = this.getVerticesData(Bi.NormalKind);
  35053. if (!r)
  35054. return this;
  35055. $n.ComputeNormals(i, n, r),
  35056. this.updateVerticesData(Bi.NormalKind, r, !1, !1)
  35057. }
  35058. return this
  35059. }
  35060. ,
  35061. t.prototype.makeGeometryUnique = function() {
  35062. if (!this._geometry)
  35063. return this;
  35064. if (1 === this._geometry.meshes.length)
  35065. return this;
  35066. var e = this._geometry
  35067. , t = this._geometry.copy(fr.RandomId());
  35068. return e.releaseForMesh(this, !0),
  35069. t.applyToMesh(this),
  35070. this
  35071. }
  35072. ,
  35073. t.prototype.setIndices = function(e, t, i) {
  35074. if (void 0 === t && (t = null),
  35075. void 0 === i && (i = !1),
  35076. this._geometry)
  35077. this._geometry.setIndices(e, t, i);
  35078. else {
  35079. var n = new $n;
  35080. n.indices = e;
  35081. var r = this.getScene();
  35082. new fr(fr.RandomId(),r,n,i,this)
  35083. }
  35084. return this
  35085. }
  35086. ,
  35087. t.prototype.updateIndices = function(e, t, i) {
  35088. return void 0 === i && (i = !1),
  35089. this._geometry ? (this._geometry.updateIndices(e, t, i),
  35090. this) : this
  35091. }
  35092. ,
  35093. t.prototype.toLeftHanded = function() {
  35094. return this._geometry ? (this._geometry.toLeftHanded(),
  35095. this) : this
  35096. }
  35097. ,
  35098. t.prototype._bind = function(e, t, i) {
  35099. if (!this._geometry)
  35100. return this;
  35101. var n, r = this.getScene().getEngine();
  35102. if (this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(t),
  35103. this._unIndexed)
  35104. n = null;
  35105. else
  35106. switch (i) {
  35107. case Or.PointFillMode:
  35108. n = null;
  35109. break;
  35110. case Or.WireFrameFillMode:
  35111. n = e._getLinesIndexBuffer(this.getIndices(), r);
  35112. break;
  35113. default:
  35114. case Or.TriangleFillMode:
  35115. n = this._geometry.getIndexBuffer()
  35116. }
  35117. return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(t, n) : this._geometry._bind(t, n, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
  35118. this
  35119. }
  35120. ,
  35121. t.prototype._draw = function(e, t, i) {
  35122. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  35123. return this;
  35124. this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
  35125. var n = this.getScene().getEngine();
  35126. return this._unIndexed || t == Or.PointFillMode ? n.drawArraysType(t, e.verticesStart, e.verticesCount, this.forcedInstanceCount || i) : t == Or.WireFrameFillMode ? n.drawElementsType(t, 0, e._linesIndexCount, this.forcedInstanceCount || i) : n.drawElementsType(t, e.indexStart, e.indexCount, this.forcedInstanceCount || i),
  35127. this
  35128. }
  35129. ,
  35130. t.prototype.registerBeforeRender = function(e) {
  35131. return this.onBeforeRenderObservable.add(e),
  35132. this
  35133. }
  35134. ,
  35135. t.prototype.unregisterBeforeRender = function(e) {
  35136. return this.onBeforeRenderObservable.removeCallback(e),
  35137. this
  35138. }
  35139. ,
  35140. t.prototype.registerAfterRender = function(e) {
  35141. return this.onAfterRenderObservable.add(e),
  35142. this
  35143. }
  35144. ,
  35145. t.prototype.unregisterAfterRender = function(e) {
  35146. return this.onAfterRenderObservable.removeCallback(e),
  35147. this
  35148. }
  35149. ,
  35150. t.prototype._getInstancesRenderList = function(e, t) {
  35151. if (void 0 === t && (t = !1),
  35152. this._instanceDataStorage.isFrozen) {
  35153. if (t)
  35154. return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e] = !1,
  35155. this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e] = !0,
  35156. this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
  35157. if (this._instanceDataStorage.previousBatch)
  35158. return this._instanceDataStorage.previousBatch
  35159. }
  35160. var i = this.getScene()
  35161. , n = i._isInIntermediateRendering()
  35162. , r = n ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
  35163. , o = this._instanceDataStorage.batchCache;
  35164. if (o.mustReturn = !1,
  35165. o.renderSelf[e] = t || !r && this.isEnabled() && this.isVisible,
  35166. o.visibleInstances[e] = null,
  35167. this._instanceDataStorage.visibleInstances && !t) {
  35168. var a = this._instanceDataStorage.visibleInstances
  35169. , s = i.getRenderId()
  35170. , l = n ? a.intermediateDefaultRenderId : a.defaultRenderId;
  35171. o.visibleInstances[e] = a[s],
  35172. !o.visibleInstances[e] && l && (o.visibleInstances[e] = a[l])
  35173. }
  35174. return o.hardwareInstancedRendering[e] = !t && this._instanceDataStorage.hardwareInstancedRendering && null !== o.visibleInstances[e] && void 0 !== o.visibleInstances[e],
  35175. this._instanceDataStorage.previousBatch = o,
  35176. o
  35177. }
  35178. ,
  35179. t.prototype._renderWithInstances = function(e, i, n, r, o) {
  35180. var a, s = n.visibleInstances[e._id];
  35181. if (!s)
  35182. return this;
  35183. for (var l = this._instanceDataStorage, c = l.instancesBufferSize, u = l.instancesBuffer, h = l.instancesPreviousBuffer, d = 16 * (s.length + 1) * 4; l.instancesBufferSize < d; )
  35184. l.instancesBufferSize *= 2;
  35185. l.instancesData && c == l.instancesBufferSize || (l.instancesData = new Float32Array(l.instancesBufferSize / 4)),
  35186. (this._scene.needsPreviousWorldMatrices && !l.instancesPreviousData || c != l.instancesBufferSize) && (l.instancesPreviousData = new Float32Array(l.instancesBufferSize / 4));
  35187. var p = 0
  35188. , f = 0
  35189. , _ = n.renderSelf[e._id]
  35190. , m = !u || c !== l.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !l.instancesPreviousBuffer;
  35191. if (this._instanceDataStorage.manualUpdate || l.isFrozen && !m)
  35192. f = (_ ? 1 : 0) + s.length;
  35193. else {
  35194. var g = this.getWorldMatrix();
  35195. if (_ && (this._scene.needsPreviousWorldMatrices && (l.masterMeshPreviousWorldMatrix ? (l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p),
  35196. l.masterMeshPreviousWorldMatrix.copyFrom(g)) : (l.masterMeshPreviousWorldMatrix = g.clone(),
  35197. l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
  35198. g.copyToArray(l.instancesData, p),
  35199. p += 16,
  35200. f++),
  35201. s) {
  35202. if (t.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && (null === (a = e.getMaterial()) || void 0 === a ? void 0 : a.needAlphaBlendingForMesh(e.getRenderingMesh()))) {
  35203. for (var v = this._scene.activeCamera.globalPosition, y = 0; y < s.length; y++) {
  35204. var b = s[y];
  35205. b._distanceToCamera = x.Distance(b.getBoundingInfo().boundingSphere.centerWorld, v)
  35206. }
  35207. s.sort((function(e, t) {
  35208. return e._distanceToCamera > t._distanceToCamera ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : 0
  35209. }
  35210. ))
  35211. }
  35212. for (y = 0; y < s.length; y++) {
  35213. var T = s[y]
  35214. , E = T.getWorldMatrix();
  35215. E.copyToArray(l.instancesData, p),
  35216. this._scene.needsPreviousWorldMatrices && (T._previousWorldMatrix ? (T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p),
  35217. T._previousWorldMatrix.copyFrom(E)) : (T._previousWorldMatrix = E.clone(),
  35218. T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
  35219. p += 16,
  35220. f++
  35221. }
  35222. }
  35223. }
  35224. return m ? (u && u.dispose(),
  35225. h && h.dispose(),
  35226. u = new wi(o,l.instancesData,!0,16,!1,!0),
  35227. l.instancesBuffer = u,
  35228. this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
  35229. data: {},
  35230. vertexBuffers: {},
  35231. strides: {},
  35232. sizes: {},
  35233. vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
  35234. }),
  35235. this._userInstancedBuffersStorage.vertexBuffers.world0 = u.createVertexBuffer("world0", 0, 4),
  35236. this._userInstancedBuffersStorage.vertexBuffers.world1 = u.createVertexBuffer("world1", 4, 4),
  35237. this._userInstancedBuffersStorage.vertexBuffers.world2 = u.createVertexBuffer("world2", 8, 4),
  35238. this._userInstancedBuffersStorage.vertexBuffers.world3 = u.createVertexBuffer("world3", 12, 4),
  35239. this._scene.needsPreviousWorldMatrices && (h = new wi(o,l.instancesPreviousData,!0,16,!1,!0),
  35240. l.instancesPreviousBuffer = h,
  35241. this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = h.createVertexBuffer("previousWorld0", 0, 4),
  35242. this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = h.createVertexBuffer("previousWorld1", 4, 4),
  35243. this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = h.createVertexBuffer("previousWorld2", 8, 4),
  35244. this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = h.createVertexBuffer("previousWorld3", 12, 4)),
  35245. this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || (u.updateDirectly(l.instancesData, 0, f),
  35246. !this._scene.needsPreviousWorldMatrices || this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesPreviousData, 0, f)),
  35247. this._processInstancedBuffers(s, _),
  35248. this.getScene()._activeIndices.addCount(e.indexCount * f, !1),
  35249. o._currentDrawContext && (o._currentDrawContext.useInstancing = !0),
  35250. this._bind(e, r, i),
  35251. this._draw(e, i, f),
  35252. !this._scene.needsPreviousWorldMatrices || m || !this._instanceDataStorage.manualUpdate || this._instanceDataStorage.isFrozen || this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesData, 0, f),
  35253. o.unbindInstanceAttributes(),
  35254. this
  35255. }
  35256. ,
  35257. t.prototype._renderWithThinInstances = function(e, t, i, n) {
  35258. var r, o, a = null !== (o = null === (r = this._thinInstanceDataStorage) || void 0 === r ? void 0 : r.instancesCount) && void 0 !== o ? o : 0;
  35259. this.getScene()._activeIndices.addCount(e.indexCount * a, !1),
  35260. n._currentDrawContext && (n._currentDrawContext.useInstancing = !0),
  35261. this._bind(e, i, t),
  35262. this._draw(e, t, a),
  35263. this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, a) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)),
  35264. n.unbindInstanceAttributes()
  35265. }
  35266. ,
  35267. t.prototype._processInstancedBuffers = function(e, t) {}
  35268. ,
  35269. t.prototype._processRendering = function(e, t, i, n, r, o, a, s) {
  35270. var l = this.getScene()
  35271. , c = l.getEngine();
  35272. if (o && t.getRenderingMesh().hasThinInstances)
  35273. return this._renderWithThinInstances(t, n, i, c),
  35274. this;
  35275. if (o)
  35276. this._renderWithInstances(t, n, r, i, c);
  35277. else {
  35278. c._currentDrawContext && (c._currentDrawContext.useInstancing = !1);
  35279. var u = 0;
  35280. r.renderSelf[t._id] && (a && a(!1, e.getWorldMatrix(), s),
  35281. u++,
  35282. this._draw(t, n, this._instanceDataStorage.overridenInstanceCount));
  35283. var h = r.visibleInstances[t._id];
  35284. if (h) {
  35285. var d = h.length;
  35286. u += d;
  35287. for (var p = 0; p < d; p++) {
  35288. var f = h[p].getWorldMatrix();
  35289. a && a(!0, f, s),
  35290. this._draw(t, n)
  35291. }
  35292. }
  35293. l._activeIndices.addCount(t.indexCount * u, !1)
  35294. }
  35295. return this
  35296. }
  35297. ,
  35298. t.prototype._rebuild = function(t) {
  35299. if (void 0 === t && (t = !1),
  35300. this._instanceDataStorage.instancesBuffer && (t && this._instanceDataStorage.instancesBuffer.dispose(),
  35301. this._instanceDataStorage.instancesBuffer = null),
  35302. this._userInstancedBuffersStorage) {
  35303. for (var i in this._userInstancedBuffersStorage.vertexBuffers) {
  35304. var n = this._userInstancedBuffersStorage.vertexBuffers[i];
  35305. n && (t && n.dispose(),
  35306. this._userInstancedBuffersStorage.vertexBuffers[i] = null)
  35307. }
  35308. this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {})
  35309. }
  35310. this._internalMeshDataInfo._effectiveMaterial = null,
  35311. e.prototype._rebuild.call(this, t)
  35312. }
  35313. ,
  35314. t.prototype._freeze = function() {
  35315. if (this.subMeshes) {
  35316. for (var e = 0; e < this.subMeshes.length; e++)
  35317. this._getInstancesRenderList(e);
  35318. this._internalMeshDataInfo._effectiveMaterial = null,
  35319. this._instanceDataStorage.isFrozen = !0
  35320. }
  35321. }
  35322. ,
  35323. t.prototype._unFreeze = function() {
  35324. this._instanceDataStorage.isFrozen = !1,
  35325. this._instanceDataStorage.previousBatch = null
  35326. }
  35327. ,
  35328. t.prototype.render = function(e, t, i) {
  35329. var n, r, o, a = this.getScene();
  35330. if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1,
  35331. this._checkOcclusionQuery() && !this._occlusionDataStorage.forceRenderingWhenOccluded)
  35332. return this;
  35333. var s = this._getInstancesRenderList(e._id, !!i);
  35334. if (s.mustReturn)
  35335. return this;
  35336. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  35337. return this;
  35338. var l = a.getEngine()
  35339. , c = 0
  35340. , u = null;
  35341. this.ignoreCameraMaxZ && a.activeCamera && !a._isInIntermediateRendering() && (c = a.activeCamera.maxZ,
  35342. u = a.activeCamera,
  35343. a.activeCamera.maxZ = 0,
  35344. a.updateTransformMatrix(!0)),
  35345. this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
  35346. var h, d = s.hardwareInstancedRendering[e._id] || e.getRenderingMesh().hasThinInstances, p = this._instanceDataStorage, f = e.getMaterial();
  35347. if (!f)
  35348. return u && (u.maxZ = c,
  35349. a.updateTransformMatrix(!0)),
  35350. this;
  35351. if (p.isFrozen && this._internalMeshDataInfo._effectiveMaterial && this._internalMeshDataInfo._effectiveMaterial === f) {
  35352. if (f._storeEffectOnSubMeshes && !(null === (n = e.effect) || void 0 === n ? void 0 : n._wasPreviouslyReady) || !f._storeEffectOnSubMeshes && !(null === (r = f.getEffect()) || void 0 === r ? void 0 : r._wasPreviouslyReady))
  35353. return u && (u.maxZ = c,
  35354. a.updateTransformMatrix(!0)),
  35355. this
  35356. } else {
  35357. if (f._storeEffectOnSubMeshes) {
  35358. if (!f.isReadyForSubMesh(this, e, d))
  35359. return u && (u.maxZ = c,
  35360. a.updateTransformMatrix(!0)),
  35361. this
  35362. } else if (!f.isReady(this, d))
  35363. return u && (u.maxZ = c,
  35364. a.updateTransformMatrix(!0)),
  35365. this;
  35366. this._internalMeshDataInfo._effectiveMaterial = f
  35367. }
  35368. t && l.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
  35369. for (var _ = null !== (o = null == (h = this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? e._drawWrapper : this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper()) ? void 0 : h.effect) && void 0 !== o ? o : null, m = 0, g = a._beforeRenderingMeshStage; m < g.length; m++)
  35370. g[m].action(this, e, s, _);
  35371. if (!h || !_)
  35372. return u && (u.maxZ = c,
  35373. a.updateTransformMatrix(!0)),
  35374. this;
  35375. var v, y = i || this;
  35376. if (p.isFrozen || !this._internalMeshDataInfo._effectiveMaterial.backFaceCulling && null === this.overrideMaterialSideOrientation)
  35377. v = p.sideOrientation;
  35378. else {
  35379. var b = y._getWorldMatrixDeterminant();
  35380. null == (v = this.overrideMaterialSideOrientation) && (v = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
  35381. b < 0 && (v = v === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation),
  35382. p.sideOrientation = v
  35383. }
  35384. var T = this._internalMeshDataInfo._effectiveMaterial._preBind(h, v);
  35385. this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && l.setDepthWrite(!0);
  35386. var E = a.forcePointsCloud ? Or.PointFillMode : a.forceWireframe ? Or.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
  35387. this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
  35388. d || this._bind(e, _, E);
  35389. var S = this._internalMeshDataInfo._effectiveMaterial
  35390. , A = y.getWorldMatrix();
  35391. S._storeEffectOnSubMeshes ? S.bindForSubMesh(A, this, e) : S.bind(A, this),
  35392. !S.backFaceCulling && S.separateCullingPass && (l.setState(!0, S.zOffset, !1, !T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
  35393. this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
  35394. l.setState(!0, S.zOffset, !1, T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
  35395. this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),
  35396. this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
  35397. this._internalMeshDataInfo._effectiveMaterial.unbind();
  35398. for (var x = 0, R = a._afterRenderingMeshStage; x < R.length; x++)
  35399. R[x].action(this, e, s, _);
  35400. return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
  35401. u && (u.maxZ = c,
  35402. a.updateTransformMatrix(!0)),
  35403. this
  35404. }
  35405. ,
  35406. t.prototype.cleanMatrixWeights = function() {
  35407. this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (this.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) ? this._normalizeSkinWeightsAndExtra() : this._normalizeSkinFourWeights())
  35408. }
  35409. ,
  35410. t.prototype._normalizeSkinFourWeights = function() {
  35411. for (var e = this.getVerticesData(Bi.MatricesWeightsKind), t = e.length, i = 0; i < t; i += 4) {
  35412. var n = e[i] + e[i + 1] + e[i + 2] + e[i + 3];
  35413. if (0 === n)
  35414. e[i] = 1;
  35415. else {
  35416. var r = 1 / n;
  35417. e[i] *= r,
  35418. e[i + 1] *= r,
  35419. e[i + 2] *= r,
  35420. e[i + 3] *= r
  35421. }
  35422. }
  35423. this.setVerticesData(Bi.MatricesWeightsKind, e)
  35424. }
  35425. ,
  35426. t.prototype._normalizeSkinWeightsAndExtra = function() {
  35427. for (var e = this.getVerticesData(Bi.MatricesWeightsExtraKind), t = this.getVerticesData(Bi.MatricesWeightsKind), i = t.length, n = 0; n < i; n += 4) {
  35428. var r = t[n] + t[n + 1] + t[n + 2] + t[n + 3];
  35429. if (0 === (r += e[n] + e[n + 1] + e[n + 2] + e[n + 3]))
  35430. t[n] = 1;
  35431. else {
  35432. var o = 1 / r;
  35433. t[n] *= o,
  35434. t[n + 1] *= o,
  35435. t[n + 2] *= o,
  35436. t[n + 3] *= o,
  35437. e[n] *= o,
  35438. e[n + 1] *= o,
  35439. e[n + 2] *= o,
  35440. e[n + 3] *= o
  35441. }
  35442. }
  35443. this.setVerticesData(Bi.MatricesWeightsKind, t),
  35444. this.setVerticesData(Bi.MatricesWeightsKind, e)
  35445. }
  35446. ,
  35447. t.prototype.validateSkinning = function() {
  35448. var e = this.getVerticesData(Bi.MatricesWeightsExtraKind)
  35449. , t = this.getVerticesData(Bi.MatricesWeightsKind);
  35450. if (null === t || null == this.skeleton)
  35451. return {
  35452. skinned: !1,
  35453. valid: !0,
  35454. report: "not skinned"
  35455. };
  35456. for (var i = t.length, n = 0, r = 0, o = 0, a = 0, s = null === e ? 4 : 8, l = new Array, c = 0; c <= s; c++)
  35457. l[c] = 0;
  35458. for (c = 0; c < i; c += 4) {
  35459. for (var u = t[c], h = u, d = 0 === h ? 0 : 1, p = 1; p < s; p++) {
  35460. var f = p < 4 ? t[c + p] : e[c + p - 4];
  35461. f > u && n++,
  35462. 0 !== f && d++,
  35463. h += f,
  35464. u = f
  35465. }
  35466. if (l[d]++,
  35467. d > o && (o = d),
  35468. 0 === h)
  35469. r++;
  35470. else {
  35471. var _ = 1 / h
  35472. , m = 0;
  35473. for (p = 0; p < s; p++)
  35474. m += p < 4 ? Math.abs(t[c + p] - t[c + p] * _) : Math.abs(e[c + p - 4] - e[c + p - 4] * _);
  35475. m > .001 && a++
  35476. }
  35477. }
  35478. var g = this.skeleton.bones.length
  35479. , v = this.getVerticesData(Bi.MatricesIndicesKind)
  35480. , y = this.getVerticesData(Bi.MatricesIndicesExtraKind)
  35481. , b = 0;
  35482. for (c = 0; c < i; c += 4)
  35483. for (p = 0; p < s; p++) {
  35484. var T = p < 4 ? v[c + p] : y[c + p - 4];
  35485. (T >= g || T < 0) && b++
  35486. }
  35487. return {
  35488. skinned: !0,
  35489. valid: 0 === r && 0 === a && 0 === b,
  35490. report: "Number of Weights = " + i / 4 + "\nMaximum influences = " + o + "\nMissing Weights = " + r + "\nNot Sorted = " + n + "\nNot Normalized = " + a + "\nWeightCounts = [" + l + "]\nNumber of bones = " + g + "\nBad Bone Indices = " + b
  35491. }
  35492. }
  35493. ,
  35494. t.prototype._checkDelayState = function() {
  35495. var e = this.getScene();
  35496. return this._geometry ? this._geometry.load(e) : this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADING,
  35497. this._queueLoad(e)),
  35498. this
  35499. }
  35500. ,
  35501. t.prototype._queueLoad = function(e) {
  35502. var t = this;
  35503. e._addPendingData(this);
  35504. var i = -1 !== this.delayLoadingFile.indexOf(".babylonbinarymeshdata");
  35505. return gi.LoadFile(this.delayLoadingFile, (function(i) {
  35506. i instanceof ArrayBuffer ? t._delayLoadingFunction(i, t) : t._delayLoadingFunction(JSON.parse(i), t),
  35507. t.instances.forEach((function(e) {
  35508. e.refreshBoundingInfo(),
  35509. e._syncSubMeshes()
  35510. }
  35511. )),
  35512. t.delayLoadState = a.DELAYLOADSTATE_LOADED,
  35513. e._removePendingData(t)
  35514. }
  35515. ), (function() {}
  35516. ), e.offlineProvider, i),
  35517. this
  35518. }
  35519. ,
  35520. t.prototype.isInFrustum = function(t) {
  35521. return this.delayLoadState !== a.DELAYLOADSTATE_LOADING && !!e.prototype.isInFrustum.call(this, t) && (this._checkDelayState(),
  35522. !0)
  35523. }
  35524. ,
  35525. t.prototype.setMaterialById = function(e) {
  35526. var t, i = this.getScene().materials;
  35527. for (t = i.length - 1; t > -1; t--)
  35528. if (i[t].id === e)
  35529. return this.material = i[t],
  35530. this;
  35531. var n = this.getScene().multiMaterials;
  35532. for (t = n.length - 1; t > -1; t--)
  35533. if (n[t].id === e)
  35534. return this.material = n[t],
  35535. this;
  35536. return this
  35537. }
  35538. ,
  35539. t.prototype.getAnimatables = function() {
  35540. var e = new Array;
  35541. return this.material && e.push(this.material),
  35542. this.skeleton && e.push(this.skeleton),
  35543. e
  35544. }
  35545. ,
  35546. t.prototype.bakeTransformIntoVertices = function(e) {
  35547. if (!this.isVerticesDataPresent(Bi.PositionKind))
  35548. return this;
  35549. var t = this.subMeshes.splice(0);
  35550. this._resetPointsArrayCache();
  35551. var i, n = this.getVerticesData(Bi.PositionKind), r = new Array;
  35552. for (i = 0; i < n.length; i += 3)
  35553. x.TransformCoordinates(x.FromArray(n, i), e).toArray(r, i);
  35554. if (this.setVerticesData(Bi.PositionKind, r, this.getVertexBuffer(Bi.PositionKind).isUpdatable()),
  35555. this.isVerticesDataPresent(Bi.NormalKind)) {
  35556. for (n = this.getVerticesData(Bi.NormalKind),
  35557. r = [],
  35558. i = 0; i < n.length; i += 3)
  35559. x.TransformNormal(x.FromArray(n, i), e).normalize().toArray(r, i);
  35560. this.setVerticesData(Bi.NormalKind, r, this.getVertexBuffer(Bi.NormalKind).isUpdatable())
  35561. }
  35562. return e.determinant() < 0 && this.flipFaces(),
  35563. this.releaseSubMeshes(),
  35564. this.subMeshes = t,
  35565. this
  35566. }
  35567. ,
  35568. t.prototype.bakeCurrentTransformIntoVertices = function(e) {
  35569. return void 0 === e && (e = !0),
  35570. this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),
  35571. this.resetLocalMatrix(e),
  35572. this
  35573. }
  35574. ,
  35575. Object.defineProperty(t.prototype, "_positions", {
  35576. get: function() {
  35577. return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null
  35578. },
  35579. enumerable: !1,
  35580. configurable: !0
  35581. }),
  35582. t.prototype._resetPointsArrayCache = function() {
  35583. return this._geometry && this._geometry._resetPointsArrayCache(),
  35584. this
  35585. }
  35586. ,
  35587. t.prototype._generatePointsArray = function() {
  35588. return !!this._geometry && this._geometry._generatePointsArray()
  35589. }
  35590. ,
  35591. t.prototype.clone = function(e, i, n, r) {
  35592. return void 0 === e && (e = ""),
  35593. void 0 === i && (i = null),
  35594. void 0 === r && (r = !0),
  35595. new t(e,this.getScene(),i,this,n,r)
  35596. }
  35597. ,
  35598. t.prototype.dispose = function(t, i) {
  35599. void 0 === i && (i = !1),
  35600. this.morphTargetManager = null,
  35601. this._geometry && this._geometry.releaseForMesh(this, !0);
  35602. var n = this._internalMeshDataInfo;
  35603. if (n._onBeforeDrawObservable && n._onBeforeDrawObservable.clear(),
  35604. n._onBeforeBindObservable && n._onBeforeBindObservable.clear(),
  35605. n._onBeforeRenderObservable && n._onBeforeRenderObservable.clear(),
  35606. n._onAfterRenderObservable && n._onAfterRenderObservable.clear(),
  35607. n._onBetweenPassObservable && n._onBetweenPassObservable.clear(),
  35608. this._scene.useClonedMeshMap) {
  35609. if (n.meshMap)
  35610. for (var r in n.meshMap)
  35611. (s = n.meshMap[r]) && (s._internalMeshDataInfo._source = null,
  35612. n.meshMap[r] = void 0);
  35613. n._source && n._source._internalMeshDataInfo.meshMap && (n._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0)
  35614. } else
  35615. for (var o = 0, a = this.getScene().meshes; o < a.length; o++) {
  35616. var s;
  35617. (s = a[o])._internalMeshDataInfo && s._internalMeshDataInfo._source && s._internalMeshDataInfo._source === this && (s._internalMeshDataInfo._source = null)
  35618. }
  35619. n._source = null,
  35620. this._disposeInstanceSpecificData(),
  35621. this._disposeThinInstanceSpecificData(),
  35622. this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),
  35623. e.prototype.dispose.call(this, t, i)
  35624. }
  35625. ,
  35626. t.prototype._disposeInstanceSpecificData = function() {}
  35627. ,
  35628. t.prototype._disposeThinInstanceSpecificData = function() {}
  35629. ,
  35630. t.prototype._invalidateInstanceVertexArrayObject = function() {}
  35631. ,
  35632. t.prototype.applyDisplacementMap = function(e, t, i, n, r, o, a) {
  35633. var s = this;
  35634. void 0 === a && (a = !1);
  35635. var l = this.getScene();
  35636. return gi.LoadImage(e, (function(e) {
  35637. var l = e.width
  35638. , c = e.height
  35639. , u = s.getEngine().createCanvas(l, c).getContext("2d");
  35640. u.drawImage(e, 0, 0);
  35641. var h = u.getImageData(0, 0, l, c).data;
  35642. s.applyDisplacementMapFromBuffer(h, l, c, t, i, r, o, a),
  35643. n && n(s)
  35644. }
  35645. ), (function() {}
  35646. ), l.offlineProvider),
  35647. this
  35648. }
  35649. ,
  35650. t.prototype.applyDisplacementMapFromBuffer = function(e, t, i, n, r, o, a, s) {
  35651. if (void 0 === s && (s = !1),
  35652. !this.isVerticesDataPresent(Bi.PositionKind) || !this.isVerticesDataPresent(Bi.NormalKind) || !this.isVerticesDataPresent(Bi.UVKind))
  35653. return K.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
  35654. this;
  35655. var l = this.getVerticesData(Bi.PositionKind, !0, !0)
  35656. , c = this.getVerticesData(Bi.NormalKind)
  35657. , u = this.getVerticesData(Bi.UVKind)
  35658. , h = x.Zero()
  35659. , d = x.Zero()
  35660. , p = A.Zero();
  35661. o = o || A.Zero(),
  35662. a = a || new A(1,1);
  35663. for (var f = 0; f < l.length; f += 3) {
  35664. x.FromArrayToRef(l, f, h),
  35665. x.FromArrayToRef(c, f, d),
  35666. A.FromArrayToRef(u, f / 3 * 2, p);
  35667. var _ = 4 * ((Math.abs(p.x * a.x + o.x % 1) * (t - 1) % t | 0) + (Math.abs(p.y * a.y + o.y % 1) * (i - 1) % i | 0) * t)
  35668. , m = e[_] / 255 * .3 + e[_ + 1] / 255 * .59 + e[_ + 2] / 255 * .11;
  35669. d.normalize(),
  35670. d.scaleInPlace(n + (r - n) * m),
  35671. (h = h.add(d)).toArray(l, f)
  35672. }
  35673. return $n.ComputeNormals(l, this.getIndices(), c),
  35674. s ? (this.setVerticesData(Bi.PositionKind, l),
  35675. this.setVerticesData(Bi.NormalKind, c),
  35676. this.setVerticesData(Bi.UVKind, u)) : (this.updateVerticesData(Bi.PositionKind, l),
  35677. this.updateVerticesData(Bi.NormalKind, c)),
  35678. this
  35679. }
  35680. ,
  35681. t.prototype.convertToFlatShadedMesh = function() {
  35682. var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {}, s = !1;
  35683. for (e = 0; e < i.length; e++) {
  35684. t = i[e];
  35685. var l = this.getVertexBuffer(t)
  35686. , c = l.getData();
  35687. (c instanceof Array || c instanceof Float32Array) && 0 === c.length || (t !== Bi.NormalKind ? (n[t] = l,
  35688. r[t] = this.getVerticesData(t),
  35689. o[t] = []) : (s = l.isUpdatable(),
  35690. i.splice(e, 1),
  35691. e--))
  35692. }
  35693. var u, h = this.subMeshes.slice(0), d = this.getIndices(), p = this.getTotalIndices();
  35694. for (u = 0; u < p; u++) {
  35695. var f = d[u];
  35696. for (e = 0; e < i.length; e++)
  35697. if (n[t = i[e]])
  35698. for (var _ = n[t].getStrideSize(), m = 0; m < _; m++)
  35699. o[t].push(r[t][f * _ + m])
  35700. }
  35701. var g, v = [], y = o[Bi.PositionKind];
  35702. for (g = this.getScene().useRightHandedSystem ? this.overrideMaterialSideOrientation === a.MATERIAL_CounterClockWiseSideOrientation : this.overrideMaterialSideOrientation === a.MATERIAL_ClockWiseSideOrientation,
  35703. u = 0; u < p; u += 3) {
  35704. d[u] = u,
  35705. d[u + 1] = u + 1,
  35706. d[u + 2] = u + 2;
  35707. var b = x.FromArray(y, 3 * u)
  35708. , T = x.FromArray(y, 3 * (u + 1))
  35709. , E = x.FromArray(y, 3 * (u + 2))
  35710. , S = b.subtract(T)
  35711. , A = E.subtract(T)
  35712. , R = x.Normalize(x.Cross(S, A));
  35713. g && R.scaleInPlace(-1);
  35714. for (var C = 0; C < 3; C++)
  35715. v.push(R.x),
  35716. v.push(R.y),
  35717. v.push(R.z)
  35718. }
  35719. for (this.setIndices(d),
  35720. this.setVerticesData(Bi.NormalKind, v, s),
  35721. e = 0; e < i.length; e++)
  35722. o[t = i[e]] && this.setVerticesData(t, o[t], n[t].isUpdatable());
  35723. this.releaseSubMeshes();
  35724. for (var P = 0; P < h.length; P++) {
  35725. var M = h[P];
  35726. hr.AddToMesh(M.materialIndex, M.indexStart, M.indexCount, M.indexStart, M.indexCount, this)
  35727. }
  35728. return this.synchronizeInstances(),
  35729. this
  35730. }
  35731. ,
  35732. t.prototype.convertToUnIndexedMesh = function() {
  35733. var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {};
  35734. for (e = 0; e < i.length; e++) {
  35735. t = i[e];
  35736. var a = this.getVertexBuffer(t);
  35737. n[t] = a,
  35738. r[t] = n[t].getData(),
  35739. o[t] = []
  35740. }
  35741. var s, l = this.subMeshes.slice(0), c = this.getIndices(), u = this.getTotalIndices();
  35742. for (s = 0; s < u; s++) {
  35743. var h = c[s];
  35744. for (e = 0; e < i.length; e++)
  35745. for (var d = n[t = i[e]].getStrideSize(), p = 0; p < d; p++)
  35746. o[t].push(r[t][h * d + p])
  35747. }
  35748. for (s = 0; s < u; s += 3)
  35749. c[s] = s,
  35750. c[s + 1] = s + 1,
  35751. c[s + 2] = s + 2;
  35752. for (this.setIndices(c),
  35753. e = 0; e < i.length; e++)
  35754. t = i[e],
  35755. this.setVerticesData(t, o[t], n[t].isUpdatable());
  35756. this.releaseSubMeshes();
  35757. for (var f = 0; f < l.length; f++) {
  35758. var _ = l[f];
  35759. hr.AddToMesh(_.materialIndex, _.indexStart, _.indexCount, _.indexStart, _.indexCount, this)
  35760. }
  35761. return this._unIndexed = !0,
  35762. this.synchronizeInstances(),
  35763. this
  35764. }
  35765. ,
  35766. t.prototype.flipFaces = function(e) {
  35767. void 0 === e && (e = !1);
  35768. var t, i = $n.ExtractFromMesh(this);
  35769. if (e && this.isVerticesDataPresent(Bi.NormalKind) && i.normals)
  35770. for (t = 0; t < i.normals.length; t++)
  35771. i.normals[t] *= -1;
  35772. if (i.indices) {
  35773. var n = void 0;
  35774. for (t = 0; t < i.indices.length; t += 3)
  35775. n = i.indices[t + 1],
  35776. i.indices[t + 1] = i.indices[t + 2],
  35777. i.indices[t + 2] = n
  35778. }
  35779. return i.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind)),
  35780. this
  35781. }
  35782. ,
  35783. t.prototype.increaseVertices = function(e) {
  35784. var t = $n.ExtractFromMesh(this)
  35785. , i = t.uvs && !Array.isArray(t.uvs) && Array.from ? Array.from(t.uvs) : t.uvs
  35786. , n = t.indices && !Array.isArray(t.indices) && Array.from ? Array.from(t.indices) : t.indices
  35787. , r = t.positions && !Array.isArray(t.positions) && Array.from ? Array.from(t.positions) : t.positions
  35788. , o = t.normals && !Array.isArray(t.normals) && Array.from ? Array.from(t.normals) : t.normals;
  35789. if (n && r && o && i) {
  35790. t.indices = n,
  35791. t.positions = r,
  35792. t.normals = o,
  35793. t.uvs = i;
  35794. for (var a = e + 1, s = new Array, l = 0; l < a + 1; l++)
  35795. s[l] = new Array;
  35796. var c = void 0
  35797. , u = void 0
  35798. , h = new x(0,0,0)
  35799. , d = new x(0,0,0)
  35800. , p = new A(0,0)
  35801. , f = new Array
  35802. , _ = new Array
  35803. , m = new Array
  35804. , g = void 0
  35805. , v = r.length
  35806. , y = i.length;
  35807. for (l = 0; l < n.length; l += 3) {
  35808. _[0] = n[l],
  35809. _[1] = n[l + 1],
  35810. _[2] = n[l + 2];
  35811. for (var b = 0; b < 3; b++)
  35812. if (c = _[b],
  35813. u = _[(b + 1) % 3],
  35814. void 0 === m[c] && void 0 === m[u] ? (m[c] = new Array,
  35815. m[u] = new Array) : (void 0 === m[c] && (m[c] = new Array),
  35816. void 0 === m[u] && (m[u] = new Array)),
  35817. void 0 === m[c][u] && void 0 === m[u][c]) {
  35818. m[c][u] = [],
  35819. h.x = (r[3 * u] - r[3 * c]) / a,
  35820. h.y = (r[3 * u + 1] - r[3 * c + 1]) / a,
  35821. h.z = (r[3 * u + 2] - r[3 * c + 2]) / a,
  35822. d.x = (o[3 * u] - o[3 * c]) / a,
  35823. d.y = (o[3 * u + 1] - o[3 * c + 1]) / a,
  35824. d.z = (o[3 * u + 2] - o[3 * c + 2]) / a,
  35825. p.x = (i[2 * u] - i[2 * c]) / a,
  35826. p.y = (i[2 * u + 1] - i[2 * c + 1]) / a,
  35827. m[c][u].push(c);
  35828. for (var T = 1; T < a; T++)
  35829. m[c][u].push(r.length / 3),
  35830. r[v] = r[3 * c] + T * h.x,
  35831. o[v++] = o[3 * c] + T * d.x,
  35832. r[v] = r[3 * c + 1] + T * h.y,
  35833. o[v++] = o[3 * c + 1] + T * d.y,
  35834. r[v] = r[3 * c + 2] + T * h.z,
  35835. o[v++] = o[3 * c + 2] + T * d.z,
  35836. i[y++] = i[2 * c] + T * p.x,
  35837. i[y++] = i[2 * c + 1] + T * p.y;
  35838. m[c][u].push(u),
  35839. m[u][c] = new Array,
  35840. g = m[c][u].length;
  35841. for (var E = 0; E < g; E++)
  35842. m[u][c][E] = m[c][u][g - 1 - E]
  35843. }
  35844. for (s[0][0] = n[l],
  35845. s[1][0] = m[n[l]][n[l + 1]][1],
  35846. s[1][1] = m[n[l]][n[l + 2]][1],
  35847. T = 2; T < a; T++)
  35848. for (s[T][0] = m[n[l]][n[l + 1]][T],
  35849. s[T][T] = m[n[l]][n[l + 2]][T],
  35850. h.x = (r[3 * s[T][T]] - r[3 * s[T][0]]) / T,
  35851. h.y = (r[3 * s[T][T] + 1] - r[3 * s[T][0] + 1]) / T,
  35852. h.z = (r[3 * s[T][T] + 2] - r[3 * s[T][0] + 2]) / T,
  35853. d.x = (o[3 * s[T][T]] - o[3 * s[T][0]]) / T,
  35854. d.y = (o[3 * s[T][T] + 1] - o[3 * s[T][0] + 1]) / T,
  35855. d.z = (o[3 * s[T][T] + 2] - o[3 * s[T][0] + 2]) / T,
  35856. p.x = (i[2 * s[T][T]] - i[2 * s[T][0]]) / T,
  35857. p.y = (i[2 * s[T][T] + 1] - i[2 * s[T][0] + 1]) / T,
  35858. b = 1; b < T; b++)
  35859. s[T][b] = r.length / 3,
  35860. r[v] = r[3 * s[T][0]] + b * h.x,
  35861. o[v++] = o[3 * s[T][0]] + b * d.x,
  35862. r[v] = r[3 * s[T][0] + 1] + b * h.y,
  35863. o[v++] = o[3 * s[T][0] + 1] + b * d.y,
  35864. r[v] = r[3 * s[T][0] + 2] + b * h.z,
  35865. o[v++] = o[3 * s[T][0] + 2] + b * d.z,
  35866. i[y++] = i[2 * s[T][0]] + b * p.x,
  35867. i[y++] = i[2 * s[T][0] + 1] + b * p.y;
  35868. for (s[a] = m[n[l + 1]][n[l + 2]],
  35869. f.push(s[0][0], s[1][0], s[1][1]),
  35870. T = 1; T < a; T++) {
  35871. for (b = void 0,
  35872. b = 0; b < T; b++)
  35873. f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1]),
  35874. f.push(s[T][b], s[T + 1][b + 1], s[T][b + 1]);
  35875. f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1])
  35876. }
  35877. }
  35878. t.indices = f,
  35879. t.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
  35880. } else
  35881. K.Warn("VertexData contains null entries")
  35882. }
  35883. ,
  35884. t.prototype.forceSharedVertices = function() {
  35885. var e = $n.ExtractFromMesh(this)
  35886. , t = e.uvs
  35887. , i = e.indices
  35888. , n = e.positions
  35889. , r = e.colors;
  35890. if (void 0 === i || void 0 === n || null === i || null === n)
  35891. K.Warn("VertexData contains empty entries");
  35892. else {
  35893. for (var o = new Array, a = new Array, s = new Array, l = new Array, c = new Array, u = 0, h = {}, d = void 0, p = void 0, f = 0; f < i.length; f += 3) {
  35894. p = [i[f], i[f + 1], i[f + 2]],
  35895. c = new Array;
  35896. for (var _ = 0; _ < 3; _++) {
  35897. c[_] = "";
  35898. for (var m = 0; m < 3; m++)
  35899. Math.abs(n[3 * p[_] + m]) < 1e-8 && (n[3 * p[_] + m] = 0),
  35900. c[_] += n[3 * p[_] + m] + "|"
  35901. }
  35902. if (c[0] != c[1] && c[0] != c[2] && c[1] != c[2])
  35903. for (_ = 0; _ < 3; _++) {
  35904. if (void 0 === (d = h[c[_]])) {
  35905. for (h[c[_]] = u,
  35906. d = u++,
  35907. m = 0; m < 3; m++)
  35908. o.push(n[3 * p[_] + m]);
  35909. if (null != r)
  35910. for (m = 0; m < 4; m++)
  35911. l.push(r[4 * p[_] + m]);
  35912. if (null != t)
  35913. for (m = 0; m < 2; m++)
  35914. s.push(t[2 * p[_] + m])
  35915. }
  35916. a.push(d)
  35917. }
  35918. }
  35919. var g = new Array;
  35920. $n.ComputeNormals(o, a, g),
  35921. e.positions = o,
  35922. e.indices = a,
  35923. e.normals = g,
  35924. null != t && (e.uvs = s),
  35925. null != r && (e.colors = l),
  35926. e.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
  35927. }
  35928. }
  35929. ,
  35930. t._instancedMeshFactory = function(e, t) {
  35931. throw be("InstancedMesh")
  35932. }
  35933. ,
  35934. t._PhysicsImpostorParser = function(e, t, i) {
  35935. throw be("PhysicsImpostor")
  35936. }
  35937. ,
  35938. t.prototype.createInstance = function(e) {
  35939. return t._instancedMeshFactory(e, this)
  35940. }
  35941. ,
  35942. t.prototype.synchronizeInstances = function() {
  35943. for (var e = 0; e < this.instances.length; e++)
  35944. this.instances[e]._syncSubMeshes();
  35945. return this
  35946. }
  35947. ,
  35948. t.prototype.optimizeIndices = function(e) {
  35949. var t = this
  35950. , i = this.getIndices()
  35951. , n = this.getVerticesData(Bi.PositionKind);
  35952. if (!n || !i)
  35953. return this;
  35954. for (var r = new Array, o = 0; o < n.length; o += 3)
  35955. r.push(x.FromArray(n, o));
  35956. var a = new Array;
  35957. return yi.SyncAsyncForLoop(r.length, 40, (function(e) {
  35958. for (var t = r.length - 1 - e, i = r[t], n = 0; n < t; ++n) {
  35959. var o = r[n];
  35960. if (i.equals(o)) {
  35961. a[t] = n;
  35962. break
  35963. }
  35964. }
  35965. }
  35966. ), (function() {
  35967. for (var n = 0; n < i.length; ++n)
  35968. i[n] = a[i[n]] || i[n];
  35969. var r = t.subMeshes.slice(0);
  35970. t.setIndices(i),
  35971. t.subMeshes = r,
  35972. e && e(t)
  35973. }
  35974. )),
  35975. this
  35976. }
  35977. ,
  35978. t.prototype.serialize = function(e) {
  35979. e.name = this.name,
  35980. e.id = this.id,
  35981. e.uniqueId = this.uniqueId,
  35982. e.type = this.getClassName(),
  35983. ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
  35984. e.position = this.position.asArray(),
  35985. this.rotationQuaternion ? e.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (e.rotation = this.rotation.asArray()),
  35986. e.scaling = this.scaling.asArray(),
  35987. this._postMultiplyPivotMatrix ? e.pivotMatrix = this.getPivotMatrix().asArray() : e.localMatrix = this.getPivotMatrix().asArray(),
  35988. e.isEnabled = this.isEnabled(!1),
  35989. e.isVisible = this.isVisible,
  35990. e.infiniteDistance = this.infiniteDistance,
  35991. e.pickable = this.isPickable,
  35992. e.receiveShadows = this.receiveShadows,
  35993. e.billboardMode = this.billboardMode,
  35994. e.visibility = this.visibility,
  35995. e.checkCollisions = this.checkCollisions,
  35996. e.isBlocker = this.isBlocker,
  35997. e.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation,
  35998. this.parent && (e.parentId = this.parent.uniqueId),
  35999. e.isUnIndexed = this.isUnIndexed;
  36000. var t = this._geometry;
  36001. if (t && this.subMeshes) {
  36002. e.geometryUniqueId = t.uniqueId,
  36003. e.geometryId = t.id,
  36004. e.subMeshes = [];
  36005. for (var i = 0; i < this.subMeshes.length; i++) {
  36006. var n = this.subMeshes[i];
  36007. e.subMeshes.push({
  36008. materialIndex: n.materialIndex,
  36009. verticesStart: n.verticesStart,
  36010. verticesCount: n.verticesCount,
  36011. indexStart: n.indexStart,
  36012. indexCount: n.indexCount
  36013. })
  36014. }
  36015. }
  36016. this.material ? this.material.doNotSerialize || (e.materialUniqueId = this.material.uniqueId,
  36017. e.materialId = this.material.id) : (this.material = null,
  36018. e.materialUniqueId = this._scene.defaultMaterial.uniqueId,
  36019. e.materialId = this._scene.defaultMaterial.id),
  36020. this.morphTargetManager && (e.morphTargetManagerId = this.morphTargetManager.uniqueId),
  36021. this.skeleton && (e.skeletonId = this.skeleton.id,
  36022. e.numBoneInfluencers = this.numBoneInfluencers),
  36023. this.getScene()._getComponent(Wi.NAME_PHYSICSENGINE) && (a = this.getPhysicsImpostor()) && (e.physicsMass = a.getParam("mass"),
  36024. e.physicsFriction = a.getParam("friction"),
  36025. e.physicsRestitution = a.getParam("mass"),
  36026. e.physicsImpostor = a.type),
  36027. this.metadata && (e.metadata = this.metadata),
  36028. e.instances = [];
  36029. for (var r = 0; r < this.instances.length; r++) {
  36030. var o = this.instances[r];
  36031. if (!o.doNotSerialize) {
  36032. var a, s = {
  36033. name: o.name,
  36034. id: o.id,
  36035. isEnabled: o.isEnabled(!1),
  36036. isVisible: o.isVisible,
  36037. isPickable: o.isPickable,
  36038. checkCollisions: o.checkCollisions,
  36039. position: o.position.asArray(),
  36040. scaling: o.scaling.asArray()
  36041. };
  36042. o.parent && (s.parentId = o.parent.uniqueId),
  36043. o.rotationQuaternion ? s.rotationQuaternion = o.rotationQuaternion.asArray() : o.rotation && (s.rotation = o.rotation.asArray()),
  36044. this.getScene()._getComponent(Wi.NAME_PHYSICSENGINE) && (a = o.getPhysicsImpostor()) && (s.physicsMass = a.getParam("mass"),
  36045. s.physicsFriction = a.getParam("friction"),
  36046. s.physicsRestitution = a.getParam("mass"),
  36047. s.physicsImpostor = a.type),
  36048. o.metadata && (s.metadata = o.metadata),
  36049. e.instances.push(s),
  36050. Ge.AppendSerializedAnimations(o, s),
  36051. s.ranges = o.serializeAnimationRanges()
  36052. }
  36053. }
  36054. if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (e.thinInstances = {
  36055. instancesCount: this._thinInstanceDataStorage.instancesCount,
  36056. matrixData: gi.SliceToArray(this._thinInstanceDataStorage.matrixData),
  36057. matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize,
  36058. enablePicking: this.thinInstanceEnablePicking
  36059. },
  36060. this._userThinInstanceBuffersStorage)) {
  36061. var l = {
  36062. data: {},
  36063. sizes: {},
  36064. strides: {}
  36065. };
  36066. for (var c in this._userThinInstanceBuffersStorage.data)
  36067. l.data[c] = gi.SliceToArray(this._userThinInstanceBuffersStorage.data[c]),
  36068. l.sizes[c] = this._userThinInstanceBuffersStorage.sizes[c],
  36069. l.strides[c] = this._userThinInstanceBuffersStorage.strides[c];
  36070. e.thinInstances.userThinInstance = l
  36071. }
  36072. Ge.AppendSerializedAnimations(this, e),
  36073. e.ranges = this.serializeAnimationRanges(),
  36074. e.layerMask = this.layerMask,
  36075. e.alphaIndex = this.alphaIndex,
  36076. e.hasVertexAlpha = this.hasVertexAlpha,
  36077. e.overlayAlpha = this.overlayAlpha,
  36078. e.overlayColor = this.overlayColor.asArray(),
  36079. e.renderOverlay = this.renderOverlay,
  36080. e.applyFog = this.applyFog,
  36081. this.actionManager && (e.actions = this.actionManager.serialize(this.name))
  36082. }
  36083. ,
  36084. t.prototype._syncGeometryWithMorphTargetManager = function() {
  36085. if (this.geometry) {
  36086. this._markSubMeshesAsAttributesDirty();
  36087. var e = this._internalAbstractMeshDataInfo._morphTargetManager;
  36088. if (e && e.vertexCount) {
  36089. if (e.vertexCount !== this.getTotalVertices())
  36090. return K.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),
  36091. void (this.morphTargetManager = null);
  36092. if (e.isUsingTextureForTargets)
  36093. return;
  36094. for (var t = 0; t < e.numInfluencers; t++) {
  36095. var i = e.getActiveTarget(t)
  36096. , n = i.getPositions();
  36097. if (!n)
  36098. return void K.Error("Invalid morph target. Target must have positions.");
  36099. this.geometry.setVerticesData(Bi.PositionKind + t, n, !1, 3);
  36100. var r = i.getNormals();
  36101. r && this.geometry.setVerticesData(Bi.NormalKind + t, r, !1, 3);
  36102. var o = i.getTangents();
  36103. o && this.geometry.setVerticesData(Bi.TangentKind + t, o, !1, 3);
  36104. var a = i.getUVs();
  36105. a && this.geometry.setVerticesData(Bi.UVKind + "_" + t, a, !1, 2)
  36106. }
  36107. } else
  36108. for (t = 0; this.geometry.isVerticesDataPresent(Bi.PositionKind + t); )
  36109. this.geometry.removeVerticesData(Bi.PositionKind + t),
  36110. this.geometry.isVerticesDataPresent(Bi.NormalKind + t) && this.geometry.removeVerticesData(Bi.NormalKind + t),
  36111. this.geometry.isVerticesDataPresent(Bi.TangentKind + t) && this.geometry.removeVerticesData(Bi.TangentKind + t),
  36112. this.geometry.isVerticesDataPresent(Bi.UVKind + t) && this.geometry.removeVerticesData(Bi.UVKind + "_" + t),
  36113. t++
  36114. }
  36115. }
  36116. ,
  36117. t.Parse = function(e, i, n) {
  36118. var r;
  36119. if ((r = e.type && "LinesMesh" === e.type ? t._LinesMeshParser(e, i) : e.type && "GroundMesh" === e.type ? t._GroundMeshParser(e, i) : e.type && "GoldbergMesh" === e.type ? t._GoldbergMeshParser(e, i) : new t(e.name,i)).id = e.id,
  36120. ye && ye.AddTagsTo(r, e.tags),
  36121. r.position = x.FromArray(e.position),
  36122. void 0 !== e.metadata && (r.metadata = e.metadata),
  36123. e.rotationQuaternion ? r.rotationQuaternion = C.FromArray(e.rotationQuaternion) : e.rotation && (r.rotation = x.FromArray(e.rotation)),
  36124. r.scaling = x.FromArray(e.scaling),
  36125. e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
  36126. r.setEnabled(e.isEnabled),
  36127. r.isVisible = e.isVisible,
  36128. r.infiniteDistance = e.infiniteDistance,
  36129. r.showBoundingBox = e.showBoundingBox,
  36130. r.showSubMeshesBoundingBox = e.showSubMeshesBoundingBox,
  36131. void 0 !== e.applyFog && (r.applyFog = e.applyFog),
  36132. void 0 !== e.pickable && (r.isPickable = e.pickable),
  36133. void 0 !== e.alphaIndex && (r.alphaIndex = e.alphaIndex),
  36134. r.receiveShadows = e.receiveShadows,
  36135. r.billboardMode = e.billboardMode,
  36136. void 0 !== e.visibility && (r.visibility = e.visibility),
  36137. r.checkCollisions = e.checkCollisions,
  36138. r.overrideMaterialSideOrientation = e.overrideMaterialSideOrientation,
  36139. void 0 !== e.isBlocker && (r.isBlocker = e.isBlocker),
  36140. r._shouldGenerateFlatShading = e.useFlatShading,
  36141. e.freezeWorldMatrix && (r._waitingData.freezeWorldMatrix = e.freezeWorldMatrix),
  36142. void 0 !== e.parentId && (r._waitingParentId = e.parentId),
  36143. void 0 !== e.actions && (r._waitingData.actions = e.actions),
  36144. void 0 !== e.overlayAlpha && (r.overlayAlpha = e.overlayAlpha),
  36145. void 0 !== e.overlayColor && (r.overlayColor = D.FromArray(e.overlayColor)),
  36146. void 0 !== e.renderOverlay && (r.renderOverlay = e.renderOverlay),
  36147. r.isUnIndexed = !!e.isUnIndexed,
  36148. r.hasVertexAlpha = e.hasVertexAlpha,
  36149. e.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
  36150. r.delayLoadingFile = n + e.delayLoadingFile,
  36151. r.buildBoundingInfo(x.FromArray(e.boundingBoxMinimum), x.FromArray(e.boundingBoxMaximum)),
  36152. e._binaryInfo && (r._binaryInfo = e._binaryInfo),
  36153. r._delayInfo = [],
  36154. e.hasUVs && r._delayInfo.push(Bi.UVKind),
  36155. e.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
  36156. e.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
  36157. e.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
  36158. e.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
  36159. e.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
  36160. e.hasColors && r._delayInfo.push(Bi.ColorKind),
  36161. e.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
  36162. e.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
  36163. r._delayLoadingFunction = fr._ImportGeometry,
  36164. dr.ForceFullSceneLoadingForIncremental && r._checkDelayState()) : fr._ImportGeometry(e, r),
  36165. e.materialUniqueId ? r._waitingMaterialId = e.materialUniqueId : e.materialId && (r._waitingMaterialId = e.materialId),
  36166. e.morphTargetManagerId > -1 && (r.morphTargetManager = i.getMorphTargetManagerById(e.morphTargetManagerId)),
  36167. void 0 !== e.skeletonId && null !== e.skeletonId && (r.skeleton = i.getLastSkeletonById(e.skeletonId),
  36168. e.numBoneInfluencers && (r.numBoneInfluencers = e.numBoneInfluencers)),
  36169. e.animations) {
  36170. for (var o = 0; o < e.animations.length; o++) {
  36171. var s = e.animations[o];
  36172. (h = b("BABYLON.Animation")) && r.animations.push(h.Parse(s))
  36173. }
  36174. Xe.ParseAnimationRanges(r, e, i)
  36175. }
  36176. if (e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
  36177. e.layerMask && !isNaN(e.layerMask) ? r.layerMask = Math.abs(parseInt(e.layerMask)) : r.layerMask = 268435455,
  36178. e.physicsImpostor && t._PhysicsImpostorParser(i, r, e),
  36179. e.lodMeshIds && (r._waitingData.lods = {
  36180. ids: e.lodMeshIds,
  36181. distances: e.lodDistances ? e.lodDistances : null,
  36182. coverages: e.lodCoverages ? e.lodCoverages : null
  36183. }),
  36184. e.instances)
  36185. for (var l = 0; l < e.instances.length; l++) {
  36186. var c = e.instances[l]
  36187. , u = r.createInstance(c.name);
  36188. if (c.id && (u.id = c.id),
  36189. ye && (c.tags ? ye.AddTagsTo(u, c.tags) : ye.AddTagsTo(u, e.tags)),
  36190. u.position = x.FromArray(c.position),
  36191. void 0 !== c.metadata && (u.metadata = c.metadata),
  36192. void 0 !== c.parentId && (u._waitingParentId = c.parentId),
  36193. void 0 !== c.isEnabled && null !== c.isEnabled && u.setEnabled(c.isEnabled),
  36194. void 0 !== c.isVisible && null !== c.isVisible && (u.isVisible = c.isVisible),
  36195. void 0 !== c.isPickable && null !== c.isPickable && (u.isPickable = c.isPickable),
  36196. c.rotationQuaternion ? u.rotationQuaternion = C.FromArray(c.rotationQuaternion) : c.rotation && (u.rotation = x.FromArray(c.rotation)),
  36197. u.scaling = x.FromArray(c.scaling),
  36198. null != c.checkCollisions && null != c.checkCollisions && (u.checkCollisions = c.checkCollisions),
  36199. null != c.pickable && null != c.pickable && (u.isPickable = c.pickable),
  36200. null != c.showBoundingBox && null != c.showBoundingBox && (u.showBoundingBox = c.showBoundingBox),
  36201. null != c.showSubMeshesBoundingBox && null != c.showSubMeshesBoundingBox && (u.showSubMeshesBoundingBox = c.showSubMeshesBoundingBox),
  36202. null != c.alphaIndex && null != c.showSubMeshesBoundingBox && (u.alphaIndex = c.alphaIndex),
  36203. c.physicsImpostor && t._PhysicsImpostorParser(i, u, c),
  36204. c.animations) {
  36205. for (o = 0; o < c.animations.length; o++) {
  36206. var h;
  36207. s = c.animations[o],
  36208. (h = b("BABYLON.Animation")) && u.animations.push(h.Parse(s))
  36209. }
  36210. Xe.ParseAnimationRanges(u, c, i),
  36211. c.autoAnimate && i.beginAnimation(u, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1)
  36212. }
  36213. }
  36214. if (e.thinInstances) {
  36215. var d = e.thinInstances;
  36216. if (r.thinInstanceEnablePicking = !!d.enablePicking,
  36217. d.matrixData ? (r.thinInstanceSetBuffer("matrix", new Float32Array(d.matrixData), 16, !1),
  36218. r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
  36219. r._thinInstanceDataStorage.instancesCount = d.instancesCount) : r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
  36220. e.thinInstances.userThinInstance) {
  36221. var p = e.thinInstances.userThinInstance;
  36222. for (var f in p.data)
  36223. r.thinInstanceSetBuffer(f, new Float32Array(p.data[f]), p.strides[f], !1),
  36224. r._userThinInstanceBuffersStorage.sizes[f] = p.sizes[f]
  36225. }
  36226. }
  36227. return r
  36228. }
  36229. ,
  36230. t.prototype.setPositionsForCPUSkinning = function() {
  36231. var e = this._internalMeshDataInfo;
  36232. if (!e._sourcePositions) {
  36233. var t = this.getVerticesData(Bi.PositionKind);
  36234. if (!t)
  36235. return e._sourcePositions;
  36236. e._sourcePositions = new Float32Array(t),
  36237. this.isVertexBufferUpdatable(Bi.PositionKind) || this.setVerticesData(Bi.PositionKind, t, !0)
  36238. }
  36239. return e._sourcePositions
  36240. }
  36241. ,
  36242. t.prototype.setNormalsForCPUSkinning = function() {
  36243. var e = this._internalMeshDataInfo;
  36244. if (!e._sourceNormals) {
  36245. var t = this.getVerticesData(Bi.NormalKind);
  36246. if (!t)
  36247. return e._sourceNormals;
  36248. e._sourceNormals = new Float32Array(t),
  36249. this.isVertexBufferUpdatable(Bi.NormalKind) || this.setVerticesData(Bi.NormalKind, t, !0)
  36250. }
  36251. return e._sourceNormals
  36252. }
  36253. ,
  36254. t.prototype.applySkeleton = function(e) {
  36255. if (!this.geometry)
  36256. return this;
  36257. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
  36258. return this;
  36259. if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(),
  36260. !this.isVerticesDataPresent(Bi.PositionKind))
  36261. return this;
  36262. if (!this.isVerticesDataPresent(Bi.MatricesIndicesKind))
  36263. return this;
  36264. if (!this.isVerticesDataPresent(Bi.MatricesWeightsKind))
  36265. return this;
  36266. var t = this.isVerticesDataPresent(Bi.NormalKind)
  36267. , i = this._internalMeshDataInfo;
  36268. if (!i._sourcePositions) {
  36269. var n = this.subMeshes.slice();
  36270. this.setPositionsForCPUSkinning(),
  36271. this.subMeshes = n
  36272. }
  36273. t && !i._sourceNormals && this.setNormalsForCPUSkinning();
  36274. var r = this.getVerticesData(Bi.PositionKind);
  36275. if (!r)
  36276. return this;
  36277. r instanceof Float32Array || (r = new Float32Array(r));
  36278. var o = this.getVerticesData(Bi.NormalKind);
  36279. if (t) {
  36280. if (!o)
  36281. return this;
  36282. o instanceof Float32Array || (o = new Float32Array(o))
  36283. }
  36284. var a = this.getVerticesData(Bi.MatricesIndicesKind)
  36285. , s = this.getVerticesData(Bi.MatricesWeightsKind);
  36286. if (!s || !a)
  36287. return this;
  36288. for (var l, c = this.numBoneInfluencers > 4, u = c ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null, h = c ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null, d = e.getTransformMatrices(this), p = x.Zero(), f = new P, _ = new P, m = 0, g = 0; g < r.length; g += 3,
  36289. m += 4) {
  36290. var v = void 0;
  36291. for (l = 0; l < 4; l++)
  36292. (v = s[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * a[m + l]), v, _),
  36293. f.addToSelf(_));
  36294. if (c)
  36295. for (l = 0; l < 4; l++)
  36296. (v = h[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * u[m + l]), v, _),
  36297. f.addToSelf(_));
  36298. x.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g], i._sourcePositions[g + 1], i._sourcePositions[g + 2], f, p),
  36299. p.toArray(r, g),
  36300. t && (x.TransformNormalFromFloatsToRef(i._sourceNormals[g], i._sourceNormals[g + 1], i._sourceNormals[g + 2], f, p),
  36301. p.toArray(o, g)),
  36302. f.reset()
  36303. }
  36304. return this.updateVerticesData(Bi.PositionKind, r),
  36305. t && this.updateVerticesData(Bi.NormalKind, o),
  36306. this
  36307. }
  36308. ,
  36309. t.MinMax = function(e) {
  36310. var t = null
  36311. , i = null;
  36312. return e.forEach((function(e) {
  36313. var n = e.getBoundingInfo().boundingBox;
  36314. t && i ? (t.minimizeInPlace(n.minimumWorld),
  36315. i.maximizeInPlace(n.maximumWorld)) : (t = n.minimumWorld,
  36316. i = n.maximumWorld)
  36317. }
  36318. )),
  36319. t && i ? {
  36320. min: t,
  36321. max: i
  36322. } : {
  36323. min: x.Zero(),
  36324. max: x.Zero()
  36325. }
  36326. }
  36327. ,
  36328. t.Center = function(e) {
  36329. var i = e instanceof Array ? t.MinMax(e) : e;
  36330. return x.Center(i.min, i.max)
  36331. }
  36332. ,
  36333. t.MergeMeshes = function(e, i, n, r, o, a) {
  36334. return void 0 === i && (i = !0),
  36335. Qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !1))
  36336. }
  36337. ,
  36338. t.MergeMeshesAsync = function(e, i, n, r, o, a) {
  36339. return void 0 === i && (i = !0),
  36340. qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !0), Yn())
  36341. }
  36342. ,
  36343. t._MergeMeshesCoroutine = function(e, i, n, r, o, a, s) {
  36344. var l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D;
  36345. return void 0 === i && (i = !0),
  36346. z(this, (function(N) {
  36347. switch (N.label) {
  36348. case 0:
  36349. if (0 === (e = e.filter(Boolean)).length)
  36350. return [2, null];
  36351. if (!n)
  36352. for (c = 0,
  36353. l = 0; l < e.length; l++)
  36354. if ((c += e[l].getTotalVertices()) >= 65536)
  36355. return K.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),
  36356. [2, null];
  36357. for (a && (o = !1),
  36358. u = new Array,
  36359. h = new Array,
  36360. d = new Array,
  36361. l = 0; l < e.length; l++) {
  36362. if ((p = e[l]).isAnInstance)
  36363. return K.Warn("Cannot merge instance meshes."),
  36364. [2, null];
  36365. if (o && d.push(p.getTotalIndices()),
  36366. a)
  36367. if (p.material)
  36368. if ((f = p.material)instanceof Dr) {
  36369. for (_ = 0; _ < f.subMaterials.length; _++)
  36370. u.indexOf(f.subMaterials[_]) < 0 && u.push(f.subMaterials[_]);
  36371. for (D = 0; D < p.subMeshes.length; D++)
  36372. h.push(u.indexOf(f.subMaterials[p.subMeshes[D].materialIndex])),
  36373. d.push(p.subMeshes[D].indexCount)
  36374. } else
  36375. for (u.indexOf(f) < 0 && u.push(f),
  36376. D = 0; D < p.subMeshes.length; D++)
  36377. h.push(u.indexOf(f)),
  36378. d.push(p.subMeshes[D].indexCount);
  36379. else
  36380. for (D = 0; D < p.subMeshes.length; D++)
  36381. h.push(0),
  36382. d.push(p.subMeshes[D].indexCount)
  36383. }
  36384. return m = e[0],
  36385. g = function(e) {
  36386. var t = e.computeWorldMatrix(!0);
  36387. return [$n.ExtractFromMesh(e, !1, !1), t]
  36388. }
  36389. ,
  36390. v = g(m),
  36391. y = v[0],
  36392. b = v[1],
  36393. s ? [4] : [3, 2];
  36394. case 1:
  36395. N.sent(),
  36396. N.label = 2;
  36397. case 2:
  36398. T = new Array(e.length - 1),
  36399. E = 1,
  36400. N.label = 3;
  36401. case 3:
  36402. return E < e.length ? (T[E - 1] = g(e[E]),
  36403. s ? [4] : [3, 5]) : [3, 6];
  36404. case 4:
  36405. N.sent(),
  36406. N.label = 5;
  36407. case 5:
  36408. return E++,
  36409. [3, 3];
  36410. case 6:
  36411. S = y._mergeCoroutine(b, T, n, s, !i),
  36412. A = S.next(),
  36413. N.label = 7;
  36414. case 7:
  36415. return A.done ? [3, 10] : s ? [4] : [3, 9];
  36416. case 8:
  36417. N.sent(),
  36418. N.label = 9;
  36419. case 9:
  36420. return A = S.next(),
  36421. [3, 7];
  36422. case 10:
  36423. x = A.value,
  36424. r || (r = new t(m.name + "_merged",m.getScene())),
  36425. R = x._applyToCoroutine(r, void 0, s),
  36426. C = R.next(),
  36427. N.label = 11;
  36428. case 11:
  36429. return C.done ? [3, 14] : s ? [4] : [3, 13];
  36430. case 12:
  36431. N.sent(),
  36432. N.label = 13;
  36433. case 13:
  36434. return C = R.next(),
  36435. [3, 11];
  36436. case 14:
  36437. if (r.checkCollisions = m.checkCollisions,
  36438. r.overrideMaterialSideOrientation = m.overrideMaterialSideOrientation,
  36439. i)
  36440. for (l = 0; l < e.length; l++)
  36441. e[l].dispose();
  36442. if (o || a) {
  36443. for (r.releaseSubMeshes(),
  36444. l = 0,
  36445. P = 0; l < d.length; )
  36446. hr.CreateFromIndices(0, P, d[l], r, void 0, !1),
  36447. P += d[l],
  36448. l++;
  36449. for (M = 0,
  36450. I = r.subMeshes; M < I.length; M++)
  36451. I[M].refreshBoundingInfo();
  36452. r.computeWorldMatrix(!0)
  36453. }
  36454. if (a) {
  36455. for ((O = new Dr(m.name + "_merged",m.getScene())).subMaterials = u,
  36456. D = 0; D < r.subMeshes.length; D++)
  36457. r.subMeshes[D].materialIndex = h[D];
  36458. r.material = O
  36459. } else
  36460. r.material = m.material;
  36461. return [2, r]
  36462. }
  36463. }
  36464. ))
  36465. }
  36466. ,
  36467. t.prototype.addInstance = function(e) {
  36468. e._indexInSourceMeshInstanceArray = this.instances.length,
  36469. this.instances.push(e)
  36470. }
  36471. ,
  36472. t.prototype.removeInstance = function(e) {
  36473. var t = e._indexInSourceMeshInstanceArray;
  36474. if (-1 != t) {
  36475. if (t !== this.instances.length - 1) {
  36476. var i = this.instances[this.instances.length - 1];
  36477. this.instances[t] = i,
  36478. i._indexInSourceMeshInstanceArray = t
  36479. }
  36480. e._indexInSourceMeshInstanceArray = -1,
  36481. this.instances.pop()
  36482. }
  36483. }
  36484. ,
  36485. t.prototype._shouldConvertRHS = function() {
  36486. return this.overrideMaterialSideOrientation === Or.CounterClockWiseSideOrientation
  36487. }
  36488. ,
  36489. t.FRONTSIDE = $n.FRONTSIDE,
  36490. t.BACKSIDE = $n.BACKSIDE,
  36491. t.DOUBLESIDE = $n.DOUBLESIDE,
  36492. t.DEFAULTSIDE = $n.DEFAULTSIDE,
  36493. t.NO_CAP = 0,
  36494. t.CAP_START = 1,
  36495. t.CAP_END = 2,
  36496. t.CAP_ALL = 3,
  36497. t.NO_FLIP = 0,
  36498. t.FLIP_TILE = 1,
  36499. t.ROTATE_TILE = 2,
  36500. t.FLIP_ROW = 3,
  36501. t.ROTATE_ROW = 4,
  36502. t.FLIP_N_ROTATE_TILE = 5,
  36503. t.FLIP_N_ROTATE_ROW = 6,
  36504. t.CENTER = 0,
  36505. t.LEFT = 1,
  36506. t.RIGHT = 2,
  36507. t.TOP = 3,
  36508. t.BOTTOM = 4,
  36509. t.INSTANCEDMESH_SORT_TRANSPARENT = !1,
  36510. t._GroundMeshParser = function(e, t) {
  36511. throw be("GroundMesh")
  36512. }
  36513. ,
  36514. t._GoldbergMeshParser = function(e, t) {
  36515. throw be("GoldbergMesh")
  36516. }
  36517. ,
  36518. t._LinesMeshParser = function(e, t) {
  36519. throw be("LinesMesh")
  36520. }
  36521. ,
  36522. t
  36523. }(Sr);
  36524. y("BABYLON.Mesh", Vr),
  36525. Vr.prototype.setMaterialByID = function(e) {
  36526. return this.setMaterialById(e)
  36527. }
  36528. ,
  36529. Vr.CreateDisc = Vr.CreateDisc || function() {
  36530. throw new Error("Import MeshBuilder to populate this function")
  36531. }
  36532. ,
  36533. Vr.CreateBox = Vr.CreateBox || function() {
  36534. throw new Error("Import MeshBuilder to populate this function")
  36535. }
  36536. ,
  36537. Vr.CreateSphere = Vr.CreateSphere || function() {
  36538. throw new Error("Import MeshBuilder to populate this function")
  36539. }
  36540. ,
  36541. Vr.CreateCylinder = Vr.CreateCylinder || function() {
  36542. throw new Error("Import MeshBuilder to populate this function")
  36543. }
  36544. ,
  36545. Vr.CreateTorusKnot = Vr.CreateTorusKnot || function() {
  36546. throw new Error("Import MeshBuilder to populate this function")
  36547. }
  36548. ,
  36549. Vr.CreateTorus = Vr.CreateTorus || function() {
  36550. throw new Error("Import MeshBuilder to populate this function")
  36551. }
  36552. ,
  36553. Vr.CreatePlane = Vr.CreatePlane || function() {
  36554. throw new Error("Import MeshBuilder to populate this function")
  36555. }
  36556. ,
  36557. Vr.CreateGround = Vr.CreateGround || function() {
  36558. throw new Error("Import MeshBuilder to populate this function")
  36559. }
  36560. ,
  36561. Vr.CreateTiledGround = Vr.CreateTiledGround || function() {
  36562. throw new Error("Import MeshBuilder to populate this function")
  36563. }
  36564. ,
  36565. Vr.CreateGroundFromHeightMap = Vr.CreateGroundFromHeightMap || function() {
  36566. throw new Error("Import MeshBuilder to populate this function")
  36567. }
  36568. ,
  36569. Vr.CreateTube = Vr.CreateTube || function() {
  36570. throw new Error("Import MeshBuilder to populate this function")
  36571. }
  36572. ,
  36573. Vr.CreatePolyhedron = Vr.CreatePolyhedron || function() {
  36574. throw new Error("Import MeshBuilder to populate this function")
  36575. }
  36576. ,
  36577. Vr.CreateIcoSphere = Vr.CreateIcoSphere || function() {
  36578. throw new Error("Import MeshBuilder to populate this function")
  36579. }
  36580. ,
  36581. Vr.CreateDecal = Vr.CreateDecal || function() {
  36582. throw new Error("Import MeshBuilder to populate this function")
  36583. }
  36584. ,
  36585. Vr.CreateCapsule = Vr.CreateCapsule || function() {
  36586. throw new Error("Import MeshBuilder to populate this function")
  36587. }
  36588. ,
  36589. Vr.ExtendToGoldberg = Vr.ExtendToGoldberg || function() {
  36590. throw new Error("Import MeshBuilder to populate this function")
  36591. }
  36592. ;
  36593. var kr = function(e) {
  36594. function t() {
  36595. return null !== e && e.apply(this, arguments) || this
  36596. }
  36597. return U(t, e),
  36598. t
  36599. }(o)
  36600. , Gr = function() {
  36601. this.rootNodes = [],
  36602. this.skeletons = [],
  36603. this.animationGroups = []
  36604. }
  36605. , zr = function(e) {
  36606. function t(t) {
  36607. var i = e.call(this) || this;
  36608. return i._wasAddedToScene = !1,
  36609. (t = t || E.LastCreatedScene) ? (i.scene = t,
  36610. i.sounds = [],
  36611. i.effectLayers = [],
  36612. i.layers = [],
  36613. i.lensFlareSystems = [],
  36614. i.proceduralTextures = [],
  36615. i.reflectionProbes = [],
  36616. t.onDisposeObservable.add((function() {
  36617. i._wasAddedToScene || i.dispose()
  36618. }
  36619. )),
  36620. i._onContextRestoredObserver = t.getEngine().onContextRestoredObservable.add((function() {
  36621. for (var e = 0, t = i.geometries; e < t.length; e++)
  36622. t[e]._rebuild();
  36623. for (var n = 0, r = i.meshes; n < r.length; n++)
  36624. r[n]._rebuild();
  36625. for (var o = 0, a = i.particleSystems; o < a.length; o++)
  36626. a[o].rebuild();
  36627. for (var s = 0, l = i.textures; s < l.length; s++)
  36628. l[s]._rebuild()
  36629. }
  36630. )),
  36631. i) : i
  36632. }
  36633. return U(t, e),
  36634. t.prototype.instantiateModelsToScene = function(e, t, i) {
  36635. var n = this;
  36636. void 0 === t && (t = !1);
  36637. var r = {}
  36638. , o = {}
  36639. , a = new Gr
  36640. , s = []
  36641. , l = [];
  36642. i || (i = {
  36643. doNotInstantiate: !0
  36644. });
  36645. var c = function(t, i) {
  36646. if (r[t.uniqueId] = i.uniqueId,
  36647. o[i.uniqueId] = i,
  36648. e && (i.name = e(t.name)),
  36649. i instanceof Vr) {
  36650. var n = i;
  36651. if (n.morphTargetManager) {
  36652. var a = t.morphTargetManager;
  36653. n.morphTargetManager = a.clone();
  36654. for (var s = 0; s < a.numTargets; s++) {
  36655. var l = a.getTarget(s)
  36656. , c = n.morphTargetManager.getTarget(s);
  36657. r[l.uniqueId] = c.uniqueId,
  36658. o[c.uniqueId] = c
  36659. }
  36660. }
  36661. }
  36662. };
  36663. return this.transformNodes.forEach((function(e) {
  36664. if (!e.parent) {
  36665. var t = e.instantiateHierarchy(null, i, (function(e, t) {
  36666. c(e, t)
  36667. }
  36668. ));
  36669. t && a.rootNodes.push(t)
  36670. }
  36671. }
  36672. )),
  36673. this.meshes.forEach((function(s) {
  36674. if (!s.parent) {
  36675. var u = s.instantiateHierarchy(null, i, (function(i, a) {
  36676. if (c(i, a),
  36677. a.material) {
  36678. var s = a;
  36679. if (s.material)
  36680. if (t) {
  36681. var u = i.material;
  36682. if (-1 === l.indexOf(u)) {
  36683. var h = u.clone(e ? e(u.name) : "Clone of " + u.name);
  36684. if (l.push(u),
  36685. r[u.uniqueId] = h.uniqueId,
  36686. o[h.uniqueId] = h,
  36687. "MultiMaterial" === u.getClassName()) {
  36688. for (var d = u, p = 0, f = d.subMaterials; p < f.length; p++) {
  36689. var _ = f[p];
  36690. _ && (h = _.clone(e ? e(_.name) : "Clone of " + _.name),
  36691. l.push(_),
  36692. r[_.uniqueId] = h.uniqueId,
  36693. o[h.uniqueId] = h)
  36694. }
  36695. d.subMaterials = d.subMaterials.map((function(e) {
  36696. return e && o[r[e.uniqueId]]
  36697. }
  36698. ))
  36699. }
  36700. }
  36701. "InstancedMesh" !== s.getClassName() && (s.material = o[r[u.uniqueId]])
  36702. } else
  36703. "MultiMaterial" === s.material.getClassName() ? -1 === n.scene.multiMaterials.indexOf(s.material) && n.scene.addMultiMaterial(s.material) : -1 === n.scene.materials.indexOf(s.material) && n.scene.addMaterial(s.material)
  36704. }
  36705. }
  36706. ));
  36707. u && a.rootNodes.push(u)
  36708. }
  36709. }
  36710. )),
  36711. this.skeletons.forEach((function(t) {
  36712. for (var i = t.clone(e ? e(t.name) : "Clone of " + t.name), l = 0, c = n.meshes; l < c.length; l++) {
  36713. var u = c[l];
  36714. if (u.skeleton === t && !u.isAnInstance) {
  36715. var h = o[r[u.uniqueId]];
  36716. if (h.isAnInstance)
  36717. continue;
  36718. if (h.skeleton = i,
  36719. -1 !== s.indexOf(i))
  36720. continue;
  36721. s.push(i);
  36722. for (var d = 0, p = i.bones; d < p.length; d++) {
  36723. var f = p[d];
  36724. f._linkedTransformNode && (f._linkedTransformNode = o[r[f._linkedTransformNode.uniqueId]])
  36725. }
  36726. }
  36727. }
  36728. a.skeletons.push(i)
  36729. }
  36730. )),
  36731. this.animationGroups.forEach((function(t) {
  36732. var i = t.clone(e ? e(t.name) : "Clone of " + t.name, (function(e) {
  36733. return o[r[e.uniqueId]] || e
  36734. }
  36735. ));
  36736. a.animationGroups.push(i)
  36737. }
  36738. )),
  36739. a
  36740. }
  36741. ,
  36742. t.prototype.addAllToScene = function() {
  36743. var e = this;
  36744. if (!this._wasAddedToScene) {
  36745. this._wasAddedToScene = !0,
  36746. this.cameras.forEach((function(t) {
  36747. e.scene.addCamera(t)
  36748. }
  36749. )),
  36750. this.lights.forEach((function(t) {
  36751. e.scene.addLight(t)
  36752. }
  36753. )),
  36754. this.meshes.forEach((function(t) {
  36755. e.scene.addMesh(t)
  36756. }
  36757. )),
  36758. this.skeletons.forEach((function(t) {
  36759. e.scene.addSkeleton(t)
  36760. }
  36761. )),
  36762. this.animations.forEach((function(t) {
  36763. e.scene.addAnimation(t)
  36764. }
  36765. )),
  36766. this.animationGroups.forEach((function(t) {
  36767. e.scene.addAnimationGroup(t)
  36768. }
  36769. )),
  36770. this.multiMaterials.forEach((function(t) {
  36771. e.scene.addMultiMaterial(t)
  36772. }
  36773. )),
  36774. this.materials.forEach((function(t) {
  36775. e.scene.addMaterial(t)
  36776. }
  36777. )),
  36778. this.morphTargetManagers.forEach((function(t) {
  36779. e.scene.addMorphTargetManager(t)
  36780. }
  36781. )),
  36782. this.geometries.forEach((function(t) {
  36783. e.scene.addGeometry(t)
  36784. }
  36785. )),
  36786. this.transformNodes.forEach((function(t) {
  36787. e.scene.addTransformNode(t)
  36788. }
  36789. )),
  36790. this.actionManagers.forEach((function(t) {
  36791. e.scene.addActionManager(t)
  36792. }
  36793. )),
  36794. this.textures.forEach((function(t) {
  36795. e.scene.addTexture(t)
  36796. }
  36797. )),
  36798. this.reflectionProbes.forEach((function(t) {
  36799. e.scene.addReflectionProbe(t)
  36800. }
  36801. )),
  36802. this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
  36803. for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
  36804. i[t].addFromContainer(this);
  36805. this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  36806. this._onContextRestoredObserver = null
  36807. }
  36808. }
  36809. ,
  36810. t.prototype.removeAllFromScene = function() {
  36811. var e = this;
  36812. this._wasAddedToScene = !1,
  36813. this.cameras.forEach((function(t) {
  36814. e.scene.removeCamera(t)
  36815. }
  36816. )),
  36817. this.lights.forEach((function(t) {
  36818. e.scene.removeLight(t)
  36819. }
  36820. )),
  36821. this.meshes.forEach((function(t) {
  36822. e.scene.removeMesh(t)
  36823. }
  36824. )),
  36825. this.skeletons.forEach((function(t) {
  36826. e.scene.removeSkeleton(t)
  36827. }
  36828. )),
  36829. this.animations.forEach((function(t) {
  36830. e.scene.removeAnimation(t)
  36831. }
  36832. )),
  36833. this.animationGroups.forEach((function(t) {
  36834. e.scene.removeAnimationGroup(t)
  36835. }
  36836. )),
  36837. this.multiMaterials.forEach((function(t) {
  36838. e.scene.removeMultiMaterial(t)
  36839. }
  36840. )),
  36841. this.materials.forEach((function(t) {
  36842. e.scene.removeMaterial(t)
  36843. }
  36844. )),
  36845. this.morphTargetManagers.forEach((function(t) {
  36846. e.scene.removeMorphTargetManager(t)
  36847. }
  36848. )),
  36849. this.geometries.forEach((function(t) {
  36850. e.scene.removeGeometry(t)
  36851. }
  36852. )),
  36853. this.transformNodes.forEach((function(t) {
  36854. e.scene.removeTransformNode(t)
  36855. }
  36856. )),
  36857. this.actionManagers.forEach((function(t) {
  36858. e.scene.removeActionManager(t)
  36859. }
  36860. )),
  36861. this.textures.forEach((function(t) {
  36862. e.scene.removeTexture(t)
  36863. }
  36864. )),
  36865. this.reflectionProbes.forEach((function(t) {
  36866. e.scene.removeReflectionProbe(t)
  36867. }
  36868. )),
  36869. this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
  36870. for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
  36871. i[t].removeFromContainer(this)
  36872. }
  36873. ,
  36874. t.prototype.dispose = function() {
  36875. this.cameras.slice(0).forEach((function(e) {
  36876. e.dispose()
  36877. }
  36878. )),
  36879. this.cameras = [],
  36880. this.lights.slice(0).forEach((function(e) {
  36881. e.dispose()
  36882. }
  36883. )),
  36884. this.lights = [],
  36885. this.meshes.slice(0).forEach((function(e) {
  36886. e.dispose()
  36887. }
  36888. )),
  36889. this.meshes = [],
  36890. this.skeletons.slice(0).forEach((function(e) {
  36891. e.dispose()
  36892. }
  36893. )),
  36894. this.skeletons = [],
  36895. this.animationGroups.slice(0).forEach((function(e) {
  36896. e.dispose()
  36897. }
  36898. )),
  36899. this.animationGroups = [],
  36900. this.multiMaterials.slice(0).forEach((function(e) {
  36901. e.dispose()
  36902. }
  36903. )),
  36904. this.multiMaterials = [],
  36905. this.materials.slice(0).forEach((function(e) {
  36906. e.dispose()
  36907. }
  36908. )),
  36909. this.materials = [],
  36910. this.geometries.slice(0).forEach((function(e) {
  36911. e.dispose()
  36912. }
  36913. )),
  36914. this.geometries = [],
  36915. this.transformNodes.slice(0).forEach((function(e) {
  36916. e.dispose()
  36917. }
  36918. )),
  36919. this.transformNodes = [],
  36920. this.actionManagers.slice(0).forEach((function(e) {
  36921. e.dispose()
  36922. }
  36923. )),
  36924. this.actionManagers = [],
  36925. this.textures.slice(0).forEach((function(e) {
  36926. e.dispose()
  36927. }
  36928. )),
  36929. this.textures = [],
  36930. this.reflectionProbes.slice(0).forEach((function(e) {
  36931. e.dispose()
  36932. }
  36933. )),
  36934. this.reflectionProbes = [],
  36935. this.environmentTexture && (this.environmentTexture.dispose(),
  36936. this.environmentTexture = null);
  36937. for (var e = 0, t = this.scene._serializableComponents; e < t.length; e++)
  36938. t[e].removeFromContainer(this, !0);
  36939. this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  36940. this._onContextRestoredObserver = null)
  36941. }
  36942. ,
  36943. t.prototype._moveAssets = function(e, t, i) {
  36944. if (e)
  36945. for (var n = 0, r = e; n < r.length; n++) {
  36946. var o = r[n]
  36947. , a = !0;
  36948. if (i)
  36949. for (var s = 0, l = i; s < l.length; s++)
  36950. if (o === l[s]) {
  36951. a = !1;
  36952. break
  36953. }
  36954. a && (t.push(o),
  36955. o._parentContainer = this)
  36956. }
  36957. }
  36958. ,
  36959. t.prototype.moveAllFromScene = function(e) {
  36960. for (var t in this._wasAddedToScene = !1,
  36961. void 0 === e && (e = new kr),
  36962. this)
  36963. Object.prototype.hasOwnProperty.call(this, t) && (this[t] = this[t] || ("environmentTexture" === t ? null : []),
  36964. this._moveAssets(this.scene[t], this[t], e[t]));
  36965. this.environmentTexture = this.scene.environmentTexture,
  36966. this.removeAllFromScene()
  36967. }
  36968. ,
  36969. t.prototype.createRootMesh = function() {
  36970. var e = new Vr("assetContainerRootMesh",this.scene);
  36971. return this.meshes.forEach((function(t) {
  36972. t.parent || e.addChild(t)
  36973. }
  36974. )),
  36975. this.meshes.unshift(e),
  36976. e
  36977. }
  36978. ,
  36979. t.prototype.mergeAnimationsTo = function(e, t, i) {
  36980. if (void 0 === e && (e = E.LastCreatedScene),
  36981. void 0 === i && (i = null),
  36982. !e)
  36983. return K.Error("No scene available to merge animations to"),
  36984. [];
  36985. var n = i || function(t) {
  36986. var i = null
  36987. , n = t.animations.length ? t.animations[0].targetProperty : ""
  36988. , r = t.name.split(".").join("").split("_primitive")[0];
  36989. switch (n) {
  36990. case "position":
  36991. case "rotationQuaternion":
  36992. i = e.getTransformNodeByName(t.name) || e.getTransformNodeByName(r);
  36993. break;
  36994. case "influence":
  36995. i = e.getMorphTargetByName(t.name) || e.getMorphTargetByName(r);
  36996. break;
  36997. default:
  36998. i = e.getNodeByName(t.name) || e.getNodeByName(r)
  36999. }
  37000. return i
  37001. }
  37002. ;
  37003. this.getNodes().forEach((function(e) {
  37004. var t = n(e);
  37005. if (null !== t) {
  37006. for (var i = function(e) {
  37007. for (var i = 0, n = t.animations.filter((function(t) {
  37008. return t.targetProperty === e.targetProperty
  37009. }
  37010. )); i < n.length; i++) {
  37011. var r = n[i]
  37012. , o = t.animations.indexOf(r, 0);
  37013. o > -1 && t.animations.splice(o, 1)
  37014. }
  37015. }, r = 0, o = e.animations; r < o.length; r++)
  37016. i(o[r]);
  37017. t.animations = t.animations.concat(e.animations)
  37018. }
  37019. }
  37020. ));
  37021. var r = new Array;
  37022. return this.animationGroups.slice().forEach((function(e) {
  37023. r.push(e.clone(e.name, n)),
  37024. e.animatables.forEach((function(e) {
  37025. e.stop()
  37026. }
  37027. ))
  37028. }
  37029. )),
  37030. t.forEach((function(t) {
  37031. var i = n(t.target);
  37032. i && (e.beginAnimation(i, t.fromFrame, t.toFrame, t.loopAnimation, t.speedRatio, t.onAnimationEnd ? t.onAnimationEnd : void 0, void 0, !0, void 0, t.onAnimationLoop ? t.onAnimationLoop : void 0),
  37033. e.stopAnimation(t.target))
  37034. }
  37035. )),
  37036. r
  37037. }
  37038. ,
  37039. t
  37040. }(o)
  37041. , Wr = function() {
  37042. function e(e) {
  37043. this.SMOOTHING = .75,
  37044. this.FFT_SIZE = 512,
  37045. this.BARGRAPHAMPLITUDE = 256,
  37046. this.DEBUGCANVASPOS = {
  37047. x: 20,
  37048. y: 20
  37049. },
  37050. this.DEBUGCANVASSIZE = {
  37051. width: 320,
  37052. height: 200
  37053. },
  37054. (e = e || E.LastCreatedScene) && (this._scene = e,
  37055. vr.audioEngine ? (this._audioEngine = vr.audioEngine,
  37056. this._audioEngine.canUseWebAudio && this._audioEngine.audioContext && (this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser(),
  37057. this._webAudioAnalyser.minDecibels = -140,
  37058. this._webAudioAnalyser.maxDecibels = 0,
  37059. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount),
  37060. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount),
  37061. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount))) : gi.Warn("No audio engine initialized, failed to create an audio analyser"))
  37062. }
  37063. return e.prototype.getFrequencyBinCount = function() {
  37064. return this._audioEngine.canUseWebAudio ? this._webAudioAnalyser.frequencyBinCount : 0
  37065. }
  37066. ,
  37067. e.prototype.getByteFrequencyData = function() {
  37068. return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
  37069. this._webAudioAnalyser.fftSize = this.FFT_SIZE,
  37070. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),
  37071. this._byteFreqs
  37072. }
  37073. ,
  37074. e.prototype.getByteTimeDomainData = function() {
  37075. return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
  37076. this._webAudioAnalyser.fftSize = this.FFT_SIZE,
  37077. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),
  37078. this._byteTime
  37079. }
  37080. ,
  37081. e.prototype.getFloatFrequencyData = function() {
  37082. return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
  37083. this._webAudioAnalyser.fftSize = this.FFT_SIZE,
  37084. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),
  37085. this._floatFreqs
  37086. }
  37087. ,
  37088. e.prototype.drawDebugCanvas = function() {
  37089. var e = this;
  37090. if (this._audioEngine.canUseWebAudio && (this._debugCanvas || (this._debugCanvas = document.createElement("canvas"),
  37091. this._debugCanvas.width = this.DEBUGCANVASSIZE.width,
  37092. this._debugCanvas.height = this.DEBUGCANVASSIZE.height,
  37093. this._debugCanvas.style.position = "absolute",
  37094. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px",
  37095. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px",
  37096. this._debugCanvasContext = this._debugCanvas.getContext("2d"),
  37097. document.body.appendChild(this._debugCanvas),
  37098. this._registerFunc = function() {
  37099. e.drawDebugCanvas()
  37100. }
  37101. ,
  37102. this._scene.registerBeforeRender(this._registerFunc)),
  37103. this._registerFunc && this._debugCanvasContext)) {
  37104. var t = this.getByteFrequencyData();
  37105. this._debugCanvasContext.fillStyle = "rgb(0, 0, 0)",
  37106. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  37107. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  37108. var n = t[i] / this.BARGRAPHAMPLITUDE
  37109. , r = this.DEBUGCANVASSIZE.height * n
  37110. , o = this.DEBUGCANVASSIZE.height - r - 1
  37111. , a = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount()
  37112. , s = i / this.getFrequencyBinCount() * 360;
  37113. this._debugCanvasContext.fillStyle = "hsl(" + s + ", 100%, 50%)",
  37114. this._debugCanvasContext.fillRect(i * a, o, a, r)
  37115. }
  37116. }
  37117. }
  37118. ,
  37119. e.prototype.stopDebugCanvas = function() {
  37120. this._debugCanvas && (this._registerFunc && (this._scene.unregisterBeforeRender(this._registerFunc),
  37121. this._registerFunc = null),
  37122. document.body.removeChild(this._debugCanvas),
  37123. this._debugCanvas = null,
  37124. this._debugCanvasContext = null)
  37125. }
  37126. ,
  37127. e.prototype.connectAudioNodes = function(e, t) {
  37128. this._audioEngine.canUseWebAudio && (e.connect(this._webAudioAnalyser),
  37129. this._webAudioAnalyser.connect(t))
  37130. }
  37131. ,
  37132. e.prototype.dispose = function() {
  37133. this._audioEngine.canUseWebAudio && this._webAudioAnalyser.disconnect()
  37134. }
  37135. ,
  37136. e
  37137. }();
  37138. vr.AudioEngineFactory = function(e, t, i) {
  37139. return new Hr(e,t,i)
  37140. }
  37141. ;
  37142. var Hr = function() {
  37143. function e(e, t, i) {
  37144. void 0 === e && (e = null),
  37145. void 0 === t && (t = null),
  37146. void 0 === i && (i = null);
  37147. var n = this;
  37148. if (this._audioContext = null,
  37149. this._audioContextInitialized = !1,
  37150. this._muteButton = null,
  37151. this._audioDestination = null,
  37152. this.canUseWebAudio = !1,
  37153. this.WarnedWebAudioUnsupported = !1,
  37154. this.isMP3supported = !1,
  37155. this.isOGGsupported = !1,
  37156. this.unlocked = !0,
  37157. this.useCustomUnlockedButton = !1,
  37158. this.onAudioUnlockedObservable = new h,
  37159. this.onAudioLockedObservable = new h,
  37160. this._tryToRun = !1,
  37161. this._onResize = function() {
  37162. n._moveButtonToTopLeft()
  37163. }
  37164. ,
  37165. nt()) {
  37166. void 0 === window.AudioContext && void 0 === window.webkitAudioContext || (window.AudioContext = window.AudioContext || window.webkitAudioContext,
  37167. this.canUseWebAudio = !0);
  37168. var r = document.createElement("audio");
  37169. this._hostElement = e,
  37170. this._audioContext = t,
  37171. this._audioDestination = i;
  37172. try {
  37173. r && r.canPlayType && (r.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || r.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0)
  37174. } catch (e) {}
  37175. try {
  37176. r && r.canPlayType && r.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0)
  37177. } catch (e) {}
  37178. }
  37179. }
  37180. return Object.defineProperty(e.prototype, "audioContext", {
  37181. get: function() {
  37182. return this._audioContextInitialized ? this.unlocked || this._muteButton || this._displayMuteButton() : this._initializeAudioContext(),
  37183. this._audioContext
  37184. },
  37185. enumerable: !1,
  37186. configurable: !0
  37187. }),
  37188. e.prototype.lock = function() {
  37189. this._triggerSuspendedState()
  37190. }
  37191. ,
  37192. e.prototype.unlock = function() {
  37193. this._triggerRunningState()
  37194. }
  37195. ,
  37196. e.prototype._resumeAudioContext = function() {
  37197. var e;
  37198. return void 0 !== this._audioContext.resume && (e = this._audioContext.resume()),
  37199. e || Promise.resolve()
  37200. }
  37201. ,
  37202. e.prototype._initializeAudioContext = function() {
  37203. try {
  37204. this.canUseWebAudio && (this._audioContext || (this._audioContext = new AudioContext),
  37205. this.masterGain = this._audioContext.createGain(),
  37206. this.masterGain.gain.value = 1,
  37207. this._audioDestination || (this._audioDestination = this._audioContext.destination),
  37208. this.masterGain.connect(this._audioDestination),
  37209. this._audioContextInitialized = !0,
  37210. "running" === this._audioContext.state && this._triggerRunningState())
  37211. } catch (e) {
  37212. this.canUseWebAudio = !1,
  37213. K.Error("Web Audio: " + e.message)
  37214. }
  37215. }
  37216. ,
  37217. e.prototype._triggerRunningState = function() {
  37218. var e = this;
  37219. this._tryToRun || (this._tryToRun = !0,
  37220. this._resumeAudioContext().then((function() {
  37221. e._tryToRun = !1,
  37222. e._muteButton && e._hideMuteButton(),
  37223. e.unlocked = !0,
  37224. e.onAudioUnlockedObservable.notifyObservers(e)
  37225. }
  37226. )).catch((function() {
  37227. e._tryToRun = !1,
  37228. e.unlocked = !1
  37229. }
  37230. )))
  37231. }
  37232. ,
  37233. e.prototype._triggerSuspendedState = function() {
  37234. this.unlocked = !1,
  37235. this.onAudioLockedObservable.notifyObservers(this),
  37236. this._displayMuteButton()
  37237. }
  37238. ,
  37239. e.prototype._displayMuteButton = function() {
  37240. var e = this;
  37241. if (!this.useCustomUnlockedButton && !this._muteButton) {
  37242. this._muteButton = document.createElement("BUTTON"),
  37243. this._muteButton.className = "babylonUnmuteIcon",
  37244. this._muteButton.id = "babylonUnmuteIconBtn",
  37245. this._muteButton.title = "Unmute";
  37246. var t = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E" : "https://cdn.babylonjs.com/Assets/audio.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }"
  37247. , i = document.createElement("style");
  37248. i.appendChild(document.createTextNode(t)),
  37249. document.getElementsByTagName("head")[0].appendChild(i),
  37250. document.body.appendChild(this._muteButton),
  37251. this._moveButtonToTopLeft(),
  37252. this._muteButton.addEventListener("touchend", (function() {
  37253. e._triggerRunningState()
  37254. }
  37255. ), !0),
  37256. this._muteButton.addEventListener("click", (function() {
  37257. e._triggerRunningState()
  37258. }
  37259. ), !0),
  37260. window.addEventListener("resize", this._onResize)
  37261. }
  37262. }
  37263. ,
  37264. e.prototype._moveButtonToTopLeft = function() {
  37265. this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px",
  37266. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px")
  37267. }
  37268. ,
  37269. e.prototype._hideMuteButton = function() {
  37270. this._muteButton && (document.body.removeChild(this._muteButton),
  37271. this._muteButton = null)
  37272. }
  37273. ,
  37274. e.prototype.dispose = function() {
  37275. this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(),
  37276. this._connectedAnalyser.dispose(),
  37277. this.masterGain.disconnect(),
  37278. this.masterGain.connect(this._audioContext.destination),
  37279. this._connectedAnalyser = null),
  37280. this.masterGain.gain.value = 1),
  37281. this.WarnedWebAudioUnsupported = !1,
  37282. this._hideMuteButton(),
  37283. window.removeEventListener("resize", this._onResize),
  37284. this.onAudioUnlockedObservable.clear(),
  37285. this.onAudioLockedObservable.clear()
  37286. }
  37287. ,
  37288. e.prototype.getGlobalVolume = function() {
  37289. return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1
  37290. }
  37291. ,
  37292. e.prototype.setGlobalVolume = function(e) {
  37293. this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = e)
  37294. }
  37295. ,
  37296. e.prototype.connectToAnalyser = function(e) {
  37297. this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
  37298. this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = e,
  37299. this.masterGain.disconnect(),
  37300. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination))
  37301. }
  37302. ,
  37303. e
  37304. }()
  37305. , Xr = function() {
  37306. function e(t, i, n, r, o) {
  37307. void 0 === r && (r = null);
  37308. var a, s, l, c, u, d = this;
  37309. if (this.autoplay = !1,
  37310. this._loop = !1,
  37311. this.useCustomAttenuation = !1,
  37312. this.isPlaying = !1,
  37313. this.isPaused = !1,
  37314. this.refDistance = 1,
  37315. this.rolloffFactor = 1,
  37316. this.maxDistance = 100,
  37317. this.distanceModel = "linear",
  37318. this.metadata = null,
  37319. this.onEndedObservable = new h,
  37320. this._spatialSound = !1,
  37321. this._panningModel = "equalpower",
  37322. this._playbackRate = 1,
  37323. this._streaming = !1,
  37324. this._startTime = 0,
  37325. this._startOffset = 0,
  37326. this._position = x.Zero(),
  37327. this._localDirection = new x(1,0,0),
  37328. this._volume = 1,
  37329. this._isReadyToPlay = !1,
  37330. this._isDirectional = !1,
  37331. this._coneInnerAngle = 360,
  37332. this._coneOuterAngle = 360,
  37333. this._coneOuterGain = 0,
  37334. this._isOutputConnected = !1,
  37335. this._urlType = "Unknown",
  37336. this.name = t,
  37337. n = n || E.LastCreatedScene)
  37338. if (this._scene = n,
  37339. e._SceneComponentInitialization(n),
  37340. this._readyToPlayCallback = r,
  37341. this._customAttenuationFunction = function(e, t, i, n, r) {
  37342. return t < i ? e * (1 - t / i) : 0
  37343. }
  37344. ,
  37345. o && (this.autoplay = o.autoplay || !1,
  37346. this._loop = o.loop || !1,
  37347. void 0 !== o.volume && (this._volume = o.volume),
  37348. this._spatialSound = null !== (a = o.spatialSound) && void 0 !== a && a,
  37349. this.maxDistance = null !== (s = o.maxDistance) && void 0 !== s ? s : 100,
  37350. this.useCustomAttenuation = null !== (l = o.useCustomAttenuation) && void 0 !== l && l,
  37351. this.rolloffFactor = o.rolloffFactor || 1,
  37352. this.refDistance = o.refDistance || 1,
  37353. this.distanceModel = o.distanceModel || "linear",
  37354. this._playbackRate = o.playbackRate || 1,
  37355. this._streaming = null !== (c = o.streaming) && void 0 !== c && c,
  37356. this._length = o.length,
  37357. this._offset = o.offset),
  37358. (null === (u = vr.audioEngine) || void 0 === u ? void 0 : u.canUseWebAudio) && vr.audioEngine.audioContext) {
  37359. this._soundGain = vr.audioEngine.audioContext.createGain(),
  37360. this._soundGain.gain.value = this._volume,
  37361. this._inputAudioNode = this._soundGain,
  37362. this._outputAudioNode = this._soundGain,
  37363. this._spatialSound && this._createSpatialParameters(),
  37364. this._scene.mainSoundTrack.addSound(this);
  37365. var p = !0;
  37366. if (i)
  37367. try {
  37368. "string" == typeof i ? this._urlType = "String" : i instanceof ArrayBuffer ? this._urlType = "ArrayBuffer" : i instanceof HTMLMediaElement ? this._urlType = "MediaElement" : i instanceof MediaStream ? this._urlType = "MediaStream" : Array.isArray(i) && (this._urlType = "Array");
  37369. var f = []
  37370. , _ = !1;
  37371. switch (this._urlType) {
  37372. case "MediaElement":
  37373. this._streaming = !0,
  37374. this._isReadyToPlay = !0,
  37375. this._streamingSource = vr.audioEngine.audioContext.createMediaElementSource(i),
  37376. this.autoplay && this.play(0, this._offset, this._length),
  37377. this._readyToPlayCallback && this._readyToPlayCallback();
  37378. break;
  37379. case "MediaStream":
  37380. this._streaming = !0,
  37381. this._isReadyToPlay = !0,
  37382. this._streamingSource = vr.audioEngine.audioContext.createMediaStreamSource(i),
  37383. this.autoplay && this.play(0, this._offset, this._length),
  37384. this._readyToPlayCallback && this._readyToPlayCallback();
  37385. break;
  37386. case "ArrayBuffer":
  37387. i.byteLength > 0 && (_ = !0,
  37388. this._soundLoaded(i));
  37389. break;
  37390. case "String":
  37391. f.push(i);
  37392. case "Array":
  37393. 0 === f.length && (f = i);
  37394. for (var m = function(e) {
  37395. var t = f[e];
  37396. if (_ = o && o.skipCodecCheck || -1 !== t.indexOf(".mp3", t.length - 4) && vr.audioEngine.isMP3supported || -1 !== t.indexOf(".ogg", t.length - 4) && vr.audioEngine.isOGGsupported || -1 !== t.indexOf(".wav", t.length - 4) || -1 !== t.indexOf(".m4a", t.length - 4) || -1 !== t.indexOf(".mp4", t.length - 4) || -1 !== t.indexOf("blob:"))
  37397. return g._streaming ? (g._htmlAudioElement = new Audio(t),
  37398. g._htmlAudioElement.controls = !1,
  37399. g._htmlAudioElement.loop = g.loop,
  37400. gi.SetCorsBehavior(t, g._htmlAudioElement),
  37401. g._htmlAudioElement.preload = "auto",
  37402. g._htmlAudioElement.addEventListener("canplaythrough", (function() {
  37403. d._isReadyToPlay = !0,
  37404. d.autoplay && d.play(0, d._offset, d._length),
  37405. d._readyToPlayCallback && d._readyToPlayCallback()
  37406. }
  37407. )),
  37408. document.body.appendChild(g._htmlAudioElement),
  37409. g._htmlAudioElement.load()) : g._scene._loadFile(t, (function(e) {
  37410. d._soundLoaded(e)
  37411. }
  37412. ), void 0, !0, !0, (function(e) {
  37413. e && K.Error("XHR " + e.status + " error on: " + t + "."),
  37414. K.Error("Sound creation aborted."),
  37415. d._scene.mainSoundTrack.removeSound(d)
  37416. }
  37417. )),
  37418. "break"
  37419. }, g = this, v = 0; v < f.length && "break" !== m(v); v++)
  37420. ;
  37421. break;
  37422. default:
  37423. p = !1
  37424. }
  37425. p ? _ || (this._isReadyToPlay = !0,
  37426. this._readyToPlayCallback && window.setTimeout((function() {
  37427. d._readyToPlayCallback && d._readyToPlayCallback()
  37428. }
  37429. ), 1e3)) : K.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")
  37430. } catch (e) {
  37431. K.Error("Unexpected error. Sound creation aborted."),
  37432. this._scene.mainSoundTrack.removeSound(this)
  37433. }
  37434. } else
  37435. this._scene.mainSoundTrack.addSound(this),
  37436. vr.audioEngine && !vr.audioEngine.WarnedWebAudioUnsupported && (K.Error("Web Audio is not supported by your browser."),
  37437. vr.audioEngine.WarnedWebAudioUnsupported = !0),
  37438. this._readyToPlayCallback && window.setTimeout((function() {
  37439. d._readyToPlayCallback && d._readyToPlayCallback()
  37440. }
  37441. ), 1e3)
  37442. }
  37443. return Object.defineProperty(e.prototype, "loop", {
  37444. get: function() {
  37445. return this._loop
  37446. },
  37447. set: function(e) {
  37448. e !== this._loop && (this._loop = e,
  37449. this.updateOptions({
  37450. loop: e
  37451. }))
  37452. },
  37453. enumerable: !1,
  37454. configurable: !0
  37455. }),
  37456. Object.defineProperty(e.prototype, "currentTime", {
  37457. get: function() {
  37458. var e;
  37459. if (this._htmlAudioElement)
  37460. return this._htmlAudioElement.currentTime;
  37461. var t = this._startOffset;
  37462. return this.isPlaying && (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (t += vr.audioEngine.audioContext.currentTime - this._startTime),
  37463. t
  37464. },
  37465. enumerable: !1,
  37466. configurable: !0
  37467. }),
  37468. Object.defineProperty(e.prototype, "spatialSound", {
  37469. get: function() {
  37470. return this._spatialSound
  37471. },
  37472. set: function(e) {
  37473. var t;
  37474. this._spatialSound = e,
  37475. this._spatialSound && (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && vr.audioEngine.audioContext && this._createSpatialParameters()
  37476. },
  37477. enumerable: !1,
  37478. configurable: !0
  37479. }),
  37480. e.prototype.dispose = function() {
  37481. var e;
  37482. (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && (this.isPlaying && this.stop(),
  37483. this._isReadyToPlay = !1,
  37484. -1 === this.soundTrackId ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this),
  37485. this._soundGain && (this._soundGain.disconnect(),
  37486. this._soundGain = null),
  37487. this._soundPanner && (this._soundPanner.disconnect(),
  37488. this._soundPanner = null),
  37489. this._soundSource && (this._soundSource.disconnect(),
  37490. this._soundSource = null),
  37491. this._audioBuffer = null,
  37492. this._htmlAudioElement && (this._htmlAudioElement.pause(),
  37493. this._htmlAudioElement.src = "",
  37494. document.body.removeChild(this._htmlAudioElement)),
  37495. this._streamingSource && this._streamingSource.disconnect(),
  37496. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  37497. this._connectedTransformNode = null))
  37498. }
  37499. ,
  37500. e.prototype.isReady = function() {
  37501. return this._isReadyToPlay
  37502. }
  37503. ,
  37504. e.prototype.getClassName = function() {
  37505. return "Sound"
  37506. }
  37507. ,
  37508. e.prototype._soundLoaded = function(e) {
  37509. var t, i = this;
  37510. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && vr.audioEngine.audioContext.decodeAudioData(e, (function(e) {
  37511. i._audioBuffer = e,
  37512. i._isReadyToPlay = !0,
  37513. i.autoplay && i.play(0, i._offset, i._length),
  37514. i._readyToPlayCallback && i._readyToPlayCallback()
  37515. }
  37516. ), (function(e) {
  37517. K.Error("Error while decoding audio data for: " + i.name + " / Error: " + e)
  37518. }
  37519. ))
  37520. }
  37521. ,
  37522. e.prototype.setAudioBuffer = function(e) {
  37523. var t;
  37524. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && (this._audioBuffer = e,
  37525. this._isReadyToPlay = !0)
  37526. }
  37527. ,
  37528. e.prototype.updateOptions = function(e) {
  37529. var t, i, n, r, o, a, s, l, c, u;
  37530. e && (this.loop = null !== (t = e.loop) && void 0 !== t ? t : this.loop,
  37531. this.maxDistance = null !== (i = e.maxDistance) && void 0 !== i ? i : this.maxDistance,
  37532. this.useCustomAttenuation = null !== (n = e.useCustomAttenuation) && void 0 !== n ? n : this.useCustomAttenuation,
  37533. this.rolloffFactor = null !== (r = e.rolloffFactor) && void 0 !== r ? r : this.rolloffFactor,
  37534. this.refDistance = null !== (o = e.refDistance) && void 0 !== o ? o : this.refDistance,
  37535. this.distanceModel = null !== (a = e.distanceModel) && void 0 !== a ? a : this.distanceModel,
  37536. this._playbackRate = null !== (s = e.playbackRate) && void 0 !== s ? s : this._playbackRate,
  37537. this._length = null !== (l = e.length) && void 0 !== l ? l : void 0,
  37538. this._offset = null !== (c = e.offset) && void 0 !== c ? c : void 0,
  37539. this.setVolume(null !== (u = e.volume) && void 0 !== u ? u : this._volume),
  37540. this._updateSpatialParameters(),
  37541. this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate,
  37542. this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate,
  37543. this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop),
  37544. void 0 !== this._offset && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset),
  37545. void 0 !== this._length && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (0 | this._offset) + this._length))))
  37546. }
  37547. ,
  37548. e.prototype._createSpatialParameters = function() {
  37549. var e, t;
  37550. (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"),
  37551. this._soundPanner = null !== (t = this._soundPanner) && void 0 !== t ? t : vr.audioEngine.audioContext.createPanner(),
  37552. this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(),
  37553. this._soundPanner.connect(this._outputAudioNode),
  37554. this._inputAudioNode = this._soundPanner))
  37555. }
  37556. ,
  37557. e.prototype._updateSpatialParameters = function() {
  37558. this._spatialSound && this._soundPanner && (this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear",
  37559. this._soundPanner.maxDistance = Number.MAX_VALUE,
  37560. this._soundPanner.refDistance = 1,
  37561. this._soundPanner.rolloffFactor = 1,
  37562. this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel,
  37563. this._soundPanner.maxDistance = this.maxDistance,
  37564. this._soundPanner.refDistance = this.refDistance,
  37565. this._soundPanner.rolloffFactor = this.rolloffFactor,
  37566. this._soundPanner.panningModel = this._panningModel))
  37567. }
  37568. ,
  37569. e.prototype.switchPanningModelToHRTF = function() {
  37570. this._panningModel = "HRTF",
  37571. this._switchPanningModel()
  37572. }
  37573. ,
  37574. e.prototype.switchPanningModelToEqualPower = function() {
  37575. this._panningModel = "equalpower",
  37576. this._switchPanningModel()
  37577. }
  37578. ,
  37579. e.prototype._switchPanningModel = function() {
  37580. var e;
  37581. (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel)
  37582. }
  37583. ,
  37584. e.prototype.connectToSoundTrackAudioNode = function(e) {
  37585. var t;
  37586. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(),
  37587. this._outputAudioNode.connect(e),
  37588. this._isOutputConnected = !0)
  37589. }
  37590. ,
  37591. e.prototype.setDirectionalCone = function(e, t, i) {
  37592. t < e ? K.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.") : (this._coneInnerAngle = e,
  37593. this._coneOuterAngle = t,
  37594. this._coneOuterGain = i,
  37595. this._isDirectional = !0,
  37596. this.isPlaying && this.loop && (this.stop(),
  37597. this.play(0, this._offset, this._length)))
  37598. }
  37599. ,
  37600. Object.defineProperty(e.prototype, "directionalConeInnerAngle", {
  37601. get: function() {
  37602. return this._coneInnerAngle
  37603. },
  37604. set: function(e) {
  37605. var t;
  37606. if (e != this._coneInnerAngle) {
  37607. if (this._coneOuterAngle < e)
  37608. return void K.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  37609. this._coneInnerAngle = e,
  37610. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle)
  37611. }
  37612. },
  37613. enumerable: !1,
  37614. configurable: !0
  37615. }),
  37616. Object.defineProperty(e.prototype, "directionalConeOuterAngle", {
  37617. get: function() {
  37618. return this._coneOuterAngle
  37619. },
  37620. set: function(e) {
  37621. var t;
  37622. if (e != this._coneOuterAngle) {
  37623. if (e < this._coneInnerAngle)
  37624. return void K.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  37625. this._coneOuterAngle = e,
  37626. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle)
  37627. }
  37628. },
  37629. enumerable: !1,
  37630. configurable: !0
  37631. }),
  37632. e.prototype.setPosition = function(e) {
  37633. var t;
  37634. e.equals(this._position) || (this._position.copyFrom(e),
  37635. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && (this._soundPanner.positionX.value = this._position.x,
  37636. this._soundPanner.positionY.value = this._position.y,
  37637. this._soundPanner.positionZ.value = this._position.z))
  37638. }
  37639. ,
  37640. e.prototype.setLocalDirectionToMesh = function(e) {
  37641. var t;
  37642. this._localDirection = e,
  37643. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._connectedTransformNode && this.isPlaying && this._updateDirection()
  37644. }
  37645. ,
  37646. e.prototype._updateDirection = function() {
  37647. if (this._connectedTransformNode && this._soundPanner) {
  37648. var e = this._connectedTransformNode.getWorldMatrix()
  37649. , t = x.TransformNormal(this._localDirection, e);
  37650. t.normalize(),
  37651. this._soundPanner.orientationX.value = t.x,
  37652. this._soundPanner.orientationY.value = t.y,
  37653. this._soundPanner.orientationZ.value = t.z
  37654. }
  37655. }
  37656. ,
  37657. e.prototype.updateDistanceFromListener = function() {
  37658. var e;
  37659. if ((null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  37660. var t = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  37661. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, t, this.maxDistance, this.refDistance, this.rolloffFactor)
  37662. }
  37663. }
  37664. ,
  37665. e.prototype.setAttenuationFunction = function(e) {
  37666. this._customAttenuationFunction = e
  37667. }
  37668. ,
  37669. e.prototype.play = function(e, t, i) {
  37670. var n, r, o, a, s = this;
  37671. if (this._isReadyToPlay && this._scene.audioEnabled && (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext))
  37672. try {
  37673. this._startOffset < 0 && (e = -this._startOffset,
  37674. this._startOffset = 0);
  37675. var l = e ? (null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.audioContext.currentTime) + e : null === (o = vr.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime;
  37676. if (this._soundSource && this._streamingSource || this._spatialSound && this._soundPanner && (isNaN(this._position.x) || isNaN(this._position.y) || isNaN(this._position.z) || (this._soundPanner.positionX.value = this._position.x,
  37677. this._soundPanner.positionY.value = this._position.y,
  37678. this._soundPanner.positionZ.value = this._position.z),
  37679. this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle,
  37680. this._soundPanner.coneOuterAngle = this._coneOuterAngle,
  37681. this._soundPanner.coneOuterGain = this._coneOuterGain,
  37682. this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))),
  37683. this._streaming) {
  37684. if (this._streamingSource || (this._streamingSource = vr.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),
  37685. this._htmlAudioElement.onended = function() {
  37686. s._onended()
  37687. }
  37688. ,
  37689. this._htmlAudioElement.playbackRate = this._playbackRate),
  37690. this._streamingSource.disconnect(),
  37691. this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode),
  37692. this._htmlAudioElement) {
  37693. var c = function() {
  37694. var e, t;
  37695. if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.unlocked) {
  37696. var i = s._htmlAudioElement.play();
  37697. void 0 !== i && i.catch((function() {
  37698. var e, t;
  37699. null === (e = vr.audioEngine) || void 0 === e || e.lock(),
  37700. (s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
  37701. c()
  37702. }
  37703. )))
  37704. }
  37705. ))
  37706. } else
  37707. (s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
  37708. c()
  37709. }
  37710. )))
  37711. };
  37712. c()
  37713. }
  37714. } else {
  37715. var u = function() {
  37716. var n, r, o;
  37717. if (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext) {
  37718. if (i = i || s._length,
  37719. t = t || s._offset,
  37720. s._soundSource) {
  37721. var a = s._soundSource;
  37722. a.onended = function() {
  37723. a.disconnect()
  37724. }
  37725. }
  37726. if (s._soundSource = null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.audioContext.createBufferSource(),
  37727. s._soundSource && s._inputAudioNode) {
  37728. s._soundSource.buffer = s._audioBuffer,
  37729. s._soundSource.connect(s._inputAudioNode),
  37730. s._soundSource.loop = s.loop,
  37731. void 0 !== t && (s._soundSource.loopStart = t),
  37732. void 0 !== i && (s._soundSource.loopEnd = (0 | t) + i),
  37733. s._soundSource.playbackRate.value = s._playbackRate,
  37734. s._soundSource.onended = function() {
  37735. s._onended()
  37736. }
  37737. ,
  37738. l = e ? (null === (o = vr.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime) + e : vr.audioEngine.audioContext.currentTime;
  37739. var c = s.isPaused ? s._startOffset % s._soundSource.buffer.duration : t || 0;
  37740. s._soundSource.start(l, c, s.loop ? void 0 : i)
  37741. }
  37742. }
  37743. };
  37744. "suspended" === (null === (a = vr.audioEngine) || void 0 === a ? void 0 : a.audioContext.state) ? setTimeout((function() {
  37745. var e;
  37746. "suspended" === (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext.state) ? (vr.audioEngine.lock(),
  37747. (s.loop || s.autoplay) && vr.audioEngine.onAudioUnlockedObservable.addOnce((function() {
  37748. u()
  37749. }
  37750. ))) : u()
  37751. }
  37752. ), 500) : u()
  37753. }
  37754. this._startTime = l,
  37755. this.isPlaying = !0,
  37756. this.isPaused = !1
  37757. } catch (e) {
  37758. K.Error("Error while trying to play audio: " + this.name + ", " + e.message)
  37759. }
  37760. }
  37761. ,
  37762. e.prototype._onended = function() {
  37763. this.isPlaying = !1,
  37764. this._startOffset = 0,
  37765. this.onended && this.onended(),
  37766. this.onEndedObservable.notifyObservers(this)
  37767. }
  37768. ,
  37769. e.prototype.stop = function(e) {
  37770. var t, i = this;
  37771. if (this.isPlaying)
  37772. if (this._streaming)
  37773. this._htmlAudioElement ? (this._htmlAudioElement.pause(),
  37774. this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(),
  37775. this.isPlaying = !1;
  37776. else if ((null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && this._soundSource) {
  37777. var n = e ? vr.audioEngine.audioContext.currentTime + e : void 0;
  37778. this._soundSource.stop(n),
  37779. void 0 === n ? (this.isPlaying = !1,
  37780. this._soundSource.onended = function() {}
  37781. ) : this._soundSource.onended = function() {
  37782. i.isPlaying = !1
  37783. }
  37784. ,
  37785. this.isPaused || (this._startOffset = 0)
  37786. }
  37787. }
  37788. ,
  37789. e.prototype.pause = function() {
  37790. var e;
  37791. this.isPlaying && (this.isPaused = !0,
  37792. this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(),
  37793. this.isPlaying = !1) : (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (this.stop(0),
  37794. this._startOffset += vr.audioEngine.audioContext.currentTime - this._startTime))
  37795. }
  37796. ,
  37797. e.prototype.setVolume = function(e, t) {
  37798. var i;
  37799. (null === (i = vr.audioEngine) || void 0 === i ? void 0 : i.canUseWebAudio) && this._soundGain && (t && vr.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(vr.audioEngine.audioContext.currentTime),
  37800. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, vr.audioEngine.audioContext.currentTime),
  37801. this._soundGain.gain.linearRampToValueAtTime(e, vr.audioEngine.audioContext.currentTime + t)) : this._soundGain.gain.value = e),
  37802. this._volume = e
  37803. }
  37804. ,
  37805. e.prototype.setPlaybackRate = function(e) {
  37806. this._playbackRate = e,
  37807. this.isPlaying && (this._streaming && this._htmlAudioElement ? this._htmlAudioElement.playbackRate = this._playbackRate : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate))
  37808. }
  37809. ,
  37810. e.prototype.getVolume = function() {
  37811. return this._volume
  37812. }
  37813. ,
  37814. e.prototype.attachToMesh = function(e) {
  37815. var t = this;
  37816. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  37817. this._registerFunc = null),
  37818. this._connectedTransformNode = e,
  37819. this._spatialSound || (this._spatialSound = !0,
  37820. this._createSpatialParameters(),
  37821. this.isPlaying && this.loop && (this.stop(),
  37822. this.play(0, this._offset, this._length))),
  37823. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),
  37824. this._registerFunc = function(e) {
  37825. return t._onRegisterAfterWorldMatrixUpdate(e)
  37826. }
  37827. ,
  37828. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)
  37829. }
  37830. ,
  37831. e.prototype.detachFromMesh = function() {
  37832. this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
  37833. this._registerFunc = null,
  37834. this._connectedTransformNode = null)
  37835. }
  37836. ,
  37837. e.prototype._onRegisterAfterWorldMatrixUpdate = function(e) {
  37838. var t;
  37839. if (e.getBoundingInfo) {
  37840. var i = e.getBoundingInfo();
  37841. this.setPosition(i.boundingSphere.centerWorld)
  37842. } else
  37843. this.setPosition(e.absolutePosition);
  37844. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._isDirectional && this.isPlaying && this._updateDirection()
  37845. }
  37846. ,
  37847. e.prototype.clone = function() {
  37848. var t = this;
  37849. if (this._streaming)
  37850. return null;
  37851. var i = function() {
  37852. t._isReadyToPlay ? (r._audioBuffer = t.getAudioBuffer(),
  37853. r._isReadyToPlay = !0,
  37854. r.autoplay && r.play(0, t._offset, t._length)) : window.setTimeout(i, 300)
  37855. }
  37856. , n = {
  37857. autoplay: this.autoplay,
  37858. loop: this.loop,
  37859. volume: this._volume,
  37860. spatialSound: this._spatialSound,
  37861. maxDistance: this.maxDistance,
  37862. useCustomAttenuation: this.useCustomAttenuation,
  37863. rolloffFactor: this.rolloffFactor,
  37864. refDistance: this.refDistance,
  37865. distanceModel: this.distanceModel
  37866. }
  37867. , r = new e(this.name + "_cloned",new ArrayBuffer(0),this._scene,null,n);
  37868. return this.useCustomAttenuation && r.setAttenuationFunction(this._customAttenuationFunction),
  37869. r.setPosition(this._position),
  37870. r.setPlaybackRate(this._playbackRate),
  37871. i(),
  37872. r
  37873. }
  37874. ,
  37875. e.prototype.getAudioBuffer = function() {
  37876. return this._audioBuffer
  37877. }
  37878. ,
  37879. e.prototype.getSoundSource = function() {
  37880. return this._soundSource
  37881. }
  37882. ,
  37883. e.prototype.getSoundGain = function() {
  37884. return this._soundGain
  37885. }
  37886. ,
  37887. e.prototype.serialize = function() {
  37888. var e = {
  37889. name: this.name,
  37890. url: this.name,
  37891. autoplay: this.autoplay,
  37892. loop: this.loop,
  37893. volume: this._volume,
  37894. spatialSound: this._spatialSound,
  37895. maxDistance: this.maxDistance,
  37896. rolloffFactor: this.rolloffFactor,
  37897. refDistance: this.refDistance,
  37898. distanceModel: this.distanceModel,
  37899. playbackRate: this._playbackRate,
  37900. panningModel: this._panningModel,
  37901. soundTrackId: this.soundTrackId,
  37902. metadata: this.metadata
  37903. };
  37904. return this._spatialSound && (this._connectedTransformNode && (e.connectedMeshId = this._connectedTransformNode.id),
  37905. e.position = this._position.asArray(),
  37906. e.refDistance = this.refDistance,
  37907. e.distanceModel = this.distanceModel,
  37908. e.isDirectional = this._isDirectional,
  37909. e.localDirectionToMesh = this._localDirection.asArray(),
  37910. e.coneInnerAngle = this._coneInnerAngle,
  37911. e.coneOuterAngle = this._coneOuterAngle,
  37912. e.coneOuterGain = this._coneOuterGain),
  37913. e
  37914. }
  37915. ,
  37916. e.Parse = function(t, i, n, r) {
  37917. var o, a = t.name;
  37918. o = t.url ? n + t.url : n + a;
  37919. var s, l = {
  37920. autoplay: t.autoplay,
  37921. loop: t.loop,
  37922. volume: t.volume,
  37923. spatialSound: t.spatialSound,
  37924. maxDistance: t.maxDistance,
  37925. rolloffFactor: t.rolloffFactor,
  37926. refDistance: t.refDistance,
  37927. distanceModel: t.distanceModel,
  37928. playbackRate: t.playbackRate
  37929. };
  37930. if (r) {
  37931. var c = function() {
  37932. r._isReadyToPlay ? (s._audioBuffer = r.getAudioBuffer(),
  37933. s._isReadyToPlay = !0,
  37934. s.autoplay && s.play(0, s._offset, s._length)) : window.setTimeout(c, 300)
  37935. };
  37936. s = new e(a,new ArrayBuffer(0),i,null,l),
  37937. c()
  37938. } else
  37939. s = new e(a,o,i,(function() {
  37940. i._removePendingData(s)
  37941. }
  37942. ),l),
  37943. i._addPendingData(s);
  37944. if (t.position) {
  37945. var u = x.FromArray(t.position);
  37946. s.setPosition(u)
  37947. }
  37948. if (t.isDirectional && (s.setDirectionalCone(t.coneInnerAngle || 360, t.coneOuterAngle || 360, t.coneOuterGain || 0),
  37949. t.localDirectionToMesh)) {
  37950. var h = x.FromArray(t.localDirectionToMesh);
  37951. s.setLocalDirectionToMesh(h)
  37952. }
  37953. if (t.connectedMeshId) {
  37954. var d = i.getMeshById(t.connectedMeshId);
  37955. d && s.attachToMesh(d)
  37956. }
  37957. return t.metadata && (s.metadata = t.metadata),
  37958. s
  37959. }
  37960. ,
  37961. e._SceneComponentInitialization = function(e) {
  37962. throw be("AudioSceneComponent")
  37963. }
  37964. ,
  37965. e
  37966. }()
  37967. , jr = function() {
  37968. function e(e, t) {
  37969. void 0 === t && (t = {}),
  37970. this.id = -1,
  37971. this._isInitialized = !1,
  37972. (e = e || E.LastCreatedScene) && (this._scene = e,
  37973. this.soundCollection = new Array,
  37974. this._options = t,
  37975. !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this),
  37976. this.id = this._scene.soundTracks.length - 1))
  37977. }
  37978. return e.prototype._initializeSoundTrackAudioGraph = function() {
  37979. var e;
  37980. (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._outputAudioNode = vr.audioEngine.audioContext.createGain(),
  37981. this._outputAudioNode.connect(vr.audioEngine.masterGain),
  37982. this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume),
  37983. this._isInitialized = !0)
  37984. }
  37985. ,
  37986. e.prototype.dispose = function() {
  37987. if (vr.audioEngine && vr.audioEngine.canUseWebAudio) {
  37988. for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
  37989. this.soundCollection[0].dispose();
  37990. this._outputAudioNode && this._outputAudioNode.disconnect(),
  37991. this._outputAudioNode = null
  37992. }
  37993. }
  37994. ,
  37995. e.prototype.addSound = function(e) {
  37996. var t;
  37997. this._isInitialized || this._initializeSoundTrackAudioGraph(),
  37998. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && e.connectToSoundTrackAudioNode(this._outputAudioNode),
  37999. e.soundTrackId && (-1 === e.soundTrackId ? this._scene.mainSoundTrack.removeSound(e) : this._scene.soundTracks && this._scene.soundTracks[e.soundTrackId].removeSound(e)),
  38000. this.soundCollection.push(e),
  38001. e.soundTrackId = this.id
  38002. }
  38003. ,
  38004. e.prototype.removeSound = function(e) {
  38005. var t = this.soundCollection.indexOf(e);
  38006. -1 !== t && this.soundCollection.splice(t, 1)
  38007. }
  38008. ,
  38009. e.prototype.setVolume = function(e) {
  38010. var t;
  38011. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e)
  38012. }
  38013. ,
  38014. e.prototype.switchPanningModelToHRTF = function() {
  38015. var e;
  38016. if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio)
  38017. for (var t = 0; t < this.soundCollection.length; t++)
  38018. this.soundCollection[t].switchPanningModelToHRTF()
  38019. }
  38020. ,
  38021. e.prototype.switchPanningModelToEqualPower = function() {
  38022. var e;
  38023. if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio)
  38024. for (var t = 0; t < this.soundCollection.length; t++)
  38025. this.soundCollection[t].switchPanningModelToEqualPower()
  38026. }
  38027. ,
  38028. e.prototype.connectToAnalyser = function(e) {
  38029. var t;
  38030. this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
  38031. this._connectedAnalyser = e,
  38032. (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(),
  38033. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, vr.audioEngine.masterGain))
  38034. }
  38035. ,
  38036. e
  38037. }();
  38038. o.AddParser(Wi.NAME_AUDIO, (function(e, t, i, n) {
  38039. var r, o, a = [];
  38040. if (i.sounds = i.sounds || [],
  38041. void 0 !== e.sounds && null !== e.sounds)
  38042. for (var s = 0, l = e.sounds.length; s < l; s++) {
  38043. var c = e.sounds[s];
  38044. (null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.canUseWebAudio) ? (c.url || (c.url = c.name),
  38045. a[c.url] ? i.sounds.push(Xr.Parse(c, t, n, a[c.url])) : (o = Xr.Parse(c, t, n),
  38046. a[c.url] = o,
  38047. i.sounds.push(o))) : i.sounds.push(new Xr(c.name,null,t))
  38048. }
  38049. a = []
  38050. }
  38051. )),
  38052. Object.defineProperty(mn.prototype, "mainSoundTrack", {
  38053. get: function() {
  38054. var e = this._getComponent(Wi.NAME_AUDIO);
  38055. return e || (e = new Yr(this),
  38056. this._addComponent(e)),
  38057. this._mainSoundTrack || (this._mainSoundTrack = new jr(this,{
  38058. mainTrack: !0
  38059. })),
  38060. this._mainSoundTrack
  38061. },
  38062. enumerable: !0,
  38063. configurable: !0
  38064. }),
  38065. mn.prototype.getSoundByName = function(e) {
  38066. var t;
  38067. for (t = 0; t < this.mainSoundTrack.soundCollection.length; t++)
  38068. if (this.mainSoundTrack.soundCollection[t].name === e)
  38069. return this.mainSoundTrack.soundCollection[t];
  38070. if (this.soundTracks)
  38071. for (var i = 0; i < this.soundTracks.length; i++)
  38072. for (t = 0; t < this.soundTracks[i].soundCollection.length; t++)
  38073. if (this.soundTracks[i].soundCollection[t].name === e)
  38074. return this.soundTracks[i].soundCollection[t];
  38075. return null
  38076. }
  38077. ,
  38078. Object.defineProperty(mn.prototype, "audioEnabled", {
  38079. get: function() {
  38080. var e = this._getComponent(Wi.NAME_AUDIO);
  38081. return e || (e = new Yr(this),
  38082. this._addComponent(e)),
  38083. e.audioEnabled
  38084. },
  38085. set: function(e) {
  38086. var t = this._getComponent(Wi.NAME_AUDIO);
  38087. t || (t = new Yr(this),
  38088. this._addComponent(t)),
  38089. e ? t.enableAudio() : t.disableAudio()
  38090. },
  38091. enumerable: !0,
  38092. configurable: !0
  38093. }),
  38094. Object.defineProperty(mn.prototype, "headphone", {
  38095. get: function() {
  38096. var e = this._getComponent(Wi.NAME_AUDIO);
  38097. return e || (e = new Yr(this),
  38098. this._addComponent(e)),
  38099. e.headphone
  38100. },
  38101. set: function(e) {
  38102. var t = this._getComponent(Wi.NAME_AUDIO);
  38103. t || (t = new Yr(this),
  38104. this._addComponent(t)),
  38105. e ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers()
  38106. },
  38107. enumerable: !0,
  38108. configurable: !0
  38109. }),
  38110. Object.defineProperty(mn.prototype, "audioListenerPositionProvider", {
  38111. get: function() {
  38112. var e = this._getComponent(Wi.NAME_AUDIO);
  38113. return e || (e = new Yr(this),
  38114. this._addComponent(e)),
  38115. e.audioListenerPositionProvider
  38116. },
  38117. set: function(e) {
  38118. var t = this._getComponent(Wi.NAME_AUDIO);
  38119. if (t || (t = new Yr(this),
  38120. this._addComponent(t)),
  38121. "function" != typeof e)
  38122. throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
  38123. t.audioListenerPositionProvider = e
  38124. },
  38125. enumerable: !0,
  38126. configurable: !0
  38127. }),
  38128. Object.defineProperty(mn.prototype, "audioPositioningRefreshRate", {
  38129. get: function() {
  38130. var e = this._getComponent(Wi.NAME_AUDIO);
  38131. return e || (e = new Yr(this),
  38132. this._addComponent(e)),
  38133. e.audioPositioningRefreshRate
  38134. },
  38135. set: function(e) {
  38136. var t = this._getComponent(Wi.NAME_AUDIO);
  38137. t || (t = new Yr(this),
  38138. this._addComponent(t)),
  38139. t.audioPositioningRefreshRate = e
  38140. },
  38141. enumerable: !0,
  38142. configurable: !0
  38143. });
  38144. var Yr = function() {
  38145. function e(e) {
  38146. this.name = Wi.NAME_AUDIO,
  38147. this._audioEnabled = !0,
  38148. this._headphone = !1,
  38149. this.audioPositioningRefreshRate = 500,
  38150. this._audioListenerPositionProvider = null,
  38151. this._cachedCameraDirection = new x,
  38152. this._cachedCameraPosition = new x,
  38153. this._lastCheck = 0,
  38154. (e = e || E.LastCreatedScene) && (this.scene = e,
  38155. e.soundTracks = new Array,
  38156. e.sounds = new Array)
  38157. }
  38158. return Object.defineProperty(e.prototype, "audioEnabled", {
  38159. get: function() {
  38160. return this._audioEnabled
  38161. },
  38162. enumerable: !1,
  38163. configurable: !0
  38164. }),
  38165. Object.defineProperty(e.prototype, "headphone", {
  38166. get: function() {
  38167. return this._headphone
  38168. },
  38169. enumerable: !1,
  38170. configurable: !0
  38171. }),
  38172. Object.defineProperty(e.prototype, "audioListenerPositionProvider", {
  38173. get: function() {
  38174. return this._audioListenerPositionProvider
  38175. },
  38176. set: function(e) {
  38177. this._audioListenerPositionProvider = e
  38178. },
  38179. enumerable: !1,
  38180. configurable: !0
  38181. }),
  38182. e.prototype.register = function() {
  38183. this.scene._afterRenderStage.registerStep(Wi.STEP_AFTERRENDER_AUDIO, this, this._afterRender)
  38184. }
  38185. ,
  38186. e.prototype.rebuild = function() {}
  38187. ,
  38188. e.prototype.serialize = function(e) {
  38189. if (e.sounds = [],
  38190. this.scene.soundTracks)
  38191. for (var t = 0; t < this.scene.soundTracks.length; t++)
  38192. for (var i = this.scene.soundTracks[t], n = 0; n < i.soundCollection.length; n++)
  38193. e.sounds.push(i.soundCollection[n].serialize())
  38194. }
  38195. ,
  38196. e.prototype.addFromContainer = function(e) {
  38197. var t = this;
  38198. e.sounds && e.sounds.forEach((function(e) {
  38199. e.play(),
  38200. e.autoplay = !0,
  38201. t.scene.mainSoundTrack.addSound(e)
  38202. }
  38203. ))
  38204. }
  38205. ,
  38206. e.prototype.removeFromContainer = function(e, t) {
  38207. var i = this;
  38208. void 0 === t && (t = !1),
  38209. e.sounds && e.sounds.forEach((function(e) {
  38210. e.stop(),
  38211. e.autoplay = !1,
  38212. i.scene.mainSoundTrack.removeSound(e),
  38213. t && e.dispose()
  38214. }
  38215. ))
  38216. }
  38217. ,
  38218. e.prototype.dispose = function() {
  38219. var e = this.scene;
  38220. if (e._mainSoundTrack && e.mainSoundTrack.dispose(),
  38221. e.soundTracks)
  38222. for (var t = 0; t < e.soundTracks.length; t++)
  38223. e.soundTracks[t].dispose()
  38224. }
  38225. ,
  38226. e.prototype.disableAudio = function() {
  38227. var e, t = this.scene;
  38228. for (this._audioEnabled = !1,
  38229. vr.audioEngine && vr.audioEngine.audioContext && vr.audioEngine.audioContext.suspend(),
  38230. e = 0; e < t.mainSoundTrack.soundCollection.length; e++)
  38231. t.mainSoundTrack.soundCollection[e].pause();
  38232. if (t.soundTracks)
  38233. for (e = 0; e < t.soundTracks.length; e++)
  38234. for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)
  38235. t.soundTracks[e].soundCollection[i].pause()
  38236. }
  38237. ,
  38238. e.prototype.enableAudio = function() {
  38239. var e, t = this.scene;
  38240. for (this._audioEnabled = !0,
  38241. vr.audioEngine && vr.audioEngine.audioContext && vr.audioEngine.audioContext.resume(),
  38242. e = 0; e < t.mainSoundTrack.soundCollection.length; e++)
  38243. t.mainSoundTrack.soundCollection[e].isPaused && t.mainSoundTrack.soundCollection[e].play();
  38244. if (t.soundTracks)
  38245. for (e = 0; e < t.soundTracks.length; e++)
  38246. for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)
  38247. t.soundTracks[e].soundCollection[i].isPaused && t.soundTracks[e].soundCollection[i].play()
  38248. }
  38249. ,
  38250. e.prototype.switchAudioModeForHeadphones = function() {
  38251. var e = this.scene;
  38252. if (this._headphone = !0,
  38253. e.mainSoundTrack.switchPanningModelToHRTF(),
  38254. e.soundTracks)
  38255. for (var t = 0; t < e.soundTracks.length; t++)
  38256. e.soundTracks[t].switchPanningModelToHRTF()
  38257. }
  38258. ,
  38259. e.prototype.switchAudioModeForNormalSpeakers = function() {
  38260. var e = this.scene;
  38261. if (this._headphone = !1,
  38262. e.mainSoundTrack.switchPanningModelToEqualPower(),
  38263. e.soundTracks)
  38264. for (var t = 0; t < e.soundTracks.length; t++)
  38265. e.soundTracks[t].switchPanningModelToEqualPower()
  38266. }
  38267. ,
  38268. e.prototype._afterRender = function() {
  38269. var t = ct.Now;
  38270. if (!(this._lastCheck && t - this._lastCheck < this.audioPositioningRefreshRate)) {
  38271. this._lastCheck = t;
  38272. var i = this.scene;
  38273. if (this._audioEnabled && i._mainSoundTrack && i.soundTracks && (0 !== i._mainSoundTrack.soundCollection.length || 1 !== i.soundTracks.length)) {
  38274. var n = vr.audioEngine;
  38275. if (n && n.audioContext) {
  38276. if (this._audioListenerPositionProvider) {
  38277. var r = this._audioListenerPositionProvider();
  38278. r.x = r.x || 0,
  38279. r.y = r.y || 0,
  38280. r.z = r.z || 0,
  38281. n.audioContext.listener.setPosition(r.x, r.y, r.z)
  38282. } else {
  38283. var o = void 0;
  38284. if (o = i.activeCameras && i.activeCameras.length > 0 ? i.activeCameras[0] : i.activeCamera) {
  38285. this._cachedCameraPosition.equals(o.globalPosition) || (this._cachedCameraPosition.copyFrom(o.globalPosition),
  38286. n.audioContext.listener.setPosition(o.globalPosition.x, o.globalPosition.y, o.globalPosition.z)),
  38287. o.rigCameras && o.rigCameras.length > 0 && (o = o.rigCameras[0]);
  38288. var a = P.Invert(o.getViewMatrix())
  38289. , s = x.TransformNormal(e._CameraDirection, a);
  38290. s.normalize(),
  38291. isNaN(s.x) || isNaN(s.y) || isNaN(s.z) || this._cachedCameraDirection.equals(s) || (this._cachedCameraDirection.copyFrom(s),
  38292. n.audioContext.listener.setOrientation(s.x, s.y, s.z, 0, 1, 0))
  38293. } else
  38294. n.audioContext.listener.setPosition(0, 0, 0)
  38295. }
  38296. var l = void 0;
  38297. for (l = 0; l < i.mainSoundTrack.soundCollection.length; l++)
  38298. (u = i.mainSoundTrack.soundCollection[l]).useCustomAttenuation && u.updateDistanceFromListener();
  38299. if (i.soundTracks)
  38300. for (l = 0; l < i.soundTracks.length; l++)
  38301. for (var c = 0; c < i.soundTracks[l].soundCollection.length; c++) {
  38302. var u;
  38303. (u = i.soundTracks[l].soundCollection[c]).useCustomAttenuation && u.updateDistanceFromListener()
  38304. }
  38305. }
  38306. }
  38307. }
  38308. }
  38309. ,
  38310. e._CameraDirection = new x(0,0,-1),
  38311. e
  38312. }();
  38313. Xr._SceneComponentInitialization = function(e) {
  38314. var t = e._getComponent(Wi.NAME_AUDIO);
  38315. t || (t = new Yr(e),
  38316. e._addComponent(t))
  38317. }
  38318. ;
  38319. var Kr = function() {
  38320. function e(e, t, i) {
  38321. var n = this;
  38322. if (this.loop = !1,
  38323. this._coneInnerAngle = 360,
  38324. this._coneOuterAngle = 360,
  38325. this._volume = 1,
  38326. this.isPlaying = !1,
  38327. this.isPaused = !1,
  38328. this._sounds = [],
  38329. this._weights = [],
  38330. t.length !== i.length)
  38331. throw new Error("Sounds length does not equal weights length");
  38332. this.loop = e,
  38333. this._weights = i;
  38334. for (var r = 0, o = 0, a = i; o < a.length; o++)
  38335. r += a[o];
  38336. for (var s = r > 0 ? 1 / r : 0, l = 0; l < this._weights.length; l++)
  38337. this._weights[l] *= s;
  38338. this._sounds = t;
  38339. for (var c = 0, u = this._sounds; c < u.length; c++)
  38340. u[c].onEndedObservable.add((function() {
  38341. n._onended()
  38342. }
  38343. ))
  38344. }
  38345. return Object.defineProperty(e.prototype, "directionalConeInnerAngle", {
  38346. get: function() {
  38347. return this._coneInnerAngle
  38348. },
  38349. set: function(e) {
  38350. if (e !== this._coneInnerAngle) {
  38351. if (this._coneOuterAngle < e)
  38352. return void K.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  38353. this._coneInnerAngle = e;
  38354. for (var t = 0, i = this._sounds; t < i.length; t++)
  38355. i[t].directionalConeInnerAngle = e
  38356. }
  38357. },
  38358. enumerable: !1,
  38359. configurable: !0
  38360. }),
  38361. Object.defineProperty(e.prototype, "directionalConeOuterAngle", {
  38362. get: function() {
  38363. return this._coneOuterAngle
  38364. },
  38365. set: function(e) {
  38366. if (e !== this._coneOuterAngle) {
  38367. if (e < this._coneInnerAngle)
  38368. return void K.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  38369. this._coneOuterAngle = e;
  38370. for (var t = 0, i = this._sounds; t < i.length; t++)
  38371. i[t].directionalConeOuterAngle = e
  38372. }
  38373. },
  38374. enumerable: !1,
  38375. configurable: !0
  38376. }),
  38377. Object.defineProperty(e.prototype, "volume", {
  38378. get: function() {
  38379. return this._volume
  38380. },
  38381. set: function(e) {
  38382. if (e !== this._volume)
  38383. for (var t = 0, i = this._sounds; t < i.length; t++)
  38384. i[t].setVolume(e)
  38385. },
  38386. enumerable: !1,
  38387. configurable: !0
  38388. }),
  38389. e.prototype._onended = function() {
  38390. void 0 !== this._currentIndex && (this._sounds[this._currentIndex].autoplay = !1),
  38391. this.loop && this.isPlaying ? this.play() : this.isPlaying = !1
  38392. }
  38393. ,
  38394. e.prototype.pause = function() {
  38395. this.isPaused = !0,
  38396. void 0 !== this._currentIndex && this._sounds[this._currentIndex].pause()
  38397. }
  38398. ,
  38399. e.prototype.stop = function() {
  38400. this.isPlaying = !1,
  38401. void 0 !== this._currentIndex && this._sounds[this._currentIndex].stop()
  38402. }
  38403. ,
  38404. e.prototype.play = function(e) {
  38405. if (!this.isPaused) {
  38406. this.stop();
  38407. for (var t = Math.random(), i = 0, n = 0; n < this._weights.length; n++)
  38408. if (t <= (i += this._weights[n])) {
  38409. this._currentIndex = n;
  38410. break
  38411. }
  38412. }
  38413. var r = this._sounds[this._currentIndex];
  38414. r.isReady() ? r.play(0, this.isPaused ? void 0 : e) : r.autoplay = !0,
  38415. this.isPlaying = !0,
  38416. this.isPaused = !1
  38417. }
  38418. ,
  38419. e
  38420. }()
  38421. , Qr = function() {
  38422. function e(e) {
  38423. this._texture = null,
  38424. this._isEnabled = !0,
  38425. this.isEnabled = !0,
  38426. this.time = 0,
  38427. (e = e || E.LastCreatedScene) && (this._scene = e,
  38428. this.animationParameters = new R(0,0,0,30))
  38429. }
  38430. return e.prototype._markSubMeshesAsAttributesDirty = function() {
  38431. for (var e = 0, t = this._scene.meshes; e < t.length; e++) {
  38432. var i = t[e];
  38433. i.bakedVertexAnimationManager === this && i._markSubMeshesAsAttributesDirty()
  38434. }
  38435. }
  38436. ,
  38437. e.prototype.bind = function(e, t) {
  38438. if (void 0 === t && (t = !1),
  38439. this._texture && this._isEnabled) {
  38440. var i = this._texture.getSize();
  38441. e.setFloat2("bakedVertexAnimationTextureSizeInverted", 1 / i.width, 1 / i.height),
  38442. e.setFloat("bakedVertexAnimationTime", this.time),
  38443. t || e.setVector4("bakedVertexAnimationSettings", this.animationParameters),
  38444. e.setTexture("bakedVertexAnimationTexture", this._texture)
  38445. }
  38446. }
  38447. ,
  38448. e.prototype.clone = function() {
  38449. var t = new e(this._scene);
  38450. return this.copyTo(t),
  38451. t
  38452. }
  38453. ,
  38454. e.prototype.setAnimationParameters = function(e, t, i, n) {
  38455. void 0 === i && (i = 0),
  38456. void 0 === n && (n = 30),
  38457. this.animationParameters = new R(e,t,i,n)
  38458. }
  38459. ,
  38460. e.prototype.dispose = function(e) {
  38461. var t;
  38462. e && (null === (t = this._texture) || void 0 === t || t.dispose())
  38463. }
  38464. ,
  38465. e.prototype.getClassName = function() {
  38466. return "BakedVertexAnimationManager"
  38467. }
  38468. ,
  38469. e.prototype.copyTo = function(e) {
  38470. Ge.Clone((function() {
  38471. return e
  38472. }
  38473. ), this)
  38474. }
  38475. ,
  38476. e.prototype.serialize = function() {
  38477. return Ge.Serialize(this)
  38478. }
  38479. ,
  38480. e.prototype.parse = function(e, t, i) {
  38481. var n = this;
  38482. Ge.Parse((function() {
  38483. return n
  38484. }
  38485. ), e, t, i)
  38486. }
  38487. ,
  38488. k([Pe(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "texture", void 0),
  38489. k([Ce(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "isEnabled", void 0),
  38490. k([Ce()], e.prototype, "animationParameters", void 0),
  38491. k([Ce()], e.prototype, "time", void 0),
  38492. e
  38493. }()
  38494. , qr = function() {
  38495. function e(e) {
  38496. this._wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
  38497. this._wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
  38498. this.wrapR = a.TEXTURE_WRAP_ADDRESSMODE,
  38499. this.anisotropicFilteringLevel = 4,
  38500. this.delayLoadState = a.DELAYLOADSTATE_NONE,
  38501. this._texture = null,
  38502. this._engine = null,
  38503. this._cachedSize = je.Zero(),
  38504. this._cachedBaseSize = je.Zero(),
  38505. this._initialSamplingMode = a.TEXTURE_BILINEAR_SAMPLINGMODE,
  38506. this._texture = e,
  38507. this._texture && (this._engine = this._texture.getEngine())
  38508. }
  38509. return Object.defineProperty(e.prototype, "wrapU", {
  38510. get: function() {
  38511. return this._wrapU
  38512. },
  38513. set: function(e) {
  38514. this._wrapU = e
  38515. },
  38516. enumerable: !1,
  38517. configurable: !0
  38518. }),
  38519. Object.defineProperty(e.prototype, "wrapV", {
  38520. get: function() {
  38521. return this._wrapV
  38522. },
  38523. set: function(e) {
  38524. this._wrapV = e
  38525. },
  38526. enumerable: !1,
  38527. configurable: !0
  38528. }),
  38529. Object.defineProperty(e.prototype, "coordinatesMode", {
  38530. get: function() {
  38531. return 0
  38532. },
  38533. enumerable: !1,
  38534. configurable: !0
  38535. }),
  38536. Object.defineProperty(e.prototype, "isCube", {
  38537. get: function() {
  38538. return !!this._texture && this._texture.isCube
  38539. },
  38540. set: function(e) {
  38541. this._texture && (this._texture.isCube = e)
  38542. },
  38543. enumerable: !1,
  38544. configurable: !0
  38545. }),
  38546. Object.defineProperty(e.prototype, "is3D", {
  38547. get: function() {
  38548. return !!this._texture && this._texture.is3D
  38549. },
  38550. set: function(e) {
  38551. this._texture && (this._texture.is3D = e)
  38552. },
  38553. enumerable: !1,
  38554. configurable: !0
  38555. }),
  38556. Object.defineProperty(e.prototype, "is2DArray", {
  38557. get: function() {
  38558. return !!this._texture && this._texture.is2DArray
  38559. },
  38560. set: function(e) {
  38561. this._texture && (this._texture.is2DArray = e)
  38562. },
  38563. enumerable: !1,
  38564. configurable: !0
  38565. }),
  38566. e.prototype.getClassName = function() {
  38567. return "ThinTexture"
  38568. }
  38569. ,
  38570. e.prototype.isReady = function() {
  38571. return this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED ? (this.delayLoad(),
  38572. !1) : !!this._texture && this._texture.isReady
  38573. }
  38574. ,
  38575. e.prototype.delayLoad = function() {}
  38576. ,
  38577. e.prototype.getInternalTexture = function() {
  38578. return this._texture
  38579. }
  38580. ,
  38581. e.prototype.getSize = function() {
  38582. if (this._texture) {
  38583. if (this._texture.width)
  38584. return this._cachedSize.width = this._texture.width,
  38585. this._cachedSize.height = this._texture.height,
  38586. this._cachedSize;
  38587. if (this._texture._size)
  38588. return this._cachedSize.width = this._texture._size,
  38589. this._cachedSize.height = this._texture._size,
  38590. this._cachedSize
  38591. }
  38592. return this._cachedSize
  38593. }
  38594. ,
  38595. e.prototype.getBaseSize = function() {
  38596. return this.isReady() && this._texture ? this._texture._size ? (this._cachedBaseSize.width = this._texture._size,
  38597. this._cachedBaseSize.height = this._texture._size,
  38598. this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth,
  38599. this._cachedBaseSize.height = this._texture.baseHeight,
  38600. this._cachedBaseSize) : (this._cachedBaseSize.width = 0,
  38601. this._cachedBaseSize.height = 0,
  38602. this._cachedBaseSize)
  38603. }
  38604. ,
  38605. Object.defineProperty(e.prototype, "samplingMode", {
  38606. get: function() {
  38607. return this._texture ? this._texture.samplingMode : this._initialSamplingMode
  38608. },
  38609. enumerable: !1,
  38610. configurable: !0
  38611. }),
  38612. e.prototype.updateSamplingMode = function(e) {
  38613. this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture)
  38614. }
  38615. ,
  38616. e.prototype.releaseInternalTexture = function() {
  38617. this._texture && (this._texture.dispose(),
  38618. this._texture = null)
  38619. }
  38620. ,
  38621. e.prototype.dispose = function() {
  38622. this._texture && (this.releaseInternalTexture(),
  38623. this._engine = null)
  38624. }
  38625. ,
  38626. e
  38627. }()
  38628. , Zr = function(e) {
  38629. function t(i) {
  38630. var n = e.call(this, null) || this;
  38631. return n.metadata = null,
  38632. n.reservedDataStore = null,
  38633. n._hasAlpha = !1,
  38634. n._getAlphaFromRGB = !1,
  38635. n.level = 1,
  38636. n._coordinatesIndex = 0,
  38637. n._coordinatesMode = a.TEXTURE_EXPLICIT_MODE,
  38638. n.wrapR = a.TEXTURE_WRAP_ADDRESSMODE,
  38639. n.anisotropicFilteringLevel = t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,
  38640. n._isCube = !1,
  38641. n._gammaSpace = !0,
  38642. n.invertZ = !1,
  38643. n.lodLevelInAlpha = !1,
  38644. n.isRenderTarget = !1,
  38645. n._prefiltered = !1,
  38646. n._forceSerialize = !1,
  38647. n.animations = new Array,
  38648. n.onDisposeObservable = new h,
  38649. n._onDisposeObserver = null,
  38650. n._scene = null,
  38651. n._uid = null,
  38652. n._parentContainer = null,
  38653. n._loadingError = !1,
  38654. i ? t._IsScene(i) ? n._scene = i : n._engine = i : n._scene = E.LastCreatedScene,
  38655. n._scene && (n.uniqueId = n._scene.getUniqueId(),
  38656. n._scene.addTexture(n),
  38657. n._engine = n._scene.getEngine()),
  38658. n._uid = null,
  38659. n
  38660. }
  38661. return U(t, e),
  38662. Object.defineProperty(t.prototype, "hasAlpha", {
  38663. get: function() {
  38664. return this._hasAlpha
  38665. },
  38666. set: function(e) {
  38667. var t = this;
  38668. this._hasAlpha !== e && (this._hasAlpha = e,
  38669. this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  38670. return e.hasTexture(t)
  38671. }
  38672. )))
  38673. },
  38674. enumerable: !1,
  38675. configurable: !0
  38676. }),
  38677. Object.defineProperty(t.prototype, "getAlphaFromRGB", {
  38678. get: function() {
  38679. return this._getAlphaFromRGB
  38680. },
  38681. set: function(e) {
  38682. var t = this;
  38683. this._getAlphaFromRGB !== e && (this._getAlphaFromRGB = e,
  38684. this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  38685. return e.hasTexture(t)
  38686. }
  38687. )))
  38688. },
  38689. enumerable: !1,
  38690. configurable: !0
  38691. }),
  38692. Object.defineProperty(t.prototype, "coordinatesIndex", {
  38693. get: function() {
  38694. return this._coordinatesIndex
  38695. },
  38696. set: function(e) {
  38697. var t = this;
  38698. this._coordinatesIndex !== e && (this._coordinatesIndex = e,
  38699. this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  38700. return e.hasTexture(t)
  38701. }
  38702. )))
  38703. },
  38704. enumerable: !1,
  38705. configurable: !0
  38706. }),
  38707. Object.defineProperty(t.prototype, "coordinatesMode", {
  38708. get: function() {
  38709. return this._coordinatesMode
  38710. },
  38711. set: function(e) {
  38712. var t = this;
  38713. this._coordinatesMode !== e && (this._coordinatesMode = e,
  38714. this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  38715. return e.hasTexture(t)
  38716. }
  38717. )))
  38718. },
  38719. enumerable: !1,
  38720. configurable: !0
  38721. }),
  38722. Object.defineProperty(t.prototype, "wrapU", {
  38723. get: function() {
  38724. return this._wrapU
  38725. },
  38726. set: function(e) {
  38727. this._wrapU = e
  38728. },
  38729. enumerable: !1,
  38730. configurable: !0
  38731. }),
  38732. Object.defineProperty(t.prototype, "wrapV", {
  38733. get: function() {
  38734. return this._wrapV
  38735. },
  38736. set: function(e) {
  38737. this._wrapV = e
  38738. },
  38739. enumerable: !1,
  38740. configurable: !0
  38741. }),
  38742. Object.defineProperty(t.prototype, "isCube", {
  38743. get: function() {
  38744. return this._texture ? this._texture.isCube : this._isCube
  38745. },
  38746. set: function(e) {
  38747. this._texture ? this._texture.isCube = e : this._isCube = e
  38748. },
  38749. enumerable: !1,
  38750. configurable: !0
  38751. }),
  38752. Object.defineProperty(t.prototype, "is3D", {
  38753. get: function() {
  38754. return !!this._texture && this._texture.is3D
  38755. },
  38756. set: function(e) {
  38757. this._texture && (this._texture.is3D = e)
  38758. },
  38759. enumerable: !1,
  38760. configurable: !0
  38761. }),
  38762. Object.defineProperty(t.prototype, "is2DArray", {
  38763. get: function() {
  38764. return !!this._texture && this._texture.is2DArray
  38765. },
  38766. set: function(e) {
  38767. this._texture && (this._texture.is2DArray = e)
  38768. },
  38769. enumerable: !1,
  38770. configurable: !0
  38771. }),
  38772. Object.defineProperty(t.prototype, "gammaSpace", {
  38773. get: function() {
  38774. return this._texture ? (null === this._texture._gammaSpace && (this._texture._gammaSpace = this._gammaSpace),
  38775. this._texture._gammaSpace && !this._texture._useSRGBBuffer) : this._gammaSpace
  38776. },
  38777. set: function(e) {
  38778. if (this._texture) {
  38779. if (this._texture._gammaSpace === e)
  38780. return;
  38781. this._texture._gammaSpace = e
  38782. } else {
  38783. if (this._gammaSpace === e)
  38784. return;
  38785. this._gammaSpace = e
  38786. }
  38787. this._markAllSubMeshesAsTexturesDirty()
  38788. },
  38789. enumerable: !1,
  38790. configurable: !0
  38791. }),
  38792. Object.defineProperty(t.prototype, "isRGBD", {
  38793. get: function() {
  38794. return null != this._texture && this._texture._isRGBD
  38795. },
  38796. set: function(e) {
  38797. this._texture && (this._texture._isRGBD = e)
  38798. },
  38799. enumerable: !1,
  38800. configurable: !0
  38801. }),
  38802. Object.defineProperty(t.prototype, "noMipmap", {
  38803. get: function() {
  38804. return !1
  38805. },
  38806. enumerable: !1,
  38807. configurable: !0
  38808. }),
  38809. Object.defineProperty(t.prototype, "lodGenerationOffset", {
  38810. get: function() {
  38811. return this._texture ? this._texture._lodGenerationOffset : 0
  38812. },
  38813. set: function(e) {
  38814. this._texture && (this._texture._lodGenerationOffset = e)
  38815. },
  38816. enumerable: !1,
  38817. configurable: !0
  38818. }),
  38819. Object.defineProperty(t.prototype, "lodGenerationScale", {
  38820. get: function() {
  38821. return this._texture ? this._texture._lodGenerationScale : 0
  38822. },
  38823. set: function(e) {
  38824. this._texture && (this._texture._lodGenerationScale = e)
  38825. },
  38826. enumerable: !1,
  38827. configurable: !0
  38828. }),
  38829. Object.defineProperty(t.prototype, "linearSpecularLOD", {
  38830. get: function() {
  38831. return !!this._texture && this._texture._linearSpecularLOD
  38832. },
  38833. set: function(e) {
  38834. this._texture && (this._texture._linearSpecularLOD = e)
  38835. },
  38836. enumerable: !1,
  38837. configurable: !0
  38838. }),
  38839. Object.defineProperty(t.prototype, "irradianceTexture", {
  38840. get: function() {
  38841. return this._texture ? this._texture._irradianceTexture : null
  38842. },
  38843. set: function(e) {
  38844. this._texture && (this._texture._irradianceTexture = e)
  38845. },
  38846. enumerable: !1,
  38847. configurable: !0
  38848. }),
  38849. Object.defineProperty(t.prototype, "uid", {
  38850. get: function() {
  38851. return this._uid || (this._uid = fi()),
  38852. this._uid
  38853. },
  38854. enumerable: !1,
  38855. configurable: !0
  38856. }),
  38857. t.prototype.toString = function() {
  38858. return this.name
  38859. }
  38860. ,
  38861. t.prototype.getClassName = function() {
  38862. return "BaseTexture"
  38863. }
  38864. ,
  38865. Object.defineProperty(t.prototype, "onDispose", {
  38866. set: function(e) {
  38867. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  38868. this._onDisposeObserver = this.onDisposeObservable.add(e)
  38869. },
  38870. enumerable: !1,
  38871. configurable: !0
  38872. }),
  38873. Object.defineProperty(t.prototype, "isBlocking", {
  38874. get: function() {
  38875. return !0
  38876. },
  38877. enumerable: !1,
  38878. configurable: !0
  38879. }),
  38880. Object.defineProperty(t.prototype, "loadingError", {
  38881. get: function() {
  38882. return this._loadingError
  38883. },
  38884. enumerable: !1,
  38885. configurable: !0
  38886. }),
  38887. Object.defineProperty(t.prototype, "errorObject", {
  38888. get: function() {
  38889. return this._errorObject
  38890. },
  38891. enumerable: !1,
  38892. configurable: !0
  38893. }),
  38894. t.prototype.getScene = function() {
  38895. return this._scene
  38896. }
  38897. ,
  38898. t.prototype._getEngine = function() {
  38899. return this._engine
  38900. }
  38901. ,
  38902. t.prototype.checkTransformsAreIdentical = function(e) {
  38903. return null !== e
  38904. }
  38905. ,
  38906. t.prototype.getTextureMatrix = function() {
  38907. return P.IdentityReadOnly
  38908. }
  38909. ,
  38910. t.prototype.getReflectionTextureMatrix = function() {
  38911. return P.IdentityReadOnly
  38912. }
  38913. ,
  38914. t.prototype.isReadyOrNotBlocking = function() {
  38915. return !this.isBlocking || this.isReady() || this.loadingError
  38916. }
  38917. ,
  38918. t.prototype.scale = function(e) {}
  38919. ,
  38920. Object.defineProperty(t.prototype, "canRescale", {
  38921. get: function() {
  38922. return !1
  38923. },
  38924. enumerable: !1,
  38925. configurable: !0
  38926. }),
  38927. t.prototype._getFromCache = function(e, t, i, n, r) {
  38928. var o = this._getEngine();
  38929. if (!o)
  38930. return null;
  38931. for (var a = o._getUseSRGBBuffer(!!r, t), s = o.getLoadedTexturesCache(), l = 0; l < s.length; l++) {
  38932. var c = s[l];
  38933. if ((void 0 === r || a === c._useSRGBBuffer) && !(void 0 !== n && n !== c.invertY || c.url !== e || c.generateMipMaps !== !t || i && i !== c.samplingMode))
  38934. return c.incrementReferences(),
  38935. c
  38936. }
  38937. return null
  38938. }
  38939. ,
  38940. t.prototype._rebuild = function() {}
  38941. ,
  38942. t.prototype.clone = function() {
  38943. return null
  38944. }
  38945. ,
  38946. Object.defineProperty(t.prototype, "textureType", {
  38947. get: function() {
  38948. return this._texture && void 0 !== this._texture.type ? this._texture.type : a.TEXTURETYPE_UNSIGNED_INT
  38949. },
  38950. enumerable: !1,
  38951. configurable: !0
  38952. }),
  38953. Object.defineProperty(t.prototype, "textureFormat", {
  38954. get: function() {
  38955. return this._texture && void 0 !== this._texture.format ? this._texture.format : a.TEXTUREFORMAT_RGBA
  38956. },
  38957. enumerable: !1,
  38958. configurable: !0
  38959. }),
  38960. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  38961. var e = this.getScene();
  38962. e && e.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
  38963. }
  38964. ,
  38965. t.prototype.readPixels = function(e, t, i, n, r) {
  38966. if (void 0 === e && (e = 0),
  38967. void 0 === t && (t = 0),
  38968. void 0 === i && (i = null),
  38969. void 0 === n && (n = !0),
  38970. void 0 === r && (r = !1),
  38971. !this._texture)
  38972. return null;
  38973. var o = this.getSize()
  38974. , a = o.width
  38975. , s = o.height
  38976. , l = this._getEngine();
  38977. if (!l)
  38978. return null;
  38979. 0 != t && (a /= Math.pow(2, t),
  38980. s /= Math.pow(2, t),
  38981. a = Math.round(a),
  38982. s = Math.round(s));
  38983. try {
  38984. return this._texture.isCube ? l._readTexturePixels(this._texture, a, s, e, t, i, n, r) : l._readTexturePixels(this._texture, a, s, -1, t, i, n, r)
  38985. } catch (e) {
  38986. return null
  38987. }
  38988. }
  38989. ,
  38990. t.prototype._readPixelsSync = function(e, t, i, n, r) {
  38991. if (void 0 === e && (e = 0),
  38992. void 0 === t && (t = 0),
  38993. void 0 === i && (i = null),
  38994. void 0 === n && (n = !0),
  38995. void 0 === r && (r = !1),
  38996. !this._texture)
  38997. return null;
  38998. var o = this.getSize()
  38999. , a = o.width
  39000. , s = o.height
  39001. , l = this._getEngine();
  39002. if (!l)
  39003. return null;
  39004. 0 != t && (a /= Math.pow(2, t),
  39005. s /= Math.pow(2, t),
  39006. a = Math.round(a),
  39007. s = Math.round(s));
  39008. try {
  39009. return this._texture.isCube ? l._readTexturePixelsSync(this._texture, a, s, e, t, i, n, r) : l._readTexturePixelsSync(this._texture, a, s, -1, t, i, n, r)
  39010. } catch (e) {
  39011. return null
  39012. }
  39013. }
  39014. ,
  39015. Object.defineProperty(t.prototype, "_lodTextureHigh", {
  39016. get: function() {
  39017. return this._texture ? this._texture._lodTextureHigh : null
  39018. },
  39019. enumerable: !1,
  39020. configurable: !0
  39021. }),
  39022. Object.defineProperty(t.prototype, "_lodTextureMid", {
  39023. get: function() {
  39024. return this._texture ? this._texture._lodTextureMid : null
  39025. },
  39026. enumerable: !1,
  39027. configurable: !0
  39028. }),
  39029. Object.defineProperty(t.prototype, "_lodTextureLow", {
  39030. get: function() {
  39031. return this._texture ? this._texture._lodTextureLow : null
  39032. },
  39033. enumerable: !1,
  39034. configurable: !0
  39035. }),
  39036. t.prototype.dispose = function() {
  39037. if (this._scene) {
  39038. this._scene.stopAnimation && this._scene.stopAnimation(this),
  39039. this._scene._removePendingData(this);
  39040. var t = this._scene.textures.indexOf(this);
  39041. if (t >= 0 && this._scene.textures.splice(t, 1),
  39042. this._scene.onTextureRemovedObservable.notifyObservers(this),
  39043. this._scene = null,
  39044. this._parentContainer) {
  39045. var i = this._parentContainer.textures.indexOf(this);
  39046. i > -1 && this._parentContainer.textures.splice(i, 1),
  39047. this._parentContainer = null
  39048. }
  39049. }
  39050. this.onDisposeObservable.notifyObservers(this),
  39051. this.onDisposeObservable.clear(),
  39052. this.metadata = null,
  39053. e.prototype.dispose.call(this)
  39054. }
  39055. ,
  39056. t.prototype.serialize = function() {
  39057. if (!this.name)
  39058. return null;
  39059. var e = Ge.Serialize(this);
  39060. return Ge.AppendSerializedAnimations(this, e),
  39061. e
  39062. }
  39063. ,
  39064. t.WhenAllReady = function(e, t) {
  39065. var i = e.length;
  39066. if (0 !== i)
  39067. for (var n = 0; n < e.length; n++) {
  39068. var r = e[n];
  39069. if (r.isReady())
  39070. 0 == --i && t();
  39071. else {
  39072. var o = r.onLoadObservable;
  39073. o && o.addOnce((function() {
  39074. 0 == --i && t()
  39075. }
  39076. ))
  39077. }
  39078. }
  39079. else
  39080. t()
  39081. }
  39082. ,
  39083. t._IsScene = function(e) {
  39084. return "Scene" === e.getClassName()
  39085. }
  39086. ,
  39087. t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
  39088. k([Ce()], t.prototype, "uniqueId", void 0),
  39089. k([Ce()], t.prototype, "name", void 0),
  39090. k([Ce()], t.prototype, "metadata", void 0),
  39091. k([Ce("hasAlpha")], t.prototype, "_hasAlpha", void 0),
  39092. k([Ce("getAlphaFromRGB")], t.prototype, "_getAlphaFromRGB", void 0),
  39093. k([Ce()], t.prototype, "level", void 0),
  39094. k([Ce("coordinatesIndex")], t.prototype, "_coordinatesIndex", void 0),
  39095. k([Ce("coordinatesMode")], t.prototype, "_coordinatesMode", void 0),
  39096. k([Ce()], t.prototype, "wrapU", null),
  39097. k([Ce()], t.prototype, "wrapV", null),
  39098. k([Ce()], t.prototype, "wrapR", void 0),
  39099. k([Ce()], t.prototype, "anisotropicFilteringLevel", void 0),
  39100. k([Ce()], t.prototype, "isCube", null),
  39101. k([Ce()], t.prototype, "is3D", null),
  39102. k([Ce()], t.prototype, "is2DArray", null),
  39103. k([Ce()], t.prototype, "gammaSpace", null),
  39104. k([Ce()], t.prototype, "invertZ", void 0),
  39105. k([Ce()], t.prototype, "lodLevelInAlpha", void 0),
  39106. k([Ce()], t.prototype, "lodGenerationOffset", null),
  39107. k([Ce()], t.prototype, "lodGenerationScale", null),
  39108. k([Ce()], t.prototype, "linearSpecularLOD", null),
  39109. k([Pe()], t.prototype, "irradianceTexture", null),
  39110. k([Ce()], t.prototype, "isRenderTarget", void 0),
  39111. t
  39112. }(qr);
  39113. function Jr(e, t, i) {
  39114. void 0 === i && (i = !1);
  39115. var n = t.width
  39116. , r = t.height;
  39117. if (e instanceof Float32Array) {
  39118. for (var o = e.byteLength / e.BYTES_PER_ELEMENT, a = new Uint8Array(o); --o >= 0; ) {
  39119. var s = e[o];
  39120. s < 0 ? s = 0 : s > 1 && (s = 1),
  39121. a[o] = 255 * s
  39122. }
  39123. e = a
  39124. }
  39125. var l = document.createElement("canvas");
  39126. l.width = n,
  39127. l.height = r;
  39128. var c = l.getContext("2d");
  39129. if (!c)
  39130. return null;
  39131. var u = c.createImageData(n, r);
  39132. if (u.data.set(e),
  39133. c.putImageData(u, 0, 0),
  39134. i) {
  39135. var h = document.createElement("canvas");
  39136. h.width = n,
  39137. h.height = r;
  39138. var d = h.getContext("2d");
  39139. return d ? (d.translate(0, r),
  39140. d.scale(1, -1),
  39141. d.drawImage(l, 0, 0),
  39142. h.toDataURL("image/png")) : null
  39143. }
  39144. return l.toDataURL("image/png")
  39145. }
  39146. function $r(e, t, i) {
  39147. void 0 === t && (t = 0),
  39148. void 0 === i && (i = 0);
  39149. var n = e.getInternalTexture();
  39150. if (!n)
  39151. return null;
  39152. var r = e._readPixelsSync(t, i);
  39153. return r ? Jr(r, e.getSize(), n.invertY) : null
  39154. }
  39155. function eo(e, t, i) {
  39156. return void 0 === t && (t = 0),
  39157. void 0 === i && (i = 0),
  39158. G(this, void 0, void 0, (function() {
  39159. var n, r;
  39160. return z(this, (function(o) {
  39161. switch (o.label) {
  39162. case 0:
  39163. return (n = e.getInternalTexture()) ? [4, e.readPixels(t, i)] : [2, null];
  39164. case 1:
  39165. return (r = o.sent()) ? [2, Jr(r, e.getSize(), n.invertY)] : [2, null]
  39166. }
  39167. }
  39168. ))
  39169. }
  39170. ))
  39171. }
  39172. var to = {
  39173. GenerateBase64StringFromPixelData: Jr,
  39174. GenerateBase64StringFromTexture: $r,
  39175. GenerateBase64StringFromTextureAsync: eo
  39176. }
  39177. , io = function(e) {
  39178. function t(i, n, r, o, s, l, c, u, d, p, f, _, m) {
  39179. void 0 === s && (s = t.TRILINEAR_SAMPLINGMODE),
  39180. void 0 === l && (l = null),
  39181. void 0 === c && (c = null),
  39182. void 0 === u && (u = null),
  39183. void 0 === d && (d = !1);
  39184. var g, v, y, b, T, E, S, A, x, R = this;
  39185. (R = e.call(this, n) || this).url = null,
  39186. R.uOffset = 0,
  39187. R.vOffset = 0,
  39188. R.uScale = 1,
  39189. R.vScale = 1,
  39190. R.uAng = 0,
  39191. R.vAng = 0,
  39192. R.wAng = 0,
  39193. R.uRotationCenter = .5,
  39194. R.vRotationCenter = .5,
  39195. R.wRotationCenter = .5,
  39196. R.homogeneousRotationInUVTransform = !1,
  39197. R.inspectableCustomProperties = null,
  39198. R._noMipmap = !1,
  39199. R._invertY = !1,
  39200. R._rowGenerationMatrix = null,
  39201. R._cachedTextureMatrix = null,
  39202. R._projectionModeMatrix = null,
  39203. R._t0 = null,
  39204. R._t1 = null,
  39205. R._t2 = null,
  39206. R._cachedUOffset = -1,
  39207. R._cachedVOffset = -1,
  39208. R._cachedUScale = 0,
  39209. R._cachedVScale = 0,
  39210. R._cachedUAng = -1,
  39211. R._cachedVAng = -1,
  39212. R._cachedWAng = -1,
  39213. R._cachedProjectionMatrixId = -1,
  39214. R._cachedURotationCenter = -1,
  39215. R._cachedVRotationCenter = -1,
  39216. R._cachedWRotationCenter = -1,
  39217. R._cachedHomogeneousRotationInUVTransform = !1,
  39218. R._cachedCoordinatesMode = -1,
  39219. R._buffer = null,
  39220. R._deleteBuffer = !1,
  39221. R._format = null,
  39222. R._delayedOnLoad = null,
  39223. R._delayedOnError = null,
  39224. R.onLoadObservable = new h,
  39225. R._isBlocking = !0,
  39226. R.name = i || "",
  39227. R.url = i;
  39228. var C = !1;
  39229. "object" == typeof r && null !== r ? (x = null !== (g = r.noMipmap) && void 0 !== g && g,
  39230. o = null !== (v = r.invertY) && void 0 !== v ? v : !pr.UseOpenGLOrientationForUV,
  39231. s = null !== (y = r.samplingMode) && void 0 !== y ? y : t.TRILINEAR_SAMPLINGMODE,
  39232. l = null !== (b = r.onLoad) && void 0 !== b ? b : null,
  39233. c = null !== (T = r.onError) && void 0 !== T ? T : null,
  39234. u = null !== (E = r.buffer) && void 0 !== E ? E : null,
  39235. d = null !== (S = r.deleteBuffer) && void 0 !== S && S,
  39236. p = r.format,
  39237. f = r.mimeType,
  39238. _ = r.loaderOptions,
  39239. m = r.creationFlags,
  39240. C = null !== (A = r.useSRGBBuffer) && void 0 !== A && A) : x = !!r,
  39241. R._noMipmap = x,
  39242. R._invertY = void 0 === o ? !pr.UseOpenGLOrientationForUV : o,
  39243. R._initialSamplingMode = s,
  39244. R._buffer = u,
  39245. R._deleteBuffer = d,
  39246. R._mimeType = f,
  39247. R._loaderOptions = _,
  39248. R._creationFlags = m,
  39249. R._useSRGBBuffer = C,
  39250. p && (R._format = p);
  39251. var P = R.getScene()
  39252. , M = R._getEngine();
  39253. if (!M)
  39254. return R;
  39255. M.onBeforeTextureInitObservable.notifyObservers(R);
  39256. var I = function() {
  39257. R._texture && (R._texture._invertVScale && (R.vScale *= -1,
  39258. R.vOffset += 1),
  39259. null !== R._texture._cachedWrapU && (R.wrapU = R._texture._cachedWrapU,
  39260. R._texture._cachedWrapU = null),
  39261. null !== R._texture._cachedWrapV && (R.wrapV = R._texture._cachedWrapV,
  39262. R._texture._cachedWrapV = null),
  39263. null !== R._texture._cachedWrapR && (R.wrapR = R._texture._cachedWrapR,
  39264. R._texture._cachedWrapR = null)),
  39265. R.onLoadObservable.hasObservers() && R.onLoadObservable.notifyObservers(R),
  39266. l && l(),
  39267. !R.isBlocking && P && P.resetCachedMaterial()
  39268. }
  39269. , O = function(e, i) {
  39270. R._loadingError = !0,
  39271. R._errorObject = {
  39272. message: e,
  39273. exception: i
  39274. },
  39275. c && c(e, i),
  39276. t.OnTextureLoadErrorObservable.notifyObservers(R)
  39277. };
  39278. if (!R.url)
  39279. return R._delayedOnLoad = I,
  39280. R._delayedOnError = O,
  39281. R;
  39282. if (R._texture = R._getFromCache(R.url, x, s, R._invertY, C),
  39283. R._texture)
  39284. if (R._texture.isReady)
  39285. Xt.SetImmediate((function() {
  39286. return I()
  39287. }
  39288. ));
  39289. else {
  39290. var D = R._texture.onLoadedObservable.add(I);
  39291. R._texture.onErrorObservable.add((function(e) {
  39292. var t;
  39293. O(e.message, e.exception),
  39294. null === (t = R._texture) || void 0 === t || t.onLoadedObservable.remove(D)
  39295. }
  39296. ))
  39297. }
  39298. else if (P && P.useDelayedTextureLoading)
  39299. R.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
  39300. R._delayedOnLoad = I,
  39301. R._delayedOnError = O;
  39302. else {
  39303. try {
  39304. R._texture = M.createTexture(R.url, x, R._invertY, P, s, I, O, R._buffer, void 0, R._format, null, f, _, m, C)
  39305. } catch (e) {
  39306. throw O("error loading", e),
  39307. e
  39308. }
  39309. d && (R._buffer = null)
  39310. }
  39311. return R
  39312. }
  39313. return U(t, e),
  39314. Object.defineProperty(t.prototype, "noMipmap", {
  39315. get: function() {
  39316. return this._noMipmap
  39317. },
  39318. enumerable: !1,
  39319. configurable: !0
  39320. }),
  39321. Object.defineProperty(t.prototype, "mimeType", {
  39322. get: function() {
  39323. return this._mimeType
  39324. },
  39325. enumerable: !1,
  39326. configurable: !0
  39327. }),
  39328. Object.defineProperty(t.prototype, "isBlocking", {
  39329. get: function() {
  39330. return this._isBlocking
  39331. },
  39332. set: function(e) {
  39333. this._isBlocking = e
  39334. },
  39335. enumerable: !1,
  39336. configurable: !0
  39337. }),
  39338. Object.defineProperty(t.prototype, "invertY", {
  39339. get: function() {
  39340. return this._invertY
  39341. },
  39342. enumerable: !1,
  39343. configurable: !0
  39344. }),
  39345. t.prototype.updateURL = function(e, t, i) {
  39346. void 0 === t && (t = null),
  39347. this.url && (this.releaseInternalTexture(),
  39348. this.getScene().markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
  39349. this.name && !ae(this.name, "data:") || (this.name = e),
  39350. this.url = e,
  39351. this._buffer = t,
  39352. this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
  39353. i && (this._delayedOnLoad = i),
  39354. this.delayLoad()
  39355. }
  39356. ,
  39357. t.prototype.delayLoad = function() {
  39358. if (this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED) {
  39359. var e = this.getScene();
  39360. e && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
  39361. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer),
  39362. this._texture ? this._delayedOnLoad && (this._texture.isReady ? Xt.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = e.getEngine().createTexture(this.url, this._noMipmap, this._invertY, e, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType, this._loaderOptions, this._creationFlags, this._useSRGBBuffer),
  39363. this._deleteBuffer && (this._buffer = null)),
  39364. this._delayedOnLoad = null,
  39365. this._delayedOnError = null)
  39366. }
  39367. }
  39368. ,
  39369. t.prototype._prepareRowForTextureGeneration = function(e, t, i, n) {
  39370. e *= this._cachedUScale,
  39371. t *= this._cachedVScale,
  39372. e -= this.uRotationCenter * this._cachedUScale,
  39373. t -= this.vRotationCenter * this._cachedVScale,
  39374. i -= this.wRotationCenter,
  39375. x.TransformCoordinatesFromFloatsToRef(e, t, i, this._rowGenerationMatrix, n),
  39376. n.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
  39377. n.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
  39378. n.z += this.wRotationCenter
  39379. }
  39380. ,
  39381. t.prototype.checkTransformsAreIdentical = function(e) {
  39382. return null !== e && this.uOffset === e.uOffset && this.vOffset === e.vOffset && this.uScale === e.uScale && this.vScale === e.vScale && this.uAng === e.uAng && this.vAng === e.vAng && this.wAng === e.wAng
  39383. }
  39384. ,
  39385. t.prototype.getTextureMatrix = function(e) {
  39386. var t = this;
  39387. if (void 0 === e && (e = 1),
  39388. this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * e === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng && this.uRotationCenter === this._cachedURotationCenter && this.vRotationCenter === this._cachedVRotationCenter && this.wRotationCenter === this._cachedWRotationCenter && this.homogeneousRotationInUVTransform === this._cachedHomogeneousRotationInUVTransform)
  39389. return this._cachedTextureMatrix;
  39390. this._cachedUOffset = this.uOffset,
  39391. this._cachedVOffset = this.vOffset,
  39392. this._cachedUScale = this.uScale * e,
  39393. this._cachedVScale = this.vScale,
  39394. this._cachedUAng = this.uAng,
  39395. this._cachedVAng = this.vAng,
  39396. this._cachedWAng = this.wAng,
  39397. this._cachedURotationCenter = this.uRotationCenter,
  39398. this._cachedVRotationCenter = this.vRotationCenter,
  39399. this._cachedWRotationCenter = this.wRotationCenter,
  39400. this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform,
  39401. this._cachedTextureMatrix && this._rowGenerationMatrix || (this._cachedTextureMatrix = P.Zero(),
  39402. this._rowGenerationMatrix = new P,
  39403. this._t0 = x.Zero(),
  39404. this._t1 = x.Zero(),
  39405. this._t2 = x.Zero()),
  39406. P.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
  39407. this.homogeneousRotationInUVTransform ? (P.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, I.Matrix[0]),
  39408. P.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, I.Matrix[1]),
  39409. P.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, I.Matrix[2]),
  39410. P.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, I.Matrix[3]),
  39411. I.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
  39412. this._cachedTextureMatrix.multiplyToRef(I.Matrix[1], this._cachedTextureMatrix),
  39413. this._cachedTextureMatrix.multiplyToRef(I.Matrix[2], this._cachedTextureMatrix),
  39414. this._cachedTextureMatrix.multiplyToRef(I.Matrix[3], this._cachedTextureMatrix),
  39415. this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0),
  39416. this._prepareRowForTextureGeneration(1, 0, 0, this._t1),
  39417. this._prepareRowForTextureGeneration(0, 1, 0, this._t2),
  39418. this._t1.subtractInPlace(this._t0),
  39419. this._t2.subtractInPlace(this._t0),
  39420. P.FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0, this._t2.x, this._t2.y, this._t2.z, 0, this._t0.x, this._t0.y, this._t0.z, 0, 0, 0, 0, 1, this._cachedTextureMatrix));
  39421. var i = this.getScene();
  39422. return i ? (i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  39423. return e.hasTexture(t)
  39424. }
  39425. )),
  39426. this._cachedTextureMatrix) : this._cachedTextureMatrix
  39427. }
  39428. ,
  39429. t.prototype.getReflectionTextureMatrix = function() {
  39430. var e = this
  39431. , i = this.getScene();
  39432. if (!i)
  39433. return this._cachedTextureMatrix;
  39434. if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode) {
  39435. if (this.coordinatesMode !== t.PROJECTION_MODE)
  39436. return this._cachedTextureMatrix;
  39437. if (this._cachedProjectionMatrixId === i.getProjectionMatrix().updateFlag)
  39438. return this._cachedTextureMatrix
  39439. }
  39440. this._cachedTextureMatrix || (this._cachedTextureMatrix = P.Zero()),
  39441. this._projectionModeMatrix || (this._projectionModeMatrix = P.Zero());
  39442. var n = this._cachedCoordinatesMode !== this.coordinatesMode;
  39443. switch (this._cachedUOffset = this.uOffset,
  39444. this._cachedVOffset = this.vOffset,
  39445. this._cachedUScale = this.uScale,
  39446. this._cachedVScale = this.vScale,
  39447. this._cachedCoordinatesMode = this.coordinatesMode,
  39448. this.coordinatesMode) {
  39449. case t.PLANAR_MODE:
  39450. P.IdentityToRef(this._cachedTextureMatrix),
  39451. this._cachedTextureMatrix[0] = this.uScale,
  39452. this._cachedTextureMatrix[5] = this.vScale,
  39453. this._cachedTextureMatrix[12] = this.uOffset,
  39454. this._cachedTextureMatrix[13] = this.vOffset;
  39455. break;
  39456. case t.PROJECTION_MODE:
  39457. P.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
  39458. var r = i.getProjectionMatrix();
  39459. this._cachedProjectionMatrixId = r.updateFlag,
  39460. r.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  39461. break;
  39462. default:
  39463. P.IdentityToRef(this._cachedTextureMatrix)
  39464. }
  39465. return n && i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
  39466. return -1 !== t.getActiveTextures().indexOf(e)
  39467. }
  39468. )),
  39469. this._cachedTextureMatrix
  39470. }
  39471. ,
  39472. t.prototype.clone = function() {
  39473. var e = this
  39474. , i = {
  39475. noMipmap: this._noMipmap,
  39476. invertY: this._invertY,
  39477. samplingMode: this.samplingMode,
  39478. onLoad: void 0,
  39479. onError: void 0,
  39480. buffer: this._texture ? this._texture._buffer : void 0,
  39481. deleteBuffer: this._deleteBuffer,
  39482. format: this.textureFormat,
  39483. mimeType: this.mimeType,
  39484. loaderOptions: this._loaderOptions,
  39485. creationFlags: this._creationFlags,
  39486. useSRGBBuffer: this._useSRGBBuffer
  39487. };
  39488. return Ge.Clone((function() {
  39489. return new t(e._texture ? e._texture.url : null,e.getScene(),i)
  39490. }
  39491. ), this)
  39492. }
  39493. ,
  39494. t.prototype.serialize = function() {
  39495. var i = this.name;
  39496. t.SerializeBuffers || ae(this.name, "data:") && (this.name = ""),
  39497. ae(this.name, "data:") && this.url === this.name && (this.url = "");
  39498. var n = e.prototype.serialize.call(this);
  39499. return n ? ((t.SerializeBuffers || t.ForceSerializeBuffers) && ("string" == typeof this._buffer && "data:" === this._buffer.substr(0, 5) ? (n.base64String = this._buffer,
  39500. n.name = n.name.replace("data:", "")) : this.url && ae(this.url, "data:") && this._buffer instanceof Uint8Array ? n.base64String = "data:image/png;base64," + le(this._buffer) : (t.ForceSerializeBuffers || this.url && ae(this.url, "blob:") || this._forceSerialize) && (n.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? $r(this) : eo(this))),
  39501. n.invertY = this._invertY,
  39502. n.samplingMode = this.samplingMode,
  39503. n._creationFlags = this._creationFlags,
  39504. n._useSRGBBuffer = this._useSRGBBuffer,
  39505. this.name = i,
  39506. n) : null
  39507. }
  39508. ,
  39509. t.prototype.getClassName = function() {
  39510. return "Texture"
  39511. }
  39512. ,
  39513. t.prototype.dispose = function() {
  39514. e.prototype.dispose.call(this),
  39515. this.onLoadObservable.clear(),
  39516. this._delayedOnLoad = null,
  39517. this._delayedOnError = null
  39518. }
  39519. ,
  39520. t.Parse = function(e, i, n) {
  39521. if (e.customType) {
  39522. var r = pi.Instantiate(e.customType).Parse(e, i, n);
  39523. return e.samplingMode && r.updateSamplingMode && r._samplingMode && r._samplingMode !== e.samplingMode && r.updateSamplingMode(e.samplingMode),
  39524. r
  39525. }
  39526. if (e.isCube && !e.isRenderTarget)
  39527. return t._CubeTextureParser(e, i, n);
  39528. if (!e.name && !e.isRenderTarget)
  39529. return null;
  39530. var o = function() {
  39531. if (a && a._texture && (a._texture._cachedWrapU = null,
  39532. a._texture._cachedWrapV = null,
  39533. a._texture._cachedWrapR = null),
  39534. e.samplingMode) {
  39535. var t = e.samplingMode;
  39536. a && a.samplingMode !== t && a.updateSamplingMode(t)
  39537. }
  39538. if (a && e.animations)
  39539. for (var i = 0; i < e.animations.length; i++) {
  39540. var n = e.animations[i]
  39541. , r = b("BABYLON.Animation");
  39542. r && a.animations.push(r.Parse(n))
  39543. }
  39544. }
  39545. , a = Ge.Parse((function() {
  39546. var r, a, s, l, c = !0;
  39547. if (e.noMipmap && (c = !1),
  39548. e.mirrorPlane) {
  39549. var u = t._CreateMirror(e.name, e.renderTargetSize, i, c);
  39550. return u._waitingRenderList = e.renderList,
  39551. u.mirrorPlane = hn.FromArray(e.mirrorPlane),
  39552. o(),
  39553. u
  39554. }
  39555. if (e.isRenderTarget) {
  39556. var h = null;
  39557. if (e.isCube) {
  39558. if (i.reflectionProbes)
  39559. for (var d = 0; d < i.reflectionProbes.length; d++) {
  39560. var p = i.reflectionProbes[d];
  39561. if (p.name === e.name)
  39562. return p.cubeTexture
  39563. }
  39564. } else
  39565. (h = t._CreateRenderTargetTexture(e.name, e.renderTargetSize, i, c, null !== (r = e._creationFlags) && void 0 !== r ? r : 0))._waitingRenderList = e.renderList;
  39566. return o(),
  39567. h
  39568. }
  39569. if (e.base64String)
  39570. l = t.CreateFromBase64String(e.base64String, e.name, i, !c, e.invertY, e.samplingMode, o, null !== (a = e._creationFlags) && void 0 !== a ? a : 0, null !== (s = e._useSRGBBuffer) && void 0 !== s && s);
  39571. else {
  39572. var f = void 0;
  39573. f = e.name && e.name.indexOf("://") > 0 ? e.name : n + e.name,
  39574. (ae(e.url, "data:") || t.UseSerializedUrlIfAny && e.url) && (f = e.url),
  39575. l = new t(f,i,!c,e.invertY,e.samplingMode,o)
  39576. }
  39577. return l
  39578. }
  39579. ), e, i);
  39580. return a
  39581. }
  39582. ,
  39583. t.CreateFromBase64String = function(e, i, n, r, o, s, l, c, u, h) {
  39584. return void 0 === s && (s = t.TRILINEAR_SAMPLINGMODE),
  39585. void 0 === l && (l = null),
  39586. void 0 === c && (c = null),
  39587. void 0 === u && (u = a.TEXTUREFORMAT_RGBA),
  39588. new t("data:" + i,n,r,o,s,l,c,e,!1,u,void 0,void 0,h)
  39589. }
  39590. ,
  39591. t.LoadFromDataString = function(e, i, n, r, o, s, l, c, u, h, d) {
  39592. return void 0 === r && (r = !1),
  39593. void 0 === s && (s = !0),
  39594. void 0 === l && (l = t.TRILINEAR_SAMPLINGMODE),
  39595. void 0 === c && (c = null),
  39596. void 0 === u && (u = null),
  39597. void 0 === h && (h = a.TEXTUREFORMAT_RGBA),
  39598. "data:" !== e.substr(0, 5) && (e = "data:" + e),
  39599. new t(e,n,o,s,l,c,u,i,r,h,void 0,void 0,d)
  39600. }
  39601. ,
  39602. t.SerializeBuffers = !0,
  39603. t.ForceSerializeBuffers = !1,
  39604. t.OnTextureLoadErrorObservable = new h,
  39605. t._CubeTextureParser = function(e, t, i) {
  39606. throw be("CubeTexture")
  39607. }
  39608. ,
  39609. t._CreateMirror = function(e, t, i, n) {
  39610. throw be("MirrorTexture")
  39611. }
  39612. ,
  39613. t._CreateRenderTargetTexture = function(e, t, i, n, r) {
  39614. throw be("RenderTargetTexture")
  39615. }
  39616. ,
  39617. t.NEAREST_SAMPLINGMODE = a.TEXTURE_NEAREST_SAMPLINGMODE,
  39618. t.NEAREST_NEAREST_MIPLINEAR = a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,
  39619. t.BILINEAR_SAMPLINGMODE = a.TEXTURE_BILINEAR_SAMPLINGMODE,
  39620. t.LINEAR_LINEAR_MIPNEAREST = a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,
  39621. t.TRILINEAR_SAMPLINGMODE = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  39622. t.LINEAR_LINEAR_MIPLINEAR = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
  39623. t.NEAREST_NEAREST_MIPNEAREST = a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,
  39624. t.NEAREST_LINEAR_MIPNEAREST = a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,
  39625. t.NEAREST_LINEAR_MIPLINEAR = a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,
  39626. t.NEAREST_LINEAR = a.TEXTURE_NEAREST_LINEAR,
  39627. t.NEAREST_NEAREST = a.TEXTURE_NEAREST_NEAREST,
  39628. t.LINEAR_NEAREST_MIPNEAREST = a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,
  39629. t.LINEAR_NEAREST_MIPLINEAR = a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,
  39630. t.LINEAR_LINEAR = a.TEXTURE_LINEAR_LINEAR,
  39631. t.LINEAR_NEAREST = a.TEXTURE_LINEAR_NEAREST,
  39632. t.EXPLICIT_MODE = a.TEXTURE_EXPLICIT_MODE,
  39633. t.SPHERICAL_MODE = a.TEXTURE_SPHERICAL_MODE,
  39634. t.PLANAR_MODE = a.TEXTURE_PLANAR_MODE,
  39635. t.CUBIC_MODE = a.TEXTURE_CUBIC_MODE,
  39636. t.PROJECTION_MODE = a.TEXTURE_PROJECTION_MODE,
  39637. t.SKYBOX_MODE = a.TEXTURE_SKYBOX_MODE,
  39638. t.INVCUBIC_MODE = a.TEXTURE_INVCUBIC_MODE,
  39639. t.EQUIRECTANGULAR_MODE = a.TEXTURE_EQUIRECTANGULAR_MODE,
  39640. t.FIXED_EQUIRECTANGULAR_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,
  39641. t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
  39642. t.CLAMP_ADDRESSMODE = a.TEXTURE_CLAMP_ADDRESSMODE,
  39643. t.WRAP_ADDRESSMODE = a.TEXTURE_WRAP_ADDRESSMODE,
  39644. t.MIRROR_ADDRESSMODE = a.TEXTURE_MIRROR_ADDRESSMODE,
  39645. t.UseSerializedUrlIfAny = !1,
  39646. k([Ce()], t.prototype, "url", void 0),
  39647. k([Ce()], t.prototype, "uOffset", void 0),
  39648. k([Ce()], t.prototype, "vOffset", void 0),
  39649. k([Ce()], t.prototype, "uScale", void 0),
  39650. k([Ce()], t.prototype, "vScale", void 0),
  39651. k([Ce()], t.prototype, "uAng", void 0),
  39652. k([Ce()], t.prototype, "vAng", void 0),
  39653. k([Ce()], t.prototype, "wAng", void 0),
  39654. k([Ce()], t.prototype, "uRotationCenter", void 0),
  39655. k([Ce()], t.prototype, "vRotationCenter", void 0),
  39656. k([Ce()], t.prototype, "wRotationCenter", void 0),
  39657. k([Ce()], t.prototype, "homogeneousRotationInUVTransform", void 0),
  39658. k([Ce()], t.prototype, "isBlocking", null),
  39659. t
  39660. }(Zr);
  39661. function no(e, t, i, n) {
  39662. var r, o = 1;
  39663. n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
  39664. o = 15360) : r = n === a.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * i * 4) : new Uint8Array(t * i * 4);
  39665. for (var s = 0; s < t; s++)
  39666. for (var l = 0; l < i; l++) {
  39667. var c = 3 * (l * t + s)
  39668. , u = 4 * (l * t + s);
  39669. r[u + 0] = e[c + 0],
  39670. r[u + 1] = e[c + 1],
  39671. r[u + 2] = e[c + 2],
  39672. r[u + 3] = o
  39673. }
  39674. return r
  39675. }
  39676. function ro(e) {
  39677. return function(t, i, n, r, o, s, l, c, u, h) {
  39678. void 0 === u && (u = null),
  39679. void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
  39680. var d = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
  39681. , p = e ? At.Raw3D : At.Raw2DArray
  39682. , f = new Lt(this,p);
  39683. f.baseWidth = i,
  39684. f.baseHeight = n,
  39685. f.baseDepth = r,
  39686. f.width = i,
  39687. f.height = n,
  39688. f.depth = r,
  39689. f.format = o,
  39690. f.type = h,
  39691. f.generateMipMaps = s,
  39692. f.samplingMode = c,
  39693. e ? f.is3D = !0 : f.is2DArray = !0,
  39694. this._doNotHandleContextLost || (f._bufferView = t),
  39695. e ? this.updateRawTexture3D(f, t, o, l, u, h) : this.updateRawTexture2DArray(f, t, o, l, u, h),
  39696. this._bindTextureDirectly(d, f, !0);
  39697. var _ = this._getSamplingParameters(c, s);
  39698. return this._gl.texParameteri(d, this._gl.TEXTURE_MAG_FILTER, _.mag),
  39699. this._gl.texParameteri(d, this._gl.TEXTURE_MIN_FILTER, _.min),
  39700. s && this._gl.generateMipmap(d),
  39701. this._bindTextureDirectly(d, null),
  39702. this._internalTexturesCache.push(f),
  39703. f
  39704. }
  39705. }
  39706. function oo(e) {
  39707. return function(t, i, n, r, o, s) {
  39708. void 0 === o && (o = null),
  39709. void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT);
  39710. var l = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
  39711. , c = this._getWebGLTextureType(s)
  39712. , u = this._getInternalFormat(n)
  39713. , h = this._getRGBABufferInternalSizedFormat(s, n);
  39714. this._bindTextureDirectly(l, t, !0),
  39715. this._unpackFlipY(void 0 === r || !!r),
  39716. this._doNotHandleContextLost || (t._bufferView = i,
  39717. t.format = n,
  39718. t.invertY = r,
  39719. t._compression = o),
  39720. t.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
  39721. o && i ? this._gl.compressedTexImage3D(l, 0, this.getCaps().s3tc[o], t.width, t.height, t.depth, 0, i) : this._gl.texImage3D(l, 0, h, t.width, t.height, t.depth, 0, u, c, i),
  39722. t.generateMipMaps && this._gl.generateMipmap(l),
  39723. this._bindTextureDirectly(l, null),
  39724. t.isReady = !0
  39725. }
  39726. }
  39727. y("BABYLON.Texture", io),
  39728. Ge._TextureParser = io.Parse,
  39729. Ht.prototype.updateRawTexture = function(e, t, i, n, r, o) {
  39730. if (void 0 === r && (r = null),
  39731. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  39732. e) {
  39733. var s = this._getRGBABufferInternalSizedFormat(o, i)
  39734. , l = this._getInternalFormat(i)
  39735. , c = this._getWebGLTextureType(o);
  39736. this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
  39737. this._unpackFlipY(void 0 === n || !!n),
  39738. this._doNotHandleContextLost || (e._bufferView = t,
  39739. e.format = i,
  39740. e.type = o,
  39741. e.invertY = n,
  39742. e._compression = r),
  39743. e.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
  39744. r && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[r], e.width, e.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, s, e.width, e.height, 0, l, c, t),
  39745. e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  39746. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  39747. e.isReady = !0
  39748. }
  39749. }
  39750. ,
  39751. Ht.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
  39752. void 0 === l && (l = null),
  39753. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  39754. void 0 === u && (u = 0);
  39755. var h = new Lt(this,At.Raw);
  39756. h.baseWidth = t,
  39757. h.baseHeight = i,
  39758. h.width = t,
  39759. h.height = i,
  39760. h.format = n,
  39761. h.generateMipMaps = r,
  39762. h.samplingMode = s,
  39763. h.invertY = o,
  39764. h._compression = l,
  39765. h.type = c,
  39766. this._doNotHandleContextLost || (h._bufferView = e),
  39767. this.updateRawTexture(h, e, n, o, l, c),
  39768. this._bindTextureDirectly(this._gl.TEXTURE_2D, h, !0);
  39769. var d = this._getSamplingParameters(s, r);
  39770. return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, d.mag),
  39771. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, d.min),
  39772. r && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  39773. this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  39774. this._internalTexturesCache.push(h),
  39775. h
  39776. }
  39777. ,
  39778. Ht.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
  39779. void 0 === l && (l = null);
  39780. var c = this._gl
  39781. , u = new Lt(this,At.CubeRaw);
  39782. u.isCube = !0,
  39783. u.format = i,
  39784. u.type = n,
  39785. this._doNotHandleContextLost || (u._bufferViewArray = e);
  39786. var h = this._getWebGLTextureType(n)
  39787. , d = this._getInternalFormat(i);
  39788. d === c.RGB && (d = c.RGBA),
  39789. h !== c.FLOAT || this._caps.textureFloatLinearFiltering ? h !== this._gl.HALF_FLOAT_OES || this._caps.textureHalfFloatLinearFiltering ? h !== c.FLOAT || this._caps.textureFloatRender ? h !== c.HALF_FLOAT || this._caps.colorBufferFloat || (r = !1,
  39790. K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
  39791. K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
  39792. s = a.TEXTURE_NEAREST_SAMPLINGMODE,
  39793. K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
  39794. s = a.TEXTURE_NEAREST_SAMPLINGMODE,
  39795. K.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));
  39796. var p = t
  39797. , f = p;
  39798. u.width = p,
  39799. u.height = f,
  39800. !this.needPOTTextures || gi.IsExponentOfTwo(u.width) && gi.IsExponentOfTwo(u.height) || (r = !1),
  39801. e && this.updateRawCubeTexture(u, e, i, n, o, l),
  39802. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, u, !0),
  39803. e && r && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  39804. var _ = this._getSamplingParameters(s, r);
  39805. return c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MAG_FILTER, _.mag),
  39806. c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MIN_FILTER, _.min),
  39807. c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE),
  39808. c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE),
  39809. this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, null),
  39810. u.generateMipMaps = r,
  39811. u.samplingMode = s,
  39812. u
  39813. }
  39814. ,
  39815. Ht.prototype.updateRawCubeTexture = function(e, t, i, n, r, o, a) {
  39816. void 0 === o && (o = null),
  39817. void 0 === a && (a = 0),
  39818. e._bufferViewArray = t,
  39819. e.format = i,
  39820. e.type = n,
  39821. e.invertY = r,
  39822. e._compression = o;
  39823. var s = this._gl
  39824. , l = this._getWebGLTextureType(n)
  39825. , c = this._getInternalFormat(i)
  39826. , u = this._getRGBABufferInternalSizedFormat(n)
  39827. , h = !1;
  39828. c === s.RGB && (c = s.RGBA,
  39829. h = !0),
  39830. this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, e, !0),
  39831. this._unpackFlipY(void 0 === r || !!r),
  39832. e.width % 4 != 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1);
  39833. for (var d = 0; d < 6; d++) {
  39834. var p = t[d];
  39835. o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, this.getCaps().s3tc[o], e.width, e.height, 0, p) : (h && (p = no(p, e.width, e.height, n)),
  39836. s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, u, e.width, e.height, 0, c, l, p))
  39837. }
  39838. (!this.needPOTTextures || gi.IsExponentOfTwo(e.width) && gi.IsExponentOfTwo(e.height)) && e.generateMipMaps && 0 === a && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),
  39839. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
  39840. e.isReady = !0
  39841. }
  39842. ,
  39843. Ht.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, o, s, l, c, u, h, d) {
  39844. var p = this;
  39845. void 0 === c && (c = null),
  39846. void 0 === u && (u = null),
  39847. void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39848. void 0 === d && (d = !1);
  39849. var f = this._gl
  39850. , _ = this.createRawCubeTexture(null, i, n, r, !o, d, h, null);
  39851. return null == t || t._addPendingData(_),
  39852. _.url = e,
  39853. this._internalTexturesCache.push(_),
  39854. this._loadFile(e, (function(e) {
  39855. !function(e) {
  39856. var i = _.width
  39857. , o = s(e);
  39858. if (o) {
  39859. if (l) {
  39860. var a = p._getWebGLTextureType(r)
  39861. , u = p._getInternalFormat(n)
  39862. , h = p._getRGBABufferInternalSizedFormat(r)
  39863. , m = !1;
  39864. u === f.RGB && (u = f.RGBA,
  39865. m = !0),
  39866. p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, _, !0),
  39867. p._unpackFlipY(!1);
  39868. for (var g = l(o), v = 0; v < g.length; v++)
  39869. for (var y = i >> v, b = 0; b < 6; b++) {
  39870. var T = g[v][b];
  39871. m && (T = no(T, y, y, r)),
  39872. f.texImage2D(b, v, h, y, y, 0, u, a, T)
  39873. }
  39874. p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, null)
  39875. } else
  39876. p.updateRawCubeTexture(_, o, n, r, d);
  39877. _.isReady = !0,
  39878. null == t || t._removePendingData(_),
  39879. c && c()
  39880. }
  39881. }(e)
  39882. }
  39883. ), void 0, null == t ? void 0 : t.offlineProvider, !0, (function(e, i) {
  39884. null == t || t._removePendingData(_),
  39885. u && e && u(e.status + " " + e.statusText, i)
  39886. }
  39887. )),
  39888. _
  39889. }
  39890. ,
  39891. Ht.prototype.createRawTexture2DArray = ro(!1),
  39892. Ht.prototype.createRawTexture3D = ro(!0),
  39893. Ht.prototype.updateRawTexture2DArray = oo(!1),
  39894. Ht.prototype.updateRawTexture3D = oo(!0);
  39895. var ao = function(e) {
  39896. function t(t, i, n, r, o, s, l, c, u, h) {
  39897. void 0 === s && (s = !0),
  39898. void 0 === l && (l = !1),
  39899. void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39900. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT);
  39901. var d = e.call(this, null, o, !s, l, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, h) || this;
  39902. return d.format = r,
  39903. d._engine ? (d._engine._caps.textureFloatLinearFiltering || u !== a.TEXTURETYPE_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
  39904. d._engine._caps.textureHalfFloatLinearFiltering || u !== a.TEXTURETYPE_HALF_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
  39905. d._texture = d._engine.createRawTexture(t, i, n, r, s, l, c, null, u, null != h ? h : 0),
  39906. d.wrapU = io.CLAMP_ADDRESSMODE,
  39907. d.wrapV = io.CLAMP_ADDRESSMODE,
  39908. d) : d
  39909. }
  39910. return U(t, e),
  39911. t.prototype.update = function(e) {
  39912. this._getEngine().updateRawTexture(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
  39913. }
  39914. ,
  39915. t.CreateLuminanceTexture = function(e, i, n, r, o, s, l) {
  39916. return void 0 === o && (o = !0),
  39917. void 0 === s && (s = !1),
  39918. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39919. new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE,r,o,s,l)
  39920. }
  39921. ,
  39922. t.CreateLuminanceAlphaTexture = function(e, i, n, r, o, s, l) {
  39923. return void 0 === o && (o = !0),
  39924. void 0 === s && (s = !1),
  39925. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39926. new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,s,l)
  39927. }
  39928. ,
  39929. t.CreateAlphaTexture = function(e, i, n, r, o, s, l) {
  39930. return void 0 === o && (o = !0),
  39931. void 0 === s && (s = !1),
  39932. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39933. new t(e,i,n,a.TEXTUREFORMAT_ALPHA,r,o,s,l)
  39934. }
  39935. ,
  39936. t.CreateRGBTexture = function(e, i, n, r, o, s, l, c) {
  39937. return void 0 === o && (o = !0),
  39938. void 0 === s && (s = !1),
  39939. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39940. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  39941. new t(e,i,n,a.TEXTUREFORMAT_RGB,r,o,s,l,c)
  39942. }
  39943. ,
  39944. t.CreateRGBATexture = function(e, i, n, r, o, s, l, c) {
  39945. return void 0 === o && (o = !0),
  39946. void 0 === s && (s = !1),
  39947. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39948. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  39949. new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c)
  39950. }
  39951. ,
  39952. t.CreateRGBAStorageTexture = function(e, i, n, r, o, s, l, c) {
  39953. return void 0 === o && (o = !0),
  39954. void 0 === s && (s = !1),
  39955. void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  39956. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  39957. new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
  39958. }
  39959. ,
  39960. t.CreateRTexture = function(e, i, n, r, o, s, l, c) {
  39961. return void 0 === o && (o = !0),
  39962. void 0 === s && (s = !1),
  39963. void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
  39964. void 0 === c && (c = a.TEXTURETYPE_FLOAT),
  39965. new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c)
  39966. }
  39967. ,
  39968. t.CreateRStorageTexture = function(e, i, n, r, o, s, l, c) {
  39969. return void 0 === o && (o = !0),
  39970. void 0 === s && (s = !1),
  39971. void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
  39972. void 0 === c && (c = a.TEXTURETYPE_FLOAT),
  39973. new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
  39974. }
  39975. ,
  39976. t
  39977. }(io)
  39978. , so = function() {
  39979. function e(e, t) {
  39980. this._scene = e,
  39981. this._mesh = t
  39982. }
  39983. return e.prototype.bakeVertexData = function(e) {
  39984. return G(this, void 0, void 0, (function() {
  39985. var t, i, n, r, o, a, s, l;
  39986. return z(this, (function(c) {
  39987. switch (c.label) {
  39988. case 0:
  39989. if (!this._mesh.skeleton)
  39990. throw new Error("No skeleton in this mesh.");
  39991. if (t = this._mesh.skeleton.bones.length,
  39992. i = e.reduce((function(e, t) {
  39993. return e + t.to - t.from + 1
  39994. }
  39995. ), 0),
  39996. isNaN(i))
  39997. throw new Error("Invalid animation ranges.");
  39998. n = 0,
  39999. r = new Float32Array(4 * (t + 1) * 4 * i),
  40000. this._scene.stopAnimation(this._mesh),
  40001. this._mesh.skeleton.returnToRest(),
  40002. o = 0,
  40003. a = e,
  40004. c.label = 1;
  40005. case 1:
  40006. if (!(o < a.length))
  40007. return [3, 6];
  40008. s = a[o],
  40009. l = s.from,
  40010. c.label = 2;
  40011. case 2:
  40012. return l <= s.to ? [4, this._executeAnimationFrame(r, l, n++)] : [3, 5];
  40013. case 3:
  40014. c.sent(),
  40015. c.label = 4;
  40016. case 4:
  40017. return l++,
  40018. [3, 2];
  40019. case 5:
  40020. return o++,
  40021. [3, 1];
  40022. case 6:
  40023. return [2, r]
  40024. }
  40025. }
  40026. ))
  40027. }
  40028. ))
  40029. }
  40030. ,
  40031. e.prototype._executeAnimationFrame = function(e, t, i) {
  40032. return G(this, void 0, void 0, (function() {
  40033. var n = this;
  40034. return z(this, (function(r) {
  40035. return [2, new Promise((function(r, o) {
  40036. n._scene.beginAnimation(n._mesh.skeleton, t, t, !1, 1, (function() {
  40037. var t = n._mesh.skeleton.getTransformMatrices(n._mesh);
  40038. e.set(t, i * t.length),
  40039. r()
  40040. }
  40041. ))
  40042. }
  40043. ))]
  40044. }
  40045. ))
  40046. }
  40047. ))
  40048. }
  40049. ,
  40050. e.prototype.textureFromBakedVertexData = function(e) {
  40051. if (!this._mesh.skeleton)
  40052. throw new Error("No skeleton in this mesh.");
  40053. var t = this._mesh.skeleton.bones.length
  40054. , i = ao.CreateRGBATexture(e, 4 * (t + 1), e.length / (4 * (t + 1) * 4), this._scene, !1, !1, io.NEAREST_NEAREST, a.TEXTURETYPE_FLOAT);
  40055. return i.name = "VAT" + this._mesh.skeleton.name,
  40056. i
  40057. }
  40058. ,
  40059. e.prototype.serializeBakedVertexDataToObject = function(e) {
  40060. if (!this._mesh.skeleton)
  40061. throw new Error("No skeleton in this mesh.");
  40062. var t = this._mesh.skeleton.bones.length
  40063. , i = 4 * (t + 1)
  40064. , n = e.length / (4 * (t + 1) * 4);
  40065. return {
  40066. vertexData: le(e),
  40067. width: i,
  40068. height: n
  40069. }
  40070. }
  40071. ,
  40072. e.prototype.loadBakedVertexDataFromObject = function(e) {
  40073. return new Float32Array(ue(e.vertexData))
  40074. }
  40075. ,
  40076. e.prototype.serializeBakedVertexDataToJSON = function(e) {
  40077. return JSON.stringify(this.serializeBakedVertexDataToObject(e))
  40078. }
  40079. ,
  40080. e.prototype.loadBakedVertexDataFromJSON = function(e) {
  40081. return this.loadBakedVertexDataFromObject(JSON.parse(e))
  40082. }
  40083. ,
  40084. e
  40085. }()
  40086. , lo = function() {
  40087. function e() {
  40088. this._zoomStopsAnimation = !1,
  40089. this._idleRotationSpeed = .05,
  40090. this._idleRotationWaitTime = 2e3,
  40091. this._idleRotationSpinupTime = 2e3,
  40092. this._isPointerDown = !1,
  40093. this._lastFrameTime = null,
  40094. this._lastInteractionTime = -1 / 0,
  40095. this._cameraRotationSpeed = 0,
  40096. this._lastFrameRadius = 0
  40097. }
  40098. return Object.defineProperty(e.prototype, "name", {
  40099. get: function() {
  40100. return "AutoRotation"
  40101. },
  40102. enumerable: !1,
  40103. configurable: !0
  40104. }),
  40105. Object.defineProperty(e.prototype, "zoomStopsAnimation", {
  40106. get: function() {
  40107. return this._zoomStopsAnimation
  40108. },
  40109. set: function(e) {
  40110. this._zoomStopsAnimation = e
  40111. },
  40112. enumerable: !1,
  40113. configurable: !0
  40114. }),
  40115. Object.defineProperty(e.prototype, "idleRotationSpeed", {
  40116. get: function() {
  40117. return this._idleRotationSpeed
  40118. },
  40119. set: function(e) {
  40120. this._idleRotationSpeed = e
  40121. },
  40122. enumerable: !1,
  40123. configurable: !0
  40124. }),
  40125. Object.defineProperty(e.prototype, "idleRotationWaitTime", {
  40126. get: function() {
  40127. return this._idleRotationWaitTime
  40128. },
  40129. set: function(e) {
  40130. this._idleRotationWaitTime = e
  40131. },
  40132. enumerable: !1,
  40133. configurable: !0
  40134. }),
  40135. Object.defineProperty(e.prototype, "idleRotationSpinupTime", {
  40136. get: function() {
  40137. return this._idleRotationSpinupTime
  40138. },
  40139. set: function(e) {
  40140. this._idleRotationSpinupTime = e
  40141. },
  40142. enumerable: !1,
  40143. configurable: !0
  40144. }),
  40145. Object.defineProperty(e.prototype, "rotationInProgress", {
  40146. get: function() {
  40147. return Math.abs(this._cameraRotationSpeed) > 0
  40148. },
  40149. enumerable: !1,
  40150. configurable: !0
  40151. }),
  40152. e.prototype.init = function() {}
  40153. ,
  40154. e.prototype.attach = function(e) {
  40155. var t = this;
  40156. this._attachedCamera = e;
  40157. var i = this._attachedCamera.getScene();
  40158. this._onPrePointerObservableObserver = i.onPrePointerObservable.add((function(e) {
  40159. e.type !== Xi.POINTERDOWN ? e.type === Xi.POINTERUP && (t._isPointerDown = !1) : t._isPointerDown = !0
  40160. }
  40161. )),
  40162. this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function() {
  40163. var e = ct.Now
  40164. , i = 0;
  40165. null != t._lastFrameTime && (i = e - t._lastFrameTime),
  40166. t._lastFrameTime = e,
  40167. t._applyUserInteraction();
  40168. var n = e - t._lastInteractionTime - t._idleRotationWaitTime
  40169. , r = Math.max(Math.min(n / t._idleRotationSpinupTime, 1), 0);
  40170. t._cameraRotationSpeed = t._idleRotationSpeed * r,
  40171. t._attachedCamera && (t._attachedCamera.alpha -= t._cameraRotationSpeed * (i / 1e3))
  40172. }
  40173. ))
  40174. }
  40175. ,
  40176. e.prototype.detach = function() {
  40177. if (this._attachedCamera) {
  40178. var e = this._attachedCamera.getScene();
  40179. this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
  40180. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  40181. this._attachedCamera = null
  40182. }
  40183. }
  40184. ,
  40185. e.prototype.resetLastInteractionTime = function(e) {
  40186. this._lastInteractionTime = null != e ? e : ct.Now
  40187. }
  40188. ,
  40189. e.prototype._userIsZooming = function() {
  40190. return !!this._attachedCamera && 0 !== this._attachedCamera.inertialRadiusOffset
  40191. }
  40192. ,
  40193. e.prototype._shouldAnimationStopForInteraction = function() {
  40194. if (!this._attachedCamera)
  40195. return !1;
  40196. var e = !1;
  40197. return this._lastFrameRadius === this._attachedCamera.radius && 0 !== this._attachedCamera.inertialRadiusOffset && (e = !0),
  40198. this._lastFrameRadius = this._attachedCamera.radius,
  40199. this._zoomStopsAnimation ? e : this._userIsZooming()
  40200. }
  40201. ,
  40202. e.prototype._applyUserInteraction = function() {
  40203. this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = ct.Now)
  40204. }
  40205. ,
  40206. e.prototype._userIsMoving = function() {
  40207. return !!this._attachedCamera && (0 !== this._attachedCamera.inertialAlphaOffset || 0 !== this._attachedCamera.inertialBetaOffset || 0 !== this._attachedCamera.inertialRadiusOffset || 0 !== this._attachedCamera.inertialPanningX || 0 !== this._attachedCamera.inertialPanningY || this._isPointerDown)
  40208. }
  40209. ,
  40210. e
  40211. }()
  40212. , co = function() {
  40213. function e() {
  40214. this.transitionDuration = 450,
  40215. this.lowerRadiusTransitionRange = 2,
  40216. this.upperRadiusTransitionRange = -2,
  40217. this._autoTransitionRange = !1,
  40218. this._radiusIsAnimating = !1,
  40219. this._radiusBounceTransition = null,
  40220. this._animatables = new Array
  40221. }
  40222. return Object.defineProperty(e.prototype, "name", {
  40223. get: function() {
  40224. return "Bouncing"
  40225. },
  40226. enumerable: !1,
  40227. configurable: !0
  40228. }),
  40229. Object.defineProperty(e.prototype, "autoTransitionRange", {
  40230. get: function() {
  40231. return this._autoTransitionRange
  40232. },
  40233. set: function(e) {
  40234. var t = this;
  40235. if (this._autoTransitionRange !== e) {
  40236. this._autoTransitionRange = e;
  40237. var i = this._attachedCamera;
  40238. i && (e ? this._onMeshTargetChangedObserver = i.onMeshTargetChangedObservable.add((function(e) {
  40239. if (e) {
  40240. e.computeWorldMatrix(!0);
  40241. var i = e.getBoundingInfo().diagonalLength;
  40242. t.lowerRadiusTransitionRange = .05 * i,
  40243. t.upperRadiusTransitionRange = .05 * i
  40244. }
  40245. }
  40246. )) : this._onMeshTargetChangedObserver && i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))
  40247. }
  40248. },
  40249. enumerable: !1,
  40250. configurable: !0
  40251. }),
  40252. e.prototype.init = function() {}
  40253. ,
  40254. e.prototype.attach = function(e) {
  40255. var t = this;
  40256. this._attachedCamera = e,
  40257. this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function() {
  40258. t._attachedCamera && (t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit) && t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),
  40259. t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit) && t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))
  40260. }
  40261. ))
  40262. }
  40263. ,
  40264. e.prototype.detach = function() {
  40265. this._attachedCamera && (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  40266. this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
  40267. this._attachedCamera = null)
  40268. }
  40269. ,
  40270. e.prototype._isRadiusAtLimit = function(e) {
  40271. return !!this._attachedCamera && this._attachedCamera.radius === e && !this._radiusIsAnimating
  40272. }
  40273. ,
  40274. e.prototype._applyBoundRadiusAnimation = function(t) {
  40275. var i = this;
  40276. if (this._attachedCamera) {
  40277. this._radiusBounceTransition || (e.EasingFunction.setEasingMode(e.EasingMode),
  40278. this._radiusBounceTransition = Qe.CreateAnimation("radius", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)),
  40279. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision,
  40280. this._attachedCamera.wheelPrecision = 1 / 0,
  40281. this._attachedCamera.inertialRadiusOffset = 0,
  40282. this.stopAllAnimations(),
  40283. this._radiusIsAnimating = !0;
  40284. var n = Qe.TransitionTo("radius", this._attachedCamera.radius + t, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, (function() {
  40285. return i._clearAnimationLocks()
  40286. }
  40287. ));
  40288. n && this._animatables.push(n)
  40289. }
  40290. }
  40291. ,
  40292. e.prototype._clearAnimationLocks = function() {
  40293. this._radiusIsAnimating = !1,
  40294. this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision)
  40295. }
  40296. ,
  40297. e.prototype.stopAllAnimations = function() {
  40298. for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
  40299. this._animatables[0].onAnimationEnd = null,
  40300. this._animatables[0].stop(),
  40301. this._animatables.shift()
  40302. }
  40303. ,
  40304. e.EasingFunction = new On(.3),
  40305. e.EasingMode = Mn.EASINGMODE_EASEOUT,
  40306. e
  40307. }()
  40308. , uo = function() {
  40309. function e() {
  40310. this.onTargetFramingAnimationEndObservable = new h,
  40311. this._mode = e.FitFrustumSidesMode,
  40312. this._radiusScale = 1,
  40313. this._positionScale = .5,
  40314. this._defaultElevation = .3,
  40315. this._elevationReturnTime = 1500,
  40316. this._elevationReturnWaitTime = 1e3,
  40317. this._zoomStopsAnimation = !1,
  40318. this._framingTime = 1500,
  40319. this.autoCorrectCameraLimitsAndSensibility = !0,
  40320. this._isPointerDown = !1,
  40321. this._lastInteractionTime = -1 / 0,
  40322. this._animatables = new Array,
  40323. this._betaIsAnimating = !1
  40324. }
  40325. return Object.defineProperty(e.prototype, "name", {
  40326. get: function() {
  40327. return "Framing"
  40328. },
  40329. enumerable: !1,
  40330. configurable: !0
  40331. }),
  40332. Object.defineProperty(e.prototype, "mode", {
  40333. get: function() {
  40334. return this._mode
  40335. },
  40336. set: function(e) {
  40337. this._mode = e
  40338. },
  40339. enumerable: !1,
  40340. configurable: !0
  40341. }),
  40342. Object.defineProperty(e.prototype, "radiusScale", {
  40343. get: function() {
  40344. return this._radiusScale
  40345. },
  40346. set: function(e) {
  40347. this._radiusScale = e
  40348. },
  40349. enumerable: !1,
  40350. configurable: !0
  40351. }),
  40352. Object.defineProperty(e.prototype, "positionScale", {
  40353. get: function() {
  40354. return this._positionScale
  40355. },
  40356. set: function(e) {
  40357. this._positionScale = e
  40358. },
  40359. enumerable: !1,
  40360. configurable: !0
  40361. }),
  40362. Object.defineProperty(e.prototype, "defaultElevation", {
  40363. get: function() {
  40364. return this._defaultElevation
  40365. },
  40366. set: function(e) {
  40367. this._defaultElevation = e
  40368. },
  40369. enumerable: !1,
  40370. configurable: !0
  40371. }),
  40372. Object.defineProperty(e.prototype, "elevationReturnTime", {
  40373. get: function() {
  40374. return this._elevationReturnTime
  40375. },
  40376. set: function(e) {
  40377. this._elevationReturnTime = e
  40378. },
  40379. enumerable: !1,
  40380. configurable: !0
  40381. }),
  40382. Object.defineProperty(e.prototype, "elevationReturnWaitTime", {
  40383. get: function() {
  40384. return this._elevationReturnWaitTime
  40385. },
  40386. set: function(e) {
  40387. this._elevationReturnWaitTime = e
  40388. },
  40389. enumerable: !1,
  40390. configurable: !0
  40391. }),
  40392. Object.defineProperty(e.prototype, "zoomStopsAnimation", {
  40393. get: function() {
  40394. return this._zoomStopsAnimation
  40395. },
  40396. set: function(e) {
  40397. this._zoomStopsAnimation = e
  40398. },
  40399. enumerable: !1,
  40400. configurable: !0
  40401. }),
  40402. Object.defineProperty(e.prototype, "framingTime", {
  40403. get: function() {
  40404. return this._framingTime
  40405. },
  40406. set: function(e) {
  40407. this._framingTime = e
  40408. },
  40409. enumerable: !1,
  40410. configurable: !0
  40411. }),
  40412. e.prototype.init = function() {}
  40413. ,
  40414. e.prototype.attach = function(t) {
  40415. var i = this;
  40416. this._attachedCamera = t;
  40417. var n = this._attachedCamera.getScene();
  40418. e.EasingFunction.setEasingMode(e.EasingMode),
  40419. this._onPrePointerObservableObserver = n.onPrePointerObservable.add((function(e) {
  40420. e.type !== Xi.POINTERDOWN ? e.type === Xi.POINTERUP && (i._isPointerDown = !1) : i._isPointerDown = !0
  40421. }
  40422. )),
  40423. this._onMeshTargetChangedObserver = t.onMeshTargetChangedObservable.add((function(e) {
  40424. e && i.zoomOnMesh(e, void 0, (function() {
  40425. i.onTargetFramingAnimationEndObservable.notifyObservers()
  40426. }
  40427. ))
  40428. }
  40429. )),
  40430. this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add((function() {
  40431. i._applyUserInteraction(),
  40432. i._maintainCameraAboveGround()
  40433. }
  40434. ))
  40435. }
  40436. ,
  40437. e.prototype.detach = function() {
  40438. if (this._attachedCamera) {
  40439. var e = this._attachedCamera.getScene();
  40440. this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
  40441. this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
  40442. this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
  40443. this._attachedCamera = null
  40444. }
  40445. }
  40446. ,
  40447. e.prototype.zoomOnMesh = function(e, t, i) {
  40448. void 0 === t && (t = !1),
  40449. void 0 === i && (i = null),
  40450. e.computeWorldMatrix(!0);
  40451. var n = e.getBoundingInfo().boundingBox;
  40452. this.zoomOnBoundingInfo(n.minimumWorld, n.maximumWorld, t, i)
  40453. }
  40454. ,
  40455. e.prototype.zoomOnMeshHierarchy = function(e, t, i) {
  40456. void 0 === t && (t = !1),
  40457. void 0 === i && (i = null),
  40458. e.computeWorldMatrix(!0);
  40459. var n = e.getHierarchyBoundingVectors(!0);
  40460. this.zoomOnBoundingInfo(n.min, n.max, t, i)
  40461. }
  40462. ,
  40463. e.prototype.zoomOnMeshesHierarchy = function(e, t, i) {
  40464. void 0 === t && (t = !1),
  40465. void 0 === i && (i = null);
  40466. for (var n = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE), r = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE), o = 0; o < e.length; o++) {
  40467. var a = e[o].getHierarchyBoundingVectors(!0);
  40468. x.CheckExtends(a.min, n, r),
  40469. x.CheckExtends(a.max, n, r)
  40470. }
  40471. this.zoomOnBoundingInfo(n, r, t, i)
  40472. }
  40473. ,
  40474. e.prototype.zoomOnBoundingInfo = function(t, i, n, r) {
  40475. var o, a = this;
  40476. if (void 0 === n && (n = !1),
  40477. void 0 === r && (r = null),
  40478. this._attachedCamera) {
  40479. var s = t.y
  40480. , l = s + (i.y - s) * this._positionScale
  40481. , c = i.subtract(t).scale(.5);
  40482. if (n)
  40483. o = new x(0,l,0);
  40484. else {
  40485. var u = t.add(c);
  40486. o = new x(u.x,l,u.z)
  40487. }
  40488. this._vectorTransition || (this._vectorTransition = Qe.CreateAnimation("target", Qe.ANIMATIONTYPE_VECTOR3, 60, e.EasingFunction)),
  40489. this._betaIsAnimating = !0;
  40490. var h = Qe.TransitionTo("target", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  40491. h && this._animatables.push(h);
  40492. var d = 0;
  40493. if (this._mode === e.FitFrustumSidesMode) {
  40494. var p = this._calculateLowerRadiusFromModelBoundingSphere(t, i);
  40495. this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = c.length() + this._attachedCamera.minZ),
  40496. d = p
  40497. } else
  40498. this._mode === e.IgnoreBoundsSizeMode && (d = this._calculateLowerRadiusFromModelBoundingSphere(t, i),
  40499. this.autoCorrectCameraLimitsAndSensibility && null === this._attachedCamera.lowerRadiusLimit && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
  40500. if (this.autoCorrectCameraLimitsAndSensibility) {
  40501. var f = i.subtract(t).length();
  40502. this._attachedCamera.panningSensibility = 5e3 / f,
  40503. this._attachedCamera.wheelPrecision = 100 / d
  40504. }
  40505. this._radiusTransition || (this._radiusTransition = Qe.CreateAnimation("radius", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)),
  40506. (h = Qe.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, (function() {
  40507. a.stopAllAnimations(),
  40508. r && r(),
  40509. a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState()
  40510. }
  40511. ))) && this._animatables.push(h)
  40512. }
  40513. }
  40514. ,
  40515. e.prototype._calculateLowerRadiusFromModelBoundingSphere = function(t, i) {
  40516. var n = i.subtract(t).length()
  40517. , r = this._getFrustumSlope()
  40518. , o = .5 * n * this._radiusScale
  40519. , a = o * Math.sqrt(1 + 1 / (r.x * r.x))
  40520. , s = o * Math.sqrt(1 + 1 / (r.y * r.y))
  40521. , l = Math.max(a, s)
  40522. , c = this._attachedCamera;
  40523. return c ? (c.lowerRadiusLimit && this._mode === e.IgnoreBoundsSizeMode && (l = l < c.lowerRadiusLimit ? c.lowerRadiusLimit : l),
  40524. c.upperRadiusLimit && (l = l > c.upperRadiusLimit ? c.upperRadiusLimit : l),
  40525. l) : 0
  40526. }
  40527. ,
  40528. e.prototype._maintainCameraAboveGround = function() {
  40529. var t = this;
  40530. if (!(this._elevationReturnTime < 0)) {
  40531. var i = ct.Now - this._lastInteractionTime
  40532. , n = .5 * Math.PI - this._defaultElevation
  40533. , r = .5 * Math.PI;
  40534. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > r && i >= this._elevationReturnWaitTime) {
  40535. this._betaIsAnimating = !0,
  40536. this.stopAllAnimations(),
  40537. this._betaTransition || (this._betaTransition = Qe.CreateAnimation("beta", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction));
  40538. var o = Qe.TransitionTo("beta", n, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, (function() {
  40539. t._clearAnimationLocks(),
  40540. t.stopAllAnimations()
  40541. }
  40542. ));
  40543. o && this._animatables.push(o)
  40544. }
  40545. }
  40546. }
  40547. ,
  40548. e.prototype._getFrustumSlope = function() {
  40549. var e = this._attachedCamera;
  40550. if (!e)
  40551. return A.Zero();
  40552. var t = e.getScene().getEngine().getAspectRatio(e)
  40553. , i = Math.tan(e.fov / 2);
  40554. return new A(i * t,i)
  40555. }
  40556. ,
  40557. e.prototype._clearAnimationLocks = function() {
  40558. this._betaIsAnimating = !1
  40559. }
  40560. ,
  40561. e.prototype._applyUserInteraction = function() {
  40562. this.isUserIsMoving && (this._lastInteractionTime = ct.Now,
  40563. this.stopAllAnimations(),
  40564. this._clearAnimationLocks())
  40565. }
  40566. ,
  40567. e.prototype.stopAllAnimations = function() {
  40568. for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
  40569. this._animatables[0] && (this._animatables[0].onAnimationEnd = null,
  40570. this._animatables[0].stop()),
  40571. this._animatables.shift()
  40572. }
  40573. ,
  40574. Object.defineProperty(e.prototype, "isUserIsMoving", {
  40575. get: function() {
  40576. return !!this._attachedCamera && (0 !== this._attachedCamera.inertialAlphaOffset || 0 !== this._attachedCamera.inertialBetaOffset || 0 !== this._attachedCamera.inertialRadiusOffset || 0 !== this._attachedCamera.inertialPanningX || 0 !== this._attachedCamera.inertialPanningY || this._isPointerDown)
  40577. },
  40578. enumerable: !1,
  40579. configurable: !0
  40580. }),
  40581. e.EasingFunction = new Fn,
  40582. e.EasingMode = Mn.EASINGMODE_EASEINOUT,
  40583. e.IgnoreBoundsSizeMode = 0,
  40584. e.FitFrustumSidesMode = 1,
  40585. e
  40586. }()
  40587. , ho = function(e, t, i, n) {
  40588. void 0 === t && (t = new x),
  40589. void 0 === i && (i = 0),
  40590. void 0 === n && (n = !1),
  40591. this.direction = e,
  40592. this.rotatedDirection = t,
  40593. this.diff = i,
  40594. this.ignore = n
  40595. }
  40596. , po = function() {
  40597. function e(e) {
  40598. this._ui = e,
  40599. this.name = "AttachToBoxBehavior",
  40600. this.distanceAwayFromFace = .15,
  40601. this.distanceAwayFromBottomOfFace = .15,
  40602. this._faceVectors = [new ho(x.Up()), new ho(x.Down()), new ho(x.Left()), new ho(x.Right()), new ho(x.Forward()), new ho(x.Forward().scaleInPlace(-1))],
  40603. this._tmpMatrix = new P,
  40604. this._tmpVector = new x,
  40605. this._zeroVector = x.Zero(),
  40606. this._lookAtTmpMatrix = new P
  40607. }
  40608. return e.prototype.init = function() {}
  40609. ,
  40610. e.prototype._closestFace = function(e) {
  40611. var t = this;
  40612. return this._faceVectors.forEach((function(i) {
  40613. t._target.rotationQuaternion || (t._target.rotationQuaternion = C.RotationYawPitchRoll(t._target.rotation.y, t._target.rotation.x, t._target.rotation.z)),
  40614. t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),
  40615. x.TransformCoordinatesToRef(i.direction, t._tmpMatrix, i.rotatedDirection),
  40616. i.diff = x.GetAngleBetweenVectors(i.rotatedDirection, e, x.Cross(i.rotatedDirection, e))
  40617. }
  40618. )),
  40619. this._faceVectors.reduce((function(e, t) {
  40620. return e.ignore ? t : t.ignore || e.diff < t.diff ? e : t
  40621. }
  40622. ), this._faceVectors[0])
  40623. }
  40624. ,
  40625. e.prototype._lookAtToRef = function(e, t, i) {
  40626. void 0 === t && (t = new x(0,1,0)),
  40627. P.LookAtLHToRef(this._zeroVector, e, t, this._lookAtTmpMatrix),
  40628. this._lookAtTmpMatrix.invert(),
  40629. C.FromRotationMatrixToRef(this._lookAtTmpMatrix, i)
  40630. }
  40631. ,
  40632. e.prototype.attach = function(e) {
  40633. var t = this;
  40634. this._target = e,
  40635. this._scene = this._target.getScene(),
  40636. this._onRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
  40637. if (t._scene.activeCamera) {
  40638. var i = t._scene.activeCamera.position;
  40639. t._scene.activeCamera.devicePosition && (i = t._scene.activeCamera.devicePosition);
  40640. var n = t._closestFace(i.subtract(e.position));
  40641. t._scene.activeCamera.leftCamera ? t._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix) : t._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix),
  40642. x.TransformCoordinatesToRef(x.Up(), t._tmpMatrix, t._tmpVector),
  40643. t._faceVectors.forEach((function(e) {
  40644. n.direction.x && e.direction.x && (e.ignore = !0),
  40645. n.direction.y && e.direction.y && (e.ignore = !0),
  40646. n.direction.z && e.direction.z && (e.ignore = !0)
  40647. }
  40648. ));
  40649. var r = t._closestFace(t._tmpVector);
  40650. t._faceVectors.forEach((function(e) {
  40651. e.ignore = !1
  40652. }
  40653. )),
  40654. t._ui.position.copyFrom(e.position),
  40655. n.direction.x && (n.rotatedDirection.scaleToRef(e.scaling.x / 2 + t.distanceAwayFromFace, t._tmpVector),
  40656. t._ui.position.addInPlace(t._tmpVector)),
  40657. n.direction.y && (n.rotatedDirection.scaleToRef(e.scaling.y / 2 + t.distanceAwayFromFace, t._tmpVector),
  40658. t._ui.position.addInPlace(t._tmpVector)),
  40659. n.direction.z && (n.rotatedDirection.scaleToRef(e.scaling.z / 2 + t.distanceAwayFromFace, t._tmpVector),
  40660. t._ui.position.addInPlace(t._tmpVector)),
  40661. t._ui.rotationQuaternion || (t._ui.rotationQuaternion = C.RotationYawPitchRoll(t._ui.rotation.y, t._ui.rotation.x, t._ui.rotation.z)),
  40662. n.rotatedDirection.scaleToRef(-1, t._tmpVector),
  40663. t._lookAtToRef(t._tmpVector, r.rotatedDirection, t._ui.rotationQuaternion),
  40664. r.direction.x && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.x / 2, t._tmpVector),
  40665. r.direction.y && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.y / 2, t._tmpVector),
  40666. r.direction.z && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.z / 2, t._tmpVector),
  40667. t._ui.position.addInPlace(t._tmpVector)
  40668. }
  40669. }
  40670. ))
  40671. }
  40672. ,
  40673. e.prototype.detach = function() {
  40674. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)
  40675. }
  40676. ,
  40677. e
  40678. }()
  40679. , fo = function() {
  40680. function e() {
  40681. var e = this;
  40682. this.delay = 0,
  40683. this.fadeInTime = 300,
  40684. this._millisecondsPerFrame = 1e3 / 60,
  40685. this._hovered = !1,
  40686. this._hoverValue = 0,
  40687. this._ownerNode = null,
  40688. this._update = function() {
  40689. if (e._ownerNode) {
  40690. if (e._hoverValue += e._hovered ? e._millisecondsPerFrame : -e._millisecondsPerFrame,
  40691. e._setAllVisibility(e._ownerNode, (e._hoverValue - e.delay) / e.fadeInTime),
  40692. e._ownerNode.visibility > 1)
  40693. return e._setAllVisibility(e._ownerNode, 1),
  40694. void (e._hoverValue = e.fadeInTime + e.delay);
  40695. if (e._ownerNode.visibility < 0 && (e._setAllVisibility(e._ownerNode, 0),
  40696. e._hoverValue < 0))
  40697. return void (e._hoverValue = 0);
  40698. setTimeout(e._update, e._millisecondsPerFrame)
  40699. }
  40700. }
  40701. }
  40702. return Object.defineProperty(e.prototype, "name", {
  40703. get: function() {
  40704. return "FadeInOut"
  40705. },
  40706. enumerable: !1,
  40707. configurable: !0
  40708. }),
  40709. e.prototype.init = function() {}
  40710. ,
  40711. e.prototype.attach = function(e) {
  40712. this._ownerNode = e,
  40713. this._setAllVisibility(this._ownerNode, 0)
  40714. }
  40715. ,
  40716. e.prototype.detach = function() {
  40717. this._ownerNode = null
  40718. }
  40719. ,
  40720. e.prototype.fadeIn = function(e) {
  40721. this._hovered = e,
  40722. this._update()
  40723. }
  40724. ,
  40725. e.prototype._setAllVisibility = function(e, t) {
  40726. var i = this;
  40727. e.visibility = t,
  40728. e.getChildMeshes().forEach((function(e) {
  40729. i._setAllVisibility(e, t)
  40730. }
  40731. ))
  40732. }
  40733. ,
  40734. e
  40735. }()
  40736. , _o = function() {
  40737. function e(e, t, i) {
  40738. void 0 === i && (i = Number.MAX_VALUE),
  40739. this.origin = e,
  40740. this.direction = t,
  40741. this.length = i
  40742. }
  40743. return e.prototype.clone = function() {
  40744. return new e(this.origin.clone(),this.direction.clone(),this.length)
  40745. }
  40746. ,
  40747. e.prototype.intersectsBoxMinMax = function(t, i, n) {
  40748. void 0 === n && (n = 0);
  40749. var r, o, a, s, l = e._TmpVector3[0].copyFromFloats(t.x - n, t.y - n, t.z - n), c = e._TmpVector3[1].copyFromFloats(i.x + n, i.y + n, i.z + n), u = 0, h = Number.MAX_VALUE;
  40750. if (Math.abs(this.direction.x) < 1e-7) {
  40751. if (this.origin.x < l.x || this.origin.x > c.x)
  40752. return !1
  40753. } else if (r = 1 / this.direction.x,
  40754. o = (l.x - this.origin.x) * r,
  40755. (a = (c.x - this.origin.x) * r) == -1 / 0 && (a = 1 / 0),
  40756. o > a && (s = o,
  40757. o = a,
  40758. a = s),
  40759. (u = Math.max(o, u)) > (h = Math.min(a, h)))
  40760. return !1;
  40761. if (Math.abs(this.direction.y) < 1e-7) {
  40762. if (this.origin.y < l.y || this.origin.y > c.y)
  40763. return !1
  40764. } else if (r = 1 / this.direction.y,
  40765. o = (l.y - this.origin.y) * r,
  40766. (a = (c.y - this.origin.y) * r) == -1 / 0 && (a = 1 / 0),
  40767. o > a && (s = o,
  40768. o = a,
  40769. a = s),
  40770. (u = Math.max(o, u)) > (h = Math.min(a, h)))
  40771. return !1;
  40772. if (Math.abs(this.direction.z) < 1e-7) {
  40773. if (this.origin.z < l.z || this.origin.z > c.z)
  40774. return !1
  40775. } else if (r = 1 / this.direction.z,
  40776. o = (l.z - this.origin.z) * r,
  40777. (a = (c.z - this.origin.z) * r) == -1 / 0 && (a = 1 / 0),
  40778. o > a && (s = o,
  40779. o = a,
  40780. a = s),
  40781. (u = Math.max(o, u)) > (h = Math.min(a, h)))
  40782. return !1;
  40783. return !0
  40784. }
  40785. ,
  40786. e.prototype.intersectsBox = function(e, t) {
  40787. return void 0 === t && (t = 0),
  40788. this.intersectsBoxMinMax(e.minimum, e.maximum, t)
  40789. }
  40790. ,
  40791. e.prototype.intersectsSphere = function(e, t) {
  40792. void 0 === t && (t = 0);
  40793. var i = e.center.x - this.origin.x
  40794. , n = e.center.y - this.origin.y
  40795. , r = e.center.z - this.origin.z
  40796. , o = i * i + n * n + r * r
  40797. , a = e.radius + t
  40798. , s = a * a;
  40799. if (o <= s)
  40800. return !0;
  40801. var l = i * this.direction.x + n * this.direction.y + r * this.direction.z;
  40802. return !(l < 0) && o - l * l <= s
  40803. }
  40804. ,
  40805. e.prototype.intersectsTriangle = function(t, i, n) {
  40806. var r = e._TmpVector3[0]
  40807. , o = e._TmpVector3[1]
  40808. , a = e._TmpVector3[2]
  40809. , s = e._TmpVector3[3]
  40810. , l = e._TmpVector3[4];
  40811. i.subtractToRef(t, r),
  40812. n.subtractToRef(t, o),
  40813. x.CrossToRef(this.direction, o, a);
  40814. var c = x.Dot(r, a);
  40815. if (0 === c)
  40816. return null;
  40817. var u = 1 / c;
  40818. this.origin.subtractToRef(t, s);
  40819. var h = x.Dot(s, a) * u;
  40820. if (h < 0 || h > 1)
  40821. return null;
  40822. x.CrossToRef(s, r, l);
  40823. var d = x.Dot(this.direction, l) * u;
  40824. if (d < 0 || h + d > 1)
  40825. return null;
  40826. var p = x.Dot(o, l) * u;
  40827. return p > this.length ? null : new er(1 - h - d,h,p)
  40828. }
  40829. ,
  40830. e.prototype.intersectsPlane = function(e) {
  40831. var t, i = x.Dot(e.normal, this.direction);
  40832. if (Math.abs(i) < 9.99999997475243e-7)
  40833. return null;
  40834. var n = x.Dot(e.normal, this.origin);
  40835. return (t = (-e.d - n) / i) < 0 ? t < -9.99999997475243e-7 ? null : 0 : t
  40836. }
  40837. ,
  40838. e.prototype.intersectsAxis = function(e, t) {
  40839. switch (void 0 === t && (t = 0),
  40840. e) {
  40841. case "y":
  40842. return (i = (this.origin.y - t) / this.direction.y) > 0 ? null : new x(this.origin.x + this.direction.x * -i,t,this.origin.z + this.direction.z * -i);
  40843. case "x":
  40844. return (i = (this.origin.x - t) / this.direction.x) > 0 ? null : new x(t,this.origin.y + this.direction.y * -i,this.origin.z + this.direction.z * -i);
  40845. case "z":
  40846. var i;
  40847. return (i = (this.origin.z - t) / this.direction.z) > 0 ? null : new x(this.origin.x + this.direction.x * -i,this.origin.y + this.direction.y * -i,t);
  40848. default:
  40849. return null
  40850. }
  40851. }
  40852. ,
  40853. e.prototype.intersectsMesh = function(t, i) {
  40854. var n = I.Matrix[0];
  40855. return t.getWorldMatrix().invertToRef(n),
  40856. this._tmpRay ? e.TransformToRef(this, n, this._tmpRay) : this._tmpRay = e.Transform(this, n),
  40857. t.intersects(this._tmpRay, i)
  40858. }
  40859. ,
  40860. e.prototype.intersectsMeshes = function(e, t, i) {
  40861. i ? i.length = 0 : i = [];
  40862. for (var n = 0; n < e.length; n++) {
  40863. var r = this.intersectsMesh(e[n], t);
  40864. r.hit && i.push(r)
  40865. }
  40866. return i.sort(this._comparePickingInfo),
  40867. i
  40868. }
  40869. ,
  40870. e.prototype._comparePickingInfo = function(e, t) {
  40871. return e.distance < t.distance ? -1 : e.distance > t.distance ? 1 : 0
  40872. }
  40873. ,
  40874. e.prototype.intersectionSegment = function(t, i, n) {
  40875. var r = this.origin
  40876. , o = I.Vector3[0]
  40877. , a = I.Vector3[1]
  40878. , s = I.Vector3[2]
  40879. , l = I.Vector3[3];
  40880. i.subtractToRef(t, o),
  40881. this.direction.scaleToRef(e._Rayl, s),
  40882. r.addToRef(s, a),
  40883. t.subtractToRef(r, l);
  40884. var c, u, h = x.Dot(o, o), d = x.Dot(o, s), p = x.Dot(s, s), f = x.Dot(o, l), _ = x.Dot(s, l), m = h * p - d * d, g = m, v = m;
  40885. m < e._Smallnum ? (c = 0,
  40886. g = 1,
  40887. u = _,
  40888. v = p) : (u = h * _ - d * f,
  40889. (c = d * _ - p * f) < 0 ? (c = 0,
  40890. u = _,
  40891. v = p) : c > g && (c = g,
  40892. u = _ + d,
  40893. v = p)),
  40894. u < 0 ? (u = 0,
  40895. -f < 0 ? c = 0 : -f > h ? c = g : (c = -f,
  40896. g = h)) : u > v && (u = v,
  40897. -f + d < 0 ? c = 0 : -f + d > h ? c = g : (c = -f + d,
  40898. g = h));
  40899. var y = Math.abs(c) < e._Smallnum ? 0 : c / g
  40900. , b = Math.abs(u) < e._Smallnum ? 0 : u / v
  40901. , T = I.Vector3[4];
  40902. s.scaleToRef(b, T);
  40903. var E = I.Vector3[5];
  40904. o.scaleToRef(y, E),
  40905. E.addInPlace(l);
  40906. var S = I.Vector3[6];
  40907. return E.subtractToRef(T, S),
  40908. b > 0 && b <= this.length && S.lengthSquared() < n * n ? E.length() : -1
  40909. }
  40910. ,
  40911. e.prototype.update = function(t, i, n, r, o, a, s, l) {
  40912. if (void 0 === l && (l = !1),
  40913. l) {
  40914. e._RayDistant || (e._RayDistant = e.Zero()),
  40915. e._RayDistant.unprojectRayToRef(t, i, n, r, P.IdentityReadOnly, a, s);
  40916. var c = I.Matrix[0];
  40917. o.invertToRef(c),
  40918. e.TransformToRef(e._RayDistant, c, this)
  40919. } else
  40920. this.unprojectRayToRef(t, i, n, r, o, a, s);
  40921. return this
  40922. }
  40923. ,
  40924. e.Zero = function() {
  40925. return new e(x.Zero(),x.Zero())
  40926. }
  40927. ,
  40928. e.CreateNew = function(t, i, n, r, o, a, s) {
  40929. return e.Zero().update(t, i, n, r, o, a, s)
  40930. }
  40931. ,
  40932. e.CreateNewFromTo = function(t, i, n) {
  40933. void 0 === n && (n = P.IdentityReadOnly);
  40934. var r = i.subtract(t)
  40935. , o = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z);
  40936. return r.normalize(),
  40937. e.Transform(new e(t,r,o), n)
  40938. }
  40939. ,
  40940. e.Transform = function(t, i) {
  40941. var n = new e(new x(0,0,0),new x(0,0,0));
  40942. return e.TransformToRef(t, i, n),
  40943. n
  40944. }
  40945. ,
  40946. e.TransformToRef = function(e, t, i) {
  40947. x.TransformCoordinatesToRef(e.origin, t, i.origin),
  40948. x.TransformNormalToRef(e.direction, t, i.direction),
  40949. i.length = e.length;
  40950. var n = i.direction
  40951. , r = n.length();
  40952. if (0 !== r && 1 !== r) {
  40953. var o = 1 / r;
  40954. n.x *= o,
  40955. n.y *= o,
  40956. n.z *= o,
  40957. i.length *= r
  40958. }
  40959. }
  40960. ,
  40961. e.prototype.unprojectRayToRef = function(e, t, i, n, r, o, a) {
  40962. var s, l = I.Matrix[0];
  40963. r.multiplyToRef(o, l),
  40964. l.multiplyToRef(a, l),
  40965. l.invert();
  40966. var c = I.Vector3[0];
  40967. c.x = e / i * 2 - 1,
  40968. c.y = -(t / n * 2 - 1),
  40969. c.z = (null === (s = E.LastCreatedEngine) || void 0 === s ? void 0 : s.isNDCHalfZRange) ? 0 : -1;
  40970. var u = I.Vector3[1].copyFromFloats(c.x, c.y, 1 - 1e-8)
  40971. , h = I.Vector3[2]
  40972. , d = I.Vector3[3];
  40973. x._UnprojectFromInvertedMatrixToRef(c, l, h),
  40974. x._UnprojectFromInvertedMatrixToRef(u, l, d),
  40975. this.origin.copyFrom(h),
  40976. d.subtractToRef(h, this.direction),
  40977. this.direction.normalize()
  40978. }
  40979. ,
  40980. e._TmpVector3 = g.BuildArray(6, x.Zero),
  40981. e._RayDistant = e.Zero(),
  40982. e._Smallnum = 1e-8,
  40983. e._Rayl = 1e9,
  40984. e
  40985. }();
  40986. mn.prototype.createPickingRay = function(e, t, i, n, r) {
  40987. void 0 === r && (r = !1);
  40988. var o = _o.Zero();
  40989. return this.createPickingRayToRef(e, t, i, o, n, r),
  40990. o
  40991. }
  40992. ,
  40993. mn.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
  40994. void 0 === o && (o = !1),
  40995. void 0 === a && (a = !1);
  40996. var s = this.getEngine();
  40997. if (!r) {
  40998. if (!this.activeCamera)
  40999. return this;
  41000. r = this.activeCamera
  41001. }
  41002. var l = r.viewport.toGlobal(s.getRenderWidth(), s.getRenderHeight());
  41003. return e = e / s.getHardwareScalingLevel() - l.x,
  41004. t = t / s.getHardwareScalingLevel() - (s.getRenderHeight() - l.y - l.height),
  41005. n.update(e, t, l.width, l.height, i || P.IdentityReadOnly, o ? P.IdentityReadOnly : r.getViewMatrix(), r.getProjectionMatrix(), a),
  41006. this
  41007. }
  41008. ,
  41009. mn.prototype.createPickingRayInCameraSpace = function(e, t, i) {
  41010. var n = _o.Zero();
  41011. return this.createPickingRayInCameraSpaceToRef(e, t, n, i),
  41012. n
  41013. }
  41014. ,
  41015. mn.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
  41016. if (!Ui)
  41017. return this;
  41018. var r = this.getEngine();
  41019. if (!n) {
  41020. if (!this.activeCamera)
  41021. throw new Error("Active camera not set");
  41022. n = this.activeCamera
  41023. }
  41024. var o = n.viewport.toGlobal(r.getRenderWidth(), r.getRenderHeight())
  41025. , a = P.Identity();
  41026. return e = e / r.getHardwareScalingLevel() - o.x,
  41027. t = t / r.getHardwareScalingLevel() - (r.getRenderHeight() - o.y - o.height),
  41028. i.update(e, t, o.width, o.height, a, a, n.getProjectionMatrix()),
  41029. this
  41030. }
  41031. ,
  41032. mn.prototype._internalPickForMesh = function(e, t, i, n, r, o, a, s) {
  41033. var l = t(n, i.enableDistantPicking)
  41034. , c = i.intersects(l, r, a, o, n, s);
  41035. return c && c.hit ? !r && null != e && c.distance >= e.distance ? null : c : null
  41036. }
  41037. ,
  41038. mn.prototype._internalPick = function(e, t, i, n, r) {
  41039. if (!Ui)
  41040. return null;
  41041. for (var o = null, a = 0; a < this.meshes.length; a++) {
  41042. var s = this.meshes[a];
  41043. if (t) {
  41044. if (!t(s))
  41045. continue
  41046. } else if (!s.isEnabled() || !s.isVisible || !s.isPickable)
  41047. continue;
  41048. var l, c = s.getWorldMatrix();
  41049. if (s.hasThinInstances && s.thinInstanceEnablePicking) {
  41050. if (l = this._internalPickForMesh(o, e, s, c, !0, !0, r)) {
  41051. if (n)
  41052. return l;
  41053. for (var u = I.Matrix[1], h = s.thinInstanceGetWorldMatrices(), d = 0; d < h.length; d++) {
  41054. h[d].multiplyToRef(c, u);
  41055. var p = this._internalPickForMesh(o, e, s, u, i, n, r, !0);
  41056. if (p && ((o = p).thinInstanceIndex = d,
  41057. i))
  41058. return o
  41059. }
  41060. }
  41061. } else if ((l = this._internalPickForMesh(o, e, s, c, i, n, r)) && (o = l,
  41062. i))
  41063. return o
  41064. }
  41065. return o || new Ui
  41066. }
  41067. ,
  41068. mn.prototype._internalMultiPick = function(e, t, i) {
  41069. if (!Ui)
  41070. return null;
  41071. for (var n = new Array, r = 0; r < this.meshes.length; r++) {
  41072. var o = this.meshes[r];
  41073. if (t) {
  41074. if (!t(o))
  41075. continue
  41076. } else if (!o.isEnabled() || !o.isVisible || !o.isPickable)
  41077. continue;
  41078. var a, s = o.getWorldMatrix();
  41079. if (o.hasThinInstances && o.thinInstanceEnablePicking) {
  41080. if (a = this._internalPickForMesh(null, e, o, s, !0, !0, i))
  41081. for (var l = I.Matrix[1], c = o.thinInstanceGetWorldMatrices(), u = 0; u < c.length; u++) {
  41082. c[u].multiplyToRef(s, l);
  41083. var h = this._internalPickForMesh(null, e, o, l, !1, !1, i, !0);
  41084. h && (h.thinInstanceIndex = u,
  41085. n.push(h))
  41086. }
  41087. } else
  41088. (a = this._internalPickForMesh(null, e, o, s, !1, !1, i)) && n.push(a)
  41089. }
  41090. return n
  41091. }
  41092. ,
  41093. mn.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
  41094. var o = this;
  41095. if (!Ui)
  41096. return null;
  41097. var a = this._internalPick((function(i) {
  41098. return o._tempPickingRay || (o._tempPickingRay = _o.Zero()),
  41099. o.createPickingRayToRef(e, t, i, o._tempPickingRay, r || null),
  41100. o._tempPickingRay
  41101. }
  41102. ), i, n, !0);
  41103. return a && (a.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
  41104. a
  41105. }
  41106. ,
  41107. mn.prototype.pick = function(e, t, i, n, r, o, a) {
  41108. var s = this;
  41109. if (void 0 === a && (a = !1),
  41110. !Ui)
  41111. return null;
  41112. var l = this._internalPick((function(i, n) {
  41113. return s._tempPickingRay || (s._tempPickingRay = _o.Zero()),
  41114. s.createPickingRayToRef(e, t, i, s._tempPickingRay, r || null, !1, n),
  41115. s._tempPickingRay
  41116. }
  41117. ), i, n, !1, o);
  41118. return l && (l.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
  41119. l
  41120. }
  41121. ,
  41122. mn.prototype.pickWithRay = function(e, t, i, n) {
  41123. var r = this
  41124. , o = this._internalPick((function(t) {
  41125. return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = P.Identity()),
  41126. t.invertToRef(r._pickWithRayInverseMatrix),
  41127. r._cachedRayForTransform || (r._cachedRayForTransform = _o.Zero()),
  41128. _o.TransformToRef(e, r._pickWithRayInverseMatrix, r._cachedRayForTransform),
  41129. r._cachedRayForTransform
  41130. }
  41131. ), t, i, !1, n);
  41132. return o && (o.ray = e),
  41133. o
  41134. }
  41135. ,
  41136. mn.prototype.multiPick = function(e, t, i, n, r) {
  41137. var o = this;
  41138. return this._internalMultiPick((function(i) {
  41139. return o.createPickingRay(e, t, i, n || null)
  41140. }
  41141. ), i, r)
  41142. }
  41143. ,
  41144. mn.prototype.multiPickWithRay = function(e, t, i) {
  41145. var n = this;
  41146. return this._internalMultiPick((function(t) {
  41147. return n._pickWithRayInverseMatrix || (n._pickWithRayInverseMatrix = P.Identity()),
  41148. t.invertToRef(n._pickWithRayInverseMatrix),
  41149. n._cachedRayForTransform || (n._cachedRayForTransform = _o.Zero()),
  41150. _o.TransformToRef(e, n._pickWithRayInverseMatrix, n._cachedRayForTransform),
  41151. n._cachedRayForTransform
  41152. }
  41153. ), t, i)
  41154. }
  41155. ,
  41156. Rr.prototype.getForwardRay = function(e, t, i) {
  41157. return void 0 === e && (e = 100),
  41158. this.getForwardRayToRef(new _o(x.Zero(),x.Zero(),e), e, t, i)
  41159. }
  41160. ,
  41161. Rr.prototype.getForwardRayToRef = function(e, t, i, n) {
  41162. return void 0 === t && (t = 100),
  41163. i || (i = this.getWorldMatrix()),
  41164. e.length = t,
  41165. n ? e.origin.copyFrom(n) : e.origin.copyFrom(this.position),
  41166. I.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  41167. x.TransformNormalToRef(I.Vector3[2], i, I.Vector3[3]),
  41168. x.NormalizeToRef(I.Vector3[3], e.direction),
  41169. e
  41170. }
  41171. ;
  41172. var mo = function() {
  41173. function e() {}
  41174. return e._RemoveAndStorePivotPoint = function(t) {
  41175. t && 0 === e._PivotCached && (t.getPivotPointToRef(e._OldPivotPoint),
  41176. e._PivotPostMultiplyPivotMatrix = t._postMultiplyPivotMatrix,
  41177. e._OldPivotPoint.equalsToFloats(0, 0, 0) || (t.setPivotMatrix(P.IdentityReadOnly),
  41178. e._OldPivotPoint.subtractToRef(t.getPivotPoint(), e._PivotTranslation),
  41179. e._PivotTmpVector.copyFromFloats(1, 1, 1),
  41180. e._PivotTmpVector.subtractInPlace(t.scaling),
  41181. e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),
  41182. t.position.addInPlace(e._PivotTmpVector))),
  41183. e._PivotCached++
  41184. }
  41185. ,
  41186. e._RestorePivotPoint = function(t) {
  41187. t && !e._OldPivotPoint.equalsToFloats(0, 0, 0) && 1 === e._PivotCached && (t.setPivotPoint(e._OldPivotPoint),
  41188. t._postMultiplyPivotMatrix = e._PivotPostMultiplyPivotMatrix,
  41189. e._PivotTmpVector.copyFromFloats(1, 1, 1),
  41190. e._PivotTmpVector.subtractInPlace(t.scaling),
  41191. e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),
  41192. t.position.subtractInPlace(e._PivotTmpVector)),
  41193. this._PivotCached--
  41194. }
  41195. ,
  41196. e._PivotCached = 0,
  41197. e._OldPivotPoint = new x,
  41198. e._PivotTranslation = new x,
  41199. e._PivotTmpVector = new x,
  41200. e._PivotPostMultiplyPivotMatrix = !1,
  41201. e
  41202. }();
  41203. function go(e) {
  41204. var t = []
  41205. , i = []
  41206. , n = []
  41207. , r = []
  41208. , o = e.width || e.size || 1
  41209. , a = e.height || e.size || 1
  41210. , s = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE
  41211. , l = o / 2
  41212. , c = a / 2;
  41213. i.push(-l, -c, 0),
  41214. n.push(0, 0, -1),
  41215. r.push(0, pr.UseOpenGLOrientationForUV ? 1 : 0),
  41216. i.push(l, -c, 0),
  41217. n.push(0, 0, -1),
  41218. r.push(1, pr.UseOpenGLOrientationForUV ? 1 : 0),
  41219. i.push(l, c, 0),
  41220. n.push(0, 0, -1),
  41221. r.push(1, pr.UseOpenGLOrientationForUV ? 0 : 1),
  41222. i.push(-l, c, 0),
  41223. n.push(0, 0, -1),
  41224. r.push(0, pr.UseOpenGLOrientationForUV ? 0 : 1),
  41225. t.push(0),
  41226. t.push(1),
  41227. t.push(2),
  41228. t.push(0),
  41229. t.push(2),
  41230. t.push(3),
  41231. $n._ComputeSides(s, i, t, n, r, e.frontUVs, e.backUVs);
  41232. var u = new $n;
  41233. return u.indices = t,
  41234. u.positions = i,
  41235. u.normals = n,
  41236. u.uvs = r,
  41237. u
  41238. }
  41239. function vo(e, t, i) {
  41240. void 0 === t && (t = {}),
  41241. void 0 === i && (i = null);
  41242. var n = new Vr(e,i);
  41243. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  41244. n._originalBuilderSideOrientation = t.sideOrientation,
  41245. go(t).applyToMesh(n, t.updatable),
  41246. t.sourcePlane && (n.translate(t.sourcePlane.normal, -t.sourcePlane.d),
  41247. n.setDirection(t.sourcePlane.normal.scale(-1))),
  41248. n
  41249. }
  41250. var yo = {
  41251. CreatePlane: vo
  41252. };
  41253. $n.CreatePlane = go,
  41254. Vr.CreatePlane = function(e, t, i, n, r) {
  41255. return vo(e, {
  41256. size: t,
  41257. width: t,
  41258. height: t,
  41259. sideOrientation: r,
  41260. updatable: n
  41261. }, i)
  41262. }
  41263. ;
  41264. var bo, To, Eo, So, Ao = function() {
  41265. function e(e) {
  41266. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1,
  41267. this.maxDragAngle = 0,
  41268. this._useAlternatePickedPointAboveMaxDragAngle = !1,
  41269. this.currentDraggingPointerId = -1,
  41270. this.dragging = !1,
  41271. this.dragDeltaRatio = .2,
  41272. this.updateDragPlane = !0,
  41273. this._debugMode = !1,
  41274. this._moving = !1,
  41275. this.onDragObservable = new h,
  41276. this.onDragStartObservable = new h,
  41277. this.onDragEndObservable = new h,
  41278. this.onEnabledObservable = new h,
  41279. this.moveAttached = !0,
  41280. this._enabled = !0,
  41281. this.startAndReleaseDragOnPointerEvents = !0,
  41282. this.detachCameraControls = !0,
  41283. this.useObjectOrientationForDragging = !0,
  41284. this.validateDrag = function(e) {
  41285. return !0
  41286. }
  41287. ,
  41288. this._tmpVector = new x(0,0,0),
  41289. this._alternatePickedPoint = new x(0,0,0),
  41290. this._worldDragAxis = new x(0,0,0),
  41291. this._targetPosition = new x(0,0,0),
  41292. this._attachedToElement = !1,
  41293. this._startDragRay = new _o(new x,new x),
  41294. this._lastPointerRay = {},
  41295. this._dragDelta = new x,
  41296. this._pointA = new x(0,0,0),
  41297. this._pointC = new x(0,0,0),
  41298. this._localAxis = new x(0,0,0),
  41299. this._lookAt = new x(0,0,0),
  41300. this._options = e || {};
  41301. var t = 0;
  41302. if (this._options.dragAxis && t++,
  41303. this._options.dragPlaneNormal && t++,
  41304. t > 1)
  41305. throw "Multiple drag modes specified in dragBehavior options. Only one expected"
  41306. }
  41307. return Object.defineProperty(e.prototype, "currentDraggingPointerID", {
  41308. get: function() {
  41309. return this.currentDraggingPointerId
  41310. },
  41311. set: function(e) {
  41312. this.currentDraggingPointerId = e
  41313. },
  41314. enumerable: !1,
  41315. configurable: !0
  41316. }),
  41317. Object.defineProperty(e.prototype, "enabled", {
  41318. get: function() {
  41319. return this._enabled
  41320. },
  41321. set: function(e) {
  41322. e != this._enabled && this.onEnabledObservable.notifyObservers(e),
  41323. this._enabled = e
  41324. },
  41325. enumerable: !1,
  41326. configurable: !0
  41327. }),
  41328. Object.defineProperty(e.prototype, "options", {
  41329. get: function() {
  41330. return this._options
  41331. },
  41332. set: function(e) {
  41333. this._options = e
  41334. },
  41335. enumerable: !1,
  41336. configurable: !0
  41337. }),
  41338. Object.defineProperty(e.prototype, "name", {
  41339. get: function() {
  41340. return "PointerDrag"
  41341. },
  41342. enumerable: !1,
  41343. configurable: !0
  41344. }),
  41345. e.prototype.init = function() {}
  41346. ,
  41347. e.prototype.attach = function(t, i) {
  41348. var n = this;
  41349. this._scene = t.getScene(),
  41350. t.isNearGrabbable = !0,
  41351. this.attachedNode = t,
  41352. e._PlaneScene || (this._debugMode ? e._PlaneScene = this._scene : (e._PlaneScene = new mn(this._scene.getEngine(),{
  41353. virtual: !0
  41354. }),
  41355. e._PlaneScene.detachControl(),
  41356. this._scene.onDisposeObservable.addOnce((function() {
  41357. e._PlaneScene.dispose(),
  41358. e._PlaneScene = null
  41359. }
  41360. )))),
  41361. this._dragPlane = vo("pointerDragPlane", {
  41362. size: this._debugMode ? 1 : 1e4,
  41363. updatable: !1,
  41364. sideOrientation: Vr.DOUBLESIDE
  41365. }, e._PlaneScene),
  41366. this.lastDragPosition = new x(0,0,0);
  41367. var r = i || function(e) {
  41368. return n.attachedNode == e || e.isDescendantOf(n.attachedNode)
  41369. }
  41370. ;
  41371. this._pointerObserver = this._scene.onPointerObservable.add((function(t) {
  41372. if (n.enabled) {
  41373. if (t.type == Xi.POINTERDOWN)
  41374. n.startAndReleaseDragOnPointerEvents && !n.dragging && t.pickInfo && t.pickInfo.hit && t.pickInfo.pickedMesh && t.pickInfo.pickedPoint && t.pickInfo.ray && r(t.pickInfo.pickedMesh) && n._startDrag(t.event.pointerId, t.pickInfo.ray, t.pickInfo.pickedPoint);
  41375. else if (t.type == Xi.POINTERUP)
  41376. n.startAndReleaseDragOnPointerEvents && n.currentDraggingPointerId == t.event.pointerId && n.releaseDrag();
  41377. else if (t.type == Xi.POINTERMOVE) {
  41378. var i = t.event.pointerId;
  41379. if (n.currentDraggingPointerId === e._AnyMouseId && i !== e._AnyMouseId) {
  41380. var o = t.event;
  41381. ("mouse" === o.pointerType || !n._scene.getEngine().hostInformation.isMobile && o instanceof MouseEvent) && (n._lastPointerRay[n.currentDraggingPointerId] && (n._lastPointerRay[i] = n._lastPointerRay[n.currentDraggingPointerId],
  41382. delete n._lastPointerRay[n.currentDraggingPointerId]),
  41383. n.currentDraggingPointerId = i)
  41384. }
  41385. n._lastPointerRay[i] || (n._lastPointerRay[i] = new _o(new x,new x)),
  41386. t.pickInfo && t.pickInfo.ray && (n._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),
  41387. n._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),
  41388. n.currentDraggingPointerId == i && n.dragging && n._moveDrag(t.pickInfo.ray))
  41389. }
  41390. } else
  41391. n._attachedToElement && n.releaseDrag()
  41392. }
  41393. )),
  41394. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
  41395. if (n._moving && n.moveAttached) {
  41396. var e = !1;
  41397. mo._RemoveAndStorePivotPoint(n.attachedNode),
  41398. n._targetPosition.subtractToRef(n.attachedNode.absolutePosition, n._tmpVector),
  41399. n._tmpVector.scaleInPlace(n.dragDeltaRatio),
  41400. n.attachedNode.getAbsolutePosition().addToRef(n._tmpVector, n._tmpVector),
  41401. n.validateDrag(n._tmpVector) && (n.attachedNode.setAbsolutePosition(n._tmpVector),
  41402. e = !0),
  41403. mo._RestorePivotPoint(n.attachedNode),
  41404. e && n.attachedNode.computeWorldMatrix()
  41405. }
  41406. }
  41407. ))
  41408. }
  41409. ,
  41410. e.prototype.releaseDrag = function() {
  41411. if (this.dragging && (this.dragging = !1,
  41412. this.onDragEndObservable.notifyObservers({
  41413. dragPlanePoint: this.lastDragPosition,
  41414. pointerId: this.currentDraggingPointerId
  41415. })),
  41416. this.currentDraggingPointerId = -1,
  41417. this._moving = !1,
  41418. this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  41419. if ("ArcRotateCamera" === this._scene.activeCamera.getClassName()) {
  41420. var e = this._scene.activeCamera;
  41421. e.attachControl(!e.inputs || e.inputs.noPreventDefault, e._useCtrlForPanning, e._panningMouseButton)
  41422. } else
  41423. this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs || this._scene.activeCamera.inputs.noPreventDefault);
  41424. this._attachedToElement = !1
  41425. }
  41426. }
  41427. ,
  41428. e.prototype.startDrag = function(t, i, n) {
  41429. void 0 === t && (t = e._AnyMouseId),
  41430. this._startDrag(t, i, n);
  41431. var r = this._lastPointerRay[t];
  41432. t === e._AnyMouseId && (r = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),
  41433. r && this._moveDrag(r)
  41434. }
  41435. ,
  41436. e.prototype._startDrag = function(e, t, i) {
  41437. if (this._scene.activeCamera && !this.dragging && this.attachedNode) {
  41438. mo._RemoveAndStorePivotPoint(this.attachedNode),
  41439. t ? (this._startDragRay.direction.copyFrom(t.direction),
  41440. this._startDragRay.origin.copyFrom(t.origin)) : (this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),
  41441. this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),
  41442. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction)),
  41443. this._updateDragPlanePosition(this._startDragRay, i || this._tmpVector);
  41444. var n = this._pickWithRayOnDragPlane(this._startDragRay);
  41445. n && (this.dragging = !0,
  41446. this.currentDraggingPointerId = e,
  41447. this.lastDragPosition.copyFrom(n),
  41448. this.onDragStartObservable.notifyObservers({
  41449. dragPlanePoint: n,
  41450. pointerId: this.currentDraggingPointerId
  41451. }),
  41452. this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),
  41453. this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera && (this._scene.activeCamera.inputs.attachedToElement ? (this._scene.activeCamera.detachControl(),
  41454. this._attachedToElement = !0) : this._attachedToElement = !1)),
  41455. mo._RestorePivotPoint(this.attachedNode)
  41456. }
  41457. }
  41458. ,
  41459. e.prototype._moveDrag = function(e) {
  41460. this._moving = !0;
  41461. var t = this._pickWithRayOnDragPlane(e);
  41462. if (t) {
  41463. mo._RemoveAndStorePivotPoint(this.attachedNode),
  41464. this.updateDragPlane && this._updateDragPlanePosition(e, t);
  41465. var i = 0;
  41466. this._options.dragAxis ? (this.useObjectOrientationForDragging ? x.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis),
  41467. t.subtractToRef(this.lastDragPosition, this._tmpVector),
  41468. i = x.Dot(this._tmpVector, this._worldDragAxis),
  41469. this._worldDragAxis.scaleToRef(i, this._dragDelta)) : (i = this._dragDelta.length(),
  41470. t.subtractToRef(this.lastDragPosition, this._dragDelta)),
  41471. this._targetPosition.addInPlace(this._dragDelta),
  41472. this.onDragObservable.notifyObservers({
  41473. dragDistance: i,
  41474. delta: this._dragDelta,
  41475. dragPlanePoint: t,
  41476. dragPlaneNormal: this._dragPlane.forward,
  41477. pointerId: this.currentDraggingPointerId
  41478. }),
  41479. this.lastDragPosition.copyFrom(t),
  41480. mo._RestorePivotPoint(this.attachedNode)
  41481. }
  41482. }
  41483. ,
  41484. e.prototype._pickWithRayOnDragPlane = function(t) {
  41485. var i = this;
  41486. if (!t)
  41487. return null;
  41488. var n = Math.acos(x.Dot(this._dragPlane.forward, t.direction));
  41489. if (n > Math.PI / 2 && (n = Math.PI - n),
  41490. this.maxDragAngle > 0 && n > this.maxDragAngle) {
  41491. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  41492. this._tmpVector.copyFrom(t.direction),
  41493. this.attachedNode.absolutePosition.subtractToRef(t.origin, this._alternatePickedPoint),
  41494. this._alternatePickedPoint.normalize(),
  41495. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * x.Dot(this._alternatePickedPoint, this._tmpVector)),
  41496. this._tmpVector.addInPlace(this._alternatePickedPoint);
  41497. var r = x.Dot(this._dragPlane.forward, this._tmpVector);
  41498. return this._dragPlane.forward.scaleToRef(-r, this._alternatePickedPoint),
  41499. this._alternatePickedPoint.addInPlace(this._tmpVector),
  41500. this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),
  41501. this._alternatePickedPoint
  41502. }
  41503. return null
  41504. }
  41505. var o = e._PlaneScene.pickWithRay(t, (function(e) {
  41506. return e == i._dragPlane
  41507. }
  41508. ));
  41509. return o && o.hit && o.pickedMesh && o.pickedPoint ? o.pickedPoint : null
  41510. }
  41511. ,
  41512. e.prototype._updateDragPlanePosition = function(e, t) {
  41513. this._pointA.copyFrom(t),
  41514. this._options.dragAxis ? (this.useObjectOrientationForDragging ? x.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis),
  41515. e.origin.subtractToRef(this._pointA, this._pointC),
  41516. this._pointC.normalize(),
  41517. Math.abs(x.Dot(this._localAxis, this._pointC)) > .999 ? Math.abs(x.Dot(x.UpReadOnly, this._pointC)) > .999 ? this._lookAt.copyFrom(x.Right()) : this._lookAt.copyFrom(x.UpReadOnly) : (x.CrossToRef(this._localAxis, this._pointC, this._lookAt),
  41518. x.CrossToRef(this._localAxis, this._lookAt, this._lookAt),
  41519. this._lookAt.normalize()),
  41520. this._dragPlane.position.copyFrom(this._pointA),
  41521. this._pointA.addToRef(this._lookAt, this._lookAt),
  41522. this._dragPlane.lookAt(this._lookAt)) : this._options.dragPlaneNormal ? (this.useObjectOrientationForDragging ? x.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal),
  41523. this._dragPlane.position.copyFrom(this._pointA),
  41524. this._pointA.addToRef(this._localAxis, this._lookAt),
  41525. this._dragPlane.lookAt(this._lookAt)) : (this._dragPlane.position.copyFrom(this._pointA),
  41526. this._dragPlane.lookAt(e.origin)),
  41527. this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),
  41528. this._dragPlane.computeWorldMatrix(!0)
  41529. }
  41530. ,
  41531. e.prototype.detach = function() {
  41532. this.attachedNode && (this.attachedNode.isNearGrabbable = !1),
  41533. this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver),
  41534. this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),
  41535. this._dragPlane && this._dragPlane.dispose(),
  41536. this.releaseDrag()
  41537. }
  41538. ,
  41539. e._AnyMouseId = -2,
  41540. e
  41541. }(), xo = function() {
  41542. function e() {
  41543. this._startDistance = 0,
  41544. this._initialScale = new x(0,0,0),
  41545. this._targetScale = new x(0,0,0),
  41546. this._sceneRenderObserver = null,
  41547. this._dragBehaviorA = new Ao({}),
  41548. this._dragBehaviorA.moveAttached = !1,
  41549. this._dragBehaviorB = new Ao({}),
  41550. this._dragBehaviorB.moveAttached = !1
  41551. }
  41552. return Object.defineProperty(e.prototype, "name", {
  41553. get: function() {
  41554. return "MultiPointerScale"
  41555. },
  41556. enumerable: !1,
  41557. configurable: !0
  41558. }),
  41559. e.prototype.init = function() {}
  41560. ,
  41561. e.prototype._getCurrentDistance = function() {
  41562. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()
  41563. }
  41564. ,
  41565. e.prototype.attach = function(e) {
  41566. var t = this;
  41567. this._ownerNode = e,
  41568. this._dragBehaviorA.onDragStartObservable.add((function() {
  41569. t._dragBehaviorA.dragging && t._dragBehaviorB.dragging && (t._dragBehaviorA.currentDraggingPointerId == t._dragBehaviorB.currentDraggingPointerId ? t._dragBehaviorA.releaseDrag() : (t._initialScale.copyFrom(e.scaling),
  41570. t._startDistance = t._getCurrentDistance()))
  41571. }
  41572. )),
  41573. this._dragBehaviorB.onDragStartObservable.add((function() {
  41574. t._dragBehaviorA.dragging && t._dragBehaviorB.dragging && (t._dragBehaviorA.currentDraggingPointerId == t._dragBehaviorB.currentDraggingPointerId ? t._dragBehaviorB.releaseDrag() : (t._initialScale.copyFrom(e.scaling),
  41575. t._startDistance = t._getCurrentDistance()))
  41576. }
  41577. )),
  41578. [this._dragBehaviorA, this._dragBehaviorB].forEach((function(e) {
  41579. e.onDragObservable.add((function() {
  41580. if (t._dragBehaviorA.dragging && t._dragBehaviorB.dragging) {
  41581. var e = t._getCurrentDistance() / t._startDistance;
  41582. t._initialScale.scaleToRef(e, t._targetScale)
  41583. }
  41584. }
  41585. ))
  41586. }
  41587. )),
  41588. e.addBehavior(this._dragBehaviorA),
  41589. e.addBehavior(this._dragBehaviorB),
  41590. this._sceneRenderObserver = e.getScene().onBeforeRenderObservable.add((function() {
  41591. if (t._dragBehaviorA.dragging && t._dragBehaviorB.dragging) {
  41592. var i = t._targetScale.subtract(e.scaling).scaleInPlace(.1);
  41593. i.length() > .01 && e.scaling.addInPlace(i)
  41594. }
  41595. }
  41596. ))
  41597. }
  41598. ,
  41599. e.prototype.detach = function() {
  41600. var e = this;
  41601. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),
  41602. [this._dragBehaviorA, this._dragBehaviorB].forEach((function(t) {
  41603. t.onDragStartObservable.clear(),
  41604. t.onDragObservable.clear(),
  41605. e._ownerNode.removeBehavior(t)
  41606. }
  41607. ))
  41608. }
  41609. ,
  41610. e
  41611. }(), Ro = function() {
  41612. function e() {
  41613. this._attachedToElement = !1,
  41614. this._virtualMeshesInfo = {},
  41615. this._tmpVector = new x,
  41616. this._tmpQuaternion = new C,
  41617. this._dragType = {
  41618. NONE: 0,
  41619. DRAG: 1,
  41620. DRAG_WITH_CONTROLLER: 2,
  41621. NEAR_DRAG: 3
  41622. },
  41623. this._moving = !1,
  41624. this._dragging = this._dragType.NONE,
  41625. this.draggableMeshes = null,
  41626. this.zDragFactor = 3,
  41627. this.currentDraggingPointerIds = [],
  41628. this.detachCameraControls = !0,
  41629. this.onDragStartObservable = new h,
  41630. this.onDragObservable = new h,
  41631. this.onDragEndObservable = new h,
  41632. this.allowMultiPointer = !0
  41633. }
  41634. return Object.defineProperty(e.prototype, "currentDraggingPointerId", {
  41635. get: function() {
  41636. return void 0 !== this.currentDraggingPointerIds[0] ? this.currentDraggingPointerIds[0] : -1
  41637. },
  41638. set: function(e) {
  41639. this.currentDraggingPointerIds[0] = e
  41640. },
  41641. enumerable: !1,
  41642. configurable: !0
  41643. }),
  41644. Object.defineProperty(e.prototype, "currentDraggingPointerID", {
  41645. get: function() {
  41646. return this.currentDraggingPointerId
  41647. },
  41648. set: function(e) {
  41649. this.currentDraggingPointerId = e
  41650. },
  41651. enumerable: !1,
  41652. configurable: !0
  41653. }),
  41654. Object.defineProperty(e.prototype, "name", {
  41655. get: function() {
  41656. return "BaseSixDofDrag"
  41657. },
  41658. enumerable: !1,
  41659. configurable: !0
  41660. }),
  41661. Object.defineProperty(e.prototype, "isMoving", {
  41662. get: function() {
  41663. return this._moving
  41664. },
  41665. enumerable: !1,
  41666. configurable: !0
  41667. }),
  41668. e.prototype.init = function() {}
  41669. ,
  41670. Object.defineProperty(e.prototype, "_pointerCamera", {
  41671. get: function() {
  41672. return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera
  41673. },
  41674. enumerable: !1,
  41675. configurable: !0
  41676. }),
  41677. e.prototype._createVirtualMeshInfo = function() {
  41678. var t = new Sr("",e._virtualScene);
  41679. t.rotationQuaternion = new C;
  41680. var i = new Sr("",e._virtualScene);
  41681. i.rotationQuaternion = new C;
  41682. var n = new Sr("",e._virtualScene);
  41683. return n.rotationQuaternion = new C,
  41684. {
  41685. dragging: !1,
  41686. moving: !1,
  41687. dragMesh: t,
  41688. originMesh: i,
  41689. pivotMesh: n,
  41690. startingPivotPosition: new x,
  41691. startingPivotOrientation: new C,
  41692. startingPosition: new x,
  41693. startingOrientation: new C,
  41694. lastOriginPosition: new x,
  41695. lastDragPosition: new x
  41696. }
  41697. }
  41698. ,
  41699. e.prototype._resetVirtualMeshesPosition = function() {
  41700. for (var e = 0; e < this.currentDraggingPointerIds.length; e++)
  41701. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()),
  41702. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
  41703. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position),
  41704. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion),
  41705. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.position),
  41706. this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.rotationQuaternion)
  41707. }
  41708. ,
  41709. e.prototype._pointerUpdate2D = function(e, t, i) {
  41710. !this._pointerCamera || this._pointerCamera.cameraRigMode != Rr.RIG_MODE_NONE || this._pointerCamera._isLeftCamera || this._pointerCamera._isRightCamera || (e.origin.copyFrom(this._pointerCamera.globalPosition),
  41711. i = 0);
  41712. var n = this._virtualMeshesInfo[t]
  41713. , r = I.Vector3[0];
  41714. e.origin.subtractToRef(n.lastOriginPosition, r),
  41715. n.lastOriginPosition.copyFrom(e.origin);
  41716. var o = -x.Dot(r, e.direction);
  41717. n.originMesh.addChild(n.dragMesh),
  41718. n.originMesh.addChild(n.pivotMesh),
  41719. this._applyZOffset(n.dragMesh, o, i),
  41720. this._applyZOffset(n.pivotMesh, o, i),
  41721. n.originMesh.position.copyFrom(e.origin);
  41722. var a = I.Vector3[0];
  41723. e.origin.addToRef(e.direction, a),
  41724. n.originMesh.lookAt(a),
  41725. n.originMesh.removeChild(n.dragMesh),
  41726. n.originMesh.removeChild(n.pivotMesh)
  41727. }
  41728. ,
  41729. e.prototype._pointerUpdateXR = function(e, t, i, n) {
  41730. var r = this._virtualMeshesInfo[i];
  41731. if (r.originMesh.position.copyFrom(e.position),
  41732. this._dragging === this._dragType.NEAR_DRAG && t ? r.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion) : r.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion),
  41733. r.pivotMesh.computeWorldMatrix(!0),
  41734. r.dragMesh.computeWorldMatrix(!0),
  41735. 0 !== n) {
  41736. var o = I.Vector3[0]
  41737. , a = I.Vector3[1];
  41738. o.copyFrom(this._pointerCamera.getForwardRay().direction),
  41739. r.originMesh.position.subtractToRef(r.lastOriginPosition, a),
  41740. r.lastOriginPosition.copyFrom(r.originMesh.position);
  41741. var s = a.length();
  41742. a.normalize();
  41743. var l = I.Vector3[2]
  41744. , c = I.Vector3[3];
  41745. r.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, l),
  41746. r.dragMesh.absolutePosition.subtractToRef(r.originMesh.position, c);
  41747. var u = c.length();
  41748. l.normalize(),
  41749. c.normalize();
  41750. var h = Math.abs(x.Dot(a, c)) * x.Dot(a, o) * n * s * u;
  41751. h < 0 && .01 - u > h && (h = Math.min(.01 - u, 0)),
  41752. c.scaleInPlace(h),
  41753. c.addToRef(r.pivotMesh.absolutePosition, this._tmpVector),
  41754. r.pivotMesh.setAbsolutePosition(this._tmpVector),
  41755. c.addToRef(r.dragMesh.absolutePosition, this._tmpVector),
  41756. r.dragMesh.setAbsolutePosition(this._tmpVector)
  41757. }
  41758. }
  41759. ,
  41760. e.prototype.attach = function(t) {
  41761. var i = this;
  41762. this._ownerNode = t,
  41763. this._scene = this._ownerNode.getScene(),
  41764. e._virtualScene || (e._virtualScene = new mn(this._scene.getEngine(),{
  41765. virtual: !0
  41766. }),
  41767. e._virtualScene.detachControl()),
  41768. this._pointerObserver = this._scene.onPointerObservable.add((function(e) {
  41769. var t = e.event.pointerId;
  41770. i._virtualMeshesInfo[t] || (i._virtualMeshesInfo[t] = i._createVirtualMeshInfo());
  41771. var n, r = i._virtualMeshesInfo[t], o = "xr" === e.event.pointerType;
  41772. if (e.type == Xi.POINTERDOWN) {
  41773. if (!r.dragging && e.pickInfo && e.pickInfo.hit && e.pickInfo.pickedMesh && e.pickInfo.pickedPoint && e.pickInfo.ray && (!o || e.pickInfo.aimTransform) && (n = e.pickInfo.pickedMesh,
  41774. i._ownerNode === n || n.isDescendantOf(i._ownerNode) && (!i.draggableMeshes || -1 !== i.draggableMeshes.indexOf(n)))) {
  41775. if (!i.allowMultiPointer && i.currentDraggingPointerIds.length > 0)
  41776. return;
  41777. !i._pointerCamera || i._pointerCamera.cameraRigMode !== Rr.RIG_MODE_NONE || i._pointerCamera._isLeftCamera || i._pointerCamera._isRightCamera || e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),
  41778. i._ownerNode.computeWorldMatrix(!0);
  41779. var a = i._virtualMeshesInfo[t];
  41780. o ? (i._dragging = e.pickInfo.originMesh ? i._dragType.NEAR_DRAG : i._dragType.DRAG_WITH_CONTROLLER,
  41781. a.originMesh.position.copyFrom(e.pickInfo.aimTransform.position),
  41782. i._dragging === i._dragType.NEAR_DRAG && e.pickInfo.gripTransform ? a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.gripTransform.rotationQuaternion) : a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.aimTransform.rotationQuaternion)) : (i._dragging = i._dragType.DRAG,
  41783. a.originMesh.position.copyFrom(e.pickInfo.ray.origin)),
  41784. a.lastOriginPosition.copyFrom(a.originMesh.position),
  41785. a.dragMesh.position.copyFrom(e.pickInfo.pickedPoint),
  41786. a.lastDragPosition.copyFrom(e.pickInfo.pickedPoint),
  41787. a.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),
  41788. a.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),
  41789. a.startingPosition.copyFrom(a.dragMesh.position),
  41790. a.startingPivotPosition.copyFrom(a.pivotMesh.position),
  41791. a.startingOrientation.copyFrom(a.dragMesh.rotationQuaternion),
  41792. a.startingPivotOrientation.copyFrom(a.pivotMesh.rotationQuaternion),
  41793. o ? (a.originMesh.addChild(a.dragMesh),
  41794. a.originMesh.addChild(a.pivotMesh)) : a.originMesh.lookAt(a.dragMesh.position),
  41795. a.dragging = !0,
  41796. -1 === i.currentDraggingPointerIds.indexOf(t) && i.currentDraggingPointerIds.push(t),
  41797. i.detachCameraControls && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.inputs && i._pointerCamera.inputs.attachedToElement ? (i._pointerCamera.detachControl(),
  41798. i._attachedToElement = !0) : i._attachedToElement = !1),
  41799. i._targetDragStart(a.pivotMesh.position, a.pivotMesh.rotationQuaternion, t),
  41800. i.onDragStartObservable.notifyObservers({
  41801. position: a.pivotMesh.position
  41802. })
  41803. }
  41804. } else if (e.type == Xi.POINTERUP || e.type == Xi.POINTERDOUBLETAP) {
  41805. var s = i.currentDraggingPointerIds.indexOf(t);
  41806. r.dragging = !1,
  41807. -1 !== s && (i.currentDraggingPointerIds.splice(s, 1),
  41808. 0 === i.currentDraggingPointerIds.length && (i._moving = !1,
  41809. i._dragging = i._dragType.NONE,
  41810. i.detachCameraControls && i._attachedToElement && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.attachControl(!0),
  41811. i._attachedToElement = !1)),
  41812. r.originMesh.removeChild(r.dragMesh),
  41813. r.originMesh.removeChild(r.pivotMesh),
  41814. i._targetDragEnd(t),
  41815. i.onDragEndObservable.notifyObservers({}))
  41816. } else if (e.type == Xi.POINTERMOVE && -1 !== (s = i.currentDraggingPointerIds.indexOf(t)) && r.dragging && e.pickInfo && (e.pickInfo.ray || e.pickInfo.aimTransform)) {
  41817. var l = i.zDragFactor;
  41818. (i.currentDraggingPointerIds.length > 1 || e.pickInfo.originMesh) && (l = 0),
  41819. i._ownerNode.computeWorldMatrix(!0),
  41820. o ? i._pointerUpdateXR(e.pickInfo.aimTransform, e.pickInfo.gripTransform, t, l) : i._pointerUpdate2D(e.pickInfo.ray, t, l),
  41821. i._tmpQuaternion.copyFrom(r.startingPivotOrientation),
  41822. i._tmpQuaternion.x = -i._tmpQuaternion.x,
  41823. i._tmpQuaternion.y = -i._tmpQuaternion.y,
  41824. i._tmpQuaternion.z = -i._tmpQuaternion.z,
  41825. r.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion, i._tmpQuaternion),
  41826. r.pivotMesh.absolutePosition.subtractToRef(r.startingPivotPosition, i._tmpVector),
  41827. i.onDragObservable.notifyObservers({
  41828. delta: i._tmpVector,
  41829. position: r.pivotMesh.position,
  41830. pickInfo: e.pickInfo
  41831. }),
  41832. i._targetDrag(i._tmpVector, i._tmpQuaternion, t),
  41833. r.lastDragPosition.copyFrom(r.dragMesh.absolutePosition),
  41834. i._moving = !0
  41835. }
  41836. }
  41837. ))
  41838. }
  41839. ,
  41840. e.prototype._applyZOffset = function(e, t, i) {
  41841. e.position.z -= e.position.z < 1 ? t * i : t * i * e.position.z,
  41842. e.position.z < 0 && (e.position.z = 0)
  41843. }
  41844. ,
  41845. e.prototype._targetDragStart = function(e, t, i) {}
  41846. ,
  41847. e.prototype._targetDrag = function(e, t, i) {}
  41848. ,
  41849. e.prototype._targetDragEnd = function(e) {}
  41850. ,
  41851. e.prototype.detach = function() {
  41852. for (var e in this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0),
  41853. this._attachedToElement = !1),
  41854. this._scene.onPointerObservable.remove(this._pointerObserver)),
  41855. this._virtualMeshesInfo)
  41856. this._virtualMeshesInfo[e].originMesh.dispose(),
  41857. this._virtualMeshesInfo[e].dragMesh.dispose();
  41858. this.onDragEndObservable.clear(),
  41859. this.onDragObservable.clear(),
  41860. this.onDragStartObservable.clear()
  41861. }
  41862. ,
  41863. e
  41864. }(), Co = function(e) {
  41865. function t() {
  41866. var t = null !== e && e.apply(this, arguments) || this;
  41867. return t._sceneRenderObserver = null,
  41868. t._targetPosition = new x(0,0,0),
  41869. t._targetOrientation = new C,
  41870. t._targetScaling = new x(1,1,1),
  41871. t._startingPosition = new x(0,0,0),
  41872. t._startingOrientation = new C,
  41873. t._startingScaling = new x(1,1,1),
  41874. t.onPositionChangedObservable = new h,
  41875. t.dragDeltaRatio = .2,
  41876. t.rotateDraggedObject = !0,
  41877. t.rotateAroundYOnly = !1,
  41878. t.rotateWithMotionController = !0,
  41879. t.disableMovement = !1,
  41880. t.faceCameraOnDragStart = !1,
  41881. t
  41882. }
  41883. return U(t, e),
  41884. Object.defineProperty(t.prototype, "name", {
  41885. get: function() {
  41886. return "SixDofDrag"
  41887. },
  41888. enumerable: !1,
  41889. configurable: !0
  41890. }),
  41891. t.prototype.attach = function(t) {
  41892. var i = this;
  41893. e.prototype.attach.call(this, t),
  41894. t.isNearGrabbable = !0,
  41895. this._virtualTransformNode = new yr("virtual_sixDof",Ro._virtualScene),
  41896. this._virtualTransformNode.rotationQuaternion = C.Identity(),
  41897. this._sceneRenderObserver = t.getScene().onBeforeRenderObservable.add((function() {
  41898. if (1 === i.currentDraggingPointerIds.length && i._moving && !i.disableMovement) {
  41899. var e = t.parent;
  41900. t.setParent(null),
  41901. t.position.addInPlace(i._targetPosition.subtract(t.position).scale(i.dragDeltaRatio)),
  41902. i.onPositionChangedObservable.notifyObservers({
  41903. position: t.absolutePosition
  41904. }),
  41905. (!e || e.scaling && !e.scaling.isNonUniformWithinEpsilon(.001)) && C.SlerpToRef(t.rotationQuaternion, i._targetOrientation, i.dragDeltaRatio, t.rotationQuaternion),
  41906. t.setParent(e)
  41907. }
  41908. }
  41909. ))
  41910. }
  41911. ,
  41912. t.prototype._getPositionOffsetAround = function(e, t, i) {
  41913. var n = I.Matrix[0]
  41914. , r = I.Matrix[1]
  41915. , o = I.Matrix[2]
  41916. , a = I.Matrix[3]
  41917. , s = I.Matrix[4];
  41918. return P.TranslationToRef(e.x, e.y, e.z, n),
  41919. P.TranslationToRef(-e.x, -e.y, -e.z, r),
  41920. P.FromQuaternionToRef(i, o),
  41921. P.ScalingToRef(t, t, t, a),
  41922. r.multiplyToRef(o, s),
  41923. s.multiplyToRef(a, s),
  41924. s.multiplyToRef(n, s),
  41925. s.getTranslation()
  41926. }
  41927. ,
  41928. t.prototype._onePointerPositionUpdated = function(e, t) {
  41929. I.Vector3[0].setAll(0),
  41930. this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? C.RotationYawPitchRollToRef(t.toEulerAngles().y, 0, 0, I.Quaternion[0]) : I.Quaternion[0].copyFrom(t),
  41931. I.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation)) : (this._dragging === this._dragType.NEAR_DRAG || this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController) && t.multiplyToRef(this._startingOrientation, this._targetOrientation),
  41932. this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)
  41933. }
  41934. ,
  41935. t.prototype._twoPointersPositionUpdated = function() {
  41936. var e = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition
  41937. , t = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition
  41938. , i = I.Vector3[0];
  41939. e.addToRef(t, i),
  41940. i.scaleInPlace(.5);
  41941. var n = I.Vector3[1];
  41942. t.subtractToRef(e, n);
  41943. var r = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition
  41944. , o = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition
  41945. , a = I.Vector3[2];
  41946. r.addToRef(o, a),
  41947. a.scaleInPlace(.5);
  41948. var s = I.Vector3[3];
  41949. o.subtractToRef(r, s);
  41950. var l = s.length() / n.length()
  41951. , c = a.subtract(i)
  41952. , u = C.FromEulerAngles(0, x.GetAngleBetweenVectorsOnPlane(n.normalize(), s.normalize(), x.UpReadOnly), 0)
  41953. , h = this._ownerNode.parent;
  41954. this._ownerNode.setParent(null);
  41955. var d = this._getPositionOffsetAround(i.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), l, u);
  41956. this._virtualTransformNode.rotationQuaternion.multiplyToRef(u, this._ownerNode.rotationQuaternion),
  41957. this._virtualTransformNode.scaling.scaleToRef(l, this._ownerNode.scaling),
  41958. this._virtualTransformNode.position.addToRef(c.addInPlace(d), this._ownerNode.position),
  41959. this.onPositionChangedObservable.notifyObservers({
  41960. position: this._ownerNode.position
  41961. }),
  41962. this._ownerNode.setParent(h)
  41963. }
  41964. ,
  41965. t.prototype._targetDragStart = function() {
  41966. var e = this.currentDraggingPointerIds.length
  41967. , t = this._ownerNode.parent;
  41968. this._ownerNode.rotationQuaternion || (this._ownerNode.rotationQuaternion = C.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z));
  41969. var i = this._ownerNode.getAbsolutePivotPoint();
  41970. if (this._ownerNode.setParent(null),
  41971. 1 === e) {
  41972. if (this._targetPosition.copyFrom(this._ownerNode.position),
  41973. this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),
  41974. this._targetScaling.copyFrom(this._ownerNode.scaling),
  41975. this.faceCameraOnDragStart && this._scene.activeCamera) {
  41976. var n = I.Vector3[0];
  41977. this._scene.activeCamera.position.subtractToRef(i, n),
  41978. n.normalize();
  41979. var r = I.Quaternion[0];
  41980. this._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(n, new x(0,1,0), r) : C.FromLookDirectionLHToRef(n, new x(0,1,0), r),
  41981. r.normalize(),
  41982. C.RotationYawPitchRollToRef(r.toEulerAngles().y, 0, 0, I.Quaternion[0]),
  41983. this._targetOrientation.copyFrom(I.Quaternion[0])
  41984. }
  41985. this._startingPosition.copyFrom(this._targetPosition),
  41986. this._startingOrientation.copyFrom(this._targetOrientation),
  41987. this._startingScaling.copyFrom(this._targetScaling)
  41988. } else
  41989. 2 === e && (this._virtualTransformNode.setPivotPoint(new x(0,0,0), Ji.LOCAL),
  41990. this._virtualTransformNode.position.copyFrom(this._ownerNode.position),
  41991. this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),
  41992. this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
  41993. this._virtualTransformNode.setPivotPoint(i, Ji.WORLD),
  41994. this._resetVirtualMeshesPosition());
  41995. this._ownerNode.setParent(t)
  41996. }
  41997. ,
  41998. t.prototype._targetDrag = function(e, t) {
  41999. 1 === this.currentDraggingPointerIds.length ? this._onePointerPositionUpdated(e, t) : 2 === this.currentDraggingPointerIds.length && this._twoPointersPositionUpdated()
  42000. }
  42001. ,
  42002. t.prototype._targetDragEnd = function() {
  42003. if (1 === this.currentDraggingPointerIds.length) {
  42004. this._resetVirtualMeshesPosition();
  42005. var e = this.faceCameraOnDragStart;
  42006. this.faceCameraOnDragStart = !1,
  42007. this._targetDragStart(),
  42008. this.faceCameraOnDragStart = e
  42009. }
  42010. }
  42011. ,
  42012. t.prototype.detach = function() {
  42013. e.prototype.detach.call(this),
  42014. this._ownerNode && (this._ownerNode.isNearGrabbable = !1,
  42015. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),
  42016. this._virtualTransformNode && this._virtualTransformNode.dispose()
  42017. }
  42018. ,
  42019. t
  42020. }(Ro), Po = function() {
  42021. function e() {
  42022. this._attachPointLocalOffset = new x,
  42023. this._workingPosition = new x,
  42024. this._workingQuaternion = new C,
  42025. this._lastTick = -1,
  42026. this._hit = !1,
  42027. this.hitNormalOffset = .05,
  42028. this.meshes = [],
  42029. this.interpolatePose = !0,
  42030. this.lerpTime = 250,
  42031. this.keepOrientationVertical = !0,
  42032. this.enabled = !0,
  42033. this.maxStickingDistance = .8
  42034. }
  42035. return Object.defineProperty(e.prototype, "name", {
  42036. get: function() {
  42037. return "SurfaceMagnetism"
  42038. },
  42039. enumerable: !1,
  42040. configurable: !0
  42041. }),
  42042. e.prototype.init = function() {}
  42043. ,
  42044. e.prototype.attach = function(e, t) {
  42045. this._attachedMesh = e,
  42046. this._scene = t || e.getScene(),
  42047. this._attachedMesh.rotationQuaternion || (this._attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(this._attachedMesh.rotation.y, this._attachedMesh.rotation.x, this._attachedMesh.rotation.z)),
  42048. this.updateAttachPoint(),
  42049. this._workingPosition.copyFrom(this._attachedMesh.position),
  42050. this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),
  42051. this._addObservables()
  42052. }
  42053. ,
  42054. e.prototype.detach = function() {
  42055. this._attachedMesh = null,
  42056. this._removeObservables()
  42057. }
  42058. ,
  42059. e.prototype._getTargetPose = function(e) {
  42060. if (!this._attachedMesh)
  42061. return null;
  42062. if (e && e.hit) {
  42063. var t = e.getNormal(!0, !0)
  42064. , i = e.pickedPoint;
  42065. if (!t || !i)
  42066. return null;
  42067. t.normalize();
  42068. var n = I.Vector3[0];
  42069. return n.copyFrom(t),
  42070. n.scaleInPlace(this.hitNormalOffset),
  42071. n.addInPlace(i),
  42072. this._attachedMesh.parent && (I.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),
  42073. x.TransformNormalToRef(n, I.Matrix[0], n)),
  42074. {
  42075. position: n,
  42076. quaternion: C.RotationYawPitchRoll(-Math.atan2(t.x, -t.z), this.keepOrientationVertical ? 0 : Math.atan2(t.y, Math.sqrt(t.z * t.z + t.x * t.x)), 0)
  42077. }
  42078. }
  42079. return null
  42080. }
  42081. ,
  42082. e.prototype.updateAttachPoint = function() {
  42083. this._getAttachPointOffsetToRef(this._attachPointLocalOffset)
  42084. }
  42085. ,
  42086. e.prototype.findAndUpdateTarget = function(e) {
  42087. if (this._hit = !1,
  42088. !e.ray)
  42089. return !1;
  42090. var t = e.ray.intersectsMeshes(this.meshes)[0];
  42091. if (this._attachedMesh && t && t.hit && t.pickedMesh) {
  42092. var i = this._getTargetPose(t);
  42093. i && x.Distance(this._attachedMesh.position, i.position) < this.maxStickingDistance && (this._workingPosition.copyFrom(i.position),
  42094. this._workingQuaternion.copyFrom(i.quaternion),
  42095. this._hit = !0)
  42096. }
  42097. return this._hit
  42098. }
  42099. ,
  42100. e.prototype._getAttachPointOffsetToRef = function(e) {
  42101. if (this._attachedMesh) {
  42102. var t = I.Quaternion[0];
  42103. t.copyFrom(this._attachedMesh.rotationQuaternion),
  42104. this._attachedMesh.rotationQuaternion.copyFromFloats(0, 0, 0, 1),
  42105. this._attachedMesh.computeWorldMatrix();
  42106. var i = this._attachedMesh.getHierarchyBoundingVectors()
  42107. , n = I.Vector3[0];
  42108. i.max.addToRef(i.min, n),
  42109. n.scaleInPlace(.5),
  42110. n.z = i.max.z;
  42111. var r = I.Matrix[0];
  42112. this._attachedMesh.getWorldMatrix().invertToRef(r),
  42113. x.TransformCoordinatesToRef(n, r, e),
  42114. this._attachedMesh.rotationQuaternion.copyFrom(t)
  42115. } else
  42116. e.setAll(0)
  42117. }
  42118. ,
  42119. e.prototype._updateTransformToGoal = function(e) {
  42120. if (this._attachedMesh && this._hit) {
  42121. var t = this._attachedMesh.parent;
  42122. this._attachedMesh.setParent(null);
  42123. var i = I.Vector3[0];
  42124. if (x.TransformNormalToRef(this._attachPointLocalOffset, this._attachedMesh.getWorldMatrix(), i),
  42125. !this.interpolatePose)
  42126. return this._attachedMesh.position.copyFrom(this._workingPosition).subtractInPlace(i),
  42127. void this._attachedMesh.rotationQuaternion.copyFrom(this._workingQuaternion);
  42128. var n = new x;
  42129. x.SmoothToRef(this._attachedMesh.position, this._workingPosition, e, this.lerpTime, n),
  42130. this._attachedMesh.position.copyFrom(n);
  42131. var r = new C;
  42132. r.copyFrom(this._attachedMesh.rotationQuaternion),
  42133. C.SmoothToRef(r, this._workingQuaternion, e, this.lerpTime, this._attachedMesh.rotationQuaternion),
  42134. this._attachedMesh.setParent(t)
  42135. }
  42136. }
  42137. ,
  42138. e.prototype._addObservables = function() {
  42139. var e = this;
  42140. this._pointerObserver = this._scene.onPointerObservable.add((function(t) {
  42141. e.enabled && t.type == Xi.POINTERMOVE && t.pickInfo && e.findAndUpdateTarget(t.pickInfo)
  42142. }
  42143. )),
  42144. this._lastTick = Date.now(),
  42145. this._onBeforeRender = this._scene.onBeforeRenderObservable.add((function() {
  42146. var t = Date.now();
  42147. e._updateTransformToGoal(t - e._lastTick),
  42148. e._lastTick = t
  42149. }
  42150. ))
  42151. }
  42152. ,
  42153. e.prototype._removeObservables = function() {
  42154. this._scene.onPointerObservable.remove(this._pointerObserver),
  42155. this._scene.onBeforeRenderObservable.remove(this._onBeforeRender),
  42156. this._pointerObserver = null,
  42157. this._onBeforeRender = null
  42158. }
  42159. ,
  42160. e
  42161. }(), Mo = function() {
  42162. function e() {
  42163. this._tmpQuaternion = new C,
  42164. this._tmpVectors = [new x, new x, new x, new x, new x, new x, new x],
  42165. this._tmpMatrix = new P,
  42166. this._tmpInvertView = new P,
  42167. this._tmpForward = new x,
  42168. this._tmpNodeForward = new x,
  42169. this._tmpPosition = new x,
  42170. this._workingPosition = new x,
  42171. this._workingQuaternion = new C,
  42172. this._lastTick = -1,
  42173. this._recenterNextUpdate = !0,
  42174. this.interpolatePose = !0,
  42175. this.lerpTime = 500,
  42176. this.ignoreCameraPitchAndRoll = !1,
  42177. this.pitchOffset = 15,
  42178. this.maxViewVerticalDegrees = 30,
  42179. this.maxViewHorizontalDegrees = 30,
  42180. this.orientToCameraDeadzoneDegrees = 60,
  42181. this.ignoreDistanceClamp = !1,
  42182. this.ignoreAngleClamp = !1,
  42183. this.verticalMaxDistance = 0,
  42184. this.defaultDistance = .8,
  42185. this.maximumDistance = 2,
  42186. this.minimumDistance = .3,
  42187. this.useFixedVerticalOffset = !1,
  42188. this.fixedVerticalOffset = 0,
  42189. this._enabled = !0
  42190. }
  42191. return Object.defineProperty(e.prototype, "followedCamera", {
  42192. get: function() {
  42193. return this._followedCamera || this._scene.activeCamera
  42194. },
  42195. set: function(e) {
  42196. this._followedCamera = e
  42197. },
  42198. enumerable: !1,
  42199. configurable: !0
  42200. }),
  42201. Object.defineProperty(e.prototype, "name", {
  42202. get: function() {
  42203. return "Follow"
  42204. },
  42205. enumerable: !1,
  42206. configurable: !0
  42207. }),
  42208. e.prototype.init = function() {}
  42209. ,
  42210. e.prototype.attach = function(e, t) {
  42211. this._scene = e.getScene(),
  42212. this.attachedNode = e,
  42213. t && (this.followedCamera = t),
  42214. this._addObservables()
  42215. }
  42216. ,
  42217. e.prototype.detach = function() {
  42218. this.attachedNode = null,
  42219. this._removeObservables()
  42220. }
  42221. ,
  42222. e.prototype.recenter = function() {
  42223. this._recenterNextUpdate = !0
  42224. }
  42225. ,
  42226. e.prototype._angleBetweenVectorAndPlane = function(e, t) {
  42227. return this._tmpVectors[0].copyFrom(e),
  42228. e = this._tmpVectors[0],
  42229. this._tmpVectors[1].copyFrom(t),
  42230. t = this._tmpVectors[1],
  42231. e.normalize(),
  42232. t.normalize(),
  42233. Math.PI / 2 - Math.acos(x.Dot(e, t))
  42234. }
  42235. ,
  42236. e.prototype._length2D = function(e) {
  42237. return Math.sqrt(e.x * e.x + e.z * e.z)
  42238. }
  42239. ,
  42240. e.prototype._distanceClamp = function(e, t) {
  42241. void 0 === t && (t = !1);
  42242. var i = this.minimumDistance
  42243. , n = this.maximumDistance
  42244. , r = this.defaultDistance
  42245. , o = this._tmpVectors[0];
  42246. o.copyFrom(e);
  42247. var a = o.length();
  42248. if (o.normalizeFromLength(a),
  42249. this.ignoreCameraPitchAndRoll) {
  42250. i = this._length2D(o) * i,
  42251. n = this._length2D(o) * n;
  42252. var s = this._length2D(e);
  42253. o.scaleInPlace(a / s),
  42254. a = s
  42255. }
  42256. var l;
  42257. return l = t ? r : d.Clamp(a, i, n),
  42258. e.copyFrom(o).scaleInPlace(l),
  42259. a !== l
  42260. }
  42261. ,
  42262. e.prototype._applyVerticalClamp = function(e) {
  42263. 0 !== this.verticalMaxDistance && (e.y = d.Clamp(e.y, -this.verticalMaxDistance, this.verticalMaxDistance))
  42264. }
  42265. ,
  42266. e.prototype._toOrientationQuatToRef = function(e, t) {
  42267. C.RotationYawPitchRollToRef(Math.atan2(e.x, e.z), Math.atan2(e.y, Math.sqrt(e.z * e.z + e.x * e.x)), 0, t)
  42268. }
  42269. ,
  42270. e.prototype._applyPitchOffset = function(e) {
  42271. var t = this._tmpVectors[0]
  42272. , i = this._tmpVectors[1];
  42273. t.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  42274. i.copyFromFloats(1, 0, 0),
  42275. x.TransformNormalToRef(t, e, t),
  42276. t.y = 0,
  42277. t.normalize(),
  42278. x.TransformNormalToRef(i, e, i),
  42279. C.RotationAxisToRef(i, this.pitchOffset * Math.PI / 180, this._tmpQuaternion),
  42280. t.rotateByQuaternionToRef(this._tmpQuaternion, t),
  42281. this._toOrientationQuatToRef(t, this._tmpQuaternion),
  42282. this._tmpQuaternion.toRotationMatrix(this._tmpMatrix),
  42283. e.copyFrom(this._tmpMatrix)
  42284. }
  42285. ,
  42286. e.prototype._angularClamp = function(e, t) {
  42287. var i = this._tmpVectors[5];
  42288. i.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1);
  42289. var n = this._tmpVectors[6];
  42290. n.copyFromFloats(1, 0, 0),
  42291. x.TransformNormalToRef(i, e, i),
  42292. x.TransformNormalToRef(n, e, n);
  42293. var r = x.UpReadOnly;
  42294. if (t.length() < m)
  42295. return !1;
  42296. var o = !1
  42297. , a = this._tmpQuaternion;
  42298. if (this.ignoreCameraPitchAndRoll) {
  42299. var s = x.GetAngleBetweenVectorsOnPlane(t, i, n);
  42300. C.RotationAxisToRef(n, s, a),
  42301. t.rotateByQuaternionToRef(a, t)
  42302. } else {
  42303. var l = -x.GetAngleBetweenVectorsOnPlane(t, i, n)
  42304. , c = this.maxViewVerticalDegrees * Math.PI / 180 * .5;
  42305. l < -c ? (C.RotationAxisToRef(n, -l - c, a),
  42306. t.rotateByQuaternionToRef(a, t),
  42307. o = !0) : l > c && (C.RotationAxisToRef(n, -l + c, a),
  42308. t.rotateByQuaternionToRef(a, t),
  42309. o = !0)
  42310. }
  42311. var u = this._angleBetweenVectorAndPlane(t, n) * (this._scene.useRightHandedSystem ? -1 : 1)
  42312. , h = this.maxViewHorizontalDegrees * Math.PI / 180 * .5;
  42313. return u < -h ? (C.RotationAxisToRef(r, -u - h, a),
  42314. t.rotateByQuaternionToRef(a, t),
  42315. o = !0) : u > h && (C.RotationAxisToRef(r, -u + h, a),
  42316. t.rotateByQuaternionToRef(a, t),
  42317. o = !0),
  42318. o
  42319. }
  42320. ,
  42321. e.prototype._orientationClamp = function(e, t) {
  42322. var i, n = this._tmpVectors[0];
  42323. n.copyFrom(e).scaleInPlace(-1).normalize();
  42324. var r = this._tmpVectors[1]
  42325. , o = this._tmpVectors[2];
  42326. r.copyFromFloats(0, 1, 0),
  42327. x.CrossToRef(n, r, o);
  42328. var a = o.length();
  42329. a < m || (o.normalizeFromLength(a),
  42330. x.CrossToRef(o, n, r),
  42331. (null === (i = this.attachedNode) || void 0 === i ? void 0 : i.getScene().useRightHandedSystem) ? C.FromLookDirectionRHToRef(n, r, t) : C.FromLookDirectionLHToRef(n, r, t))
  42332. }
  42333. ,
  42334. e.prototype._passedOrientationDeadzone = function(e, t) {
  42335. var i = this._tmpVectors[5];
  42336. return i.copyFrom(e),
  42337. i.normalize(),
  42338. 180 * Math.abs(x.GetAngleBetweenVectorsOnPlane(t, i, x.UpReadOnly)) / Math.PI > this.orientToCameraDeadzoneDegrees
  42339. }
  42340. ,
  42341. e.prototype._updateLeashing = function(e) {
  42342. if (this.attachedNode && this._enabled) {
  42343. var t = this.attachedNode.parent;
  42344. this.attachedNode.setParent(null);
  42345. var i = this.attachedNode.getWorldMatrix()
  42346. , n = this._workingPosition
  42347. , r = this._workingQuaternion
  42348. , o = this.attachedNode.getPivotPoint()
  42349. , a = this._tmpInvertView;
  42350. a.copyFrom(e.getViewMatrix()),
  42351. a.invert(),
  42352. x.TransformCoordinatesToRef(o, i, n);
  42353. var s = this._tmpPosition;
  42354. s.copyFromFloats(0, 0, 0),
  42355. x.TransformCoordinatesToRef(s, i, s),
  42356. s.scaleInPlace(-1).subtractInPlace(o),
  42357. n.subtractInPlace(e.globalPosition),
  42358. this.ignoreCameraPitchAndRoll && this._applyPitchOffset(a);
  42359. var l = !1
  42360. , c = this._tmpForward;
  42361. c.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  42362. x.TransformNormalToRef(c, a, c);
  42363. var u = this._tmpNodeForward;
  42364. if (u.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  42365. x.TransformNormalToRef(u, i, u),
  42366. this._recenterNextUpdate)
  42367. n.copyFrom(c).scaleInPlace(this.defaultDistance);
  42368. else if (this.ignoreAngleClamp) {
  42369. var h = n.length();
  42370. n.copyFrom(c).scaleInPlace(h)
  42371. } else
  42372. l = this._angularClamp(a, n);
  42373. var d = !1;
  42374. this.ignoreDistanceClamp || (d = this._distanceClamp(n, l),
  42375. this._applyVerticalClamp(n)),
  42376. this.useFixedVerticalOffset && (n.y = s.y - e.globalPosition.y + this.fixedVerticalOffset),
  42377. (l || d || this._passedOrientationDeadzone(n, u) || this._recenterNextUpdate) && this._orientationClamp(n, r),
  42378. this._workingPosition.subtractInPlace(o),
  42379. this._recenterNextUpdate = !1,
  42380. this.attachedNode.setParent(t)
  42381. }
  42382. }
  42383. ,
  42384. e.prototype._updateTransformToGoal = function(e) {
  42385. if (this.attachedNode && this.followedCamera && this._enabled) {
  42386. this.attachedNode.rotationQuaternion || (this.attachedNode.rotationQuaternion = C.Identity());
  42387. var t = this.attachedNode.parent;
  42388. if (this.attachedNode.setParent(null),
  42389. !this.interpolatePose)
  42390. return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),
  42391. void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);
  42392. var i = new x;
  42393. i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),
  42394. x.SmoothToRef(i, this._workingPosition, e, this.lerpTime, i),
  42395. i.addInPlace(this.followedCamera.globalPosition),
  42396. this.attachedNode.position.copyFrom(i);
  42397. var n = new C;
  42398. n.copyFrom(this.attachedNode.rotationQuaternion),
  42399. C.SmoothToRef(n, this._workingQuaternion, e, this.lerpTime, this.attachedNode.rotationQuaternion),
  42400. this.attachedNode.setParent(t)
  42401. }
  42402. }
  42403. ,
  42404. e.prototype._addObservables = function() {
  42405. var e = this;
  42406. this._lastTick = Date.now(),
  42407. this._onBeforeRender = this._scene.onBeforeRenderObservable.add((function() {
  42408. if (e.followedCamera) {
  42409. var t = Date.now();
  42410. e._updateLeashing(e.followedCamera),
  42411. e._updateTransformToGoal(t - e._lastTick),
  42412. e._lastTick = t
  42413. }
  42414. }
  42415. ))
  42416. }
  42417. ,
  42418. e.prototype._removeObservables = function() {
  42419. this._onBeforeRender && this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)
  42420. }
  42421. ,
  42422. e
  42423. }(), Io = function() {
  42424. function e() {}
  42425. return e.ANCHOR_SYSTEM = "xr-anchor-system",
  42426. e.BACKGROUND_REMOVER = "xr-background-remover",
  42427. e.HIT_TEST = "xr-hit-test",
  42428. e.MESH_DETECTION = "xr-mesh-detection",
  42429. e.PHYSICS_CONTROLLERS = "xr-physics-controller",
  42430. e.PLANE_DETECTION = "xr-plane-detection",
  42431. e.POINTER_SELECTION = "xr-controller-pointer-selection",
  42432. e.TELEPORTATION = "xr-controller-teleportation",
  42433. e.FEATURE_POINTS = "xr-feature-points",
  42434. e.HAND_TRACKING = "xr-hand-tracking",
  42435. e.IMAGE_TRACKING = "xr-image-tracking",
  42436. e.NEAR_INTERACTION = "xr-near-interaction",
  42437. e.DOM_OVERLAY = "xr-dom-overlay",
  42438. e.MOVEMENT = "xr-controller-movement",
  42439. e.LIGHT_ESTIMATION = "xr-light-estimation",
  42440. e.EYE_TRACKING = "xr-eye-tracking",
  42441. e.WALKING_LOCOMOTION = "xr-walking-locomotion",
  42442. e.LAYERS = "xr-layers",
  42443. e
  42444. }(), Oo = function() {
  42445. function e(e) {
  42446. var t = this;
  42447. this._xrSessionManager = e,
  42448. this._features = {},
  42449. this._xrSessionManager.onXRSessionInit.add((function() {
  42450. t.getEnabledFeatures().forEach((function(e) {
  42451. var i = t._features[e];
  42452. !i.enabled || i.featureImplementation.attached || i.featureImplementation.disableAutoAttach || t.attachFeature(e)
  42453. }
  42454. ))
  42455. }
  42456. )),
  42457. this._xrSessionManager.onXRSessionEnded.add((function() {
  42458. t.getEnabledFeatures().forEach((function(e) {
  42459. var i = t._features[e];
  42460. i.enabled && i.featureImplementation.attached && t.detachFeature(e)
  42461. }
  42462. ))
  42463. }
  42464. ))
  42465. }
  42466. return e.AddWebXRFeature = function(e, t, i, n) {
  42467. void 0 === i && (i = 1),
  42468. void 0 === n && (n = !1),
  42469. this._AvailableFeatures[e] = this._AvailableFeatures[e] || {
  42470. latest: i
  42471. },
  42472. i > this._AvailableFeatures[e].latest && (this._AvailableFeatures[e].latest = i),
  42473. n && (this._AvailableFeatures[e].stable = i),
  42474. this._AvailableFeatures[e][i] = t
  42475. }
  42476. ,
  42477. e.ConstructFeature = function(e, t, i, n) {
  42478. void 0 === t && (t = 1);
  42479. var r = this._AvailableFeatures[e][t];
  42480. if (!r)
  42481. throw new Error("feature not found");
  42482. return r(i, n)
  42483. }
  42484. ,
  42485. e.GetAvailableFeatures = function() {
  42486. return Object.keys(this._AvailableFeatures)
  42487. }
  42488. ,
  42489. e.GetAvailableVersions = function(e) {
  42490. return Object.keys(this._AvailableFeatures[e])
  42491. }
  42492. ,
  42493. e.GetLatestVersionOfFeature = function(e) {
  42494. return this._AvailableFeatures[e] && this._AvailableFeatures[e].latest || -1
  42495. }
  42496. ,
  42497. e.GetStableVersionOfFeature = function(e) {
  42498. return this._AvailableFeatures[e] && this._AvailableFeatures[e].stable || -1
  42499. }
  42500. ,
  42501. e.prototype.attachFeature = function(e) {
  42502. var t = this._features[e];
  42503. t && t.enabled && !t.featureImplementation.attached && t.featureImplementation.attach()
  42504. }
  42505. ,
  42506. e.prototype.detachFeature = function(e) {
  42507. var t = this._features[e];
  42508. t && t.featureImplementation.attached && t.featureImplementation.detach()
  42509. }
  42510. ,
  42511. e.prototype.disableFeature = function(e) {
  42512. var t = "string" == typeof e ? e : e.Name
  42513. , i = this._features[t];
  42514. return !(!i || !i.enabled || (i.enabled = !1,
  42515. this.detachFeature(t),
  42516. i.featureImplementation.dispose(),
  42517. delete this._features[t],
  42518. 0))
  42519. }
  42520. ,
  42521. e.prototype.dispose = function() {
  42522. var e = this;
  42523. this.getEnabledFeatures().forEach((function(t) {
  42524. e.disableFeature(t)
  42525. }
  42526. ))
  42527. }
  42528. ,
  42529. e.prototype.enableFeature = function(t, i, n, r, o) {
  42530. var a = this;
  42531. void 0 === i && (i = "latest"),
  42532. void 0 === n && (n = {}),
  42533. void 0 === r && (r = !0),
  42534. void 0 === o && (o = !0);
  42535. var s = "string" == typeof t ? t : t.Name
  42536. , l = 0;
  42537. if ("string" == typeof i) {
  42538. if (!i)
  42539. throw new Error("Error in provided version - ".concat(s, " (").concat(i, ")"));
  42540. if (-1 === (l = "stable" === i ? e.GetStableVersionOfFeature(s) : "latest" === i ? e.GetLatestVersionOfFeature(s) : +i) || isNaN(l))
  42541. throw new Error("feature not found - ".concat(s, " (").concat(i, ")"))
  42542. } else
  42543. l = i;
  42544. var c = e._ConflictingFeatures[s];
  42545. if (void 0 !== c && -1 !== this.getEnabledFeatures().indexOf(c))
  42546. throw new Error("Feature ".concat(s, " cannot be enabled while ").concat(c, " is enabled."));
  42547. var u = this._features[s]
  42548. , h = e.ConstructFeature(s, l, this._xrSessionManager, n);
  42549. if (!h)
  42550. throw new Error("feature not found - ".concat(s));
  42551. u && this.disableFeature(s);
  42552. var d = h();
  42553. if (d.dependsOn) {
  42554. var p = d.dependsOn.every((function(e) {
  42555. return !!a._features[e]
  42556. }
  42557. ));
  42558. if (!p)
  42559. throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(d.dependsOn.join(", ")))
  42560. }
  42561. if (d.isCompatible())
  42562. return this._features[s] = {
  42563. featureImplementation: d,
  42564. enabled: !0,
  42565. version: l,
  42566. required: o
  42567. },
  42568. r ? this._xrSessionManager.session && !this._features[s].featureImplementation.attached && this.attachFeature(s) : this._features[s].featureImplementation.disableAutoAttach = !0,
  42569. this._features[s].featureImplementation;
  42570. if (o)
  42571. throw new Error("required feature not compatible");
  42572. return gi.Warn("Feature ".concat(s, " not compatible with the current environment/browser and was not enabled.")),
  42573. d
  42574. }
  42575. ,
  42576. e.prototype.getEnabledFeature = function(e) {
  42577. return this._features[e] && this._features[e].featureImplementation
  42578. }
  42579. ,
  42580. e.prototype.getEnabledFeatures = function() {
  42581. return Object.keys(this._features)
  42582. }
  42583. ,
  42584. e.prototype._extendXRSessionInitObject = function(e) {
  42585. return G(this, void 0, void 0, (function() {
  42586. var t, i, n, r, o, a, s;
  42587. return z(this, (function(l) {
  42588. switch (l.label) {
  42589. case 0:
  42590. t = this.getEnabledFeatures(),
  42591. i = 0,
  42592. n = t,
  42593. l.label = 1;
  42594. case 1:
  42595. return i < n.length ? (r = n[i],
  42596. o = this._features[r],
  42597. (a = o.featureImplementation.xrNativeFeatureName) && (o.required ? (e.requiredFeatures = e.requiredFeatures || [],
  42598. -1 === e.requiredFeatures.indexOf(a) && e.requiredFeatures.push(a)) : (e.optionalFeatures = e.optionalFeatures || [],
  42599. -1 === e.optionalFeatures.indexOf(a) && e.optionalFeatures.push(a))),
  42600. o.featureImplementation.getXRSessionInitExtension ? [4, o.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4];
  42601. case 2:
  42602. s = l.sent(),
  42603. e = V(V({}, e), s),
  42604. l.label = 3;
  42605. case 3:
  42606. return i++,
  42607. [3, 1];
  42608. case 4:
  42609. return [2, e]
  42610. }
  42611. }
  42612. ))
  42613. }
  42614. ))
  42615. }
  42616. ,
  42617. e._AvailableFeatures = {},
  42618. e._ConflictingFeatures = ((bo = {})[Io.TELEPORTATION] = Io.MOVEMENT,
  42619. bo[Io.MOVEMENT] = Io.TELEPORTATION,
  42620. bo),
  42621. e
  42622. }();
  42623. !function(e) {
  42624. e[e.ABOVE_FINGER_TIPS = 0] = "ABOVE_FINGER_TIPS",
  42625. e[e.RADIAL_SIDE = 1] = "RADIAL_SIDE",
  42626. e[e.ULNAR_SIDE = 2] = "ULNAR_SIDE",
  42627. e[e.BELOW_WRIST = 3] = "BELOW_WRIST"
  42628. }(To || (To = {})),
  42629. function(e) {
  42630. e[e.LOOK_AT_CAMERA = 0] = "LOOK_AT_CAMERA",
  42631. e[e.HAND_ROTATION = 1] = "HAND_ROTATION"
  42632. }(Eo || (Eo = {})),
  42633. function(e) {
  42634. e[e.ALWAYS_VISIBLE = 0] = "ALWAYS_VISIBLE",
  42635. e[e.PALM_UP = 1] = "PALM_UP",
  42636. e[e.GAZE_FOCUS = 2] = "GAZE_FOCUS",
  42637. e[e.PALM_AND_GAZE = 3] = "PALM_AND_GAZE"
  42638. }(So || (So = {}));
  42639. var Do = function() {
  42640. function e() {
  42641. this._sceneRenderObserver = null,
  42642. this._zoneAxis = {},
  42643. this.handConstraintVisibility = So.PALM_AND_GAZE,
  42644. this.palmUpStrictness = .95,
  42645. this.gazeProximityRadius = .15,
  42646. this.targetOffset = .1,
  42647. this.targetZone = To.ULNAR_SIDE,
  42648. this.zoneOrientationMode = Eo.HAND_ROTATION,
  42649. this.nodeOrientationMode = Eo.HAND_ROTATION,
  42650. this.handedness = "none",
  42651. this.lerpTime = 100,
  42652. this._zoneAxis[To.ABOVE_FINGER_TIPS] = new x(0,1,0),
  42653. this._zoneAxis[To.RADIAL_SIDE] = new x(-1,0,0),
  42654. this._zoneAxis[To.ULNAR_SIDE] = new x(1,0,0),
  42655. this._zoneAxis[To.BELOW_WRIST] = new x(0,-1,0)
  42656. }
  42657. return Object.defineProperty(e.prototype, "name", {
  42658. get: function() {
  42659. return "HandConstraint"
  42660. },
  42661. enumerable: !1,
  42662. configurable: !0
  42663. }),
  42664. e.prototype.enable = function() {
  42665. this._node.setEnabled(!0)
  42666. }
  42667. ,
  42668. e.prototype.disable = function() {
  42669. this._node.setEnabled(!1)
  42670. }
  42671. ,
  42672. e.prototype._getHandPose = function() {
  42673. if (!this._handTracking)
  42674. return null;
  42675. var e;
  42676. if (e = "none" === this.handedness ? this._handTracking.getHandByHandedness("left") || this._handTracking.getHandByHandedness("right") : this._handTracking.getHandByHandedness(this.handedness)) {
  42677. var t = e.getJointMesh("pinky-finger-metacarpal")
  42678. , i = e.getJointMesh("middle-finger-metacarpal")
  42679. , n = e.getJointMesh("wrist");
  42680. if (n && i && t) {
  42681. var r = {
  42682. position: i.absolutePosition,
  42683. quaternion: new C,
  42684. id: e.xrController.uniqueId
  42685. }
  42686. , o = I.Vector3[0]
  42687. , a = I.Vector3[1]
  42688. , s = I.Vector3[2];
  42689. return o.copyFrom(i.absolutePosition).subtractInPlace(n.absolutePosition).normalize(),
  42690. a.copyFrom(t.absolutePosition).subtractInPlace(i.absolutePosition).normalize(),
  42691. x.CrossToRef(o, a, a),
  42692. x.CrossToRef(a, o, s),
  42693. C.FromLookDirectionLHToRef(a, o, r.quaternion),
  42694. r
  42695. }
  42696. }
  42697. return null
  42698. }
  42699. ,
  42700. e.prototype.init = function() {}
  42701. ,
  42702. e.prototype.attach = function(e) {
  42703. var t = this;
  42704. this._node = e,
  42705. this._scene = e.getScene(),
  42706. this._node.rotationQuaternion || (this._node.rotationQuaternion = C.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z));
  42707. var i = Date.now();
  42708. this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
  42709. var e = t._getHandPose();
  42710. if (t._node.reservedDataStore = t._node.reservedDataStore || {},
  42711. t._node.reservedDataStore.nearInteraction = t._node.reservedDataStore.nearInteraction || {},
  42712. t._node.reservedDataStore.nearInteraction.excludedControllerId = null,
  42713. e) {
  42714. var n = I.Vector3[0]
  42715. , r = t._scene.activeCamera;
  42716. n.copyFrom(t._zoneAxis[t.targetZone]);
  42717. var o = I.Quaternion[0];
  42718. if (r && (t.zoneOrientationMode === Eo.LOOK_AT_CAMERA || t.nodeOrientationMode === Eo.LOOK_AT_CAMERA)) {
  42719. var a = I.Vector3[1];
  42720. a.copyFrom(r.position).subtractInPlace(e.position).normalize(),
  42721. t._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(a, x.UpReadOnly, o) : C.FromLookDirectionLHToRef(a, x.UpReadOnly, o)
  42722. }
  42723. t.zoneOrientationMode === Eo.HAND_ROTATION ? e.quaternion.toRotationMatrix(I.Matrix[0]) : o.toRotationMatrix(I.Matrix[0]),
  42724. x.TransformNormalToRef(n, I.Matrix[0], n),
  42725. n.scaleInPlace(t.targetOffset);
  42726. var s = I.Vector3[2]
  42727. , l = I.Quaternion[1];
  42728. s.copyFrom(e.position).addInPlace(n),
  42729. t.nodeOrientationMode === Eo.HAND_ROTATION ? l.copyFrom(e.quaternion) : l.copyFrom(o);
  42730. var c = Date.now() - i;
  42731. x.SmoothToRef(t._node.position, s, c, t.lerpTime, t._node.position),
  42732. C.SmoothToRef(t._node.rotationQuaternion, l, c, t.lerpTime, t._node.rotationQuaternion),
  42733. t._node.reservedDataStore.nearInteraction.excludedControllerId = e.id
  42734. }
  42735. t._setVisibility(e),
  42736. i = Date.now()
  42737. }
  42738. ))
  42739. }
  42740. ,
  42741. e.prototype._setVisibility = function(e) {
  42742. var t = !0
  42743. , i = !0
  42744. , n = this._scene.activeCamera;
  42745. if (n) {
  42746. var r = n.getForwardRay();
  42747. if (this.handConstraintVisibility === So.GAZE_FOCUS || this.handConstraintVisibility === So.PALM_AND_GAZE) {
  42748. i = !1;
  42749. var o = void 0;
  42750. this._eyeTracking && (o = this._eyeTracking.getEyeGaze()),
  42751. o = o || r;
  42752. var a = I.Vector3[0];
  42753. e ? e.position.subtractToRef(o.origin, a) : this._node.getAbsolutePosition().subtractToRef(o.origin, a);
  42754. var s = x.Dot(a, o.direction)
  42755. , l = s * s;
  42756. s > 0 && a.lengthSquared() - l < this.gazeProximityRadius * this.gazeProximityRadius && (i = !0)
  42757. }
  42758. if ((this.handConstraintVisibility === So.PALM_UP || this.handConstraintVisibility === So.PALM_AND_GAZE) && (t = !1,
  42759. e)) {
  42760. var c = I.Vector3[0];
  42761. x.LeftHandedForwardReadOnly.rotateByQuaternionToRef(e.quaternion, c),
  42762. x.Dot(c, r.direction) > 2 * this.palmUpStrictness - 1 && (t = !0)
  42763. }
  42764. }
  42765. this._node.setEnabled(t && i)
  42766. }
  42767. ,
  42768. e.prototype.detach = function() {
  42769. this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)
  42770. }
  42771. ,
  42772. e.prototype.linkToXRExperience = function(e) {
  42773. try {
  42774. this._eyeTracking = e.featuresManager.getEnabledFeature(Io.EYE_TRACKING)
  42775. } catch (e) {}
  42776. try {
  42777. this._handTracking = e.featuresManager.getEnabledFeature(Io.HAND_TRACKING)
  42778. } catch (e) {
  42779. alert("Hand tracking must be enabled for the Hand Menu to work")
  42780. }
  42781. }
  42782. ,
  42783. e
  42784. }()
  42785. , No = function() {
  42786. function e(e, t, i) {
  42787. if (this.targetPosition = x.Zero(),
  42788. this.poleTargetPosition = x.Zero(),
  42789. this.poleTargetLocalOffset = x.Zero(),
  42790. this.poleAngle = 0,
  42791. this.slerpAmount = 1,
  42792. this._bone1Quat = C.Identity(),
  42793. this._bone1Mat = P.Identity(),
  42794. this._bone2Ang = Math.PI,
  42795. this._maxAngle = Math.PI,
  42796. this._rightHandedSystem = !1,
  42797. this._bendAxis = x.Right(),
  42798. this._slerping = !1,
  42799. this._adjustRoll = 0,
  42800. this._bone2 = t,
  42801. this._bone1 = t.getParent(),
  42802. this._bone1) {
  42803. this.mesh = e;
  42804. var n = t.getPosition();
  42805. if (t.getAbsoluteTransform().determinant() > 0 && (this._rightHandedSystem = !0,
  42806. this._bendAxis.x = 0,
  42807. this._bendAxis.y = 0,
  42808. this._bendAxis.z = -1,
  42809. n.x > n.y && n.x > n.z && (this._adjustRoll = .5 * Math.PI,
  42810. this._bendAxis.z = 1)),
  42811. this._bone1.length) {
  42812. var r = this._bone1.getScale()
  42813. , o = this._bone2.getScale();
  42814. this._bone1Length = this._bone1.length * r.y * this.mesh.scaling.y,
  42815. this._bone2Length = this._bone2.length * o.y * this.mesh.scaling.y
  42816. } else if (this._bone1.children[0]) {
  42817. e.computeWorldMatrix(!0);
  42818. var a = this._bone2.children[0].getAbsolutePosition(e)
  42819. , s = this._bone2.getAbsolutePosition(e)
  42820. , l = this._bone1.getAbsolutePosition(e);
  42821. this._bone1Length = x.Distance(a, s),
  42822. this._bone2Length = x.Distance(s, l)
  42823. }
  42824. this._bone1.getRotationMatrixToRef(Ji.WORLD, e, this._bone1Mat),
  42825. this.maxAngle = Math.PI,
  42826. i && (i.targetMesh && (this.targetMesh = i.targetMesh,
  42827. this.targetMesh.computeWorldMatrix(!0)),
  42828. i.poleTargetMesh ? (this.poleTargetMesh = i.poleTargetMesh,
  42829. this.poleTargetMesh.computeWorldMatrix(!0)) : i.poleTargetBone ? this.poleTargetBone = i.poleTargetBone : this._bone1.getParent() && (this.poleTargetBone = this._bone1.getParent()),
  42830. i.poleTargetLocalOffset && this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),
  42831. i.poleAngle && (this.poleAngle = i.poleAngle),
  42832. i.bendAxis && this._bendAxis.copyFrom(i.bendAxis),
  42833. i.maxAngle && (this.maxAngle = i.maxAngle),
  42834. i.slerpAmount && (this.slerpAmount = i.slerpAmount))
  42835. }
  42836. }
  42837. return Object.defineProperty(e.prototype, "maxAngle", {
  42838. get: function() {
  42839. return this._maxAngle
  42840. },
  42841. set: function(e) {
  42842. this._setMaxAngle(e)
  42843. },
  42844. enumerable: !1,
  42845. configurable: !0
  42846. }),
  42847. e.prototype._setMaxAngle = function(e) {
  42848. e < 0 && (e = 0),
  42849. (e > Math.PI || null == e) && (e = Math.PI),
  42850. this._maxAngle = e;
  42851. var t = this._bone1Length
  42852. , i = this._bone2Length;
  42853. this._maxReach = Math.sqrt(t * t + i * i - 2 * t * i * Math.cos(e))
  42854. }
  42855. ,
  42856. e.prototype.update = function() {
  42857. var t = this._bone1;
  42858. if (t) {
  42859. var i = this.targetPosition
  42860. , n = this.poleTargetPosition
  42861. , r = e._TmpMats[0]
  42862. , o = e._TmpMats[1];
  42863. this.targetMesh && i.copyFrom(this.targetMesh.getAbsolutePosition()),
  42864. this.poleTargetBone ? this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, n) : this.poleTargetMesh && x.TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), n);
  42865. var a = e._TmpVecs[0]
  42866. , s = e._TmpVecs[1]
  42867. , l = e._TmpVecs[2]
  42868. , c = e._TmpVecs[3]
  42869. , u = e._TmpVecs[4]
  42870. , h = e._TmpQuat;
  42871. t.getAbsolutePositionToRef(this.mesh, a),
  42872. n.subtractToRef(a, u),
  42873. 0 == u.x && 0 == u.y && 0 == u.z ? u.y = 1 : u.normalize(),
  42874. i.subtractToRef(a, c),
  42875. c.normalize(),
  42876. x.CrossToRef(c, u, s),
  42877. s.normalize(),
  42878. x.CrossToRef(c, s, l),
  42879. l.normalize(),
  42880. P.FromXYZAxesToRef(l, c, s, r);
  42881. var d = this._bone1Length
  42882. , p = this._bone2Length
  42883. , f = x.Distance(a, i);
  42884. this._maxReach > 0 && (f = Math.min(this._maxReach, f));
  42885. var _ = (p * p + f * f - d * d) / (2 * p * f)
  42886. , m = (f * f + d * d - p * p) / (2 * f * d);
  42887. _ > 1 && (_ = 1),
  42888. m > 1 && (m = 1),
  42889. _ < -1 && (_ = -1),
  42890. m < -1 && (m = -1);
  42891. var g = Math.acos(_)
  42892. , v = Math.acos(m)
  42893. , y = -g - v;
  42894. if (this._rightHandedSystem)
  42895. P.RotationYawPitchRollToRef(0, 0, this._adjustRoll, o),
  42896. o.multiplyToRef(r, r),
  42897. P.RotationAxisToRef(this._bendAxis, v, o),
  42898. o.multiplyToRef(r, r);
  42899. else {
  42900. var b = e._TmpVecs[5];
  42901. b.copyFrom(this._bendAxis),
  42902. b.x *= -1,
  42903. P.RotationAxisToRef(b, -v, o),
  42904. o.multiplyToRef(r, r)
  42905. }
  42906. this.poleAngle && (P.RotationAxisToRef(c, this.poleAngle, o),
  42907. r.multiplyToRef(o, r)),
  42908. this._bone1 && (this.slerpAmount < 1 ? (this._slerping || C.FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat),
  42909. C.FromRotationMatrixToRef(r, h),
  42910. C.SlerpToRef(this._bone1Quat, h, this.slerpAmount, this._bone1Quat),
  42911. y = this._bone2Ang * (1 - this.slerpAmount) + y * this.slerpAmount,
  42912. this._bone1.setRotationQuaternion(this._bone1Quat, Ji.WORLD, this.mesh),
  42913. this._slerping = !0) : (this._bone1.setRotationMatrix(r, Ji.WORLD, this.mesh),
  42914. this._bone1Mat.copyFrom(r),
  42915. this._slerping = !1),
  42916. this._updateLinkedTransformRotation(this._bone1)),
  42917. this._bone2.setAxisAngle(this._bendAxis, y, Ji.LOCAL),
  42918. this._updateLinkedTransformRotation(this._bone2),
  42919. this._bone2Ang = y
  42920. }
  42921. }
  42922. ,
  42923. e.prototype._updateLinkedTransformRotation = function(e) {
  42924. e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new C),
  42925. e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
  42926. }
  42927. ,
  42928. e._TmpVecs = [x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero()],
  42929. e._TmpQuat = C.Identity(),
  42930. e._TmpMats = [P.Identity(), P.Identity()],
  42931. e
  42932. }()
  42933. , Lo = function() {
  42934. function e(e, t, i, n) {
  42935. if (this.upAxis = x.Up(),
  42936. this.upAxisSpace = Ji.LOCAL,
  42937. this.adjustYaw = 0,
  42938. this.adjustPitch = 0,
  42939. this.adjustRoll = 0,
  42940. this.slerpAmount = 1,
  42941. this._boneQuat = C.Identity(),
  42942. this._slerping = !1,
  42943. this._firstFrameSkipped = !1,
  42944. this._fowardAxis = x.Forward(),
  42945. this.mesh = e,
  42946. this.bone = t,
  42947. this.target = i,
  42948. n && (n.adjustYaw && (this.adjustYaw = n.adjustYaw),
  42949. n.adjustPitch && (this.adjustPitch = n.adjustPitch),
  42950. n.adjustRoll && (this.adjustRoll = n.adjustRoll),
  42951. null != n.maxYaw ? this.maxYaw = n.maxYaw : this.maxYaw = Math.PI,
  42952. null != n.minYaw ? this.minYaw = n.minYaw : this.minYaw = -Math.PI,
  42953. null != n.maxPitch ? this.maxPitch = n.maxPitch : this.maxPitch = Math.PI,
  42954. null != n.minPitch ? this.minPitch = n.minPitch : this.minPitch = -Math.PI,
  42955. null != n.slerpAmount && (this.slerpAmount = n.slerpAmount),
  42956. null != n.upAxis && (this.upAxis = n.upAxis),
  42957. null != n.upAxisSpace && (this.upAxisSpace = n.upAxisSpace),
  42958. null != n.yawAxis || null != n.pitchAxis)) {
  42959. var r = vn.Y
  42960. , o = vn.X;
  42961. null != n.yawAxis && (r = n.yawAxis.clone()).normalize(),
  42962. null != n.pitchAxis && (o = n.pitchAxis.clone()).normalize();
  42963. var a = x.Cross(o, r);
  42964. this._transformYawPitch = P.Identity(),
  42965. P.FromXYZAxesToRef(o, r, a, this._transformYawPitch),
  42966. this._transformYawPitchInv = this._transformYawPitch.clone(),
  42967. this._transformYawPitch.invert()
  42968. }
  42969. t.getParent() || this.upAxisSpace != Ji.BONE || (this.upAxisSpace = Ji.LOCAL)
  42970. }
  42971. return Object.defineProperty(e.prototype, "minYaw", {
  42972. get: function() {
  42973. return this._minYaw
  42974. },
  42975. set: function(e) {
  42976. this._minYaw = e,
  42977. this._minYawSin = Math.sin(e),
  42978. this._minYawCos = Math.cos(e),
  42979. null != this._maxYaw && (this._midYawConstraint = .5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw,
  42980. this._yawRange = this._maxYaw - this._minYaw)
  42981. },
  42982. enumerable: !1,
  42983. configurable: !0
  42984. }),
  42985. Object.defineProperty(e.prototype, "maxYaw", {
  42986. get: function() {
  42987. return this._maxYaw
  42988. },
  42989. set: function(e) {
  42990. this._maxYaw = e,
  42991. this._maxYawSin = Math.sin(e),
  42992. this._maxYawCos = Math.cos(e),
  42993. null != this._minYaw && (this._midYawConstraint = .5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw,
  42994. this._yawRange = this._maxYaw - this._minYaw)
  42995. },
  42996. enumerable: !1,
  42997. configurable: !0
  42998. }),
  42999. Object.defineProperty(e.prototype, "minPitch", {
  43000. get: function() {
  43001. return this._minPitch
  43002. },
  43003. set: function(e) {
  43004. this._minPitch = e,
  43005. this._minPitchTan = Math.tan(e)
  43006. },
  43007. enumerable: !1,
  43008. configurable: !0
  43009. }),
  43010. Object.defineProperty(e.prototype, "maxPitch", {
  43011. get: function() {
  43012. return this._maxPitch
  43013. },
  43014. set: function(e) {
  43015. this._maxPitch = e,
  43016. this._maxPitchTan = Math.tan(e)
  43017. },
  43018. enumerable: !1,
  43019. configurable: !0
  43020. }),
  43021. e.prototype.update = function() {
  43022. if (this.slerpAmount < 1 && !this._firstFrameSkipped)
  43023. this._firstFrameSkipped = !0;
  43024. else {
  43025. var t = this.bone
  43026. , i = e._TmpVecs[0];
  43027. t.getAbsolutePositionToRef(this.mesh, i);
  43028. var n = this.target
  43029. , r = e._TmpMats[0]
  43030. , o = e._TmpMats[1]
  43031. , a = this.mesh
  43032. , s = t.getParent()
  43033. , l = e._TmpVecs[1];
  43034. l.copyFrom(this.upAxis),
  43035. this.upAxisSpace == Ji.BONE && s ? (this._transformYawPitch && x.TransformCoordinatesToRef(l, this._transformYawPitchInv, l),
  43036. s.getDirectionToRef(l, this.mesh, l)) : this.upAxisSpace == Ji.LOCAL && (a.getDirectionToRef(l, l),
  43037. 1 == a.scaling.x && 1 == a.scaling.y && 1 == a.scaling.z || l.normalize());
  43038. var c = !1
  43039. , u = !1;
  43040. if (this._maxYaw == Math.PI && this._minYaw == -Math.PI || (c = !0),
  43041. this._maxPitch == Math.PI && this._minPitch == -Math.PI || (u = !0),
  43042. c || u) {
  43043. var h = e._TmpMats[2]
  43044. , d = e._TmpMats[3];
  43045. if (this.upAxisSpace == Ji.BONE && 1 == l.y && s)
  43046. s.getRotationMatrixToRef(Ji.WORLD, this.mesh, h);
  43047. else if (this.upAxisSpace != Ji.LOCAL || 1 != l.y || s) {
  43048. var p = e._TmpVecs[2];
  43049. p.copyFrom(this._fowardAxis),
  43050. this._transformYawPitch && x.TransformCoordinatesToRef(p, this._transformYawPitchInv, p),
  43051. s ? s.getDirectionToRef(p, this.mesh, p) : a.getDirectionToRef(p, p);
  43052. var f = x.Cross(l, p);
  43053. f.normalize(),
  43054. p = x.Cross(f, l),
  43055. P.FromXYZAxesToRef(f, l, p, h)
  43056. } else
  43057. h.copyFrom(a.getWorldMatrix());
  43058. h.invertToRef(d);
  43059. var _ = null;
  43060. if (u) {
  43061. var m = e._TmpVecs[3];
  43062. n.subtractToRef(i, m),
  43063. x.TransformCoordinatesToRef(m, d, m),
  43064. _ = Math.sqrt(m.x * m.x + m.z * m.z);
  43065. var g = Math.atan2(m.y, _)
  43066. , v = g;
  43067. g > this._maxPitch ? (m.y = this._maxPitchTan * _,
  43068. v = this._maxPitch) : g < this._minPitch && (m.y = this._minPitchTan * _,
  43069. v = this._minPitch),
  43070. g != v && (x.TransformCoordinatesToRef(m, h, m),
  43071. m.addInPlace(i),
  43072. n = m)
  43073. }
  43074. if (c) {
  43075. m = e._TmpVecs[4],
  43076. n.subtractToRef(i, m),
  43077. x.TransformCoordinatesToRef(m, d, m);
  43078. var y = Math.atan2(m.x, m.z)
  43079. , b = y;
  43080. if ((y > this._maxYaw || y < this._minYaw) && (null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z)),
  43081. this._yawRange > Math.PI ? this._isAngleBetween(y, this._maxYaw, this._midYawConstraint) ? (m.z = this._maxYawCos * _,
  43082. m.x = this._maxYawSin * _,
  43083. b = this._maxYaw) : this._isAngleBetween(y, this._midYawConstraint, this._minYaw) && (m.z = this._minYawCos * _,
  43084. m.x = this._minYawSin * _,
  43085. b = this._minYaw) : y > this._maxYaw ? (m.z = this._maxYawCos * _,
  43086. m.x = this._maxYawSin * _,
  43087. b = this._maxYaw) : y < this._minYaw && (m.z = this._minYawCos * _,
  43088. m.x = this._minYawSin * _,
  43089. b = this._minYaw)),
  43090. this._slerping && this._yawRange > Math.PI) {
  43091. var T = e._TmpVecs[8];
  43092. T.copyFrom(vn.Z),
  43093. this._transformYawPitch && x.TransformCoordinatesToRef(T, this._transformYawPitchInv, T);
  43094. var E = e._TmpMats[4];
  43095. this._boneQuat.toRotationMatrix(E),
  43096. this.mesh.getWorldMatrix().multiplyToRef(E, E),
  43097. x.TransformCoordinatesToRef(T, E, T),
  43098. x.TransformCoordinatesToRef(T, d, T);
  43099. var S = Math.atan2(T.x, T.z);
  43100. if (this._getAngleBetween(S, y) > this._getAngleBetween(S, this._midYawConstraint)) {
  43101. null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z));
  43102. var A = this._getAngleBetween(S, this._maxYaw);
  43103. this._getAngleBetween(S, this._minYaw) < A ? (b = S + .75 * Math.PI,
  43104. m.z = Math.cos(b) * _,
  43105. m.x = Math.sin(b) * _) : (b = S - .75 * Math.PI,
  43106. m.z = Math.cos(b) * _,
  43107. m.x = Math.sin(b) * _)
  43108. }
  43109. }
  43110. y != b && (x.TransformCoordinatesToRef(m, h, m),
  43111. m.addInPlace(i),
  43112. n = m)
  43113. }
  43114. }
  43115. var R = e._TmpVecs[5]
  43116. , M = e._TmpVecs[6]
  43117. , I = e._TmpVecs[7]
  43118. , O = e._TmpQuat;
  43119. n.subtractToRef(i, R),
  43120. R.normalize(),
  43121. x.CrossToRef(l, R, M),
  43122. M.normalize(),
  43123. x.CrossToRef(R, M, I),
  43124. I.normalize(),
  43125. P.FromXYZAxesToRef(M, I, R, r),
  43126. 0 === M.x && 0 === M.y && 0 === M.z || 0 === I.x && 0 === I.y && 0 === I.z || 0 === R.x && 0 === R.y && 0 === R.z || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (P.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o),
  43127. o.multiplyToRef(r, r)),
  43128. this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(Ji.WORLD, this.mesh, this._boneQuat),
  43129. this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
  43130. C.FromRotationMatrixToRef(r, O),
  43131. C.SlerpToRef(this._boneQuat, O, this.slerpAmount, this._boneQuat),
  43132. this.bone.setRotationQuaternion(this._boneQuat, Ji.WORLD, this.mesh),
  43133. this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
  43134. this.bone.setRotationMatrix(r, Ji.WORLD, this.mesh),
  43135. this._slerping = !1),
  43136. this._updateLinkedTransformRotation())
  43137. }
  43138. }
  43139. ,
  43140. e.prototype._getAngleDiff = function(e, t) {
  43141. var i = t - e;
  43142. return (i %= 2 * Math.PI) > Math.PI ? i -= 2 * Math.PI : i < -Math.PI && (i += 2 * Math.PI),
  43143. i
  43144. }
  43145. ,
  43146. e.prototype._getAngleBetween = function(e, t) {
  43147. var i = 0;
  43148. return (i = (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) < (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) ? t - e : e - t) > Math.PI && (i = 2 * Math.PI - i),
  43149. i
  43150. }
  43151. ,
  43152. e.prototype._isAngleBetween = function(e, t, i) {
  43153. if (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e,
  43154. (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) < (i = (i %= 2 * Math.PI) < 0 ? i + 2 * Math.PI : i)) {
  43155. if (e > t && e < i)
  43156. return !0
  43157. } else if (e > i && e < t)
  43158. return !0;
  43159. return !1
  43160. }
  43161. ,
  43162. e.prototype._updateLinkedTransformRotation = function() {
  43163. var e = this.bone;
  43164. e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new C),
  43165. e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
  43166. }
  43167. ,
  43168. e._TmpVecs = g.BuildArray(10, x.Zero),
  43169. e._TmpQuat = C.Identity(),
  43170. e._TmpMats = g.BuildArray(5, P.Identity),
  43171. e
  43172. }()
  43173. , Fo = function() {
  43174. function e(e, t, i) {
  43175. this.name = e,
  43176. this.id = t,
  43177. this.bones = new Array,
  43178. this.needInitialSkinMatrix = !1,
  43179. this._isDirty = !0,
  43180. this._meshesWithPoseMatrix = new Array,
  43181. this._identity = P.Identity(),
  43182. this._ranges = {},
  43183. this._lastAbsoluteTransformsUpdateId = -1,
  43184. this._canUseTextureForBones = !1,
  43185. this._uniqueId = 0,
  43186. this._numBonesWithLinkedTransformNode = 0,
  43187. this._hasWaitingData = null,
  43188. this._parentContainer = null,
  43189. this.doNotSerialize = !1,
  43190. this._useTextureToStoreBoneMatrices = !0,
  43191. this._animationPropertiesOverride = null,
  43192. this.onBeforeComputeObservable = new h,
  43193. this.bones = [],
  43194. this._scene = i || E.LastCreatedScene,
  43195. this._uniqueId = this._scene.getUniqueId(),
  43196. this._scene.addSkeleton(this),
  43197. this._isDirty = !0;
  43198. var n = this._scene.getEngine().getCaps();
  43199. this._canUseTextureForBones = n.textureFloat && n.maxVertexTextureImageUnits > 0
  43200. }
  43201. return Object.defineProperty(e.prototype, "useTextureToStoreBoneMatrices", {
  43202. get: function() {
  43203. return this._useTextureToStoreBoneMatrices
  43204. },
  43205. set: function(e) {
  43206. this._useTextureToStoreBoneMatrices = e,
  43207. this._markAsDirty()
  43208. },
  43209. enumerable: !1,
  43210. configurable: !0
  43211. }),
  43212. Object.defineProperty(e.prototype, "animationPropertiesOverride", {
  43213. get: function() {
  43214. return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
  43215. },
  43216. set: function(e) {
  43217. this._animationPropertiesOverride = e
  43218. },
  43219. enumerable: !1,
  43220. configurable: !0
  43221. }),
  43222. Object.defineProperty(e.prototype, "isUsingTextureForMatrices", {
  43223. get: function() {
  43224. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones
  43225. },
  43226. enumerable: !1,
  43227. configurable: !0
  43228. }),
  43229. Object.defineProperty(e.prototype, "uniqueId", {
  43230. get: function() {
  43231. return this._uniqueId
  43232. },
  43233. enumerable: !1,
  43234. configurable: !0
  43235. }),
  43236. e.prototype.getClassName = function() {
  43237. return "Skeleton"
  43238. }
  43239. ,
  43240. e.prototype.getChildren = function() {
  43241. return this.bones.filter((function(e) {
  43242. return !e.getParent()
  43243. }
  43244. ))
  43245. }
  43246. ,
  43247. e.prototype.getTransformMatrices = function(e) {
  43248. return this.needInitialSkinMatrix ? (e._bonesTransformMatrices || this.prepare(),
  43249. e._bonesTransformMatrices) : (this._transformMatrices || this.prepare(),
  43250. this._transformMatrices)
  43251. }
  43252. ,
  43253. e.prototype.getTransformMatrixTexture = function(e) {
  43254. return this.needInitialSkinMatrix && e._transformMatrixTexture ? e._transformMatrixTexture : this._transformMatrixTexture
  43255. }
  43256. ,
  43257. e.prototype.getScene = function() {
  43258. return this._scene
  43259. }
  43260. ,
  43261. e.prototype.toString = function(e) {
  43262. var t = "Name: ".concat(this.name, ", nBones: ").concat(this.bones.length);
  43263. if (t += ", nAnimationRanges: ".concat(this._ranges ? Object.keys(this._ranges).length : "none"),
  43264. e) {
  43265. t += ", Ranges: {";
  43266. var i = !0;
  43267. for (var n in this._ranges)
  43268. i && (t += ", ",
  43269. i = !1),
  43270. t += n;
  43271. t += "}"
  43272. }
  43273. return t
  43274. }
  43275. ,
  43276. e.prototype.getBoneIndexByName = function(e) {
  43277. for (var t = 0, i = this.bones.length; t < i; t++)
  43278. if (this.bones[t].name === e)
  43279. return t;
  43280. return -1
  43281. }
  43282. ,
  43283. e.prototype.createAnimationRange = function(e, t, i) {
  43284. if (!this._ranges[e]) {
  43285. this._ranges[e] = new We(e,t,i);
  43286. for (var n = 0, r = this.bones.length; n < r; n++)
  43287. this.bones[n].animations[0] && this.bones[n].animations[0].createRange(e, t, i)
  43288. }
  43289. }
  43290. ,
  43291. e.prototype.deleteAnimationRange = function(e, t) {
  43292. void 0 === t && (t = !0);
  43293. for (var i = 0, n = this.bones.length; i < n; i++)
  43294. this.bones[i].animations[0] && this.bones[i].animations[0].deleteRange(e, t);
  43295. this._ranges[e] = null
  43296. }
  43297. ,
  43298. e.prototype.getAnimationRange = function(e) {
  43299. return this._ranges[e] || null
  43300. }
  43301. ,
  43302. e.prototype.getAnimationRanges = function() {
  43303. var e, t = [];
  43304. for (e in this._ranges)
  43305. t.push(this._ranges[e]);
  43306. return t
  43307. }
  43308. ,
  43309. e.prototype.copyAnimationRange = function(e, t, i) {
  43310. if (void 0 === i && (i = !1),
  43311. this._ranges[t] || !e.getAnimationRange(t))
  43312. return !1;
  43313. var n, r, o = !0, a = this._getHighestAnimationFrame() + 1, s = {}, l = e.bones;
  43314. for (r = 0,
  43315. n = l.length; r < n; r++)
  43316. s[l[r].name] = l[r];
  43317. this.bones.length !== l.length && (K.Warn("copyAnimationRange: this rig has ".concat(this.bones.length, " bones, while source as ").concat(l.length)),
  43318. o = !1);
  43319. var c = i && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null;
  43320. for (r = 0,
  43321. n = this.bones.length; r < n; r++) {
  43322. var u = this.bones[r].name
  43323. , h = s[u];
  43324. h ? o = o && this.bones[r].copyAnimationRange(h, t, a, i, c) : (K.Warn("copyAnimationRange: not same rig, missing source bone " + u),
  43325. o = !1)
  43326. }
  43327. var d = e.getAnimationRange(t);
  43328. return d && (this._ranges[t] = new We(t,d.from + a,d.to + a)),
  43329. o
  43330. }
  43331. ,
  43332. e.prototype.returnToRest = function() {
  43333. for (var e = 0, t = this.bones; e < t.length; e++) {
  43334. var i = t[e];
  43335. -1 !== i._index && i.returnToRest()
  43336. }
  43337. }
  43338. ,
  43339. e.prototype._getHighestAnimationFrame = function() {
  43340. for (var e = 0, t = 0, i = this.bones.length; t < i; t++)
  43341. if (this.bones[t].animations[0]) {
  43342. var n = this.bones[t].animations[0].getHighestFrame();
  43343. e < n && (e = n)
  43344. }
  43345. return e
  43346. }
  43347. ,
  43348. e.prototype.beginAnimation = function(e, t, i, n) {
  43349. var r = this.getAnimationRange(e);
  43350. return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
  43351. }
  43352. ,
  43353. e.MakeAnimationAdditive = function(e, t, i) {
  43354. void 0 === t && (t = 0);
  43355. var n = e.getAnimationRange(i);
  43356. if (!n)
  43357. return null;
  43358. for (var r = e._scene.getAllAnimatablesByTarget(e), o = null, a = 0; a < r.length; a++) {
  43359. var s = r[a];
  43360. if (s.fromFrame === (null == n ? void 0 : n.from) && s.toFrame === (null == n ? void 0 : n.to)) {
  43361. o = s;
  43362. break
  43363. }
  43364. }
  43365. var l = e.getAnimatables();
  43366. for (a = 0; a < l.length; a++) {
  43367. var c = l[a].animations;
  43368. if (c)
  43369. for (var u = 0; u < c.length; u++)
  43370. Qe.MakeAnimationAdditive(c[u], t, i)
  43371. }
  43372. return o && (o.isAdditive = !0),
  43373. e
  43374. }
  43375. ,
  43376. e.prototype._markAsDirty = function() {
  43377. this._isDirty = !0
  43378. }
  43379. ,
  43380. e.prototype._registerMeshWithPoseMatrix = function(e) {
  43381. this._meshesWithPoseMatrix.push(e)
  43382. }
  43383. ,
  43384. e.prototype._unregisterMeshWithPoseMatrix = function(e) {
  43385. var t = this._meshesWithPoseMatrix.indexOf(e);
  43386. t > -1 && this._meshesWithPoseMatrix.splice(t, 1)
  43387. }
  43388. ,
  43389. e.prototype._computeTransformMatrices = function(e, t) {
  43390. this.onBeforeComputeObservable.notifyObservers(this);
  43391. for (var i = 0; i < this.bones.length; i++) {
  43392. var n = this.bones[i];
  43393. n._childUpdateId++;
  43394. var r = n.getParent();
  43395. if (r ? n.getLocalMatrix().multiplyToRef(r.getWorldMatrix(), n.getWorldMatrix()) : t ? n.getLocalMatrix().multiplyToRef(t, n.getWorldMatrix()) : n.getWorldMatrix().copyFrom(n.getLocalMatrix()),
  43396. -1 !== n._index) {
  43397. var o = null === n._index ? i : n._index;
  43398. n.getInvertedAbsoluteTransform().multiplyToArray(n.getWorldMatrix(), e, 16 * o)
  43399. }
  43400. }
  43401. this._identity.copyToArray(e, 16 * this.bones.length)
  43402. }
  43403. ,
  43404. e.prototype.prepare = function() {
  43405. if (this._numBonesWithLinkedTransformNode > 0)
  43406. for (var e = 0, t = this.bones; e < t.length; e++)
  43407. (u = t[e])._linkedTransformNode && (u._linkedTransformNode.computeWorldMatrix(),
  43408. u._matrix = u._linkedTransformNode._localMatrix);
  43409. if (this.needInitialSkinMatrix)
  43410. for (var i = 0, n = this._meshesWithPoseMatrix; i < n.length; i++) {
  43411. var r = n[i]
  43412. , o = r.getPoseMatrix()
  43413. , s = this._isDirty;
  43414. if (r._bonesTransformMatrices && r._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (r._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1)),
  43415. s = !0),
  43416. s) {
  43417. if (this._synchronizedWithMesh !== r) {
  43418. this._synchronizedWithMesh = r;
  43419. for (var l = 0, c = this.bones; l < c.length; l++) {
  43420. var u;
  43421. (u = c[l]).getParent() || (u.getBaseMatrix().multiplyToRef(o, I.Matrix[1]),
  43422. u._updateDifferenceMatrix(I.Matrix[1]))
  43423. }
  43424. if (this.isUsingTextureForMatrices) {
  43425. var h = 4 * (this.bones.length + 1);
  43426. r._transformMatrixTexture && r._transformMatrixTexture.getSize().width === h || (r._transformMatrixTexture && r._transformMatrixTexture.dispose(),
  43427. r._transformMatrixTexture = ao.CreateRGBATexture(r._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))
  43428. }
  43429. }
  43430. this._computeTransformMatrices(r._bonesTransformMatrices, o),
  43431. this.isUsingTextureForMatrices && r._transformMatrixTexture && r._transformMatrixTexture.update(r._bonesTransformMatrices)
  43432. }
  43433. }
  43434. else {
  43435. if (!this._isDirty)
  43436. return;
  43437. this._transformMatrices && this._transformMatrices.length === 16 * (this.bones.length + 1) || (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)),
  43438. this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(),
  43439. this._transformMatrixTexture = ao.CreateRGBATexture(this._transformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))),
  43440. this._computeTransformMatrices(this._transformMatrices, null),
  43441. this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices)
  43442. }
  43443. this._isDirty = !1
  43444. }
  43445. ,
  43446. e.prototype.getAnimatables = function() {
  43447. if (!this._animatables || this._animatables.length !== this.bones.length) {
  43448. this._animatables = [];
  43449. for (var e = 0; e < this.bones.length; e++)
  43450. this._animatables.push(this.bones[e])
  43451. }
  43452. return this._animatables
  43453. }
  43454. ,
  43455. e.prototype.clone = function(t, i) {
  43456. var n = new e(t,i || t,this._scene);
  43457. n.needInitialSkinMatrix = this.needInitialSkinMatrix;
  43458. for (var r = 0; r < this.bones.length; r++) {
  43459. var o = this.bones[r]
  43460. , a = null
  43461. , s = o.getParent();
  43462. if (s) {
  43463. var l = this.bones.indexOf(s);
  43464. a = n.bones[l]
  43465. }
  43466. var c = new yn(o.name,n,a,o.getBaseMatrix().clone(),o.getRestPose().clone());
  43467. c._index = o._index,
  43468. o._linkedTransformNode && c.linkTransformNode(o._linkedTransformNode),
  43469. fe.DeepCopy(o.animations, c.animations)
  43470. }
  43471. if (this._ranges)
  43472. for (var u in n._ranges = {},
  43473. this._ranges) {
  43474. var h = this._ranges[u];
  43475. h && (n._ranges[u] = h.clone())
  43476. }
  43477. return this._isDirty = !0,
  43478. n
  43479. }
  43480. ,
  43481. e.prototype.enableBlending = function(e) {
  43482. void 0 === e && (e = .01),
  43483. this.bones.forEach((function(t) {
  43484. t.animations.forEach((function(t) {
  43485. t.enableBlending = !0,
  43486. t.blendingSpeed = e
  43487. }
  43488. ))
  43489. }
  43490. ))
  43491. }
  43492. ,
  43493. e.prototype.dispose = function() {
  43494. if (this._meshesWithPoseMatrix = [],
  43495. this.getScene().stopAnimation(this),
  43496. this.getScene().removeSkeleton(this),
  43497. this._parentContainer) {
  43498. var e = this._parentContainer.skeletons.indexOf(this);
  43499. e > -1 && this._parentContainer.skeletons.splice(e, 1),
  43500. this._parentContainer = null
  43501. }
  43502. this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
  43503. this._transformMatrixTexture = null)
  43504. }
  43505. ,
  43506. e.prototype.serialize = function() {
  43507. var e, t = {};
  43508. t.name = this.name,
  43509. t.id = this.id,
  43510. this.dimensionsAtRest && (t.dimensionsAtRest = this.dimensionsAtRest.asArray()),
  43511. t.bones = [],
  43512. t.needInitialSkinMatrix = this.needInitialSkinMatrix;
  43513. for (var i = 0; i < this.bones.length; i++) {
  43514. var n = this.bones[i]
  43515. , r = n.getParent()
  43516. , o = {
  43517. parentBoneIndex: r ? this.bones.indexOf(r) : -1,
  43518. index: n.getIndex(),
  43519. name: n.name,
  43520. id: n.id,
  43521. matrix: n.getBaseMatrix().toArray(),
  43522. rest: n.getRestPose().toArray(),
  43523. linkedTransformNodeId: null === (e = n.getTransformNode()) || void 0 === e ? void 0 : e.id
  43524. };
  43525. for (var a in t.bones.push(o),
  43526. n.length && (o.length = n.length),
  43527. n.metadata && (o.metadata = n.metadata),
  43528. n.animations && n.animations.length > 0 && (o.animation = n.animations[0].serialize()),
  43529. t.ranges = [],
  43530. this._ranges) {
  43531. var s = this._ranges[a];
  43532. if (s) {
  43533. var l = {};
  43534. l.name = a,
  43535. l.from = s.from,
  43536. l.to = s.to,
  43537. t.ranges.push(l)
  43538. }
  43539. }
  43540. }
  43541. return t
  43542. }
  43543. ,
  43544. e.Parse = function(t, i) {
  43545. var n, r = new e(t.name,t.id,i);
  43546. for (t.dimensionsAtRest && (r.dimensionsAtRest = x.FromArray(t.dimensionsAtRest)),
  43547. r.needInitialSkinMatrix = t.needInitialSkinMatrix,
  43548. n = 0; n < t.bones.length; n++) {
  43549. var o = t.bones[n]
  43550. , a = t.bones[n].index
  43551. , s = null;
  43552. o.parentBoneIndex > -1 && (s = r.bones[o.parentBoneIndex]);
  43553. var l = o.rest ? P.FromArray(o.rest) : null
  43554. , c = new yn(o.name,r,s,P.FromArray(o.matrix),l,null,a);
  43555. void 0 !== o.id && null !== o.id && (c.id = o.id),
  43556. o.length && (c.length = o.length),
  43557. o.metadata && (c.metadata = o.metadata),
  43558. o.animation && c.animations.push(Qe.Parse(o.animation)),
  43559. void 0 !== o.linkedTransformNodeId && null !== o.linkedTransformNodeId && (r._hasWaitingData = !0,
  43560. c._waitingTransformNodeId = o.linkedTransformNodeId)
  43561. }
  43562. if (t.ranges)
  43563. for (n = 0; n < t.ranges.length; n++) {
  43564. var u = t.ranges[n];
  43565. r.createAnimationRange(u.name, u.from, u.to)
  43566. }
  43567. return r
  43568. }
  43569. ,
  43570. e.prototype.computeAbsoluteTransforms = function(e) {
  43571. void 0 === e && (e = !1);
  43572. var t = this._scene.getRenderId();
  43573. (this._lastAbsoluteTransformsUpdateId != t || e) && (this.bones[0].computeAbsoluteTransforms(),
  43574. this._lastAbsoluteTransformsUpdateId = t)
  43575. }
  43576. ,
  43577. e.prototype.getPoseMatrix = function() {
  43578. var e = null;
  43579. return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()),
  43580. e
  43581. }
  43582. ,
  43583. e.prototype.sortBones = function() {
  43584. for (var e = new Array, t = new Array(this.bones.length), i = 0; i < this.bones.length; i++)
  43585. this._sortBones(i, e, t);
  43586. this.bones = e
  43587. }
  43588. ,
  43589. e.prototype._sortBones = function(e, t, i) {
  43590. if (!i[e]) {
  43591. i[e] = !0;
  43592. var n = this.bones[e];
  43593. void 0 === n._index && (n._index = e);
  43594. var r = n.getParent();
  43595. r && this._sortBones(this.bones.indexOf(r), t, i),
  43596. t.push(n)
  43597. }
  43598. }
  43599. ,
  43600. e.prototype.setCurrentPoseAsRest = function() {
  43601. this.bones.forEach((function(e) {
  43602. e.setCurrentPoseAsRest()
  43603. }
  43604. ))
  43605. }
  43606. ,
  43607. e
  43608. }()
  43609. , wo = function() {
  43610. function e(e, t, i) {
  43611. void 0 === i && (i = a.BUFFER_CREATIONFLAG_READWRITE),
  43612. this._engine = e,
  43613. this._engine._storageBuffers.push(this),
  43614. this._create(t, i)
  43615. }
  43616. return e.prototype._create = function(e, t) {
  43617. this._bufferSize = e,
  43618. this._creationFlags = t,
  43619. this._buffer = this._engine.createStorageBuffer(e, t)
  43620. }
  43621. ,
  43622. e.prototype._rebuild = function() {
  43623. this._create(this._bufferSize, this._creationFlags)
  43624. }
  43625. ,
  43626. e.prototype.getBuffer = function() {
  43627. return this._buffer
  43628. }
  43629. ,
  43630. e.prototype.update = function(e, t, i) {
  43631. this._buffer && this._engine.updateStorageBuffer(this._buffer, e, t, i)
  43632. }
  43633. ,
  43634. e.prototype.read = function(e, t, i) {
  43635. return this._engine.readFromStorageBuffer(this._buffer, e, t, i)
  43636. }
  43637. ,
  43638. e.prototype.dispose = function() {
  43639. var e = this._engine._storageBuffers
  43640. , t = e.indexOf(this);
  43641. -1 !== t && (e[t] = e[e.length - 1],
  43642. e.pop()),
  43643. this._engine._releaseBuffer(this._buffer),
  43644. this._buffer = null
  43645. }
  43646. ,
  43647. e
  43648. }()
  43649. , Bo = function() {
  43650. function e() {
  43651. this.wheelPrecisionX = 3,
  43652. this.wheelPrecisionY = 3,
  43653. this.wheelPrecisionZ = 3,
  43654. this.onChangedObservable = new h,
  43655. this._wheelDeltaX = 0,
  43656. this._wheelDeltaY = 0,
  43657. this._wheelDeltaZ = 0,
  43658. this._ffMultiplier = 12,
  43659. this._normalize = 120
  43660. }
  43661. return e.prototype.attachControl = function(e) {
  43662. var t = this;
  43663. e = gi.BackCompatCameraNoPreventDefault(arguments),
  43664. this._wheel = function(i) {
  43665. if (i.type === Xi.POINTERWHEEL) {
  43666. var n = i.event
  43667. , r = n.deltaMode === $i.DOM_DELTA_LINE ? t._ffMultiplier : 1;
  43668. void 0 !== n.deltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.deltaX / t._normalize,
  43669. t._wheelDeltaY -= t.wheelPrecisionY * r * n.deltaY / t._normalize,
  43670. t._wheelDeltaZ += t.wheelPrecisionZ * r * n.deltaZ / t._normalize) : void 0 !== n.wheelDeltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.wheelDeltaX / t._normalize,
  43671. t._wheelDeltaY -= t.wheelPrecisionY * r * n.wheelDeltaY / t._normalize,
  43672. t._wheelDeltaZ += t.wheelPrecisionZ * r * n.wheelDeltaZ / t._normalize) : n.wheelDelta && (t._wheelDeltaY -= t.wheelPrecisionY * n.wheelDelta / t._normalize),
  43673. n.preventDefault && (e || n.preventDefault())
  43674. }
  43675. }
  43676. ,
  43677. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
  43678. }
  43679. ,
  43680. e.prototype.detachControl = function() {
  43681. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  43682. this._observer = null,
  43683. this._wheel = null),
  43684. this.onChangedObservable && this.onChangedObservable.clear()
  43685. }
  43686. ,
  43687. e.prototype.checkInputs = function() {
  43688. this.onChangedObservable.notifyObservers({
  43689. wheelDeltaX: this._wheelDeltaX,
  43690. wheelDeltaY: this._wheelDeltaY,
  43691. wheelDeltaZ: this._wheelDeltaZ
  43692. }),
  43693. this._wheelDeltaX = 0,
  43694. this._wheelDeltaY = 0,
  43695. this._wheelDeltaZ = 0
  43696. }
  43697. ,
  43698. e.prototype.getClassName = function() {
  43699. return "BaseCameraMouseWheelInput"
  43700. }
  43701. ,
  43702. e.prototype.getSimpleName = function() {
  43703. return "mousewheel"
  43704. }
  43705. ,
  43706. k([Ce()], e.prototype, "wheelPrecisionX", void 0),
  43707. k([Ce()], e.prototype, "wheelPrecisionY", void 0),
  43708. k([Ce()], e.prototype, "wheelPrecisionZ", void 0),
  43709. e
  43710. }()
  43711. , Uo = function() {
  43712. function e() {
  43713. this._currentActiveButton = -1,
  43714. this.buttons = [0, 1, 2]
  43715. }
  43716. return e.prototype.attachControl = function(e) {
  43717. var t = this;
  43718. e = gi.BackCompatCameraNoPreventDefault(arguments);
  43719. var i = this.camera.getEngine()
  43720. , n = i.getInputElement()
  43721. , r = 0
  43722. , o = null;
  43723. this._pointA = null,
  43724. this._pointB = null,
  43725. this._altKey = !1,
  43726. this._ctrlKey = !1,
  43727. this._metaKey = !1,
  43728. this._shiftKey = !1,
  43729. this._buttonsPressed = 0,
  43730. this._pointerInput = function(a) {
  43731. var s = a.event
  43732. , l = "touch" === s.pointerType;
  43733. if (!i.isInVRExclusivePointerMode && (a.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(s.button))) {
  43734. var c = s.srcElement || s.target;
  43735. if (t._altKey = s.altKey,
  43736. t._ctrlKey = s.ctrlKey,
  43737. t._metaKey = s.metaKey,
  43738. t._shiftKey = s.shiftKey,
  43739. t._buttonsPressed = s.buttons,
  43740. i.isPointerLock) {
  43741. var u = s.movementX || s.mozMovementX || s.webkitMovementX || s.msMovementX || 0
  43742. , h = s.movementY || s.mozMovementY || s.webkitMovementY || s.msMovementY || 0;
  43743. t.onTouch(null, u, h),
  43744. t._pointA = null,
  43745. t._pointB = null
  43746. } else if (a.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !l)
  43747. if (a.type === Xi.POINTERDOUBLETAP)
  43748. t.onDoubleTap(s.pointerType);
  43749. else if (a.type !== Xi.POINTERUP || t._currentActiveButton !== s.button && !l) {
  43750. if (a.type === Xi.POINTERMOVE)
  43751. if (e || s.preventDefault(),
  43752. t._pointA && null === t._pointB)
  43753. u = s.clientX - t._pointA.x,
  43754. h = s.clientY - t._pointA.y,
  43755. t.onTouch(t._pointA, u, h),
  43756. t._pointA.x = s.clientX,
  43757. t._pointA.y = s.clientY;
  43758. else if (t._pointA && t._pointB) {
  43759. var d = t._pointA.pointerId === s.pointerId ? t._pointA : t._pointB;
  43760. d.x = s.clientX,
  43761. d.y = s.clientY;
  43762. var p = t._pointA.x - t._pointB.x
  43763. , f = t._pointA.y - t._pointB.y
  43764. , _ = p * p + f * f
  43765. , m = {
  43766. x: (t._pointA.x + t._pointB.x) / 2,
  43767. y: (t._pointA.y + t._pointB.y) / 2,
  43768. pointerId: s.pointerId,
  43769. type: a.type
  43770. };
  43771. t.onMultiTouch(t._pointA, t._pointB, r, _, o, m),
  43772. o = m,
  43773. r = _
  43774. }
  43775. } else {
  43776. try {
  43777. null == c || c.releasePointerCapture(s.pointerId)
  43778. } catch (e) {}
  43779. l || (t._pointB = null),
  43780. i._badOS ? t._pointA = t._pointB = null : t._pointB && t._pointA && t._pointA.pointerId == s.pointerId ? (t._pointA = t._pointB,
  43781. t._pointB = null) : t._pointA && t._pointB && t._pointB.pointerId == s.pointerId ? t._pointB = null : t._pointA = t._pointB = null,
  43782. (0 !== r || o) && (t.onMultiTouch(t._pointA, t._pointB, r, 0, o, null),
  43783. r = 0,
  43784. o = null),
  43785. t._currentActiveButton = -1,
  43786. t.onButtonUp(s),
  43787. e || s.preventDefault()
  43788. }
  43789. else {
  43790. try {
  43791. null == c || c.setPointerCapture(s.pointerId)
  43792. } catch (e) {}
  43793. null === t._pointA ? t._pointA = {
  43794. x: s.clientX,
  43795. y: s.clientY,
  43796. pointerId: s.pointerId,
  43797. type: s.pointerType
  43798. } : null === t._pointB && (t._pointB = {
  43799. x: s.clientX,
  43800. y: s.clientY,
  43801. pointerId: s.pointerId,
  43802. type: s.pointerType
  43803. }),
  43804. -1 !== t._currentActiveButton || l || (t._currentActiveButton = s.button),
  43805. t.onButtonDown(s),
  43806. e || (s.preventDefault(),
  43807. n && n.focus())
  43808. }
  43809. }
  43810. }
  43811. ,
  43812. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE | Xi.POINTERDOUBLETAP),
  43813. this._onLostFocus = function() {
  43814. t._pointA = t._pointB = null,
  43815. r = 0,
  43816. o = null,
  43817. t.onLostFocus()
  43818. }
  43819. ,
  43820. this._contextMenuBind = this.onContextMenu.bind(this),
  43821. n && n.addEventListener("contextmenu", this._contextMenuBind, !1);
  43822. var a = this.camera.getScene().getEngine().getHostWindow();
  43823. a && gi.RegisterTopRootEvents(a, [{
  43824. name: "blur",
  43825. handler: this._onLostFocus
  43826. }])
  43827. }
  43828. ,
  43829. e.prototype.detachControl = function() {
  43830. if (this._onLostFocus) {
  43831. var e = this.camera.getScene().getEngine().getHostWindow();
  43832. e && gi.UnregisterTopRootEvents(e, [{
  43833. name: "blur",
  43834. handler: this._onLostFocus
  43835. }])
  43836. }
  43837. if (this._observer) {
  43838. if (this.camera.getScene().onPointerObservable.remove(this._observer),
  43839. this._observer = null,
  43840. this._contextMenuBind) {
  43841. var t = this.camera.getScene().getEngine().getInputElement();
  43842. t && t.removeEventListener("contextmenu", this._contextMenuBind)
  43843. }
  43844. this._onLostFocus = null
  43845. }
  43846. this._altKey = !1,
  43847. this._ctrlKey = !1,
  43848. this._metaKey = !1,
  43849. this._shiftKey = !1,
  43850. this._buttonsPressed = 0
  43851. }
  43852. ,
  43853. e.prototype.getClassName = function() {
  43854. return "BaseCameraPointersInput"
  43855. }
  43856. ,
  43857. e.prototype.getSimpleName = function() {
  43858. return "pointers"
  43859. }
  43860. ,
  43861. e.prototype.onDoubleTap = function(e) {}
  43862. ,
  43863. e.prototype.onTouch = function(e, t, i) {}
  43864. ,
  43865. e.prototype.onMultiTouch = function(e, t, i, n, r, o) {}
  43866. ,
  43867. e.prototype.onContextMenu = function(e) {
  43868. e.preventDefault()
  43869. }
  43870. ,
  43871. e.prototype.onButtonDown = function(e) {}
  43872. ,
  43873. e.prototype.onButtonUp = function(e) {}
  43874. ,
  43875. e.prototype.onLostFocus = function() {}
  43876. ,
  43877. k([Ce()], e.prototype, "buttons", void 0),
  43878. e
  43879. }()
  43880. , Vo = {}
  43881. , ko = function() {
  43882. function e(e) {
  43883. this.attachedToElement = !1,
  43884. this.attached = {},
  43885. this.camera = e,
  43886. this.checkInputs = function() {}
  43887. }
  43888. return e.prototype.add = function(e) {
  43889. var t = e.getSimpleName();
  43890. this.attached[t] ? K.Warn("camera input of type " + t + " already exists on camera") : (this.attached[t] = e,
  43891. e.camera = this.camera,
  43892. e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))),
  43893. this.attachedToElement && e.attachControl())
  43894. }
  43895. ,
  43896. e.prototype.remove = function(e) {
  43897. for (var t in this.attached) {
  43898. var i = this.attached[t];
  43899. i === e && (i.detachControl(),
  43900. i.camera = null,
  43901. delete this.attached[t],
  43902. this.rebuildInputCheck())
  43903. }
  43904. }
  43905. ,
  43906. e.prototype.removeByType = function(e) {
  43907. for (var t in this.attached) {
  43908. var i = this.attached[t];
  43909. i.getClassName() === e && (i.detachControl(),
  43910. i.camera = null,
  43911. delete this.attached[t],
  43912. this.rebuildInputCheck())
  43913. }
  43914. }
  43915. ,
  43916. e.prototype._addCheckInputs = function(e) {
  43917. var t = this.checkInputs;
  43918. return function() {
  43919. t(),
  43920. e()
  43921. }
  43922. }
  43923. ,
  43924. e.prototype.attachInput = function(e) {
  43925. this.attachedToElement && e.attachControl(this.noPreventDefault)
  43926. }
  43927. ,
  43928. e.prototype.attachElement = function(e) {
  43929. if (void 0 === e && (e = !1),
  43930. !this.attachedToElement)
  43931. for (var t in e = !Rr.ForceAttachControlToAlwaysPreventDefault && e,
  43932. this.attachedToElement = !0,
  43933. this.noPreventDefault = e,
  43934. this.attached)
  43935. this.attached[t].attachControl(e)
  43936. }
  43937. ,
  43938. e.prototype.detachElement = function(e) {
  43939. for (var t in void 0 === e && (e = !1),
  43940. this.attached)
  43941. this.attached[t].detachControl(),
  43942. e && (this.attached[t].camera = null);
  43943. this.attachedToElement = !1
  43944. }
  43945. ,
  43946. e.prototype.rebuildInputCheck = function() {
  43947. for (var e in this.checkInputs = function() {}
  43948. ,
  43949. this.attached) {
  43950. var t = this.attached[e];
  43951. t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t)))
  43952. }
  43953. }
  43954. ,
  43955. e.prototype.clear = function() {
  43956. this.attachedToElement && this.detachElement(!0),
  43957. this.attached = {},
  43958. this.attachedToElement = !1,
  43959. this.checkInputs = function() {}
  43960. }
  43961. ,
  43962. e.prototype.serialize = function(e) {
  43963. var t = {};
  43964. for (var i in this.attached) {
  43965. var n = this.attached[i]
  43966. , r = Ge.Serialize(n);
  43967. t[n.getClassName()] = r
  43968. }
  43969. e.inputsmgr = t
  43970. }
  43971. ,
  43972. e.prototype.parse = function(e) {
  43973. var t = e.inputsmgr;
  43974. if (t) {
  43975. this.clear();
  43976. var i = function(e) {
  43977. var i = Vo[e];
  43978. if (i) {
  43979. var r = t[e]
  43980. , o = Ge.Parse((function() {
  43981. return new i
  43982. }
  43983. ), r, null);
  43984. n.add(o)
  43985. }
  43986. }
  43987. , n = this;
  43988. for (var r in t)
  43989. i(r)
  43990. } else {
  43991. var o = function(t) {
  43992. var i = Vo[a.attached[t].getClassName()];
  43993. if (i) {
  43994. var n = Ge.Parse((function() {
  43995. return new i
  43996. }
  43997. ), e, null);
  43998. a.remove(a.attached[t]),
  43999. a.add(n)
  44000. }
  44001. }
  44002. , a = this;
  44003. for (var r in this.attached)
  44004. o(r)
  44005. }
  44006. }
  44007. ,
  44008. e
  44009. }()
  44010. , Go = function(e, t) {
  44011. this.x = e,
  44012. this.y = t
  44013. }
  44014. , zo = function() {
  44015. function e(t, i, n, r, o, a, s) {
  44016. void 0 === r && (r = 0),
  44017. void 0 === o && (o = 1),
  44018. void 0 === a && (a = 2),
  44019. void 0 === s && (s = 3),
  44020. this.id = t,
  44021. this.index = i,
  44022. this.browserGamepad = n,
  44023. this._leftStick = {
  44024. x: 0,
  44025. y: 0
  44026. },
  44027. this._rightStick = {
  44028. x: 0,
  44029. y: 0
  44030. },
  44031. this._isConnected = !0,
  44032. this._invertLeftStickY = !1,
  44033. this.type = e.GAMEPAD,
  44034. this._leftStickAxisX = r,
  44035. this._leftStickAxisY = o,
  44036. this._rightStickAxisX = a,
  44037. this._rightStickAxisY = s,
  44038. this.browserGamepad.axes.length >= 2 && (this._leftStick = {
  44039. x: this.browserGamepad.axes[this._leftStickAxisX],
  44040. y: this.browserGamepad.axes[this._leftStickAxisY]
  44041. }),
  44042. this.browserGamepad.axes.length >= 4 && (this._rightStick = {
  44043. x: this.browserGamepad.axes[this._rightStickAxisX],
  44044. y: this.browserGamepad.axes[this._rightStickAxisY]
  44045. })
  44046. }
  44047. return Object.defineProperty(e.prototype, "isConnected", {
  44048. get: function() {
  44049. return this._isConnected
  44050. },
  44051. enumerable: !1,
  44052. configurable: !0
  44053. }),
  44054. e.prototype.onleftstickchanged = function(e) {
  44055. this._onleftstickchanged = e
  44056. }
  44057. ,
  44058. e.prototype.onrightstickchanged = function(e) {
  44059. this._onrightstickchanged = e
  44060. }
  44061. ,
  44062. Object.defineProperty(e.prototype, "leftStick", {
  44063. get: function() {
  44064. return this._leftStick
  44065. },
  44066. set: function(e) {
  44067. !this._onleftstickchanged || this._leftStick.x === e.x && this._leftStick.y === e.y || this._onleftstickchanged(e),
  44068. this._leftStick = e
  44069. },
  44070. enumerable: !1,
  44071. configurable: !0
  44072. }),
  44073. Object.defineProperty(e.prototype, "rightStick", {
  44074. get: function() {
  44075. return this._rightStick
  44076. },
  44077. set: function(e) {
  44078. !this._onrightstickchanged || this._rightStick.x === e.x && this._rightStick.y === e.y || this._onrightstickchanged(e),
  44079. this._rightStick = e
  44080. },
  44081. enumerable: !1,
  44082. configurable: !0
  44083. }),
  44084. e.prototype.update = function() {
  44085. this._leftStick && (this.leftStick = {
  44086. x: this.browserGamepad.axes[this._leftStickAxisX],
  44087. y: this.browserGamepad.axes[this._leftStickAxisY]
  44088. },
  44089. this._invertLeftStickY && (this.leftStick.y *= -1)),
  44090. this._rightStick && (this.rightStick = {
  44091. x: this.browserGamepad.axes[this._rightStickAxisX],
  44092. y: this.browserGamepad.axes[this._rightStickAxisY]
  44093. })
  44094. }
  44095. ,
  44096. e.prototype.dispose = function() {}
  44097. ,
  44098. e.GAMEPAD = 0,
  44099. e.GENERIC = 1,
  44100. e.XBOX = 2,
  44101. e.POSE_ENABLED = 3,
  44102. e.DUALSHOCK = 4,
  44103. e
  44104. }()
  44105. , Wo = function(e) {
  44106. function t(t, i, n) {
  44107. var r = e.call(this, t, i, n) || this;
  44108. return r.onButtonDownObservable = new h,
  44109. r.onButtonUpObservable = new h,
  44110. r.type = zo.GENERIC,
  44111. r._buttons = new Array(n.buttons.length),
  44112. r
  44113. }
  44114. return U(t, e),
  44115. t.prototype.onbuttondown = function(e) {
  44116. this._onbuttondown = e
  44117. }
  44118. ,
  44119. t.prototype.onbuttonup = function(e) {
  44120. this._onbuttonup = e
  44121. }
  44122. ,
  44123. t.prototype._setButtonValue = function(e, t, i) {
  44124. return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
  44125. this.onButtonDownObservable.notifyObservers(i)),
  44126. 0 === e && (this._onbuttonup && this._onbuttonup(i),
  44127. this.onButtonUpObservable.notifyObservers(i))),
  44128. e
  44129. }
  44130. ,
  44131. t.prototype.update = function() {
  44132. e.prototype.update.call(this);
  44133. for (var t = 0; t < this._buttons.length; t++)
  44134. this._buttons[t] = this._setButtonValue(this.browserGamepad.buttons[t].value, this._buttons[t], t)
  44135. }
  44136. ,
  44137. t.prototype.dispose = function() {
  44138. e.prototype.dispose.call(this),
  44139. this.onButtonDownObservable.clear(),
  44140. this.onButtonUpObservable.clear()
  44141. }
  44142. ,
  44143. t
  44144. }(zo)
  44145. , Ho = function() {
  44146. function e() {
  44147. this.gamepadRotationSensibility = 80,
  44148. this.gamepadMoveSensibility = 40,
  44149. this._yAxisScale = 1
  44150. }
  44151. return Object.defineProperty(e.prototype, "invertYAxis", {
  44152. get: function() {
  44153. return 1 !== this._yAxisScale
  44154. },
  44155. set: function(e) {
  44156. this._yAxisScale = e ? -1 : 1
  44157. },
  44158. enumerable: !1,
  44159. configurable: !0
  44160. }),
  44161. e.prototype.attachControl = function() {
  44162. var e = this
  44163. , t = this.camera.getScene().gamepadManager;
  44164. this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
  44165. t.type !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
  44166. }
  44167. )),
  44168. this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
  44169. e.gamepad === t && (e.gamepad = null)
  44170. }
  44171. )),
  44172. this.gamepad = t.getGamepadByType(zo.XBOX)
  44173. }
  44174. ,
  44175. e.prototype.detachControl = function() {
  44176. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  44177. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  44178. this.gamepad = null
  44179. }
  44180. ,
  44181. e.prototype.checkInputs = function() {
  44182. if (this.gamepad) {
  44183. var e = this.camera
  44184. , t = this.gamepad.rightStick;
  44185. if (t) {
  44186. if (0 != t.x) {
  44187. var i = t.x / this.gamepadRotationSensibility;
  44188. 0 != i && Math.abs(i) > .005 && (e.inertialAlphaOffset += i)
  44189. }
  44190. if (0 != t.y) {
  44191. var n = t.y / this.gamepadRotationSensibility * this._yAxisScale;
  44192. 0 != n && Math.abs(n) > .005 && (e.inertialBetaOffset += n)
  44193. }
  44194. }
  44195. var r = this.gamepad.leftStick;
  44196. if (r && 0 != r.y) {
  44197. var o = r.y / this.gamepadMoveSensibility;
  44198. 0 != o && Math.abs(o) > .005 && (this.camera.inertialRadiusOffset -= o)
  44199. }
  44200. }
  44201. }
  44202. ,
  44203. e.prototype.getClassName = function() {
  44204. return "ArcRotateCameraGamepadInput"
  44205. }
  44206. ,
  44207. e.prototype.getSimpleName = function() {
  44208. return "gamepad"
  44209. }
  44210. ,
  44211. k([Ce()], e.prototype, "gamepadRotationSensibility", void 0),
  44212. k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
  44213. e
  44214. }();
  44215. Vo.ArcRotateCameraGamepadInput = Ho;
  44216. var Xo = function() {
  44217. function e() {
  44218. this.keysUp = [38],
  44219. this.keysDown = [40],
  44220. this.keysLeft = [37],
  44221. this.keysRight = [39],
  44222. this.keysReset = [220],
  44223. this.panningSensibility = 50,
  44224. this.zoomingSensibility = 25,
  44225. this.useAltToZoom = !0,
  44226. this.angularSpeed = .01,
  44227. this._keys = new Array
  44228. }
  44229. return e.prototype.attachControl = function(e) {
  44230. var t = this;
  44231. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44232. this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
  44233. this._engine = this._scene.getEngine(),
  44234. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
  44235. t._keys = []
  44236. }
  44237. )),
  44238. this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
  44239. var n, r = i.event;
  44240. r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
  44241. t._altPressed = r.altKey,
  44242. (-1 !== t.keysUp.indexOf(r.keyCode) || -1 !== t.keysDown.indexOf(r.keyCode) || -1 !== t.keysLeft.indexOf(r.keyCode) || -1 !== t.keysRight.indexOf(r.keyCode) || -1 !== t.keysReset.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
  44243. r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysReset.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
  44244. r.preventDefault && (e || r.preventDefault())))
  44245. }
  44246. )))
  44247. }
  44248. ,
  44249. e.prototype.detachControl = function() {
  44250. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  44251. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  44252. this._onKeyboardObserver = null,
  44253. this._onCanvasBlurObserver = null),
  44254. this._keys = []
  44255. }
  44256. ,
  44257. e.prototype.checkInputs = function() {
  44258. if (this._onKeyboardObserver)
  44259. for (var e = this.camera, t = 0; t < this._keys.length; t++) {
  44260. var i = this._keys[t];
  44261. -1 !== this.keysLeft.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX -= 1 / this.panningSensibility : e.inertialAlphaOffset -= this.angularSpeed : -1 !== this.keysUp.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset += 1 / this.zoomingSensibility : e.inertialBetaOffset -= this.angularSpeed : -1 !== this.keysRight.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX += 1 / this.panningSensibility : e.inertialAlphaOffset += this.angularSpeed : -1 !== this.keysDown.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset -= 1 / this.zoomingSensibility : e.inertialBetaOffset += this.angularSpeed : -1 !== this.keysReset.indexOf(i) && e.useInputToRestoreState && e.restoreState()
  44262. }
  44263. }
  44264. ,
  44265. e.prototype.getClassName = function() {
  44266. return "ArcRotateCameraKeyboardMoveInput"
  44267. }
  44268. ,
  44269. e.prototype.getSimpleName = function() {
  44270. return "keyboard"
  44271. }
  44272. ,
  44273. k([Ce()], e.prototype, "keysUp", void 0),
  44274. k([Ce()], e.prototype, "keysDown", void 0),
  44275. k([Ce()], e.prototype, "keysLeft", void 0),
  44276. k([Ce()], e.prototype, "keysRight", void 0),
  44277. k([Ce()], e.prototype, "keysReset", void 0),
  44278. k([Ce()], e.prototype, "panningSensibility", void 0),
  44279. k([Ce()], e.prototype, "zoomingSensibility", void 0),
  44280. k([Ce()], e.prototype, "useAltToZoom", void 0),
  44281. k([Ce()], e.prototype, "angularSpeed", void 0),
  44282. e
  44283. }();
  44284. Vo.ArcRotateCameraKeyboardMoveInput = Xo;
  44285. var jo = function() {
  44286. function e() {
  44287. this.wheelPrecision = 3,
  44288. this.zoomToMouseLocation = !1,
  44289. this.wheelDeltaPercentage = 0,
  44290. this.customComputeDeltaFromMouseWheel = null,
  44291. this._inertialPanning = x.Zero()
  44292. }
  44293. return e.prototype._computeDeltaFromMouseWheelLegacyEvent = function(e, t) {
  44294. var i = .01 * e * this.wheelDeltaPercentage * t;
  44295. return e > 0 ? i / (1 + this.wheelDeltaPercentage) : i * (1 + this.wheelDeltaPercentage)
  44296. }
  44297. ,
  44298. e.prototype.attachControl = function(e) {
  44299. var t = this;
  44300. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44301. this._wheel = function(i) {
  44302. if (i.type === Xi.POINTERWHEEL) {
  44303. var n, r = i.event, o = 0, a = r, s = r.deltaMode === $i.DOM_DELTA_LINE ? 40 : 1;
  44304. if (n = void 0 !== r.deltaY ? -r.deltaY * s : void 0 !== r.wheelDeltaY ? -r.wheelDeltaY * s : a.wheelDelta,
  44305. t.customComputeDeltaFromMouseWheel)
  44306. o = t.customComputeDeltaFromMouseWheel(n, t, r);
  44307. else if (t.wheelDeltaPercentage) {
  44308. if ((o = t._computeDeltaFromMouseWheelLegacyEvent(n, t.camera.radius)) > 0) {
  44309. for (var l = t.camera.radius, c = t.camera.inertialRadiusOffset + o, u = 0; u < 20 && Math.abs(c) > .001; u++)
  44310. l -= c,
  44311. c *= t.camera.inertia;
  44312. l = d.Clamp(l, 0, Number.MAX_VALUE),
  44313. o = t._computeDeltaFromMouseWheelLegacyEvent(n, l)
  44314. }
  44315. } else
  44316. o = n / (40 * t.wheelPrecision);
  44317. o && (t.zoomToMouseLocation && t._hitPlane ? t._zoomToMouse(o) : t.camera.inertialRadiusOffset += o),
  44318. r.preventDefault && (e || r.preventDefault())
  44319. }
  44320. }
  44321. ,
  44322. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL),
  44323. this.zoomToMouseLocation && this._inertialPanning.setAll(0)
  44324. }
  44325. ,
  44326. e.prototype.detachControl = function() {
  44327. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  44328. this._observer = null,
  44329. this._wheel = null)
  44330. }
  44331. ,
  44332. e.prototype.checkInputs = function() {
  44333. if (this.zoomToMouseLocation) {
  44334. var e = this.camera;
  44335. 0 + e.inertialAlphaOffset + e.inertialBetaOffset + e.inertialRadiusOffset && (this._updateHitPlane(),
  44336. e.target.addInPlace(this._inertialPanning),
  44337. this._inertialPanning.scaleInPlace(e.inertia),
  44338. this._zeroIfClose(this._inertialPanning))
  44339. }
  44340. }
  44341. ,
  44342. e.prototype.getClassName = function() {
  44343. return "ArcRotateCameraMouseWheelInput"
  44344. }
  44345. ,
  44346. e.prototype.getSimpleName = function() {
  44347. return "mousewheel"
  44348. }
  44349. ,
  44350. e.prototype._updateHitPlane = function() {
  44351. var e = this.camera
  44352. , t = e.target.subtract(e.position);
  44353. this._hitPlane = hn.FromPositionAndNormal(e.target, t)
  44354. }
  44355. ,
  44356. e.prototype._getPosition = function() {
  44357. var e, t = this.camera, i = t.getScene(), n = i.createPickingRay(i.pointerX, i.pointerY, P.Identity(), t, !1), r = 0;
  44358. return this._hitPlane && (r = null !== (e = n.intersectsPlane(this._hitPlane)) && void 0 !== e ? e : 0),
  44359. n.origin.addInPlace(n.direction.scaleInPlace(r))
  44360. }
  44361. ,
  44362. e.prototype._zoomToMouse = function(e) {
  44363. var t, i, n = this.camera, r = 1 - n.inertia;
  44364. if (n.lowerRadiusLimit) {
  44365. var o = null !== (t = n.lowerRadiusLimit) && void 0 !== t ? t : 0;
  44366. n.radius - (n.inertialRadiusOffset + e) / r < o && (e = (n.radius - o) * r - n.inertialRadiusOffset)
  44367. }
  44368. if (n.upperRadiusLimit) {
  44369. var a = null !== (i = n.upperRadiusLimit) && void 0 !== i ? i : 0;
  44370. n.radius - (n.inertialRadiusOffset + e) / r > a && (e = (n.radius - a) * r - n.inertialRadiusOffset)
  44371. }
  44372. var s = e / r / n.radius
  44373. , l = this._getPosition()
  44374. , c = I.Vector3[6];
  44375. l.subtractToRef(n.target, c),
  44376. c.scaleInPlace(s),
  44377. c.scaleInPlace(r),
  44378. this._inertialPanning.addInPlace(c),
  44379. n.inertialRadiusOffset += e
  44380. }
  44381. ,
  44382. e.prototype._zeroIfClose = function(e) {
  44383. Math.abs(e.x) < m && (e.x = 0),
  44384. Math.abs(e.y) < m && (e.y = 0),
  44385. Math.abs(e.z) < m && (e.z = 0)
  44386. }
  44387. ,
  44388. k([Ce()], e.prototype, "wheelPrecision", void 0),
  44389. k([Ce()], e.prototype, "zoomToMouseLocation", void 0),
  44390. k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
  44391. e
  44392. }();
  44393. Vo.ArcRotateCameraMouseWheelInput = jo;
  44394. var Yo = function(e) {
  44395. function t() {
  44396. var t = null !== e && e.apply(this, arguments) || this;
  44397. return t.buttons = [0, 1, 2],
  44398. t.angularSensibilityX = 1e3,
  44399. t.angularSensibilityY = 1e3,
  44400. t.pinchPrecision = 12,
  44401. t.pinchDeltaPercentage = 0,
  44402. t.useNaturalPinchZoom = !1,
  44403. t.pinchZoom = !0,
  44404. t.panningSensibility = 1e3,
  44405. t.multiTouchPanning = !0,
  44406. t.multiTouchPanAndZoom = !0,
  44407. t.pinchInwards = !0,
  44408. t._isPanClick = !1,
  44409. t._twoFingerActivityCount = 0,
  44410. t._isPinching = !1,
  44411. t
  44412. }
  44413. return U(t, e),
  44414. t.prototype.getClassName = function() {
  44415. return "ArcRotateCameraPointersInput"
  44416. }
  44417. ,
  44418. t.prototype._computeMultiTouchPanning = function(e, t) {
  44419. if (0 !== this.panningSensibility && e && t) {
  44420. var i = t.x - e.x
  44421. , n = t.y - e.y;
  44422. this.camera.inertialPanningX += -i / this.panningSensibility,
  44423. this.camera.inertialPanningY += n / this.panningSensibility
  44424. }
  44425. }
  44426. ,
  44427. t.prototype._computePinchZoom = function(e, i) {
  44428. var n = this.camera.radius || t.MinimumRadiusForPinch;
  44429. this.useNaturalPinchZoom ? this.camera.radius = n * Math.sqrt(e) / Math.sqrt(i) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += .001 * (i - e) * n * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (i - e) / (this.pinchPrecision * (this.pinchInwards ? 1 : -1) * (this.angularSensibilityX + this.angularSensibilityY) / 2)
  44430. }
  44431. ,
  44432. t.prototype.onTouch = function(e, t, i) {
  44433. 0 !== this.panningSensibility && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -t / this.panningSensibility,
  44434. this.camera.inertialPanningY += i / this.panningSensibility) : (this.camera.inertialAlphaOffset -= t / this.angularSensibilityX,
  44435. this.camera.inertialBetaOffset -= i / this.angularSensibilityY)
  44436. }
  44437. ,
  44438. t.prototype.onDoubleTap = function() {
  44439. this.camera.useInputToRestoreState && this.camera.restoreState()
  44440. }
  44441. ,
  44442. t.prototype.onMultiTouch = function(e, t, i, n, r, o) {
  44443. 0 === i && null === r || 0 === n && null === o || (this.multiTouchPanAndZoom ? (this._computePinchZoom(i, n),
  44444. this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
  44445. this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(n) - Math.sqrt(i)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(i, n),
  44446. this._isPinching = !0) : this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning ? this._computeMultiTouchPanning(r, o) : this.pinchZoom && this._computePinchZoom(i, n))
  44447. }
  44448. ,
  44449. t.prototype.onButtonDown = function(e) {
  44450. this._isPanClick = e.button === this.camera._panningMouseButton
  44451. }
  44452. ,
  44453. t.prototype.onButtonUp = function() {
  44454. this._twoFingerActivityCount = 0,
  44455. this._isPinching = !1
  44456. }
  44457. ,
  44458. t.prototype.onLostFocus = function() {
  44459. this._isPanClick = !1,
  44460. this._twoFingerActivityCount = 0,
  44461. this._isPinching = !1
  44462. }
  44463. ,
  44464. t.MinimumRadiusForPinch = .001,
  44465. k([Ce()], t.prototype, "buttons", void 0),
  44466. k([Ce()], t.prototype, "angularSensibilityX", void 0),
  44467. k([Ce()], t.prototype, "angularSensibilityY", void 0),
  44468. k([Ce()], t.prototype, "pinchPrecision", void 0),
  44469. k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
  44470. k([Ce()], t.prototype, "useNaturalPinchZoom", void 0),
  44471. k([Ce()], t.prototype, "pinchZoom", void 0),
  44472. k([Ce()], t.prototype, "panningSensibility", void 0),
  44473. k([Ce()], t.prototype, "multiTouchPanning", void 0),
  44474. k([Ce()], t.prototype, "multiTouchPanAndZoom", void 0),
  44475. t
  44476. }(Uo);
  44477. Vo.ArcRotateCameraPointersInput = Yo;
  44478. var Ko = function(e) {
  44479. function t(t) {
  44480. return e.call(this, t) || this
  44481. }
  44482. return U(t, e),
  44483. t.prototype.addMouseWheel = function() {
  44484. return this.add(new jo),
  44485. this
  44486. }
  44487. ,
  44488. t.prototype.addPointers = function() {
  44489. return this.add(new Yo),
  44490. this
  44491. }
  44492. ,
  44493. t.prototype.addKeyboard = function() {
  44494. return this.add(new Xo),
  44495. this
  44496. }
  44497. ,
  44498. t
  44499. }(ko);
  44500. Ko.prototype.addVRDeviceOrientation = function() {
  44501. return this.add(new Qo),
  44502. this
  44503. }
  44504. ;
  44505. var Qo = function() {
  44506. function e() {
  44507. this.alphaCorrection = 1,
  44508. this.gammaCorrection = 1,
  44509. this._alpha = 0,
  44510. this._gamma = 0,
  44511. this._dirty = !1,
  44512. this._deviceOrientationHandler = this._onOrientationEvent.bind(this)
  44513. }
  44514. return e.prototype.attachControl = function(e) {
  44515. var t = this;
  44516. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44517. this.camera.attachControl(e);
  44518. var i = this.camera.getScene().getEngine().getHostWindow();
  44519. i && ("undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
  44520. "granted" === e ? i.addEventListener("deviceorientation", t._deviceOrientationHandler) : gi.Warn("Permission not granted.")
  44521. }
  44522. )).catch((function(e) {
  44523. gi.Error(e)
  44524. }
  44525. )) : i.addEventListener("deviceorientation", this._deviceOrientationHandler))
  44526. }
  44527. ,
  44528. e.prototype._onOrientationEvent = function(e) {
  44529. null !== e.alpha && (this._alpha = (0 | +e.alpha) * this.alphaCorrection),
  44530. null !== e.gamma && (this._gamma = (0 | +e.gamma) * this.gammaCorrection),
  44531. this._dirty = !0
  44532. }
  44533. ,
  44534. e.prototype.checkInputs = function() {
  44535. this._dirty && (this._dirty = !1,
  44536. this._gamma < 0 && (this._gamma = 180 + this._gamma),
  44537. this.camera.alpha = -this._alpha / 180 * Math.PI % Math.PI * 2,
  44538. this.camera.beta = this._gamma / 180 * Math.PI)
  44539. }
  44540. ,
  44541. e.prototype.detachControl = function() {
  44542. window.removeEventListener("deviceorientation", this._deviceOrientationHandler)
  44543. }
  44544. ,
  44545. e.prototype.getClassName = function() {
  44546. return "ArcRotateCameraVRDeviceOrientationInput"
  44547. }
  44548. ,
  44549. e.prototype.getSimpleName = function() {
  44550. return "VRDeviceOrientation"
  44551. }
  44552. ,
  44553. e
  44554. }();
  44555. Vo.ArcRotateCameraVRDeviceOrientationInput = Qo;
  44556. var qo = function() {
  44557. function e() {
  44558. this.keysForward = [87],
  44559. this.keysBackward = [83],
  44560. this.keysUp = [69],
  44561. this.keysDown = [81],
  44562. this.keysRight = [68],
  44563. this.keysLeft = [65],
  44564. this._keys = new Array
  44565. }
  44566. return e.prototype.attachControl = function(e) {
  44567. var t = this;
  44568. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44569. this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
  44570. this._engine = this._scene.getEngine(),
  44571. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
  44572. t._keys = []
  44573. }
  44574. )),
  44575. this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
  44576. var n, r = i.event;
  44577. i.type === Qi.KEYDOWN ? -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
  44578. e || r.preventDefault()) : -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
  44579. e || r.preventDefault())
  44580. }
  44581. )))
  44582. }
  44583. ,
  44584. e.prototype.detachControl = function() {
  44585. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  44586. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  44587. this._onKeyboardObserver = null,
  44588. this._onCanvasBlurObserver = null),
  44589. this._keys = []
  44590. }
  44591. ,
  44592. e.prototype.getClassName = function() {
  44593. return "FlyCameraKeyboardInput"
  44594. }
  44595. ,
  44596. e.prototype._onLostFocus = function() {
  44597. this._keys = []
  44598. }
  44599. ,
  44600. e.prototype.getSimpleName = function() {
  44601. return "keyboard"
  44602. }
  44603. ,
  44604. e.prototype.checkInputs = function() {
  44605. if (this._onKeyboardObserver)
  44606. for (var e = this.camera, t = 0; t < this._keys.length; t++) {
  44607. var i = this._keys[t]
  44608. , n = e._computeLocalCameraSpeed();
  44609. -1 !== this.keysForward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysBackward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 0) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysLeft.indexOf(i) && e._localDirection.copyFromFloats(-n, 0, 0),
  44610. e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
  44611. e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
  44612. x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
  44613. e.cameraDirection.addInPlace(e._transformedDirection)
  44614. }
  44615. }
  44616. ,
  44617. k([Ce()], e.prototype, "keysForward", void 0),
  44618. k([Ce()], e.prototype, "keysBackward", void 0),
  44619. k([Ce()], e.prototype, "keysUp", void 0),
  44620. k([Ce()], e.prototype, "keysDown", void 0),
  44621. k([Ce()], e.prototype, "keysRight", void 0),
  44622. k([Ce()], e.prototype, "keysLeft", void 0),
  44623. e
  44624. }();
  44625. Vo.FlyCameraKeyboardInput = qo;
  44626. var Zo = function() {
  44627. function e() {
  44628. this.buttons = [0, 1, 2],
  44629. this.buttonsYaw = [-1, 0, 1],
  44630. this.buttonsPitch = [-1, 0, 1],
  44631. this.buttonsRoll = [2],
  44632. this.activeButton = -1,
  44633. this.angularSensibility = 1e3,
  44634. this._previousPosition = null
  44635. }
  44636. return e.prototype.attachControl = function(e) {
  44637. var t = this;
  44638. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44639. this._noPreventDefault = e,
  44640. this._observer = this.camera.getScene().onPointerObservable.add((function(e) {
  44641. t._pointerInput(e)
  44642. }
  44643. ), Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
  44644. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add((function() {
  44645. t.camera.rollCorrect && t.camera.restoreRoll(t.camera.rollCorrect)
  44646. }
  44647. ))
  44648. }
  44649. ,
  44650. e.prototype.detachControl = function() {
  44651. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  44652. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),
  44653. this._observer = null,
  44654. this._rollObserver = null,
  44655. this._previousPosition = null,
  44656. this._noPreventDefault = void 0)
  44657. }
  44658. ,
  44659. e.prototype.getClassName = function() {
  44660. return "FlyCameraMouseInput"
  44661. }
  44662. ,
  44663. e.prototype.getSimpleName = function() {
  44664. return "mouse"
  44665. }
  44666. ,
  44667. e.prototype._pointerInput = function(e) {
  44668. var t = e.event
  44669. , i = this.camera.getEngine();
  44670. if (!i.isInVRExclusivePointerMode && (this.touchEnabled || "touch" !== t.pointerType) && (e.type === Xi.POINTERMOVE || -1 !== this.buttons.indexOf(t.button))) {
  44671. var n = t.srcElement || t.target;
  44672. if (e.type === Xi.POINTERDOWN) {
  44673. try {
  44674. null == n || n.setPointerCapture(t.pointerId)
  44675. } catch (t) {}
  44676. this._previousPosition = {
  44677. x: t.clientX,
  44678. y: t.clientY
  44679. },
  44680. this.activeButton = t.button,
  44681. this._noPreventDefault || (t.preventDefault(),
  44682. this._element.focus()),
  44683. i.isPointerLock && this._onMouseMove(e.event)
  44684. } else if (e.type === Xi.POINTERUP) {
  44685. try {
  44686. null == n || n.releasePointerCapture(t.pointerId)
  44687. } catch (t) {}
  44688. this.activeButton = -1,
  44689. this._previousPosition = null,
  44690. this._noPreventDefault || t.preventDefault()
  44691. } else if (e.type === Xi.POINTERMOVE) {
  44692. if (!this._previousPosition)
  44693. return void (i.isPointerLock && this._onMouseMove(e.event));
  44694. var r = t.clientX - this._previousPosition.x
  44695. , o = t.clientY - this._previousPosition.y;
  44696. this._rotateCamera(r, o),
  44697. this._previousPosition = {
  44698. x: t.clientX,
  44699. y: t.clientY
  44700. },
  44701. this._noPreventDefault || t.preventDefault()
  44702. }
  44703. }
  44704. }
  44705. ,
  44706. e.prototype._onMouseMove = function(e) {
  44707. var t = this.camera.getEngine();
  44708. if (t.isPointerLock && !t.isInVRExclusivePointerMode) {
  44709. var i = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0
  44710. , n = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  44711. this._rotateCamera(i, n),
  44712. this._previousPosition = null,
  44713. this._noPreventDefault || e.preventDefault()
  44714. }
  44715. }
  44716. ,
  44717. e.prototype._rotateCamera = function(e, t) {
  44718. var i = this
  44719. , n = this.camera;
  44720. this.camera.getScene().useRightHandedSystem && (e *= -1),
  44721. n.parent && n.parent._getWorldMatrixDeterminant() < 0 && (e *= -1);
  44722. var r, o = e / this.angularSensibility, a = t / this.angularSensibility, s = C.RotationYawPitchRoll(n.rotation.y, n.rotation.x, n.rotation.z);
  44723. if (this.buttonsPitch.some((function(e) {
  44724. return e === i.activeButton
  44725. }
  44726. )) && (r = C.RotationAxis(vn.X, a),
  44727. s.multiplyInPlace(r)),
  44728. this.buttonsYaw.some((function(e) {
  44729. return e === i.activeButton
  44730. }
  44731. ))) {
  44732. r = C.RotationAxis(vn.Y, o),
  44733. s.multiplyInPlace(r);
  44734. var l = n.bankedTurnLimit + n._trackRoll;
  44735. if (n.bankedTurn && -l < n.rotation.z && n.rotation.z < l) {
  44736. var c = n.bankedTurnMultiplier * -o;
  44737. r = C.RotationAxis(vn.Z, c),
  44738. s.multiplyInPlace(r)
  44739. }
  44740. }
  44741. this.buttonsRoll.some((function(e) {
  44742. return e === i.activeButton
  44743. }
  44744. )) && (r = C.RotationAxis(vn.Z, -o),
  44745. n._trackRoll -= o,
  44746. s.multiplyInPlace(r)),
  44747. s.toEulerAnglesToRef(n.rotation)
  44748. }
  44749. ,
  44750. k([Ce()], e.prototype, "buttons", void 0),
  44751. k([Ce()], e.prototype, "angularSensibility", void 0),
  44752. e
  44753. }();
  44754. Vo.FlyCameraMouseInput = Zo;
  44755. var Jo = function() {
  44756. function e() {
  44757. this.keysHeightOffsetIncr = [38],
  44758. this.keysHeightOffsetDecr = [40],
  44759. this.keysHeightOffsetModifierAlt = !1,
  44760. this.keysHeightOffsetModifierCtrl = !1,
  44761. this.keysHeightOffsetModifierShift = !1,
  44762. this.keysRotationOffsetIncr = [37],
  44763. this.keysRotationOffsetDecr = [39],
  44764. this.keysRotationOffsetModifierAlt = !1,
  44765. this.keysRotationOffsetModifierCtrl = !1,
  44766. this.keysRotationOffsetModifierShift = !1,
  44767. this.keysRadiusIncr = [40],
  44768. this.keysRadiusDecr = [38],
  44769. this.keysRadiusModifierAlt = !0,
  44770. this.keysRadiusModifierCtrl = !1,
  44771. this.keysRadiusModifierShift = !1,
  44772. this.heightSensibility = 1,
  44773. this.rotationSensibility = 1,
  44774. this.radiusSensibility = 1,
  44775. this._keys = new Array
  44776. }
  44777. return e.prototype.attachControl = function(e) {
  44778. var t = this;
  44779. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44780. this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
  44781. this._engine = this._scene.getEngine(),
  44782. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
  44783. t._keys = []
  44784. }
  44785. )),
  44786. this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
  44787. var n, r = i.event;
  44788. r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
  44789. t._altPressed = r.altKey,
  44790. t._shiftPressed = r.shiftKey,
  44791. (-1 !== t.keysHeightOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysHeightOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRadiusIncr.indexOf(r.keyCode) || -1 !== t.keysRadiusDecr.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
  44792. r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysHeightOffsetIncr.indexOf(r.keyCode) && -1 === t.keysHeightOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetIncr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRadiusIncr.indexOf(r.keyCode) && -1 === t.keysRadiusDecr.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
  44793. r.preventDefault && (e || r.preventDefault())))
  44794. }
  44795. )))
  44796. }
  44797. ,
  44798. e.prototype.detachControl = function() {
  44799. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  44800. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  44801. this._onKeyboardObserver = null,
  44802. this._onCanvasBlurObserver = null),
  44803. this._keys = []
  44804. }
  44805. ,
  44806. e.prototype.checkInputs = function() {
  44807. var e = this;
  44808. this._onKeyboardObserver && this._keys.forEach((function(t) {
  44809. -1 !== e.keysHeightOffsetIncr.indexOf(t) && e._modifierHeightOffset() ? e.camera.heightOffset += e.heightSensibility : -1 !== e.keysHeightOffsetDecr.indexOf(t) && e._modifierHeightOffset() ? e.camera.heightOffset -= e.heightSensibility : -1 !== e.keysRotationOffsetIncr.indexOf(t) && e._modifierRotationOffset() ? (e.camera.rotationOffset += e.rotationSensibility,
  44810. e.camera.rotationOffset %= 360) : -1 !== e.keysRotationOffsetDecr.indexOf(t) && e._modifierRotationOffset() ? (e.camera.rotationOffset -= e.rotationSensibility,
  44811. e.camera.rotationOffset %= 360) : -1 !== e.keysRadiusIncr.indexOf(t) && e._modifierRadius() ? e.camera.radius += e.radiusSensibility : -1 !== e.keysRadiusDecr.indexOf(t) && e._modifierRadius() && (e.camera.radius -= e.radiusSensibility)
  44812. }
  44813. ))
  44814. }
  44815. ,
  44816. e.prototype.getClassName = function() {
  44817. return "FollowCameraKeyboardMoveInput"
  44818. }
  44819. ,
  44820. e.prototype.getSimpleName = function() {
  44821. return "keyboard"
  44822. }
  44823. ,
  44824. e.prototype._modifierHeightOffset = function() {
  44825. return this.keysHeightOffsetModifierAlt === this._altPressed && this.keysHeightOffsetModifierCtrl === this._ctrlPressed && this.keysHeightOffsetModifierShift === this._shiftPressed
  44826. }
  44827. ,
  44828. e.prototype._modifierRotationOffset = function() {
  44829. return this.keysRotationOffsetModifierAlt === this._altPressed && this.keysRotationOffsetModifierCtrl === this._ctrlPressed && this.keysRotationOffsetModifierShift === this._shiftPressed
  44830. }
  44831. ,
  44832. e.prototype._modifierRadius = function() {
  44833. return this.keysRadiusModifierAlt === this._altPressed && this.keysRadiusModifierCtrl === this._ctrlPressed && this.keysRadiusModifierShift === this._shiftPressed
  44834. }
  44835. ,
  44836. k([Ce()], e.prototype, "keysHeightOffsetIncr", void 0),
  44837. k([Ce()], e.prototype, "keysHeightOffsetDecr", void 0),
  44838. k([Ce()], e.prototype, "keysHeightOffsetModifierAlt", void 0),
  44839. k([Ce()], e.prototype, "keysHeightOffsetModifierCtrl", void 0),
  44840. k([Ce()], e.prototype, "keysHeightOffsetModifierShift", void 0),
  44841. k([Ce()], e.prototype, "keysRotationOffsetIncr", void 0),
  44842. k([Ce()], e.prototype, "keysRotationOffsetDecr", void 0),
  44843. k([Ce()], e.prototype, "keysRotationOffsetModifierAlt", void 0),
  44844. k([Ce()], e.prototype, "keysRotationOffsetModifierCtrl", void 0),
  44845. k([Ce()], e.prototype, "keysRotationOffsetModifierShift", void 0),
  44846. k([Ce()], e.prototype, "keysRadiusIncr", void 0),
  44847. k([Ce()], e.prototype, "keysRadiusDecr", void 0),
  44848. k([Ce()], e.prototype, "keysRadiusModifierAlt", void 0),
  44849. k([Ce()], e.prototype, "keysRadiusModifierCtrl", void 0),
  44850. k([Ce()], e.prototype, "keysRadiusModifierShift", void 0),
  44851. k([Ce()], e.prototype, "heightSensibility", void 0),
  44852. k([Ce()], e.prototype, "rotationSensibility", void 0),
  44853. k([Ce()], e.prototype, "radiusSensibility", void 0),
  44854. e
  44855. }();
  44856. Vo.FollowCameraKeyboardMoveInput = Jo;
  44857. var $o = function() {
  44858. function e() {
  44859. this.axisControlRadius = !0,
  44860. this.axisControlHeight = !1,
  44861. this.axisControlRotation = !1,
  44862. this.wheelPrecision = 3,
  44863. this.wheelDeltaPercentage = 0
  44864. }
  44865. return e.prototype.attachControl = function(e) {
  44866. var t = this;
  44867. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44868. this._wheel = function(i) {
  44869. if (i.type === Xi.POINTERWHEEL) {
  44870. var n = i.event
  44871. , r = 0
  44872. , o = Math.max(-1, Math.min(1, n.deltaY || n.wheelDelta || -n.detail));
  44873. t.wheelDeltaPercentage ? (console.assert(t.axisControlRadius + t.axisControlHeight + t.axisControlRotation <= 1, "wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: " + t.axisControlRadius + ", axisControlHeightOffset: " + t.axisControlHeight + ", axisControlRotationOffset: " + t.axisControlRotation),
  44874. t.axisControlRadius ? r = .01 * o * t.wheelDeltaPercentage * t.camera.radius : t.axisControlHeight ? r = .01 * o * t.wheelDeltaPercentage * t.camera.heightOffset : t.axisControlRotation && (r = .01 * o * t.wheelDeltaPercentage * t.camera.rotationOffset)) : r = o * t.wheelPrecision,
  44875. r && (t.axisControlRadius ? t.camera.radius += r : t.axisControlHeight ? t.camera.heightOffset -= r : t.axisControlRotation && (t.camera.rotationOffset -= r)),
  44876. n.preventDefault && (e || n.preventDefault())
  44877. }
  44878. }
  44879. ,
  44880. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
  44881. }
  44882. ,
  44883. e.prototype.detachControl = function() {
  44884. this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  44885. this._observer = null,
  44886. this._wheel = null)
  44887. }
  44888. ,
  44889. e.prototype.getClassName = function() {
  44890. return "ArcRotateCameraMouseWheelInput"
  44891. }
  44892. ,
  44893. e.prototype.getSimpleName = function() {
  44894. return "mousewheel"
  44895. }
  44896. ,
  44897. k([Ce()], e.prototype, "axisControlRadius", void 0),
  44898. k([Ce()], e.prototype, "axisControlHeight", void 0),
  44899. k([Ce()], e.prototype, "axisControlRotation", void 0),
  44900. k([Ce()], e.prototype, "wheelPrecision", void 0),
  44901. k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
  44902. e
  44903. }();
  44904. Vo.FollowCameraMouseWheelInput = $o;
  44905. var ea = function(e) {
  44906. function t() {
  44907. var t = null !== e && e.apply(this, arguments) || this;
  44908. return t.angularSensibilityX = 1,
  44909. t.angularSensibilityY = 1,
  44910. t.pinchPrecision = 1e4,
  44911. t.pinchDeltaPercentage = 0,
  44912. t.axisXControlRadius = !1,
  44913. t.axisXControlHeight = !1,
  44914. t.axisXControlRotation = !0,
  44915. t.axisYControlRadius = !1,
  44916. t.axisYControlHeight = !0,
  44917. t.axisYControlRotation = !1,
  44918. t.axisPinchControlRadius = !0,
  44919. t.axisPinchControlHeight = !1,
  44920. t.axisPinchControlRotation = !1,
  44921. t.warningEnable = !0,
  44922. t._warningCounter = 0,
  44923. t
  44924. }
  44925. return U(t, e),
  44926. t.prototype.getClassName = function() {
  44927. return "FollowCameraPointersInput"
  44928. }
  44929. ,
  44930. t.prototype.onTouch = function(e, t, i) {
  44931. this._warning(),
  44932. this.axisXControlRotation ? this.camera.rotationOffset += t / this.angularSensibilityX : this.axisYControlRotation && (this.camera.rotationOffset += i / this.angularSensibilityX),
  44933. this.axisXControlHeight ? this.camera.heightOffset += t / this.angularSensibilityY : this.axisYControlHeight && (this.camera.heightOffset += i / this.angularSensibilityY),
  44934. this.axisXControlRadius ? this.camera.radius -= t / this.angularSensibilityY : this.axisYControlRadius && (this.camera.radius -= i / this.angularSensibilityY)
  44935. }
  44936. ,
  44937. t.prototype.onMultiTouch = function(e, t, i, n, r, o) {
  44938. if (!(0 === i && null === r || 0 === n && null === o)) {
  44939. var a = (n - i) / (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  44940. this.pinchDeltaPercentage ? (a *= .01 * this.pinchDeltaPercentage,
  44941. this.axisPinchControlRotation && (this.camera.rotationOffset += a * this.camera.rotationOffset),
  44942. this.axisPinchControlHeight && (this.camera.heightOffset += a * this.camera.heightOffset),
  44943. this.axisPinchControlRadius && (this.camera.radius -= a * this.camera.radius)) : (this.axisPinchControlRotation && (this.camera.rotationOffset += a),
  44944. this.axisPinchControlHeight && (this.camera.heightOffset += a),
  44945. this.axisPinchControlRadius && (this.camera.radius -= a))
  44946. }
  44947. }
  44948. ,
  44949. t.prototype._warning = function() {
  44950. if (this.warningEnable && this._warningCounter++ % 100 == 0) {
  44951. var e = "It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";
  44952. console.assert(this.axisXControlRotation + this.axisXControlHeight + this.axisXControlRadius <= 1, e + "axisXControlRotation: " + this.axisXControlRotation + ", axisXControlHeight: " + this.axisXControlHeight + ", axisXControlRadius: " + this.axisXControlRadius),
  44953. console.assert(this.axisYControlRotation + this.axisYControlHeight + this.axisYControlRadius <= 1, e + "axisYControlRotation: " + this.axisYControlRotation + ", axisYControlHeight: " + this.axisYControlHeight + ", axisYControlRadius: " + this.axisYControlRadius),
  44954. console.assert(this.axisPinchControlRotation + this.axisPinchControlHeight + this.axisPinchControlRadius <= 1, e + "axisPinchControlRotation: " + this.axisPinchControlRotation + ", axisPinchControlHeight: " + this.axisPinchControlHeight + ", axisPinchControlRadius: " + this.axisPinchControlRadius)
  44955. }
  44956. }
  44957. ,
  44958. k([Ce()], t.prototype, "angularSensibilityX", void 0),
  44959. k([Ce()], t.prototype, "angularSensibilityY", void 0),
  44960. k([Ce()], t.prototype, "pinchPrecision", void 0),
  44961. k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
  44962. k([Ce()], t.prototype, "axisXControlRadius", void 0),
  44963. k([Ce()], t.prototype, "axisXControlHeight", void 0),
  44964. k([Ce()], t.prototype, "axisXControlRotation", void 0),
  44965. k([Ce()], t.prototype, "axisYControlRadius", void 0),
  44966. k([Ce()], t.prototype, "axisYControlHeight", void 0),
  44967. k([Ce()], t.prototype, "axisYControlRotation", void 0),
  44968. k([Ce()], t.prototype, "axisPinchControlRadius", void 0),
  44969. k([Ce()], t.prototype, "axisPinchControlHeight", void 0),
  44970. k([Ce()], t.prototype, "axisPinchControlRotation", void 0),
  44971. t
  44972. }(Uo);
  44973. Vo.FollowCameraPointersInput = ea;
  44974. var ta = function() {
  44975. function e() {
  44976. this.keysUp = [38],
  44977. this.keysUpward = [33],
  44978. this.keysDown = [40],
  44979. this.keysDownward = [34],
  44980. this.keysLeft = [37],
  44981. this.keysRight = [39],
  44982. this.rotationSpeed = .5,
  44983. this.keysRotateLeft = [],
  44984. this.keysRotateRight = [],
  44985. this._keys = new Array
  44986. }
  44987. return e.prototype.attachControl = function(e) {
  44988. var t = this;
  44989. e = gi.BackCompatCameraNoPreventDefault(arguments),
  44990. this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
  44991. this._engine = this._scene.getEngine(),
  44992. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
  44993. t._keys = []
  44994. }
  44995. )),
  44996. this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
  44997. var n, r = i.event;
  44998. r.metaKey || (i.type === Qi.KEYDOWN ? -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
  44999. e || r.preventDefault()) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
  45000. e || r.preventDefault()))
  45001. }
  45002. )))
  45003. }
  45004. ,
  45005. e.prototype.detachControl = function() {
  45006. this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
  45007. this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
  45008. this._onKeyboardObserver = null,
  45009. this._onCanvasBlurObserver = null),
  45010. this._keys = []
  45011. }
  45012. ,
  45013. e.prototype.checkInputs = function() {
  45014. if (this._onKeyboardObserver)
  45015. for (var e = this.camera, t = 0; t < this._keys.length; t++) {
  45016. var i = this._keys[t]
  45017. , n = e._computeLocalCameraSpeed();
  45018. -1 !== this.keysLeft.indexOf(i) ? e._localDirection.copyFromFloats(-n, 0, 0) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUpward.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDownward.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 0) : -1 !== this.keysRotateLeft.indexOf(i) ? (e._localDirection.copyFromFloats(0, 0, 0),
  45019. e.cameraRotation.y -= this._getLocalRotation()) : -1 !== this.keysRotateRight.indexOf(i) && (e._localDirection.copyFromFloats(0, 0, 0),
  45020. e.cameraRotation.y += this._getLocalRotation()),
  45021. e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
  45022. e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
  45023. x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
  45024. e.cameraDirection.addInPlace(e._transformedDirection)
  45025. }
  45026. }
  45027. ,
  45028. e.prototype.getClassName = function() {
  45029. return "FreeCameraKeyboardMoveInput"
  45030. }
  45031. ,
  45032. e.prototype._onLostFocus = function() {
  45033. this._keys = []
  45034. }
  45035. ,
  45036. e.prototype.getSimpleName = function() {
  45037. return "keyboard"
  45038. }
  45039. ,
  45040. e.prototype._getLocalRotation = function() {
  45041. var e = this.rotationSpeed * this._engine.getDeltaTime() / 1e3;
  45042. return this.camera.getScene().useRightHandedSystem && (e *= -1),
  45043. this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0 && (e *= -1),
  45044. e
  45045. }
  45046. ,
  45047. k([Ce()], e.prototype, "keysUp", void 0),
  45048. k([Ce()], e.prototype, "keysUpward", void 0),
  45049. k([Ce()], e.prototype, "keysDown", void 0),
  45050. k([Ce()], e.prototype, "keysDownward", void 0),
  45051. k([Ce()], e.prototype, "keysLeft", void 0),
  45052. k([Ce()], e.prototype, "keysRight", void 0),
  45053. k([Ce()], e.prototype, "rotationSpeed", void 0),
  45054. k([Ce()], e.prototype, "keysRotateLeft", void 0),
  45055. k([Ce()], e.prototype, "keysRotateRight", void 0),
  45056. e
  45057. }();
  45058. Vo.FreeCameraKeyboardMoveInput = ta;
  45059. var ia, na = function() {
  45060. function e(e) {
  45061. void 0 === e && (e = !0),
  45062. this.touchEnabled = e,
  45063. this.buttons = [0, 1, 2],
  45064. this.angularSensibility = 2e3,
  45065. this._previousPosition = null,
  45066. this.onPointerMovedObservable = new h,
  45067. this._allowCameraRotation = !0,
  45068. this._currentActiveButton = -1
  45069. }
  45070. return e.prototype.attachControl = function(e) {
  45071. var t = this;
  45072. e = gi.BackCompatCameraNoPreventDefault(arguments);
  45073. var i = this.camera.getEngine()
  45074. , n = i.getInputElement();
  45075. this._pointerInput || (this._pointerInput = function(r) {
  45076. var o = r.event
  45077. , a = "touch" === o.pointerType;
  45078. if (!i.isInVRExclusivePointerMode && (t.touchEnabled || !a) && (r.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(o.button))) {
  45079. var s = o.srcElement || o.target;
  45080. if (r.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !a)
  45081. if (r.type !== Xi.POINTERUP || t._currentActiveButton !== o.button && !a) {
  45082. if (r.type === Xi.POINTERMOVE)
  45083. if (i.isPointerLock && t._onMouseMove)
  45084. t._onMouseMove(r.event);
  45085. else if (t._previousPosition) {
  45086. var l = o.clientX - t._previousPosition.x
  45087. , c = o.clientY - t._previousPosition.y;
  45088. t.camera.getScene().useRightHandedSystem && (l *= -1),
  45089. t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (l *= -1),
  45090. t._allowCameraRotation && (t.camera.cameraRotation.y += l / t.angularSensibility,
  45091. t.camera.cameraRotation.x += c / t.angularSensibility),
  45092. t.onPointerMovedObservable.notifyObservers({
  45093. offsetX: l,
  45094. offsetY: c
  45095. }),
  45096. t._previousPosition = {
  45097. x: o.clientX,
  45098. y: o.clientY
  45099. },
  45100. e || o.preventDefault()
  45101. }
  45102. } else {
  45103. try {
  45104. null == s || s.releasePointerCapture(o.pointerId)
  45105. } catch (e) {}
  45106. t._currentActiveButton = -1,
  45107. t._previousPosition = null,
  45108. e || o.preventDefault()
  45109. }
  45110. else {
  45111. try {
  45112. null == s || s.setPointerCapture(o.pointerId)
  45113. } catch (e) {}
  45114. -1 === t._currentActiveButton && (t._currentActiveButton = o.button),
  45115. t._previousPosition = {
  45116. x: o.clientX,
  45117. y: o.clientY
  45118. },
  45119. e || (o.preventDefault(),
  45120. n && n.focus()),
  45121. i.isPointerLock && t._onMouseMove && t._onMouseMove(r.event)
  45122. }
  45123. }
  45124. }
  45125. ),
  45126. this._onMouseMove = function(n) {
  45127. if (i.isPointerLock && !i.isInVRExclusivePointerMode) {
  45128. var r = n.movementX || n.mozMovementX || n.webkitMovementX || n.msMovementX || 0;
  45129. t.camera.getScene().useRightHandedSystem && (r *= -1),
  45130. t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (r *= -1),
  45131. t.camera.cameraRotation.y += r / t.angularSensibility;
  45132. var o = n.movementY || n.mozMovementY || n.webkitMovementY || n.msMovementY || 0;
  45133. t.camera.cameraRotation.x += o / t.angularSensibility,
  45134. t._previousPosition = null,
  45135. e || n.preventDefault()
  45136. }
  45137. }
  45138. ,
  45139. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
  45140. n && (this._contextMenuBind = this.onContextMenu.bind(this),
  45141. n.addEventListener("contextmenu", this._contextMenuBind, !1))
  45142. }
  45143. ,
  45144. e.prototype.onContextMenu = function(e) {
  45145. e.preventDefault()
  45146. }
  45147. ,
  45148. e.prototype.detachControl = function() {
  45149. if (this._observer) {
  45150. if (this.camera.getScene().onPointerObservable.remove(this._observer),
  45151. this._contextMenuBind) {
  45152. var e = this.camera.getEngine().getInputElement();
  45153. e && e.removeEventListener("contextmenu", this._contextMenuBind)
  45154. }
  45155. this.onPointerMovedObservable && this.onPointerMovedObservable.clear(),
  45156. this._observer = null,
  45157. this._onMouseMove = null,
  45158. this._previousPosition = null
  45159. }
  45160. }
  45161. ,
  45162. e.prototype.getClassName = function() {
  45163. return "FreeCameraMouseInput"
  45164. }
  45165. ,
  45166. e.prototype.getSimpleName = function() {
  45167. return "mouse"
  45168. }
  45169. ,
  45170. k([Ce()], e.prototype, "buttons", void 0),
  45171. k([Ce()], e.prototype, "angularSensibility", void 0),
  45172. e
  45173. }();
  45174. Vo.FreeCameraMouseInput = na,
  45175. function(e) {
  45176. e[e.MoveRelative = 0] = "MoveRelative",
  45177. e[e.RotateRelative = 1] = "RotateRelative",
  45178. e[e.MoveScene = 2] = "MoveScene"
  45179. }(ia || (ia = {}));
  45180. var ra = function(e) {
  45181. function t() {
  45182. var t = null !== e && e.apply(this, arguments) || this;
  45183. return t._moveRelative = x.Zero(),
  45184. t._rotateRelative = x.Zero(),
  45185. t._moveScene = x.Zero(),
  45186. t._wheelXAction = ia.MoveRelative,
  45187. t._wheelXActionCoordinate = gn.X,
  45188. t._wheelYAction = ia.MoveRelative,
  45189. t._wheelYActionCoordinate = gn.Z,
  45190. t._wheelZAction = null,
  45191. t._wheelZActionCoordinate = null,
  45192. t
  45193. }
  45194. return U(t, e),
  45195. t.prototype.getClassName = function() {
  45196. return "FreeCameraMouseWheelInput"
  45197. }
  45198. ,
  45199. Object.defineProperty(t.prototype, "wheelXMoveRelative", {
  45200. get: function() {
  45201. return this._wheelXAction !== ia.MoveRelative ? null : this._wheelXActionCoordinate
  45202. },
  45203. set: function(e) {
  45204. null === e && this._wheelXAction !== ia.MoveRelative || (this._wheelXAction = ia.MoveRelative,
  45205. this._wheelXActionCoordinate = e)
  45206. },
  45207. enumerable: !1,
  45208. configurable: !0
  45209. }),
  45210. Object.defineProperty(t.prototype, "wheelYMoveRelative", {
  45211. get: function() {
  45212. return this._wheelYAction !== ia.MoveRelative ? null : this._wheelYActionCoordinate
  45213. },
  45214. set: function(e) {
  45215. null === e && this._wheelYAction !== ia.MoveRelative || (this._wheelYAction = ia.MoveRelative,
  45216. this._wheelYActionCoordinate = e)
  45217. },
  45218. enumerable: !1,
  45219. configurable: !0
  45220. }),
  45221. Object.defineProperty(t.prototype, "wheelZMoveRelative", {
  45222. get: function() {
  45223. return this._wheelZAction !== ia.MoveRelative ? null : this._wheelZActionCoordinate
  45224. },
  45225. set: function(e) {
  45226. null === e && this._wheelZAction !== ia.MoveRelative || (this._wheelZAction = ia.MoveRelative,
  45227. this._wheelZActionCoordinate = e)
  45228. },
  45229. enumerable: !1,
  45230. configurable: !0
  45231. }),
  45232. Object.defineProperty(t.prototype, "wheelXRotateRelative", {
  45233. get: function() {
  45234. return this._wheelXAction !== ia.RotateRelative ? null : this._wheelXActionCoordinate
  45235. },
  45236. set: function(e) {
  45237. null === e && this._wheelXAction !== ia.RotateRelative || (this._wheelXAction = ia.RotateRelative,
  45238. this._wheelXActionCoordinate = e)
  45239. },
  45240. enumerable: !1,
  45241. configurable: !0
  45242. }),
  45243. Object.defineProperty(t.prototype, "wheelYRotateRelative", {
  45244. get: function() {
  45245. return this._wheelYAction !== ia.RotateRelative ? null : this._wheelYActionCoordinate
  45246. },
  45247. set: function(e) {
  45248. null === e && this._wheelYAction !== ia.RotateRelative || (this._wheelYAction = ia.RotateRelative,
  45249. this._wheelYActionCoordinate = e)
  45250. },
  45251. enumerable: !1,
  45252. configurable: !0
  45253. }),
  45254. Object.defineProperty(t.prototype, "wheelZRotateRelative", {
  45255. get: function() {
  45256. return this._wheelZAction !== ia.RotateRelative ? null : this._wheelZActionCoordinate
  45257. },
  45258. set: function(e) {
  45259. null === e && this._wheelZAction !== ia.RotateRelative || (this._wheelZAction = ia.RotateRelative,
  45260. this._wheelZActionCoordinate = e)
  45261. },
  45262. enumerable: !1,
  45263. configurable: !0
  45264. }),
  45265. Object.defineProperty(t.prototype, "wheelXMoveScene", {
  45266. get: function() {
  45267. return this._wheelXAction !== ia.MoveScene ? null : this._wheelXActionCoordinate
  45268. },
  45269. set: function(e) {
  45270. null === e && this._wheelXAction !== ia.MoveScene || (this._wheelXAction = ia.MoveScene,
  45271. this._wheelXActionCoordinate = e)
  45272. },
  45273. enumerable: !1,
  45274. configurable: !0
  45275. }),
  45276. Object.defineProperty(t.prototype, "wheelYMoveScene", {
  45277. get: function() {
  45278. return this._wheelYAction !== ia.MoveScene ? null : this._wheelYActionCoordinate
  45279. },
  45280. set: function(e) {
  45281. null === e && this._wheelYAction !== ia.MoveScene || (this._wheelYAction = ia.MoveScene,
  45282. this._wheelYActionCoordinate = e)
  45283. },
  45284. enumerable: !1,
  45285. configurable: !0
  45286. }),
  45287. Object.defineProperty(t.prototype, "wheelZMoveScene", {
  45288. get: function() {
  45289. return this._wheelZAction !== ia.MoveScene ? null : this._wheelZActionCoordinate
  45290. },
  45291. set: function(e) {
  45292. null === e && this._wheelZAction !== ia.MoveScene || (this._wheelZAction = ia.MoveScene,
  45293. this._wheelZActionCoordinate = e)
  45294. },
  45295. enumerable: !1,
  45296. configurable: !0
  45297. }),
  45298. t.prototype.checkInputs = function() {
  45299. if (0 !== this._wheelDeltaX || 0 !== this._wheelDeltaY || 0 != this._wheelDeltaZ) {
  45300. this._moveRelative.setAll(0),
  45301. this._rotateRelative.setAll(0),
  45302. this._moveScene.setAll(0),
  45303. this._updateCamera(),
  45304. this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
  45305. var t = P.Zero();
  45306. this.camera.getViewMatrix().invertToRef(t);
  45307. var i = x.Zero();
  45308. x.TransformNormalToRef(this._moveRelative, t, i),
  45309. this.camera.cameraRotation.x += this._rotateRelative.x / 200,
  45310. this.camera.cameraRotation.y += this._rotateRelative.y / 200,
  45311. this.camera.cameraDirection.addInPlace(i),
  45312. this.camera.cameraDirection.addInPlace(this._moveScene),
  45313. e.prototype.checkInputs.call(this)
  45314. }
  45315. }
  45316. ,
  45317. t.prototype._updateCamera = function() {
  45318. this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate),
  45319. this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate),
  45320. this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate)
  45321. }
  45322. ,
  45323. t.prototype._updateCameraProperty = function(e, t, i) {
  45324. if (0 !== e && null !== t && null !== i) {
  45325. var n = null;
  45326. switch (t) {
  45327. case ia.MoveRelative:
  45328. n = this._moveRelative;
  45329. break;
  45330. case ia.RotateRelative:
  45331. n = this._rotateRelative;
  45332. break;
  45333. case ia.MoveScene:
  45334. n = this._moveScene
  45335. }
  45336. switch (i) {
  45337. case gn.X:
  45338. n.set(e, 0, 0);
  45339. break;
  45340. case gn.Y:
  45341. n.set(0, e, 0);
  45342. break;
  45343. case gn.Z:
  45344. n.set(0, 0, e)
  45345. }
  45346. }
  45347. }
  45348. ,
  45349. k([Ce()], t.prototype, "wheelXMoveRelative", null),
  45350. k([Ce()], t.prototype, "wheelYMoveRelative", null),
  45351. k([Ce()], t.prototype, "wheelZMoveRelative", null),
  45352. k([Ce()], t.prototype, "wheelXRotateRelative", null),
  45353. k([Ce()], t.prototype, "wheelYRotateRelative", null),
  45354. k([Ce()], t.prototype, "wheelZRotateRelative", null),
  45355. k([Ce()], t.prototype, "wheelXMoveScene", null),
  45356. k([Ce()], t.prototype, "wheelYMoveScene", null),
  45357. k([Ce()], t.prototype, "wheelZMoveScene", null),
  45358. t
  45359. }(Bo);
  45360. Vo.FreeCameraMouseWheelInput = ra;
  45361. var oa = function() {
  45362. function e(e) {
  45363. void 0 === e && (e = !1),
  45364. this.allowMouse = e,
  45365. this.touchAngularSensibility = 2e5,
  45366. this.touchMoveSensibility = 250,
  45367. this.singleFingerRotate = !1,
  45368. this._offsetX = null,
  45369. this._offsetY = null,
  45370. this._pointerPressed = new Array
  45371. }
  45372. return e.prototype.attachControl = function(e) {
  45373. var t = this;
  45374. e = gi.BackCompatCameraNoPreventDefault(arguments);
  45375. var i = null;
  45376. if (void 0 === this._pointerInput && (this._onLostFocus = function() {
  45377. t._offsetX = null,
  45378. t._offsetY = null
  45379. }
  45380. ,
  45381. this._pointerInput = function(n) {
  45382. var r = n.event
  45383. , o = !t.camera.getEngine().hostInformation.isMobile && r instanceof MouseEvent;
  45384. if (t.allowMouse || "mouse" !== r.pointerType && !o)
  45385. if (n.type === Xi.POINTERDOWN) {
  45386. if (e || r.preventDefault(),
  45387. t._pointerPressed.push(r.pointerId),
  45388. 1 !== t._pointerPressed.length)
  45389. return;
  45390. i = {
  45391. x: r.clientX,
  45392. y: r.clientY
  45393. }
  45394. } else if (n.type === Xi.POINTERUP) {
  45395. if (e || r.preventDefault(),
  45396. -1 === (a = t._pointerPressed.indexOf(r.pointerId)))
  45397. return;
  45398. if (t._pointerPressed.splice(a, 1),
  45399. 0 != a)
  45400. return;
  45401. i = null,
  45402. t._offsetX = null,
  45403. t._offsetY = null
  45404. } else if (n.type === Xi.POINTERMOVE) {
  45405. if (e || r.preventDefault(),
  45406. !i)
  45407. return;
  45408. var a;
  45409. if (0 != (a = t._pointerPressed.indexOf(r.pointerId)))
  45410. return;
  45411. t._offsetX = r.clientX - i.x,
  45412. t._offsetY = -(r.clientY - i.y)
  45413. }
  45414. }
  45415. ),
  45416. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
  45417. this._onLostFocus) {
  45418. var n = this.camera.getEngine()
  45419. , r = n.getInputElement();
  45420. r && r.addEventListener("blur", this._onLostFocus)
  45421. }
  45422. }
  45423. ,
  45424. e.prototype.detachControl = function() {
  45425. if (this._pointerInput) {
  45426. if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
  45427. this._observer = null),
  45428. this._onLostFocus) {
  45429. var e = this.camera.getEngine().getInputElement();
  45430. e && e.removeEventListener("blur", this._onLostFocus),
  45431. this._onLostFocus = null
  45432. }
  45433. this._pointerPressed = [],
  45434. this._offsetX = null,
  45435. this._offsetY = null
  45436. }
  45437. }
  45438. ,
  45439. e.prototype.checkInputs = function() {
  45440. if (null !== this._offsetX && null !== this._offsetY && (0 !== this._offsetX || 0 !== this._offsetY)) {
  45441. var e = this.camera;
  45442. if (e.cameraRotation.y = this._offsetX / this.touchAngularSensibility,
  45443. this.singleFingerRotate && 1 === this._pointerPressed.length || !this.singleFingerRotate && this._pointerPressed.length > 1)
  45444. e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
  45445. else {
  45446. var t = e._computeLocalCameraSpeed()
  45447. , i = new x(0,0,t * this._offsetY / this.touchMoveSensibility);
  45448. P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
  45449. e.cameraDirection.addInPlace(x.TransformCoordinates(i, e._cameraRotationMatrix))
  45450. }
  45451. }
  45452. }
  45453. ,
  45454. e.prototype.getClassName = function() {
  45455. return "FreeCameraTouchInput"
  45456. }
  45457. ,
  45458. e.prototype.getSimpleName = function() {
  45459. return "touch"
  45460. }
  45461. ,
  45462. k([Ce()], e.prototype, "touchAngularSensibility", void 0),
  45463. k([Ce()], e.prototype, "touchMoveSensibility", void 0),
  45464. e
  45465. }();
  45466. Vo.FreeCameraTouchInput = oa;
  45467. var aa = function(e) {
  45468. function t(t) {
  45469. var i = e.call(this, t) || this;
  45470. return i._mouseInput = null,
  45471. i._mouseWheelInput = null,
  45472. i
  45473. }
  45474. return U(t, e),
  45475. t.prototype.addKeyboard = function() {
  45476. return this.add(new ta),
  45477. this
  45478. }
  45479. ,
  45480. t.prototype.addMouse = function(e) {
  45481. return void 0 === e && (e = !0),
  45482. this._mouseInput || (this._mouseInput = new na(e),
  45483. this.add(this._mouseInput)),
  45484. this
  45485. }
  45486. ,
  45487. t.prototype.removeMouse = function() {
  45488. return this._mouseInput && this.remove(this._mouseInput),
  45489. this
  45490. }
  45491. ,
  45492. t.prototype.addMouseWheel = function() {
  45493. return this._mouseWheelInput || (this._mouseWheelInput = new ra,
  45494. this.add(this._mouseWheelInput)),
  45495. this
  45496. }
  45497. ,
  45498. t.prototype.removeMouseWheel = function() {
  45499. return this._mouseWheelInput && this.remove(this._mouseWheelInput),
  45500. this
  45501. }
  45502. ,
  45503. t.prototype.addTouch = function() {
  45504. return this.add(new oa),
  45505. this
  45506. }
  45507. ,
  45508. t.prototype.clear = function() {
  45509. e.prototype.clear.call(this),
  45510. this._mouseInput = null
  45511. }
  45512. ,
  45513. t
  45514. }(ko);
  45515. aa.prototype.addDeviceOrientation = function() {
  45516. return this._deviceOrientationInput || (this._deviceOrientationInput = new sa,
  45517. this.add(this._deviceOrientationInput)),
  45518. this
  45519. }
  45520. ;
  45521. var sa = function() {
  45522. function e() {
  45523. var e = this;
  45524. this._screenOrientationAngle = 0,
  45525. this._screenQuaternion = new C,
  45526. this._alpha = 0,
  45527. this._beta = 0,
  45528. this._gamma = 0,
  45529. this._onDeviceOrientationChangedObservable = new h,
  45530. this._orientationChanged = function() {
  45531. e._screenOrientationAngle = void 0 !== window.orientation ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0,
  45532. e._screenOrientationAngle = -gi.ToRadians(e._screenOrientationAngle / 2),
  45533. e._screenQuaternion.copyFromFloats(0, Math.sin(e._screenOrientationAngle), 0, Math.cos(e._screenOrientationAngle))
  45534. }
  45535. ,
  45536. this._deviceOrientation = function(t) {
  45537. e._alpha = null !== t.alpha ? t.alpha : 0,
  45538. e._beta = null !== t.beta ? t.beta : 0,
  45539. e._gamma = null !== t.gamma ? t.gamma : 0,
  45540. null !== t.alpha && e._onDeviceOrientationChangedObservable.notifyObservers()
  45541. }
  45542. ,
  45543. this._constantTranform = new C(-Math.sqrt(.5),0,0,Math.sqrt(.5)),
  45544. this._orientationChanged()
  45545. }
  45546. return e.WaitForOrientationChangeAsync = function(e) {
  45547. return new Promise((function(t, i) {
  45548. var n = !1
  45549. , r = function() {
  45550. window.removeEventListener("deviceorientation", r),
  45551. n = !0,
  45552. t()
  45553. };
  45554. e && setTimeout((function() {
  45555. n || (window.removeEventListener("deviceorientation", r),
  45556. i("WaitForOrientationChangeAsync timed out"))
  45557. }
  45558. ), e),
  45559. "undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
  45560. "granted" == e ? window.addEventListener("deviceorientation", r) : gi.Warn("Permission not granted.")
  45561. }
  45562. )).catch((function(e) {
  45563. gi.Error(e)
  45564. }
  45565. )) : window.addEventListener("deviceorientation", r)
  45566. }
  45567. ))
  45568. }
  45569. ,
  45570. Object.defineProperty(e.prototype, "camera", {
  45571. get: function() {
  45572. return this._camera
  45573. },
  45574. set: function(e) {
  45575. var t = this;
  45576. this._camera = e,
  45577. null == this._camera || this._camera.rotationQuaternion || (this._camera.rotationQuaternion = new C),
  45578. this._camera && this._camera.onDisposeObservable.add((function() {
  45579. t._onDeviceOrientationChangedObservable.clear()
  45580. }
  45581. ))
  45582. },
  45583. enumerable: !1,
  45584. configurable: !0
  45585. }),
  45586. e.prototype.attachControl = function() {
  45587. var e = this
  45588. , t = this.camera.getScene().getEngine().getHostWindow();
  45589. if (t) {
  45590. var i = function() {
  45591. t.addEventListener("orientationchange", e._orientationChanged),
  45592. t.addEventListener("deviceorientation", e._deviceOrientation),
  45593. e._orientationChanged()
  45594. };
  45595. "undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
  45596. "granted" === e ? i() : gi.Warn("Permission not granted.")
  45597. }
  45598. )).catch((function(e) {
  45599. gi.Error(e)
  45600. }
  45601. )) : i()
  45602. }
  45603. }
  45604. ,
  45605. e.prototype.detachControl = function() {
  45606. window.removeEventListener("orientationchange", this._orientationChanged),
  45607. window.removeEventListener("deviceorientation", this._deviceOrientation),
  45608. this._alpha = 0
  45609. }
  45610. ,
  45611. e.prototype.checkInputs = function() {
  45612. this._alpha && (C.RotationYawPitchRollToRef(gi.ToRadians(this._alpha), gi.ToRadians(this._beta), -gi.ToRadians(this._gamma), this.camera.rotationQuaternion),
  45613. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),
  45614. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),
  45615. this._camera.rotationQuaternion.z *= -1,
  45616. this._camera.rotationQuaternion.w *= -1)
  45617. }
  45618. ,
  45619. e.prototype.getClassName = function() {
  45620. return "FreeCameraDeviceOrientationInput"
  45621. }
  45622. ,
  45623. e.prototype.getSimpleName = function() {
  45624. return "deviceOrientation"
  45625. }
  45626. ,
  45627. e
  45628. }();
  45629. Vo.FreeCameraDeviceOrientationInput = sa;
  45630. var la, ca = function() {
  45631. function e() {
  45632. this.gamepadAngularSensibility = 200,
  45633. this.gamepadMoveSensibility = 40,
  45634. this.deadzoneDelta = .1,
  45635. this._yAxisScale = 1,
  45636. this._cameraTransform = P.Identity(),
  45637. this._deltaTransform = x.Zero(),
  45638. this._vector3 = x.Zero(),
  45639. this._vector2 = A.Zero()
  45640. }
  45641. return Object.defineProperty(e.prototype, "invertYAxis", {
  45642. get: function() {
  45643. return 1 !== this._yAxisScale
  45644. },
  45645. set: function(e) {
  45646. this._yAxisScale = e ? -1 : 1
  45647. },
  45648. enumerable: !1,
  45649. configurable: !0
  45650. }),
  45651. e.prototype.attachControl = function() {
  45652. var e = this
  45653. , t = this.camera.getScene().gamepadManager;
  45654. this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
  45655. t.type !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
  45656. }
  45657. )),
  45658. this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
  45659. e.gamepad === t && (e.gamepad = null)
  45660. }
  45661. )),
  45662. this.gamepad = t.getGamepadByType(zo.XBOX),
  45663. !this.gamepad && t.gamepads.length && (this.gamepad = t.gamepads[0])
  45664. }
  45665. ,
  45666. e.prototype.detachControl = function() {
  45667. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  45668. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  45669. this.gamepad = null
  45670. }
  45671. ,
  45672. e.prototype.checkInputs = function() {
  45673. if (this.gamepad && this.gamepad.leftStick) {
  45674. var e = this.camera
  45675. , t = this.gamepad.leftStick;
  45676. 0 !== this.gamepadMoveSensibility && (t.x = Math.abs(t.x) > this.deadzoneDelta ? t.x / this.gamepadMoveSensibility : 0,
  45677. t.y = Math.abs(t.y) > this.deadzoneDelta ? t.y / this.gamepadMoveSensibility : 0);
  45678. var i = this.gamepad.rightStick;
  45679. i && 0 !== this.gamepadAngularSensibility ? (i.x = Math.abs(i.x) > this.deadzoneDelta ? i.x / this.gamepadAngularSensibility : 0,
  45680. i.y = (Math.abs(i.y) > this.deadzoneDelta ? i.y / this.gamepadAngularSensibility : 0) * this._yAxisScale) : i = {
  45681. x: 0,
  45682. y: 0
  45683. },
  45684. e.rotationQuaternion ? e.rotationQuaternion.toRotationMatrix(this._cameraTransform) : P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, this._cameraTransform);
  45685. var n = 50 * e._computeLocalCameraSpeed();
  45686. this._vector3.copyFromFloats(t.x * n, 0, -t.y * n),
  45687. x.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform),
  45688. e.cameraDirection.addInPlace(this._deltaTransform),
  45689. this._vector2.copyFromFloats(i.y, i.x),
  45690. e.cameraRotation.addInPlace(this._vector2)
  45691. }
  45692. }
  45693. ,
  45694. e.prototype.getClassName = function() {
  45695. return "FreeCameraGamepadInput"
  45696. }
  45697. ,
  45698. e.prototype.getSimpleName = function() {
  45699. return "gamepad"
  45700. }
  45701. ,
  45702. k([Ce()], e.prototype, "gamepadAngularSensibility", void 0),
  45703. k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
  45704. e
  45705. }();
  45706. Vo.FreeCameraGamepadInput = ca,
  45707. function(e) {
  45708. e[e.X = 0] = "X",
  45709. e[e.Y = 1] = "Y",
  45710. e[e.Z = 2] = "Z"
  45711. }(la || (la = {}));
  45712. var ua = function() {
  45713. function e(t, i) {
  45714. var n = this
  45715. , r = V(V({}, e._GetDefaultOptions()), i);
  45716. if (this._leftJoystick = !!t,
  45717. e._GlobalJoystickIndex++,
  45718. this._axisTargetedByLeftAndRight = la.X,
  45719. this._axisTargetedByUpAndDown = la.Y,
  45720. this.reverseLeftRight = !1,
  45721. this.reverseUpDown = !1,
  45722. this._touches = new Ei,
  45723. this.deltaPosition = x.Zero(),
  45724. this._joystickSensibility = 25,
  45725. this._inversedSensibility = 1 / (this._joystickSensibility / 1e3),
  45726. this._onResize = function() {
  45727. e._VJCanvasWidth = window.innerWidth,
  45728. e._VJCanvasHeight = window.innerHeight,
  45729. e.Canvas && (e.Canvas.width = e._VJCanvasWidth,
  45730. e.Canvas.height = e._VJCanvasHeight),
  45731. e._HalfWidth = e._VJCanvasWidth / 2
  45732. }
  45733. ,
  45734. !e.Canvas) {
  45735. window.addEventListener("resize", this._onResize, !1),
  45736. e.Canvas = document.createElement("canvas"),
  45737. e._VJCanvasWidth = window.innerWidth,
  45738. e._VJCanvasHeight = window.innerHeight,
  45739. e.Canvas.width = window.innerWidth,
  45740. e.Canvas.height = window.innerHeight,
  45741. e.Canvas.style.width = "100%",
  45742. e.Canvas.style.height = "100%",
  45743. e.Canvas.style.position = "absolute",
  45744. e.Canvas.style.backgroundColor = "transparent",
  45745. e.Canvas.style.top = "0px",
  45746. e.Canvas.style.left = "0px",
  45747. e.Canvas.style.zIndex = "5",
  45748. e.Canvas.style.msTouchAction = "none",
  45749. e.Canvas.style.touchAction = "none",
  45750. e.Canvas.setAttribute("touch-action", "none");
  45751. var o = e.Canvas.getContext("2d");
  45752. if (!o)
  45753. throw new Error("Unable to create canvas for virtual joystick");
  45754. e._VJCanvasContext = o,
  45755. e._VJCanvasContext.strokeStyle = "#ffffff",
  45756. e._VJCanvasContext.lineWidth = 2,
  45757. document.body.appendChild(e.Canvas)
  45758. }
  45759. e._HalfWidth = e.Canvas.width / 2,
  45760. this.pressed = !1,
  45761. this.limitToContainer = r.limitToContainer,
  45762. this._joystickColor = r.color,
  45763. this.containerSize = r.containerSize,
  45764. this.puckSize = r.puckSize,
  45765. r.position && this.setPosition(r.position.x, r.position.y),
  45766. r.puckImage && this.setPuckImage(r.puckImage),
  45767. r.containerImage && this.setContainerImage(r.containerImage),
  45768. r.alwaysVisible && e._AlwaysVisibleSticks++,
  45769. this.alwaysVisible = r.alwaysVisible,
  45770. this._joystickPointerId = -1,
  45771. this._joystickPointerPos = new A(0,0),
  45772. this._joystickPreviousPointerPos = new A(0,0),
  45773. this._joystickPointerStartPos = new A(0,0),
  45774. this._deltaJoystickVector = new A(0,0),
  45775. this._onPointerDownHandlerRef = function(e) {
  45776. n._onPointerDown(e)
  45777. }
  45778. ,
  45779. this._onPointerMoveHandlerRef = function(e) {
  45780. n._onPointerMove(e)
  45781. }
  45782. ,
  45783. this._onPointerUpHandlerRef = function(e) {
  45784. n._onPointerUp(e)
  45785. }
  45786. ,
  45787. e.Canvas.addEventListener("pointerdown", this._onPointerDownHandlerRef, !1),
  45788. e.Canvas.addEventListener("pointermove", this._onPointerMoveHandlerRef, !1),
  45789. e.Canvas.addEventListener("pointerup", this._onPointerUpHandlerRef, !1),
  45790. e.Canvas.addEventListener("pointerout", this._onPointerUpHandlerRef, !1),
  45791. e.Canvas.addEventListener("contextmenu", (function(e) {
  45792. e.preventDefault()
  45793. }
  45794. ), !1),
  45795. requestAnimationFrame((function() {
  45796. n._drawVirtualJoystick()
  45797. }
  45798. ))
  45799. }
  45800. return e._GetDefaultOptions = function() {
  45801. return {
  45802. puckSize: 40,
  45803. containerSize: 60,
  45804. color: "cyan",
  45805. puckImage: void 0,
  45806. containerImage: void 0,
  45807. position: void 0,
  45808. alwaysVisible: !1,
  45809. limitToContainer: !1
  45810. }
  45811. }
  45812. ,
  45813. e.prototype.setJoystickSensibility = function(e) {
  45814. this._joystickSensibility = e,
  45815. this._inversedSensibility = 1 / (this._joystickSensibility / 1e3)
  45816. }
  45817. ,
  45818. e.prototype._onPointerDown = function(t) {
  45819. t.preventDefault(),
  45820. (!0 === this._leftJoystick ? t.clientX < e._HalfWidth : t.clientX > e._HalfWidth) && this._joystickPointerId < 0 ? (this._joystickPointerId = t.pointerId,
  45821. this._joystickPosition ? (this._joystickPointerStartPos = this._joystickPosition.clone(),
  45822. this._joystickPointerPos = this._joystickPosition.clone(),
  45823. this._joystickPreviousPointerPos = this._joystickPosition.clone(),
  45824. this._onPointerMove(t)) : (this._joystickPointerStartPos.x = t.clientX,
  45825. this._joystickPointerStartPos.y = t.clientY,
  45826. this._joystickPointerPos = this._joystickPointerStartPos.clone(),
  45827. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone()),
  45828. this._deltaJoystickVector.x = 0,
  45829. this._deltaJoystickVector.y = 0,
  45830. this.pressed = !0,
  45831. this._touches.add(t.pointerId.toString(), t)) : e._GlobalJoystickIndex < 2 && this._action && (this._action(),
  45832. this._touches.add(t.pointerId.toString(), {
  45833. x: t.clientX,
  45834. y: t.clientY,
  45835. prevX: t.clientX,
  45836. prevY: t.clientY
  45837. }))
  45838. }
  45839. ,
  45840. e.prototype._onPointerMove = function(t) {
  45841. if (this._joystickPointerId == t.pointerId) {
  45842. if (this.limitToContainer) {
  45843. var i = new A(t.clientX - this._joystickPointerStartPos.x,t.clientY - this._joystickPointerStartPos.y)
  45844. , n = i.length();
  45845. n > this.containerSize && i.scaleInPlace(this.containerSize / n),
  45846. this._joystickPointerPos.x = this._joystickPointerStartPos.x + i.x,
  45847. this._joystickPointerPos.y = this._joystickPointerStartPos.y + i.y
  45848. } else
  45849. this._joystickPointerPos.x = t.clientX,
  45850. this._joystickPointerPos.y = t.clientY;
  45851. this._deltaJoystickVector = this._joystickPointerPos.clone(),
  45852. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos),
  45853. 0 < e._AlwaysVisibleSticks && (this._leftJoystick ? this._joystickPointerPos.x = Math.min(e._HalfWidth, this._joystickPointerPos.x) : this._joystickPointerPos.x = Math.max(e._HalfWidth, this._joystickPointerPos.x));
  45854. var r = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility;
  45855. switch (this._axisTargetedByLeftAndRight) {
  45856. case la.X:
  45857. this.deltaPosition.x = Math.min(1, Math.max(-1, r));
  45858. break;
  45859. case la.Y:
  45860. this.deltaPosition.y = Math.min(1, Math.max(-1, r));
  45861. break;
  45862. case la.Z:
  45863. this.deltaPosition.z = Math.min(1, Math.max(-1, r))
  45864. }
  45865. var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility;
  45866. switch (this._axisTargetedByUpAndDown) {
  45867. case la.X:
  45868. this.deltaPosition.x = Math.min(1, Math.max(-1, o));
  45869. break;
  45870. case la.Y:
  45871. this.deltaPosition.y = Math.min(1, Math.max(-1, o));
  45872. break;
  45873. case la.Z:
  45874. this.deltaPosition.z = Math.min(1, Math.max(-1, o))
  45875. }
  45876. } else {
  45877. var a = this._touches.get(t.pointerId.toString());
  45878. a && (a.x = t.clientX,
  45879. a.y = t.clientY)
  45880. }
  45881. }
  45882. ,
  45883. e.prototype._onPointerUp = function(t) {
  45884. if (this._joystickPointerId == t.pointerId)
  45885. this._clearPreviousDraw(),
  45886. this._joystickPointerId = -1,
  45887. this.pressed = !1;
  45888. else {
  45889. var i = this._touches.get(t.pointerId.toString());
  45890. i && e._VJCanvasContext.clearRect(i.prevX - 44, i.prevY - 44, 88, 88)
  45891. }
  45892. this._deltaJoystickVector.x = 0,
  45893. this._deltaJoystickVector.y = 0,
  45894. this._touches.remove(t.pointerId.toString())
  45895. }
  45896. ,
  45897. e.prototype.setJoystickColor = function(e) {
  45898. this._joystickColor = e
  45899. }
  45900. ,
  45901. Object.defineProperty(e.prototype, "containerSize", {
  45902. get: function() {
  45903. return this._joystickContainerSize
  45904. },
  45905. set: function(e) {
  45906. this._joystickContainerSize = e,
  45907. this._clearContainerSize = ~~(2.1 * this._joystickContainerSize),
  45908. this._clearContainerSizeOffset = ~~(this._clearContainerSize / 2)
  45909. },
  45910. enumerable: !1,
  45911. configurable: !0
  45912. }),
  45913. Object.defineProperty(e.prototype, "puckSize", {
  45914. get: function() {
  45915. return this._joystickPuckSize
  45916. },
  45917. set: function(e) {
  45918. this._joystickPuckSize = e,
  45919. this._clearPuckSize = ~~(2.1 * this._joystickPuckSize),
  45920. this._clearPuckSizeOffset = ~~(this._clearPuckSize / 2)
  45921. },
  45922. enumerable: !1,
  45923. configurable: !0
  45924. }),
  45925. e.prototype.clearPosition = function() {
  45926. this.alwaysVisible = !1,
  45927. this._joystickPosition = null
  45928. }
  45929. ,
  45930. Object.defineProperty(e.prototype, "alwaysVisible", {
  45931. get: function() {
  45932. return this._alwaysVisible
  45933. },
  45934. set: function(t) {
  45935. this._alwaysVisible !== t && (t && this._joystickPosition ? (e._AlwaysVisibleSticks++,
  45936. this._alwaysVisible = !0) : (e._AlwaysVisibleSticks--,
  45937. this._alwaysVisible = !1))
  45938. },
  45939. enumerable: !1,
  45940. configurable: !0
  45941. }),
  45942. e.prototype.setPosition = function(e, t) {
  45943. this._joystickPointerStartPos && this._clearPreviousDraw(),
  45944. this._joystickPosition = new A(e,t)
  45945. }
  45946. ,
  45947. e.prototype.setActionOnTouch = function(e) {
  45948. this._action = e
  45949. }
  45950. ,
  45951. e.prototype.setAxisForLeftRight = function(e) {
  45952. switch (e) {
  45953. case la.X:
  45954. case la.Y:
  45955. case la.Z:
  45956. this._axisTargetedByLeftAndRight = e;
  45957. break;
  45958. default:
  45959. this._axisTargetedByLeftAndRight = la.X
  45960. }
  45961. }
  45962. ,
  45963. e.prototype.setAxisForUpDown = function(e) {
  45964. switch (e) {
  45965. case la.X:
  45966. case la.Y:
  45967. case la.Z:
  45968. this._axisTargetedByUpAndDown = e;
  45969. break;
  45970. default:
  45971. this._axisTargetedByUpAndDown = la.Y
  45972. }
  45973. }
  45974. ,
  45975. e.prototype._clearPreviousDraw = function() {
  45976. var t = this._joystickPosition || this._joystickPointerStartPos;
  45977. e._VJCanvasContext.clearRect(t.x - this._clearContainerSizeOffset, t.y - this._clearContainerSizeOffset, this._clearContainerSize, this._clearContainerSize),
  45978. e._VJCanvasContext.clearRect(this._joystickPreviousPointerPos.x - this._clearPuckSizeOffset, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset, this._clearPuckSize, this._clearPuckSize)
  45979. }
  45980. ,
  45981. e.prototype.setContainerImage = function(e) {
  45982. var t = this
  45983. , i = new Image;
  45984. i.src = e,
  45985. i.onload = function() {
  45986. return t._containerImage = i
  45987. }
  45988. }
  45989. ,
  45990. e.prototype.setPuckImage = function(e) {
  45991. var t = this
  45992. , i = new Image;
  45993. i.src = e,
  45994. i.onload = function() {
  45995. return t._puckImage = i
  45996. }
  45997. }
  45998. ,
  45999. e.prototype._drawContainer = function() {
  46000. var t = this._joystickPosition || this._joystickPointerStartPos;
  46001. this._clearPreviousDraw(),
  46002. this._containerImage ? e._VJCanvasContext.drawImage(this._containerImage, t.x - this.containerSize, t.y - this.containerSize, 2 * this.containerSize, 2 * this.containerSize) : (e._VJCanvasContext.beginPath(),
  46003. e._VJCanvasContext.strokeStyle = this._joystickColor,
  46004. e._VJCanvasContext.lineWidth = 2,
  46005. e._VJCanvasContext.arc(t.x, t.y, this.containerSize, 0, 2 * Math.PI, !0),
  46006. e._VJCanvasContext.stroke(),
  46007. e._VJCanvasContext.closePath(),
  46008. e._VJCanvasContext.beginPath(),
  46009. e._VJCanvasContext.lineWidth = 6,
  46010. e._VJCanvasContext.strokeStyle = this._joystickColor,
  46011. e._VJCanvasContext.arc(t.x, t.y, this.puckSize, 0, 2 * Math.PI, !0),
  46012. e._VJCanvasContext.stroke(),
  46013. e._VJCanvasContext.closePath())
  46014. }
  46015. ,
  46016. e.prototype._drawPuck = function() {
  46017. this._puckImage ? e._VJCanvasContext.drawImage(this._puckImage, this._joystickPointerPos.x - this.puckSize, this._joystickPointerPos.y - this.puckSize, 2 * this.puckSize, 2 * this.puckSize) : (e._VJCanvasContext.beginPath(),
  46018. e._VJCanvasContext.strokeStyle = this._joystickColor,
  46019. e._VJCanvasContext.lineWidth = 2,
  46020. e._VJCanvasContext.arc(this._joystickPointerPos.x, this._joystickPointerPos.y, this.puckSize, 0, 2 * Math.PI, !0),
  46021. e._VJCanvasContext.stroke(),
  46022. e._VJCanvasContext.closePath())
  46023. }
  46024. ,
  46025. e.prototype._drawVirtualJoystick = function() {
  46026. var t = this;
  46027. this.alwaysVisible && this._drawContainer(),
  46028. this.pressed && this._touches.forEach((function(i, n) {
  46029. n.pointerId === t._joystickPointerId ? (t.alwaysVisible || t._drawContainer(),
  46030. t._drawPuck(),
  46031. t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (e._VJCanvasContext.clearRect(n.prevX - 44, n.prevY - 44, 88, 88),
  46032. e._VJCanvasContext.beginPath(),
  46033. e._VJCanvasContext.fillStyle = "white",
  46034. e._VJCanvasContext.beginPath(),
  46035. e._VJCanvasContext.strokeStyle = "red",
  46036. e._VJCanvasContext.lineWidth = 6,
  46037. e._VJCanvasContext.arc(n.x, n.y, 40, 0, 2 * Math.PI, !0),
  46038. e._VJCanvasContext.stroke(),
  46039. e._VJCanvasContext.closePath(),
  46040. n.prevX = n.x,
  46041. n.prevY = n.y)
  46042. }
  46043. )),
  46044. requestAnimationFrame((function() {
  46045. t._drawVirtualJoystick()
  46046. }
  46047. ))
  46048. }
  46049. ,
  46050. e.prototype.releaseCanvas = function() {
  46051. e.Canvas && (e.Canvas.removeEventListener("pointerdown", this._onPointerDownHandlerRef),
  46052. e.Canvas.removeEventListener("pointermove", this._onPointerMoveHandlerRef),
  46053. e.Canvas.removeEventListener("pointerup", this._onPointerUpHandlerRef),
  46054. e.Canvas.removeEventListener("pointerout", this._onPointerUpHandlerRef),
  46055. window.removeEventListener("resize", this._onResize),
  46056. document.body.removeChild(e.Canvas),
  46057. e.Canvas = null)
  46058. }
  46059. ,
  46060. e._GlobalJoystickIndex = 0,
  46061. e._AlwaysVisibleSticks = 0,
  46062. e
  46063. }();
  46064. aa.prototype.addVirtualJoystick = function() {
  46065. return this.add(new ha),
  46066. this
  46067. }
  46068. ;
  46069. var ha = function() {
  46070. function e() {}
  46071. return e.prototype.getLeftJoystick = function() {
  46072. return this._leftjoystick
  46073. }
  46074. ,
  46075. e.prototype.getRightJoystick = function() {
  46076. return this._rightjoystick
  46077. }
  46078. ,
  46079. e.prototype.checkInputs = function() {
  46080. if (this._leftjoystick) {
  46081. var e = this.camera
  46082. , t = 50 * e._computeLocalCameraSpeed()
  46083. , i = P.RotationYawPitchRoll(e.rotation.y, e.rotation.x, 0)
  46084. , n = x.TransformCoordinates(new x(this._leftjoystick.deltaPosition.x * t,this._leftjoystick.deltaPosition.y * t,this._leftjoystick.deltaPosition.z * t), i);
  46085. e.cameraDirection = e.cameraDirection.add(n),
  46086. e.cameraRotation = e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),
  46087. this._leftjoystick.pressed || (this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(.9)),
  46088. this._rightjoystick.pressed || (this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(.9))
  46089. }
  46090. }
  46091. ,
  46092. e.prototype.attachControl = function() {
  46093. this._leftjoystick = new ua(!0),
  46094. this._leftjoystick.setAxisForUpDown(la.Z),
  46095. this._leftjoystick.setAxisForLeftRight(la.X),
  46096. this._leftjoystick.setJoystickSensibility(.15),
  46097. this._rightjoystick = new ua(!1),
  46098. this._rightjoystick.setAxisForUpDown(la.X),
  46099. this._rightjoystick.setAxisForLeftRight(la.Y),
  46100. this._rightjoystick.reverseUpDown = !0,
  46101. this._rightjoystick.setJoystickSensibility(.05),
  46102. this._rightjoystick.setJoystickColor("yellow")
  46103. }
  46104. ,
  46105. e.prototype.detachControl = function() {
  46106. this._leftjoystick.releaseCanvas(),
  46107. this._rightjoystick.releaseCanvas()
  46108. }
  46109. ,
  46110. e.prototype.getClassName = function() {
  46111. return "FreeCameraVirtualJoystickInput"
  46112. }
  46113. ,
  46114. e.prototype.getSimpleName = function() {
  46115. return "virtualJoystick"
  46116. }
  46117. ,
  46118. e
  46119. }();
  46120. Vo.FreeCameraVirtualJoystickInput = ha;
  46121. var da = function(e) {
  46122. function t(t, i, n, r) {
  46123. void 0 === r && (r = !0);
  46124. var o = e.call(this, t, i, n, r) || this;
  46125. return o._tmpUpVector = x.Zero(),
  46126. o._tmpTargetVector = x.Zero(),
  46127. o.cameraDirection = new x(0,0,0),
  46128. o.cameraRotation = new A(0,0),
  46129. o.ignoreParentScaling = !1,
  46130. o.updateUpVectorFromRotation = !1,
  46131. o._tmpQuaternion = new C,
  46132. o.rotation = new x(0,0,0),
  46133. o.speed = 2,
  46134. o.noRotationConstraint = !1,
  46135. o.invertRotation = !1,
  46136. o.inverseRotationSpeed = .2,
  46137. o.lockedTarget = null,
  46138. o._currentTarget = x.Zero(),
  46139. o._initialFocalDistance = 1,
  46140. o._viewMatrix = P.Zero(),
  46141. o._camMatrix = P.Zero(),
  46142. o._cameraTransformMatrix = P.Zero(),
  46143. o._cameraRotationMatrix = P.Zero(),
  46144. o._referencePoint = new x(0,0,1),
  46145. o._transformedReferencePoint = x.Zero(),
  46146. o._defaultUp = x.Up(),
  46147. o._cachedRotationZ = 0,
  46148. o._cachedQuaternionRotationZ = 0,
  46149. o
  46150. }
  46151. return U(t, e),
  46152. t.prototype.getFrontPosition = function(e) {
  46153. this.getWorldMatrix();
  46154. var t = this.getTarget().subtract(this.position);
  46155. return t.normalize(),
  46156. t.scaleInPlace(e),
  46157. this.globalPosition.add(t)
  46158. }
  46159. ,
  46160. t.prototype._getLockedTargetPosition = function() {
  46161. return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
  46162. this.lockedTarget.absolutePosition || this.lockedTarget) : null
  46163. }
  46164. ,
  46165. t.prototype.storeState = function() {
  46166. return this._storedPosition = this.position.clone(),
  46167. this._storedRotation = this.rotation.clone(),
  46168. this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()),
  46169. e.prototype.storeState.call(this)
  46170. }
  46171. ,
  46172. t.prototype._restoreStateValues = function() {
  46173. return !!e.prototype._restoreStateValues.call(this) && (this.position = this._storedPosition.clone(),
  46174. this.rotation = this._storedRotation.clone(),
  46175. this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()),
  46176. this.cameraDirection.copyFromFloats(0, 0, 0),
  46177. this.cameraRotation.copyFromFloats(0, 0),
  46178. !0)
  46179. }
  46180. ,
  46181. t.prototype._initCache = function() {
  46182. e.prototype._initCache.call(this),
  46183. this._cache.lockedTarget = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  46184. this._cache.rotation = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  46185. this._cache.rotationQuaternion = new C(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
  46186. }
  46187. ,
  46188. t.prototype._updateCache = function(t) {
  46189. t || e.prototype._updateCache.call(this);
  46190. var i = this._getLockedTargetPosition();
  46191. i ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(i) : this._cache.lockedTarget = i.clone() : this._cache.lockedTarget = null,
  46192. this._cache.rotation.copyFrom(this.rotation),
  46193. this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)
  46194. }
  46195. ,
  46196. t.prototype._isSynchronizedViewMatrix = function() {
  46197. if (!e.prototype._isSynchronizedViewMatrix.call(this))
  46198. return !1;
  46199. var t = this._getLockedTargetPosition();
  46200. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(t) : !t) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation))
  46201. }
  46202. ,
  46203. t.prototype._computeLocalCameraSpeed = function() {
  46204. var e = this.getEngine();
  46205. return this.speed * Math.sqrt(e.getDeltaTime() / (100 * e.getFps()))
  46206. }
  46207. ,
  46208. t.prototype.setTarget = function(e) {
  46209. this.upVector.normalize(),
  46210. this._initialFocalDistance = e.subtract(this.position).length(),
  46211. this.position.z === e.z && (this.position.z += m),
  46212. this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
  46213. P.LookAtLHToRef(this.position, e, this._defaultUp, this._camMatrix),
  46214. this._camMatrix.invert(),
  46215. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  46216. var t = e.subtract(this.position);
  46217. t.x >= 0 ? this.rotation.y = -Math.atan(t.z / t.x) + Math.PI / 2 : this.rotation.y = -Math.atan(t.z / t.x) - Math.PI / 2,
  46218. this.rotation.z = 0,
  46219. isNaN(this.rotation.x) && (this.rotation.x = 0),
  46220. isNaN(this.rotation.y) && (this.rotation.y = 0),
  46221. isNaN(this.rotation.z) && (this.rotation.z = 0),
  46222. this.rotationQuaternion && C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
  46223. }
  46224. ,
  46225. Object.defineProperty(t.prototype, "target", {
  46226. get: function() {
  46227. return this.getTarget()
  46228. },
  46229. set: function(e) {
  46230. this.setTarget(e)
  46231. },
  46232. enumerable: !1,
  46233. configurable: !0
  46234. }),
  46235. t.prototype.getTarget = function() {
  46236. return this._currentTarget
  46237. }
  46238. ,
  46239. t.prototype._decideIfNeedsToMove = function() {
  46240. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
  46241. }
  46242. ,
  46243. t.prototype._updatePosition = function() {
  46244. if (this.parent)
  46245. return this.parent.getWorldMatrix().invertToRef(I.Matrix[0]),
  46246. x.TransformNormalToRef(this.cameraDirection, I.Matrix[0], I.Vector3[0]),
  46247. void this.position.addInPlace(I.Vector3[0]);
  46248. this.position.addInPlace(this.cameraDirection)
  46249. }
  46250. ,
  46251. t.prototype._checkInputs = function() {
  46252. var t = this.invertRotation ? -this.inverseRotationSpeed : 1
  46253. , i = this._decideIfNeedsToMove()
  46254. , n = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  46255. if (i && this._updatePosition(),
  46256. n) {
  46257. if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation),
  46258. this.rotation.x += this.cameraRotation.x * t,
  46259. this.rotation.y += this.cameraRotation.y * t,
  46260. !this.noRotationConstraint) {
  46261. var r = 1.570796;
  46262. this.rotation.x > r && (this.rotation.x = r),
  46263. this.rotation.x < -r && (this.rotation.x = -r)
  46264. }
  46265. this.rotationQuaternion && this.rotation.lengthSquared() && C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
  46266. }
  46267. i && (Math.abs(this.cameraDirection.x) < this.speed * m && (this.cameraDirection.x = 0),
  46268. Math.abs(this.cameraDirection.y) < this.speed * m && (this.cameraDirection.y = 0),
  46269. Math.abs(this.cameraDirection.z) < this.speed * m && (this.cameraDirection.z = 0),
  46270. this.cameraDirection.scaleInPlace(this.inertia)),
  46271. n && (Math.abs(this.cameraRotation.x) < this.speed * m && (this.cameraRotation.x = 0),
  46272. Math.abs(this.cameraRotation.y) < this.speed * m && (this.cameraRotation.y = 0),
  46273. this.cameraRotation.scaleInPlace(this.inertia)),
  46274. e.prototype._checkInputs.call(this)
  46275. }
  46276. ,
  46277. t.prototype._updateCameraRotationMatrix = function() {
  46278. this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : P.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
  46279. }
  46280. ,
  46281. t.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
  46282. return x.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector),
  46283. this
  46284. }
  46285. ,
  46286. t.prototype._getViewMatrix = function() {
  46287. return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()),
  46288. this._updateCameraRotationMatrix(),
  46289. this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(),
  46290. this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(),
  46291. this._cachedRotationZ = this.rotation.z),
  46292. x.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
  46293. this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
  46294. this.updateUpVectorFromRotation && (this.rotationQuaternion ? vn.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (C.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
  46295. vn.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))),
  46296. this._computeViewMatrix(this.position, this._currentTarget, this.upVector),
  46297. this._viewMatrix
  46298. }
  46299. ,
  46300. t.prototype._computeViewMatrix = function(e, t, i) {
  46301. if (this.ignoreParentScaling) {
  46302. if (this.parent) {
  46303. var n = this.parent.getWorldMatrix();
  46304. x.TransformCoordinatesToRef(e, n, this._globalPosition),
  46305. x.TransformCoordinatesToRef(t, n, this._tmpTargetVector),
  46306. x.TransformNormalToRef(i, n, this._tmpUpVector),
  46307. this._markSyncedWithParent()
  46308. } else
  46309. this._globalPosition.copyFrom(e),
  46310. this._tmpTargetVector.copyFrom(t),
  46311. this._tmpUpVector.copyFrom(i);
  46312. this.getScene().useRightHandedSystem ? P.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : P.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix)
  46313. } else
  46314. this.getScene().useRightHandedSystem ? P.LookAtRHToRef(e, t, i, this._viewMatrix) : P.LookAtLHToRef(e, t, i, this._viewMatrix),
  46315. this.parent ? (n = this.parent.getWorldMatrix(),
  46316. this._viewMatrix.invert(),
  46317. this._viewMatrix.multiplyToRef(n, this._viewMatrix),
  46318. this._viewMatrix.getTranslationToRef(this._globalPosition),
  46319. this._viewMatrix.invert(),
  46320. this._markSyncedWithParent()) : this._globalPosition.copyFrom(e)
  46321. }
  46322. ,
  46323. t.prototype.createRigCamera = function(e, i) {
  46324. if (this.cameraRigMode !== Rr.RIG_MODE_NONE) {
  46325. var n = new t(e,this.position.clone(),this.getScene());
  46326. return n.isRigCamera = !0,
  46327. n.rigParent = this,
  46328. this.cameraRigMode !== Rr.RIG_MODE_VR && this.cameraRigMode !== Rr.RIG_MODE_WEBVR || (this.rotationQuaternion || (this.rotationQuaternion = new C),
  46329. n._cameraRigParams = {},
  46330. n.rotationQuaternion = new C),
  46331. n
  46332. }
  46333. return null
  46334. }
  46335. ,
  46336. t.prototype._updateRigCameras = function() {
  46337. var t = this._rigCameras[0]
  46338. , i = this._rigCameras[1];
  46339. switch (this.computeWorldMatrix(),
  46340. this.cameraRigMode) {
  46341. case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  46342. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  46343. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  46344. case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  46345. case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
  46346. var n = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
  46347. , r = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
  46348. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * n, t),
  46349. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * r, i);
  46350. break;
  46351. case Rr.RIG_MODE_VR:
  46352. t.rotationQuaternion ? (t.rotationQuaternion.copyFrom(this.rotationQuaternion),
  46353. i.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (t.rotation.copyFrom(this.rotation),
  46354. i.rotation.copyFrom(this.rotation)),
  46355. t.position.copyFrom(this.position),
  46356. i.position.copyFrom(this.position)
  46357. }
  46358. e.prototype._updateRigCameras.call(this)
  46359. }
  46360. ,
  46361. t.prototype._getRigCamPositionAndTarget = function(e, i) {
  46362. this.getTarget().subtractToRef(this.position, t._TargetFocalPoint),
  46363. t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  46364. var n = t._TargetFocalPoint.addInPlace(this.position);
  46365. P.TranslationToRef(-n.x, -n.y, -n.z, t._TargetTransformMatrix),
  46366. t._TargetTransformMatrix.multiplyToRef(P.RotationAxis(i.upVector, e), t._RigCamTransformMatrix),
  46367. P.TranslationToRef(n.x, n.y, n.z, t._TargetTransformMatrix),
  46368. t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix),
  46369. x.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, i.position),
  46370. i.setTarget(n)
  46371. }
  46372. ,
  46373. t.prototype.getClassName = function() {
  46374. return "TargetCamera"
  46375. }
  46376. ,
  46377. t._RigCamTransformMatrix = new P,
  46378. t._TargetTransformMatrix = new P,
  46379. t._TargetFocalPoint = new x,
  46380. k([De()], t.prototype, "rotation", void 0),
  46381. k([Ce()], t.prototype, "speed", void 0),
  46382. k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
  46383. t
  46384. }(Rr)
  46385. , pa = function(e) {
  46386. function t(t, i, n, r) {
  46387. void 0 === r && (r = !0);
  46388. var o = e.call(this, t, i, n, r) || this;
  46389. return o.ellipsoid = new x(.5,1,.5),
  46390. o.ellipsoidOffset = new x(0,0,0),
  46391. o.checkCollisions = !1,
  46392. o.applyGravity = !1,
  46393. o._needMoveForGravity = !1,
  46394. o._oldPosition = x.Zero(),
  46395. o._diffPosition = x.Zero(),
  46396. o._newPosition = x.Zero(),
  46397. o._collisionMask = -1,
  46398. o._onCollisionPositionChange = function(e, t, i) {
  46399. var n;
  46400. void 0 === i && (i = null),
  46401. n = t,
  46402. o._newPosition.copyFrom(n),
  46403. o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
  46404. o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
  46405. o.onCollide && i && o.onCollide(i))
  46406. }
  46407. ,
  46408. o.inputs = new aa(o),
  46409. o.inputs.addKeyboard().addMouse(),
  46410. o
  46411. }
  46412. return U(t, e),
  46413. Object.defineProperty(t.prototype, "angularSensibility", {
  46414. get: function() {
  46415. var e = this.inputs.attached.mouse;
  46416. return e ? e.angularSensibility : 0
  46417. },
  46418. set: function(e) {
  46419. var t = this.inputs.attached.mouse;
  46420. t && (t.angularSensibility = e)
  46421. },
  46422. enumerable: !1,
  46423. configurable: !0
  46424. }),
  46425. Object.defineProperty(t.prototype, "keysUp", {
  46426. get: function() {
  46427. var e = this.inputs.attached.keyboard;
  46428. return e ? e.keysUp : []
  46429. },
  46430. set: function(e) {
  46431. var t = this.inputs.attached.keyboard;
  46432. t && (t.keysUp = e)
  46433. },
  46434. enumerable: !1,
  46435. configurable: !0
  46436. }),
  46437. Object.defineProperty(t.prototype, "keysUpward", {
  46438. get: function() {
  46439. var e = this.inputs.attached.keyboard;
  46440. return e ? e.keysUpward : []
  46441. },
  46442. set: function(e) {
  46443. var t = this.inputs.attached.keyboard;
  46444. t && (t.keysUpward = e)
  46445. },
  46446. enumerable: !1,
  46447. configurable: !0
  46448. }),
  46449. Object.defineProperty(t.prototype, "keysDown", {
  46450. get: function() {
  46451. var e = this.inputs.attached.keyboard;
  46452. return e ? e.keysDown : []
  46453. },
  46454. set: function(e) {
  46455. var t = this.inputs.attached.keyboard;
  46456. t && (t.keysDown = e)
  46457. },
  46458. enumerable: !1,
  46459. configurable: !0
  46460. }),
  46461. Object.defineProperty(t.prototype, "keysDownward", {
  46462. get: function() {
  46463. var e = this.inputs.attached.keyboard;
  46464. return e ? e.keysDownward : []
  46465. },
  46466. set: function(e) {
  46467. var t = this.inputs.attached.keyboard;
  46468. t && (t.keysDownward = e)
  46469. },
  46470. enumerable: !1,
  46471. configurable: !0
  46472. }),
  46473. Object.defineProperty(t.prototype, "keysLeft", {
  46474. get: function() {
  46475. var e = this.inputs.attached.keyboard;
  46476. return e ? e.keysLeft : []
  46477. },
  46478. set: function(e) {
  46479. var t = this.inputs.attached.keyboard;
  46480. t && (t.keysLeft = e)
  46481. },
  46482. enumerable: !1,
  46483. configurable: !0
  46484. }),
  46485. Object.defineProperty(t.prototype, "keysRight", {
  46486. get: function() {
  46487. var e = this.inputs.attached.keyboard;
  46488. return e ? e.keysRight : []
  46489. },
  46490. set: function(e) {
  46491. var t = this.inputs.attached.keyboard;
  46492. t && (t.keysRight = e)
  46493. },
  46494. enumerable: !1,
  46495. configurable: !0
  46496. }),
  46497. Object.defineProperty(t.prototype, "keysRotateLeft", {
  46498. get: function() {
  46499. var e = this.inputs.attached.keyboard;
  46500. return e ? e.keysRotateLeft : []
  46501. },
  46502. set: function(e) {
  46503. var t = this.inputs.attached.keyboard;
  46504. t && (t.keysRotateLeft = e)
  46505. },
  46506. enumerable: !1,
  46507. configurable: !0
  46508. }),
  46509. Object.defineProperty(t.prototype, "keysRotateRight", {
  46510. get: function() {
  46511. var e = this.inputs.attached.keyboard;
  46512. return e ? e.keysRotateRight : []
  46513. },
  46514. set: function(e) {
  46515. var t = this.inputs.attached.keyboard;
  46516. t && (t.keysRotateRight = e)
  46517. },
  46518. enumerable: !1,
  46519. configurable: !0
  46520. }),
  46521. t.prototype.attachControl = function(e, t) {
  46522. t = gi.BackCompatCameraNoPreventDefault(arguments),
  46523. this.inputs.attachElement(t)
  46524. }
  46525. ,
  46526. t.prototype.detachControl = function() {
  46527. this.inputs.detachElement(),
  46528. this.cameraDirection = new x(0,0,0),
  46529. this.cameraRotation = new A(0,0)
  46530. }
  46531. ,
  46532. Object.defineProperty(t.prototype, "collisionMask", {
  46533. get: function() {
  46534. return this._collisionMask
  46535. },
  46536. set: function(e) {
  46537. this._collisionMask = isNaN(e) ? -1 : e
  46538. },
  46539. enumerable: !1,
  46540. configurable: !0
  46541. }),
  46542. t.prototype._collideWithWorld = function(e) {
  46543. (this.parent ? x.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
  46544. this._oldPosition.addInPlace(this.ellipsoidOffset);
  46545. var t = this.getScene().collisionCoordinator;
  46546. this._collider || (this._collider = t.createCollider()),
  46547. this._collider._radius = this.ellipsoid,
  46548. this._collider.collisionMask = this._collisionMask;
  46549. var i = e;
  46550. this.applyGravity && (i = e.add(this.getScene().gravity)),
  46551. t.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
  46552. }
  46553. ,
  46554. t.prototype._checkInputs = function() {
  46555. this._localDirection || (this._localDirection = x.Zero(),
  46556. this._transformedDirection = x.Zero()),
  46557. this.inputs.checkInputs(),
  46558. e.prototype._checkInputs.call(this)
  46559. }
  46560. ,
  46561. t.prototype._decideIfNeedsToMove = function() {
  46562. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
  46563. }
  46564. ,
  46565. t.prototype._updatePosition = function() {
  46566. this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : e.prototype._updatePosition.call(this)
  46567. }
  46568. ,
  46569. t.prototype.dispose = function() {
  46570. this.inputs.clear(),
  46571. e.prototype.dispose.call(this)
  46572. }
  46573. ,
  46574. t.prototype.getClassName = function() {
  46575. return "FreeCamera"
  46576. }
  46577. ,
  46578. k([De()], t.prototype, "ellipsoid", void 0),
  46579. k([De()], t.prototype, "ellipsoidOffset", void 0),
  46580. k([Ce()], t.prototype, "checkCollisions", void 0),
  46581. k([Ce()], t.prototype, "applyGravity", void 0),
  46582. t
  46583. }(da);
  46584. Xe.AddNodeConstructor("TouchCamera", (function(e, t) {
  46585. return function() {
  46586. return new fa(e,x.Zero(),t)
  46587. }
  46588. }
  46589. ));
  46590. var fa = function(e) {
  46591. function t(t, i, n) {
  46592. var r = e.call(this, t, i, n) || this;
  46593. return r.inputs.addTouch(),
  46594. r._setupInputs(),
  46595. r
  46596. }
  46597. return U(t, e),
  46598. Object.defineProperty(t.prototype, "touchAngularSensibility", {
  46599. get: function() {
  46600. var e = this.inputs.attached.touch;
  46601. return e ? e.touchAngularSensibility : 0
  46602. },
  46603. set: function(e) {
  46604. var t = this.inputs.attached.touch;
  46605. t && (t.touchAngularSensibility = e)
  46606. },
  46607. enumerable: !1,
  46608. configurable: !0
  46609. }),
  46610. Object.defineProperty(t.prototype, "touchMoveSensibility", {
  46611. get: function() {
  46612. var e = this.inputs.attached.touch;
  46613. return e ? e.touchMoveSensibility : 0
  46614. },
  46615. set: function(e) {
  46616. var t = this.inputs.attached.touch;
  46617. t && (t.touchMoveSensibility = e)
  46618. },
  46619. enumerable: !1,
  46620. configurable: !0
  46621. }),
  46622. t.prototype.getClassName = function() {
  46623. return "TouchCamera"
  46624. }
  46625. ,
  46626. t.prototype._setupInputs = function() {
  46627. var e = this.inputs.attached.touch
  46628. , t = this.inputs.attached.mouse;
  46629. t ? t.touchEnabled = !1 : e.allowMouse = !0
  46630. }
  46631. ,
  46632. t
  46633. }(pa);
  46634. Xe.AddNodeConstructor("ArcRotateCamera", (function(e, t) {
  46635. return function() {
  46636. return new _a(e,0,0,1,x.Zero(),t)
  46637. }
  46638. }
  46639. ));
  46640. var _a = function(e) {
  46641. function t(t, i, n, r, o, a, s) {
  46642. void 0 === s && (s = !0);
  46643. var l = e.call(this, t, x.Zero(), a, s) || this;
  46644. return l.inertialAlphaOffset = 0,
  46645. l.inertialBetaOffset = 0,
  46646. l.inertialRadiusOffset = 0,
  46647. l.lowerAlphaLimit = null,
  46648. l.upperAlphaLimit = null,
  46649. l.lowerBetaLimit = .01,
  46650. l.upperBetaLimit = Math.PI - .01,
  46651. l.lowerRadiusLimit = null,
  46652. l.upperRadiusLimit = null,
  46653. l.inertialPanningX = 0,
  46654. l.inertialPanningY = 0,
  46655. l.pinchToPanMaxDistance = 20,
  46656. l.panningDistanceLimit = null,
  46657. l.panningOriginTarget = x.Zero(),
  46658. l.panningInertia = .9,
  46659. l.zoomOnFactor = 1,
  46660. l.targetScreenOffset = A.Zero(),
  46661. l.allowUpsideDown = !0,
  46662. l.useInputToRestoreState = !0,
  46663. l._viewMatrix = new P,
  46664. l.panningAxis = new x(1,1,0),
  46665. l._transformedDirection = new x,
  46666. l.mapPanning = !1,
  46667. l.onMeshTargetChangedObservable = new h,
  46668. l.checkCollisions = !1,
  46669. l.collisionRadius = new x(.5,.5,.5),
  46670. l._previousPosition = x.Zero(),
  46671. l._collisionVelocity = x.Zero(),
  46672. l._newPosition = x.Zero(),
  46673. l._computationVector = x.Zero(),
  46674. l._onCollisionPositionChange = function(e, t, i) {
  46675. void 0 === i && (i = null),
  46676. i ? (l.setPosition(t),
  46677. l.onCollide && l.onCollide(i)) : l._previousPosition.copyFrom(l._position);
  46678. var n = Math.cos(l.alpha)
  46679. , r = Math.sin(l.alpha)
  46680. , o = Math.cos(l.beta)
  46681. , a = Math.sin(l.beta);
  46682. 0 === a && (a = 1e-4);
  46683. var s = l._getTargetPosition();
  46684. l._computationVector.copyFromFloats(l.radius * n * a, l.radius * o, l.radius * r * a),
  46685. s.addToRef(l._computationVector, l._newPosition),
  46686. l._position.copyFrom(l._newPosition);
  46687. var c = l.upVector;
  46688. l.allowUpsideDown && l.beta < 0 && (c = (c = c.clone()).negate()),
  46689. l._computeViewMatrix(l._position, s, c),
  46690. l._viewMatrix.addAtIndex(12, l.targetScreenOffset.x),
  46691. l._viewMatrix.addAtIndex(13, l.targetScreenOffset.y),
  46692. l._collisionTriggered = !1
  46693. }
  46694. ,
  46695. l._target = x.Zero(),
  46696. o && l.setTarget(o),
  46697. l.alpha = i,
  46698. l.beta = n,
  46699. l.radius = r,
  46700. l.getViewMatrix(),
  46701. l.inputs = new Ko(l),
  46702. l.inputs.addKeyboard().addMouseWheel().addPointers(),
  46703. l
  46704. }
  46705. return U(t, e),
  46706. Object.defineProperty(t.prototype, "target", {
  46707. get: function() {
  46708. return this._target
  46709. },
  46710. set: function(e) {
  46711. this.setTarget(e)
  46712. },
  46713. enumerable: !1,
  46714. configurable: !0
  46715. }),
  46716. Object.defineProperty(t.prototype, "targetHost", {
  46717. get: function() {
  46718. return this._targetHost
  46719. },
  46720. set: function(e) {
  46721. e && this.setTarget(e)
  46722. },
  46723. enumerable: !1,
  46724. configurable: !0
  46725. }),
  46726. t.prototype.getTarget = function() {
  46727. return this.target
  46728. }
  46729. ,
  46730. Object.defineProperty(t.prototype, "position", {
  46731. get: function() {
  46732. return this._position
  46733. },
  46734. set: function(e) {
  46735. this.setPosition(e)
  46736. },
  46737. enumerable: !1,
  46738. configurable: !0
  46739. }),
  46740. Object.defineProperty(t.prototype, "upVector", {
  46741. get: function() {
  46742. return this._upVector
  46743. },
  46744. set: function(e) {
  46745. this._upToYMatrix || (this._yToUpMatrix = new P,
  46746. this._upToYMatrix = new P,
  46747. this._upVector = x.Zero()),
  46748. e.normalize(),
  46749. this._upVector.copyFrom(e),
  46750. this.setMatUp()
  46751. },
  46752. enumerable: !1,
  46753. configurable: !0
  46754. }),
  46755. t.prototype.setMatUp = function() {
  46756. P.RotationAlignToRef(x.UpReadOnly, this._upVector, this._yToUpMatrix),
  46757. P.RotationAlignToRef(this._upVector, x.UpReadOnly, this._upToYMatrix)
  46758. }
  46759. ,
  46760. Object.defineProperty(t.prototype, "angularSensibilityX", {
  46761. get: function() {
  46762. var e = this.inputs.attached.pointers;
  46763. return e ? e.angularSensibilityX : 0
  46764. },
  46765. set: function(e) {
  46766. var t = this.inputs.attached.pointers;
  46767. t && (t.angularSensibilityX = e)
  46768. },
  46769. enumerable: !1,
  46770. configurable: !0
  46771. }),
  46772. Object.defineProperty(t.prototype, "angularSensibilityY", {
  46773. get: function() {
  46774. var e = this.inputs.attached.pointers;
  46775. return e ? e.angularSensibilityY : 0
  46776. },
  46777. set: function(e) {
  46778. var t = this.inputs.attached.pointers;
  46779. t && (t.angularSensibilityY = e)
  46780. },
  46781. enumerable: !1,
  46782. configurable: !0
  46783. }),
  46784. Object.defineProperty(t.prototype, "pinchPrecision", {
  46785. get: function() {
  46786. var e = this.inputs.attached.pointers;
  46787. return e ? e.pinchPrecision : 0
  46788. },
  46789. set: function(e) {
  46790. var t = this.inputs.attached.pointers;
  46791. t && (t.pinchPrecision = e)
  46792. },
  46793. enumerable: !1,
  46794. configurable: !0
  46795. }),
  46796. Object.defineProperty(t.prototype, "pinchDeltaPercentage", {
  46797. get: function() {
  46798. var e = this.inputs.attached.pointers;
  46799. return e ? e.pinchDeltaPercentage : 0
  46800. },
  46801. set: function(e) {
  46802. var t = this.inputs.attached.pointers;
  46803. t && (t.pinchDeltaPercentage = e)
  46804. },
  46805. enumerable: !1,
  46806. configurable: !0
  46807. }),
  46808. Object.defineProperty(t.prototype, "useNaturalPinchZoom", {
  46809. get: function() {
  46810. var e = this.inputs.attached.pointers;
  46811. return !!e && e.useNaturalPinchZoom
  46812. },
  46813. set: function(e) {
  46814. var t = this.inputs.attached.pointers;
  46815. t && (t.useNaturalPinchZoom = e)
  46816. },
  46817. enumerable: !1,
  46818. configurable: !0
  46819. }),
  46820. Object.defineProperty(t.prototype, "panningSensibility", {
  46821. get: function() {
  46822. var e = this.inputs.attached.pointers;
  46823. return e ? e.panningSensibility : 0
  46824. },
  46825. set: function(e) {
  46826. var t = this.inputs.attached.pointers;
  46827. t && (t.panningSensibility = e)
  46828. },
  46829. enumerable: !1,
  46830. configurable: !0
  46831. }),
  46832. Object.defineProperty(t.prototype, "keysUp", {
  46833. get: function() {
  46834. var e = this.inputs.attached.keyboard;
  46835. return e ? e.keysUp : []
  46836. },
  46837. set: function(e) {
  46838. var t = this.inputs.attached.keyboard;
  46839. t && (t.keysUp = e)
  46840. },
  46841. enumerable: !1,
  46842. configurable: !0
  46843. }),
  46844. Object.defineProperty(t.prototype, "keysDown", {
  46845. get: function() {
  46846. var e = this.inputs.attached.keyboard;
  46847. return e ? e.keysDown : []
  46848. },
  46849. set: function(e) {
  46850. var t = this.inputs.attached.keyboard;
  46851. t && (t.keysDown = e)
  46852. },
  46853. enumerable: !1,
  46854. configurable: !0
  46855. }),
  46856. Object.defineProperty(t.prototype, "keysLeft", {
  46857. get: function() {
  46858. var e = this.inputs.attached.keyboard;
  46859. return e ? e.keysLeft : []
  46860. },
  46861. set: function(e) {
  46862. var t = this.inputs.attached.keyboard;
  46863. t && (t.keysLeft = e)
  46864. },
  46865. enumerable: !1,
  46866. configurable: !0
  46867. }),
  46868. Object.defineProperty(t.prototype, "keysRight", {
  46869. get: function() {
  46870. var e = this.inputs.attached.keyboard;
  46871. return e ? e.keysRight : []
  46872. },
  46873. set: function(e) {
  46874. var t = this.inputs.attached.keyboard;
  46875. t && (t.keysRight = e)
  46876. },
  46877. enumerable: !1,
  46878. configurable: !0
  46879. }),
  46880. Object.defineProperty(t.prototype, "wheelPrecision", {
  46881. get: function() {
  46882. var e = this.inputs.attached.mousewheel;
  46883. return e ? e.wheelPrecision : 0
  46884. },
  46885. set: function(e) {
  46886. var t = this.inputs.attached.mousewheel;
  46887. t && (t.wheelPrecision = e)
  46888. },
  46889. enumerable: !1,
  46890. configurable: !0
  46891. }),
  46892. Object.defineProperty(t.prototype, "zoomToMouseLocation", {
  46893. get: function() {
  46894. var e = this.inputs.attached.mousewheel;
  46895. return !!e && e.zoomToMouseLocation
  46896. },
  46897. set: function(e) {
  46898. var t = this.inputs.attached.mousewheel;
  46899. t && (t.zoomToMouseLocation = e)
  46900. },
  46901. enumerable: !1,
  46902. configurable: !0
  46903. }),
  46904. Object.defineProperty(t.prototype, "wheelDeltaPercentage", {
  46905. get: function() {
  46906. var e = this.inputs.attached.mousewheel;
  46907. return e ? e.wheelDeltaPercentage : 0
  46908. },
  46909. set: function(e) {
  46910. var t = this.inputs.attached.mousewheel;
  46911. t && (t.wheelDeltaPercentage = e)
  46912. },
  46913. enumerable: !1,
  46914. configurable: !0
  46915. }),
  46916. Object.defineProperty(t.prototype, "bouncingBehavior", {
  46917. get: function() {
  46918. return this._bouncingBehavior
  46919. },
  46920. enumerable: !1,
  46921. configurable: !0
  46922. }),
  46923. Object.defineProperty(t.prototype, "useBouncingBehavior", {
  46924. get: function() {
  46925. return null != this._bouncingBehavior
  46926. },
  46927. set: function(e) {
  46928. e !== this.useBouncingBehavior && (e ? (this._bouncingBehavior = new co,
  46929. this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior),
  46930. this._bouncingBehavior = null))
  46931. },
  46932. enumerable: !1,
  46933. configurable: !0
  46934. }),
  46935. Object.defineProperty(t.prototype, "framingBehavior", {
  46936. get: function() {
  46937. return this._framingBehavior
  46938. },
  46939. enumerable: !1,
  46940. configurable: !0
  46941. }),
  46942. Object.defineProperty(t.prototype, "useFramingBehavior", {
  46943. get: function() {
  46944. return null != this._framingBehavior
  46945. },
  46946. set: function(e) {
  46947. e !== this.useFramingBehavior && (e ? (this._framingBehavior = new uo,
  46948. this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior),
  46949. this._framingBehavior = null))
  46950. },
  46951. enumerable: !1,
  46952. configurable: !0
  46953. }),
  46954. Object.defineProperty(t.prototype, "autoRotationBehavior", {
  46955. get: function() {
  46956. return this._autoRotationBehavior
  46957. },
  46958. enumerable: !1,
  46959. configurable: !0
  46960. }),
  46961. Object.defineProperty(t.prototype, "useAutoRotationBehavior", {
  46962. get: function() {
  46963. return null != this._autoRotationBehavior
  46964. },
  46965. set: function(e) {
  46966. e !== this.useAutoRotationBehavior && (e ? (this._autoRotationBehavior = new lo,
  46967. this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior),
  46968. this._autoRotationBehavior = null))
  46969. },
  46970. enumerable: !1,
  46971. configurable: !0
  46972. }),
  46973. t.prototype._initCache = function() {
  46974. e.prototype._initCache.call(this),
  46975. this._cache._target = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  46976. this._cache.alpha = void 0,
  46977. this._cache.beta = void 0,
  46978. this._cache.radius = void 0,
  46979. this._cache.targetScreenOffset = A.Zero()
  46980. }
  46981. ,
  46982. t.prototype._updateCache = function(t) {
  46983. t || e.prototype._updateCache.call(this),
  46984. this._cache._target.copyFrom(this._getTargetPosition()),
  46985. this._cache.alpha = this.alpha,
  46986. this._cache.beta = this.beta,
  46987. this._cache.radius = this.radius,
  46988. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)
  46989. }
  46990. ,
  46991. t.prototype._getTargetPosition = function() {
  46992. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  46993. var e = this._targetHost.getAbsolutePosition();
  46994. this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e)
  46995. }
  46996. return this._getLockedTargetPosition() || this._target
  46997. }
  46998. ,
  46999. t.prototype.storeState = function() {
  47000. return this._storedAlpha = this.alpha,
  47001. this._storedBeta = this.beta,
  47002. this._storedRadius = this.radius,
  47003. this._storedTarget = this._getTargetPosition().clone(),
  47004. this._storedTargetScreenOffset = this.targetScreenOffset.clone(),
  47005. e.prototype.storeState.call(this)
  47006. }
  47007. ,
  47008. t.prototype._restoreStateValues = function() {
  47009. return !!e.prototype._restoreStateValues.call(this) && (this.setTarget(this._storedTarget.clone()),
  47010. this.alpha = this._storedAlpha,
  47011. this.beta = this._storedBeta,
  47012. this.radius = this._storedRadius,
  47013. this.targetScreenOffset = this._storedTargetScreenOffset.clone(),
  47014. this.inertialAlphaOffset = 0,
  47015. this.inertialBetaOffset = 0,
  47016. this.inertialRadiusOffset = 0,
  47017. this.inertialPanningX = 0,
  47018. this.inertialPanningY = 0,
  47019. !0)
  47020. }
  47021. ,
  47022. t.prototype._isSynchronizedViewMatrix = function() {
  47023. return !!e.prototype._isSynchronizedViewMatrix.call(this) && this._cache._target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset)
  47024. }
  47025. ,
  47026. t.prototype.attachControl = function(e, t, i, n) {
  47027. var r = this;
  47028. void 0 === i && (i = !0),
  47029. void 0 === n && (n = 2);
  47030. var o = arguments;
  47031. t = gi.BackCompatCameraNoPreventDefault(o),
  47032. this._useCtrlForPanning = i,
  47033. this._panningMouseButton = n,
  47034. "boolean" == typeof o[0] && (o.length > 1 && (this._useCtrlForPanning = o[1]),
  47035. o.length > 2 && (this._panningMouseButton = o[2])),
  47036. this.inputs.attachElement(t),
  47037. this._reset = function() {
  47038. r.inertialAlphaOffset = 0,
  47039. r.inertialBetaOffset = 0,
  47040. r.inertialRadiusOffset = 0,
  47041. r.inertialPanningX = 0,
  47042. r.inertialPanningY = 0
  47043. }
  47044. }
  47045. ,
  47046. t.prototype.detachControl = function() {
  47047. this.inputs.detachElement(),
  47048. this._reset && this._reset()
  47049. }
  47050. ,
  47051. t.prototype._checkInputs = function() {
  47052. if (!this._collisionTriggered) {
  47053. if (this.inputs.checkInputs(),
  47054. 0 !== this.inertialAlphaOffset || 0 !== this.inertialBetaOffset || 0 !== this.inertialRadiusOffset) {
  47055. var t = this.inertialAlphaOffset;
  47056. this.beta <= 0 && (t *= -1),
  47057. this.getScene().useRightHandedSystem && (t *= -1),
  47058. this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (t *= -1),
  47059. this.alpha += t,
  47060. this.beta += this.inertialBetaOffset,
  47061. this.radius -= this.inertialRadiusOffset,
  47062. this.inertialAlphaOffset *= this.inertia,
  47063. this.inertialBetaOffset *= this.inertia,
  47064. this.inertialRadiusOffset *= this.inertia,
  47065. Math.abs(this.inertialAlphaOffset) < m && (this.inertialAlphaOffset = 0),
  47066. Math.abs(this.inertialBetaOffset) < m && (this.inertialBetaOffset = 0),
  47067. Math.abs(this.inertialRadiusOffset) < this.speed * m && (this.inertialRadiusOffset = 0)
  47068. }
  47069. if (0 !== this.inertialPanningX || 0 !== this.inertialPanningY) {
  47070. var i = new x(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
  47071. this._viewMatrix.invertToRef(this._cameraTransformMatrix),
  47072. i.multiplyInPlace(this.panningAxis),
  47073. x.TransformNormalToRef(i, this._cameraTransformMatrix, this._transformedDirection),
  47074. !this.mapPanning && this.panningAxis.y || (this._transformedDirection.y = 0),
  47075. this._targetHost || (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target),
  47076. x.DistanceSquared(this._transformedDirection, this.panningOriginTarget) <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)) : this._target.addInPlace(this._transformedDirection)),
  47077. this.inertialPanningX *= this.panningInertia,
  47078. this.inertialPanningY *= this.panningInertia,
  47079. Math.abs(this.inertialPanningX) < this.speed * m && (this.inertialPanningX = 0),
  47080. Math.abs(this.inertialPanningY) < this.speed * m && (this.inertialPanningY = 0)
  47081. }
  47082. this._checkLimits(),
  47083. e.prototype._checkInputs.call(this)
  47084. }
  47085. }
  47086. ,
  47087. t.prototype._checkLimits = function() {
  47088. null === this.lowerBetaLimit || void 0 === this.lowerBetaLimit ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit),
  47089. null === this.upperBetaLimit || void 0 === this.upperBetaLimit ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit),
  47090. null !== this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit),
  47091. null !== this.upperAlphaLimit && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit),
  47092. null !== this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit,
  47093. this.inertialRadiusOffset = 0),
  47094. null !== this.upperRadiusLimit && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit,
  47095. this.inertialRadiusOffset = 0)
  47096. }
  47097. ,
  47098. t.prototype.rebuildAnglesAndRadius = function() {
  47099. this._position.subtractToRef(this._getTargetPosition(), this._computationVector),
  47100. 0 === this._upVector.x && 1 === this._upVector.y && 0 === this._upVector.z || x.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector),
  47101. this.radius = this._computationVector.length(),
  47102. 0 === this.radius && (this.radius = 1e-4);
  47103. var e = this.alpha;
  47104. 0 === this._computationVector.x && 0 === this._computationVector.z ? this.alpha = Math.PI / 2 : this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2))),
  47105. this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
  47106. var t = Math.round((e - this.alpha) / (2 * Math.PI));
  47107. this.alpha += 2 * t * Math.PI,
  47108. this.beta = Math.acos(this._computationVector.y / this.radius),
  47109. this._checkLimits()
  47110. }
  47111. ,
  47112. t.prototype.setPosition = function(e) {
  47113. this._position.equals(e) || (this._position.copyFrom(e),
  47114. this.rebuildAnglesAndRadius())
  47115. }
  47116. ,
  47117. t.prototype.setTarget = function(e, t, i, n) {
  47118. if (void 0 === t && (t = !1),
  47119. void 0 === i && (i = !1),
  47120. void 0 === n && (n = !1),
  47121. e.getBoundingInfo)
  47122. this._targetBoundingCenter = t ? e.getBoundingInfo().boundingBox.centerWorld.clone() : null,
  47123. e.computeWorldMatrix(),
  47124. this._targetHost = e,
  47125. this._target = this._getTargetPosition(),
  47126. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  47127. else {
  47128. var r = e
  47129. , o = this._getTargetPosition();
  47130. if (o && !i && o.equals(r))
  47131. return;
  47132. this._targetHost = null,
  47133. this._target = r,
  47134. this._targetBoundingCenter = null,
  47135. this.onMeshTargetChangedObservable.notifyObservers(null)
  47136. }
  47137. n || this.rebuildAnglesAndRadius()
  47138. }
  47139. ,
  47140. t.prototype._getViewMatrix = function() {
  47141. var e = Math.cos(this.alpha)
  47142. , t = Math.sin(this.alpha)
  47143. , i = Math.cos(this.beta)
  47144. , n = Math.sin(this.beta);
  47145. 0 === n && (n = 1e-4),
  47146. 0 === this.radius && (this.radius = 1e-4);
  47147. var r = this._getTargetPosition();
  47148. if (this._computationVector.copyFromFloats(this.radius * e * n, this.radius * i, this.radius * t * n),
  47149. 0 === this._upVector.x && 1 === this._upVector.y && 0 === this._upVector.z || x.TransformCoordinatesToRef(this._computationVector, this._yToUpMatrix, this._computationVector),
  47150. r.addToRef(this._computationVector, this._newPosition),
  47151. this.getScene().collisionsEnabled && this.checkCollisions) {
  47152. var o = this.getScene().collisionCoordinator;
  47153. this._collider || (this._collider = o.createCollider()),
  47154. this._collider._radius = this.collisionRadius,
  47155. this._newPosition.subtractToRef(this._position, this._collisionVelocity),
  47156. this._collisionTriggered = !0,
  47157. o.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
  47158. } else {
  47159. this._position.copyFrom(this._newPosition);
  47160. var a = this.upVector;
  47161. this.allowUpsideDown && n < 0 && (a = a.negate()),
  47162. this._computeViewMatrix(this._position, r, a),
  47163. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
  47164. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
  47165. }
  47166. return this._currentTarget = r,
  47167. this._viewMatrix
  47168. }
  47169. ,
  47170. t.prototype.zoomOn = function(e, t) {
  47171. void 0 === t && (t = !1),
  47172. e = e || this.getScene().meshes;
  47173. var i = Vr.MinMax(e)
  47174. , n = x.Distance(i.min, i.max);
  47175. this.radius = n * this.zoomOnFactor,
  47176. this.focusOn({
  47177. min: i.min,
  47178. max: i.max,
  47179. distance: n
  47180. }, t)
  47181. }
  47182. ,
  47183. t.prototype.focusOn = function(e, t) {
  47184. var i, n;
  47185. if (void 0 === t && (t = !1),
  47186. void 0 === e.min) {
  47187. var r = e || this.getScene().meshes;
  47188. i = Vr.MinMax(r),
  47189. n = x.Distance(i.min, i.max)
  47190. } else
  47191. i = e,
  47192. n = e.distance;
  47193. this._target = Vr.Center(i),
  47194. t || (this.maxZ = 2 * n)
  47195. }
  47196. ,
  47197. t.prototype.createRigCamera = function(e, i) {
  47198. var n = 0;
  47199. switch (this.cameraRigMode) {
  47200. case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  47201. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  47202. case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  47203. case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
  47204. case Rr.RIG_MODE_VR:
  47205. n = this._cameraRigParams.stereoHalfAngle * (0 === i ? 1 : -1);
  47206. break;
  47207. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  47208. n = this._cameraRigParams.stereoHalfAngle * (0 === i ? -1 : 1)
  47209. }
  47210. var r = new t(e,this.alpha + n,this.beta,this.radius,this._target,this.getScene());
  47211. return r._cameraRigParams = {},
  47212. r.isRigCamera = !0,
  47213. r.rigParent = this,
  47214. r.upVector = this.upVector,
  47215. r
  47216. }
  47217. ,
  47218. t.prototype._updateRigCameras = function() {
  47219. var t = this._rigCameras[0]
  47220. , i = this._rigCameras[1];
  47221. switch (t.beta = i.beta = this.beta,
  47222. this.cameraRigMode) {
  47223. case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  47224. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  47225. case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  47226. case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
  47227. case Rr.RIG_MODE_VR:
  47228. t.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
  47229. i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  47230. break;
  47231. case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  47232. t.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle,
  47233. i.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle
  47234. }
  47235. e.prototype._updateRigCameras.call(this)
  47236. }
  47237. ,
  47238. t.prototype.dispose = function() {
  47239. this.inputs.clear(),
  47240. e.prototype.dispose.call(this)
  47241. }
  47242. ,
  47243. t.prototype.getClassName = function() {
  47244. return "ArcRotateCamera"
  47245. }
  47246. ,
  47247. k([Ce()], t.prototype, "alpha", void 0),
  47248. k([Ce()], t.prototype, "beta", void 0),
  47249. k([Ce()], t.prototype, "radius", void 0),
  47250. k([De("target")], t.prototype, "_target", void 0),
  47251. k([Ne("targetHost")], t.prototype, "_targetHost", void 0),
  47252. k([Ce()], t.prototype, "inertialAlphaOffset", void 0),
  47253. k([Ce()], t.prototype, "inertialBetaOffset", void 0),
  47254. k([Ce()], t.prototype, "inertialRadiusOffset", void 0),
  47255. k([Ce()], t.prototype, "lowerAlphaLimit", void 0),
  47256. k([Ce()], t.prototype, "upperAlphaLimit", void 0),
  47257. k([Ce()], t.prototype, "lowerBetaLimit", void 0),
  47258. k([Ce()], t.prototype, "upperBetaLimit", void 0),
  47259. k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
  47260. k([Ce()], t.prototype, "upperRadiusLimit", void 0),
  47261. k([Ce()], t.prototype, "inertialPanningX", void 0),
  47262. k([Ce()], t.prototype, "inertialPanningY", void 0),
  47263. k([Ce()], t.prototype, "pinchToPanMaxDistance", void 0),
  47264. k([Ce()], t.prototype, "panningDistanceLimit", void 0),
  47265. k([De()], t.prototype, "panningOriginTarget", void 0),
  47266. k([Ce()], t.prototype, "panningInertia", void 0),
  47267. k([Ce()], t.prototype, "zoomToMouseLocation", null),
  47268. k([Ce()], t.prototype, "zoomOnFactor", void 0),
  47269. k([Oe()], t.prototype, "targetScreenOffset", void 0),
  47270. k([Ce()], t.prototype, "allowUpsideDown", void 0),
  47271. k([Ce()], t.prototype, "useInputToRestoreState", void 0),
  47272. t
  47273. }(da);
  47274. Xe.AddNodeConstructor("DeviceOrientationCamera", (function(e, t) {
  47275. return function() {
  47276. return new ma(e,x.Zero(),t)
  47277. }
  47278. }
  47279. ));
  47280. var ma = function(e) {
  47281. function t(t, i, n) {
  47282. var r = e.call(this, t, i, n) || this;
  47283. return r._tmpDragQuaternion = new C,
  47284. r._disablePointerInputWhenUsingDeviceOrientation = !0,
  47285. r._dragFactor = 0,
  47286. r._quaternionCache = new C,
  47287. r.inputs.addDeviceOrientation(),
  47288. r.inputs._deviceOrientationInput && r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function() {
  47289. r._disablePointerInputWhenUsingDeviceOrientation && r.inputs._mouseInput && (r.inputs._mouseInput._allowCameraRotation = !1,
  47290. r.inputs._mouseInput.onPointerMovedObservable.add((function(e) {
  47291. 0 != r._dragFactor && (r._initialQuaternion || (r._initialQuaternion = new C),
  47292. C.FromEulerAnglesToRef(0, e.offsetX * r._dragFactor, 0, r._tmpDragQuaternion),
  47293. r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion, r._initialQuaternion))
  47294. }
  47295. )))
  47296. }
  47297. )),
  47298. r
  47299. }
  47300. return U(t, e),
  47301. Object.defineProperty(t.prototype, "disablePointerInputWhenUsingDeviceOrientation", {
  47302. get: function() {
  47303. return this._disablePointerInputWhenUsingDeviceOrientation
  47304. },
  47305. set: function(e) {
  47306. this._disablePointerInputWhenUsingDeviceOrientation = e
  47307. },
  47308. enumerable: !1,
  47309. configurable: !0
  47310. }),
  47311. t.prototype.enableHorizontalDragging = function(e) {
  47312. void 0 === e && (e = 1 / 300),
  47313. this._dragFactor = e
  47314. }
  47315. ,
  47316. t.prototype.getClassName = function() {
  47317. return "DeviceOrientationCamera"
  47318. }
  47319. ,
  47320. t.prototype._checkInputs = function() {
  47321. e.prototype._checkInputs.call(this),
  47322. this._quaternionCache.copyFrom(this.rotationQuaternion),
  47323. this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
  47324. }
  47325. ,
  47326. t.prototype.resetToCurrentRotation = function(e) {
  47327. var t = this;
  47328. void 0 === e && (e = vn.Y),
  47329. this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new C),
  47330. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion),
  47331. ["x", "y", "z"].forEach((function(i) {
  47332. e[i] ? t._initialQuaternion[i] *= -1 : t._initialQuaternion[i] = 0
  47333. }
  47334. )),
  47335. this._initialQuaternion.normalize(),
  47336. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion))
  47337. }
  47338. ,
  47339. t
  47340. }(pa)
  47341. , ga = function(e) {
  47342. function t(t) {
  47343. return e.call(this, t) || this
  47344. }
  47345. return U(t, e),
  47346. t.prototype.addKeyboard = function() {
  47347. return this.add(new qo),
  47348. this
  47349. }
  47350. ,
  47351. t.prototype.addMouse = function() {
  47352. return this.add(new Zo),
  47353. this
  47354. }
  47355. ,
  47356. t
  47357. }(ko)
  47358. , va = function(e) {
  47359. function t(t, i, n, r) {
  47360. void 0 === r && (r = !0);
  47361. var o = e.call(this, t, i, n, r) || this;
  47362. return o.ellipsoid = new x(1,1,1),
  47363. o.ellipsoidOffset = new x(0,0,0),
  47364. o.checkCollisions = !1,
  47365. o.applyGravity = !1,
  47366. o.cameraDirection = x.Zero(),
  47367. o._trackRoll = 0,
  47368. o.rollCorrect = 100,
  47369. o.bankedTurn = !1,
  47370. o.bankedTurnLimit = Math.PI / 2,
  47371. o.bankedTurnMultiplier = 1,
  47372. o._needMoveForGravity = !1,
  47373. o._oldPosition = x.Zero(),
  47374. o._diffPosition = x.Zero(),
  47375. o._newPosition = x.Zero(),
  47376. o._collisionMask = -1,
  47377. o._onCollisionPositionChange = function(e, t, i) {
  47378. var n;
  47379. void 0 === i && (i = null),
  47380. n = t,
  47381. o._newPosition.copyFrom(n),
  47382. o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
  47383. o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
  47384. o.onCollide && i && o.onCollide(i))
  47385. }
  47386. ,
  47387. o.inputs = new ga(o),
  47388. o.inputs.addKeyboard().addMouse(),
  47389. o
  47390. }
  47391. return U(t, e),
  47392. Object.defineProperty(t.prototype, "angularSensibility", {
  47393. get: function() {
  47394. var e = this.inputs.attached.mouse;
  47395. return e ? e.angularSensibility : 0
  47396. },
  47397. set: function(e) {
  47398. var t = this.inputs.attached.mouse;
  47399. t && (t.angularSensibility = e)
  47400. },
  47401. enumerable: !1,
  47402. configurable: !0
  47403. }),
  47404. Object.defineProperty(t.prototype, "keysForward", {
  47405. get: function() {
  47406. var e = this.inputs.attached.keyboard;
  47407. return e ? e.keysForward : []
  47408. },
  47409. set: function(e) {
  47410. var t = this.inputs.attached.keyboard;
  47411. t && (t.keysForward = e)
  47412. },
  47413. enumerable: !1,
  47414. configurable: !0
  47415. }),
  47416. Object.defineProperty(t.prototype, "keysBackward", {
  47417. get: function() {
  47418. var e = this.inputs.attached.keyboard;
  47419. return e ? e.keysBackward : []
  47420. },
  47421. set: function(e) {
  47422. var t = this.inputs.attached.keyboard;
  47423. t && (t.keysBackward = e)
  47424. },
  47425. enumerable: !1,
  47426. configurable: !0
  47427. }),
  47428. Object.defineProperty(t.prototype, "keysUp", {
  47429. get: function() {
  47430. var e = this.inputs.attached.keyboard;
  47431. return e ? e.keysUp : []
  47432. },
  47433. set: function(e) {
  47434. var t = this.inputs.attached.keyboard;
  47435. t && (t.keysUp = e)
  47436. },
  47437. enumerable: !1,
  47438. configurable: !0
  47439. }),
  47440. Object.defineProperty(t.prototype, "keysDown", {
  47441. get: function() {
  47442. var e = this.inputs.attached.keyboard;
  47443. return e ? e.keysDown : []
  47444. },
  47445. set: function(e) {
  47446. var t = this.inputs.attached.keyboard;
  47447. t && (t.keysDown = e)
  47448. },
  47449. enumerable: !1,
  47450. configurable: !0
  47451. }),
  47452. Object.defineProperty(t.prototype, "keysLeft", {
  47453. get: function() {
  47454. var e = this.inputs.attached.keyboard;
  47455. return e ? e.keysLeft : []
  47456. },
  47457. set: function(e) {
  47458. var t = this.inputs.attached.keyboard;
  47459. t && (t.keysLeft = e)
  47460. },
  47461. enumerable: !1,
  47462. configurable: !0
  47463. }),
  47464. Object.defineProperty(t.prototype, "keysRight", {
  47465. get: function() {
  47466. var e = this.inputs.attached.keyboard;
  47467. return e ? e.keysRight : []
  47468. },
  47469. set: function(e) {
  47470. var t = this.inputs.attached.keyboard;
  47471. t && (t.keysRight = e)
  47472. },
  47473. enumerable: !1,
  47474. configurable: !0
  47475. }),
  47476. t.prototype.attachControl = function(e, t) {
  47477. t = gi.BackCompatCameraNoPreventDefault(arguments),
  47478. this.inputs.attachElement(t)
  47479. }
  47480. ,
  47481. t.prototype.detachControl = function() {
  47482. this.inputs.detachElement(),
  47483. this.cameraDirection = new x(0,0,0)
  47484. }
  47485. ,
  47486. Object.defineProperty(t.prototype, "collisionMask", {
  47487. get: function() {
  47488. return this._collisionMask
  47489. },
  47490. set: function(e) {
  47491. this._collisionMask = isNaN(e) ? -1 : e
  47492. },
  47493. enumerable: !1,
  47494. configurable: !0
  47495. }),
  47496. t.prototype._collideWithWorld = function(e) {
  47497. (this.parent ? x.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
  47498. this._oldPosition.addInPlace(this.ellipsoidOffset);
  47499. var t = this.getScene().collisionCoordinator;
  47500. this._collider || (this._collider = t.createCollider()),
  47501. this._collider._radius = this.ellipsoid,
  47502. this._collider.collisionMask = this._collisionMask;
  47503. var i = e;
  47504. this.applyGravity && (i = e.add(this.getScene().gravity)),
  47505. t.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
  47506. }
  47507. ,
  47508. t.prototype._checkInputs = function() {
  47509. this._localDirection || (this._localDirection = x.Zero(),
  47510. this._transformedDirection = x.Zero()),
  47511. this.inputs.checkInputs(),
  47512. e.prototype._checkInputs.call(this)
  47513. }
  47514. ,
  47515. t.prototype._decideIfNeedsToMove = function() {
  47516. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
  47517. }
  47518. ,
  47519. t.prototype._updatePosition = function() {
  47520. this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : e.prototype._updatePosition.call(this)
  47521. }
  47522. ,
  47523. t.prototype.restoreRoll = function(e) {
  47524. var t = this._trackRoll
  47525. , i = t - this.rotation.z;
  47526. Math.abs(i) >= .001 && (this.rotation.z += i / e,
  47527. Math.abs(t - this.rotation.z) <= .001 && (this.rotation.z = t))
  47528. }
  47529. ,
  47530. t.prototype.dispose = function() {
  47531. this.inputs.clear(),
  47532. e.prototype.dispose.call(this)
  47533. }
  47534. ,
  47535. t.prototype.getClassName = function() {
  47536. return "FlyCamera"
  47537. }
  47538. ,
  47539. k([De()], t.prototype, "ellipsoid", void 0),
  47540. k([De()], t.prototype, "ellipsoidOffset", void 0),
  47541. k([Ce()], t.prototype, "checkCollisions", void 0),
  47542. k([Ce()], t.prototype, "applyGravity", void 0),
  47543. t
  47544. }(da)
  47545. , ya = function(e) {
  47546. function t(t) {
  47547. return e.call(this, t) || this
  47548. }
  47549. return U(t, e),
  47550. t.prototype.addKeyboard = function() {
  47551. return this.add(new Jo),
  47552. this
  47553. }
  47554. ,
  47555. t.prototype.addMouseWheel = function() {
  47556. return this.add(new $o),
  47557. this
  47558. }
  47559. ,
  47560. t.prototype.addPointers = function() {
  47561. return this.add(new ea),
  47562. this
  47563. }
  47564. ,
  47565. t.prototype.addVRDeviceOrientation = function() {
  47566. return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),
  47567. this
  47568. }
  47569. ,
  47570. t
  47571. }(ko);
  47572. Xe.AddNodeConstructor("FollowCamera", (function(e, t) {
  47573. return function() {
  47574. return new Ta(e,x.Zero(),t)
  47575. }
  47576. }
  47577. )),
  47578. Xe.AddNodeConstructor("ArcFollowCamera", (function(e, t) {
  47579. return function() {
  47580. return new Ea(e,0,0,1,null,t)
  47581. }
  47582. }
  47583. ));
  47584. var ba, Ta = function(e) {
  47585. function t(t, i, n, r) {
  47586. void 0 === r && (r = null);
  47587. var o = e.call(this, t, i, n) || this;
  47588. return o.radius = 12,
  47589. o.lowerRadiusLimit = null,
  47590. o.upperRadiusLimit = null,
  47591. o.rotationOffset = 0,
  47592. o.lowerRotationOffsetLimit = null,
  47593. o.upperRotationOffsetLimit = null,
  47594. o.heightOffset = 4,
  47595. o.lowerHeightOffsetLimit = null,
  47596. o.upperHeightOffsetLimit = null,
  47597. o.cameraAcceleration = .05,
  47598. o.maxCameraSpeed = 20,
  47599. o.lockedTarget = r,
  47600. o.inputs = new ya(o),
  47601. o.inputs.addKeyboard().addMouseWheel().addPointers(),
  47602. o
  47603. }
  47604. return U(t, e),
  47605. t.prototype._follow = function(e) {
  47606. if (e) {
  47607. var t = I.Matrix[0];
  47608. e.absoluteRotationQuaternion.toRotationMatrix(t);
  47609. var i = Math.atan2(t.m[8], t.m[10])
  47610. , n = gi.ToRadians(this.rotationOffset) + i
  47611. , r = e.getAbsolutePosition()
  47612. , o = r.x + Math.sin(n) * this.radius
  47613. , a = r.z + Math.cos(n) * this.radius
  47614. , s = o - this.position.x
  47615. , l = r.y + this.heightOffset - this.position.y
  47616. , c = a - this.position.z
  47617. , u = s * this.cameraAcceleration * 2
  47618. , h = l * this.cameraAcceleration
  47619. , d = c * this.cameraAcceleration * 2;
  47620. (u > this.maxCameraSpeed || u < -this.maxCameraSpeed) && (u = u < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
  47621. (h > this.maxCameraSpeed || h < -this.maxCameraSpeed) && (h = h < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
  47622. (d > this.maxCameraSpeed || d < -this.maxCameraSpeed) && (d = d < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
  47623. this.position = new x(this.position.x + u,this.position.y + h,this.position.z + d),
  47624. this.setTarget(r)
  47625. }
  47626. }
  47627. ,
  47628. t.prototype.attachControl = function(e, t) {
  47629. t = gi.BackCompatCameraNoPreventDefault(arguments),
  47630. this.inputs.attachElement(t),
  47631. this._reset = function() {}
  47632. }
  47633. ,
  47634. t.prototype.detachControl = function() {
  47635. this.inputs.detachElement(),
  47636. this._reset && this._reset()
  47637. }
  47638. ,
  47639. t.prototype._checkInputs = function() {
  47640. this.inputs.checkInputs(),
  47641. this._checkLimits(),
  47642. e.prototype._checkInputs.call(this),
  47643. this.lockedTarget && this._follow(this.lockedTarget)
  47644. }
  47645. ,
  47646. t.prototype._checkLimits = function() {
  47647. null !== this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit),
  47648. null !== this.upperRadiusLimit && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit),
  47649. null !== this.lowerHeightOffsetLimit && this.heightOffset < this.lowerHeightOffsetLimit && (this.heightOffset = this.lowerHeightOffsetLimit),
  47650. null !== this.upperHeightOffsetLimit && this.heightOffset > this.upperHeightOffsetLimit && (this.heightOffset = this.upperHeightOffsetLimit),
  47651. null !== this.lowerRotationOffsetLimit && this.rotationOffset < this.lowerRotationOffsetLimit && (this.rotationOffset = this.lowerRotationOffsetLimit),
  47652. null !== this.upperRotationOffsetLimit && this.rotationOffset > this.upperRotationOffsetLimit && (this.rotationOffset = this.upperRotationOffsetLimit)
  47653. }
  47654. ,
  47655. t.prototype.getClassName = function() {
  47656. return "FollowCamera"
  47657. }
  47658. ,
  47659. k([Ce()], t.prototype, "radius", void 0),
  47660. k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
  47661. k([Ce()], t.prototype, "upperRadiusLimit", void 0),
  47662. k([Ce()], t.prototype, "rotationOffset", void 0),
  47663. k([Ce()], t.prototype, "lowerRotationOffsetLimit", void 0),
  47664. k([Ce()], t.prototype, "upperRotationOffsetLimit", void 0),
  47665. k([Ce()], t.prototype, "heightOffset", void 0),
  47666. k([Ce()], t.prototype, "lowerHeightOffsetLimit", void 0),
  47667. k([Ce()], t.prototype, "upperHeightOffsetLimit", void 0),
  47668. k([Ce()], t.prototype, "cameraAcceleration", void 0),
  47669. k([Ce()], t.prototype, "maxCameraSpeed", void 0),
  47670. k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
  47671. t
  47672. }(da), Ea = function(e) {
  47673. function t(t, i, n, r, o, a) {
  47674. var s = e.call(this, t, x.Zero(), a) || this;
  47675. return s.alpha = i,
  47676. s.beta = n,
  47677. s.radius = r,
  47678. s._cartesianCoordinates = x.Zero(),
  47679. s.setMeshTarget(o),
  47680. s
  47681. }
  47682. return U(t, e),
  47683. t.prototype.setMeshTarget = function(e) {
  47684. this._meshTarget = e,
  47685. this._follow()
  47686. }
  47687. ,
  47688. t.prototype._follow = function() {
  47689. if (this._meshTarget) {
  47690. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta),
  47691. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta),
  47692. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  47693. var e = this._meshTarget.getAbsolutePosition();
  47694. this.position = e.add(this._cartesianCoordinates),
  47695. this.setTarget(e)
  47696. }
  47697. }
  47698. ,
  47699. t.prototype._checkInputs = function() {
  47700. e.prototype._checkInputs.call(this),
  47701. this._follow()
  47702. }
  47703. ,
  47704. t.prototype.getClassName = function() {
  47705. return "ArcFollowCamera"
  47706. }
  47707. ,
  47708. t
  47709. }(da);
  47710. !function(e) {
  47711. e[e.VIVE = 0] = "VIVE",
  47712. e[e.OCULUS = 1] = "OCULUS",
  47713. e[e.WINDOWS = 2] = "WINDOWS",
  47714. e[e.GEAR_VR = 3] = "GEAR_VR",
  47715. e[e.DAYDREAM = 4] = "DAYDREAM",
  47716. e[e.GENERIC = 5] = "GENERIC"
  47717. }(ba || (ba = {}));
  47718. var Sa, Aa, xa = function() {
  47719. function e() {}
  47720. return e.InitiateController = function(e) {
  47721. for (var t = 0, i = this._ControllerFactories; t < i.length; t++) {
  47722. var n = i[t];
  47723. if (n.canCreate(e))
  47724. return n.create(e)
  47725. }
  47726. if (this._DefaultControllerFactory)
  47727. return this._DefaultControllerFactory(e);
  47728. throw "The type of gamepad you are trying to load needs to be imported first or is not supported."
  47729. }
  47730. ,
  47731. e._ControllerFactories = [],
  47732. e._DefaultControllerFactory = null,
  47733. e
  47734. }(), Ra = function(e) {
  47735. function t(t) {
  47736. var i = e.call(this, t.id, t.index, t) || this;
  47737. return i.isXR = !1,
  47738. i._deviceRoomPosition = x.Zero(),
  47739. i._deviceRoomRotationQuaternion = new C,
  47740. i.devicePosition = x.Zero(),
  47741. i.deviceRotationQuaternion = new C,
  47742. i.deviceScaleFactor = 1,
  47743. i._trackPosition = !0,
  47744. i._maxRotationDistFromHeadset = Math.PI / 5,
  47745. i._draggedRoomRotation = 0,
  47746. i._leftHandSystemQuaternion = new C,
  47747. i._deviceToWorld = P.Identity(),
  47748. i._pointingPoseNode = null,
  47749. i._workingMatrix = P.Identity(),
  47750. i._meshAttachedObservable = new h,
  47751. i.type = zo.POSE_ENABLED,
  47752. i.controllerType = ba.GENERIC,
  47753. i.position = x.Zero(),
  47754. i.rotationQuaternion = new C,
  47755. i._calculatedPosition = x.Zero(),
  47756. i._calculatedRotation = new C,
  47757. C.RotationYawPitchRollToRef(Math.PI, 0, 0, i._leftHandSystemQuaternion),
  47758. i
  47759. }
  47760. return U(t, e),
  47761. t.prototype._disableTrackPosition = function(e) {
  47762. this._trackPosition && (this._calculatedPosition.copyFrom(e),
  47763. this._trackPosition = !1)
  47764. }
  47765. ,
  47766. t.prototype.update = function() {
  47767. e.prototype.update.call(this),
  47768. this._updatePoseAndMesh()
  47769. }
  47770. ,
  47771. t.prototype._updatePoseAndMesh = function() {
  47772. if (!this.isXR) {
  47773. var e = this.browserGamepad.pose;
  47774. if (this.updateFromDevice(e),
  47775. !this._trackPosition && E.LastCreatedScene && E.LastCreatedScene.activeCamera && E.LastCreatedScene.activeCamera.devicePosition) {
  47776. var t = E.LastCreatedScene.activeCamera;
  47777. if (t._computeDevicePosition(),
  47778. this._deviceToWorld.setTranslation(t.devicePosition),
  47779. t.deviceRotationQuaternion) {
  47780. t._deviceRoomRotationQuaternion.toEulerAnglesToRef(I.Vector3[0]);
  47781. var i = Math.atan2(Math.sin(I.Vector3[0].y - this._draggedRoomRotation), Math.cos(I.Vector3[0].y - this._draggedRoomRotation));
  47782. if (Math.abs(i) > this._maxRotationDistFromHeadset) {
  47783. var n = i - (i < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  47784. this._draggedRoomRotation += n;
  47785. var r = Math.sin(-n)
  47786. , o = Math.cos(-n);
  47787. this._calculatedPosition.x = this._calculatedPosition.x * o - this._calculatedPosition.z * r,
  47788. this._calculatedPosition.z = this._calculatedPosition.x * r + this._calculatedPosition.z * o
  47789. }
  47790. }
  47791. }
  47792. x.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition),
  47793. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),
  47794. C.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
  47795. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),
  47796. this._mesh && (this._mesh.position.copyFrom(this.devicePosition),
  47797. this._mesh.rotationQuaternion && this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))
  47798. }
  47799. }
  47800. ,
  47801. t.prototype.updateFromDevice = function(e) {
  47802. if (!this.isXR && e) {
  47803. this.rawPose = e,
  47804. e.position && (this._deviceRoomPosition.copyFromFloats(e.position[0], e.position[1], -e.position[2]),
  47805. this._mesh && this._mesh.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1),
  47806. this._trackPosition && this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition),
  47807. this._calculatedPosition.addInPlace(this.position));
  47808. var t = this.rawPose;
  47809. e.orientation && t.orientation && 4 === t.orientation.length && (this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0], t.orientation[1], -t.orientation[2], -t.orientation[3]),
  47810. this._mesh && (this._mesh.getScene().useRightHandedSystem ? (this._deviceRoomRotationQuaternion.z *= -1,
  47811. this._deviceRoomRotationQuaternion.w *= -1) : this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion)),
  47812. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation))
  47813. }
  47814. }
  47815. ,
  47816. t.prototype.attachToMesh = function(e) {
  47817. if (this._mesh && (this._mesh.parent = null),
  47818. this._mesh = e,
  47819. this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera),
  47820. this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new C),
  47821. !this.isXR && (this._updatePoseAndMesh(),
  47822. this._pointingPoseNode)) {
  47823. for (var t = [], i = this._pointingPoseNode; i.parent; )
  47824. t.push(i.parent),
  47825. i = i.parent;
  47826. t.reverse().forEach((function(e) {
  47827. e.computeWorldMatrix(!0)
  47828. }
  47829. ))
  47830. }
  47831. this._meshAttachedObservable.notifyObservers(e)
  47832. }
  47833. ,
  47834. t.prototype.attachToPoseControlledCamera = function(e) {
  47835. this._poseControlledCamera = e,
  47836. this._mesh && (this._mesh.parent = this._poseControlledCamera)
  47837. }
  47838. ,
  47839. t.prototype.dispose = function() {
  47840. this._mesh && this._mesh.dispose(),
  47841. this._mesh = null,
  47842. e.prototype.dispose.call(this)
  47843. }
  47844. ,
  47845. Object.defineProperty(t.prototype, "mesh", {
  47846. get: function() {
  47847. return this._mesh
  47848. },
  47849. enumerable: !1,
  47850. configurable: !0
  47851. }),
  47852. t.prototype.getForwardRay = function(e) {
  47853. if (void 0 === e && (e = 100),
  47854. !this.mesh)
  47855. return new _o(x.Zero(),new x(0,0,1),e);
  47856. var t = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix()
  47857. , i = t.getTranslation()
  47858. , n = new x(0,0,-1)
  47859. , r = x.TransformNormal(n, t)
  47860. , o = x.Normalize(r);
  47861. return new _o(i,o,e)
  47862. }
  47863. ,
  47864. t.POINTING_POSE = "POINTING_POSE",
  47865. t
  47866. }(zo);
  47867. !function(e) {
  47868. e[e.A = 0] = "A",
  47869. e[e.B = 1] = "B",
  47870. e[e.X = 2] = "X",
  47871. e[e.Y = 3] = "Y",
  47872. e[e.LB = 4] = "LB",
  47873. e[e.RB = 5] = "RB",
  47874. e[e.Back = 8] = "Back",
  47875. e[e.Start = 9] = "Start",
  47876. e[e.LeftStick = 10] = "LeftStick",
  47877. e[e.RightStick = 11] = "RightStick"
  47878. }(Sa || (Sa = {})),
  47879. function(e) {
  47880. e[e.Up = 12] = "Up",
  47881. e[e.Down = 13] = "Down",
  47882. e[e.Left = 14] = "Left",
  47883. e[e.Right = 15] = "Right"
  47884. }(Aa || (Aa = {}));
  47885. var Ca, Pa, Ma = function(e) {
  47886. function t(t, i, n, r) {
  47887. void 0 === r && (r = !1);
  47888. var o = e.call(this, t, i, n, 0, 1, 2, 3) || this;
  47889. return o._leftTrigger = 0,
  47890. o._rightTrigger = 0,
  47891. o.onButtonDownObservable = new h,
  47892. o.onButtonUpObservable = new h,
  47893. o.onPadDownObservable = new h,
  47894. o.onPadUpObservable = new h,
  47895. o._buttonA = 0,
  47896. o._buttonB = 0,
  47897. o._buttonX = 0,
  47898. o._buttonY = 0,
  47899. o._buttonBack = 0,
  47900. o._buttonStart = 0,
  47901. o._buttonLB = 0,
  47902. o._buttonRB = 0,
  47903. o._buttonLeftStick = 0,
  47904. o._buttonRightStick = 0,
  47905. o._dPadUp = 0,
  47906. o._dPadDown = 0,
  47907. o._dPadLeft = 0,
  47908. o._dPadRight = 0,
  47909. o._isXboxOnePad = !1,
  47910. o.type = zo.XBOX,
  47911. o._isXboxOnePad = r,
  47912. o
  47913. }
  47914. return U(t, e),
  47915. t.prototype.onlefttriggerchanged = function(e) {
  47916. this._onlefttriggerchanged = e
  47917. }
  47918. ,
  47919. t.prototype.onrighttriggerchanged = function(e) {
  47920. this._onrighttriggerchanged = e
  47921. }
  47922. ,
  47923. Object.defineProperty(t.prototype, "leftTrigger", {
  47924. get: function() {
  47925. return this._leftTrigger
  47926. },
  47927. set: function(e) {
  47928. this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e),
  47929. this._leftTrigger = e
  47930. },
  47931. enumerable: !1,
  47932. configurable: !0
  47933. }),
  47934. Object.defineProperty(t.prototype, "rightTrigger", {
  47935. get: function() {
  47936. return this._rightTrigger
  47937. },
  47938. set: function(e) {
  47939. this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e),
  47940. this._rightTrigger = e
  47941. },
  47942. enumerable: !1,
  47943. configurable: !0
  47944. }),
  47945. t.prototype.onbuttondown = function(e) {
  47946. this._onbuttondown = e
  47947. }
  47948. ,
  47949. t.prototype.onbuttonup = function(e) {
  47950. this._onbuttonup = e
  47951. }
  47952. ,
  47953. t.prototype.ondpaddown = function(e) {
  47954. this._ondpaddown = e
  47955. }
  47956. ,
  47957. t.prototype.ondpadup = function(e) {
  47958. this._ondpadup = e
  47959. }
  47960. ,
  47961. t.prototype._setButtonValue = function(e, t, i) {
  47962. return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
  47963. this.onButtonDownObservable.notifyObservers(i)),
  47964. 0 === e && (this._onbuttonup && this._onbuttonup(i),
  47965. this.onButtonUpObservable.notifyObservers(i))),
  47966. e
  47967. }
  47968. ,
  47969. t.prototype._setDPadValue = function(e, t, i) {
  47970. return e !== t && (1 === e && (this._ondpaddown && this._ondpaddown(i),
  47971. this.onPadDownObservable.notifyObservers(i)),
  47972. 0 === e && (this._ondpadup && this._ondpadup(i),
  47973. this.onPadUpObservable.notifyObservers(i))),
  47974. e
  47975. }
  47976. ,
  47977. Object.defineProperty(t.prototype, "buttonA", {
  47978. get: function() {
  47979. return this._buttonA
  47980. },
  47981. set: function(e) {
  47982. this._buttonA = this._setButtonValue(e, this._buttonA, Sa.A)
  47983. },
  47984. enumerable: !1,
  47985. configurable: !0
  47986. }),
  47987. Object.defineProperty(t.prototype, "buttonB", {
  47988. get: function() {
  47989. return this._buttonB
  47990. },
  47991. set: function(e) {
  47992. this._buttonB = this._setButtonValue(e, this._buttonB, Sa.B)
  47993. },
  47994. enumerable: !1,
  47995. configurable: !0
  47996. }),
  47997. Object.defineProperty(t.prototype, "buttonX", {
  47998. get: function() {
  47999. return this._buttonX
  48000. },
  48001. set: function(e) {
  48002. this._buttonX = this._setButtonValue(e, this._buttonX, Sa.X)
  48003. },
  48004. enumerable: !1,
  48005. configurable: !0
  48006. }),
  48007. Object.defineProperty(t.prototype, "buttonY", {
  48008. get: function() {
  48009. return this._buttonY
  48010. },
  48011. set: function(e) {
  48012. this._buttonY = this._setButtonValue(e, this._buttonY, Sa.Y)
  48013. },
  48014. enumerable: !1,
  48015. configurable: !0
  48016. }),
  48017. Object.defineProperty(t.prototype, "buttonStart", {
  48018. get: function() {
  48019. return this._buttonStart
  48020. },
  48021. set: function(e) {
  48022. this._buttonStart = this._setButtonValue(e, this._buttonStart, Sa.Start)
  48023. },
  48024. enumerable: !1,
  48025. configurable: !0
  48026. }),
  48027. Object.defineProperty(t.prototype, "buttonBack", {
  48028. get: function() {
  48029. return this._buttonBack
  48030. },
  48031. set: function(e) {
  48032. this._buttonBack = this._setButtonValue(e, this._buttonBack, Sa.Back)
  48033. },
  48034. enumerable: !1,
  48035. configurable: !0
  48036. }),
  48037. Object.defineProperty(t.prototype, "buttonLB", {
  48038. get: function() {
  48039. return this._buttonLB
  48040. },
  48041. set: function(e) {
  48042. this._buttonLB = this._setButtonValue(e, this._buttonLB, Sa.LB)
  48043. },
  48044. enumerable: !1,
  48045. configurable: !0
  48046. }),
  48047. Object.defineProperty(t.prototype, "buttonRB", {
  48048. get: function() {
  48049. return this._buttonRB
  48050. },
  48051. set: function(e) {
  48052. this._buttonRB = this._setButtonValue(e, this._buttonRB, Sa.RB)
  48053. },
  48054. enumerable: !1,
  48055. configurable: !0
  48056. }),
  48057. Object.defineProperty(t.prototype, "buttonLeftStick", {
  48058. get: function() {
  48059. return this._buttonLeftStick
  48060. },
  48061. set: function(e) {
  48062. this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Sa.LeftStick)
  48063. },
  48064. enumerable: !1,
  48065. configurable: !0
  48066. }),
  48067. Object.defineProperty(t.prototype, "buttonRightStick", {
  48068. get: function() {
  48069. return this._buttonRightStick
  48070. },
  48071. set: function(e) {
  48072. this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Sa.RightStick)
  48073. },
  48074. enumerable: !1,
  48075. configurable: !0
  48076. }),
  48077. Object.defineProperty(t.prototype, "dPadUp", {
  48078. get: function() {
  48079. return this._dPadUp
  48080. },
  48081. set: function(e) {
  48082. this._dPadUp = this._setDPadValue(e, this._dPadUp, Aa.Up)
  48083. },
  48084. enumerable: !1,
  48085. configurable: !0
  48086. }),
  48087. Object.defineProperty(t.prototype, "dPadDown", {
  48088. get: function() {
  48089. return this._dPadDown
  48090. },
  48091. set: function(e) {
  48092. this._dPadDown = this._setDPadValue(e, this._dPadDown, Aa.Down)
  48093. },
  48094. enumerable: !1,
  48095. configurable: !0
  48096. }),
  48097. Object.defineProperty(t.prototype, "dPadLeft", {
  48098. get: function() {
  48099. return this._dPadLeft
  48100. },
  48101. set: function(e) {
  48102. this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Aa.Left)
  48103. },
  48104. enumerable: !1,
  48105. configurable: !0
  48106. }),
  48107. Object.defineProperty(t.prototype, "dPadRight", {
  48108. get: function() {
  48109. return this._dPadRight
  48110. },
  48111. set: function(e) {
  48112. this._dPadRight = this._setDPadValue(e, this._dPadRight, Aa.Right)
  48113. },
  48114. enumerable: !1,
  48115. configurable: !0
  48116. }),
  48117. t.prototype.update = function() {
  48118. e.prototype.update.call(this),
  48119. this._isXboxOnePad,
  48120. this.buttonA = this.browserGamepad.buttons[0].value,
  48121. this.buttonB = this.browserGamepad.buttons[1].value,
  48122. this.buttonX = this.browserGamepad.buttons[2].value,
  48123. this.buttonY = this.browserGamepad.buttons[3].value,
  48124. this.buttonLB = this.browserGamepad.buttons[4].value,
  48125. this.buttonRB = this.browserGamepad.buttons[5].value,
  48126. this.leftTrigger = this.browserGamepad.buttons[6].value,
  48127. this.rightTrigger = this.browserGamepad.buttons[7].value,
  48128. this.buttonBack = this.browserGamepad.buttons[8].value,
  48129. this.buttonStart = this.browserGamepad.buttons[9].value,
  48130. this.buttonLeftStick = this.browserGamepad.buttons[10].value,
  48131. this.buttonRightStick = this.browserGamepad.buttons[11].value,
  48132. this.dPadUp = this.browserGamepad.buttons[12].value,
  48133. this.dPadDown = this.browserGamepad.buttons[13].value,
  48134. this.dPadLeft = this.browserGamepad.buttons[14].value,
  48135. this.dPadRight = this.browserGamepad.buttons[15].value
  48136. }
  48137. ,
  48138. t.prototype.dispose = function() {
  48139. e.prototype.dispose.call(this),
  48140. this.onButtonDownObservable.clear(),
  48141. this.onButtonUpObservable.clear(),
  48142. this.onPadDownObservable.clear(),
  48143. this.onPadUpObservable.clear()
  48144. }
  48145. ,
  48146. t
  48147. }(zo);
  48148. !function(e) {
  48149. e[e.Cross = 0] = "Cross",
  48150. e[e.Circle = 1] = "Circle",
  48151. e[e.Square = 2] = "Square",
  48152. e[e.Triangle = 3] = "Triangle",
  48153. e[e.L1 = 4] = "L1",
  48154. e[e.R1 = 5] = "R1",
  48155. e[e.Share = 8] = "Share",
  48156. e[e.Options = 9] = "Options",
  48157. e[e.LeftStick = 10] = "LeftStick",
  48158. e[e.RightStick = 11] = "RightStick"
  48159. }(Ca || (Ca = {})),
  48160. function(e) {
  48161. e[e.Up = 12] = "Up",
  48162. e[e.Down = 13] = "Down",
  48163. e[e.Left = 14] = "Left",
  48164. e[e.Right = 15] = "Right"
  48165. }(Pa || (Pa = {}));
  48166. var Ia = function(e) {
  48167. function t(t, i, n) {
  48168. var r = e.call(this, t.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), i, n, 0, 1, 2, 3) || this;
  48169. return r._leftTrigger = 0,
  48170. r._rightTrigger = 0,
  48171. r.onButtonDownObservable = new h,
  48172. r.onButtonUpObservable = new h,
  48173. r.onPadDownObservable = new h,
  48174. r.onPadUpObservable = new h,
  48175. r._buttonCross = 0,
  48176. r._buttonCircle = 0,
  48177. r._buttonSquare = 0,
  48178. r._buttonTriangle = 0,
  48179. r._buttonShare = 0,
  48180. r._buttonOptions = 0,
  48181. r._buttonL1 = 0,
  48182. r._buttonR1 = 0,
  48183. r._buttonLeftStick = 0,
  48184. r._buttonRightStick = 0,
  48185. r._dPadUp = 0,
  48186. r._dPadDown = 0,
  48187. r._dPadLeft = 0,
  48188. r._dPadRight = 0,
  48189. r.type = zo.DUALSHOCK,
  48190. r
  48191. }
  48192. return U(t, e),
  48193. t.prototype.onlefttriggerchanged = function(e) {
  48194. this._onlefttriggerchanged = e
  48195. }
  48196. ,
  48197. t.prototype.onrighttriggerchanged = function(e) {
  48198. this._onrighttriggerchanged = e
  48199. }
  48200. ,
  48201. Object.defineProperty(t.prototype, "leftTrigger", {
  48202. get: function() {
  48203. return this._leftTrigger
  48204. },
  48205. set: function(e) {
  48206. this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e),
  48207. this._leftTrigger = e
  48208. },
  48209. enumerable: !1,
  48210. configurable: !0
  48211. }),
  48212. Object.defineProperty(t.prototype, "rightTrigger", {
  48213. get: function() {
  48214. return this._rightTrigger
  48215. },
  48216. set: function(e) {
  48217. this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e),
  48218. this._rightTrigger = e
  48219. },
  48220. enumerable: !1,
  48221. configurable: !0
  48222. }),
  48223. t.prototype.onbuttondown = function(e) {
  48224. this._onbuttondown = e
  48225. }
  48226. ,
  48227. t.prototype.onbuttonup = function(e) {
  48228. this._onbuttonup = e
  48229. }
  48230. ,
  48231. t.prototype.ondpaddown = function(e) {
  48232. this._ondpaddown = e
  48233. }
  48234. ,
  48235. t.prototype.ondpadup = function(e) {
  48236. this._ondpadup = e
  48237. }
  48238. ,
  48239. t.prototype._setButtonValue = function(e, t, i) {
  48240. return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
  48241. this.onButtonDownObservable.notifyObservers(i)),
  48242. 0 === e && (this._onbuttonup && this._onbuttonup(i),
  48243. this.onButtonUpObservable.notifyObservers(i))),
  48244. e
  48245. }
  48246. ,
  48247. t.prototype._setDPadValue = function(e, t, i) {
  48248. return e !== t && (1 === e && (this._ondpaddown && this._ondpaddown(i),
  48249. this.onPadDownObservable.notifyObservers(i)),
  48250. 0 === e && (this._ondpadup && this._ondpadup(i),
  48251. this.onPadUpObservable.notifyObservers(i))),
  48252. e
  48253. }
  48254. ,
  48255. Object.defineProperty(t.prototype, "buttonCross", {
  48256. get: function() {
  48257. return this._buttonCross
  48258. },
  48259. set: function(e) {
  48260. this._buttonCross = this._setButtonValue(e, this._buttonCross, Ca.Cross)
  48261. },
  48262. enumerable: !1,
  48263. configurable: !0
  48264. }),
  48265. Object.defineProperty(t.prototype, "buttonCircle", {
  48266. get: function() {
  48267. return this._buttonCircle
  48268. },
  48269. set: function(e) {
  48270. this._buttonCircle = this._setButtonValue(e, this._buttonCircle, Ca.Circle)
  48271. },
  48272. enumerable: !1,
  48273. configurable: !0
  48274. }),
  48275. Object.defineProperty(t.prototype, "buttonSquare", {
  48276. get: function() {
  48277. return this._buttonSquare
  48278. },
  48279. set: function(e) {
  48280. this._buttonSquare = this._setButtonValue(e, this._buttonSquare, Ca.Square)
  48281. },
  48282. enumerable: !1,
  48283. configurable: !0
  48284. }),
  48285. Object.defineProperty(t.prototype, "buttonTriangle", {
  48286. get: function() {
  48287. return this._buttonTriangle
  48288. },
  48289. set: function(e) {
  48290. this._buttonTriangle = this._setButtonValue(e, this._buttonTriangle, Ca.Triangle)
  48291. },
  48292. enumerable: !1,
  48293. configurable: !0
  48294. }),
  48295. Object.defineProperty(t.prototype, "buttonOptions", {
  48296. get: function() {
  48297. return this._buttonOptions
  48298. },
  48299. set: function(e) {
  48300. this._buttonOptions = this._setButtonValue(e, this._buttonOptions, Ca.Options)
  48301. },
  48302. enumerable: !1,
  48303. configurable: !0
  48304. }),
  48305. Object.defineProperty(t.prototype, "buttonShare", {
  48306. get: function() {
  48307. return this._buttonShare
  48308. },
  48309. set: function(e) {
  48310. this._buttonShare = this._setButtonValue(e, this._buttonShare, Ca.Share)
  48311. },
  48312. enumerable: !1,
  48313. configurable: !0
  48314. }),
  48315. Object.defineProperty(t.prototype, "buttonL1", {
  48316. get: function() {
  48317. return this._buttonL1
  48318. },
  48319. set: function(e) {
  48320. this._buttonL1 = this._setButtonValue(e, this._buttonL1, Ca.L1)
  48321. },
  48322. enumerable: !1,
  48323. configurable: !0
  48324. }),
  48325. Object.defineProperty(t.prototype, "buttonR1", {
  48326. get: function() {
  48327. return this._buttonR1
  48328. },
  48329. set: function(e) {
  48330. this._buttonR1 = this._setButtonValue(e, this._buttonR1, Ca.R1)
  48331. },
  48332. enumerable: !1,
  48333. configurable: !0
  48334. }),
  48335. Object.defineProperty(t.prototype, "buttonLeftStick", {
  48336. get: function() {
  48337. return this._buttonLeftStick
  48338. },
  48339. set: function(e) {
  48340. this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Ca.LeftStick)
  48341. },
  48342. enumerable: !1,
  48343. configurable: !0
  48344. }),
  48345. Object.defineProperty(t.prototype, "buttonRightStick", {
  48346. get: function() {
  48347. return this._buttonRightStick
  48348. },
  48349. set: function(e) {
  48350. this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Ca.RightStick)
  48351. },
  48352. enumerable: !1,
  48353. configurable: !0
  48354. }),
  48355. Object.defineProperty(t.prototype, "dPadUp", {
  48356. get: function() {
  48357. return this._dPadUp
  48358. },
  48359. set: function(e) {
  48360. this._dPadUp = this._setDPadValue(e, this._dPadUp, Pa.Up)
  48361. },
  48362. enumerable: !1,
  48363. configurable: !0
  48364. }),
  48365. Object.defineProperty(t.prototype, "dPadDown", {
  48366. get: function() {
  48367. return this._dPadDown
  48368. },
  48369. set: function(e) {
  48370. this._dPadDown = this._setDPadValue(e, this._dPadDown, Pa.Down)
  48371. },
  48372. enumerable: !1,
  48373. configurable: !0
  48374. }),
  48375. Object.defineProperty(t.prototype, "dPadLeft", {
  48376. get: function() {
  48377. return this._dPadLeft
  48378. },
  48379. set: function(e) {
  48380. this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Pa.Left)
  48381. },
  48382. enumerable: !1,
  48383. configurable: !0
  48384. }),
  48385. Object.defineProperty(t.prototype, "dPadRight", {
  48386. get: function() {
  48387. return this._dPadRight
  48388. },
  48389. set: function(e) {
  48390. this._dPadRight = this._setDPadValue(e, this._dPadRight, Pa.Right)
  48391. },
  48392. enumerable: !1,
  48393. configurable: !0
  48394. }),
  48395. t.prototype.update = function() {
  48396. e.prototype.update.call(this),
  48397. this.buttonCross = this.browserGamepad.buttons[0].value,
  48398. this.buttonCircle = this.browserGamepad.buttons[1].value,
  48399. this.buttonSquare = this.browserGamepad.buttons[2].value,
  48400. this.buttonTriangle = this.browserGamepad.buttons[3].value,
  48401. this.buttonL1 = this.browserGamepad.buttons[4].value,
  48402. this.buttonR1 = this.browserGamepad.buttons[5].value,
  48403. this.leftTrigger = this.browserGamepad.buttons[6].value,
  48404. this.rightTrigger = this.browserGamepad.buttons[7].value,
  48405. this.buttonShare = this.browserGamepad.buttons[8].value,
  48406. this.buttonOptions = this.browserGamepad.buttons[9].value,
  48407. this.buttonLeftStick = this.browserGamepad.buttons[10].value,
  48408. this.buttonRightStick = this.browserGamepad.buttons[11].value,
  48409. this.dPadUp = this.browserGamepad.buttons[12].value,
  48410. this.dPadDown = this.browserGamepad.buttons[13].value,
  48411. this.dPadLeft = this.browserGamepad.buttons[14].value,
  48412. this.dPadRight = this.browserGamepad.buttons[15].value
  48413. }
  48414. ,
  48415. t.prototype.dispose = function() {
  48416. e.prototype.dispose.call(this),
  48417. this.onButtonDownObservable.clear(),
  48418. this.onButtonUpObservable.clear(),
  48419. this.onPadDownObservable.clear(),
  48420. this.onPadUpObservable.clear()
  48421. }
  48422. ,
  48423. t
  48424. }(zo)
  48425. , Oa = function() {
  48426. function e(e) {
  48427. var t = this;
  48428. if (this._scene = e,
  48429. this._babylonGamepads = [],
  48430. this._oneGamepadConnected = !1,
  48431. this._isMonitoring = !1,
  48432. this.onGamepadDisconnectedObservable = new h,
  48433. nt() ? (this._gamepadEventSupported = "GamepadEvent"in window,
  48434. this._gamepadSupport = navigator && (navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads)) : this._gamepadEventSupported = !1,
  48435. this.onGamepadConnectedObservable = new h((function(e) {
  48436. for (var i in t._babylonGamepads) {
  48437. var n = t._babylonGamepads[i];
  48438. n && n._isConnected && t.onGamepadConnectedObservable.notifyObserver(e, n)
  48439. }
  48440. }
  48441. )),
  48442. this._onGamepadConnectedEvent = function(e) {
  48443. var i, n = e.gamepad;
  48444. n.index in t._babylonGamepads && t._babylonGamepads[n.index].isConnected || (t._babylonGamepads[n.index] ? ((i = t._babylonGamepads[n.index]).browserGamepad = n,
  48445. i._isConnected = !0) : i = t._addNewGamepad(n),
  48446. t.onGamepadConnectedObservable.notifyObservers(i),
  48447. t._startMonitoringGamepads())
  48448. }
  48449. ,
  48450. this._onGamepadDisconnectedEvent = function(e) {
  48451. var i = e.gamepad;
  48452. for (var n in t._babylonGamepads)
  48453. if (t._babylonGamepads[n].index === i.index) {
  48454. var r = t._babylonGamepads[n];
  48455. r._isConnected = !1,
  48456. t.onGamepadDisconnectedObservable.notifyObservers(r),
  48457. r.dispose && r.dispose();
  48458. break
  48459. }
  48460. }
  48461. ,
  48462. this._gamepadSupport)
  48463. if (this._updateGamepadObjects(),
  48464. this._babylonGamepads.length && this._startMonitoringGamepads(),
  48465. this._gamepadEventSupported) {
  48466. var i = this._scene ? this._scene.getEngine().getHostWindow() : window;
  48467. i && (i.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1),
  48468. i.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1))
  48469. } else
  48470. this._startMonitoringGamepads()
  48471. }
  48472. return Object.defineProperty(e.prototype, "gamepads", {
  48473. get: function() {
  48474. return this._babylonGamepads
  48475. },
  48476. enumerable: !1,
  48477. configurable: !0
  48478. }),
  48479. e.prototype.getGamepadByType = function(e) {
  48480. void 0 === e && (e = zo.XBOX);
  48481. for (var t = 0, i = this._babylonGamepads; t < i.length; t++) {
  48482. var n = i[t];
  48483. if (n && n.type === e)
  48484. return n
  48485. }
  48486. return null
  48487. }
  48488. ,
  48489. e.prototype.dispose = function() {
  48490. this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent),
  48491. this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent),
  48492. this._onGamepadConnectedEvent = null,
  48493. this._onGamepadDisconnectedEvent = null),
  48494. this._babylonGamepads.forEach((function(e) {
  48495. e.dispose()
  48496. }
  48497. )),
  48498. this.onGamepadConnectedObservable.clear(),
  48499. this.onGamepadDisconnectedObservable.clear(),
  48500. this._oneGamepadConnected = !1,
  48501. this._stopMonitoringGamepads(),
  48502. this._babylonGamepads = []
  48503. }
  48504. ,
  48505. e.prototype._addNewGamepad = function(e) {
  48506. var t;
  48507. this._oneGamepadConnected || (this._oneGamepadConnected = !0);
  48508. var i = -1 !== e.id.search("054c") && -1 === e.id.search("0ce6")
  48509. , n = -1 !== e.id.search("Xbox One");
  48510. return t = n || -1 !== e.id.search("Xbox 360") || -1 !== e.id.search("xinput") || -1 !== e.id.search("045e") && -1 === e.id.search("Surface Dock") ? new Ma(e.id,e.index,e,n) : i ? new Ia(e.id,e.index,e) : e.pose ? xa.InitiateController(e) : new Wo(e.id,e.index,e),
  48511. this._babylonGamepads[t.index] = t,
  48512. t
  48513. }
  48514. ,
  48515. e.prototype._startMonitoringGamepads = function() {
  48516. this._isMonitoring || (this._isMonitoring = !0,
  48517. this._scene || this._checkGamepadsStatus())
  48518. }
  48519. ,
  48520. e.prototype._stopMonitoringGamepads = function() {
  48521. this._isMonitoring = !1
  48522. }
  48523. ,
  48524. e.prototype._checkGamepadsStatus = function() {
  48525. var e = this;
  48526. for (var t in this._updateGamepadObjects(),
  48527. this._babylonGamepads) {
  48528. var i = this._babylonGamepads[t];
  48529. if (i && i.isConnected)
  48530. try {
  48531. i.update()
  48532. } catch (e) {
  48533. -1 === this._loggedErrors.indexOf(i.index) && (gi.Warn("Error updating gamepad ".concat(i.id)),
  48534. this._loggedErrors.push(i.index))
  48535. }
  48536. }
  48537. this._isMonitoring && !this._scene && vr.QueueNewFrame((function() {
  48538. e._checkGamepadsStatus()
  48539. }
  48540. ))
  48541. }
  48542. ,
  48543. e.prototype._updateGamepadObjects = function() {
  48544. for (var e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], t = 0; t < e.length; t++) {
  48545. var i = e[t];
  48546. if (i)
  48547. if (this._babylonGamepads[i.index])
  48548. this._babylonGamepads[t].browserGamepad = i,
  48549. this._babylonGamepads[t].isConnected || (this._babylonGamepads[t]._isConnected = !0,
  48550. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));
  48551. else {
  48552. var n = this._addNewGamepad(i);
  48553. this.onGamepadConnectedObservable.notifyObservers(n)
  48554. }
  48555. }
  48556. }
  48557. ,
  48558. e
  48559. }();
  48560. Object.defineProperty(mn.prototype, "gamepadManager", {
  48561. get: function() {
  48562. if (!this._gamepadManager) {
  48563. this._gamepadManager = new Oa(this);
  48564. var e = this._getComponent(Wi.NAME_GAMEPAD);
  48565. e || (e = new Da(this),
  48566. this._addComponent(e))
  48567. }
  48568. return this._gamepadManager
  48569. },
  48570. enumerable: !0,
  48571. configurable: !0
  48572. }),
  48573. aa.prototype.addGamepad = function() {
  48574. return this.add(new ca),
  48575. this
  48576. }
  48577. ,
  48578. Ko.prototype.addGamepad = function() {
  48579. return this.add(new Ho),
  48580. this
  48581. }
  48582. ;
  48583. var Da = function() {
  48584. function e(e) {
  48585. this.name = Wi.NAME_GAMEPAD,
  48586. this.scene = e
  48587. }
  48588. return e.prototype.register = function() {
  48589. this.scene._beforeCameraUpdateStage.registerStep(Wi.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate)
  48590. }
  48591. ,
  48592. e.prototype.rebuild = function() {}
  48593. ,
  48594. e.prototype.dispose = function() {
  48595. var e = this.scene._gamepadManager;
  48596. e && (e.dispose(),
  48597. this.scene._gamepadManager = null)
  48598. }
  48599. ,
  48600. e.prototype._beforeCameraUpdate = function() {
  48601. var e = this.scene._gamepadManager;
  48602. e && e._isMonitoring && e._checkGamepadsStatus()
  48603. }
  48604. ,
  48605. e
  48606. }();
  48607. Xe.AddNodeConstructor("FreeCamera", (function(e, t) {
  48608. return function() {
  48609. return new Na(e,x.Zero(),t)
  48610. }
  48611. }
  48612. ));
  48613. var Na = function(e) {
  48614. function t(t, i, n) {
  48615. var r = e.call(this, t, i, n) || this;
  48616. return r.inputs.addGamepad(),
  48617. r
  48618. }
  48619. return U(t, e),
  48620. Object.defineProperty(t.prototype, "gamepadAngularSensibility", {
  48621. get: function() {
  48622. var e = this.inputs.attached.gamepad;
  48623. return e ? e.gamepadAngularSensibility : 0
  48624. },
  48625. set: function(e) {
  48626. var t = this.inputs.attached.gamepad;
  48627. t && (t.gamepadAngularSensibility = e)
  48628. },
  48629. enumerable: !1,
  48630. configurable: !0
  48631. }),
  48632. Object.defineProperty(t.prototype, "gamepadMoveSensibility", {
  48633. get: function() {
  48634. var e = this.inputs.attached.gamepad;
  48635. return e ? e.gamepadMoveSensibility : 0
  48636. },
  48637. set: function(e) {
  48638. var t = this.inputs.attached.gamepad;
  48639. t && (t.gamepadMoveSensibility = e)
  48640. },
  48641. enumerable: !1,
  48642. configurable: !0
  48643. }),
  48644. t.prototype.getClassName = function() {
  48645. return "UniversalCamera"
  48646. }
  48647. ,
  48648. t
  48649. }(fa);
  48650. Rr._CreateDefaultParsedCamera = function(e, t) {
  48651. return new Na(e,x.Zero(),t)
  48652. }
  48653. ,
  48654. Xe.AddNodeConstructor("GamepadCamera", (function(e, t) {
  48655. return function() {
  48656. return new La(e,x.Zero(),t)
  48657. }
  48658. }
  48659. ));
  48660. var La = function(e) {
  48661. function t(t, i, n) {
  48662. return e.call(this, t, i, n) || this
  48663. }
  48664. return U(t, e),
  48665. t.prototype.getClassName = function() {
  48666. return "GamepadCamera"
  48667. }
  48668. ,
  48669. t
  48670. }(Na);
  48671. Pt.ShadersStore.postprocessVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  48672. var Fa = function() {
  48673. function e(e, t, i, n) {
  48674. this._textures = null,
  48675. this._attachments = null,
  48676. this._generateStencilBuffer = !1,
  48677. this._generateDepthBuffer = !1,
  48678. this._depthStencilTextureWithStencil = !1,
  48679. this._isMulti = e,
  48680. this._isCube = t,
  48681. this._size = i,
  48682. this._engine = n,
  48683. this._depthStencilTexture = null
  48684. }
  48685. return Object.defineProperty(e.prototype, "depthStencilTexture", {
  48686. get: function() {
  48687. return this._depthStencilTexture
  48688. },
  48689. enumerable: !1,
  48690. configurable: !0
  48691. }),
  48692. Object.defineProperty(e.prototype, "depthStencilTextureWithStencil", {
  48693. get: function() {
  48694. return this._depthStencilTextureWithStencil
  48695. },
  48696. enumerable: !1,
  48697. configurable: !0
  48698. }),
  48699. Object.defineProperty(e.prototype, "isCube", {
  48700. get: function() {
  48701. return this._isCube
  48702. },
  48703. enumerable: !1,
  48704. configurable: !0
  48705. }),
  48706. Object.defineProperty(e.prototype, "isMulti", {
  48707. get: function() {
  48708. return this._isMulti
  48709. },
  48710. enumerable: !1,
  48711. configurable: !0
  48712. }),
  48713. Object.defineProperty(e.prototype, "is2DArray", {
  48714. get: function() {
  48715. return this.layers > 0
  48716. },
  48717. enumerable: !1,
  48718. configurable: !0
  48719. }),
  48720. Object.defineProperty(e.prototype, "size", {
  48721. get: function() {
  48722. return this.width
  48723. },
  48724. enumerable: !1,
  48725. configurable: !0
  48726. }),
  48727. Object.defineProperty(e.prototype, "width", {
  48728. get: function() {
  48729. return this._size.width || this._size
  48730. },
  48731. enumerable: !1,
  48732. configurable: !0
  48733. }),
  48734. Object.defineProperty(e.prototype, "height", {
  48735. get: function() {
  48736. return this._size.height || this._size
  48737. },
  48738. enumerable: !1,
  48739. configurable: !0
  48740. }),
  48741. Object.defineProperty(e.prototype, "layers", {
  48742. get: function() {
  48743. return this._size.layers || 0
  48744. },
  48745. enumerable: !1,
  48746. configurable: !0
  48747. }),
  48748. Object.defineProperty(e.prototype, "texture", {
  48749. get: function() {
  48750. var e, t;
  48751. return null !== (t = null === (e = this._textures) || void 0 === e ? void 0 : e[0]) && void 0 !== t ? t : null
  48752. },
  48753. enumerable: !1,
  48754. configurable: !0
  48755. }),
  48756. Object.defineProperty(e.prototype, "textures", {
  48757. get: function() {
  48758. return this._textures
  48759. },
  48760. enumerable: !1,
  48761. configurable: !0
  48762. }),
  48763. Object.defineProperty(e.prototype, "samples", {
  48764. get: function() {
  48765. var e, t;
  48766. return null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : 1
  48767. },
  48768. enumerable: !1,
  48769. configurable: !0
  48770. }),
  48771. e.prototype.setSamples = function(e, t, i) {
  48772. return void 0 === t && (t = !0),
  48773. void 0 === i && (i = !1),
  48774. this.samples !== e || i ? this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, t) : this._engine.updateRenderTargetTextureSampleCount(this, e) : e
  48775. }
  48776. ,
  48777. e.prototype.setTextures = function(e) {
  48778. Array.isArray(e) ? this._textures = e : this._textures = e ? [e] : null
  48779. }
  48780. ,
  48781. e.prototype.setTexture = function(e, t, i) {
  48782. void 0 === t && (t = 0),
  48783. void 0 === i && (i = !0),
  48784. this._textures || (this._textures = []),
  48785. this._textures[t] && i && this._textures[t].dispose(),
  48786. this._textures[t] = e
  48787. }
  48788. ,
  48789. e.prototype.createDepthStencilTexture = function(e, t, i, n, r) {
  48790. var o;
  48791. return void 0 === e && (e = 0),
  48792. void 0 === t && (t = !0),
  48793. void 0 === i && (i = !1),
  48794. void 0 === n && (n = 1),
  48795. void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
  48796. null === (o = this._depthStencilTexture) || void 0 === o || o.dispose(),
  48797. this._depthStencilTextureWithStencil = i,
  48798. this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
  48799. bilinearFiltering: t,
  48800. comparisonFunction: e,
  48801. generateStencil: i,
  48802. isCube: this._isCube,
  48803. samples: n,
  48804. depthTextureFormat: r
  48805. }, this),
  48806. this._depthStencilTexture
  48807. }
  48808. ,
  48809. e.prototype._shareDepth = function(e) {
  48810. this._depthStencilTexture && (e._depthStencilTexture && e._depthStencilTexture.dispose(),
  48811. e._depthStencilTexture = this._depthStencilTexture,
  48812. this._depthStencilTexture.incrementReferences())
  48813. }
  48814. ,
  48815. e.prototype._swapAndDie = function(e) {
  48816. this.texture && this.texture._swapAndDie(e),
  48817. this._textures = null,
  48818. this.dispose(!0)
  48819. }
  48820. ,
  48821. e.prototype._cloneRenderTargetWrapper = function() {
  48822. var e, t, i, n, r, o, a = null;
  48823. if (this._isMulti) {
  48824. var s = this.textures;
  48825. if (s && s.length > 0) {
  48826. var l = !1
  48827. , c = s.length
  48828. , u = s[s.length - 1]._source;
  48829. u !== At.Depth && u !== At.DepthStencil || (l = !0,
  48830. c--);
  48831. for (var h = [], d = [], p = 0; p < c; ++p) {
  48832. var f = s[p];
  48833. h.push(f.samplingMode),
  48834. d.push(f.type)
  48835. }
  48836. var _ = {
  48837. samplingModes: h,
  48838. generateMipMaps: s[0].generateMipMaps,
  48839. generateDepthBuffer: this._generateDepthBuffer,
  48840. generateStencilBuffer: this._generateStencilBuffer,
  48841. generateDepthTexture: l,
  48842. types: d,
  48843. textureCount: c
  48844. }
  48845. , m = {
  48846. width: this.width,
  48847. height: this.height
  48848. };
  48849. a = this._engine.createMultipleRenderTarget(m, _)
  48850. }
  48851. } else {
  48852. var g = {};
  48853. g.generateDepthBuffer = this._generateDepthBuffer,
  48854. g.generateMipMaps = null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.generateMipMaps) && void 0 !== t && t,
  48855. g.generateStencilBuffer = this._generateStencilBuffer,
  48856. g.samplingMode = null === (i = this.texture) || void 0 === i ? void 0 : i.samplingMode,
  48857. g.type = null === (n = this.texture) || void 0 === n ? void 0 : n.type,
  48858. g.format = null === (r = this.texture) || void 0 === r ? void 0 : r.format,
  48859. this.isCube ? a = this._engine.createRenderTargetCubeTexture(this.width, g) : (m = {
  48860. width: this.width,
  48861. height: this.height,
  48862. layers: this.is2DArray ? null === (o = this.texture) || void 0 === o ? void 0 : o.depth : void 0
  48863. },
  48864. a = this._engine.createRenderTargetTexture(m, g)),
  48865. a.texture.isReady = !0
  48866. }
  48867. return a
  48868. }
  48869. ,
  48870. e.prototype._swapRenderTargetWrapper = function(e) {
  48871. if (this._textures && e._textures)
  48872. for (var t = 0; t < this._textures.length; ++t)
  48873. this._textures[t]._swapAndDie(e._textures[t], !1),
  48874. e._textures[t].isReady = !0;
  48875. this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture),
  48876. e._depthStencilTexture.isReady = !0),
  48877. this._textures = null,
  48878. this._depthStencilTexture = null
  48879. }
  48880. ,
  48881. e.prototype._rebuild = function() {
  48882. var e = this._cloneRenderTargetWrapper();
  48883. if (e) {
  48884. if (this._depthStencilTexture) {
  48885. var t = this._depthStencilTexture.samplingMode
  48886. , i = t === a.TEXTURE_BILINEAR_SAMPLINGMODE || t === a.TEXTURE_TRILINEAR_SAMPLINGMODE || t === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  48887. e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, i, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples)
  48888. }
  48889. this.samples > 1 && e.setSamples(this.samples),
  48890. e._swapRenderTargetWrapper(this),
  48891. e.dispose()
  48892. }
  48893. }
  48894. ,
  48895. e.prototype.releaseTextures = function() {
  48896. var e, t;
  48897. if (this._textures)
  48898. for (var i = 0; null !== (t = i < (null === (e = this._textures) || void 0 === e ? void 0 : e.length)) && void 0 !== t && t; ++i)
  48899. this._textures[i].dispose();
  48900. this._textures = null
  48901. }
  48902. ,
  48903. e.prototype.dispose = function(e) {
  48904. var t;
  48905. void 0 === e && (e = !1),
  48906. e || (null === (t = this._depthStencilTexture) || void 0 === t || t.dispose(),
  48907. this._depthStencilTexture = null,
  48908. this.releaseTextures()),
  48909. this._engine._releaseRenderTargetWrapper(this)
  48910. }
  48911. ,
  48912. e
  48913. }()
  48914. , wa = function(e) {
  48915. function t(t, i, n, r, o) {
  48916. var a = e.call(this, t, i, n, r) || this;
  48917. return a._framebuffer = null,
  48918. a._depthStencilBuffer = null,
  48919. a._MSAAFramebuffer = null,
  48920. a._colorTextureArray = null,
  48921. a._depthStencilTextureArray = null,
  48922. a._context = o,
  48923. a
  48924. }
  48925. return U(t, e),
  48926. t.prototype._cloneRenderTargetWrapper = function() {
  48927. var t = null;
  48928. return this._colorTextureArray && this._depthStencilTextureArray ? (t = this._engine.createMultiviewRenderTargetTexture(this.width, this.height)).texture.isReady = !0 : t = e.prototype._cloneRenderTargetWrapper.call(this),
  48929. t
  48930. }
  48931. ,
  48932. t.prototype._swapRenderTargetWrapper = function(t) {
  48933. e.prototype._swapRenderTargetWrapper.call(this, t),
  48934. t._framebuffer = this._framebuffer,
  48935. t._depthStencilBuffer = this._depthStencilBuffer,
  48936. t._MSAAFramebuffer = this._MSAAFramebuffer,
  48937. t._colorTextureArray = this._colorTextureArray,
  48938. t._depthStencilTextureArray = this._depthStencilTextureArray,
  48939. this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null
  48940. }
  48941. ,
  48942. t.prototype._shareDepth = function(t) {
  48943. e.prototype._shareDepth.call(this, t);
  48944. var i = this._context
  48945. , n = this._depthStencilBuffer
  48946. , r = t._framebuffer;
  48947. t._depthStencilBuffer && i.deleteRenderbuffer(t._depthStencilBuffer),
  48948. t._depthStencilBuffer = this._depthStencilBuffer,
  48949. this._engine._bindUnboundFramebuffer(r),
  48950. i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, n),
  48951. this._engine._bindUnboundFramebuffer(null)
  48952. }
  48953. ,
  48954. t.prototype._bindTextureRenderTarget = function(e, t, i, n) {
  48955. if (void 0 === t && (t = 0),
  48956. void 0 === i && (i = -1),
  48957. void 0 === n && (n = 0),
  48958. e._hardwareTexture) {
  48959. var r = this._context
  48960. , o = this._framebuffer
  48961. , a = this._engine._currentFramebuffer;
  48962. this._engine._bindUnboundFramebuffer(o);
  48963. var s = r[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + t : "COLOR_ATTACHMENT" + t + "_WEBGL"]
  48964. , l = -1 !== i ? r.TEXTURE_CUBE_MAP_POSITIVE_X + i : r.TEXTURE_2D;
  48965. r.framebufferTexture2D(r.FRAMEBUFFER, s, l, e._hardwareTexture.underlyingResource, n),
  48966. this._engine._bindUnboundFramebuffer(a)
  48967. }
  48968. }
  48969. ,
  48970. t.prototype.setTexture = function(t, i, n) {
  48971. void 0 === i && (i = 0),
  48972. void 0 === n && (n = !0),
  48973. e.prototype.setTexture.call(this, t, i, n),
  48974. this._bindTextureRenderTarget(t, i)
  48975. }
  48976. ,
  48977. t.prototype.dispose = function(t) {
  48978. void 0 === t && (t = !1);
  48979. var i = this._context;
  48980. t || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray),
  48981. this._colorTextureArray = null),
  48982. this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray),
  48983. this._depthStencilTextureArray = null)),
  48984. this._framebuffer && (i.deleteFramebuffer(this._framebuffer),
  48985. this._framebuffer = null),
  48986. this._depthStencilBuffer && (i.deleteRenderbuffer(this._depthStencilBuffer),
  48987. this._depthStencilBuffer = null),
  48988. this._MSAAFramebuffer && (i.deleteFramebuffer(this._MSAAFramebuffer),
  48989. this._MSAAFramebuffer = null),
  48990. e.prototype.dispose.call(this, t)
  48991. }
  48992. ,
  48993. t
  48994. }(Fa);
  48995. Ht.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
  48996. var n = new wa(e,t,i,this,this._gl);
  48997. return this._renderTargetWrapperCache.push(n),
  48998. n
  48999. }
  49000. ,
  49001. Ht.prototype.createRenderTargetTexture = function(e, t) {
  49002. var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
  49003. , n = {};
  49004. void 0 !== t && "object" == typeof t ? (n.generateDepthBuffer = !!t.generateDepthBuffer,
  49005. n.generateStencilBuffer = !!t.generateStencilBuffer) : (n.generateDepthBuffer = !0,
  49006. n.generateStencilBuffer = !1);
  49007. var r = this._createInternalTexture(e, t, !0, At.RenderTarget)
  49008. , o = e.width || e
  49009. , a = e.height || e
  49010. , s = this._currentFramebuffer
  49011. , l = this._gl
  49012. , c = l.createFramebuffer();
  49013. return this._bindUnboundFramebuffer(c),
  49014. i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!n.generateStencilBuffer, n.generateDepthBuffer, o, a),
  49015. r.is2DArray || l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, r._hardwareTexture.underlyingResource, 0),
  49016. this._bindUnboundFramebuffer(s),
  49017. i._framebuffer = c,
  49018. i._generateDepthBuffer = n.generateDepthBuffer,
  49019. i._generateStencilBuffer = !!n.generateStencilBuffer,
  49020. i.setTextures(r),
  49021. i
  49022. }
  49023. ,
  49024. Ht.prototype.createDepthStencilTexture = function(e, t, i) {
  49025. if (t.isCube) {
  49026. var n = e.width || e;
  49027. return this._createDepthStencilCubeTexture(n, t, i)
  49028. }
  49029. return this._createDepthStencilTexture(e, t, i)
  49030. }
  49031. ,
  49032. Ht.prototype._createDepthStencilTexture = function(e, t, i) {
  49033. var n = this._gl
  49034. , r = e.layers || 0
  49035. , o = 0 !== r ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D
  49036. , s = new Lt(this,At.DepthStencil);
  49037. if (!this._caps.depthTextureExtension)
  49038. return K.Error("Depth texture is not supported by your browser or hardware."),
  49039. s;
  49040. var l = V({
  49041. bilinearFiltering: !1,
  49042. comparisonFunction: 0,
  49043. generateStencil: !1
  49044. }, t);
  49045. this._bindTextureDirectly(o, s, !0),
  49046. this._setupDepthStencilTexture(s, e, l.generateStencil, 0 !== l.comparisonFunction && l.bilinearFiltering, l.comparisonFunction),
  49047. s.format = l.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH24,
  49048. i._depthStencilTexture = s,
  49049. i._depthStencilTextureWithStencil = l.generateStencil;
  49050. var c = l.generateStencil ? n.UNSIGNED_INT_24_8 : n.UNSIGNED_INT
  49051. , u = l.generateStencil ? n.DEPTH_STENCIL : n.DEPTH_COMPONENT
  49052. , h = u;
  49053. return this.webGLVersion > 1 && (h = l.generateStencil ? n.DEPTH24_STENCIL8 : n.DEPTH_COMPONENT24),
  49054. s.is2DArray ? n.texImage3D(o, 0, h, s.width, s.height, r, 0, u, c, null) : n.texImage2D(o, 0, h, s.width, s.height, 0, u, c, null),
  49055. this._bindTextureDirectly(o, null),
  49056. this._internalTexturesCache.push(s),
  49057. s
  49058. }
  49059. ,
  49060. Ht.prototype.updateRenderTargetTextureSampleCount = function(e, t) {
  49061. if (this.webGLVersion < 2 || !e || !e.texture)
  49062. return 1;
  49063. if (e.samples === t)
  49064. return t;
  49065. var i = this._gl;
  49066. t = Math.min(t, this.getCaps().maxMSAASamples),
  49067. e._depthStencilBuffer && (i.deleteRenderbuffer(e._depthStencilBuffer),
  49068. e._depthStencilBuffer = null),
  49069. e._MSAAFramebuffer && (i.deleteFramebuffer(e._MSAAFramebuffer),
  49070. e._MSAAFramebuffer = null);
  49071. var n = e.texture._hardwareTexture;
  49072. if (n._MSAARenderBuffer && (i.deleteRenderbuffer(n._MSAARenderBuffer),
  49073. n._MSAARenderBuffer = null),
  49074. t > 1 && i.renderbufferStorageMultisample) {
  49075. var r = i.createFramebuffer();
  49076. if (!r)
  49077. throw new Error("Unable to create multi sampled framebuffer");
  49078. e._MSAAFramebuffer = r,
  49079. this._bindUnboundFramebuffer(e._MSAAFramebuffer);
  49080. var o = this._createRenderBuffer(e.texture.width, e.texture.height, t, -1, this._getRGBAMultiSampleBufferFormat(e.texture.type), i.COLOR_ATTACHMENT0, !1);
  49081. if (!o)
  49082. throw new Error("Unable to create multi sampled framebuffer");
  49083. n._MSAARenderBuffer = o
  49084. } else
  49085. this._bindUnboundFramebuffer(e._framebuffer);
  49086. return e.texture.samples = t,
  49087. e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
  49088. this._bindUnboundFramebuffer(null),
  49089. t
  49090. }
  49091. ;
  49092. var Ba = function() {
  49093. function e(e, t, i, n, r, o, s, l, c, u, d, p, f, _, m) {
  49094. void 0 === s && (s = a.TEXTURE_NEAREST_SAMPLINGMODE),
  49095. void 0 === u && (u = null),
  49096. void 0 === d && (d = a.TEXTURETYPE_UNSIGNED_INT),
  49097. void 0 === p && (p = "postprocess"),
  49098. void 0 === _ && (_ = !1),
  49099. void 0 === m && (m = a.TEXTUREFORMAT_RGBA),
  49100. this._parentContainer = null,
  49101. this.width = -1,
  49102. this.height = -1,
  49103. this.nodeMaterialSource = null,
  49104. this._outputTexture = null,
  49105. this.autoClear = !0,
  49106. this.alphaMode = a.ALPHA_DISABLE,
  49107. this.animations = new Array,
  49108. this.enablePixelPerfectMode = !1,
  49109. this.forceFullscreenViewport = !0,
  49110. this.scaleMode = a.SCALEMODE_FLOOR,
  49111. this.alwaysForcePOT = !1,
  49112. this._samples = 1,
  49113. this.adaptScaleToCurrentViewport = !1,
  49114. this._reusable = !1,
  49115. this._renderId = 0,
  49116. this.externalTextureSamplerBinding = !1,
  49117. this._textures = new bi(2),
  49118. this._textureCache = [],
  49119. this._currentRenderTextureInd = 0,
  49120. this._scaleRatio = new A(1,1),
  49121. this._texelSize = A.Zero(),
  49122. this.onActivateObservable = new h,
  49123. this.onSizeChangedObservable = new h,
  49124. this.onApplyObservable = new h,
  49125. this.onBeforeRenderObservable = new h,
  49126. this.onAfterRenderObservable = new h,
  49127. this.name = e,
  49128. null != o ? (this._camera = o,
  49129. this._scene = o.getScene(),
  49130. o.attachPostProcess(this),
  49131. this._engine = this._scene.getEngine(),
  49132. this._scene.postProcesses.push(this),
  49133. this.uniqueId = this._scene.getUniqueId()) : l && (this._engine = l,
  49134. this._engine.postProcesses.push(this)),
  49135. this._options = r,
  49136. this.renderTargetSamplingMode = s || a.TEXTURE_NEAREST_SAMPLINGMODE,
  49137. this._reusable = c || !1,
  49138. this._textureType = d,
  49139. this._textureFormat = m,
  49140. this._samplers = n || [],
  49141. this._samplers.push("textureSampler"),
  49142. this._fragmentUrl = t,
  49143. this._vertexUrl = p,
  49144. this._parameters = i || [],
  49145. this._parameters.push("scale"),
  49146. this._indexParameters = f,
  49147. this._drawWrapper = new Gt(this._engine),
  49148. _ || this.updateEffect(u)
  49149. }
  49150. return Object.defineProperty(e.prototype, "samples", {
  49151. get: function() {
  49152. return this._samples
  49153. },
  49154. set: function(e) {
  49155. var t = this;
  49156. this._samples = Math.min(e, this._engine.getCaps().maxMSAASamples),
  49157. this._textures.forEach((function(e) {
  49158. e.samples !== t._samples && t._engine.updateRenderTargetTextureSampleCount(e, t._samples)
  49159. }
  49160. ))
  49161. },
  49162. enumerable: !1,
  49163. configurable: !0
  49164. }),
  49165. e.prototype.getEffectName = function() {
  49166. return this._fragmentUrl
  49167. }
  49168. ,
  49169. Object.defineProperty(e.prototype, "onActivate", {
  49170. set: function(e) {
  49171. this._onActivateObserver && this.onActivateObservable.remove(this._onActivateObserver),
  49172. e && (this._onActivateObserver = this.onActivateObservable.add(e))
  49173. },
  49174. enumerable: !1,
  49175. configurable: !0
  49176. }),
  49177. Object.defineProperty(e.prototype, "onSizeChanged", {
  49178. set: function(e) {
  49179. this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver),
  49180. this._onSizeChangedObserver = this.onSizeChangedObservable.add(e)
  49181. },
  49182. enumerable: !1,
  49183. configurable: !0
  49184. }),
  49185. Object.defineProperty(e.prototype, "onApply", {
  49186. set: function(e) {
  49187. this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver),
  49188. this._onApplyObserver = this.onApplyObservable.add(e)
  49189. },
  49190. enumerable: !1,
  49191. configurable: !0
  49192. }),
  49193. Object.defineProperty(e.prototype, "onBeforeRender", {
  49194. set: function(e) {
  49195. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  49196. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
  49197. },
  49198. enumerable: !1,
  49199. configurable: !0
  49200. }),
  49201. Object.defineProperty(e.prototype, "onAfterRender", {
  49202. set: function(e) {
  49203. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  49204. this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
  49205. },
  49206. enumerable: !1,
  49207. configurable: !0
  49208. }),
  49209. Object.defineProperty(e.prototype, "inputTexture", {
  49210. get: function() {
  49211. return this._textures.data[this._currentRenderTextureInd]
  49212. },
  49213. set: function(e) {
  49214. this._forcedOutputTexture = e
  49215. },
  49216. enumerable: !1,
  49217. configurable: !0
  49218. }),
  49219. e.prototype.restoreDefaultInputTexture = function() {
  49220. this._forcedOutputTexture && (this._forcedOutputTexture = null,
  49221. this.markTextureDirty())
  49222. }
  49223. ,
  49224. e.prototype.getCamera = function() {
  49225. return this._camera
  49226. }
  49227. ,
  49228. Object.defineProperty(e.prototype, "texelSize", {
  49229. get: function() {
  49230. return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.texelSize : (this._forcedOutputTexture && this._texelSize.copyFromFloats(1 / this._forcedOutputTexture.width, 1 / this._forcedOutputTexture.height),
  49231. this._texelSize)
  49232. },
  49233. enumerable: !1,
  49234. configurable: !0
  49235. }),
  49236. e.prototype.getClassName = function() {
  49237. return "PostProcess"
  49238. }
  49239. ,
  49240. e.prototype.getEngine = function() {
  49241. return this._engine
  49242. }
  49243. ,
  49244. e.prototype.getEffect = function() {
  49245. return this._drawWrapper.effect
  49246. }
  49247. ,
  49248. e.prototype.shareOutputWith = function(e) {
  49249. return this._disposeTextures(),
  49250. this._shareOutputWithPostProcess = e,
  49251. this
  49252. }
  49253. ,
  49254. e.prototype.useOwnOutput = function() {
  49255. 0 == this._textures.length && (this._textures = new bi(2)),
  49256. this._shareOutputWithPostProcess = null
  49257. }
  49258. ,
  49259. e.prototype.updateEffect = function(e, t, i, n, r, o, a, s) {
  49260. void 0 === e && (e = null),
  49261. void 0 === t && (t = null),
  49262. void 0 === i && (i = null),
  49263. this._postProcessDefines = e,
  49264. this._drawWrapper.effect = this._engine.createEffect({
  49265. vertex: null != a ? a : this._vertexUrl,
  49266. fragment: null != s ? s : this._fragmentUrl
  49267. }, ["position"], t || this._parameters, i || this._samplers, null !== e ? e : "", void 0, r, o, n || this._indexParameters)
  49268. }
  49269. ,
  49270. e.prototype.isReusable = function() {
  49271. return this._reusable
  49272. }
  49273. ,
  49274. e.prototype.markTextureDirty = function() {
  49275. this.width = -1
  49276. }
  49277. ,
  49278. e.prototype._createRenderTargetTexture = function(e, t, i) {
  49279. void 0 === i && (i = 0);
  49280. for (var n = 0; n < this._textureCache.length; n++)
  49281. if (this._textureCache[n].texture.width === e.width && this._textureCache[n].texture.height === e.height && this._textureCache[n].postProcessChannel === i && this._textureCache[n].texture._generateDepthBuffer === t.generateDepthBuffer)
  49282. return this._textureCache[n].texture;
  49283. var r = this._engine.createRenderTargetTexture(e, t);
  49284. return this._textureCache.push({
  49285. texture: r,
  49286. postProcessChannel: i,
  49287. lastUsedRenderId: -1
  49288. }),
  49289. r
  49290. }
  49291. ,
  49292. e.prototype._flushTextureCache = function() {
  49293. for (var e = this._renderId, t = this._textureCache.length - 1; t >= 0; t--)
  49294. if (e - this._textureCache[t].lastUsedRenderId > 100) {
  49295. for (var i = !1, n = 0; n < this._textures.length; n++)
  49296. if (this._textures.data[n] === this._textureCache[t].texture) {
  49297. i = !0;
  49298. break
  49299. }
  49300. i || (this._textureCache[t].texture.dispose(),
  49301. this._textureCache.splice(t, 1))
  49302. }
  49303. }
  49304. ,
  49305. e.prototype._resize = function(e, t, i, n, r) {
  49306. this._textures.length > 0 && this._textures.reset(),
  49307. this.width = e,
  49308. this.height = t;
  49309. for (var o = null, a = 0; a < i._postProcesses.length; a++)
  49310. if (null !== i._postProcesses[a]) {
  49311. o = i._postProcesses[a];
  49312. break
  49313. }
  49314. var s = {
  49315. width: this.width,
  49316. height: this.height
  49317. }
  49318. , l = {
  49319. generateMipMaps: n,
  49320. generateDepthBuffer: r || o === this,
  49321. generateStencilBuffer: (r || o === this) && this._engine.isStencilEnable,
  49322. samplingMode: this.renderTargetSamplingMode,
  49323. type: this._textureType,
  49324. format: this._textureFormat
  49325. };
  49326. this._textures.push(this._createRenderTargetTexture(s, l, 0)),
  49327. this._reusable && this._textures.push(this._createRenderTargetTexture(s, l, 1)),
  49328. this._texelSize.copyFromFloats(1 / this.width, 1 / this.height),
  49329. this.onSizeChangedObservable.notifyObservers(this)
  49330. }
  49331. ,
  49332. e.prototype.activate = function(e, t, i) {
  49333. var n, r, o = this;
  49334. void 0 === t && (t = null);
  49335. var s = (e = e || this._camera).getScene()
  49336. , l = s.getEngine()
  49337. , c = l.getCaps().maxTextureSize
  49338. , u = (t ? t.width : this._engine.getRenderWidth(!0)) * this._options | 0
  49339. , h = (t ? t.height : this._engine.getRenderHeight(!0)) * this._options | 0
  49340. , d = e.parent;
  49341. !d || d.leftCamera != e && d.rightCamera != e || (u /= 2);
  49342. var p, f = this._options.width || u, _ = this._options.height || h, m = this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_LINEAR && this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_NEAREST && this.renderTargetSamplingMode !== a.TEXTURE_LINEAR_LINEAR;
  49343. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  49344. if (this.adaptScaleToCurrentViewport) {
  49345. var g = l.currentViewport;
  49346. g && (f *= g.width,
  49347. _ *= g.height)
  49348. }
  49349. (m || this.alwaysForcePOT) && (this._options.width || (f = l.needPOTTextures ? vr.GetExponentOfTwo(f, c, this.scaleMode) : f),
  49350. this._options.height || (_ = l.needPOTTextures ? vr.GetExponentOfTwo(_, c, this.scaleMode) : _)),
  49351. this.width === f && this.height === _ || this._resize(f, _, e, m, i),
  49352. this._textures.forEach((function(e) {
  49353. e.samples !== o.samples && o._engine.updateRenderTargetTextureSampleCount(e, o.samples)
  49354. }
  49355. )),
  49356. this._flushTextureCache(),
  49357. this._renderId++
  49358. }
  49359. if (this._shareOutputWithPostProcess)
  49360. p = this._shareOutputWithPostProcess.inputTexture;
  49361. else if (this._forcedOutputTexture)
  49362. p = this._forcedOutputTexture,
  49363. this.width = this._forcedOutputTexture.width,
  49364. this.height = this._forcedOutputTexture.height;
  49365. else {
  49366. p = this.inputTexture;
  49367. for (var v = void 0, y = 0; y < this._textureCache.length; y++)
  49368. if (this._textureCache[y].texture === p) {
  49369. v = this._textureCache[y];
  49370. break
  49371. }
  49372. v && (v.lastUsedRenderId = this._renderId)
  49373. }
  49374. return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(u / f, h / _),
  49375. this._engine.bindFramebuffer(p, 0, u, h, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1),
  49376. this._engine.bindFramebuffer(p, 0, void 0, void 0, this.forceFullscreenViewport)),
  49377. null === (r = (n = this._engine)._debugInsertMarker) || void 0 === r || r.call(n, "post process ".concat(this.name, " input")),
  49378. this.onActivateObservable.notifyObservers(e),
  49379. this.autoClear && this.alphaMode === a.ALPHA_DISABLE && this._engine.clear(this.clearColor ? this.clearColor : s.clearColor, s._allowPostProcessClearColor, !0, !0),
  49380. this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2),
  49381. p
  49382. }
  49383. ,
  49384. Object.defineProperty(e.prototype, "isSupported", {
  49385. get: function() {
  49386. return this._drawWrapper.effect.isSupported
  49387. },
  49388. enumerable: !1,
  49389. configurable: !0
  49390. }),
  49391. Object.defineProperty(e.prototype, "aspectRatio", {
  49392. get: function() {
  49393. return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height
  49394. },
  49395. enumerable: !1,
  49396. configurable: !0
  49397. }),
  49398. e.prototype.isReady = function() {
  49399. var e, t;
  49400. return null !== (t = null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
  49401. }
  49402. ,
  49403. e.prototype.apply = function() {
  49404. var e, t;
  49405. return (null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.isReady()) ? (this._engine.enableEffect(this._drawWrapper),
  49406. this._engine.setState(!1),
  49407. this._engine.setDepthBuffer(!1),
  49408. this._engine.setDepthWrite(!1),
  49409. this._engine.setAlphaMode(this.alphaMode),
  49410. this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a),
  49411. t = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture,
  49412. this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", null == t ? void 0 : t.texture),
  49413. this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
  49414. this.onApplyObservable.notifyObservers(this._drawWrapper.effect),
  49415. this._drawWrapper.effect) : null
  49416. }
  49417. ,
  49418. e.prototype._disposeTextures = function() {
  49419. this._shareOutputWithPostProcess || this._forcedOutputTexture ? this._disposeTextureCache() : (this._disposeTextureCache(),
  49420. this._textures.dispose())
  49421. }
  49422. ,
  49423. e.prototype._disposeTextureCache = function() {
  49424. for (var e = this._textureCache.length - 1; e >= 0; e--)
  49425. this._textureCache[e].texture.dispose();
  49426. this._textureCache.length = 0
  49427. }
  49428. ,
  49429. e.prototype.setPrePassRenderer = function(e) {
  49430. return !!this._prePassEffectConfiguration && (this._prePassEffectConfiguration = e.addEffectConfiguration(this._prePassEffectConfiguration),
  49431. this._prePassEffectConfiguration.enabled = !0,
  49432. !0)
  49433. }
  49434. ,
  49435. e.prototype.dispose = function(e) {
  49436. var t;
  49437. if (e = e || this._camera,
  49438. this._disposeTextures(),
  49439. this._scene && -1 !== (t = this._scene.postProcesses.indexOf(this)) && this._scene.postProcesses.splice(t, 1),
  49440. this._parentContainer) {
  49441. var i = this._parentContainer.postProcesses.indexOf(this);
  49442. i > -1 && this._parentContainer.postProcesses.splice(i, 1),
  49443. this._parentContainer = null
  49444. }
  49445. if (-1 !== (t = this._engine.postProcesses.indexOf(this)) && this._engine.postProcesses.splice(t, 1),
  49446. e) {
  49447. if (e.detachPostProcess(this),
  49448. 0 === (t = e._postProcesses.indexOf(this)) && e._postProcesses.length > 0) {
  49449. var n = this._camera._getFirstPostProcess();
  49450. n && n.markTextureDirty()
  49451. }
  49452. this.onActivateObservable.clear(),
  49453. this.onAfterRenderObservable.clear(),
  49454. this.onApplyObservable.clear(),
  49455. this.onBeforeRenderObservable.clear(),
  49456. this.onSizeChangedObservable.clear()
  49457. }
  49458. }
  49459. ,
  49460. e.prototype.serialize = function() {
  49461. var e = Ge.Serialize(this)
  49462. , t = this.getCamera() || this._scene && this._scene.activeCamera;
  49463. return e.customType = "BABYLON." + this.getClassName(),
  49464. e.cameraId = t ? t.id : null,
  49465. e.reusable = this._reusable,
  49466. e.textureType = this._textureType,
  49467. e.fragmentUrl = this._fragmentUrl,
  49468. e.parameters = this._parameters,
  49469. e.samplers = this._samplers,
  49470. e.options = this._options,
  49471. e.defines = this._postProcessDefines,
  49472. e.textureFormat = this._textureFormat,
  49473. e.vertexUrl = this._vertexUrl,
  49474. e.indexParameters = this._indexParameters,
  49475. e
  49476. }
  49477. ,
  49478. e.prototype.clone = function() {
  49479. var t = this.serialize();
  49480. t._engine = this._engine,
  49481. t.cameraId = null;
  49482. var i = e.Parse(t, this._scene, "");
  49483. return i ? (i.onActivateObservable = this.onActivateObservable.clone(),
  49484. i.onSizeChangedObservable = this.onSizeChangedObservable.clone(),
  49485. i.onApplyObservable = this.onApplyObservable.clone(),
  49486. i.onBeforeRenderObservable = this.onBeforeRenderObservable.clone(),
  49487. i.onAfterRenderObservable = this.onAfterRenderObservable.clone(),
  49488. i._prePassEffectConfiguration = this._prePassEffectConfiguration,
  49489. i) : null
  49490. }
  49491. ,
  49492. e.Parse = function(e, t, i) {
  49493. var n = b(e.customType);
  49494. if (!n || !n._Parse)
  49495. return null;
  49496. var r = t ? t.getCameraById(e.cameraId) : null;
  49497. return n._Parse(e, r, t, i)
  49498. }
  49499. ,
  49500. e._Parse = function(t, i, n, r) {
  49501. return Ge.Parse((function() {
  49502. return new e(t.name,t.fragmentUrl,t.parameters,t.samplers,t.options,i,t.renderTargetSamplingMode,t._engine,t.reusable,t.defines,t.textureType,t.vertexUrl,t.indexParameters,!1,t.textureFormat)
  49503. }
  49504. ), t, n, r)
  49505. }
  49506. ,
  49507. k([Ce()], e.prototype, "uniqueId", void 0),
  49508. k([Ce()], e.prototype, "name", void 0),
  49509. k([Ce()], e.prototype, "width", void 0),
  49510. k([Ce()], e.prototype, "height", void 0),
  49511. k([Ce()], e.prototype, "renderTargetSamplingMode", void 0),
  49512. k([Fe()], e.prototype, "clearColor", void 0),
  49513. k([Ce()], e.prototype, "autoClear", void 0),
  49514. k([Ce()], e.prototype, "alphaMode", void 0),
  49515. k([Ce()], e.prototype, "alphaConstants", void 0),
  49516. k([Ce()], e.prototype, "enablePixelPerfectMode", void 0),
  49517. k([Ce()], e.prototype, "forceFullscreenViewport", void 0),
  49518. k([Ce()], e.prototype, "scaleMode", void 0),
  49519. k([Ce()], e.prototype, "alwaysForcePOT", void 0),
  49520. k([Ce("samples")], e.prototype, "_samples", void 0),
  49521. k([Ce()], e.prototype, "adaptScaleToCurrentViewport", void 0),
  49522. e
  49523. }();
  49524. y("BABYLON.PostProcess", Ba);
  49525. Pt.ShadersStore.passPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  49526. Pt.ShadersStore.passCubePixelShader = "varying vec2 vUV;\nuniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";
  49527. var Ua = function(e) {
  49528. function t(t, i, n, r, o, s, l, c) {
  49529. return void 0 === n && (n = null),
  49530. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  49531. void 0 === c && (c = !1),
  49532. e.call(this, t, "pass", null, null, i, n, r, o, s, void 0, l, void 0, null, c) || this
  49533. }
  49534. return U(t, e),
  49535. t.prototype.getClassName = function() {
  49536. return "PassPostProcess"
  49537. }
  49538. ,
  49539. t._Parse = function(e, i, n, r) {
  49540. return Ge.Parse((function() {
  49541. return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
  49542. }
  49543. ), e, n, r)
  49544. }
  49545. ,
  49546. t
  49547. }(Ba);
  49548. y("BABYLON.PassPostProcess", Ua);
  49549. var Va = function(e) {
  49550. function t(t, i, n, r, o, s, l, c) {
  49551. void 0 === n && (n = null),
  49552. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  49553. void 0 === c && (c = !1);
  49554. var u = e.call(this, t, "passCube", null, null, i, n, r, o, s, "#define POSITIVEX", l, void 0, null, c) || this;
  49555. return u._face = 0,
  49556. u
  49557. }
  49558. return U(t, e),
  49559. Object.defineProperty(t.prototype, "face", {
  49560. get: function() {
  49561. return this._face
  49562. },
  49563. set: function(e) {
  49564. if (!(e < 0 || e > 5))
  49565. switch (this._face = e,
  49566. this._face) {
  49567. case 0:
  49568. this.updateEffect("#define POSITIVEX");
  49569. break;
  49570. case 1:
  49571. this.updateEffect("#define NEGATIVEX");
  49572. break;
  49573. case 2:
  49574. this.updateEffect("#define POSITIVEY");
  49575. break;
  49576. case 3:
  49577. this.updateEffect("#define NEGATIVEY");
  49578. break;
  49579. case 4:
  49580. this.updateEffect("#define POSITIVEZ");
  49581. break;
  49582. case 5:
  49583. this.updateEffect("#define NEGATIVEZ")
  49584. }
  49585. },
  49586. enumerable: !1,
  49587. configurable: !0
  49588. }),
  49589. t.prototype.getClassName = function() {
  49590. return "PassCubePostProcess"
  49591. }
  49592. ,
  49593. t._Parse = function(e, i, n, r) {
  49594. return Ge.Parse((function() {
  49595. return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
  49596. }
  49597. ), e, n, r)
  49598. }
  49599. ,
  49600. t
  49601. }(Ba);
  49602. vr._RescalePostProcessFactory = function(e) {
  49603. return new Ua("rescale",1,null,a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,a.TEXTURETYPE_UNSIGNED_INT)
  49604. }
  49605. ;
  49606. Pt.ShadersStore.anaglyphPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";
  49607. var ka = function(e) {
  49608. function t(t, i, n, r, o, a) {
  49609. var s = e.call(this, t, "anaglyph", null, ["leftSampler"], i, n[1], r, o, a) || this;
  49610. return s._passedProcess = n[0]._rigPostProcess,
  49611. s.onApplyObservable.add((function(e) {
  49612. e.setTextureFromPostProcess("leftSampler", s._passedProcess)
  49613. }
  49614. )),
  49615. s
  49616. }
  49617. return U(t, e),
  49618. t.prototype.getClassName = function() {
  49619. return "AnaglyphPostProcess"
  49620. }
  49621. ,
  49622. t
  49623. }(Ba);
  49624. function Ga(e) {
  49625. e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
  49626. e._rigCameras[1]._rigPostProcess = new ka(e.name + "_anaglyph",1,e._rigCameras)
  49627. }
  49628. y("BABYLON.AnaglyphPostProcess", ka),
  49629. Xe.AddNodeConstructor("AnaglyphArcRotateCamera", (function(e, t, i) {
  49630. return function() {
  49631. return new za(e,0,0,1,x.Zero(),i.interaxial_distance,t)
  49632. }
  49633. }
  49634. ));
  49635. var za = function(e) {
  49636. function t(t, i, n, r, o, a, s) {
  49637. var l = e.call(this, t, i, n, r, o, s) || this;
  49638. return l._setRigMode = Ga.bind(null, l),
  49639. l.interaxialDistance = a,
  49640. l.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
  49641. interaxialDistance: a
  49642. }),
  49643. l
  49644. }
  49645. return U(t, e),
  49646. t.prototype.getClassName = function() {
  49647. return "AnaglyphArcRotateCamera"
  49648. }
  49649. ,
  49650. t
  49651. }(_a);
  49652. Xe.AddNodeConstructor("AnaglyphFreeCamera", (function(e, t, i) {
  49653. return function() {
  49654. return new Wa(e,x.Zero(),i.interaxial_distance,t)
  49655. }
  49656. }
  49657. ));
  49658. var Wa = function(e) {
  49659. function t(t, i, n, r) {
  49660. var o = e.call(this, t, i, r) || this;
  49661. return o._setRigMode = Ga.bind(null, o),
  49662. o.interaxialDistance = n,
  49663. o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
  49664. interaxialDistance: n
  49665. }),
  49666. o
  49667. }
  49668. return U(t, e),
  49669. t.prototype.getClassName = function() {
  49670. return "AnaglyphFreeCamera"
  49671. }
  49672. ,
  49673. t
  49674. }(pa);
  49675. Xe.AddNodeConstructor("AnaglyphGamepadCamera", (function(e, t, i) {
  49676. return function() {
  49677. return new Ha(e,x.Zero(),i.interaxial_distance,t)
  49678. }
  49679. }
  49680. ));
  49681. var Ha = function(e) {
  49682. function t(t, i, n, r) {
  49683. var o = e.call(this, t, i, r) || this;
  49684. return o._setRigMode = Ga.bind(null, o),
  49685. o.interaxialDistance = n,
  49686. o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
  49687. interaxialDistance: n
  49688. }),
  49689. o
  49690. }
  49691. return U(t, e),
  49692. t.prototype.getClassName = function() {
  49693. return "AnaglyphGamepadCamera"
  49694. }
  49695. ,
  49696. t
  49697. }(La);
  49698. Xe.AddNodeConstructor("AnaglyphUniversalCamera", (function(e, t, i) {
  49699. return function() {
  49700. return new Xa(e,x.Zero(),i.interaxial_distance,t)
  49701. }
  49702. }
  49703. ));
  49704. var Xa = function(e) {
  49705. function t(t, i, n, r) {
  49706. var o = e.call(this, t, i, r) || this;
  49707. return o._setRigMode = Ga.bind(null, o),
  49708. o.interaxialDistance = n,
  49709. o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
  49710. interaxialDistance: n
  49711. }),
  49712. o
  49713. }
  49714. return U(t, e),
  49715. t.prototype.getClassName = function() {
  49716. return "AnaglyphUniversalCamera"
  49717. }
  49718. ,
  49719. t
  49720. }(Na);
  49721. Pt.ShadersStore.stereoscopicInterlacePixelShader = "const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nbool useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0)==1.0;\nuseCamB=mod(rowNum,2.0)==0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";
  49722. var ja = function(e) {
  49723. function t(t, i, n, r, o, a, s) {
  49724. var l = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], o, a, s, r ? "#define IS_STEREOSCOPIC_INTERLACED 1" : n ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
  49725. return l._passedProcess = i[0]._rigPostProcess,
  49726. l._stepSize = new A(1 / l.width,1 / l.height),
  49727. l.onSizeChangedObservable.add((function() {
  49728. l._stepSize = new A(1 / l.width,1 / l.height)
  49729. }
  49730. )),
  49731. l.onApplyObservable.add((function(e) {
  49732. e.setTextureFromPostProcess("camASampler", l._passedProcess),
  49733. e.setFloat2("stepSize", l._stepSize.x, l._stepSize.y)
  49734. }
  49735. )),
  49736. l
  49737. }
  49738. return U(t, e),
  49739. t.prototype.getClassName = function() {
  49740. return "StereoscopicInterlacePostProcessI"
  49741. }
  49742. ,
  49743. t
  49744. }(Ba)
  49745. , Ya = function(e) {
  49746. function t(t, i, n, r, o, a) {
  49747. var s = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], r, o, a, n ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
  49748. return s._passedProcess = i[0]._rigPostProcess,
  49749. s._stepSize = new A(1 / s.width,1 / s.height),
  49750. s.onSizeChangedObservable.add((function() {
  49751. s._stepSize = new A(1 / s.width,1 / s.height)
  49752. }
  49753. )),
  49754. s.onApplyObservable.add((function(e) {
  49755. e.setTextureFromPostProcess("camASampler", s._passedProcess),
  49756. e.setFloat2("stepSize", s._stepSize.x, s._stepSize.y)
  49757. }
  49758. )),
  49759. s
  49760. }
  49761. return U(t, e),
  49762. t.prototype.getClassName = function() {
  49763. return "StereoscopicInterlacePostProcess"
  49764. }
  49765. ,
  49766. t
  49767. }(Ba);
  49768. function Ka(e) {
  49769. var t = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED
  49770. , i = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  49771. e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_INTERLACED ? (e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
  49772. e._rigCameras[1]._rigPostProcess = new ja(e.name + "_stereoInterlace",e._rigCameras,!1,!0)) : (e._rigCameras[i ? 1 : 0].viewport = new xr(0,0,t ? .5 : 1,t ? 1 : .5),
  49773. e._rigCameras[i ? 0 : 1].viewport = new xr(t ? .5 : 0,t ? 0 : .5,t ? .5 : 1,t ? 1 : .5))
  49774. }
  49775. Xe.AddNodeConstructor("StereoscopicArcRotateCamera", (function(e, t, i) {
  49776. return function() {
  49777. return new Qa(e,0,0,1,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
  49778. }
  49779. }
  49780. ));
  49781. var Qa = function(e) {
  49782. function t(t, i, n, r, o, a, s, l) {
  49783. var c = e.call(this, t, i, n, r, o, l) || this;
  49784. return c._setRigMode = Ka.bind(null, c),
  49785. c.interaxialDistance = a,
  49786. c.isStereoscopicSideBySide = s,
  49787. c.setCameraRigMode(s ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
  49788. interaxialDistance: a
  49789. }),
  49790. c
  49791. }
  49792. return U(t, e),
  49793. t.prototype.getClassName = function() {
  49794. return "StereoscopicArcRotateCamera"
  49795. }
  49796. ,
  49797. t
  49798. }(_a);
  49799. Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
  49800. return function() {
  49801. return new qa(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
  49802. }
  49803. }
  49804. ));
  49805. var qa = function(e) {
  49806. function t(t, i, n, r, o) {
  49807. var a = e.call(this, t, i, o) || this;
  49808. return a._setRigMode = Ka.bind(null, a),
  49809. a.interaxialDistance = n,
  49810. a.isStereoscopicSideBySide = r,
  49811. a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
  49812. interaxialDistance: n
  49813. }),
  49814. a
  49815. }
  49816. return U(t, e),
  49817. t.prototype.getClassName = function() {
  49818. return "StereoscopicFreeCamera"
  49819. }
  49820. ,
  49821. t
  49822. }(pa);
  49823. Xe.AddNodeConstructor("StereoscopicGamepadCamera", (function(e, t, i) {
  49824. return function() {
  49825. return new Za(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
  49826. }
  49827. }
  49828. ));
  49829. var Za = function(e) {
  49830. function t(t, i, n, r, o) {
  49831. var a = e.call(this, t, i, o) || this;
  49832. return a._setRigMode = Ka.bind(null, a),
  49833. a.interaxialDistance = n,
  49834. a.isStereoscopicSideBySide = r,
  49835. a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
  49836. interaxialDistance: n
  49837. }),
  49838. a
  49839. }
  49840. return U(t, e),
  49841. t.prototype.getClassName = function() {
  49842. return "StereoscopicGamepadCamera"
  49843. }
  49844. ,
  49845. t
  49846. }(La);
  49847. Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
  49848. return function() {
  49849. return new Ja(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
  49850. }
  49851. }
  49852. ));
  49853. var Ja = function(e) {
  49854. function t(t, i, n, r, o) {
  49855. var a = e.call(this, t, i, o) || this;
  49856. return a._setRigMode = Ka.bind(null, a),
  49857. a.interaxialDistance = n,
  49858. a.isStereoscopicSideBySide = r,
  49859. a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
  49860. interaxialDistance: n
  49861. }),
  49862. a
  49863. }
  49864. return U(t, e),
  49865. t.prototype.getClassName = function() {
  49866. return "StereoscopicUniversalCamera"
  49867. }
  49868. ,
  49869. t
  49870. }(Na)
  49871. , $a = function(e) {
  49872. function t(t, i, n, r, o) {
  49873. void 0 === r && (r = 1),
  49874. void 0 === o && (o = .065);
  49875. var a = e.call(this, t, i, n) || this;
  49876. return a._distanceBetweenEyes = o,
  49877. a._distanceToProjectionPlane = r,
  49878. a.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, {
  49879. stereoHalfAngle: 0
  49880. }),
  49881. a._cameraRigParams.stereoHalfAngle = 0,
  49882. a._cameraRigParams.interaxialDistance = o,
  49883. a
  49884. }
  49885. return U(t, e),
  49886. Object.defineProperty(t.prototype, "distanceBetweenEyes", {
  49887. get: function() {
  49888. return this._distanceBetweenEyes
  49889. },
  49890. set: function(e) {
  49891. this._distanceBetweenEyes = e
  49892. },
  49893. enumerable: !1,
  49894. configurable: !0
  49895. }),
  49896. Object.defineProperty(t.prototype, "distanceToProjectionPlane", {
  49897. get: function() {
  49898. return this._distanceToProjectionPlane
  49899. },
  49900. set: function(e) {
  49901. this._distanceToProjectionPlane = e
  49902. },
  49903. enumerable: !1,
  49904. configurable: !0
  49905. }),
  49906. t.prototype.getClassName = function() {
  49907. return "StereoscopicUniversalCamera"
  49908. }
  49909. ,
  49910. t.prototype.createRigCamera = function(e) {
  49911. var t = new da(e,x.Zero(),this.getScene())
  49912. , i = new yr("tm_" + e,this.getScene());
  49913. return t.parent = i,
  49914. i.setPivotMatrix(P.Identity(), !1),
  49915. t.isRigCamera = !0,
  49916. t.rigParent = this,
  49917. t
  49918. }
  49919. ,
  49920. t.prototype._updateRigCameras = function() {
  49921. for (var e = 0; e < this._rigCameras.length; e++) {
  49922. var t = this._rigCameras[e];
  49923. t.minZ = this.minZ,
  49924. t.maxZ = this.maxZ,
  49925. t.fov = this.fov,
  49926. t.upVector.copyFrom(this.upVector),
  49927. t.rotationQuaternion ? t.rotationQuaternion.copyFrom(this.rotationQuaternion) : t.rotation.copyFrom(this.rotation),
  49928. this._updateCamera(this._rigCameras[e], e)
  49929. }
  49930. }
  49931. ,
  49932. t.prototype._updateCamera = function(e, t) {
  49933. var i = this.distanceBetweenEyes / 2
  49934. , n = i / this.distanceToProjectionPlane;
  49935. e.position.copyFrom(this.position),
  49936. e.position.addInPlaceFromFloats(0 === t ? -i : i, 0, -this._distanceToProjectionPlane);
  49937. var r = e.parent
  49938. , o = r.getPivotMatrix();
  49939. o.setTranslationFromFloats(0 === t ? i : -i, 0, 0),
  49940. o.setRowFromFloats(2, 0 === t ? n : -n, 0, 1, 0),
  49941. r.setPivotMatrix(o, !1)
  49942. }
  49943. ,
  49944. t.prototype._setRigMode = function() {
  49945. this._rigCameras[0].viewport = new xr(0,0,.5,1),
  49946. this._rigCameras[1].viewport = new xr(.5,0,.5,1);
  49947. for (var e = 0; e < this._rigCameras.length; e++)
  49948. this._updateCamera(this._rigCameras[e], e)
  49949. }
  49950. ,
  49951. t
  49952. }(Na);
  49953. Xe.AddNodeConstructor("VirtualJoysticksCamera", (function(e, t) {
  49954. return function() {
  49955. return new es(e,x.Zero(),t)
  49956. }
  49957. }
  49958. ));
  49959. var es = function(e) {
  49960. function t(t, i, n) {
  49961. var r = e.call(this, t, i, n) || this;
  49962. return r.inputs.addVirtualJoystick(),
  49963. r
  49964. }
  49965. return U(t, e),
  49966. t.prototype.getClassName = function() {
  49967. return "VirtualJoysticksCamera"
  49968. }
  49969. ,
  49970. t
  49971. }(pa)
  49972. , ts = function() {
  49973. function e() {
  49974. this.compensateDistortion = !0,
  49975. this.multiviewEnabled = !1
  49976. }
  49977. return Object.defineProperty(e.prototype, "aspectRatio", {
  49978. get: function() {
  49979. return this.hResolution / (2 * this.vResolution)
  49980. },
  49981. enumerable: !1,
  49982. configurable: !0
  49983. }),
  49984. Object.defineProperty(e.prototype, "aspectRatioFov", {
  49985. get: function() {
  49986. return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance))
  49987. },
  49988. enumerable: !1,
  49989. configurable: !0
  49990. }),
  49991. Object.defineProperty(e.prototype, "leftHMatrix", {
  49992. get: function() {
  49993. var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
  49994. return P.Translation(e, 0, 0)
  49995. },
  49996. enumerable: !1,
  49997. configurable: !0
  49998. }),
  49999. Object.defineProperty(e.prototype, "rightHMatrix", {
  50000. get: function() {
  50001. var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
  50002. return P.Translation(-e, 0, 0)
  50003. },
  50004. enumerable: !1,
  50005. configurable: !0
  50006. }),
  50007. Object.defineProperty(e.prototype, "leftPreViewMatrix", {
  50008. get: function() {
  50009. return P.Translation(.5 * this.interpupillaryDistance, 0, 0)
  50010. },
  50011. enumerable: !1,
  50012. configurable: !0
  50013. }),
  50014. Object.defineProperty(e.prototype, "rightPreViewMatrix", {
  50015. get: function() {
  50016. return P.Translation(-.5 * this.interpupillaryDistance, 0, 0)
  50017. },
  50018. enumerable: !1,
  50019. configurable: !0
  50020. }),
  50021. e.GetDefault = function() {
  50022. var t = new e;
  50023. return t.hResolution = 1280,
  50024. t.vResolution = 800,
  50025. t.hScreenSize = .149759993,
  50026. t.vScreenSize = .0935999975,
  50027. t.vScreenCenter = .0467999987,
  50028. t.eyeToScreenDistance = .0410000011,
  50029. t.lensSeparationDistance = .063500002,
  50030. t.interpupillaryDistance = .064000003,
  50031. t.distortionK = [1, .219999999, .239999995, 0],
  50032. t.chromaAbCorrection = [.995999992, -.00400000019, 1.01400006, 0],
  50033. t.postProcessScaleFactor = 1.714605507808412,
  50034. t.lensCenterOffset = .151976421,
  50035. t
  50036. }
  50037. ,
  50038. e
  50039. }();
  50040. Pt.ShadersStore.vrDistortionCorrectionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";
  50041. var is = function(e) {
  50042. function t(t, i, n, r) {
  50043. var o = e.call(this, t, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, r.postProcessScaleFactor, i, io.BILINEAR_SAMPLINGMODE) || this;
  50044. return o._isRightEye = n,
  50045. o._distortionFactors = r.distortionK,
  50046. o._postProcessScaleFactor = r.postProcessScaleFactor,
  50047. o._lensCenterOffset = r.lensCenterOffset,
  50048. o.adaptScaleToCurrentViewport = !0,
  50049. o.onSizeChangedObservable.add((function() {
  50050. o._scaleIn = new A(2,2 / o.aspectRatio),
  50051. o._scaleFactor = new A(1 / o._postProcessScaleFactor * .5,1 / o._postProcessScaleFactor * .5 * o.aspectRatio),
  50052. o._lensCenter = new A(o._isRightEye ? .5 - .5 * o._lensCenterOffset : .5 + .5 * o._lensCenterOffset,.5)
  50053. }
  50054. )),
  50055. o.onApplyObservable.add((function(e) {
  50056. e.setFloat2("LensCenter", o._lensCenter.x, o._lensCenter.y),
  50057. e.setFloat2("Scale", o._scaleFactor.x, o._scaleFactor.y),
  50058. e.setFloat2("ScaleIn", o._scaleIn.x, o._scaleIn.y),
  50059. e.setFloat4("HmdWarpParam", o._distortionFactors[0], o._distortionFactors[1], o._distortionFactors[2], o._distortionFactors[3])
  50060. }
  50061. )),
  50062. o
  50063. }
  50064. return U(t, e),
  50065. t.prototype.getClassName = function() {
  50066. return "VRDistortionCorrectionPostProcess"
  50067. }
  50068. ,
  50069. t
  50070. }(Ba);
  50071. Pt.ShadersStore.vrMultiviewToSingleviewPixelShader = "precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));\n}",
  50072. Ht.prototype.createRenderTargetCubeTexture = function(e, t) {
  50073. var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
  50074. , n = V({
  50075. generateMipMaps: !0,
  50076. generateDepthBuffer: !0,
  50077. generateStencilBuffer: !1,
  50078. type: a.TEXTURETYPE_UNSIGNED_INT,
  50079. samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  50080. format: a.TEXTUREFORMAT_RGBA
  50081. }, t);
  50082. n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
  50083. (n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
  50084. var r = this._gl
  50085. , o = new Lt(this,At.RenderTarget);
  50086. this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, o, !0);
  50087. var s = this._getSamplingParameters(n.samplingMode, n.generateMipMaps);
  50088. n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
  50089. K.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),
  50090. r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MAG_FILTER, s.mag),
  50091. r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MIN_FILTER, s.min),
  50092. r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE),
  50093. r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE);
  50094. for (var l = 0; l < 6; l++)
  50095. r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + l, 0, this._getRGBABufferInternalSizedFormat(n.type, n.format), e, e, 0, this._getInternalFormat(n.format), this._getWebGLTextureType(n.type), null);
  50096. var c = r.createFramebuffer();
  50097. return this._bindUnboundFramebuffer(c),
  50098. i._depthStencilBuffer = this._setupFramebufferDepthAttachments(n.generateStencilBuffer, n.generateDepthBuffer, e, e),
  50099. n.generateMipMaps && r.generateMipmap(r.TEXTURE_CUBE_MAP),
  50100. this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, null),
  50101. this._bindUnboundFramebuffer(null),
  50102. i._framebuffer = c,
  50103. i._generateDepthBuffer = n.generateDepthBuffer,
  50104. i._generateStencilBuffer = n.generateStencilBuffer,
  50105. o.width = e,
  50106. o.height = e,
  50107. o.isReady = !0,
  50108. o.isCube = !0,
  50109. o.samples = 1,
  50110. o.generateMipMaps = n.generateMipMaps,
  50111. o.samplingMode = n.samplingMode,
  50112. o.type = n.type,
  50113. o.format = n.format,
  50114. this._internalTexturesCache.push(o),
  50115. i.setTextures(o),
  50116. i
  50117. }
  50118. ;
  50119. var ns = function(e) {
  50120. function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
  50121. void 0 === o && (o = !0),
  50122. void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT),
  50123. void 0 === l && (l = !1),
  50124. void 0 === c && (c = io.TRILINEAR_SAMPLINGMODE),
  50125. void 0 === u && (u = !0),
  50126. void 0 === d && (d = !1),
  50127. void 0 === p && (p = !1),
  50128. void 0 === f && (f = a.TEXTUREFORMAT_RGBA),
  50129. void 0 === _ && (_ = !1);
  50130. var v, y = this;
  50131. if ((y = e.call(this, null, n, !r, void 0, c, void 0, void 0, void 0, void 0, f) || this).renderParticles = !0,
  50132. y.renderSprites = !1,
  50133. y.ignoreCameraViewport = !1,
  50134. y.onBeforeBindObservable = new h,
  50135. y.onAfterUnbindObservable = new h,
  50136. y.onBeforeRenderObservable = new h,
  50137. y.onAfterRenderObservable = new h,
  50138. y.onClearObservable = new h,
  50139. y.onResizeObservable = new h,
  50140. y._cleared = !1,
  50141. y.skipInitialClear = !1,
  50142. y._currentRefreshId = -1,
  50143. y._refreshRate = 1,
  50144. y._samples = 1,
  50145. y._canRescale = !0,
  50146. y._renderTarget = null,
  50147. y.boundingBoxPosition = x.Zero(),
  50148. !(n = y.getScene()))
  50149. return y;
  50150. var b = y.getScene().getEngine();
  50151. return y._coordinatesMode = io.PROJECTION_MODE,
  50152. y.renderList = new Array,
  50153. y.name = t,
  50154. y.isRenderTarget = !0,
  50155. y._initialSizeParameter = i,
  50156. y._renderPassIds = [],
  50157. y._isCubeData = l,
  50158. y._processSizeParameter(i),
  50159. y.renderPassId = y._renderPassIds[0],
  50160. y._resizeObserver = b.onResizeObservable.add((function() {}
  50161. )),
  50162. y._generateMipMaps = !!r,
  50163. y._doNotChangeAspectRatio = o,
  50164. y._renderingManager = new zi(n),
  50165. y._renderingManager._useSceneAutoClearSetup = !0,
  50166. p || (y._renderTargetOptions = {
  50167. generateMipMaps: r,
  50168. type: s,
  50169. format: null !== (v = y._format) && void 0 !== v ? v : void 0,
  50170. samplingMode: y.samplingMode,
  50171. generateDepthBuffer: u,
  50172. generateStencilBuffer: d,
  50173. samples: m,
  50174. creationFlags: g
  50175. },
  50176. y.samplingMode === io.NEAREST_SAMPLINGMODE && (y.wrapU = io.CLAMP_ADDRESSMODE,
  50177. y.wrapV = io.CLAMP_ADDRESSMODE),
  50178. _ || (l ? (y._renderTarget = n.getEngine().createRenderTargetCubeTexture(y.getRenderSize(), y._renderTargetOptions),
  50179. y.coordinatesMode = io.INVCUBIC_MODE,
  50180. y._textureMatrix = P.Identity()) : y._renderTarget = n.getEngine().createRenderTargetTexture(y._size, y._renderTargetOptions),
  50181. y._texture = y._renderTarget.texture,
  50182. void 0 !== m && (y.samples = m))),
  50183. y
  50184. }
  50185. return U(t, e),
  50186. Object.defineProperty(t.prototype, "renderList", {
  50187. get: function() {
  50188. return this._renderList
  50189. },
  50190. set: function(e) {
  50191. this._renderList = e,
  50192. this._renderList && this._hookArray(this._renderList)
  50193. },
  50194. enumerable: !1,
  50195. configurable: !0
  50196. }),
  50197. t.prototype._hookArray = function(e) {
  50198. var t = this
  50199. , i = e.push;
  50200. e.push = function() {
  50201. for (var n, r = [], o = 0; o < arguments.length; o++)
  50202. r[o] = arguments[o];
  50203. var a = 0 === e.length
  50204. , s = i.apply(e, r);
  50205. return a && (null === (n = t.getScene()) || void 0 === n || n.meshes.forEach((function(e) {
  50206. e._markSubMeshesAsLightDirty()
  50207. }
  50208. ))),
  50209. s
  50210. }
  50211. ;
  50212. var n = e.splice;
  50213. e.splice = function(i, r) {
  50214. var o, a = n.apply(e, [i, r]);
  50215. return 0 === e.length && (null === (o = t.getScene()) || void 0 === o || o.meshes.forEach((function(e) {
  50216. e._markSubMeshesAsLightDirty()
  50217. }
  50218. ))),
  50219. a
  50220. }
  50221. }
  50222. ,
  50223. Object.defineProperty(t.prototype, "postProcesses", {
  50224. get: function() {
  50225. return this._postProcesses
  50226. },
  50227. enumerable: !1,
  50228. configurable: !0
  50229. }),
  50230. Object.defineProperty(t.prototype, "_prePassEnabled", {
  50231. get: function() {
  50232. return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled
  50233. },
  50234. enumerable: !1,
  50235. configurable: !0
  50236. }),
  50237. Object.defineProperty(t.prototype, "onAfterUnbind", {
  50238. set: function(e) {
  50239. this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
  50240. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(e)
  50241. },
  50242. enumerable: !1,
  50243. configurable: !0
  50244. }),
  50245. Object.defineProperty(t.prototype, "onBeforeRender", {
  50246. set: function(e) {
  50247. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  50248. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
  50249. },
  50250. enumerable: !1,
  50251. configurable: !0
  50252. }),
  50253. Object.defineProperty(t.prototype, "onAfterRender", {
  50254. set: function(e) {
  50255. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  50256. this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
  50257. },
  50258. enumerable: !1,
  50259. configurable: !0
  50260. }),
  50261. Object.defineProperty(t.prototype, "onClear", {
  50262. set: function(e) {
  50263. this._onClearObserver && this.onClearObservable.remove(this._onClearObserver),
  50264. this._onClearObserver = this.onClearObservable.add(e)
  50265. },
  50266. enumerable: !1,
  50267. configurable: !0
  50268. }),
  50269. Object.defineProperty(t.prototype, "renderPassIds", {
  50270. get: function() {
  50271. return this._renderPassIds
  50272. },
  50273. enumerable: !1,
  50274. configurable: !0
  50275. }),
  50276. Object.defineProperty(t.prototype, "currentRefreshId", {
  50277. get: function() {
  50278. return this._currentRefreshId
  50279. },
  50280. enumerable: !1,
  50281. configurable: !0
  50282. }),
  50283. t.prototype.setMaterialForRendering = function(e, t) {
  50284. var i;
  50285. i = Array.isArray(e) ? e : [e];
  50286. for (var n = 0; n < i.length; ++n)
  50287. for (var r = 0; r < this._renderPassIds.length; ++r)
  50288. i[n].setMaterialForRenderPass(this._renderPassIds[r], void 0 !== t ? Array.isArray(t) ? t[r] : t : void 0)
  50289. }
  50290. ,
  50291. Object.defineProperty(t.prototype, "renderTargetOptions", {
  50292. get: function() {
  50293. return this._renderTargetOptions
  50294. },
  50295. enumerable: !1,
  50296. configurable: !0
  50297. }),
  50298. Object.defineProperty(t.prototype, "renderTarget", {
  50299. get: function() {
  50300. return this._renderTarget
  50301. },
  50302. enumerable: !1,
  50303. configurable: !0
  50304. }),
  50305. t.prototype._onRatioRescale = function() {
  50306. this._sizeRatio && this.resize(this._initialSizeParameter)
  50307. }
  50308. ,
  50309. Object.defineProperty(t.prototype, "boundingBoxSize", {
  50310. get: function() {
  50311. return this._boundingBoxSize
  50312. },
  50313. set: function(e) {
  50314. if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
  50315. this._boundingBoxSize = e;
  50316. var t = this.getScene();
  50317. t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
  50318. }
  50319. },
  50320. enumerable: !1,
  50321. configurable: !0
  50322. }),
  50323. Object.defineProperty(t.prototype, "depthStencilTexture", {
  50324. get: function() {
  50325. var e, t;
  50326. return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e._depthStencilTexture) && void 0 !== t ? t : null
  50327. },
  50328. enumerable: !1,
  50329. configurable: !0
  50330. }),
  50331. t.prototype.createDepthStencilTexture = function(e, t, i, n, r) {
  50332. var o;
  50333. void 0 === e && (e = 0),
  50334. void 0 === t && (t = !0),
  50335. void 0 === i && (i = !1),
  50336. void 0 === n && (n = 1),
  50337. void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
  50338. null === (o = this._renderTarget) || void 0 === o || o.createDepthStencilTexture(e, t, i, n, r)
  50339. }
  50340. ,
  50341. t.prototype._releaseRenderPassId = function() {
  50342. if (this._scene)
  50343. for (var e = this._scene.getEngine(), t = 0; t < this._renderPassIds.length; ++t)
  50344. e.releaseRenderPassId(this._renderPassIds[t]);
  50345. this._renderPassIds = []
  50346. }
  50347. ,
  50348. t.prototype._createRenderPassId = function() {
  50349. this._releaseRenderPassId();
  50350. for (var e = this._scene.getEngine(), t = this._isCubeData ? 6 : this.getRenderLayers() || 1, i = 0; i < t; ++i)
  50351. this._renderPassIds[i] = e.createRenderPassId("RenderTargetTexture - ".concat(this.name, "#").concat(i))
  50352. }
  50353. ,
  50354. t.prototype._processSizeParameter = function(e) {
  50355. if (e.ratio) {
  50356. this._sizeRatio = e.ratio;
  50357. var t = this._getEngine();
  50358. this._size = {
  50359. width: this._bestReflectionRenderTargetDimension(t.getRenderWidth(), this._sizeRatio),
  50360. height: this._bestReflectionRenderTargetDimension(t.getRenderHeight(), this._sizeRatio)
  50361. }
  50362. } else
  50363. this._size = e;
  50364. this._createRenderPassId()
  50365. }
  50366. ,
  50367. Object.defineProperty(t.prototype, "samples", {
  50368. get: function() {
  50369. var e, t;
  50370. return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : this._samples
  50371. },
  50372. set: function(e) {
  50373. this._renderTarget && (this._samples = this._renderTarget.setSamples(e))
  50374. },
  50375. enumerable: !1,
  50376. configurable: !0
  50377. }),
  50378. t.prototype.resetRefreshCounter = function() {
  50379. this._currentRefreshId = -1
  50380. }
  50381. ,
  50382. Object.defineProperty(t.prototype, "refreshRate", {
  50383. get: function() {
  50384. return this._refreshRate
  50385. },
  50386. set: function(e) {
  50387. this._refreshRate = e,
  50388. this.resetRefreshCounter()
  50389. },
  50390. enumerable: !1,
  50391. configurable: !0
  50392. }),
  50393. t.prototype.addPostProcess = function(e) {
  50394. if (!this._postProcessManager) {
  50395. var t = this.getScene();
  50396. if (!t)
  50397. return;
  50398. this._postProcessManager = new Vi(t),
  50399. this._postProcesses = new Array
  50400. }
  50401. this._postProcesses.push(e),
  50402. this._postProcesses[0].autoClear = !1
  50403. }
  50404. ,
  50405. t.prototype.clearPostProcesses = function(e) {
  50406. if (void 0 === e && (e = !1),
  50407. this._postProcesses) {
  50408. if (e)
  50409. for (var t = 0, i = this._postProcesses; t < i.length; t++)
  50410. i[t].dispose();
  50411. this._postProcesses = []
  50412. }
  50413. }
  50414. ,
  50415. t.prototype.removePostProcess = function(e) {
  50416. if (this._postProcesses) {
  50417. var t = this._postProcesses.indexOf(e);
  50418. -1 !== t && (this._postProcesses.splice(t, 1),
  50419. this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1))
  50420. }
  50421. }
  50422. ,
  50423. t.prototype._shouldRender = function() {
  50424. return -1 === this._currentRefreshId || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
  50425. !0) : (this._currentRefreshId++,
  50426. !1)
  50427. }
  50428. ,
  50429. t.prototype.getRenderSize = function() {
  50430. return this.getRenderWidth()
  50431. }
  50432. ,
  50433. t.prototype.getRenderWidth = function() {
  50434. return this._size.width ? this._size.width : this._size
  50435. }
  50436. ,
  50437. t.prototype.getRenderHeight = function() {
  50438. return this._size.width ? this._size.height : this._size
  50439. }
  50440. ,
  50441. t.prototype.getRenderLayers = function() {
  50442. return this._size.layers || 0
  50443. }
  50444. ,
  50445. t.prototype.disableRescaling = function() {
  50446. this._canRescale = !1
  50447. }
  50448. ,
  50449. Object.defineProperty(t.prototype, "canRescale", {
  50450. get: function() {
  50451. return this._canRescale
  50452. },
  50453. enumerable: !1,
  50454. configurable: !0
  50455. }),
  50456. t.prototype.scale = function(e) {
  50457. var t = Math.max(1, this.getRenderSize() * e);
  50458. this.resize(t)
  50459. }
  50460. ,
  50461. t.prototype.getReflectionTextureMatrix = function() {
  50462. return this.isCube ? this._textureMatrix : e.prototype.getReflectionTextureMatrix.call(this)
  50463. }
  50464. ,
  50465. t.prototype.resize = function(e) {
  50466. var t, i = this.isCube;
  50467. null === (t = this._renderTarget) || void 0 === t || t.dispose(),
  50468. this._renderTarget = null;
  50469. var n = this.getScene();
  50470. n && (this._processSizeParameter(e),
  50471. this._renderTarget = i ? n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : n.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions),
  50472. this._texture = this._renderTarget.texture,
  50473. void 0 !== this._renderTargetOptions.samples && (this.samples = this._renderTargetOptions.samples),
  50474. this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this))
  50475. }
  50476. ,
  50477. t.prototype.render = function(e, t) {
  50478. void 0 === e && (e = !1),
  50479. void 0 === t && (t = !1),
  50480. this._render(e, t)
  50481. }
  50482. ,
  50483. t.prototype.isReadyForRendering = function() {
  50484. return this._render(!1, !1, !0)
  50485. }
  50486. ,
  50487. t.prototype._render = function(e, t, i) {
  50488. var n;
  50489. void 0 === e && (e = !1),
  50490. void 0 === t && (t = !1),
  50491. void 0 === i && (i = !1);
  50492. var r = this.getScene();
  50493. if (!r)
  50494. return i;
  50495. var o = r.getEngine();
  50496. if (void 0 !== this.useCameraPostProcesses && (e = this.useCameraPostProcesses),
  50497. this._waitingRenderList) {
  50498. this.renderList = [];
  50499. for (var a = 0; a < this._waitingRenderList.length; a++) {
  50500. var s = this._waitingRenderList[a];
  50501. (u = r.getMeshById(s)) && this.renderList.push(u)
  50502. }
  50503. this._waitingRenderList = void 0
  50504. }
  50505. if (this.renderListPredicate) {
  50506. this.renderList ? this.renderList.length = 0 : this.renderList = [];
  50507. var l = this.getScene();
  50508. if (!l)
  50509. return i;
  50510. var c = l.meshes;
  50511. for (a = 0; a < c.length; a++) {
  50512. var u = c[a];
  50513. this.renderListPredicate(u) && this.renderList.push(u)
  50514. }
  50515. }
  50516. var h = o.currentRenderPassId;
  50517. this.onBeforeBindObservable.notifyObservers(this);
  50518. var d = null !== (n = this.activeCamera) && void 0 !== n ? n : r.activeCamera;
  50519. d && (d !== r.activeCamera && r.setTransformMatrix(d.getViewMatrix(), d.getProjectionMatrix(!0)),
  50520. o.setViewport(d.viewport, this.getRenderWidth(), this.getRenderHeight())),
  50521. this._defaultRenderListPrepared = !1;
  50522. var p = i;
  50523. if (i) {
  50524. r.getViewMatrix() || r.updateTransformMatrix();
  50525. var f = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1;
  50526. for (y = 0; y < f && p; y++) {
  50527. var _ = null
  50528. , m = this.renderList ? this.renderList : r.getActiveMeshes().data
  50529. , g = this.renderList ? this.renderList.length : r.getActiveMeshes().length;
  50530. o.currentRenderPassId = this._renderPassIds[y],
  50531. this.onBeforeRenderObservable.notifyObservers(y),
  50532. this.getCustomRenderList && (_ = this.getCustomRenderList(y, m, g)),
  50533. _ || (_ = m),
  50534. this._doNotChangeAspectRatio || r.updateTransformMatrix(!0);
  50535. for (var v = 0; v < _.length && p; ++v)
  50536. if ((u = _[v]).isEnabled() && !u.isBlocked && u.isVisible && u.subMeshes)
  50537. if (this.customIsReadyFunction) {
  50538. if (!this.customIsReadyFunction(u, this.refreshRate)) {
  50539. p = !1;
  50540. break
  50541. }
  50542. } else if (!u.isReady(!0)) {
  50543. p = !1;
  50544. break
  50545. }
  50546. this.onAfterRenderObservable.notifyObservers(y)
  50547. }
  50548. } else if (this.is2DArray)
  50549. for (var y = 0; y < this.getRenderLayers(); y++)
  50550. this._renderToTarget(0, e, t, y, d),
  50551. r.incrementRenderId(),
  50552. r.resetCachedMaterial();
  50553. else if (this.isCube)
  50554. for (var b = 0; b < 6; b++)
  50555. this._renderToTarget(b, e, t, void 0, d),
  50556. r.incrementRenderId(),
  50557. r.resetCachedMaterial();
  50558. else
  50559. this._renderToTarget(0, e, t, void 0, d);
  50560. return this.onAfterUnbindObservable.notifyObservers(this),
  50561. o.currentRenderPassId = h,
  50562. r.activeCamera && ((r.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== r.activeCamera) && r.setTransformMatrix(r.activeCamera.getViewMatrix(), r.activeCamera.getProjectionMatrix(!0)),
  50563. o.setViewport(r.activeCamera.viewport)),
  50564. r.resetCachedMaterial(),
  50565. p
  50566. }
  50567. ,
  50568. t.prototype._bestReflectionRenderTargetDimension = function(e, t) {
  50569. var i = e * t
  50570. , n = vr.NearestPOT(i + 16384 / (128 + i));
  50571. return Math.min(vr.FloorPOT(e), n)
  50572. }
  50573. ,
  50574. t.prototype._prepareRenderingManager = function(e, t, i, n) {
  50575. var r = this.getScene();
  50576. if (r) {
  50577. this._renderingManager.reset();
  50578. for (var o = r.getRenderId(), a = 0; a < t; a++) {
  50579. var s = e[a];
  50580. if (s && !s.isBlocked) {
  50581. if (this.customIsReadyFunction) {
  50582. if (!this.customIsReadyFunction(s, this.refreshRate)) {
  50583. this.resetRefreshCounter();
  50584. continue
  50585. }
  50586. } else if (!s.isReady(0 === this.refreshRate)) {
  50587. this.resetRefreshCounter();
  50588. continue
  50589. }
  50590. if (!s._internalAbstractMeshDataInfo._currentLODIsUpToDate && r.activeCamera && (s._internalAbstractMeshDataInfo._currentLOD = r.customLODSelector ? r.customLODSelector(s, this.activeCamera || r.activeCamera) : s.getLOD(this.activeCamera || r.activeCamera),
  50591. s._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
  50592. !s._internalAbstractMeshDataInfo._currentLOD)
  50593. continue;
  50594. var l = s._internalAbstractMeshDataInfo._currentLOD;
  50595. l._preActivateForIntermediateRendering(o);
  50596. var c;
  50597. if (c = !(!n || !i) && 0 == (s.layerMask & i.layerMask),
  50598. s.isEnabled() && s.isVisible && s.subMeshes && !c && (l !== s && l._activate(o, !0),
  50599. s._activate(o, !0) && s.subMeshes.length)) {
  50600. s.isAnInstance ? s._internalAbstractMeshDataInfo._actAsRegularMesh && (l = s) : l._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1,
  50601. l._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
  50602. for (var u = 0; u < l.subMeshes.length; u++) {
  50603. var h = l.subMeshes[u];
  50604. this._renderingManager.dispatch(h, l)
  50605. }
  50606. }
  50607. }
  50608. }
  50609. for (var d = 0; d < r.particleSystems.length; d++) {
  50610. var p = r.particleSystems[d]
  50611. , f = p.emitter;
  50612. p.isStarted() && f && f.position && f.isEnabled() && e.indexOf(f) >= 0 && this._renderingManager.dispatchParticles(p)
  50613. }
  50614. }
  50615. }
  50616. ,
  50617. t.prototype._bindFrameBuffer = function(e, t) {
  50618. void 0 === e && (e = 0),
  50619. void 0 === t && (t = 0);
  50620. var i = this.getScene();
  50621. if (i) {
  50622. var n = i.getEngine();
  50623. this._renderTarget && n.bindFramebuffer(this._renderTarget, this.isCube ? e : void 0, void 0, void 0, this.ignoreCameraViewport, 0, t)
  50624. }
  50625. }
  50626. ,
  50627. t.prototype._unbindFrameBuffer = function(e, t) {
  50628. var i = this;
  50629. this._renderTarget && e.unBindFramebuffer(this._renderTarget, this.isCube, (function() {
  50630. i.onAfterRenderObservable.notifyObservers(t)
  50631. }
  50632. ))
  50633. }
  50634. ,
  50635. t.prototype._prepareFrame = function(e, t, i, n) {
  50636. this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : n && e.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(t, i)
  50637. }
  50638. ,
  50639. t.prototype._renderToTarget = function(e, t, i, n, r) {
  50640. var o, s, l, c;
  50641. void 0 === n && (n = 0),
  50642. void 0 === r && (r = null);
  50643. var u = this.getScene();
  50644. if (u) {
  50645. var h = u.getEngine();
  50646. if (this._texture) {
  50647. if (null === (o = h._debugPushGroup) || void 0 === o || o.call(h, "render to face #".concat(e, " layer #").concat(n), 1),
  50648. this._prepareFrame(u, e, n, t),
  50649. this.is2DArray ? (h.currentRenderPassId = this._renderPassIds[n],
  50650. this.onBeforeRenderObservable.notifyObservers(n)) : (h.currentRenderPassId = this._renderPassIds[e],
  50651. this.onBeforeRenderObservable.notifyObservers(e)),
  50652. h.snapshotRendering && h.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST)
  50653. this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0);
  50654. else {
  50655. var d = null
  50656. , p = this.renderList ? this.renderList : u.getActiveMeshes().data
  50657. , f = this.renderList ? this.renderList.length : u.getActiveMeshes().length;
  50658. this.getCustomRenderList && (d = this.getCustomRenderList(this.is2DArray ? n : e, p, f)),
  50659. d ? this._prepareRenderingManager(d, d.length, r, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(p, f, r, !this.renderList),
  50660. this._defaultRenderListPrepared = !0),
  50661. d = p);
  50662. for (var _ = 0, m = u._beforeRenderTargetClearStage; _ < m.length; _++)
  50663. m[_].action(this, e, n);
  50664. this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0),
  50665. this._doNotChangeAspectRatio || u.updateTransformMatrix(!0);
  50666. for (var g = 0, v = u._beforeRenderTargetDrawStage; g < v.length; g++)
  50667. v[g].action(this, e, n);
  50668. this._renderingManager.render(this.customRenderFunction, d, this.renderParticles, this.renderSprites);
  50669. for (var y = 0, b = u._afterRenderTargetDrawStage; y < b.length; y++)
  50670. b[y].action(this, e, n);
  50671. var T = this._texture.generateMipMaps;
  50672. this._texture.generateMipMaps = !1,
  50673. this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, null !== (s = this._renderTarget) && void 0 !== s ? s : void 0, e, this._postProcesses, this.ignoreCameraViewport) : t && u.postProcessManager._finalizeFrame(!1, null !== (l = this._renderTarget) && void 0 !== l ? l : void 0, e),
  50674. this._texture.generateMipMaps = T,
  50675. this._doNotChangeAspectRatio || u.updateTransformMatrix(!0),
  50676. i && gi.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), h)
  50677. }
  50678. this._unbindFrameBuffer(h, e),
  50679. this.isCube && 5 === e && h.generateMipMapsForCubemap(this._texture),
  50680. null === (c = h._debugPopGroup) || void 0 === c || c.call(h, 1)
  50681. }
  50682. }
  50683. }
  50684. ,
  50685. t.prototype.setRenderingOrder = function(e, t, i, n) {
  50686. void 0 === t && (t = null),
  50687. void 0 === i && (i = null),
  50688. void 0 === n && (n = null),
  50689. this._renderingManager.setRenderingOrder(e, t, i, n)
  50690. }
  50691. ,
  50692. t.prototype.setRenderingAutoClearDepthStencil = function(e, t) {
  50693. this._renderingManager.setRenderingAutoClearDepthStencil(e, t),
  50694. this._renderingManager._useSceneAutoClearSetup = !1
  50695. }
  50696. ,
  50697. t.prototype.clone = function() {
  50698. var e = this.getSize()
  50699. , i = new t(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);
  50700. return i.hasAlpha = this.hasAlpha,
  50701. i.level = this.level,
  50702. i.coordinatesMode = this.coordinatesMode,
  50703. this.renderList && (i.renderList = this.renderList.slice(0)),
  50704. i
  50705. }
  50706. ,
  50707. t.prototype.serialize = function() {
  50708. if (!this.name)
  50709. return null;
  50710. var t = e.prototype.serialize.call(this);
  50711. if (t.renderTargetSize = this.getRenderSize(),
  50712. t.renderList = [],
  50713. this.renderList)
  50714. for (var i = 0; i < this.renderList.length; i++)
  50715. t.renderList.push(this.renderList[i].id);
  50716. return t
  50717. }
  50718. ,
  50719. t.prototype.disposeFramebufferObjects = function() {
  50720. var e;
  50721. null === (e = this._renderTarget) || void 0 === e || e.dispose(!0)
  50722. }
  50723. ,
  50724. t.prototype.releaseInternalTexture = function() {
  50725. var e;
  50726. null === (e = this._renderTarget) || void 0 === e || e.releaseTextures(),
  50727. this._texture = null
  50728. }
  50729. ,
  50730. t.prototype.dispose = function() {
  50731. var t;
  50732. this.onResizeObservable.clear(),
  50733. this.onClearObservable.clear(),
  50734. this.onAfterRenderObservable.clear(),
  50735. this.onAfterUnbindObservable.clear(),
  50736. this.onBeforeBindObservable.clear(),
  50737. this.onBeforeRenderObservable.clear(),
  50738. this._postProcessManager && (this._postProcessManager.dispose(),
  50739. this._postProcessManager = null),
  50740. this._prePassRenderTarget && this._prePassRenderTarget.dispose(),
  50741. this._releaseRenderPassId(),
  50742. this.clearPostProcesses(!0),
  50743. this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),
  50744. this._resizeObserver = null),
  50745. this.renderList = null;
  50746. var i = this.getScene();
  50747. if (i) {
  50748. var n = i.customRenderTargets.indexOf(this);
  50749. n >= 0 && i.customRenderTargets.splice(n, 1);
  50750. for (var r = 0, o = i.cameras; r < o.length; r++) {
  50751. var a = o[r];
  50752. (n = a.customRenderTargets.indexOf(this)) >= 0 && a.customRenderTargets.splice(n, 1)
  50753. }
  50754. null === (t = this._renderTarget) || void 0 === t || t.dispose(),
  50755. this._renderTarget = null,
  50756. this._texture = null,
  50757. e.prototype.dispose.call(this)
  50758. }
  50759. }
  50760. ,
  50761. t.prototype._rebuild = function() {
  50762. this.refreshRate === t.REFRESHRATE_RENDER_ONCE && (this.refreshRate = t.REFRESHRATE_RENDER_ONCE),
  50763. this._postProcessManager && this._postProcessManager._rebuild()
  50764. }
  50765. ,
  50766. t.prototype.freeRenderingGroups = function() {
  50767. this._renderingManager && this._renderingManager.freeRenderingGroups()
  50768. }
  50769. ,
  50770. t.prototype.getViewCount = function() {
  50771. return 1
  50772. }
  50773. ,
  50774. t.REFRESHRATE_RENDER_ONCE = 0,
  50775. t.REFRESHRATE_RENDER_ONEVERYFRAME = 1,
  50776. t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2,
  50777. t
  50778. }(io);
  50779. io._CreateRenderTargetTexture = function(e, t, i, n, r) {
  50780. return new ns(e,t,i,n)
  50781. }
  50782. ;
  50783. var rs = function(e) {
  50784. function t(t, i) {
  50785. void 0 === i && (i = 512);
  50786. var n = e.call(this, "multiview rtt", i, t, !1, !0, a.TEXTURETYPE_UNSIGNED_INT, !1, void 0, !1, !1, !0, void 0, !0) || this;
  50787. return n._renderTarget = n.getScene().getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(), n.getRenderHeight()),
  50788. n._texture = n._renderTarget.texture,
  50789. n._texture.isMultiview = !0,
  50790. n._texture.format = a.TEXTUREFORMAT_RGBA,
  50791. n.samples = n._getEngine().getCaps().maxSamples || n.samples,
  50792. n
  50793. }
  50794. return U(t, e),
  50795. Object.defineProperty(t.prototype, "samples", {
  50796. set: function(e) {
  50797. this._samples = e
  50798. },
  50799. enumerable: !1,
  50800. configurable: !0
  50801. }),
  50802. t.prototype._bindFrameBuffer = function() {
  50803. this._renderTarget && this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)
  50804. }
  50805. ,
  50806. t.prototype.getViewCount = function() {
  50807. return 2
  50808. }
  50809. ,
  50810. t
  50811. }(ns);
  50812. function os(e, t) {
  50813. var i = new Fi(e,void 0,!0,t);
  50814. return i.addUniform("viewProjection", 16),
  50815. i.addUniform("viewProjectionR", 16),
  50816. i.addUniform("view", 16),
  50817. i.addUniform("projection", 16),
  50818. i.addUniform("vEyePosition", 4),
  50819. i
  50820. }
  50821. vr.prototype.createMultiviewRenderTargetTexture = function(e, t) {
  50822. var i = this._gl;
  50823. if (!this.getCaps().multiview)
  50824. throw "Multiview is not supported";
  50825. var n = this._createHardwareRenderTargetWrapper(!1, !1, {
  50826. width: e,
  50827. height: t
  50828. });
  50829. n._framebuffer = i.createFramebuffer();
  50830. var r = new Lt(this,At.Unknown,!0);
  50831. return r.width = e,
  50832. r.height = t,
  50833. r.isMultiview = !0,
  50834. n._colorTextureArray = i.createTexture(),
  50835. i.bindTexture(i.TEXTURE_2D_ARRAY, n._colorTextureArray),
  50836. i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.RGBA8, e, t, 2),
  50837. n._depthStencilTextureArray = i.createTexture(),
  50838. i.bindTexture(i.TEXTURE_2D_ARRAY, n._depthStencilTextureArray),
  50839. i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.DEPTH24_STENCIL8, e, t, 2),
  50840. r.isReady = !0,
  50841. n.setTextures(r),
  50842. n._depthStencilTexture = r,
  50843. n
  50844. }
  50845. ,
  50846. vr.prototype.bindMultiviewFramebuffer = function(e) {
  50847. var t = e
  50848. , i = this._gl
  50849. , n = this.getCaps().oculusMultiview || this.getCaps().multiview;
  50850. if (this.bindFramebuffer(t, void 0, void 0, void 0, !0),
  50851. i.bindFramebuffer(i.DRAW_FRAMEBUFFER, t._framebuffer),
  50852. !t._colorTextureArray || !t._depthStencilTextureArray)
  50853. throw "Invalid multiview frame buffer";
  50854. this.getCaps().oculusMultiview ? (n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, t.samples, 0, 2),
  50855. n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, t.samples, 0, 2)) : (n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, 0, 2),
  50856. n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, 0, 2))
  50857. }
  50858. ,
  50859. Rr.prototype._useMultiviewToSingleView = !1,
  50860. Rr.prototype._multiviewTexture = null,
  50861. Rr.prototype._resizeOrCreateMultiviewTexture = function(e, t) {
  50862. this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == e && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(),
  50863. this._multiviewTexture = new rs(this.getScene(),{
  50864. width: e,
  50865. height: t
  50866. })) : this._multiviewTexture = new rs(this.getScene(),{
  50867. width: e,
  50868. height: t
  50869. })
  50870. }
  50871. ;
  50872. var as = mn.prototype.createSceneUniformBuffer;
  50873. mn.prototype._transformMatrixR = P.Zero(),
  50874. mn.prototype._multiviewSceneUbo = null,
  50875. mn.prototype._createMultiviewUbo = function() {
  50876. this._multiviewSceneUbo = os(this.getEngine(), "scene_multiview")
  50877. }
  50878. ,
  50879. mn.prototype.createSceneUniformBuffer = function(e) {
  50880. return this._multiviewSceneUbo ? os(this.getEngine(), e) : as.bind(this)(e)
  50881. }
  50882. ,
  50883. mn.prototype._updateMultiviewUbo = function(e, t) {
  50884. e && t && e.multiplyToRef(t, this._transformMatrixR),
  50885. e && t && (e.multiplyToRef(t, I.Matrix[0]),
  50886. dn.GetRightPlaneToRef(I.Matrix[0], this._frustumPlanes[3])),
  50887. this._multiviewSceneUbo && (this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix()),
  50888. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR),
  50889. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix),
  50890. this._multiviewSceneUbo.updateMatrix("projection", this._projectionMatrix))
  50891. }
  50892. ,
  50893. mn.prototype._renderMultiviewToSingleView = function(e) {
  50894. e._resizeOrCreateMultiviewTexture(e._rigPostProcess && e._rigPostProcess && e._rigPostProcess.width > 0 ? e._rigPostProcess.width : this.getEngine().getRenderWidth(!0), e._rigPostProcess && e._rigPostProcess && e._rigPostProcess.height > 0 ? e._rigPostProcess.height : this.getEngine().getRenderHeight(!0)),
  50895. this._multiviewSceneUbo || this._createMultiviewUbo(),
  50896. e.outputRenderTarget = e._multiviewTexture,
  50897. this._renderForCamera(e),
  50898. e.outputRenderTarget = null;
  50899. for (var t = 0; t < e._rigCameras.length; t++) {
  50900. var i = this.getEngine();
  50901. this._activeCamera = e._rigCameras[t],
  50902. i.setViewport(this._activeCamera.viewport),
  50903. this.postProcessManager && (this.postProcessManager._prepareFrame(),
  50904. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))
  50905. }
  50906. }
  50907. ;
  50908. var ss = function(e) {
  50909. function t(t, i, n) {
  50910. var r = e.call(this, t, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], n, i, io.BILINEAR_SAMPLINGMODE) || this;
  50911. return r.onSizeChangedObservable.add((function() {}
  50912. )),
  50913. r.onApplyObservable.add((function(e) {
  50914. i._scene.activeCamera && i._scene.activeCamera.isLeftCamera ? e.setInt("imageIndex", 0) : e.setInt("imageIndex", 1),
  50915. e.setTexture("multiviewSampler", i._multiviewTexture)
  50916. }
  50917. )),
  50918. r
  50919. }
  50920. return U(t, e),
  50921. t.prototype.getClassName = function() {
  50922. return "VRMultiviewToSingleviewPostProcess"
  50923. }
  50924. ,
  50925. t
  50926. }(Ba);
  50927. function ls(e, t) {
  50928. var i = t.vrCameraMetrics || ts.GetDefault();
  50929. e._rigCameras[0]._cameraRigParams.vrMetrics = i,
  50930. e._rigCameras[0].viewport = new xr(0,0,.5,1),
  50931. e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new P,
  50932. e._rigCameras[0]._cameraRigParams.vrHMatrix = i.leftHMatrix,
  50933. e._rigCameras[0]._cameraRigParams.vrPreViewMatrix = i.leftPreViewMatrix,
  50934. e._rigCameras[0].getProjectionMatrix = e._rigCameras[0]._getVRProjectionMatrix,
  50935. e._rigCameras[1]._cameraRigParams.vrMetrics = i,
  50936. e._rigCameras[1].viewport = new xr(.5,0,.5,1),
  50937. e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new P,
  50938. e._rigCameras[1]._cameraRigParams.vrHMatrix = i.rightHMatrix,
  50939. e._rigCameras[1]._cameraRigParams.vrPreViewMatrix = i.rightPreViewMatrix,
  50940. e._rigCameras[1].getProjectionMatrix = e._rigCameras[1]._getVRProjectionMatrix,
  50941. i.multiviewEnabled && (e.getScene().getEngine().getCaps().multiview ? (e._useMultiviewToSingleView = !0,
  50942. e._rigPostProcess = new ss("VRMultiviewToSingleview",e,i.postProcessScaleFactor)) : (K.Warn("Multiview is not supported, falling back to standard rendering"),
  50943. i.multiviewEnabled = !1)),
  50944. i.compensateDistortion && (e._rigCameras[0]._rigPostProcess = new is("VR_Distort_Compensation_Left",e._rigCameras[0],!1,i),
  50945. e._rigCameras[1]._rigPostProcess = new is("VR_Distort_Compensation_Right",e._rigCameras[1],!0,i))
  50946. }
  50947. Xe.AddNodeConstructor("VRDeviceOrientationArcRotateCamera", (function(e, t) {
  50948. return function() {
  50949. return new cs(e,0,0,1,x.Zero(),t)
  50950. }
  50951. }
  50952. ));
  50953. var cs = function(e) {
  50954. function t(t, i, n, r, o, a, s, l) {
  50955. void 0 === s && (s = !0),
  50956. void 0 === l && (l = ts.GetDefault());
  50957. var c = e.call(this, t, i, n, r, o, a) || this;
  50958. return c._setRigMode = ls.bind(null, c),
  50959. l.compensateDistortion = s,
  50960. c.setCameraRigMode(Rr.RIG_MODE_VR, {
  50961. vrCameraMetrics: l
  50962. }),
  50963. c.inputs.addVRDeviceOrientation(),
  50964. c
  50965. }
  50966. return U(t, e),
  50967. t.prototype.getClassName = function() {
  50968. return "VRDeviceOrientationArcRotateCamera"
  50969. }
  50970. ,
  50971. t
  50972. }(_a);
  50973. Xe.AddNodeConstructor("VRDeviceOrientationFreeCamera", (function(e, t) {
  50974. return function() {
  50975. return new us(e,x.Zero(),t)
  50976. }
  50977. }
  50978. ));
  50979. var us = function(e) {
  50980. function t(t, i, n, r, o) {
  50981. void 0 === r && (r = !0),
  50982. void 0 === o && (o = ts.GetDefault());
  50983. var a = e.call(this, t, i, n) || this;
  50984. return a._setRigMode = ls.bind(null, a),
  50985. o.compensateDistortion = r,
  50986. a.setCameraRigMode(Rr.RIG_MODE_VR, {
  50987. vrCameraMetrics: o
  50988. }),
  50989. a
  50990. }
  50991. return U(t, e),
  50992. t.prototype.getClassName = function() {
  50993. return "VRDeviceOrientationFreeCamera"
  50994. }
  50995. ,
  50996. t
  50997. }(ma);
  50998. Xe.AddNodeConstructor("VRDeviceOrientationGamepadCamera", (function(e, t) {
  50999. return function() {
  51000. return new hs(e,x.Zero(),t)
  51001. }
  51002. }
  51003. ));
  51004. var hs = function(e) {
  51005. function t(t, i, n, r, o) {
  51006. void 0 === r && (r = !0),
  51007. void 0 === o && (o = ts.GetDefault());
  51008. var a = e.call(this, t, i, n, r, o) || this;
  51009. return a._setRigMode = ls.bind(null, a),
  51010. a.inputs.addGamepad(),
  51011. a
  51012. }
  51013. return U(t, e),
  51014. t.prototype.getClassName = function() {
  51015. return "VRDeviceOrientationGamepadCamera"
  51016. }
  51017. ,
  51018. t
  51019. }(us);
  51020. Xe.AddNodeConstructor("Light_Type_3", (function(e, t) {
  51021. return function() {
  51022. return new ds(e,x.Zero(),t)
  51023. }
  51024. }
  51025. ));
  51026. var ds = function(e) {
  51027. function t(t, i, n) {
  51028. var r = e.call(this, t, n) || this;
  51029. return r.groundColor = new D(0,0,0),
  51030. r.direction = i || x.Up(),
  51031. r
  51032. }
  51033. return U(t, e),
  51034. t.prototype._buildUniformLayout = function() {
  51035. this._uniformBuffer.addUniform("vLightData", 4),
  51036. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  51037. this._uniformBuffer.addUniform("vLightSpecular", 4),
  51038. this._uniformBuffer.addUniform("vLightGround", 3),
  51039. this._uniformBuffer.addUniform("shadowsInfo", 3),
  51040. this._uniformBuffer.addUniform("depthValues", 2),
  51041. this._uniformBuffer.create()
  51042. }
  51043. ,
  51044. t.prototype.getClassName = function() {
  51045. return "HemisphericLight"
  51046. }
  51047. ,
  51048. t.prototype.setDirectionToTarget = function(e) {
  51049. return this.direction = x.Normalize(e.subtract(x.Zero())),
  51050. this.direction
  51051. }
  51052. ,
  51053. t.prototype.getShadowGenerator = function() {
  51054. return null
  51055. }
  51056. ,
  51057. t.prototype.transferToEffect = function(e, t) {
  51058. var i = x.Normalize(this.direction);
  51059. return this._uniformBuffer.updateFloat4("vLightData", i.x, i.y, i.z, 0, t),
  51060. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), t),
  51061. this
  51062. }
  51063. ,
  51064. t.prototype.transferToNodeMaterialEffect = function(e, t) {
  51065. var i = x.Normalize(this.direction);
  51066. return e.setFloat3(t, i.x, i.y, i.z),
  51067. this
  51068. }
  51069. ,
  51070. t.prototype.computeWorldMatrix = function() {
  51071. return this._worldMatrix || (this._worldMatrix = P.Identity()),
  51072. this._worldMatrix
  51073. }
  51074. ,
  51075. t.prototype.getTypeID = function() {
  51076. return Cr.LIGHTTYPEID_HEMISPHERICLIGHT
  51077. }
  51078. ,
  51079. t.prototype.prepareLightSpecificDefines = function(e, t) {
  51080. e["HEMILIGHT" + t] = !0
  51081. }
  51082. ,
  51083. k([Me()], t.prototype, "groundColor", void 0),
  51084. k([De()], t.prototype, "direction", void 0),
  51085. t
  51086. }(Cr);
  51087. function ps(e, t) {
  51088. if (t.vrDisplay) {
  51089. var i = t.vrDisplay.getEyeParameters("left")
  51090. , n = t.vrDisplay.getEyeParameters("right");
  51091. e._rigCameras[0].viewport = new xr(0,0,.5,1),
  51092. e._rigCameras[0].setCameraRigParameter("left", !0),
  51093. e._rigCameras[0].setCameraRigParameter("specs", t.specs),
  51094. e._rigCameras[0].setCameraRigParameter("eyeParameters", i),
  51095. e._rigCameras[0].setCameraRigParameter("frameData", t.frameData),
  51096. e._rigCameras[0].setCameraRigParameter("parentCamera", t.parentCamera),
  51097. e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new P,
  51098. e._rigCameras[0].getProjectionMatrix = e._getWebVRProjectionMatrix,
  51099. e._rigCameras[0].parent = e,
  51100. e._rigCameras[0]._getViewMatrix = e._getWebVRViewMatrix,
  51101. e._rigCameras[1].viewport = new xr(.5,0,.5,1),
  51102. e._rigCameras[1].setCameraRigParameter("eyeParameters", n),
  51103. e._rigCameras[1].setCameraRigParameter("specs", t.specs),
  51104. e._rigCameras[1].setCameraRigParameter("frameData", t.frameData),
  51105. e._rigCameras[1].setCameraRigParameter("parentCamera", t.parentCamera),
  51106. e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new P,
  51107. e._rigCameras[1].getProjectionMatrix = e._getWebVRProjectionMatrix,
  51108. e._rigCameras[1].parent = e,
  51109. e._rigCameras[1]._getViewMatrix = e._getWebVRViewMatrix
  51110. }
  51111. }
  51112. Object.defineProperty(vr.prototype, "isInVRExclusivePointerMode", {
  51113. get: function() {
  51114. return this._vrExclusivePointerMode
  51115. },
  51116. enumerable: !0,
  51117. configurable: !0
  51118. }),
  51119. vr.prototype._prepareVRComponent = function() {
  51120. this._vrSupported = !1,
  51121. this._vrExclusivePointerMode = !1,
  51122. this.onVRDisplayChangedObservable = new h,
  51123. this.onVRRequestPresentComplete = new h,
  51124. this.onVRRequestPresentStart = new h
  51125. }
  51126. ,
  51127. vr.prototype.isVRDevicePresent = function() {
  51128. return !!this._vrDisplay
  51129. }
  51130. ,
  51131. vr.prototype.getVRDevice = function() {
  51132. return this._vrDisplay
  51133. }
  51134. ,
  51135. vr.prototype.initWebVR = function() {
  51136. return this.initWebVRAsync(),
  51137. this.onVRDisplayChangedObservable
  51138. }
  51139. ,
  51140. vr.prototype.initWebVRAsync = function() {
  51141. var e = this
  51142. , t = function() {
  51143. var t = {
  51144. vrDisplay: e._vrDisplay,
  51145. vrSupported: e._vrSupported
  51146. };
  51147. e.onVRDisplayChangedObservable.notifyObservers(t),
  51148. e._webVRInitPromise = new Promise((function(e) {
  51149. e(t)
  51150. }
  51151. ))
  51152. };
  51153. if (!this._onVrDisplayConnect) {
  51154. this._onVrDisplayConnect = function(i) {
  51155. e._vrDisplay = i.display,
  51156. t()
  51157. }
  51158. ,
  51159. this._onVrDisplayDisconnect = function() {
  51160. e._vrDisplay.cancelAnimationFrame(e._frameHandler),
  51161. e._vrDisplay = void 0,
  51162. e._frameHandler = vr.QueueNewFrame(e._boundRenderFunction),
  51163. t()
  51164. }
  51165. ,
  51166. this._onVrDisplayPresentChange = function() {
  51167. e._vrExclusivePointerMode = e._vrDisplay && e._vrDisplay.isPresenting
  51168. }
  51169. ;
  51170. var i = this.getHostWindow();
  51171. i && (i.addEventListener("vrdisplayconnect", this._onVrDisplayConnect),
  51172. i.addEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
  51173. i.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange))
  51174. }
  51175. return this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync(),
  51176. this._webVRInitPromise.then(t),
  51177. this._webVRInitPromise
  51178. }
  51179. ,
  51180. vr.prototype._getVRDisplaysAsync = function() {
  51181. var e = this;
  51182. return new Promise((function(t) {
  51183. navigator.getVRDisplays ? navigator.getVRDisplays().then((function(i) {
  51184. e._vrSupported = !0,
  51185. e._vrDisplay = i[0],
  51186. t({
  51187. vrDisplay: e._vrDisplay,
  51188. vrSupported: e._vrSupported
  51189. })
  51190. }
  51191. )) : (e._vrDisplay = void 0,
  51192. e._vrSupported = !1,
  51193. t({
  51194. vrDisplay: e._vrDisplay,
  51195. vrSupported: e._vrSupported
  51196. }))
  51197. }
  51198. ))
  51199. }
  51200. ,
  51201. vr.prototype.enableVR = function(e) {
  51202. var t = this;
  51203. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  51204. this.onVRRequestPresentStart.notifyObservers(this);
  51205. var i = {
  51206. highRefreshRate: !!this.vrPresentationAttributes && this.vrPresentationAttributes.highRefreshRate,
  51207. foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1,
  51208. multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && e.useMultiview
  51209. };
  51210. this._vrDisplay.requestPresent([V({
  51211. source: this.getRenderingCanvas(),
  51212. attributes: i
  51213. }, i)]).then((function() {
  51214. t.onVRRequestPresentComplete.notifyObservers(!0),
  51215. t._onVRFullScreenTriggered()
  51216. }
  51217. )).catch((function() {
  51218. t.onVRRequestPresentComplete.notifyObservers(!1)
  51219. }
  51220. ))
  51221. }
  51222. }
  51223. ,
  51224. vr.prototype._onVRFullScreenTriggered = function() {
  51225. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  51226. this._oldSize = new je(this.getRenderWidth(),this.getRenderHeight()),
  51227. this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
  51228. var e = this._vrDisplay.getEyeParameters("left");
  51229. this.setHardwareScalingLevel(1),
  51230. this.setSize(2 * e.renderWidth, e.renderHeight)
  51231. } else
  51232. this.setHardwareScalingLevel(this._oldHardwareScaleFactor),
  51233. this.setSize(this._oldSize.width, this._oldSize.height)
  51234. }
  51235. ,
  51236. vr.prototype.disableVR = function() {
  51237. var e = this;
  51238. this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then((function() {
  51239. return e._onVRFullScreenTriggered()
  51240. }
  51241. )).catch((function() {
  51242. return e._onVRFullScreenTriggered()
  51243. }
  51244. )),
  51245. nt() && (window.removeEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted),
  51246. window.removeEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted),
  51247. this._onVrDisplayConnect && (window.removeEventListener("vrdisplayconnect", this._onVrDisplayConnect),
  51248. this._onVrDisplayDisconnect && window.removeEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
  51249. this._onVrDisplayPresentChange && window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
  51250. this._onVrDisplayConnect = null,
  51251. this._onVrDisplayDisconnect = null))
  51252. }
  51253. ,
  51254. vr.prototype._connectVREvents = function(e, t) {
  51255. var i = this;
  51256. if (this._onVRDisplayPointerRestricted = function() {
  51257. e && e.requestPointerLock()
  51258. }
  51259. ,
  51260. this._onVRDisplayPointerUnrestricted = function() {
  51261. if (t)
  51262. t.exitPointerLock && t.exitPointerLock();
  51263. else {
  51264. var e = i.getHostWindow();
  51265. e.document && e.document.exitPointerLock && e.document.exitPointerLock()
  51266. }
  51267. }
  51268. ,
  51269. nt()) {
  51270. var n = this.getHostWindow();
  51271. n.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1),
  51272. n.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1)
  51273. }
  51274. }
  51275. ,
  51276. vr.prototype._submitVRFrame = function() {
  51277. if (this._vrDisplay && this._vrDisplay.isPresenting)
  51278. try {
  51279. this._vrDisplay.submitFrame()
  51280. } catch (e) {
  51281. gi.Warn("webVR submitFrame has had an unexpected failure: " + e)
  51282. }
  51283. }
  51284. ,
  51285. vr.prototype.isVRPresenting = function() {
  51286. return this._vrDisplay && this._vrDisplay.isPresenting
  51287. }
  51288. ,
  51289. vr.prototype._requestVRFrame = function() {
  51290. this._frameHandler = vr.QueueNewFrame(this._boundRenderFunction, this._vrDisplay)
  51291. }
  51292. ,
  51293. Xe.AddNodeConstructor("WebVRFreeCamera", (function(e, t) {
  51294. return function() {
  51295. return new fs(e,x.Zero(),t)
  51296. }
  51297. }
  51298. )),
  51299. Xe.AddNodeConstructor("WebVRGamepadCamera", (function(e, t) {
  51300. return function() {
  51301. return new fs(e,x.Zero(),t)
  51302. }
  51303. }
  51304. ));
  51305. var fs = function(e) {
  51306. function t(t, i, n, r) {
  51307. void 0 === r && (r = {});
  51308. var o = e.call(this, t, i, n) || this;
  51309. o._webVROptions = r,
  51310. o._vrDevice = null,
  51311. o.rawPose = null,
  51312. o._specsVersion = "1.1",
  51313. o._attached = !1,
  51314. o._descendants = [],
  51315. o._deviceRoomPosition = x.Zero(),
  51316. o._deviceRoomRotationQuaternion = C.Identity(),
  51317. o._standingMatrix = null,
  51318. o.devicePosition = x.Zero(),
  51319. o.deviceRotationQuaternion = C.Identity(),
  51320. o.deviceScaleFactor = 1,
  51321. o._deviceToWorld = P.Identity(),
  51322. o._worldToDevice = P.Identity(),
  51323. o.controllers = [],
  51324. o.onControllersAttachedObservable = new h,
  51325. o.onControllerMeshLoadedObservable = new h,
  51326. o.onPoseUpdatedFromDeviceObservable = new h,
  51327. o._poseSet = !1,
  51328. o.rigParenting = !0,
  51329. o._defaultHeight = void 0,
  51330. o._setRigMode = ps.bind(null, o),
  51331. o._detachIfAttached = function() {
  51332. var e = o.getEngine().getVRDevice();
  51333. e && !e.isPresenting && o.detachControl()
  51334. }
  51335. ,
  51336. o._workingVector = x.Zero(),
  51337. o._oneVector = x.One(),
  51338. o._workingMatrix = P.Identity(),
  51339. o._tmpMatrix = new P,
  51340. o._cache.position = x.Zero(),
  51341. r.defaultHeight && (o._defaultHeight = r.defaultHeight,
  51342. o.position.y = o._defaultHeight),
  51343. o.minZ = .1,
  51344. 5 === arguments.length && (o._webVROptions = arguments[4]),
  51345. null == o._webVROptions.trackPosition && (o._webVROptions.trackPosition = !0),
  51346. null == o._webVROptions.controllerMeshes && (o._webVROptions.controllerMeshes = !0),
  51347. null == o._webVROptions.defaultLightingOnControllers && (o._webVROptions.defaultLightingOnControllers = !0),
  51348. o.rotationQuaternion = new C,
  51349. o._webVROptions && o._webVROptions.positionScale && (o.deviceScaleFactor = o._webVROptions.positionScale);
  51350. var a = o.getEngine();
  51351. return o._onVREnabled = function(e) {
  51352. e && o.initControllers()
  51353. }
  51354. ,
  51355. a.onVRRequestPresentComplete.add(o._onVREnabled),
  51356. a.initWebVR().add((function(e) {
  51357. e.vrDisplay && o._vrDevice !== e.vrDisplay && (o._vrDevice = e.vrDisplay,
  51358. o.setCameraRigMode(Rr.RIG_MODE_WEBVR, {
  51359. parentCamera: o,
  51360. vrDisplay: o._vrDevice,
  51361. frameData: o._frameData,
  51362. specs: o._specsVersion
  51363. }),
  51364. o._attached && o.getEngine().enableVR(o._webVROptions))
  51365. }
  51366. )),
  51367. "undefined" != typeof VRFrameData && (o._frameData = new VRFrameData),
  51368. r.useMultiview && (o.getScene().getEngine().getCaps().multiview ? (o._useMultiviewToSingleView = !0,
  51369. o._rigPostProcess = new ss("VRMultiviewToSingleview",o,1)) : (K.Warn("Multiview is not supported, falling back to standard rendering"),
  51370. o._useMultiviewToSingleView = !1)),
  51371. o.getScene().onBeforeCameraRenderObservable.add((function(e) {
  51372. e.parent === o && o.rigParenting && (o._descendants = o.getDescendants(!0, (function(e) {
  51373. var t = o.controllers.some((function(t) {
  51374. return t._mesh === e
  51375. }
  51376. ))
  51377. , i = -1 !== o._rigCameras.indexOf(e);
  51378. return !t && !i
  51379. }
  51380. )),
  51381. o._descendants.forEach((function(t) {
  51382. t.parent = e
  51383. }
  51384. )))
  51385. }
  51386. )),
  51387. o.getScene().onAfterCameraRenderObservable.add((function(e) {
  51388. e.parent === o && o.rigParenting && o._descendants.forEach((function(e) {
  51389. e.parent = o
  51390. }
  51391. ))
  51392. }
  51393. )),
  51394. o
  51395. }
  51396. return U(t, e),
  51397. t.prototype.deviceDistanceToRoomGround = function() {
  51398. return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector),
  51399. this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0
  51400. }
  51401. ,
  51402. t.prototype.useStandingMatrix = function(e) {
  51403. var t = this;
  51404. void 0 === e && (e = function(e) {}
  51405. ),
  51406. this.getEngine().initWebVRAsync().then((function(i) {
  51407. i.vrDisplay && i.vrDisplay.stageParameters && i.vrDisplay.stageParameters.sittingToStandingTransform && t._webVROptions.trackPosition ? (t._standingMatrix = new P,
  51408. P.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, t._standingMatrix),
  51409. t.getScene().useRightHandedSystem || t._standingMatrix && t._standingMatrix.toggleModelMatrixHandInPlace(),
  51410. e(!0)) : e(!1)
  51411. }
  51412. ))
  51413. }
  51414. ,
  51415. t.prototype.useStandingMatrixAsync = function() {
  51416. var e = this;
  51417. return new Promise((function(t) {
  51418. e.useStandingMatrix((function(e) {
  51419. t(e)
  51420. }
  51421. ))
  51422. }
  51423. ))
  51424. }
  51425. ,
  51426. t.prototype.dispose = function() {
  51427. this._detachIfAttached(),
  51428. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),
  51429. this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),
  51430. e.prototype.dispose.call(this)
  51431. }
  51432. ,
  51433. t.prototype.getControllerByName = function(e) {
  51434. for (var t = 0, i = this.controllers; t < i.length; t++) {
  51435. var n = i[t];
  51436. if (n.hand === e)
  51437. return n
  51438. }
  51439. return null
  51440. }
  51441. ,
  51442. Object.defineProperty(t.prototype, "leftController", {
  51443. get: function() {
  51444. return this._leftController || (this._leftController = this.getControllerByName("left")),
  51445. this._leftController
  51446. },
  51447. enumerable: !1,
  51448. configurable: !0
  51449. }),
  51450. Object.defineProperty(t.prototype, "rightController", {
  51451. get: function() {
  51452. return this._rightController || (this._rightController = this.getControllerByName("right")),
  51453. this._rightController
  51454. },
  51455. enumerable: !1,
  51456. configurable: !0
  51457. }),
  51458. t.prototype.getForwardRay = function(t) {
  51459. return void 0 === t && (t = 100),
  51460. this.leftCamera ? e.prototype.getForwardRay.call(this, t, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : e.prototype.getForwardRay.call(this, t)
  51461. }
  51462. ,
  51463. t.prototype._checkInputs = function() {
  51464. this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData),
  51465. this.updateFromDevice(this._frameData.pose)),
  51466. e.prototype._checkInputs.call(this)
  51467. }
  51468. ,
  51469. t.prototype.updateFromDevice = function(e) {
  51470. e && e.orientation && 4 === e.orientation.length && (this.rawPose = e,
  51471. this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0], e.orientation[1], -e.orientation[2], -e.orientation[3]),
  51472. this.getScene().useRightHandedSystem && (this._deviceRoomRotationQuaternion.z *= -1,
  51473. this._deviceRoomRotationQuaternion.w *= -1),
  51474. this._webVROptions.trackPosition && this.rawPose.position && (this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]),
  51475. this.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1)),
  51476. this._poseSet = !0)
  51477. }
  51478. ,
  51479. t.prototype.attachControl = function(t) {
  51480. t = gi.BackCompatCameraNoPreventDefault(arguments),
  51481. e.prototype.attachControl.call(this, t),
  51482. this._attached = !0,
  51483. t = !Rr.ForceAttachControlToAlwaysPreventDefault && t,
  51484. this._vrDevice && this.getEngine().enableVR(this._webVROptions);
  51485. var i = this._scene.getEngine().getHostWindow();
  51486. i && i.addEventListener("vrdisplaypresentchange", this._detachIfAttached)
  51487. }
  51488. ,
  51489. t.prototype.detachControl = function() {
  51490. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
  51491. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
  51492. e.prototype.detachControl.call(this),
  51493. this._attached = !1,
  51494. this.getEngine().disableVR(),
  51495. window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached)
  51496. }
  51497. ,
  51498. t.prototype.getClassName = function() {
  51499. return "WebVRFreeCamera"
  51500. }
  51501. ,
  51502. t.prototype.resetToCurrentRotation = function() {
  51503. this._vrDevice.resetPose()
  51504. }
  51505. ,
  51506. t.prototype._updateRigCameras = function() {
  51507. var e = this._rigCameras[0]
  51508. , t = this._rigCameras[1];
  51509. e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
  51510. t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
  51511. e.position.copyFrom(this._deviceRoomPosition),
  51512. t.position.copyFrom(this._deviceRoomPosition)
  51513. }
  51514. ,
  51515. t.prototype._correctPositionIfNotTrackPosition = function(e, t) {
  51516. void 0 === t && (t = !1),
  51517. this.rawPose && this.rawPose.position && !this._webVROptions.trackPosition && (P.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix),
  51518. t || this._tmpMatrix.invert(),
  51519. this._tmpMatrix.multiplyToRef(e, e))
  51520. }
  51521. ,
  51522. t.prototype._updateCache = function(t) {
  51523. var i = this;
  51524. this.rotationQuaternion.equals(this._cache.rotationQuaternion) && this.position.equals(this._cache.position) || (this._updateCacheCalled || (this._updateCacheCalled = !0,
  51525. this.update()),
  51526. this.rotationQuaternion.toRotationMatrix(this._workingMatrix),
  51527. x.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector),
  51528. this.devicePosition.subtractToRef(this._workingVector, this._workingVector),
  51529. P.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld),
  51530. this._deviceToWorld.getTranslationToRef(this._workingVector),
  51531. this._workingVector.addInPlace(this.position),
  51532. this._workingVector.subtractInPlace(this._cache.position),
  51533. this._deviceToWorld.setTranslation(this._workingVector),
  51534. this._deviceToWorld.invertToRef(this._worldToDevice),
  51535. this.controllers.forEach((function(e) {
  51536. e._deviceToWorld.copyFrom(i._deviceToWorld),
  51537. i._correctPositionIfNotTrackPosition(e._deviceToWorld),
  51538. e.update()
  51539. }
  51540. ))),
  51541. t || e.prototype._updateCache.call(this),
  51542. this._updateCacheCalled = !1
  51543. }
  51544. ,
  51545. t.prototype._computeDevicePosition = function() {
  51546. x.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition)
  51547. }
  51548. ,
  51549. t.prototype.update = function() {
  51550. this._computeDevicePosition(),
  51551. P.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix),
  51552. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix),
  51553. C.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
  51554. this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),
  51555. e.prototype.update.call(this)
  51556. }
  51557. ,
  51558. t.prototype._getViewMatrix = function() {
  51559. return P.Identity()
  51560. }
  51561. ,
  51562. t.prototype._getWebVRViewMatrix = function() {
  51563. var e = this._cameraRigParams.parentCamera;
  51564. e._updateCache();
  51565. var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix;
  51566. return P.FromArrayToRef(t, 0, this._webvrViewMatrix),
  51567. this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(),
  51568. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),
  51569. x.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
  51570. this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
  51571. 1 !== e.deviceScaleFactor && (this._webvrViewMatrix.invert(),
  51572. e.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, e.deviceScaleFactor),
  51573. this._webvrViewMatrix.multiplyAtIndex(13, e.deviceScaleFactor),
  51574. this._webvrViewMatrix.multiplyAtIndex(14, e.deviceScaleFactor)),
  51575. this._webvrViewMatrix.invert()),
  51576. e._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0),
  51577. e._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix),
  51578. this._workingMatrix = this._workingMatrix || P.Identity(),
  51579. this._webvrViewMatrix.invertToRef(this._workingMatrix),
  51580. this._workingMatrix.multiplyToRef(e.getWorldMatrix(), this._workingMatrix),
  51581. this._workingMatrix.getTranslationToRef(this._globalPosition),
  51582. this._markSyncedWithParent(),
  51583. this._webvrViewMatrix
  51584. }
  51585. ,
  51586. t.prototype._getWebVRProjectionMatrix = function() {
  51587. var e = this.parent;
  51588. e._vrDevice.depthNear = e.minZ,
  51589. e._vrDevice.depthFar = e.maxZ;
  51590. var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix;
  51591. return P.FromArrayToRef(t, 0, this._projectionMatrix),
  51592. this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(),
  51593. this._projectionMatrix
  51594. }
  51595. ,
  51596. t.prototype.initControllers = function() {
  51597. var e = this;
  51598. this.controllers = [];
  51599. var t = this.getScene().gamepadManager;
  51600. this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
  51601. if (t.type === zo.POSE_ENABLED) {
  51602. var i = t;
  51603. i.defaultModel && i.defaultModel.setEnabled(!1),
  51604. "right" === i.hand && (e._rightController = null),
  51605. "left" === i.hand && (e._leftController = null);
  51606. var n = e.controllers.indexOf(i);
  51607. -1 !== n && e.controllers.splice(n, 1)
  51608. }
  51609. }
  51610. )),
  51611. this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
  51612. if (t.type === zo.POSE_ENABLED) {
  51613. var i = t;
  51614. if (e._webVROptions.trackPosition || (i._disableTrackPosition(new x("left" == i.hand ? -.15 : .15,-.5,.25)),
  51615. e._updateCacheWhenTrackingDisabledObserver || (e._updateCacheWhenTrackingDisabledObserver = e._scene.onBeforeRenderObservable.add((function() {
  51616. e._updateCache()
  51617. }
  51618. )))),
  51619. i.deviceScaleFactor = e.deviceScaleFactor,
  51620. i._deviceToWorld.copyFrom(e._deviceToWorld),
  51621. e._correctPositionIfNotTrackPosition(i._deviceToWorld),
  51622. e._webVROptions.controllerMeshes && (i.defaultModel ? i.defaultModel.setEnabled(!0) : i.initControllerMesh(e.getScene(), (function(t) {
  51623. if (t.scaling.scaleInPlace(e.deviceScaleFactor),
  51624. e.onControllerMeshLoadedObservable.notifyObservers(i),
  51625. e._webVROptions.defaultLightingOnControllers) {
  51626. e._lightOnControllers || (e._lightOnControllers = new ds("vrControllersLight",new x(0,1,0),e.getScene()));
  51627. var n = function(e, t) {
  51628. var i = e.getChildren();
  51629. i && 0 !== i.length && i.forEach((function(e) {
  51630. t.includedOnlyMeshes.push(e),
  51631. n(e, t)
  51632. }
  51633. ))
  51634. };
  51635. e._lightOnControllers.includedOnlyMeshes.push(t),
  51636. n(t, e._lightOnControllers)
  51637. }
  51638. }
  51639. ))),
  51640. i.attachToPoseControlledCamera(e),
  51641. -1 === e.controllers.indexOf(i)) {
  51642. e.controllers.push(i);
  51643. for (var n = !1, r = 0; r < e.controllers.length; r++)
  51644. e.controllers[r].controllerType === ba.VIVE && (n ? e.controllers[r].hand = "right" : (n = !0,
  51645. e.controllers[r].hand = "left"));
  51646. e.controllers.length >= 2 && e.onControllersAttachedObservable.notifyObservers(e.controllers)
  51647. }
  51648. }
  51649. }
  51650. ))
  51651. }
  51652. ,
  51653. t
  51654. }(pa)
  51655. , _s = function(e) {
  51656. function t(t) {
  51657. var i = e.call(this, t) || this;
  51658. return i.onTriggerStateChangedObservable = new h,
  51659. i.onMainButtonStateChangedObservable = new h,
  51660. i.onSecondaryButtonStateChangedObservable = new h,
  51661. i.onPadStateChangedObservable = new h,
  51662. i.onPadValuesChangedObservable = new h,
  51663. i.pad = {
  51664. x: 0,
  51665. y: 0
  51666. },
  51667. i._changes = {
  51668. pressChanged: !1,
  51669. touchChanged: !1,
  51670. valueChanged: !1,
  51671. changed: !1
  51672. },
  51673. i._buttons = new Array(t.buttons.length),
  51674. i.hand = t.hand,
  51675. i
  51676. }
  51677. return U(t, e),
  51678. t.prototype.onButtonStateChange = function(e) {
  51679. this._onButtonStateChange = e
  51680. }
  51681. ,
  51682. Object.defineProperty(t.prototype, "defaultModel", {
  51683. get: function() {
  51684. return this._defaultModel
  51685. },
  51686. enumerable: !1,
  51687. configurable: !0
  51688. }),
  51689. t.prototype.update = function() {
  51690. e.prototype.update.call(this);
  51691. for (var t = 0; t < this._buttons.length; t++)
  51692. this._setButtonValue(this.browserGamepad.buttons[t], this._buttons[t], t);
  51693. this.leftStick.x === this.pad.x && this.leftStick.y === this.pad.y || (this.pad.x = this.leftStick.x,
  51694. this.pad.y = this.leftStick.y,
  51695. this.onPadValuesChangedObservable.notifyObservers(this.pad))
  51696. }
  51697. ,
  51698. t.prototype._setButtonValue = function(e, t, i) {
  51699. e || (e = {
  51700. pressed: !1,
  51701. touched: !1,
  51702. value: 0
  51703. }),
  51704. t ? (this._checkChanges(e, t),
  51705. this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, i, e),
  51706. this._handleButtonChange(i, e, this._changes)),
  51707. this._buttons[i].pressed = e.pressed,
  51708. this._buttons[i].touched = e.touched,
  51709. this._buttons[i].value = e.value < 1e-8 ? 0 : e.value) : this._buttons[i] = {
  51710. pressed: e.pressed,
  51711. touched: e.touched,
  51712. value: e.value
  51713. }
  51714. }
  51715. ,
  51716. t.prototype._checkChanges = function(e, t) {
  51717. return this._changes.pressChanged = e.pressed !== t.pressed,
  51718. this._changes.touchChanged = e.touched !== t.touched,
  51719. this._changes.valueChanged = e.value !== t.value,
  51720. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged,
  51721. this._changes
  51722. }
  51723. ,
  51724. t.prototype.dispose = function() {
  51725. e.prototype.dispose.call(this),
  51726. this._defaultModel = null,
  51727. this.onTriggerStateChangedObservable.clear(),
  51728. this.onMainButtonStateChangedObservable.clear(),
  51729. this.onSecondaryButtonStateChangedObservable.clear(),
  51730. this.onPadStateChangedObservable.clear(),
  51731. this.onPadValuesChangedObservable.clear()
  51732. }
  51733. ,
  51734. t
  51735. }(Ra)
  51736. , ms = function() {
  51737. function e() {
  51738. this.previousWorldMatrices = {},
  51739. this.previousBones = {}
  51740. }
  51741. return e.AddUniforms = function(e) {
  51742. e.push("previousWorld", "previousViewProjection", "mPreviousBones")
  51743. }
  51744. ,
  51745. e.AddSamplers = function(e) {}
  51746. ,
  51747. e.prototype.bindForSubMesh = function(e, t, i, n, r) {
  51748. if (t.prePassRenderer && t.prePassRenderer.enabled && t.prePassRenderer.currentRTisSceneRT && -1 !== t.prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE)) {
  51749. this.previousWorldMatrices[i.uniqueId] || (this.previousWorldMatrices[i.uniqueId] = n.clone()),
  51750. this.previousViewProjection || (this.previousViewProjection = t.getTransformMatrix().clone(),
  51751. this.currentViewProjection = t.getTransformMatrix().clone());
  51752. var o = t.getEngine();
  51753. this.currentViewProjection.updateFlag !== t.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = o.frameId,
  51754. this.previousViewProjection.copyFrom(this.currentViewProjection),
  51755. this.currentViewProjection.copyFrom(t.getTransformMatrix())) : this._lastUpdateFrameId !== o.frameId && (this._lastUpdateFrameId = o.frameId,
  51756. this.previousViewProjection.copyFrom(this.currentViewProjection)),
  51757. e.setMatrix("previousWorld", this.previousWorldMatrices[i.uniqueId]),
  51758. e.setMatrix("previousViewProjection", this.previousViewProjection),
  51759. this.previousWorldMatrices[i.uniqueId] = n.clone()
  51760. }
  51761. }
  51762. ,
  51763. e
  51764. }()
  51765. , gs = function(e) {
  51766. function t(t, i, n) {
  51767. void 0 === n && (n = !0);
  51768. var r = e.call(this, t, i) || this;
  51769. return r._normalMatrix = new P,
  51770. r._storeEffectOnSubMeshes = n,
  51771. r
  51772. }
  51773. return U(t, e),
  51774. t.prototype.getEffect = function() {
  51775. return this._storeEffectOnSubMeshes ? this._activeEffect : e.prototype.getEffect.call(this)
  51776. }
  51777. ,
  51778. t.prototype.isReady = function(e, t) {
  51779. return !!e && (!this._storeEffectOnSubMeshes || !e.subMeshes || 0 === e.subMeshes.length || this.isReadyForSubMesh(e, e.subMeshes[0], t))
  51780. }
  51781. ,
  51782. t.prototype._isReadyForSubMesh = function(e) {
  51783. var t = e.materialDefines;
  51784. return !(this.checkReadyOnEveryCall || !e.effect || !t || t._renderId !== this.getScene().getRenderId())
  51785. }
  51786. ,
  51787. t.prototype.bindOnlyWorldMatrix = function(e) {
  51788. this._activeEffect.setMatrix("world", e)
  51789. }
  51790. ,
  51791. t.prototype.bindOnlyNormalMatrix = function(e) {
  51792. this._activeEffect.setMatrix("normalMatrix", e)
  51793. }
  51794. ,
  51795. t.prototype.bind = function(e, t) {
  51796. t && this.bindForSubMesh(e, t, t.subMeshes[0])
  51797. }
  51798. ,
  51799. t.prototype._afterBind = function(t, i) {
  51800. void 0 === i && (i = null),
  51801. e.prototype._afterBind.call(this, t, i),
  51802. this.getScene()._cachedEffect = i
  51803. }
  51804. ,
  51805. t.prototype._mustRebind = function(e, t, i) {
  51806. return void 0 === i && (i = 1),
  51807. e.isCachedMaterialInvalid(this, t, i)
  51808. }
  51809. ,
  51810. t
  51811. }(Or)
  51812. , vs = function() {
  51813. function e() {}
  51814. return Object.defineProperty(e, "DiffuseTextureEnabled", {
  51815. get: function() {
  51816. return this._DiffuseTextureEnabled
  51817. },
  51818. set: function(e) {
  51819. this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
  51820. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51821. },
  51822. enumerable: !1,
  51823. configurable: !0
  51824. }),
  51825. Object.defineProperty(e, "DetailTextureEnabled", {
  51826. get: function() {
  51827. return this._DetailTextureEnabled
  51828. },
  51829. set: function(e) {
  51830. this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e,
  51831. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51832. },
  51833. enumerable: !1,
  51834. configurable: !0
  51835. }),
  51836. Object.defineProperty(e, "AmbientTextureEnabled", {
  51837. get: function() {
  51838. return this._AmbientTextureEnabled
  51839. },
  51840. set: function(e) {
  51841. this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e,
  51842. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51843. },
  51844. enumerable: !1,
  51845. configurable: !0
  51846. }),
  51847. Object.defineProperty(e, "OpacityTextureEnabled", {
  51848. get: function() {
  51849. return this._OpacityTextureEnabled
  51850. },
  51851. set: function(e) {
  51852. this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e,
  51853. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51854. },
  51855. enumerable: !1,
  51856. configurable: !0
  51857. }),
  51858. Object.defineProperty(e, "ReflectionTextureEnabled", {
  51859. get: function() {
  51860. return this._ReflectionTextureEnabled
  51861. },
  51862. set: function(e) {
  51863. this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e,
  51864. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51865. },
  51866. enumerable: !1,
  51867. configurable: !0
  51868. }),
  51869. Object.defineProperty(e, "EmissiveTextureEnabled", {
  51870. get: function() {
  51871. return this._EmissiveTextureEnabled
  51872. },
  51873. set: function(e) {
  51874. this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e,
  51875. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51876. },
  51877. enumerable: !1,
  51878. configurable: !0
  51879. }),
  51880. Object.defineProperty(e, "SpecularTextureEnabled", {
  51881. get: function() {
  51882. return this._SpecularTextureEnabled
  51883. },
  51884. set: function(e) {
  51885. this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e,
  51886. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51887. },
  51888. enumerable: !1,
  51889. configurable: !0
  51890. }),
  51891. Object.defineProperty(e, "BumpTextureEnabled", {
  51892. get: function() {
  51893. return this._BumpTextureEnabled
  51894. },
  51895. set: function(e) {
  51896. this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e,
  51897. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51898. },
  51899. enumerable: !1,
  51900. configurable: !0
  51901. }),
  51902. Object.defineProperty(e, "LightmapTextureEnabled", {
  51903. get: function() {
  51904. return this._LightmapTextureEnabled
  51905. },
  51906. set: function(e) {
  51907. this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e,
  51908. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51909. },
  51910. enumerable: !1,
  51911. configurable: !0
  51912. }),
  51913. Object.defineProperty(e, "RefractionTextureEnabled", {
  51914. get: function() {
  51915. return this._RefractionTextureEnabled
  51916. },
  51917. set: function(e) {
  51918. this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e,
  51919. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51920. },
  51921. enumerable: !1,
  51922. configurable: !0
  51923. }),
  51924. Object.defineProperty(e, "ColorGradingTextureEnabled", {
  51925. get: function() {
  51926. return this._ColorGradingTextureEnabled
  51927. },
  51928. set: function(e) {
  51929. this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e,
  51930. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51931. },
  51932. enumerable: !1,
  51933. configurable: !0
  51934. }),
  51935. Object.defineProperty(e, "FresnelEnabled", {
  51936. get: function() {
  51937. return this._FresnelEnabled
  51938. },
  51939. set: function(e) {
  51940. this._FresnelEnabled !== e && (this._FresnelEnabled = e,
  51941. vr.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag))
  51942. },
  51943. enumerable: !1,
  51944. configurable: !0
  51945. }),
  51946. Object.defineProperty(e, "ClearCoatTextureEnabled", {
  51947. get: function() {
  51948. return this._ClearCoatTextureEnabled
  51949. },
  51950. set: function(e) {
  51951. this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e,
  51952. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51953. },
  51954. enumerable: !1,
  51955. configurable: !0
  51956. }),
  51957. Object.defineProperty(e, "ClearCoatBumpTextureEnabled", {
  51958. get: function() {
  51959. return this._ClearCoatBumpTextureEnabled
  51960. },
  51961. set: function(e) {
  51962. this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e,
  51963. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51964. },
  51965. enumerable: !1,
  51966. configurable: !0
  51967. }),
  51968. Object.defineProperty(e, "ClearCoatTintTextureEnabled", {
  51969. get: function() {
  51970. return this._ClearCoatTintTextureEnabled
  51971. },
  51972. set: function(e) {
  51973. this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e,
  51974. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51975. },
  51976. enumerable: !1,
  51977. configurable: !0
  51978. }),
  51979. Object.defineProperty(e, "SheenTextureEnabled", {
  51980. get: function() {
  51981. return this._SheenTextureEnabled
  51982. },
  51983. set: function(e) {
  51984. this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e,
  51985. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51986. },
  51987. enumerable: !1,
  51988. configurable: !0
  51989. }),
  51990. Object.defineProperty(e, "AnisotropicTextureEnabled", {
  51991. get: function() {
  51992. return this._AnisotropicTextureEnabled
  51993. },
  51994. set: function(e) {
  51995. this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e,
  51996. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  51997. },
  51998. enumerable: !1,
  51999. configurable: !0
  52000. }),
  52001. Object.defineProperty(e, "ThicknessTextureEnabled", {
  52002. get: function() {
  52003. return this._ThicknessTextureEnabled
  52004. },
  52005. set: function(e) {
  52006. this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e,
  52007. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  52008. },
  52009. enumerable: !1,
  52010. configurable: !0
  52011. }),
  52012. Object.defineProperty(e, "RefractionIntensityTextureEnabled", {
  52013. get: function() {
  52014. return this._ThicknessTextureEnabled
  52015. },
  52016. set: function(e) {
  52017. this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e,
  52018. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  52019. },
  52020. enumerable: !1,
  52021. configurable: !0
  52022. }),
  52023. Object.defineProperty(e, "TranslucencyIntensityTextureEnabled", {
  52024. get: function() {
  52025. return this._ThicknessTextureEnabled
  52026. },
  52027. set: function(e) {
  52028. this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e,
  52029. vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
  52030. },
  52031. enumerable: !1,
  52032. configurable: !0
  52033. }),
  52034. e._DiffuseTextureEnabled = !0,
  52035. e._DetailTextureEnabled = !0,
  52036. e._AmbientTextureEnabled = !0,
  52037. e._OpacityTextureEnabled = !0,
  52038. e._ReflectionTextureEnabled = !0,
  52039. e._EmissiveTextureEnabled = !0,
  52040. e._SpecularTextureEnabled = !0,
  52041. e._BumpTextureEnabled = !0,
  52042. e._LightmapTextureEnabled = !0,
  52043. e._RefractionTextureEnabled = !0,
  52044. e._ColorGradingTextureEnabled = !0,
  52045. e._FresnelEnabled = !0,
  52046. e._ClearCoatTextureEnabled = !0,
  52047. e._ClearCoatBumpTextureEnabled = !0,
  52048. e._ClearCoatTintTextureEnabled = !0,
  52049. e._SheenTextureEnabled = !0,
  52050. e._AnisotropicTextureEnabled = !0,
  52051. e._ThicknessTextureEnabled = !0,
  52052. e._RefractionIntensityTextureEnabled = !0,
  52053. e._TranslucencyIntensityTextureEnabled = !0,
  52054. e
  52055. }();
  52056. Pt.IncludesShadersStore.defaultFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform vec3 vAmbientColor;\nuniform float visibility;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
  52057. Pt.IncludesShadersStore.sceneUboDeclaration = "layout(std140,column_major) uniform;\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;\nmat4 projection;\nvec4 vEyePosition;\n};\n";
  52058. Pt.IncludesShadersStore.meshUboDeclaration = "uniform mat4 world;\nuniform float visibility;\n#define WORLD_UBO\n";
  52059. Pt.IncludesShadersStore.defaultUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nfloat alphaCutOff;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec3 vRefractionPosition;\nvec3 vRefractionSize;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nvec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
  52060. Pt.IncludesShadersStore.prePassDeclaration = "#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;\n#ifdef PREPASS_DEPTH\nvarying highp vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nvarying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;\n#endif\n#endif\n";
  52061. Pt.IncludesShadersStore.oitDeclaration = "#ifdef ORDER_INDEPENDENT_TRANSPARENCY\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out vec2 depth; \nlayout(location=1) out vec4 frontColor;\nlayout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;\nuniform sampler2D oitDepthSampler;\nuniform sampler2D oitFrontColorSampler;\n#endif\n";
  52062. Pt.IncludesShadersStore.mainUVVaryingDeclaration = "#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n";
  52063. Pt.IncludesShadersStore.helperFunctions = "const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D =max(rgbdMaxRange/maxRGB,1.);\nD =clamp(floor(D)/255.0,0.,1.);\nvec3 rgb=color.rgb*D;\nrgb=toGammaSpace(rgb);\nreturn vec4(clamp(rgb,0.,1.),D); \n}\nvec3 fromRGBD(vec4 rgbd) {\nrgbd.rgb=toLinearSpace(rgbd.rgb);\nreturn rgbd.rgb/rgbd.a;\n}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\nvec3 intersectPositionWS=vertexPos+origVec*distance;\nreturn intersectPositionWS-cubePos;\n}\n";
  52064. Pt.IncludesShadersStore.lightFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif\n";
  52065. Pt.IncludesShadersStore.lightUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X}; \n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";
  52066. Pt.IncludesShadersStore.lightsFragmentFunctions = "struct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w==0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";
  52067. Pt.IncludesShadersStore.shadowsFragmentFunctions = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\n#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;\n}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\n#define inline\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\n#define inline\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\n#if defined(WEBGL2) || defined(WEBGPU)\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nvec3 uvLayer=vec3(uv.x,uv.y,layer);\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\n#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture2D(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\nfloat AAOffset=shadowMapSizeInverse*10.;\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\nvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec4 offset=vec4(poissonSamplers[i],0.);\noffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\nshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\nshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture2D(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\nfloat AAOffset=shadowMapSizeInverse*10.;\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n}\n#define inline\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#define inline\nfloat computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#endif\n#endif\n";
  52068. Pt.IncludesShadersStore.samplerFragmentDeclaration = "#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV==1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV==2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV==3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV==4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV==5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV==6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\nuniform sampler2D _SAMPLERNAME_Sampler;\n#endif\n";
  52069. Pt.IncludesShadersStore.fresnelFunction = "#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif\n";
  52070. Pt.IncludesShadersStore.reflectionFunction = "vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0); \n}\nvec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(1.0-s,t,0); \n}\nvec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nr=vec3(reflectionMatrix*vec4(r,0));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n}\nvec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr=vec3(reflectionMatrix*vec4(r,0));\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n}\nvec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=worldPos.xyz-eyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n}\nvec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*(view*worldPos));\n}\nvec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*vec4(positionW,1.));\n}\n#ifdef REFLECTION\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nreturn computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nreturn computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nreturn computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_CUBIC\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nreturn computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);\n#else\nreturn computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn computeProjectionCoords(worldPos,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn computeSkyBoxCoords(vPositionUVW,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}\n#endif\n";
  52071. Pt.IncludesShadersStore.imageProcessingDeclaration = "#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif\n";
  52072. Pt.IncludesShadersStore.imageProcessingFunctions = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n/** \n* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.\n* sampler3dSetting.x=textureOffset (0.5/textureSize).\n* sampler3dSetting.y=textureSize.\n*/\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108, 1.10813,-0.07276),\nvec3(-0.07367,-0.00605, 1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  52073. Pt.IncludesShadersStore.bumpFragmentMainFunctions = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\n{\n#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\n{\nreturn perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);\n}\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n";
  52074. Pt.IncludesShadersStore.bumpFragmentFunctions = "#if defined(BUMP)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)\n#endif\n#if defined(DETAIL)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n";
  52075. Pt.IncludesShadersStore.clipPlaneFragmentDeclaration = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif\n";
  52076. Pt.IncludesShadersStore.logDepthDeclaration = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif\n";
  52077. Pt.IncludesShadersStore.fogFragmentDeclaration = "#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR==vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP==vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2==vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif\n";
  52078. Pt.IncludesShadersStore.oitFragment = "#ifdef ORDER_INDEPENDENT_TRANSPARENCY\nfloat fragDepth=gl_FragCoord.z; \n#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS\nuint halfFloat=packHalf2x16(vec2(fragDepth));\nvec2 full=unpackHalf2x16(halfFloat);\nfragDepth=full.x;\n#endif\nivec2 fragCoord=ivec2(gl_FragCoord.xy);\nvec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;\nvec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);\ndepth.rg=vec2(-MAX_DEPTH);\nfrontColor=lastFrontColor;\nbackColor=vec4(0.0);\n#ifdef USE_REVERSE_DEPTHBUFFER\nfloat furthestDepth=-lastDepth.x;\nfloat nearestDepth=lastDepth.y;\n#else\nfloat nearestDepth=-lastDepth.x;\nfloat furthestDepth=lastDepth.y;\n#endif\nfloat alphaMultiplier=1.0-lastFrontColor.a;\n#ifdef USE_REVERSE_DEPTHBUFFER\nif (fragDepth>nearestDepth || fragDepth<furthestDepth) {\n#else\nif (fragDepth<nearestDepth || fragDepth>furthestDepth) {\n#endif\nreturn;\n}\n#ifdef USE_REVERSE_DEPTHBUFFER\nif (fragDepth<nearestDepth && fragDepth>furthestDepth) {\n#else\nif (fragDepth>nearestDepth && fragDepth<furthestDepth) {\n#endif\ndepth.rg=vec2(-fragDepth,fragDepth);\nreturn;\n}\n#endif\n";
  52079. Pt.IncludesShadersStore.clipPlaneFragment = "#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif\n";
  52080. Pt.IncludesShadersStore.bumpFragment = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#elif defined(BUMP)\nfloat normalScale=vBumpInfos.y;\n#else\nfloat normalScale=1.0;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#elif defined(BUMP)\nvec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);\n#else\nvec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nvec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;\nmat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef DETAIL\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);\nvec2 detailNormalRG=detailColor.wy*2.0-1.0;\nfloat detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));\nvec3 detailNormal=vec3(detailNormalRG,detailNormalB);\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#elif !defined(DETAIL)\nnormalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);\n#else\nvec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;\n#if DETAIL_NORMALBLENDMETHOD==0 \ndetailNormal.xy*=vDetailInfos.z;\nvec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));\n#elif DETAIL_NORMALBLENDMETHOD==1 \ndetailNormal.xy*=vDetailInfos.z;\nbumpNormal+=vec3(0.0,0.0,1.0);\ndetailNormal*=vec3(-1.0,-1.0,1.0);\nvec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;\n#endif\nnormalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);\n#endif\n#elif defined(DETAIL)\ndetailNormal.xy*=vDetailInfos.z;\nnormalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\n#endif\n";
  52081. Pt.IncludesShadersStore.depthPrePass = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif\n";
  52082. Pt.IncludesShadersStore.lightFragment = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\n#ifdef HEMILIGHT{X}\npreInfo.roughness=sheenOut.sheenRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef CLEARCOAT\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) \n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;\n#else\ndiff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {\nindex{X}=i;\nbreak;\n}\n}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nshadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nshadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nfloat frustumLength=frustumLengths{X}[index{X}];\nfloat diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};\nif (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{\nindex{X}+=1;\nfloat nextShadow=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nnextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nnextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow=mix(nextShadow,shadow,diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(SHADOWCLOSEESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor.rgb*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\n#ifdef SHADOWCSMDEBUG{X}\ndiffuseBase+=info.diffuse*shadowDebug{X};\n#else \ndiffuseBase+=info.diffuse*shadow;\n#endif\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif\n";
  52083. Pt.IncludesShadersStore.logDepthFragment = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif\n";
  52084. Pt.IncludesShadersStore.fogFragment = "#ifdef FOG\nfloat fog=CalcFogFactor();\n#ifdef PBR\nfog=toLinearSpace(fog);\n#endif\ncolor.rgb=mix(vFogColor,color.rgb,fog);\n#endif\n";
  52085. Pt.ShadersStore.defaultPixelShader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\n#include<oitDeclaration>\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULARTERM)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)\n#endif\n#include<fresnelFunction>\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<oitFragment>\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec4 refractionColor=vec4(0.,0.,0.,1.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\n#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector);\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nvReflectionUVW.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;\ngl_FragData[0]=color; \n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {\nfrontColor.rgb+=color.rgb*color.a*alphaMultiplier;\nfrontColor.a=1.0-alphaMultiplier*(1.0-color.a);\n} else {\nbackColor+=color;\n}\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
  52086. Pt.IncludesShadersStore.defaultVertexDeclaration = "uniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n#endif\n#define ADDITIONAL_VERTEX_DECLARATION\n";
  52087. Pt.IncludesShadersStore.uvAttributeDeclaration = "#ifdef UV{X}\nattribute vec2 uv{X};\n#endif\n";
  52088. Pt.IncludesShadersStore.bonesDeclaration = "#if NUM_BONE_INFLUENCERS>0\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\n#ifdef BONETEXTURE\n#define inline\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{\nfloat offset=index *4.0;\nfloat dx=1.0/boneTextureWidth;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif\n";
  52089. Pt.IncludesShadersStore.bakedVertexAnimationDeclaration = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform float bakedVertexAnimationTime;\nuniform vec2 bakedVertexAnimationTextureSizeInverted;\nuniform vec4 bakedVertexAnimationSettings;\nuniform sampler2D bakedVertexAnimationTexture;\n#ifdef INSTANCES\nattribute vec4 bakedVertexAnimationSettingsInstanced;\n#endif\n#define inline\nmat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)\n{\nfloat offset=index*4.0;\nfloat frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;\nfloat dx=bakedVertexAnimationTextureSizeInverted.x;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n";
  52090. Pt.IncludesShadersStore.instancesDeclaration = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute vec4 previousWorld0;\nattribute vec4 previousWorld1;\nattribute vec4 previousWorld2;\nattribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform mat4 previousWorld;\n#endif\n#endif\n";
  52091. Pt.IncludesShadersStore.prePassVertexDeclaration = "#ifdef PREPASS\n#ifdef PREPASS_DEPTH\nvarying vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#endif\n";
  52092. Pt.IncludesShadersStore.samplerVertexDeclaration = "#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n";
  52093. Pt.IncludesShadersStore.bumpVertexDeclaration = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  52094. Pt.IncludesShadersStore.clipPlaneVertexDeclaration = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nvarying float fClipDistance6;\n#endif\n";
  52095. Pt.IncludesShadersStore.fogVertexDeclaration = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif\n";
  52096. Pt.IncludesShadersStore.lightVxFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#endif\n";
  52097. Pt.IncludesShadersStore.lightVxUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";
  52098. Pt.IncludesShadersStore.morphTargetsVertexGlobalDeclaration = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#ifdef MORPHTARGETS_TEXTURE \nprecision mediump sampler2DArray; \nuniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];\nuniform vec3 morphTargetTextureInfo;\nuniform sampler2DArray morphTargets;\nvec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)\n{ \nfloat y=floor(vertexIndex/morphTargetTextureInfo.y);\nfloat x=vertexIndex-y*morphTargetTextureInfo.y;\nvec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);\nreturn texture(morphTargets,textureUV).xyz;\n}\n#endif\n#endif\n";
  52099. Pt.IncludesShadersStore.morphTargetsVertexDeclaration = "#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif\n#endif\n";
  52100. Pt.IncludesShadersStore.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nfloat vertexID;\n#endif\n#endif\n";
  52101. Pt.IncludesShadersStore.morphTargetsVertex = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \nvertexID=float(gl_VertexID)*morphTargetTextureInfo.x;\npositionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(readVector3FromRawSampler({X},vertexID) -normal)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";
  52102. Pt.IncludesShadersStore.instancesVertex = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n";
  52103. Pt.IncludesShadersStore.bonesVertex = "#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";
  52104. Pt.IncludesShadersStore.bakedVertexAnimation = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\n#define BVASNAME bakedVertexAnimationSettingsInstanced\n#else\n#define BVASNAME bakedVertexAnimationSettings\n#endif\nfloat VATStartFrame=BVASNAME.x;\nfloat VATEndFrame=BVASNAME.y;\nfloat VATOffsetFrame=BVASNAME.z;\nfloat VATSpeed=BVASNAME.w;\nfloat totalFrames=VATEndFrame-VATStartFrame+1.0;\nfloat time=bakedVertexAnimationTime*VATSpeed/totalFrames;\nfloat frameCorrection=time<1.0 ? 0.0 : 1.0;\nfloat numOfFrames=totalFrames-frameCorrection;\nfloat VATFrameNum=fract(time)*numOfFrames;\nVATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum+=VATStartFrame+frameCorrection;\nmat4 VATInfluence;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif\n";
  52105. Pt.IncludesShadersStore.prePassVertex = "#ifdef PREPASS_DEPTH\nvViewPos=(view*worldPos).rgb;\n#endif\n#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n";
  52106. Pt.IncludesShadersStore.uvVariableDeclaration = "#if !defined(UV{X}) && defined(MAINUV{X})\nvec2 uv{X}=vec2(0.,0.);\n#endif\n#ifdef MAINUV{X}\nvMainUV{X}=uv{X};\n#endif\n";
  52107. Pt.IncludesShadersStore.samplerVertexImplementation = "#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nif (v_INFONAME_==0.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));\n}\n#ifdef UV2\nelse if (v_INFONAME_==1.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef UV3\nelse if (v_INFONAME_==2.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));\n}\n#endif\n#ifdef UV4\nelse if (v_INFONAME_==3.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));\n}\n#endif\n#ifdef UV5\nelse if (v_INFONAME_==4.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));\n}\n#endif\n#ifdef UV6\nelse if (v_INFONAME_==5.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));\n}\n#endif\n#endif\n";
  52108. Pt.IncludesShadersStore.bumpVertex = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif\n";
  52109. Pt.IncludesShadersStore.clipPlaneVertex = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif\n";
  52110. Pt.IncludesShadersStore.fogVertex = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif\n";
  52111. Pt.IncludesShadersStore.shadowsVertex = "#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {\nvPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#else\nvDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#endif\n}\n#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#else\nvDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#endif\n#endif\n#endif\n";
  52112. Pt.IncludesShadersStore.pointCloudVertex = "#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n";
  52113. Pt.IncludesShadersStore.logDepthVertex = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif\n";
  52114. Pt.ShadersStore.defaultVertexShader = "#include<__decl__defaultVertex>\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#include<uvAttributeDeclaration>[2..7]\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\n#include<prePassVertexDeclaration>\n#include<mainUVVaryingDeclaration>[1..7]\n#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)\n#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)\n#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)\n#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)\n#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)\n#if defined(SPECULARTERM)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)\n#endif\n#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n#ifndef UV1\nvec2 uvUpdated=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#include<uvVariableDeclaration>[2..7]\n#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)\n#if defined(SPECULARTERM)\n#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)\n#endif\n#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  52115. var ys = function() {
  52116. function e() {
  52117. this._defines = {},
  52118. this._currentRank = 32,
  52119. this._maxRank = -1,
  52120. this._mesh = null
  52121. }
  52122. return e.prototype.unBindMesh = function() {
  52123. this._mesh = null
  52124. }
  52125. ,
  52126. e.prototype.addFallback = function(e, t) {
  52127. this._defines[e] || (e < this._currentRank && (this._currentRank = e),
  52128. e > this._maxRank && (this._maxRank = e),
  52129. this._defines[e] = new Array),
  52130. this._defines[e].push(t)
  52131. }
  52132. ,
  52133. e.prototype.addCPUSkinningFallback = function(e, t) {
  52134. this._mesh = t,
  52135. e < this._currentRank && (this._currentRank = e),
  52136. e > this._maxRank && (this._maxRank = e)
  52137. }
  52138. ,
  52139. Object.defineProperty(e.prototype, "hasMoreFallbacks", {
  52140. get: function() {
  52141. return this._currentRank <= this._maxRank
  52142. },
  52143. enumerable: !1,
  52144. configurable: !0
  52145. }),
  52146. e.prototype.reduce = function(e, t) {
  52147. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
  52148. this._mesh.computeBonesUsingShaders = !1,
  52149. e = e.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0"),
  52150. t._bonesComputationForcedToCPU = !0;
  52151. for (var i = this._mesh.getScene(), n = 0; n < i.meshes.length; n++) {
  52152. var r = i.meshes[n];
  52153. if (r.material) {
  52154. if (r.computeBonesUsingShaders && 0 !== r.numBoneInfluencers)
  52155. if (r.material.getEffect() === t)
  52156. r.computeBonesUsingShaders = !1;
  52157. else if (r.subMeshes)
  52158. for (var o = 0, a = r.subMeshes; o < a.length; o++)
  52159. if (a[o].effect === t) {
  52160. r.computeBonesUsingShaders = !1;
  52161. break
  52162. }
  52163. } else
  52164. !this._mesh.material && r.computeBonesUsingShaders && r.numBoneInfluencers > 0 && (r.computeBonesUsingShaders = !1)
  52165. }
  52166. } else {
  52167. var s = this._defines[this._currentRank];
  52168. if (s)
  52169. for (n = 0; n < s.length; n++)
  52170. e = e.replace("#define " + s[n], "");
  52171. this._currentRank++
  52172. }
  52173. return e
  52174. }
  52175. ,
  52176. e
  52177. }()
  52178. , bs = function() {
  52179. function e(e) {
  52180. this._plugins = [],
  52181. this._activePlugins = [],
  52182. this._activePluginsForExtraEvents = [],
  52183. this._material = e,
  52184. this._scene = e.getScene(),
  52185. this._engine = this._scene.getEngine()
  52186. }
  52187. return e.prototype._addPlugin = function(e) {
  52188. for (var t = 0; t < this._plugins.length; ++t)
  52189. if (this._plugins[t].name === e.name)
  52190. throw 'Plugin "'.concat(e.name, '" already added to the material "').concat(this._material.name, '"!');
  52191. if (this._material._uniformBufferLayoutBuilt)
  52192. throw 'The plugin "'.concat(e.name, '" can\'t be added to the material "').concat(this._material.name, '" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.');
  52193. this._material._callbackPluginEventGeneric = this._handlePluginEvent.bind(this),
  52194. this._plugins.push(e),
  52195. this._plugins.sort((function(e, t) {
  52196. return e.priority - t.priority
  52197. }
  52198. )),
  52199. this._codeInjectionPoints = {};
  52200. for (var i = {}, n = 0, r = this._plugins; n < r.length; n++) {
  52201. var o = r[n];
  52202. o.collectDefines(i),
  52203. this._collectPointNames("vertex", o.getCustomCode("vertex")),
  52204. this._collectPointNames("fragment", o.getCustomCode("fragment"))
  52205. }
  52206. Object.keys(i).length > 0 ? this._defineNamesFromPlugins = i : delete this._defineNamesFromPlugins
  52207. }
  52208. ,
  52209. e.prototype._activatePlugin = function(e) {
  52210. -1 === this._activePlugins.indexOf(e) && (this._activePlugins.push(e),
  52211. this._activePlugins.sort((function(e, t) {
  52212. return e.priority - t.priority
  52213. }
  52214. )),
  52215. this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this),
  52216. this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this),
  52217. this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this),
  52218. e.registerForExtraEvents && (this._activePluginsForExtraEvents.push(e),
  52219. this._activePluginsForExtraEvents.sort((function(e, t) {
  52220. return e.priority - t.priority
  52221. }
  52222. )),
  52223. this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this),
  52224. this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this),
  52225. this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this)))
  52226. }
  52227. ,
  52228. e.prototype.getPlugin = function(e) {
  52229. for (var t = 0; t < this._plugins.length; ++t)
  52230. if (this._plugins[t].name === e)
  52231. return this._plugins[t];
  52232. return null
  52233. }
  52234. ,
  52235. e.prototype._handlePluginEventIsReadyForSubMesh = function(e) {
  52236. for (var t = !0, i = 0, n = this._activePlugins; i < n.length; i++) {
  52237. var r = n[i];
  52238. t = t && r.isReadyForSubMesh(e.defines, this._scene, this._engine, e.subMesh)
  52239. }
  52240. e.isReadyForSubMesh = t
  52241. }
  52242. ,
  52243. e.prototype._handlePluginEventPrepareDefines = function(e) {
  52244. for (var t = 0, i = this._activePlugins; t < i.length; t++)
  52245. i[t].prepareDefines(e.defines, this._scene, e.mesh)
  52246. }
  52247. ,
  52248. e.prototype._handlePluginEventHardBindForSubMesh = function(e) {
  52249. for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
  52250. i[t].hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
  52251. }
  52252. ,
  52253. e.prototype._handlePluginEventBindForSubMesh = function(e) {
  52254. for (var t = 0, i = this._activePlugins; t < i.length; t++)
  52255. i[t].bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
  52256. }
  52257. ,
  52258. e.prototype._handlePluginEventHasRenderTargetTextures = function(e) {
  52259. for (var t = !1, i = 0, n = this._activePluginsForExtraEvents; i < n.length && !(t = n[i].hasRenderTargetTextures()); i++)
  52260. ;
  52261. e.hasRenderTargetTextures = t
  52262. }
  52263. ,
  52264. e.prototype._handlePluginEventFillRenderTargetTextures = function(e) {
  52265. for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
  52266. i[t].fillRenderTargetTextures(e.renderTargets)
  52267. }
  52268. ,
  52269. e.prototype._handlePluginEvent = function(e, t) {
  52270. var i, n, r;
  52271. switch (e) {
  52272. case Ar.GetActiveTextures:
  52273. for (var o = t, a = 0, s = this._activePlugins; a < s.length; a++)
  52274. (g = s[a]).getActiveTextures(o.activeTextures);
  52275. break;
  52276. case Ar.GetAnimatables:
  52277. o = t;
  52278. for (var l = 0, c = this._activePlugins; l < c.length; l++)
  52279. (g = c[l]).getAnimatables(o.animatables);
  52280. break;
  52281. case Ar.HasTexture:
  52282. o = t;
  52283. for (var u = !1, h = 0, d = this._activePlugins; h < d.length && !(u = (g = d[h]).hasTexture(o.texture)); h++)
  52284. ;
  52285. o.hasTexture = u;
  52286. break;
  52287. case Ar.Disposed:
  52288. o = t;
  52289. for (var p = 0, f = this._plugins; p < f.length; p++)
  52290. (g = f[p]).dispose(o.forceDisposeTextures);
  52291. break;
  52292. case Ar.GetDefineNames:
  52293. (o = t).defineNames = this._defineNamesFromPlugins;
  52294. break;
  52295. case Ar.PrepareEffect:
  52296. o = t;
  52297. for (var _ = 0, m = this._activePlugins; _ < m.length; _++) {
  52298. var g = m[_];
  52299. o.fallbackRank = g.addFallbacks(o.defines, o.fallbacks, o.fallbackRank)
  52300. }
  52301. this._uniformList.length > 0 && (i = o.uniforms).push.apply(i, this._uniformList),
  52302. this._samplerList.length > 0 && (n = o.samplers).push.apply(n, this._samplerList),
  52303. this._uboList.length > 0 && (r = o.uniformBuffersNames).push.apply(r, this._uboList),
  52304. o.customCode = this._injectCustomCode(o.customCode);
  52305. break;
  52306. case Ar.PrepareUniformBuffer:
  52307. o = t,
  52308. this._uboDeclaration = "",
  52309. this._vertexDeclaration = "",
  52310. this._fragmentDeclaration = "",
  52311. this._uniformList = [],
  52312. this._samplerList = [],
  52313. this._uboList = [];
  52314. for (var v = 0, y = this._plugins; v < y.length; v++) {
  52315. var b = (g = y[v]).getUniforms();
  52316. if (b) {
  52317. if (b.ubo)
  52318. for (var T = 0, E = b.ubo; T < E.length; T++) {
  52319. var S = E[T];
  52320. o.ubo.addUniform(S.name, S.size),
  52321. this._uboDeclaration += "".concat(S.type, " ").concat(S.name, ";\r\n"),
  52322. this._uniformList.push(S.name)
  52323. }
  52324. b.vertex && (this._vertexDeclaration += b.vertex + "\r\n"),
  52325. b.fragment && (this._fragmentDeclaration += b.fragment + "\r\n")
  52326. }
  52327. g.getSamplers(this._samplerList),
  52328. g.getUniformBuffersNames(this._uboList)
  52329. }
  52330. }
  52331. }
  52332. ,
  52333. e.prototype._collectPointNames = function(e, t) {
  52334. if (t)
  52335. for (var i in t)
  52336. this._codeInjectionPoints[e] || (this._codeInjectionPoints[e] = {}),
  52337. this._codeInjectionPoints[e][i] = !0
  52338. }
  52339. ,
  52340. e.prototype._injectCustomCode = function(e) {
  52341. var t = this;
  52342. return function(i, n) {
  52343. var r;
  52344. e && (n = e(i, n)),
  52345. t._uboDeclaration && (n = n.replace("#define ADDITIONAL_UBO_DECLARATION", t._uboDeclaration)),
  52346. t._vertexDeclaration && (n = n.replace("#define ADDITIONAL_VERTEX_DECLARATION", t._vertexDeclaration)),
  52347. t._fragmentDeclaration && (n = n.replace("#define ADDITIONAL_FRAGMENT_DECLARATION", t._fragmentDeclaration));
  52348. var o = null === (r = t._codeInjectionPoints) || void 0 === r ? void 0 : r[i];
  52349. if (!o)
  52350. return n;
  52351. for (var a in o) {
  52352. for (var s = "", l = 0, c = t._activePlugins; l < c.length; l++) {
  52353. var u = c[l].getCustomCode(i);
  52354. (null == u ? void 0 : u[a]) && (s += u[a] + "\r\n")
  52355. }
  52356. if (s.length > 0)
  52357. if ("!" === a.charAt(0))
  52358. for (var h = new RegExp(a.substring(1),"g"), d = h.exec(n); null !== d; )
  52359. n = n.replace(d[0], s),
  52360. d = h.exec(n);
  52361. else {
  52362. var p = "#define " + a;
  52363. n = n.replace(p, "\r\n" + s + "\r\n" + p)
  52364. }
  52365. }
  52366. return n
  52367. }
  52368. }
  52369. ,
  52370. e
  52371. }()
  52372. , Ts = []
  52373. , Es = !1;
  52374. function Ss(e, t) {
  52375. Es || (Or.OnEventObservable.add((function(e) {
  52376. for (var t = 0, i = Ts; t < i.length; t++)
  52377. (0,
  52378. i[t][1])(e)
  52379. }
  52380. ), Ar.Created),
  52381. Es = !0);
  52382. var i = Ts.filter((function(t) {
  52383. var i = t[0];
  52384. return t[1],
  52385. i === e
  52386. }
  52387. ));
  52388. i.length > 0 ? i[0][1] = t : Ts.push([e, t])
  52389. }
  52390. function As(e) {
  52391. for (var t = 0; t < Ts.length; ++t)
  52392. if (Ts[t][0] === e)
  52393. return Ts.splice(t, 1),
  52394. !0;
  52395. return !1
  52396. }
  52397. function xs() {
  52398. Ts.length = 0
  52399. }
  52400. var Rs = function() {
  52401. function e(e, t, i, n, r, o) {
  52402. void 0 === r && (r = !0),
  52403. void 0 === o && (o = !1),
  52404. this.priority = 500,
  52405. this.registerForExtraEvents = !1,
  52406. this._material = e,
  52407. this.name = t,
  52408. this.priority = i,
  52409. e.pluginManager || (e.pluginManager = new bs(e)),
  52410. this._pluginDefineNames = n,
  52411. this._pluginManager = e.pluginManager,
  52412. r && this._pluginManager._addPlugin(this),
  52413. o && this._enable(!0),
  52414. this.markAllDefinesAsDirty = e._dirtyCallbacks[a.MATERIAL_AllDirtyFlag]
  52415. }
  52416. return e.prototype._enable = function(e) {
  52417. e && this._pluginManager._activatePlugin(this)
  52418. }
  52419. ,
  52420. e.prototype.getClassName = function() {
  52421. return "MaterialPluginBase"
  52422. }
  52423. ,
  52424. e.prototype.isReadyForSubMesh = function(e, t, i, n) {
  52425. return !0
  52426. }
  52427. ,
  52428. e.prototype.hardBindForSubMesh = function(e, t, i, n) {}
  52429. ,
  52430. e.prototype.bindForSubMesh = function(e, t, i, n) {}
  52431. ,
  52432. e.prototype.dispose = function(e) {}
  52433. ,
  52434. e.prototype.getCustomCode = function(e) {
  52435. return null
  52436. }
  52437. ,
  52438. e.prototype.collectDefines = function(e) {
  52439. if (this._pluginDefineNames)
  52440. for (var t = 0, i = Object.keys(this._pluginDefineNames); t < i.length; t++) {
  52441. var n = i[t];
  52442. if ("_" !== n[0]) {
  52443. var r = typeof this._pluginDefineNames[n];
  52444. e[n] = {
  52445. type: "number" === r ? "number" : "string" === r ? "string" : "boolean" === r ? "boolean" : "object",
  52446. default: this._pluginDefineNames[n]
  52447. }
  52448. }
  52449. }
  52450. }
  52451. ,
  52452. e.prototype.prepareDefines = function(e, t, i) {}
  52453. ,
  52454. e.prototype.hasTexture = function(e) {
  52455. return !1
  52456. }
  52457. ,
  52458. e.prototype.hasRenderTargetTextures = function() {
  52459. return !1
  52460. }
  52461. ,
  52462. e.prototype.fillRenderTargetTextures = function(e) {}
  52463. ,
  52464. e.prototype.getActiveTextures = function(e) {}
  52465. ,
  52466. e.prototype.getAnimatables = function(e) {}
  52467. ,
  52468. e.prototype.addFallbacks = function(e, t, i) {
  52469. return i
  52470. }
  52471. ,
  52472. e.prototype.getSamplers = function(e) {}
  52473. ,
  52474. e.prototype.getUniformBuffersNames = function(e) {}
  52475. ,
  52476. e.prototype.getUniforms = function() {
  52477. return {}
  52478. }
  52479. ,
  52480. e.prototype.copyTo = function(e) {
  52481. Ge.Clone((function() {
  52482. return e
  52483. }
  52484. ), this)
  52485. }
  52486. ,
  52487. e.prototype.serialize = function() {
  52488. return Ge.Serialize(this)
  52489. }
  52490. ,
  52491. e.prototype.parse = function(e, t, i) {
  52492. var n = this;
  52493. Ge.Parse((function() {
  52494. return n
  52495. }
  52496. ), e, t, i)
  52497. }
  52498. ,
  52499. k([Ce()], e.prototype, "name", void 0),
  52500. k([Ce()], e.prototype, "priority", void 0),
  52501. k([Ce()], e.prototype, "registerForExtraEvents", void 0),
  52502. e
  52503. }()
  52504. , Cs = function(e) {
  52505. function t() {
  52506. var t = null !== e && e.apply(this, arguments) || this;
  52507. return t.DETAIL = !1,
  52508. t.DETAILDIRECTUV = 0,
  52509. t.DETAIL_NORMALBLENDMETHOD = 0,
  52510. t
  52511. }
  52512. return U(t, e),
  52513. t
  52514. }(Si)
  52515. , Ps = function(e) {
  52516. function t(t, i) {
  52517. void 0 === i && (i = !0);
  52518. var n = e.call(this, t, "DetailMap", 140, new Cs, i) || this;
  52519. return n._texture = null,
  52520. n.diffuseBlendLevel = 1,
  52521. n.roughnessBlendLevel = 1,
  52522. n.bumpLevel = 1,
  52523. n._normalBlendMethod = Or.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
  52524. n._isEnabled = !1,
  52525. n.isEnabled = !1,
  52526. n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
  52527. n
  52528. }
  52529. return U(t, e),
  52530. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  52531. this._enable(this._isEnabled),
  52532. this._internalMarkAllSubMeshesAsTexturesDirty()
  52533. }
  52534. ,
  52535. t.prototype.isReadyForSubMesh = function(e, t, i) {
  52536. return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && i.getCaps().standardDerivatives && this._texture && vs.DetailTextureEnabled && !this._texture.isReady())
  52537. }
  52538. ,
  52539. t.prototype.prepareDefines = function(e, t) {
  52540. if (this._isEnabled) {
  52541. e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
  52542. var i = t.getEngine();
  52543. e._areTexturesDirty && (i.getCaps().standardDerivatives && this._texture && vs.DetailTextureEnabled && this._isEnabled ? (Mr.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"),
  52544. e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1)
  52545. } else
  52546. e.DETAIL = !1
  52547. }
  52548. ,
  52549. t.prototype.bindForSubMesh = function(e, t) {
  52550. if (this._isEnabled) {
  52551. var i = this._material.isFrozen;
  52552. e.useUbo && i && e.isSync || this._texture && vs.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
  52553. Mr.BindTextureMatrix(this._texture, e, "detail")),
  52554. t.texturesEnabled && this._texture && vs.DetailTextureEnabled && e.setTexture("detailSampler", this._texture)
  52555. }
  52556. }
  52557. ,
  52558. t.prototype.hasTexture = function(e) {
  52559. return this._texture === e
  52560. }
  52561. ,
  52562. t.prototype.getActiveTextures = function(e) {
  52563. this._texture && e.push(this._texture)
  52564. }
  52565. ,
  52566. t.prototype.getAnimatables = function(e) {
  52567. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
  52568. }
  52569. ,
  52570. t.prototype.dispose = function(e) {
  52571. var t;
  52572. e && (null === (t = this._texture) || void 0 === t || t.dispose())
  52573. }
  52574. ,
  52575. t.prototype.getClassName = function() {
  52576. return "DetailMapConfiguration"
  52577. }
  52578. ,
  52579. t.prototype.getSamplers = function(e) {
  52580. e.push("detailSampler")
  52581. }
  52582. ,
  52583. t.prototype.getUniforms = function() {
  52584. return {
  52585. ubo: [{
  52586. name: "vDetailInfos",
  52587. size: 4,
  52588. type: "vec4"
  52589. }, {
  52590. name: "detailMatrix",
  52591. size: 16,
  52592. type: "mat4"
  52593. }]
  52594. }
  52595. }
  52596. ,
  52597. k([Pe("detailTexture"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
  52598. k([Ce()], t.prototype, "diffuseBlendLevel", void 0),
  52599. k([Ce()], t.prototype, "roughnessBlendLevel", void 0),
  52600. k([Ce()], t.prototype, "bumpLevel", void 0),
  52601. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "normalBlendMethod", void 0),
  52602. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
  52603. t
  52604. }(Rs)
  52605. , Ms = {
  52606. effect: null,
  52607. subMesh: null
  52608. }
  52609. , Is = function(e) {
  52610. function t(t) {
  52611. var i = e.call(this, t) || this;
  52612. return i.MAINUV1 = !1,
  52613. i.MAINUV2 = !1,
  52614. i.MAINUV3 = !1,
  52615. i.MAINUV4 = !1,
  52616. i.MAINUV5 = !1,
  52617. i.MAINUV6 = !1,
  52618. i.DIFFUSE = !1,
  52619. i.DIFFUSEDIRECTUV = 0,
  52620. i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
  52621. i.AMBIENT = !1,
  52622. i.AMBIENTDIRECTUV = 0,
  52623. i.OPACITY = !1,
  52624. i.OPACITYDIRECTUV = 0,
  52625. i.OPACITYRGB = !1,
  52626. i.REFLECTION = !1,
  52627. i.EMISSIVE = !1,
  52628. i.EMISSIVEDIRECTUV = 0,
  52629. i.SPECULAR = !1,
  52630. i.SPECULARDIRECTUV = 0,
  52631. i.BUMP = !1,
  52632. i.BUMPDIRECTUV = 0,
  52633. i.PARALLAX = !1,
  52634. i.PARALLAXOCCLUSION = !1,
  52635. i.SPECULAROVERALPHA = !1,
  52636. i.CLIPPLANE = !1,
  52637. i.CLIPPLANE2 = !1,
  52638. i.CLIPPLANE3 = !1,
  52639. i.CLIPPLANE4 = !1,
  52640. i.CLIPPLANE5 = !1,
  52641. i.CLIPPLANE6 = !1,
  52642. i.ALPHATEST = !1,
  52643. i.DEPTHPREPASS = !1,
  52644. i.ALPHAFROMDIFFUSE = !1,
  52645. i.POINTSIZE = !1,
  52646. i.FOG = !1,
  52647. i.SPECULARTERM = !1,
  52648. i.DIFFUSEFRESNEL = !1,
  52649. i.OPACITYFRESNEL = !1,
  52650. i.REFLECTIONFRESNEL = !1,
  52651. i.REFRACTIONFRESNEL = !1,
  52652. i.EMISSIVEFRESNEL = !1,
  52653. i.FRESNEL = !1,
  52654. i.NORMAL = !1,
  52655. i.TANGENT = !1,
  52656. i.UV1 = !1,
  52657. i.UV2 = !1,
  52658. i.UV3 = !1,
  52659. i.UV4 = !1,
  52660. i.UV5 = !1,
  52661. i.UV6 = !1,
  52662. i.VERTEXCOLOR = !1,
  52663. i.VERTEXALPHA = !1,
  52664. i.NUM_BONE_INFLUENCERS = 0,
  52665. i.BonesPerMesh = 0,
  52666. i.BONETEXTURE = !1,
  52667. i.BONES_VELOCITY_ENABLED = !1,
  52668. i.INSTANCES = !1,
  52669. i.THIN_INSTANCES = !1,
  52670. i.INSTANCESCOLOR = !1,
  52671. i.GLOSSINESS = !1,
  52672. i.ROUGHNESS = !1,
  52673. i.EMISSIVEASILLUMINATION = !1,
  52674. i.LINKEMISSIVEWITHDIFFUSE = !1,
  52675. i.REFLECTIONFRESNELFROMSPECULAR = !1,
  52676. i.LIGHTMAP = !1,
  52677. i.LIGHTMAPDIRECTUV = 0,
  52678. i.OBJECTSPACE_NORMALMAP = !1,
  52679. i.USELIGHTMAPASSHADOWMAP = !1,
  52680. i.REFLECTIONMAP_3D = !1,
  52681. i.REFLECTIONMAP_SPHERICAL = !1,
  52682. i.REFLECTIONMAP_PLANAR = !1,
  52683. i.REFLECTIONMAP_CUBIC = !1,
  52684. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  52685. i.USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  52686. i.REFLECTIONMAP_PROJECTION = !1,
  52687. i.REFLECTIONMAP_SKYBOX = !1,
  52688. i.REFLECTIONMAP_EXPLICIT = !1,
  52689. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  52690. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  52691. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  52692. i.REFLECTIONMAP_OPPOSITEZ = !1,
  52693. i.INVERTCUBICMAP = !1,
  52694. i.LOGARITHMICDEPTH = !1,
  52695. i.REFRACTION = !1,
  52696. i.REFRACTIONMAP_3D = !1,
  52697. i.REFLECTIONOVERALPHA = !1,
  52698. i.TWOSIDEDLIGHTING = !1,
  52699. i.SHADOWFLOAT = !1,
  52700. i.MORPHTARGETS = !1,
  52701. i.MORPHTARGETS_NORMAL = !1,
  52702. i.MORPHTARGETS_TANGENT = !1,
  52703. i.MORPHTARGETS_UV = !1,
  52704. i.NUM_MORPH_INFLUENCERS = 0,
  52705. i.MORPHTARGETS_TEXTURE = !1,
  52706. i.NONUNIFORMSCALING = !1,
  52707. i.PREMULTIPLYALPHA = !1,
  52708. i.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1,
  52709. i.ALPHABLEND = !0,
  52710. i.PREPASS = !1,
  52711. i.PREPASS_IRRADIANCE = !1,
  52712. i.PREPASS_IRRADIANCE_INDEX = -1,
  52713. i.PREPASS_ALBEDO_SQRT = !1,
  52714. i.PREPASS_ALBEDO_SQRT_INDEX = -1,
  52715. i.PREPASS_DEPTH = !1,
  52716. i.PREPASS_DEPTH_INDEX = -1,
  52717. i.PREPASS_NORMAL = !1,
  52718. i.PREPASS_NORMAL_INDEX = -1,
  52719. i.PREPASS_POSITION = !1,
  52720. i.PREPASS_POSITION_INDEX = -1,
  52721. i.PREPASS_VELOCITY = !1,
  52722. i.PREPASS_VELOCITY_INDEX = -1,
  52723. i.PREPASS_REFLECTIVITY = !1,
  52724. i.PREPASS_REFLECTIVITY_INDEX = -1,
  52725. i.SCENE_MRT_COUNT = 0,
  52726. i.RGBDLIGHTMAP = !1,
  52727. i.RGBDREFLECTION = !1,
  52728. i.RGBDREFRACTION = !1,
  52729. i.IMAGEPROCESSING = !1,
  52730. i.VIGNETTE = !1,
  52731. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  52732. i.VIGNETTEBLENDMODEOPAQUE = !1,
  52733. i.TONEMAPPING = !1,
  52734. i.TONEMAPPING_ACES = !1,
  52735. i.CONTRAST = !1,
  52736. i.COLORCURVES = !1,
  52737. i.COLORGRADING = !1,
  52738. i.COLORGRADING3D = !1,
  52739. i.SAMPLER3DGREENDEPTH = !1,
  52740. i.SAMPLER3DBGRMAP = !1,
  52741. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  52742. i.SKIPFINALCOLORCLAMP = !1,
  52743. i.MULTIVIEW = !1,
  52744. i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
  52745. i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
  52746. i.IS_REFLECTION_LINEAR = !1,
  52747. i.IS_REFRACTION_LINEAR = !1,
  52748. i.EXPOSURE = !1,
  52749. i.rebuild(),
  52750. i
  52751. }
  52752. return U(t, e),
  52753. t.prototype.setReflectionMode = function(e) {
  52754. for (var t = 0, i = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"]; t < i.length; t++) {
  52755. var n = i[t];
  52756. this[n] = n === e
  52757. }
  52758. }
  52759. ,
  52760. t
  52761. }(Si)
  52762. , Os = function(e) {
  52763. function t(i, n) {
  52764. var r = e.call(this, i, n) || this;
  52765. return r._diffuseTexture = null,
  52766. r._ambientTexture = null,
  52767. r._opacityTexture = null,
  52768. r._reflectionTexture = null,
  52769. r._emissiveTexture = null,
  52770. r._specularTexture = null,
  52771. r._bumpTexture = null,
  52772. r._lightmapTexture = null,
  52773. r._refractionTexture = null,
  52774. r.ambientColor = new D(0,0,0),
  52775. r.diffuseColor = new D(1,1,1),
  52776. r.specularColor = new D(1,1,1),
  52777. r.emissiveColor = new D(0,0,0),
  52778. r.specularPower = 64,
  52779. r._useAlphaFromDiffuseTexture = !1,
  52780. r._useEmissiveAsIllumination = !1,
  52781. r._linkEmissiveWithDiffuse = !1,
  52782. r._useSpecularOverAlpha = !1,
  52783. r._useReflectionOverAlpha = !1,
  52784. r._disableLighting = !1,
  52785. r._useObjectSpaceNormalMap = !1,
  52786. r._useParallax = !1,
  52787. r._useParallaxOcclusion = !1,
  52788. r.parallaxScaleBias = .05,
  52789. r._roughness = 0,
  52790. r.indexOfRefraction = .98,
  52791. r.invertRefractionY = !0,
  52792. r.alphaCutOff = .4,
  52793. r._useLightmapAsShadowmap = !1,
  52794. r._useReflectionFresnelFromSpecular = !1,
  52795. r._useGlossinessFromSpecularMapAlpha = !1,
  52796. r._maxSimultaneousLights = 4,
  52797. r._invertNormalMapX = !1,
  52798. r._invertNormalMapY = !1,
  52799. r._twoSidedLighting = !1,
  52800. r._renderTargets = new bi(16),
  52801. r._worldViewProjectionMatrix = P.Zero(),
  52802. r._globalAmbientColor = new D(0,0,0),
  52803. r._cacheHasRenderTargetTextures = !1,
  52804. r.detailMap = new Ps(r),
  52805. r._attachImageProcessingConfiguration(null),
  52806. r.prePassConfiguration = new ms,
  52807. r.getRenderTargetTextures = function() {
  52808. return r._renderTargets.reset(),
  52809. t.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
  52810. t.RefractionTextureEnabled && r._refractionTexture && r._refractionTexture.isRenderTarget && r._renderTargets.push(r._refractionTexture),
  52811. r._eventInfo.renderTargets = r._renderTargets,
  52812. r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
  52813. r._renderTargets
  52814. }
  52815. ,
  52816. r
  52817. }
  52818. return U(t, e),
  52819. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  52820. get: function() {
  52821. return this._imageProcessingConfiguration
  52822. },
  52823. set: function(e) {
  52824. this._attachImageProcessingConfiguration(e),
  52825. this._markAllSubMeshesAsTexturesDirty()
  52826. },
  52827. enumerable: !1,
  52828. configurable: !0
  52829. }),
  52830. t.prototype._attachImageProcessingConfiguration = function(e) {
  52831. var t = this;
  52832. e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  52833. this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
  52834. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
  52835. t._markAllSubMeshesAsImageProcessingDirty()
  52836. }
  52837. ))))
  52838. }
  52839. ,
  52840. Object.defineProperty(t.prototype, "isPrePassCapable", {
  52841. get: function() {
  52842. return !this.disableDepthWrite
  52843. },
  52844. enumerable: !1,
  52845. configurable: !0
  52846. }),
  52847. Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
  52848. get: function() {
  52849. return this.imageProcessingConfiguration.colorCurvesEnabled
  52850. },
  52851. set: function(e) {
  52852. this.imageProcessingConfiguration.colorCurvesEnabled = e
  52853. },
  52854. enumerable: !1,
  52855. configurable: !0
  52856. }),
  52857. Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
  52858. get: function() {
  52859. return this.imageProcessingConfiguration.colorGradingEnabled
  52860. },
  52861. set: function(e) {
  52862. this.imageProcessingConfiguration.colorGradingEnabled = e
  52863. },
  52864. enumerable: !1,
  52865. configurable: !0
  52866. }),
  52867. Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
  52868. get: function() {
  52869. return this._imageProcessingConfiguration.toneMappingEnabled
  52870. },
  52871. set: function(e) {
  52872. this._imageProcessingConfiguration.toneMappingEnabled = e
  52873. },
  52874. enumerable: !1,
  52875. configurable: !0
  52876. }),
  52877. Object.defineProperty(t.prototype, "cameraExposure", {
  52878. get: function() {
  52879. return this._imageProcessingConfiguration.exposure
  52880. },
  52881. set: function(e) {
  52882. this._imageProcessingConfiguration.exposure = e
  52883. },
  52884. enumerable: !1,
  52885. configurable: !0
  52886. }),
  52887. Object.defineProperty(t.prototype, "cameraContrast", {
  52888. get: function() {
  52889. return this._imageProcessingConfiguration.contrast
  52890. },
  52891. set: function(e) {
  52892. this._imageProcessingConfiguration.contrast = e
  52893. },
  52894. enumerable: !1,
  52895. configurable: !0
  52896. }),
  52897. Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
  52898. get: function() {
  52899. return this._imageProcessingConfiguration.colorGradingTexture
  52900. },
  52901. set: function(e) {
  52902. this._imageProcessingConfiguration.colorGradingTexture = e
  52903. },
  52904. enumerable: !1,
  52905. configurable: !0
  52906. }),
  52907. Object.defineProperty(t.prototype, "cameraColorCurves", {
  52908. get: function() {
  52909. return this._imageProcessingConfiguration.colorCurves
  52910. },
  52911. set: function(e) {
  52912. this._imageProcessingConfiguration.colorCurves = e
  52913. },
  52914. enumerable: !1,
  52915. configurable: !0
  52916. }),
  52917. Object.defineProperty(t.prototype, "canRenderToMRT", {
  52918. get: function() {
  52919. return !0
  52920. },
  52921. enumerable: !1,
  52922. configurable: !0
  52923. }),
  52924. Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
  52925. get: function() {
  52926. return !!(t.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || !!(t.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures
  52927. },
  52928. enumerable: !1,
  52929. configurable: !0
  52930. }),
  52931. t.prototype.getClassName = function() {
  52932. return "StandardMaterial"
  52933. }
  52934. ,
  52935. Object.defineProperty(t.prototype, "useLogarithmicDepth", {
  52936. get: function() {
  52937. return this._useLogarithmicDepth
  52938. },
  52939. set: function(e) {
  52940. this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported,
  52941. this._markAllSubMeshesAsMiscDirty()
  52942. },
  52943. enumerable: !1,
  52944. configurable: !0
  52945. }),
  52946. t.prototype.needAlphaBlending = function() {
  52947. return !this._disableAlphaBlending && (this.alpha < 1 || null != this._opacityTexture || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled)
  52948. }
  52949. ,
  52950. t.prototype.needAlphaTesting = function() {
  52951. return !!this._forceAlphaTest || this._hasAlphaChannel() && (null == this._transparencyMode || this._transparencyMode === Or.MATERIAL_ALPHATEST)
  52952. }
  52953. ,
  52954. t.prototype._shouldUseAlphaFromDiffuseTexture = function() {
  52955. return null != this._diffuseTexture && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Or.MATERIAL_OPAQUE
  52956. }
  52957. ,
  52958. t.prototype._hasAlphaChannel = function() {
  52959. return null != this._diffuseTexture && this._diffuseTexture.hasAlpha || null != this._opacityTexture
  52960. }
  52961. ,
  52962. t.prototype.getAlphaTestTexture = function() {
  52963. return this._diffuseTexture
  52964. }
  52965. ,
  52966. t.prototype.isReadyForSubMesh = function(e, i, n) {
  52967. if (void 0 === n && (n = !1),
  52968. this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
  52969. i.effect && this.isFrozen && i.effect._wasPreviouslyReady)
  52970. return !0;
  52971. i.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
  52972. i.materialDefines = new Is(this._eventInfo.defineNames));
  52973. var r = this.getScene()
  52974. , o = i.materialDefines;
  52975. if (this._isReadyForSubMesh(i))
  52976. return !0;
  52977. var s = r.getEngine();
  52978. o._needNormals = Mr.PrepareDefinesForLights(r, e, o, !0, this._maxSimultaneousLights, this._disableLighting),
  52979. Mr.PrepareDefinesForMultiview(r, o);
  52980. var l = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
  52981. if (Mr.PrepareDefinesForPrePass(r, o, this.canRenderToMRT && !l),
  52982. Mr.PrepareDefinesForOIT(r, o, l),
  52983. o._areTexturesDirty) {
  52984. this._eventInfo.hasRenderTargetTextures = !1,
  52985. this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
  52986. this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures,
  52987. o._needUVs = !1;
  52988. for (var c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)
  52989. o["MAINUV" + c] = !1;
  52990. if (r.texturesEnabled) {
  52991. if (this._diffuseTexture && t.DiffuseTextureEnabled) {
  52992. if (!this._diffuseTexture.isReadyOrNotBlocking())
  52993. return !1;
  52994. Mr.PrepareDefinesForMergedUV(this._diffuseTexture, o, "DIFFUSE")
  52995. } else
  52996. o.DIFFUSE = !1;
  52997. if (this._ambientTexture && t.AmbientTextureEnabled) {
  52998. if (!this._ambientTexture.isReadyOrNotBlocking())
  52999. return !1;
  53000. Mr.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT")
  53001. } else
  53002. o.AMBIENT = !1;
  53003. if (this._opacityTexture && t.OpacityTextureEnabled) {
  53004. if (!this._opacityTexture.isReadyOrNotBlocking())
  53005. return !1;
  53006. Mr.PrepareDefinesForMergedUV(this._opacityTexture, o, "OPACITY"),
  53007. o.OPACITYRGB = this._opacityTexture.getAlphaFromRGB
  53008. } else
  53009. o.OPACITY = !1;
  53010. if (this._reflectionTexture && t.ReflectionTextureEnabled) {
  53011. if (!this._reflectionTexture.isReadyOrNotBlocking())
  53012. return !1;
  53013. switch (o._needNormals = !0,
  53014. o.REFLECTION = !0,
  53015. o.ROUGHNESS = this._roughness > 0,
  53016. o.REFLECTIONOVERALPHA = this._useReflectionOverAlpha,
  53017. o.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === io.INVCUBIC_MODE,
  53018. o.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
  53019. o.RGBDREFLECTION = this._reflectionTexture.isRGBD,
  53020. o.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
  53021. this._reflectionTexture.coordinatesMode) {
  53022. case io.EXPLICIT_MODE:
  53023. o.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  53024. break;
  53025. case io.PLANAR_MODE:
  53026. o.setReflectionMode("REFLECTIONMAP_PLANAR");
  53027. break;
  53028. case io.PROJECTION_MODE:
  53029. o.setReflectionMode("REFLECTIONMAP_PROJECTION");
  53030. break;
  53031. case io.SKYBOX_MODE:
  53032. o.setReflectionMode("REFLECTIONMAP_SKYBOX");
  53033. break;
  53034. case io.SPHERICAL_MODE:
  53035. o.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  53036. break;
  53037. case io.EQUIRECTANGULAR_MODE:
  53038. o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  53039. break;
  53040. case io.FIXED_EQUIRECTANGULAR_MODE:
  53041. o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  53042. break;
  53043. case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  53044. o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  53045. break;
  53046. case io.CUBIC_MODE:
  53047. case io.INVCUBIC_MODE:
  53048. default:
  53049. o.setReflectionMode("REFLECTIONMAP_CUBIC")
  53050. }
  53051. o.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize
  53052. } else
  53053. o.REFLECTION = !1,
  53054. o.REFLECTIONMAP_OPPOSITEZ = !1;
  53055. if (this._emissiveTexture && t.EmissiveTextureEnabled) {
  53056. if (!this._emissiveTexture.isReadyOrNotBlocking())
  53057. return !1;
  53058. Mr.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE")
  53059. } else
  53060. o.EMISSIVE = !1;
  53061. if (this._lightmapTexture && t.LightmapTextureEnabled) {
  53062. if (!this._lightmapTexture.isReadyOrNotBlocking())
  53063. return !1;
  53064. Mr.PrepareDefinesForMergedUV(this._lightmapTexture, o, "LIGHTMAP"),
  53065. o.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
  53066. o.RGBDLIGHTMAP = this._lightmapTexture.isRGBD
  53067. } else
  53068. o.LIGHTMAP = !1;
  53069. if (this._specularTexture && t.SpecularTextureEnabled) {
  53070. if (!this._specularTexture.isReadyOrNotBlocking())
  53071. return !1;
  53072. Mr.PrepareDefinesForMergedUV(this._specularTexture, o, "SPECULAR"),
  53073. o.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha
  53074. } else
  53075. o.SPECULAR = !1;
  53076. if (r.getEngine().getCaps().standardDerivatives && this._bumpTexture && t.BumpTextureEnabled) {
  53077. if (!this._bumpTexture.isReady())
  53078. return !1;
  53079. Mr.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"),
  53080. o.PARALLAX = this._useParallax,
  53081. o.PARALLAXOCCLUSION = this._useParallaxOcclusion,
  53082. o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
  53083. } else
  53084. o.BUMP = !1;
  53085. if (this._refractionTexture && t.RefractionTextureEnabled) {
  53086. if (!this._refractionTexture.isReadyOrNotBlocking())
  53087. return !1;
  53088. o._needUVs = !0,
  53089. o.REFRACTION = !0,
  53090. o.REFRACTIONMAP_3D = this._refractionTexture.isCube,
  53091. o.RGBDREFRACTION = this._refractionTexture.isRGBD,
  53092. o.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize
  53093. } else
  53094. o.REFRACTION = !1;
  53095. o.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting
  53096. } else
  53097. o.DIFFUSE = !1,
  53098. o.AMBIENT = !1,
  53099. o.OPACITY = !1,
  53100. o.REFLECTION = !1,
  53101. o.EMISSIVE = !1,
  53102. o.LIGHTMAP = !1,
  53103. o.BUMP = !1,
  53104. o.REFRACTION = !1;
  53105. o.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(),
  53106. o.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination,
  53107. o.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse,
  53108. o.SPECULAROVERALPHA = this._useSpecularOverAlpha,
  53109. o.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
  53110. o.ALPHATEST_AFTERALLALPHACOMPUTATIONS = null !== this.transparencyMode,
  53111. o.ALPHABLEND = null === this.transparencyMode || this.needAlphaBlendingForMesh(e)
  53112. }
  53113. if (this._eventInfo.isReadyForSubMesh = !0,
  53114. this._eventInfo.defines = o,
  53115. this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
  53116. !this._eventInfo.isReadyForSubMesh)
  53117. return !1;
  53118. if (o._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53119. if (!this._imageProcessingConfiguration.isReady())
  53120. return !1;
  53121. this._imageProcessingConfiguration.prepareDefines(o),
  53122. o.IS_REFLECTION_LINEAR = null != this.reflectionTexture && !this.reflectionTexture.gammaSpace,
  53123. o.IS_REFRACTION_LINEAR = null != this.refractionTexture && !this.refractionTexture.gammaSpace
  53124. }
  53125. if (o._areFresnelDirty && (t.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (o.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled,
  53126. o.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled,
  53127. o.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled,
  53128. o.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular,
  53129. o.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled,
  53130. o.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled,
  53131. o._needNormals = !0,
  53132. o.FRESNEL = !0) : o.FRESNEL = !1),
  53133. Mr.PrepareDefinesForMisc(e, r, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, o),
  53134. Mr.PrepareDefinesForAttributes(e, o, !0, !0, !0),
  53135. Mr.PrepareDefinesForFrameBoundValues(r, s, o, n, null, i.getRenderingMesh().hasThinInstances),
  53136. this._eventInfo.defines = o,
  53137. this._eventInfo.mesh = e,
  53138. this._callbackPluginEventPrepareDefines(this._eventInfo),
  53139. o.isDirty) {
  53140. var u = o._areLightsDisposed;
  53141. o.markAsProcessed();
  53142. var h = new ys;
  53143. o.REFLECTION && h.addFallback(0, "REFLECTION"),
  53144. o.SPECULAR && h.addFallback(0, "SPECULAR"),
  53145. o.BUMP && h.addFallback(0, "BUMP"),
  53146. o.PARALLAX && h.addFallback(1, "PARALLAX"),
  53147. o.PARALLAXOCCLUSION && h.addFallback(0, "PARALLAXOCCLUSION"),
  53148. o.SPECULAROVERALPHA && h.addFallback(0, "SPECULAROVERALPHA"),
  53149. o.FOG && h.addFallback(1, "FOG"),
  53150. o.POINTSIZE && h.addFallback(0, "POINTSIZE"),
  53151. o.LOGARITHMICDEPTH && h.addFallback(0, "LOGARITHMICDEPTH"),
  53152. Mr.HandleFallbacksForShadows(o, h, this._maxSimultaneousLights),
  53153. o.SPECULARTERM && h.addFallback(0, "SPECULARTERM"),
  53154. o.DIFFUSEFRESNEL && h.addFallback(1, "DIFFUSEFRESNEL"),
  53155. o.OPACITYFRESNEL && h.addFallback(2, "OPACITYFRESNEL"),
  53156. o.REFLECTIONFRESNEL && h.addFallback(3, "REFLECTIONFRESNEL"),
  53157. o.EMISSIVEFRESNEL && h.addFallback(4, "EMISSIVEFRESNEL"),
  53158. o.FRESNEL && h.addFallback(4, "FRESNEL"),
  53159. o.MULTIVIEW && h.addFallback(0, "MULTIVIEW");
  53160. var d = [Bi.PositionKind];
  53161. for (o.NORMAL && d.push(Bi.NormalKind),
  53162. o.TANGENT && d.push(Bi.TangentKind),
  53163. c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)
  53164. o["UV" + c] && d.push("uv".concat(1 === c ? "" : c));
  53165. o.VERTEXCOLOR && d.push(Bi.ColorKind),
  53166. o.INSTANCESCOLOR && d.push(Bi.ColorInstanceKind),
  53167. Mr.PrepareAttributesForBones(d, e, o, h),
  53168. Mr.PrepareAttributesForInstances(d, o),
  53169. Mr.PrepareAttributesForMorphTargets(d, e, o),
  53170. Mr.PrepareAttributesForBakedVertexAnimation(d, e, o);
  53171. var p = "default"
  53172. , f = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility", "vFogInfos", "vFogColor", "pointSize", "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix", "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor", "vReflectionPosition", "vReflectionSize", "vRefractionPosition", "vRefractionSize", "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  53173. , _ = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
  53174. , m = ["Material", "Scene", "Mesh"];
  53175. this._eventInfo.fallbacks = h,
  53176. this._eventInfo.fallbackRank = 0,
  53177. this._eventInfo.defines = o,
  53178. this._eventInfo.uniforms = f,
  53179. this._eventInfo.samplers = _,
  53180. this._eventInfo.uniformBuffersNames = m,
  53181. this._eventInfo.customCode = void 0,
  53182. this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
  53183. ms.AddUniforms(f),
  53184. ms.AddSamplers(_),
  53185. Ri && (Ri.PrepareUniforms(f, o),
  53186. Ri.PrepareSamplers(_, o)),
  53187. Mr.PrepareUniformsAndSamplersList({
  53188. uniformsNames: f,
  53189. uniformBuffersNames: m,
  53190. samplers: _,
  53191. defines: o,
  53192. maxSimultaneousLights: this._maxSimultaneousLights
  53193. });
  53194. var g = {};
  53195. this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, o, d, g));
  53196. var v = o.toString()
  53197. , y = i.effect
  53198. , b = r.getEngine().createEffect(p, {
  53199. attributes: d,
  53200. uniformsNames: f,
  53201. uniformBuffersNames: m,
  53202. samplers: _,
  53203. defines: v,
  53204. fallbacks: h,
  53205. onCompiled: this.onCompiled,
  53206. onError: this.onError,
  53207. indexParameters: {
  53208. maxSimultaneousLights: this._maxSimultaneousLights,
  53209. maxSimultaneousMorphTargets: o.NUM_MORPH_INFLUENCERS
  53210. },
  53211. processFinalCode: g.processFinalCode,
  53212. processCodeAfterIncludes: this._eventInfo.customCode,
  53213. multiTarget: o.PREPASS
  53214. }, s);
  53215. if (b)
  53216. if (this._onEffectCreatedObservable && (Ms.effect = b,
  53217. Ms.subMesh = i,
  53218. this._onEffectCreatedObservable.notifyObservers(Ms)),
  53219. this.allowShaderHotSwapping && y && !b.isReady()) {
  53220. if (b = y,
  53221. o.markAsUnprocessed(),
  53222. u)
  53223. return o._areLightsDisposed = !0,
  53224. !1
  53225. } else
  53226. r.resetCachedMaterial(),
  53227. i.setEffect(b, o, this._materialContext)
  53228. }
  53229. return !(!i.effect || !i.effect.isReady() || (o._renderId = r.getRenderId(),
  53230. i.effect._wasPreviouslyReady = !0,
  53231. 0))
  53232. }
  53233. ,
  53234. t.prototype.buildUniformLayout = function() {
  53235. var t = this._uniformBuffer;
  53236. t.addUniform("diffuseLeftColor", 4),
  53237. t.addUniform("diffuseRightColor", 4),
  53238. t.addUniform("opacityParts", 4),
  53239. t.addUniform("reflectionLeftColor", 4),
  53240. t.addUniform("reflectionRightColor", 4),
  53241. t.addUniform("refractionLeftColor", 4),
  53242. t.addUniform("refractionRightColor", 4),
  53243. t.addUniform("emissiveLeftColor", 4),
  53244. t.addUniform("emissiveRightColor", 4),
  53245. t.addUniform("vDiffuseInfos", 2),
  53246. t.addUniform("vAmbientInfos", 2),
  53247. t.addUniform("vOpacityInfos", 2),
  53248. t.addUniform("vReflectionInfos", 2),
  53249. t.addUniform("vReflectionPosition", 3),
  53250. t.addUniform("vReflectionSize", 3),
  53251. t.addUniform("vEmissiveInfos", 2),
  53252. t.addUniform("vLightmapInfos", 2),
  53253. t.addUniform("vSpecularInfos", 2),
  53254. t.addUniform("vBumpInfos", 3),
  53255. t.addUniform("diffuseMatrix", 16),
  53256. t.addUniform("ambientMatrix", 16),
  53257. t.addUniform("opacityMatrix", 16),
  53258. t.addUniform("reflectionMatrix", 16),
  53259. t.addUniform("emissiveMatrix", 16),
  53260. t.addUniform("lightmapMatrix", 16),
  53261. t.addUniform("specularMatrix", 16),
  53262. t.addUniform("bumpMatrix", 16),
  53263. t.addUniform("vTangentSpaceParams", 2),
  53264. t.addUniform("pointSize", 1),
  53265. t.addUniform("alphaCutOff", 1),
  53266. t.addUniform("refractionMatrix", 16),
  53267. t.addUniform("vRefractionInfos", 4),
  53268. t.addUniform("vRefractionPosition", 3),
  53269. t.addUniform("vRefractionSize", 3),
  53270. t.addUniform("vSpecularColor", 4),
  53271. t.addUniform("vEmissiveColor", 3),
  53272. t.addUniform("vDiffuseColor", 4),
  53273. t.addUniform("vAmbientColor", 3),
  53274. e.prototype.buildUniformLayout.call(this)
  53275. }
  53276. ,
  53277. t.prototype.bindForSubMesh = function(e, i, n) {
  53278. var r, o = this.getScene(), a = n.materialDefines;
  53279. if (a) {
  53280. var s = n.effect;
  53281. if (s) {
  53282. this._activeEffect = s,
  53283. i.getMeshUniformBuffer().bindToEffect(s, "Mesh"),
  53284. i.transferToEffect(e),
  53285. this._uniformBuffer.bindToEffect(s, "Material"),
  53286. this.prePassConfiguration.bindForSubMesh(this._activeEffect, o, i, e, this.isFrozen),
  53287. this._eventInfo.subMesh = n,
  53288. this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
  53289. a.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
  53290. this.bindOnlyNormalMatrix(this._normalMatrix));
  53291. var l = this._mustRebind(o, s, i.visibility);
  53292. Mr.BindBonesParameters(i, s);
  53293. var c = this._uniformBuffer;
  53294. if (l) {
  53295. if (this.bindViewProjection(s),
  53296. !c.useUbo || !this.isFrozen || !c.isSync) {
  53297. if (t.FresnelEnabled && a.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (c.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power),
  53298. c.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)),
  53299. this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && c.updateColor4("opacityParts", new D(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power),
  53300. this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (c.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power),
  53301. c.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)),
  53302. this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (c.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power),
  53303. c.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)),
  53304. this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (c.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power),
  53305. c.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))),
  53306. o.texturesEnabled) {
  53307. if (this._diffuseTexture && t.DiffuseTextureEnabled && (c.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
  53308. Mr.BindTextureMatrix(this._diffuseTexture, c, "diffuse")),
  53309. this._ambientTexture && t.AmbientTextureEnabled && (c.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
  53310. Mr.BindTextureMatrix(this._ambientTexture, c, "ambient")),
  53311. this._opacityTexture && t.OpacityTextureEnabled && (c.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
  53312. Mr.BindTextureMatrix(this._opacityTexture, c, "opacity")),
  53313. this._hasAlphaChannel() && c.updateFloat("alphaCutOff", this.alphaCutOff),
  53314. this._reflectionTexture && t.ReflectionTextureEnabled && (c.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness),
  53315. c.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()),
  53316. this._reflectionTexture.boundingBoxSize)) {
  53317. var u = this._reflectionTexture;
  53318. c.updateVector3("vReflectionPosition", u.boundingBoxPosition),
  53319. c.updateVector3("vReflectionSize", u.boundingBoxSize)
  53320. }
  53321. if (this._emissiveTexture && t.EmissiveTextureEnabled && (c.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
  53322. Mr.BindTextureMatrix(this._emissiveTexture, c, "emissive")),
  53323. this._lightmapTexture && t.LightmapTextureEnabled && (c.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
  53324. Mr.BindTextureMatrix(this._lightmapTexture, c, "lightmap")),
  53325. this._specularTexture && t.SpecularTextureEnabled && (c.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
  53326. Mr.BindTextureMatrix(this._specularTexture, c, "specular")),
  53327. this._bumpTexture && o.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && (c.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias),
  53328. Mr.BindTextureMatrix(this._bumpTexture, c, "bump"),
  53329. o._mirroredCameraPosition ? c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)),
  53330. this._refractionTexture && t.RefractionTextureEnabled) {
  53331. var h = 1;
  53332. this._refractionTexture.isCube || (c.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()),
  53333. this._refractionTexture.depth && (h = this._refractionTexture.depth)),
  53334. c.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, h, this.invertRefractionY ? -1 : 1),
  53335. this._refractionTexture.boundingBoxSize && (u = this._refractionTexture,
  53336. c.updateVector3("vRefractionPosition", u.boundingBoxPosition),
  53337. c.updateVector3("vRefractionSize", u.boundingBoxSize))
  53338. }
  53339. }
  53340. this.pointsCloud && c.updateFloat("pointSize", this.pointSize),
  53341. a.SPECULARTERM && c.updateColor4("vSpecularColor", this.specularColor, this.specularPower),
  53342. c.updateColor3("vEmissiveColor", t.EmissiveTextureEnabled ? this.emissiveColor : D.BlackReadOnly),
  53343. c.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha),
  53344. o.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor),
  53345. c.updateColor3("vAmbientColor", this._globalAmbientColor)
  53346. }
  53347. o.texturesEnabled && (this._diffuseTexture && t.DiffuseTextureEnabled && s.setTexture("diffuseSampler", this._diffuseTexture),
  53348. this._ambientTexture && t.AmbientTextureEnabled && s.setTexture("ambientSampler", this._ambientTexture),
  53349. this._opacityTexture && t.OpacityTextureEnabled && s.setTexture("opacitySampler", this._opacityTexture),
  53350. this._reflectionTexture && t.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? s.setTexture("reflectionCubeSampler", this._reflectionTexture) : s.setTexture("reflection2DSampler", this._reflectionTexture)),
  53351. this._emissiveTexture && t.EmissiveTextureEnabled && s.setTexture("emissiveSampler", this._emissiveTexture),
  53352. this._lightmapTexture && t.LightmapTextureEnabled && s.setTexture("lightmapSampler", this._lightmapTexture),
  53353. this._specularTexture && t.SpecularTextureEnabled && s.setTexture("specularSampler", this._specularTexture),
  53354. this._bumpTexture && o.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && s.setTexture("bumpSampler", this._bumpTexture),
  53355. this._refractionTexture && t.RefractionTextureEnabled && (this._refractionTexture.isCube ? s.setTexture("refractionCubeSampler", this._refractionTexture) : s.setTexture("refraction2DSampler", this._refractionTexture))),
  53356. this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(i) && this.getScene().depthPeelingRenderer.bind(s),
  53357. this._eventInfo.subMesh = n,
  53358. this._callbackPluginEventBindForSubMesh(this._eventInfo),
  53359. Mr.BindClipPlane(s, o),
  53360. this.bindEyePosition(s)
  53361. } else
  53362. o.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
  53363. !l && this.isFrozen || (o.lightsEnabled && !this._disableLighting && Mr.BindLights(o, i, s, a, this._maxSimultaneousLights),
  53364. (o.fogEnabled && i.applyFog && o.fogMode !== mn.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || i.receiveShadows) && this.bindView(s),
  53365. Mr.BindFogParameters(o, i, s),
  53366. a.NUM_MORPH_INFLUENCERS && Mr.BindMorphTargetParameters(i, s),
  53367. a.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (r = i.bakedVertexAnimationManager) || void 0 === r || r.bind(s, a.INSTANCES)),
  53368. this.useLogarithmicDepth && Mr.BindLogDepth(a, s, o),
  53369. this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)),
  53370. this._afterBind(i, this._activeEffect),
  53371. c.update()
  53372. }
  53373. }
  53374. }
  53375. ,
  53376. t.prototype.getAnimatables = function() {
  53377. var t = e.prototype.getAnimatables.call(this);
  53378. return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && t.push(this._diffuseTexture),
  53379. this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && t.push(this._ambientTexture),
  53380. this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && t.push(this._opacityTexture),
  53381. this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && t.push(this._reflectionTexture),
  53382. this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && t.push(this._emissiveTexture),
  53383. this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && t.push(this._specularTexture),
  53384. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture),
  53385. this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && t.push(this._lightmapTexture),
  53386. this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && t.push(this._refractionTexture),
  53387. t
  53388. }
  53389. ,
  53390. t.prototype.getActiveTextures = function() {
  53391. var t = e.prototype.getActiveTextures.call(this);
  53392. return this._diffuseTexture && t.push(this._diffuseTexture),
  53393. this._ambientTexture && t.push(this._ambientTexture),
  53394. this._opacityTexture && t.push(this._opacityTexture),
  53395. this._reflectionTexture && t.push(this._reflectionTexture),
  53396. this._emissiveTexture && t.push(this._emissiveTexture),
  53397. this._specularTexture && t.push(this._specularTexture),
  53398. this._bumpTexture && t.push(this._bumpTexture),
  53399. this._lightmapTexture && t.push(this._lightmapTexture),
  53400. this._refractionTexture && t.push(this._refractionTexture),
  53401. t
  53402. }
  53403. ,
  53404. t.prototype.hasTexture = function(t) {
  53405. return !!e.prototype.hasTexture.call(this, t) || this._diffuseTexture === t || this._ambientTexture === t || this._opacityTexture === t || this._reflectionTexture === t || this._emissiveTexture === t || this._specularTexture === t || this._bumpTexture === t || this._lightmapTexture === t || this._refractionTexture === t
  53406. }
  53407. ,
  53408. t.prototype.dispose = function(t, i) {
  53409. var n, r, o, a, s, l, c, u, h;
  53410. i && (null === (n = this._diffuseTexture) || void 0 === n || n.dispose(),
  53411. null === (r = this._ambientTexture) || void 0 === r || r.dispose(),
  53412. null === (o = this._opacityTexture) || void 0 === o || o.dispose(),
  53413. null === (a = this._reflectionTexture) || void 0 === a || a.dispose(),
  53414. null === (s = this._emissiveTexture) || void 0 === s || s.dispose(),
  53415. null === (l = this._specularTexture) || void 0 === l || l.dispose(),
  53416. null === (c = this._bumpTexture) || void 0 === c || c.dispose(),
  53417. null === (u = this._lightmapTexture) || void 0 === u || u.dispose(),
  53418. null === (h = this._refractionTexture) || void 0 === h || h.dispose()),
  53419. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  53420. e.prototype.dispose.call(this, t, i)
  53421. }
  53422. ,
  53423. t.prototype.clone = function(e) {
  53424. var i = this
  53425. , n = Ge.Clone((function() {
  53426. return new t(e,i.getScene())
  53427. }
  53428. ), this);
  53429. return n.name = e,
  53430. n.id = e,
  53431. this.stencil.copyTo(n.stencil),
  53432. n
  53433. }
  53434. ,
  53435. t.Parse = function(e, i, n) {
  53436. var r = Ge.Parse((function() {
  53437. return new t(e.name,i)
  53438. }
  53439. ), e, i, n);
  53440. return e.stencil && r.stencil.parse(e.stencil, i, n),
  53441. r
  53442. }
  53443. ,
  53444. Object.defineProperty(t, "DiffuseTextureEnabled", {
  53445. get: function() {
  53446. return vs.DiffuseTextureEnabled
  53447. },
  53448. set: function(e) {
  53449. vs.DiffuseTextureEnabled = e
  53450. },
  53451. enumerable: !1,
  53452. configurable: !0
  53453. }),
  53454. Object.defineProperty(t, "DetailTextureEnabled", {
  53455. get: function() {
  53456. return vs.DetailTextureEnabled
  53457. },
  53458. set: function(e) {
  53459. vs.DetailTextureEnabled = e
  53460. },
  53461. enumerable: !1,
  53462. configurable: !0
  53463. }),
  53464. Object.defineProperty(t, "AmbientTextureEnabled", {
  53465. get: function() {
  53466. return vs.AmbientTextureEnabled
  53467. },
  53468. set: function(e) {
  53469. vs.AmbientTextureEnabled = e
  53470. },
  53471. enumerable: !1,
  53472. configurable: !0
  53473. }),
  53474. Object.defineProperty(t, "OpacityTextureEnabled", {
  53475. get: function() {
  53476. return vs.OpacityTextureEnabled
  53477. },
  53478. set: function(e) {
  53479. vs.OpacityTextureEnabled = e
  53480. },
  53481. enumerable: !1,
  53482. configurable: !0
  53483. }),
  53484. Object.defineProperty(t, "ReflectionTextureEnabled", {
  53485. get: function() {
  53486. return vs.ReflectionTextureEnabled
  53487. },
  53488. set: function(e) {
  53489. vs.ReflectionTextureEnabled = e
  53490. },
  53491. enumerable: !1,
  53492. configurable: !0
  53493. }),
  53494. Object.defineProperty(t, "EmissiveTextureEnabled", {
  53495. get: function() {
  53496. return vs.EmissiveTextureEnabled
  53497. },
  53498. set: function(e) {
  53499. vs.EmissiveTextureEnabled = e
  53500. },
  53501. enumerable: !1,
  53502. configurable: !0
  53503. }),
  53504. Object.defineProperty(t, "SpecularTextureEnabled", {
  53505. get: function() {
  53506. return vs.SpecularTextureEnabled
  53507. },
  53508. set: function(e) {
  53509. vs.SpecularTextureEnabled = e
  53510. },
  53511. enumerable: !1,
  53512. configurable: !0
  53513. }),
  53514. Object.defineProperty(t, "BumpTextureEnabled", {
  53515. get: function() {
  53516. return vs.BumpTextureEnabled
  53517. },
  53518. set: function(e) {
  53519. vs.BumpTextureEnabled = e
  53520. },
  53521. enumerable: !1,
  53522. configurable: !0
  53523. }),
  53524. Object.defineProperty(t, "LightmapTextureEnabled", {
  53525. get: function() {
  53526. return vs.LightmapTextureEnabled
  53527. },
  53528. set: function(e) {
  53529. vs.LightmapTextureEnabled = e
  53530. },
  53531. enumerable: !1,
  53532. configurable: !0
  53533. }),
  53534. Object.defineProperty(t, "RefractionTextureEnabled", {
  53535. get: function() {
  53536. return vs.RefractionTextureEnabled
  53537. },
  53538. set: function(e) {
  53539. vs.RefractionTextureEnabled = e
  53540. },
  53541. enumerable: !1,
  53542. configurable: !0
  53543. }),
  53544. Object.defineProperty(t, "ColorGradingTextureEnabled", {
  53545. get: function() {
  53546. return vs.ColorGradingTextureEnabled
  53547. },
  53548. set: function(e) {
  53549. vs.ColorGradingTextureEnabled = e
  53550. },
  53551. enumerable: !1,
  53552. configurable: !0
  53553. }),
  53554. Object.defineProperty(t, "FresnelEnabled", {
  53555. get: function() {
  53556. return vs.FresnelEnabled
  53557. },
  53558. set: function(e) {
  53559. vs.FresnelEnabled = e
  53560. },
  53561. enumerable: !1,
  53562. configurable: !0
  53563. }),
  53564. k([Pe("diffuseTexture")], t.prototype, "_diffuseTexture", void 0),
  53565. k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "diffuseTexture", void 0),
  53566. k([Pe("ambientTexture")], t.prototype, "_ambientTexture", void 0),
  53567. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
  53568. k([Pe("opacityTexture")], t.prototype, "_opacityTexture", void 0),
  53569. k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
  53570. k([Pe("reflectionTexture")], t.prototype, "_reflectionTexture", void 0),
  53571. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
  53572. k([Pe("emissiveTexture")], t.prototype, "_emissiveTexture", void 0),
  53573. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
  53574. k([Pe("specularTexture")], t.prototype, "_specularTexture", void 0),
  53575. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularTexture", void 0),
  53576. k([Pe("bumpTexture")], t.prototype, "_bumpTexture", void 0),
  53577. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
  53578. k([Pe("lightmapTexture")], t.prototype, "_lightmapTexture", void 0),
  53579. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "lightmapTexture", void 0),
  53580. k([Pe("refractionTexture")], t.prototype, "_refractionTexture", void 0),
  53581. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
  53582. k([Me("ambient")], t.prototype, "ambientColor", void 0),
  53583. k([Me("diffuse")], t.prototype, "diffuseColor", void 0),
  53584. k([Me("specular")], t.prototype, "specularColor", void 0),
  53585. k([Me("emissive")], t.prototype, "emissiveColor", void 0),
  53586. k([Ce()], t.prototype, "specularPower", void 0),
  53587. k([Ce("useAlphaFromDiffuseTexture")], t.prototype, "_useAlphaFromDiffuseTexture", void 0),
  53588. k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromDiffuseTexture", void 0),
  53589. k([Ce("useEmissiveAsIllumination")], t.prototype, "_useEmissiveAsIllumination", void 0),
  53590. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useEmissiveAsIllumination", void 0),
  53591. k([Ce("linkEmissiveWithDiffuse")], t.prototype, "_linkEmissiveWithDiffuse", void 0),
  53592. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkEmissiveWithDiffuse", void 0),
  53593. k([Ce("useSpecularOverAlpha")], t.prototype, "_useSpecularOverAlpha", void 0),
  53594. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
  53595. k([Ce("useReflectionOverAlpha")], t.prototype, "_useReflectionOverAlpha", void 0),
  53596. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useReflectionOverAlpha", void 0),
  53597. k([Ce("disableLighting")], t.prototype, "_disableLighting", void 0),
  53598. k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
  53599. k([Ce("useObjectSpaceNormalMap")], t.prototype, "_useObjectSpaceNormalMap", void 0),
  53600. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
  53601. k([Ce("useParallax")], t.prototype, "_useParallax", void 0),
  53602. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
  53603. k([Ce("useParallaxOcclusion")], t.prototype, "_useParallaxOcclusion", void 0),
  53604. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
  53605. k([Ce()], t.prototype, "parallaxScaleBias", void 0),
  53606. k([Ce("roughness")], t.prototype, "_roughness", void 0),
  53607. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
  53608. k([Ce()], t.prototype, "indexOfRefraction", void 0),
  53609. k([Ce()], t.prototype, "invertRefractionY", void 0),
  53610. k([Ce()], t.prototype, "alphaCutOff", void 0),
  53611. k([Ce("useLightmapAsShadowmap")], t.prototype, "_useLightmapAsShadowmap", void 0),
  53612. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
  53613. k([Ie("diffuseFresnelParameters")], t.prototype, "_diffuseFresnelParameters", void 0),
  53614. k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "diffuseFresnelParameters", void 0),
  53615. k([Ie("opacityFresnelParameters")], t.prototype, "_opacityFresnelParameters", void 0),
  53616. k([Re("_markAllSubMeshesAsFresnelAndMiscDirty")], t.prototype, "opacityFresnelParameters", void 0),
  53617. k([Ie("reflectionFresnelParameters")], t.prototype, "_reflectionFresnelParameters", void 0),
  53618. k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "reflectionFresnelParameters", void 0),
  53619. k([Ie("refractionFresnelParameters")], t.prototype, "_refractionFresnelParameters", void 0),
  53620. k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "refractionFresnelParameters", void 0),
  53621. k([Ie("emissiveFresnelParameters")], t.prototype, "_emissiveFresnelParameters", void 0),
  53622. k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "emissiveFresnelParameters", void 0),
  53623. k([Ce("useReflectionFresnelFromSpecular")], t.prototype, "_useReflectionFresnelFromSpecular", void 0),
  53624. k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "useReflectionFresnelFromSpecular", void 0),
  53625. k([Ce("useGlossinessFromSpecularMapAlpha")], t.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
  53626. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
  53627. k([Ce("maxSimultaneousLights")], t.prototype, "_maxSimultaneousLights", void 0),
  53628. k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
  53629. k([Ce("invertNormalMapX")], t.prototype, "_invertNormalMapX", void 0),
  53630. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
  53631. k([Ce("invertNormalMapY")], t.prototype, "_invertNormalMapY", void 0),
  53632. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
  53633. k([Ce("twoSidedLighting")], t.prototype, "_twoSidedLighting", void 0),
  53634. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
  53635. k([Ce()], t.prototype, "useLogarithmicDepth", null),
  53636. t
  53637. }(gs);
  53638. y("BABYLON.StandardMaterial", Os),
  53639. mn.DefaultMaterialFactory = function(e) {
  53640. return new Os("default material",e)
  53641. }
  53642. ,
  53643. Ht.prototype.createDynamicTexture = function(e, t, i, n) {
  53644. var r = new Lt(this,At.Dynamic);
  53645. return r.baseWidth = e,
  53646. r.baseHeight = t,
  53647. i && (e = this.needPOTTextures ? Ht.GetExponentOfTwo(e, this._caps.maxTextureSize) : e,
  53648. t = this.needPOTTextures ? Ht.GetExponentOfTwo(t, this._caps.maxTextureSize) : t),
  53649. r.width = e,
  53650. r.height = t,
  53651. r.isReady = !1,
  53652. r.generateMipMaps = i,
  53653. r.samplingMode = n,
  53654. this.updateTextureSamplingMode(n, r),
  53655. this._internalTexturesCache.push(r),
  53656. r
  53657. }
  53658. ,
  53659. Ht.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
  53660. if (void 0 === n && (n = !1),
  53661. void 0 === o && (o = !1),
  53662. void 0 === a && (a = !1),
  53663. e) {
  53664. var s = this._gl
  53665. , l = s.TEXTURE_2D
  53666. , c = this._bindTextureDirectly(l, e, !0, o);
  53667. this._unpackFlipY(void 0 === i ? e.invertY : i),
  53668. n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  53669. var u = this._getWebGLTextureType(e.type)
  53670. , h = this._getInternalFormat(r || e.format)
  53671. , d = this._getRGBABufferInternalSizedFormat(e.type, h);
  53672. s.texImage2D(l, 0, d, h, u, t),
  53673. e.generateMipMaps && s.generateMipmap(l),
  53674. c || this._bindTextureDirectly(l, null),
  53675. n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
  53676. e.isReady = !0
  53677. }
  53678. }
  53679. ;
  53680. var Ds = function(e) {
  53681. function t(t, i, n, r, o, s, l) {
  53682. void 0 === n && (n = null),
  53683. void 0 === r && (r = !1),
  53684. void 0 === o && (o = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  53685. void 0 === s && (s = a.TEXTUREFORMAT_RGBA);
  53686. var c = e.call(this, null, n, !r, l, o, void 0, void 0, void 0, void 0, s) || this;
  53687. c.name = t,
  53688. c.wrapU = io.CLAMP_ADDRESSMODE,
  53689. c.wrapV = io.CLAMP_ADDRESSMODE,
  53690. c._generateMipMaps = r;
  53691. var u = c._getEngine();
  53692. if (!u)
  53693. return c;
  53694. i.getContext ? (c._canvas = i,
  53695. c._texture = u.createDynamicTexture(i.width, i.height, r, o)) : (c._canvas = u.createCanvas(1, 1),
  53696. i.width || 0 === i.width ? c._texture = u.createDynamicTexture(i.width, i.height, r, o) : c._texture = u.createDynamicTexture(i, i, r, o));
  53697. var h = c.getSize();
  53698. return c._canvas.width !== h.width && (c._canvas.width = h.width),
  53699. c._canvas.height !== h.height && (c._canvas.height = h.height),
  53700. c._context = c._canvas.getContext("2d"),
  53701. c
  53702. }
  53703. return U(t, e),
  53704. t.prototype.getClassName = function() {
  53705. return "DynamicTexture"
  53706. }
  53707. ,
  53708. Object.defineProperty(t.prototype, "canRescale", {
  53709. get: function() {
  53710. return !0
  53711. },
  53712. enumerable: !1,
  53713. configurable: !0
  53714. }),
  53715. t.prototype._recreate = function(e) {
  53716. this._canvas.width = e.width,
  53717. this._canvas.height = e.height,
  53718. this.releaseInternalTexture(),
  53719. this._texture = this._getEngine().createDynamicTexture(e.width, e.height, this._generateMipMaps, this.samplingMode)
  53720. }
  53721. ,
  53722. t.prototype.scale = function(e) {
  53723. var t = this.getSize();
  53724. t.width *= e,
  53725. t.height *= e,
  53726. this._recreate(t)
  53727. }
  53728. ,
  53729. t.prototype.scaleTo = function(e, t) {
  53730. var i = this.getSize();
  53731. i.width = e,
  53732. i.height = t,
  53733. this._recreate(i)
  53734. }
  53735. ,
  53736. t.prototype.getContext = function() {
  53737. return this._context
  53738. }
  53739. ,
  53740. t.prototype.clear = function() {
  53741. var e = this.getSize();
  53742. this._context.fillRect(0, 0, e.width, e.height)
  53743. }
  53744. ,
  53745. t.prototype.update = function(e, t, i) {
  53746. void 0 === t && (t = !1),
  53747. void 0 === i && (i = !1),
  53748. this._getEngine().updateDynamicTexture(this._texture, this._canvas, void 0 === e || e, t, this._format || void 0, void 0, i)
  53749. }
  53750. ,
  53751. t.prototype.drawText = function(e, t, i, n, r, o, a, s) {
  53752. void 0 === s && (s = !0);
  53753. var l = this.getSize();
  53754. if (o && (this._context.fillStyle = o,
  53755. this._context.fillRect(0, 0, l.width, l.height)),
  53756. this._context.font = n,
  53757. null == t) {
  53758. var c = this._context.measureText(e);
  53759. t = (l.width - c.width) / 2
  53760. }
  53761. if (null == i) {
  53762. var u = parseInt(n.replace(/\D/g, ""));
  53763. i = l.height / 2 + u / 3.65
  53764. }
  53765. this._context.fillStyle = r || "",
  53766. this._context.fillText(e, t, i),
  53767. s && this.update(a)
  53768. }
  53769. ,
  53770. t.prototype.clone = function() {
  53771. var e = this.getScene();
  53772. if (!e)
  53773. return this;
  53774. var i = this.getSize()
  53775. , n = new t(this.name,i,e,this._generateMipMaps);
  53776. return n.hasAlpha = this.hasAlpha,
  53777. n.level = this.level,
  53778. n.wrapU = this.wrapU,
  53779. n.wrapV = this.wrapV,
  53780. n
  53781. }
  53782. ,
  53783. t.prototype.serialize = function() {
  53784. var i = this.getScene();
  53785. i && !i.isReady() && K.Warn("The scene must be ready before serializing the dynamic texture");
  53786. var n = e.prototype.serialize.call(this);
  53787. return t._IsCanvasElement(this._canvas) && (n.base64String = this._canvas.toDataURL()),
  53788. n.invertY = this._invertY,
  53789. n.samplingMode = this.samplingMode,
  53790. n
  53791. }
  53792. ,
  53793. t._IsCanvasElement = function(e) {
  53794. return void 0 !== e.toDataURL
  53795. }
  53796. ,
  53797. t.prototype._rebuild = function() {
  53798. this.update()
  53799. }
  53800. ,
  53801. t
  53802. }(io);
  53803. Pt.ShadersStore.imageProcessingPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}";
  53804. var Ns, Ls, Fs = function(e) {
  53805. function t(t, i, n, r, o, s, l, c) {
  53806. void 0 === n && (n = null),
  53807. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
  53808. var u = e.call(this, t, "imageProcessing", [], [], i, n, r, o, s, null, l, "postprocess", null, !0) || this;
  53809. return u._fromLinearSpace = !0,
  53810. u._defines = {
  53811. IMAGEPROCESSING: !1,
  53812. VIGNETTE: !1,
  53813. VIGNETTEBLENDMODEMULTIPLY: !1,
  53814. VIGNETTEBLENDMODEOPAQUE: !1,
  53815. TONEMAPPING: !1,
  53816. TONEMAPPING_ACES: !1,
  53817. CONTRAST: !1,
  53818. COLORCURVES: !1,
  53819. COLORGRADING: !1,
  53820. COLORGRADING3D: !1,
  53821. FROMLINEARSPACE: !1,
  53822. SAMPLER3DGREENDEPTH: !1,
  53823. SAMPLER3DBGRMAP: !1,
  53824. IMAGEPROCESSINGPOSTPROCESS: !1,
  53825. EXPOSURE: !1,
  53826. SKIPFINALCOLORCLAMP: !1
  53827. },
  53828. c ? (c.applyByPostProcess = !0,
  53829. u._attachImageProcessingConfiguration(c, !0),
  53830. u._updateParameters()) : (u._attachImageProcessingConfiguration(null, !0),
  53831. u.imageProcessingConfiguration.applyByPostProcess = !0),
  53832. u.onApply = function(e) {
  53833. u.imageProcessingConfiguration.bind(e, u.aspectRatio)
  53834. }
  53835. ,
  53836. u
  53837. }
  53838. return U(t, e),
  53839. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  53840. get: function() {
  53841. return this._imageProcessingConfiguration
  53842. },
  53843. set: function(e) {
  53844. e.applyByPostProcess = !0,
  53845. this._attachImageProcessingConfiguration(e)
  53846. },
  53847. enumerable: !1,
  53848. configurable: !0
  53849. }),
  53850. t.prototype._attachImageProcessingConfiguration = function(e, t) {
  53851. var i = this;
  53852. if (void 0 === t && (t = !1),
  53853. e !== this._imageProcessingConfiguration) {
  53854. if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  53855. e)
  53856. this._imageProcessingConfiguration = e;
  53857. else {
  53858. var n = null
  53859. , r = this.getEngine()
  53860. , o = this.getCamera();
  53861. if (o)
  53862. n = o.getScene();
  53863. else if (r && r.scenes) {
  53864. var a = r.scenes;
  53865. n = a[a.length - 1]
  53866. } else
  53867. n = E.LastCreatedScene;
  53868. this._imageProcessingConfiguration = n ? n.imageProcessingConfiguration : new Ri
  53869. }
  53870. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
  53871. i._updateParameters()
  53872. }
  53873. ))),
  53874. t || this._updateParameters()
  53875. }
  53876. }
  53877. ,
  53878. Object.defineProperty(t.prototype, "isSupported", {
  53879. get: function() {
  53880. var e = this.getEffect();
  53881. return !e || e.isSupported
  53882. },
  53883. enumerable: !1,
  53884. configurable: !0
  53885. }),
  53886. Object.defineProperty(t.prototype, "colorCurves", {
  53887. get: function() {
  53888. return this.imageProcessingConfiguration.colorCurves
  53889. },
  53890. set: function(e) {
  53891. this.imageProcessingConfiguration.colorCurves = e
  53892. },
  53893. enumerable: !1,
  53894. configurable: !0
  53895. }),
  53896. Object.defineProperty(t.prototype, "colorCurvesEnabled", {
  53897. get: function() {
  53898. return this.imageProcessingConfiguration.colorCurvesEnabled
  53899. },
  53900. set: function(e) {
  53901. this.imageProcessingConfiguration.colorCurvesEnabled = e
  53902. },
  53903. enumerable: !1,
  53904. configurable: !0
  53905. }),
  53906. Object.defineProperty(t.prototype, "colorGradingTexture", {
  53907. get: function() {
  53908. return this.imageProcessingConfiguration.colorGradingTexture
  53909. },
  53910. set: function(e) {
  53911. this.imageProcessingConfiguration.colorGradingTexture = e
  53912. },
  53913. enumerable: !1,
  53914. configurable: !0
  53915. }),
  53916. Object.defineProperty(t.prototype, "colorGradingEnabled", {
  53917. get: function() {
  53918. return this.imageProcessingConfiguration.colorGradingEnabled
  53919. },
  53920. set: function(e) {
  53921. this.imageProcessingConfiguration.colorGradingEnabled = e
  53922. },
  53923. enumerable: !1,
  53924. configurable: !0
  53925. }),
  53926. Object.defineProperty(t.prototype, "exposure", {
  53927. get: function() {
  53928. return this.imageProcessingConfiguration.exposure
  53929. },
  53930. set: function(e) {
  53931. this.imageProcessingConfiguration.exposure = e
  53932. },
  53933. enumerable: !1,
  53934. configurable: !0
  53935. }),
  53936. Object.defineProperty(t.prototype, "toneMappingEnabled", {
  53937. get: function() {
  53938. return this._imageProcessingConfiguration.toneMappingEnabled
  53939. },
  53940. set: function(e) {
  53941. this._imageProcessingConfiguration.toneMappingEnabled = e
  53942. },
  53943. enumerable: !1,
  53944. configurable: !0
  53945. }),
  53946. Object.defineProperty(t.prototype, "toneMappingType", {
  53947. get: function() {
  53948. return this._imageProcessingConfiguration.toneMappingType
  53949. },
  53950. set: function(e) {
  53951. this._imageProcessingConfiguration.toneMappingType = e
  53952. },
  53953. enumerable: !1,
  53954. configurable: !0
  53955. }),
  53956. Object.defineProperty(t.prototype, "contrast", {
  53957. get: function() {
  53958. return this.imageProcessingConfiguration.contrast
  53959. },
  53960. set: function(e) {
  53961. this.imageProcessingConfiguration.contrast = e
  53962. },
  53963. enumerable: !1,
  53964. configurable: !0
  53965. }),
  53966. Object.defineProperty(t.prototype, "vignetteStretch", {
  53967. get: function() {
  53968. return this.imageProcessingConfiguration.vignetteStretch
  53969. },
  53970. set: function(e) {
  53971. this.imageProcessingConfiguration.vignetteStretch = e
  53972. },
  53973. enumerable: !1,
  53974. configurable: !0
  53975. }),
  53976. Object.defineProperty(t.prototype, "vignetteCentreX", {
  53977. get: function() {
  53978. return this.imageProcessingConfiguration.vignetteCentreX
  53979. },
  53980. set: function(e) {
  53981. this.imageProcessingConfiguration.vignetteCentreX = e
  53982. },
  53983. enumerable: !1,
  53984. configurable: !0
  53985. }),
  53986. Object.defineProperty(t.prototype, "vignetteCentreY", {
  53987. get: function() {
  53988. return this.imageProcessingConfiguration.vignetteCentreY
  53989. },
  53990. set: function(e) {
  53991. this.imageProcessingConfiguration.vignetteCentreY = e
  53992. },
  53993. enumerable: !1,
  53994. configurable: !0
  53995. }),
  53996. Object.defineProperty(t.prototype, "vignetteWeight", {
  53997. get: function() {
  53998. return this.imageProcessingConfiguration.vignetteWeight
  53999. },
  54000. set: function(e) {
  54001. this.imageProcessingConfiguration.vignetteWeight = e
  54002. },
  54003. enumerable: !1,
  54004. configurable: !0
  54005. }),
  54006. Object.defineProperty(t.prototype, "vignetteColor", {
  54007. get: function() {
  54008. return this.imageProcessingConfiguration.vignetteColor
  54009. },
  54010. set: function(e) {
  54011. this.imageProcessingConfiguration.vignetteColor = e
  54012. },
  54013. enumerable: !1,
  54014. configurable: !0
  54015. }),
  54016. Object.defineProperty(t.prototype, "vignetteCameraFov", {
  54017. get: function() {
  54018. return this.imageProcessingConfiguration.vignetteCameraFov
  54019. },
  54020. set: function(e) {
  54021. this.imageProcessingConfiguration.vignetteCameraFov = e
  54022. },
  54023. enumerable: !1,
  54024. configurable: !0
  54025. }),
  54026. Object.defineProperty(t.prototype, "vignetteBlendMode", {
  54027. get: function() {
  54028. return this.imageProcessingConfiguration.vignetteBlendMode
  54029. },
  54030. set: function(e) {
  54031. this.imageProcessingConfiguration.vignetteBlendMode = e
  54032. },
  54033. enumerable: !1,
  54034. configurable: !0
  54035. }),
  54036. Object.defineProperty(t.prototype, "vignetteEnabled", {
  54037. get: function() {
  54038. return this.imageProcessingConfiguration.vignetteEnabled
  54039. },
  54040. set: function(e) {
  54041. this.imageProcessingConfiguration.vignetteEnabled = e
  54042. },
  54043. enumerable: !1,
  54044. configurable: !0
  54045. }),
  54046. Object.defineProperty(t.prototype, "fromLinearSpace", {
  54047. get: function() {
  54048. return this._fromLinearSpace
  54049. },
  54050. set: function(e) {
  54051. this._fromLinearSpace !== e && (this._fromLinearSpace = e,
  54052. this._updateParameters())
  54053. },
  54054. enumerable: !1,
  54055. configurable: !0
  54056. }),
  54057. t.prototype.getClassName = function() {
  54058. return "ImageProcessingPostProcess"
  54059. }
  54060. ,
  54061. t.prototype._updateParameters = function() {
  54062. this._defines.FROMLINEARSPACE = this._fromLinearSpace,
  54063. this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
  54064. var e = "";
  54065. for (var t in this._defines)
  54066. this._defines[t] && (e += "#define ".concat(t, ";\r\n"));
  54067. var i = ["textureSampler"]
  54068. , n = ["scale"];
  54069. Ri && (Ri.PrepareSamplers(i, this._defines),
  54070. Ri.PrepareUniforms(n, this._defines)),
  54071. this.updateEffect(e, n, i)
  54072. }
  54073. ,
  54074. t.prototype.dispose = function(t) {
  54075. e.prototype.dispose.call(this, t),
  54076. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  54077. this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1)
  54078. }
  54079. ,
  54080. k([Ce()], t.prototype, "_fromLinearSpace", void 0),
  54081. t
  54082. }(Ba), ws = function() {
  54083. function e(e, t, i, n, r) {
  54084. this.getWidth = e,
  54085. this.getHeight = t,
  54086. this.layer = i,
  54087. this.layerType = n,
  54088. this.createRenderTargetTextureProvider = r
  54089. }
  54090. return Object.defineProperty(e.prototype, "isFixedFoveationSupported", {
  54091. get: function() {
  54092. return "XRWebGLLayer" == this.layerType && "number" == typeof this.layer.fixedFoveation
  54093. },
  54094. enumerable: !1,
  54095. configurable: !0
  54096. }),
  54097. Object.defineProperty(e.prototype, "fixedFoveation", {
  54098. get: function() {
  54099. return this.isFixedFoveationSupported ? this.layer.fixedFoveation : null
  54100. },
  54101. set: function(e) {
  54102. if (this.isFixedFoveationSupported) {
  54103. var t = Math.max(0, Math.min(1, e || 0));
  54104. this.layer.fixedFoveation = t
  54105. }
  54106. },
  54107. enumerable: !1,
  54108. configurable: !0
  54109. }),
  54110. e
  54111. }(), Bs = function() {
  54112. function e(e, t) {
  54113. this._scene = e,
  54114. this.layerWrapper = t,
  54115. this._renderTargetTextures = new Array,
  54116. this._engine = e.getEngine()
  54117. }
  54118. return e.prototype._createInternalTexture = function(e, t) {
  54119. var i = new Lt(this._engine,At.Unknown,!0);
  54120. return i.width = e.width,
  54121. i.height = e.height,
  54122. i._hardwareTexture = new kt(t,this._engine._gl),
  54123. i.isReady = !0,
  54124. i
  54125. }
  54126. ,
  54127. e.prototype._createRenderTargetTexture = function(e, t, i, n, r, o) {
  54128. if (!this._engine)
  54129. throw new Error("Engine is disposed");
  54130. var a = {
  54131. width: e,
  54132. height: t
  54133. }
  54134. , s = o ? new rs(this._scene,a) : new ns("XR renderTargetTexture",a,this._scene)
  54135. , l = s.renderTarget;
  54136. if (!i && n || (l._framebuffer = i),
  54137. n)
  54138. if (o)
  54139. l._colorTextureArray = n;
  54140. else {
  54141. var c = this._createInternalTexture(a, n);
  54142. l.setTexture(c, 0),
  54143. s._texture = c
  54144. }
  54145. return r && (o ? l._depthStencilTextureArray = r : l._depthStencilTexture = this._createInternalTexture(a, r)),
  54146. s.disableRescaling(),
  54147. "undefined" != typeof XRWebGLBinding && (s.skipInitialClear = !0),
  54148. this._renderTargetTextures.push(s),
  54149. s
  54150. }
  54151. ,
  54152. e.prototype._destroyRenderTargetTexture = function(e) {
  54153. this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e), 1),
  54154. e.dispose()
  54155. }
  54156. ,
  54157. e.prototype.getFramebufferDimensions = function() {
  54158. return this._framebufferDimensions
  54159. }
  54160. ,
  54161. e.prototype.dispose = function() {
  54162. this._renderTargetTextures.forEach((function(e) {
  54163. return e.dispose()
  54164. }
  54165. )),
  54166. this._renderTargetTextures.length = 0
  54167. }
  54168. ,
  54169. e
  54170. }(), Us = function(e) {
  54171. function t(t) {
  54172. var i = e.call(this, (function() {
  54173. return t.framebufferWidth
  54174. }
  54175. ), (function() {
  54176. return t.framebufferHeight
  54177. }
  54178. ), t, "XRWebGLLayer", (function(e) {
  54179. return new Vs(e.scene,i)
  54180. }
  54181. )) || this;
  54182. return i.layer = t,
  54183. i
  54184. }
  54185. return U(t, e),
  54186. t
  54187. }(ws), Vs = function(e) {
  54188. function t(t, i) {
  54189. var n = e.call(this, t, i) || this;
  54190. return n.layerWrapper = i,
  54191. n._layer = i.layer,
  54192. n._framebufferDimensions = {
  54193. framebufferWidth: n._layer.framebufferWidth,
  54194. framebufferHeight: n._layer.framebufferHeight
  54195. },
  54196. n
  54197. }
  54198. return U(t, e),
  54199. t.prototype.trySetViewportForView = function(e, t) {
  54200. var i = this._layer.getViewport(t)
  54201. , n = this._framebufferDimensions.framebufferWidth
  54202. , r = this._framebufferDimensions.framebufferHeight;
  54203. return e.x = i.x / n,
  54204. e.y = i.y / r,
  54205. e.width = i.width / n,
  54206. e.height = i.height / r,
  54207. !0
  54208. }
  54209. ,
  54210. t.prototype.getRenderTargetTextureForEye = function(e) {
  54211. var t = this._layer.framebufferWidth
  54212. , i = this._layer.framebufferHeight
  54213. , n = this._layer.framebuffer;
  54214. return this._rtt && t === this._framebufferDimensions.framebufferWidth && i === this._framebufferDimensions.framebufferHeight && n === this._framebuffer || (this._rtt = this._createRenderTargetTexture(t, i, n),
  54215. this._framebufferDimensions.framebufferWidth = t,
  54216. this._framebufferDimensions.framebufferHeight = i,
  54217. this._framebuffer = n),
  54218. this._rtt
  54219. }
  54220. ,
  54221. t.prototype.getRenderTargetTextureForView = function(e) {
  54222. return this.getRenderTargetTextureForEye(e.eye)
  54223. }
  54224. ,
  54225. t
  54226. }(Bs), ks = function() {
  54227. function e() {}
  54228. return e.GetDefaults = function(t) {
  54229. var i = new e;
  54230. return i.canvasOptions = {
  54231. antialias: !0,
  54232. depth: !0,
  54233. stencil: !t || t.isStencilEnable,
  54234. alpha: !0,
  54235. multiview: !1,
  54236. framebufferScaleFactor: 1
  54237. },
  54238. i.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",
  54239. i
  54240. }
  54241. ,
  54242. e
  54243. }(), Gs = function() {
  54244. function e(e, t) {
  54245. void 0 === t && (t = ks.GetDefaults());
  54246. var i = this;
  54247. if (this._options = t,
  54248. this._canvas = null,
  54249. this._engine = null,
  54250. this.xrLayer = null,
  54251. this._xrLayerWrapper = null,
  54252. this.onXRLayerInitObservable = new h,
  54253. this._engine = e.scene.getEngine(),
  54254. this._engine.onDisposeObservable.addOnce((function() {
  54255. i._engine = null
  54256. }
  54257. )),
  54258. t.canvasElement)
  54259. this._setManagedOutputCanvas(t.canvasElement);
  54260. else {
  54261. var n = document.createElement("canvas");
  54262. n.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;",
  54263. this._setManagedOutputCanvas(n)
  54264. }
  54265. e.onXRSessionInit.add((function() {
  54266. i._addCanvas()
  54267. }
  54268. )),
  54269. e.onXRSessionEnded.add((function() {
  54270. i._removeCanvas()
  54271. }
  54272. ))
  54273. }
  54274. return e.prototype.dispose = function() {
  54275. this._removeCanvas(),
  54276. this._setManagedOutputCanvas(null)
  54277. }
  54278. ,
  54279. e.prototype.initializeXRLayerAsync = function(e) {
  54280. return G(this, void 0, void 0, (function() {
  54281. var t, i = this;
  54282. return z(this, (function(n) {
  54283. return t = function() {
  54284. return i.xrLayer = new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions),
  54285. i._xrLayerWrapper = new Us(i.xrLayer),
  54286. i.onXRLayerInitObservable.notifyObservers(i.xrLayer),
  54287. i.xrLayer
  54288. }
  54289. ,
  54290. this.canvasContext.makeXRCompatible ? [2, this.canvasContext.makeXRCompatible().then((function() {}
  54291. ), (function() {
  54292. gi.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")
  54293. }
  54294. )).then((function() {
  54295. return t()
  54296. }
  54297. ))] : [2, Promise.resolve(t())]
  54298. }
  54299. ))
  54300. }
  54301. ))
  54302. }
  54303. ,
  54304. e.prototype._addCanvas = function() {
  54305. var e = this;
  54306. this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas() && document.body.appendChild(this._canvas),
  54307. this.xrLayer ? this._setCanvasSize(!0) : this.onXRLayerInitObservable.addOnce((function() {
  54308. e._setCanvasSize(!0)
  54309. }
  54310. ))
  54311. }
  54312. ,
  54313. e.prototype._removeCanvas = function() {
  54314. this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas() && document.body.removeChild(this._canvas),
  54315. this._setCanvasSize(!1)
  54316. }
  54317. ,
  54318. e.prototype._setCanvasSize = function(e, t) {
  54319. void 0 === e && (e = !0),
  54320. void 0 === t && (t = this._xrLayerWrapper),
  54321. this._canvas && this._engine && (e ? t && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = t.getWidth() + "px",
  54322. this._canvas.style.height = t.getHeight() + "px") : this._engine.setSize(t.getWidth(), t.getHeight())) : this._originalCanvasSize && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = this._originalCanvasSize.width + "px",
  54323. this._canvas.style.height = this._originalCanvasSize.height + "px") : this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height)))
  54324. }
  54325. ,
  54326. e.prototype._setManagedOutputCanvas = function(e) {
  54327. this._removeCanvas(),
  54328. e ? (this._originalCanvasSize = {
  54329. width: e.offsetWidth,
  54330. height: e.offsetHeight
  54331. },
  54332. this._canvas = e,
  54333. this.canvasContext = this._canvas.getContext("webgl2"),
  54334. this.canvasContext || (this.canvasContext = this._canvas.getContext("webgl"))) : (this._canvas = null,
  54335. this.canvasContext = null)
  54336. }
  54337. ,
  54338. e
  54339. }(), zs = function(e) {
  54340. function t(t) {
  54341. var i = e.call(this, (function() {
  54342. return t.framebufferWidth
  54343. }
  54344. ), (function() {
  54345. return t.framebufferHeight
  54346. }
  54347. ), t, "XRWebGLLayer", (function(e) {
  54348. return new Ws(e,i)
  54349. }
  54350. )) || this;
  54351. return i.layer = t,
  54352. i
  54353. }
  54354. return U(t, e),
  54355. t
  54356. }(ws), Ws = function(e) {
  54357. function t(t, i) {
  54358. var n = e.call(this, t.scene, i) || this;
  54359. return n.layerWrapper = i,
  54360. n._nativeRTTProvider = navigator.xr.getNativeRenderTargetProvider(t.session, n._createRenderTargetTexture.bind(n), n._destroyRenderTargetTexture.bind(n)),
  54361. n._nativeLayer = i.layer,
  54362. n
  54363. }
  54364. return U(t, e),
  54365. t.prototype.trySetViewportForView = function(e) {
  54366. return e.x = 0,
  54367. e.y = 0,
  54368. e.width = 1,
  54369. e.height = 1,
  54370. !0
  54371. }
  54372. ,
  54373. t.prototype.getRenderTargetTextureForEye = function(e) {
  54374. return this._nativeRTTProvider.getRenderTargetForEye(e)
  54375. }
  54376. ,
  54377. t.prototype.getRenderTargetTextureForView = function(e) {
  54378. return this._nativeRTTProvider.getRenderTargetForEye(e.eye)
  54379. }
  54380. ,
  54381. t.prototype.getFramebufferDimensions = function() {
  54382. return {
  54383. framebufferWidth: this._nativeLayer.framebufferWidth,
  54384. framebufferHeight: this._nativeLayer.framebufferHeight
  54385. }
  54386. }
  54387. ,
  54388. t
  54389. }(Bs), Hs = function() {
  54390. function e(e) {
  54391. this._nativeRenderTarget = navigator.xr.getWebXRRenderTarget(e.scene.getEngine())
  54392. }
  54393. return e.prototype.initializeXRLayerAsync = function(e) {
  54394. return G(this, void 0, void 0, (function() {
  54395. return z(this, (function(t) {
  54396. switch (t.label) {
  54397. case 0:
  54398. return [4, this._nativeRenderTarget.initializeXRLayerAsync(e)];
  54399. case 1:
  54400. return t.sent(),
  54401. this.xrLayer = this._nativeRenderTarget.xrLayer,
  54402. [2, this.xrLayer]
  54403. }
  54404. }
  54405. ))
  54406. }
  54407. ))
  54408. }
  54409. ,
  54410. e.prototype.dispose = function() {}
  54411. ,
  54412. e
  54413. }(), Xs = function() {
  54414. function e(e) {
  54415. var t = this;
  54416. this.scene = e,
  54417. this.currentTimestamp = -1,
  54418. this.defaultHeightCompensation = 1.7,
  54419. this.onXRFrameObservable = new h,
  54420. this.onXRReferenceSpaceChanged = new h,
  54421. this.onXRSessionEnded = new h,
  54422. this.onXRSessionInit = new h,
  54423. this.inXRFrameLoop = !1,
  54424. this.inXRSession = !1,
  54425. this._engine = e.getEngine(),
  54426. this._onEngineDisposedObserver = this._engine.onDisposeObservable.addOnce((function() {
  54427. t._engine = null
  54428. }
  54429. )),
  54430. e.onDisposeObservable.addOnce((function() {
  54431. t.dispose()
  54432. }
  54433. ))
  54434. }
  54435. return Object.defineProperty(e.prototype, "referenceSpace", {
  54436. get: function() {
  54437. return this._referenceSpace
  54438. },
  54439. set: function(e) {
  54440. this._referenceSpace = e,
  54441. this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)
  54442. },
  54443. enumerable: !1,
  54444. configurable: !0
  54445. }),
  54446. Object.defineProperty(e.prototype, "sessionMode", {
  54447. get: function() {
  54448. return this._sessionMode
  54449. },
  54450. enumerable: !1,
  54451. configurable: !0
  54452. }),
  54453. e.prototype.dispose = function() {
  54454. var e;
  54455. this.inXRSession && this.exitXRAsync(),
  54456. this.onXRFrameObservable.clear(),
  54457. this.onXRSessionEnded.clear(),
  54458. this.onXRReferenceSpaceChanged.clear(),
  54459. this.onXRSessionInit.clear(),
  54460. null === (e = this._engine) || void 0 === e || e.onDisposeObservable.remove(this._onEngineDisposedObserver),
  54461. this._engine = null
  54462. }
  54463. ,
  54464. e.prototype.exitXRAsync = function() {
  54465. return this.session && this.inXRSession ? (this.inXRSession = !1,
  54466. this.session.end().catch((function() {
  54467. K.Warn("Could not end XR session.")
  54468. }
  54469. ))) : Promise.resolve()
  54470. }
  54471. ,
  54472. e.prototype.trySetViewportForView = function(e, t) {
  54473. var i;
  54474. return (null === (i = this._baseLayerRTTProvider) || void 0 === i ? void 0 : i.trySetViewportForView(e, t)) || !1
  54475. }
  54476. ,
  54477. e.prototype.getRenderTargetTextureForEye = function(e) {
  54478. var t;
  54479. return (null === (t = this._baseLayerRTTProvider) || void 0 === t ? void 0 : t.getRenderTargetTextureForEye(e)) || null
  54480. }
  54481. ,
  54482. e.prototype.getRenderTargetTextureForView = function(e) {
  54483. var t;
  54484. return (null === (t = this._baseLayerRTTProvider) || void 0 === t ? void 0 : t.getRenderTargetTextureForView(e)) || null
  54485. }
  54486. ,
  54487. e.prototype.getWebXRRenderTarget = function(e) {
  54488. var t = this.scene.getEngine();
  54489. return this._xrNavigator.xr.native ? new Hs(this) : ((e = e || ks.GetDefaults(t)).canvasElement = e.canvasElement || t.getRenderingCanvas() || void 0,
  54490. new Gs(this,e))
  54491. }
  54492. ,
  54493. e.prototype.initializeAsync = function() {
  54494. return this._xrNavigator = navigator,
  54495. this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available")
  54496. }
  54497. ,
  54498. e.prototype.initializeSessionAsync = function(e, t) {
  54499. var i = this;
  54500. return void 0 === e && (e = "immersive-vr"),
  54501. void 0 === t && (t = {}),
  54502. this._xrNavigator.xr.requestSession(e, t).then((function(t) {
  54503. return i.session = t,
  54504. i._sessionMode = e,
  54505. i.onXRSessionInit.notifyObservers(t),
  54506. i.inXRSession = !0,
  54507. i.session.addEventListener("end", (function() {
  54508. var e;
  54509. i.inXRSession = !1,
  54510. i.onXRSessionEnded.notifyObservers(null),
  54511. i._engine && (i._engine.framebufferDimensionsObject = null,
  54512. i._engine.restoreDefaultFramebuffer(),
  54513. i._engine.customAnimationFrameRequester = null,
  54514. i._engine._renderLoop()),
  54515. i.isNative && (null === (e = i._baseLayerRTTProvider) || void 0 === e || e.dispose()),
  54516. i._baseLayerRTTProvider = null,
  54517. i._baseLayerWrapper = null
  54518. }
  54519. ), {
  54520. once: !0
  54521. }),
  54522. i.session
  54523. }
  54524. ))
  54525. }
  54526. ,
  54527. e.prototype.isSessionSupportedAsync = function(t) {
  54528. return e.IsSessionSupportedAsync(t)
  54529. }
  54530. ,
  54531. e.prototype.resetReferenceSpace = function() {
  54532. this.referenceSpace = this.baseReferenceSpace
  54533. }
  54534. ,
  54535. e.prototype.runXRRenderLoop = function() {
  54536. var e, t = this;
  54537. this.inXRSession && this._engine && (this._engine.customAnimationFrameRequester = {
  54538. requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
  54539. renderFunction: function(e, i) {
  54540. var n;
  54541. t.inXRSession && t._engine && (t.currentFrame = i,
  54542. t.currentTimestamp = e,
  54543. i && (t.inXRFrameLoop = !0,
  54544. t._engine.framebufferDimensionsObject = (null === (n = t._baseLayerRTTProvider) || void 0 === n ? void 0 : n.getFramebufferDimensions()) || null,
  54545. t.onXRFrameObservable.notifyObservers(i),
  54546. t._engine._renderLoop(),
  54547. t._engine.framebufferDimensionsObject = null,
  54548. t.inXRFrameLoop = !1))
  54549. }
  54550. },
  54551. this._engine.framebufferDimensionsObject = (null === (e = this._baseLayerRTTProvider) || void 0 === e ? void 0 : e.getFramebufferDimensions()) || null,
  54552. "undefined" != typeof window && window.cancelAnimationFrame && window.cancelAnimationFrame(this._engine._frameHandler),
  54553. this._engine._renderLoop())
  54554. }
  54555. ,
  54556. e.prototype.setReferenceSpaceTypeAsync = function(e) {
  54557. var t = this;
  54558. return void 0 === e && (e = "local-floor"),
  54559. this.session.requestReferenceSpace(e).then((function(e) {
  54560. return e
  54561. }
  54562. ), (function(e) {
  54563. return K.Error("XR.requestReferenceSpace failed for the following reason: "),
  54564. K.Error(e),
  54565. K.Log('Defaulting to universally-supported "viewer" reference space type.'),
  54566. t.session.requestReferenceSpace("viewer").then((function(e) {
  54567. var i = new XRRigidTransform({
  54568. x: 0,
  54569. y: -t.defaultHeightCompensation,
  54570. z: 0
  54571. });
  54572. return e.getOffsetReferenceSpace(i)
  54573. }
  54574. ), (function(e) {
  54575. throw K.Error(e),
  54576. 'XR initialization failed: required "viewer" reference space type not supported.'
  54577. }
  54578. ))
  54579. }
  54580. )).then((function(e) {
  54581. return t.session.requestReferenceSpace("viewer").then((function(i) {
  54582. return t.viewerReferenceSpace = i,
  54583. e
  54584. }
  54585. ))
  54586. }
  54587. )).then((function(e) {
  54588. return t.referenceSpace = t.baseReferenceSpace = e,
  54589. t.referenceSpace
  54590. }
  54591. ))
  54592. }
  54593. ,
  54594. e.prototype.updateRenderStateAsync = function(e) {
  54595. return Promise.resolve(this.session.updateRenderState(e))
  54596. }
  54597. ,
  54598. e.prototype._setBaseLayerWrapper = function(e) {
  54599. var t, i;
  54600. this.isNative && (null === (t = this._baseLayerRTTProvider) || void 0 === t || t.dispose()),
  54601. this._baseLayerWrapper = e,
  54602. this._baseLayerRTTProvider = (null === (i = this._baseLayerWrapper) || void 0 === i ? void 0 : i.createRenderTargetTextureProvider(this)) || null
  54603. }
  54604. ,
  54605. e.prototype.updateRenderState = function(e) {
  54606. e.baseLayer && this._setBaseLayerWrapper(this.isNative ? new zs(e.baseLayer) : new Us(e.baseLayer)),
  54607. this.session.updateRenderState(e)
  54608. }
  54609. ,
  54610. e.IsSessionSupportedAsync = function(e) {
  54611. if (!navigator.xr)
  54612. return Promise.resolve(!1);
  54613. var t = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
  54614. return t ? t.call(navigator.xr, e).then((function(e) {
  54615. var t = void 0 === e || e;
  54616. return Promise.resolve(t)
  54617. }
  54618. )).catch((function(e) {
  54619. return K.Warn(e),
  54620. Promise.resolve(!1)
  54621. }
  54622. )) : Promise.resolve(!1)
  54623. }
  54624. ,
  54625. Object.defineProperty(e.prototype, "isNative", {
  54626. get: function() {
  54627. var e;
  54628. return null !== (e = this._xrNavigator.xr.native) && void 0 !== e && e
  54629. },
  54630. enumerable: !1,
  54631. configurable: !0
  54632. }),
  54633. Object.defineProperty(e.prototype, "currentFrameRate", {
  54634. get: function() {
  54635. var e;
  54636. return null === (e = this.session) || void 0 === e ? void 0 : e.frameRate
  54637. },
  54638. enumerable: !1,
  54639. configurable: !0
  54640. }),
  54641. Object.defineProperty(e.prototype, "supportedFrameRates", {
  54642. get: function() {
  54643. var e;
  54644. return null === (e = this.session) || void 0 === e ? void 0 : e.supportedFrameRates
  54645. },
  54646. enumerable: !1,
  54647. configurable: !0
  54648. }),
  54649. e.prototype.updateTargetFrameRate = function(e) {
  54650. return this.session.updateTargetFrameRate(e)
  54651. }
  54652. ,
  54653. e.prototype.runInXRFrame = function(e, t) {
  54654. void 0 === t && (t = !0),
  54655. this.inXRFrameLoop ? e() : !this.inXRSession && t || this.onXRFrameObservable.addOnce(e)
  54656. }
  54657. ,
  54658. Object.defineProperty(e.prototype, "isFixedFoveationSupported", {
  54659. get: function() {
  54660. var e;
  54661. return (null === (e = this._baseLayerWrapper) || void 0 === e ? void 0 : e.isFixedFoveationSupported) || !1
  54662. },
  54663. enumerable: !1,
  54664. configurable: !0
  54665. }),
  54666. Object.defineProperty(e.prototype, "fixedFoveation", {
  54667. get: function() {
  54668. var e;
  54669. return (null === (e = this._baseLayerWrapper) || void 0 === e ? void 0 : e.fixedFoveation) || null
  54670. },
  54671. set: function(e) {
  54672. var t = Math.max(0, Math.min(1, e || 0));
  54673. this._baseLayerWrapper && (this._baseLayerWrapper.fixedFoveation = t)
  54674. },
  54675. enumerable: !1,
  54676. configurable: !0
  54677. }),
  54678. e
  54679. }();
  54680. function js(e) {
  54681. var t = e.height || 2
  54682. , i = 0 === e.diameterTop ? 0 : e.diameterTop || e.diameter || 1
  54683. , n = 0 === e.diameterBottom ? 0 : e.diameterBottom || e.diameter || 1;
  54684. i = i || 1e-5,
  54685. n = n || 1e-5;
  54686. var r, o = e.tessellation || 24, a = e.subdivisions || 1, s = !!e.hasRings, l = !!e.enclose, c = 0 === e.cap ? 0 : e.cap || Vr.CAP_ALL, u = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = e.faceUV || new Array(3), p = e.faceColors, f = 2 + (1 + (1 !== u && l ? 2 : 0)) * (s ? a : 1);
  54687. for (r = 0; r < f; r++)
  54688. p && void 0 === p[r] && (p[r] = new N(1,1,1,1));
  54689. for (r = 0; r < f; r++)
  54690. d && void 0 === d[r] && (d[r] = new R(0,0,1,1));
  54691. var _, m, g, v, y, b, T = new Array, E = new Array, S = new Array, C = new Array, P = new Array, M = 2 * Math.PI * u / o, I = (n - i) / 2 / t, O = x.Zero(), D = x.Zero(), L = x.Zero(), F = x.Zero(), w = x.Zero(), B = vn.Y, U = 1, V = 1, k = 0, G = 0;
  54692. for (v = 0; v <= a; v++)
  54693. for (g = ((m = v / a) * (i - n) + n) / 2,
  54694. U = s && 0 !== v && v !== a ? 2 : 1,
  54695. b = 0; b < U; b++) {
  54696. for (s && (V += b),
  54697. l && (V += 2 * b),
  54698. y = 0; y <= o; y++)
  54699. _ = y * M,
  54700. O.x = Math.cos(-_) * g,
  54701. O.y = -t / 2 + m * t,
  54702. O.z = Math.sin(-_) * g,
  54703. 0 === i && v === a ? (D.x = S[S.length - 3 * (o + 1)],
  54704. D.y = S[S.length - 3 * (o + 1) + 1],
  54705. D.z = S[S.length - 3 * (o + 1) + 2]) : (D.x = O.x,
  54706. D.z = O.z,
  54707. D.y = Math.sqrt(D.x * D.x + D.z * D.z) * I,
  54708. D.normalize()),
  54709. 0 === y && (L.copyFrom(O),
  54710. F.copyFrom(D)),
  54711. E.push(O.x, O.y, O.z),
  54712. S.push(D.x, D.y, D.z),
  54713. G = s ? k !== V ? d[V].y : d[V].w : d[V].y + (d[V].w - d[V].y) * m,
  54714. C.push(d[V].x + (d[V].z - d[V].x) * y / o, pr.UseOpenGLOrientationForUV ? 1 - G : G),
  54715. p && P.push(p[V].r, p[V].g, p[V].b, p[V].a);
  54716. 1 !== u && l && (E.push(O.x, O.y, O.z),
  54717. E.push(0, O.y, 0),
  54718. E.push(0, O.y, 0),
  54719. E.push(L.x, L.y, L.z),
  54720. x.CrossToRef(B, D, w),
  54721. w.normalize(),
  54722. S.push(w.x, w.y, w.z, w.x, w.y, w.z),
  54723. x.CrossToRef(F, B, w),
  54724. w.normalize(),
  54725. S.push(w.x, w.y, w.z, w.x, w.y, w.z),
  54726. G = s ? k !== V ? d[V + 1].y : d[V + 1].w : d[V + 1].y + (d[V + 1].w - d[V + 1].y) * m,
  54727. C.push(d[V + 1].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
  54728. C.push(d[V + 1].z, pr.UseOpenGLOrientationForUV ? 1 - G : G),
  54729. G = s ? k !== V ? d[V + 2].y : d[V + 2].w : d[V + 2].y + (d[V + 2].w - d[V + 2].y) * m,
  54730. C.push(d[V + 2].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
  54731. C.push(d[V + 2].z, pr.UseOpenGLOrientationForUV ? 1 - G : G),
  54732. p && (P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a),
  54733. P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a),
  54734. P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a),
  54735. P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a))),
  54736. k !== V && (k = V)
  54737. }
  54738. var z = 1 !== u && l ? o + 4 : o;
  54739. for (v = 0,
  54740. V = 0; V < a; V++) {
  54741. var W = 0
  54742. , H = 0
  54743. , X = 0
  54744. , j = 0;
  54745. for (y = 0; y < o; y++)
  54746. W = v * (z + 1) + y,
  54747. H = (v + 1) * (z + 1) + y,
  54748. X = v * (z + 1) + (y + 1),
  54749. j = (v + 1) * (z + 1) + (y + 1),
  54750. T.push(W, H, X),
  54751. T.push(j, X, H);
  54752. 1 !== u && l && (T.push(W + 2, H + 2, X + 2),
  54753. T.push(j + 2, X + 2, H + 2),
  54754. T.push(W + 4, H + 4, X + 4),
  54755. T.push(j + 4, X + 4, H + 4)),
  54756. v = s ? v + 2 : v + 1
  54757. }
  54758. var Y = function(e) {
  54759. var r = e ? i / 2 : n / 2;
  54760. if (0 !== r) {
  54761. var a, s, l, c = e ? d[f - 1] : d[0], h = null;
  54762. p && (h = e ? p[f - 1] : p[0]);
  54763. var _ = E.length / 3
  54764. , m = e ? t / 2 : -t / 2
  54765. , g = new x(0,m,0);
  54766. E.push(g.x, g.y, g.z),
  54767. S.push(0, e ? 1 : -1, 0);
  54768. var v = c.y + .5 * (c.w - c.y);
  54769. C.push(c.x + .5 * (c.z - c.x), pr.UseOpenGLOrientationForUV ? 1 - v : v),
  54770. h && P.push(h.r, h.g, h.b, h.a);
  54771. var y = new A(.5,.5);
  54772. for (l = 0; l <= o; l++) {
  54773. a = 2 * Math.PI * l * u / o;
  54774. var b = Math.cos(-a)
  54775. , R = Math.sin(-a);
  54776. s = new x(b * r,m,R * r);
  54777. var M = new A(b * y.x + .5,R * y.y + .5);
  54778. E.push(s.x, s.y, s.z),
  54779. S.push(0, e ? 1 : -1, 0);
  54780. var I = c.y + (c.w - c.y) * M.y;
  54781. C.push(c.x + (c.z - c.x) * M.x, pr.UseOpenGLOrientationForUV ? 1 - I : I),
  54782. h && P.push(h.r, h.g, h.b, h.a)
  54783. }
  54784. for (l = 0; l < o; l++)
  54785. e ? (T.push(_),
  54786. T.push(_ + (l + 2)),
  54787. T.push(_ + (l + 1))) : (T.push(_),
  54788. T.push(_ + (l + 1)),
  54789. T.push(_ + (l + 2)))
  54790. }
  54791. };
  54792. c !== Vr.CAP_START && c !== Vr.CAP_ALL || Y(!1),
  54793. c !== Vr.CAP_END && c !== Vr.CAP_ALL || Y(!0),
  54794. $n._ComputeSides(h, E, T, S, C, e.frontUVs, e.backUVs);
  54795. var K = new $n;
  54796. return K.indices = T,
  54797. K.positions = E,
  54798. K.normals = S,
  54799. K.uvs = C,
  54800. p && (K.colors = P),
  54801. K
  54802. }
  54803. function Ys(e, t, i) {
  54804. void 0 === t && (t = {});
  54805. var n = new Vr(e,i);
  54806. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  54807. n._originalBuilderSideOrientation = t.sideOrientation,
  54808. js(t).applyToMesh(n, t.updatable),
  54809. n
  54810. }
  54811. !function(e) {
  54812. e[e.ENTERING_XR = 0] = "ENTERING_XR",
  54813. e[e.EXITING_XR = 1] = "EXITING_XR",
  54814. e[e.IN_XR = 2] = "IN_XR",
  54815. e[e.NOT_IN_XR = 3] = "NOT_IN_XR"
  54816. }(Ns || (Ns = {})),
  54817. function(e) {
  54818. e[e.NOT_TRACKING = 0] = "NOT_TRACKING",
  54819. e[e.TRACKING_LOST = 1] = "TRACKING_LOST",
  54820. e[e.TRACKING = 2] = "TRACKING"
  54821. }(Ls || (Ls = {}));
  54822. var Ks = {
  54823. CreateCylinder: Ys
  54824. };
  54825. function Qs(e) {
  54826. for (var t = [], i = [], n = [], r = [], o = e.diameter || 1, a = e.thickness || .5, s = e.tessellation || 16, l = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, c = s + 1, u = 0; u <= s; u++)
  54827. for (var h = u / s, d = u * Math.PI * 2 / s - Math.PI / 2, p = P.Translation(o / 2, 0, 0).multiply(P.RotationY(d)), f = 0; f <= s; f++) {
  54828. var _ = 1 - f / s
  54829. , m = f * Math.PI * 2 / s + Math.PI
  54830. , g = Math.cos(m)
  54831. , v = Math.sin(m)
  54832. , y = new x(g,v,0)
  54833. , b = y.scale(a / 2)
  54834. , T = new A(h,_);
  54835. b = x.TransformCoordinates(b, p),
  54836. y = x.TransformNormal(y, p),
  54837. i.push(b.x, b.y, b.z),
  54838. n.push(y.x, y.y, y.z),
  54839. r.push(T.x, pr.UseOpenGLOrientationForUV ? 1 - T.y : T.y);
  54840. var E = (u + 1) % c
  54841. , S = (f + 1) % c;
  54842. t.push(u * c + f),
  54843. t.push(u * c + S),
  54844. t.push(E * c + f),
  54845. t.push(u * c + S),
  54846. t.push(E * c + S),
  54847. t.push(E * c + f)
  54848. }
  54849. $n._ComputeSides(l, i, t, n, r, e.frontUVs, e.backUVs);
  54850. var R = new $n;
  54851. return R.indices = t,
  54852. R.positions = i,
  54853. R.normals = n,
  54854. R.uvs = r,
  54855. R
  54856. }
  54857. function qs(e, t, i) {
  54858. void 0 === t && (t = {});
  54859. var n = new Vr(e,i);
  54860. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  54861. n._originalBuilderSideOrientation = t.sideOrientation,
  54862. Qs(t).applyToMesh(n, t.updatable),
  54863. n
  54864. }
  54865. $n.CreateCylinder = js,
  54866. Vr.CreateCylinder = function(e, t, i, n, r, o, a, s, l) {
  54867. return void 0 !== a && a instanceof mn || (void 0 !== a && (l = s || Vr.DEFAULTSIDE,
  54868. s = a),
  54869. a = o,
  54870. o = 1),
  54871. Ys(e, {
  54872. height: t,
  54873. diameterTop: i,
  54874. diameterBottom: n,
  54875. tessellation: r,
  54876. subdivisions: o,
  54877. sideOrientation: l,
  54878. updatable: s
  54879. }, a)
  54880. }
  54881. ;
  54882. var Zs = {
  54883. CreateTorus: qs
  54884. };
  54885. $n.CreateTorus = Qs,
  54886. Vr.CreateTorus = function(e, t, i, n, r, o, a) {
  54887. return qs(e, {
  54888. diameter: t,
  54889. thickness: i,
  54890. tessellation: n,
  54891. sideOrientation: a,
  54892. updatable: o
  54893. }, r)
  54894. }
  54895. ,
  54896. Vr._GroundMeshParser = function(e, t) {
  54897. return Js.Parse(e, t)
  54898. }
  54899. ;
  54900. var Js = function(e) {
  54901. function t(t, i) {
  54902. var n = e.call(this, t, i) || this;
  54903. return n.generateOctree = !1,
  54904. n
  54905. }
  54906. return U(t, e),
  54907. t.prototype.getClassName = function() {
  54908. return "GroundMesh"
  54909. }
  54910. ,
  54911. Object.defineProperty(t.prototype, "subdivisions", {
  54912. get: function() {
  54913. return Math.min(this._subdivisionsX, this._subdivisionsY)
  54914. },
  54915. enumerable: !1,
  54916. configurable: !0
  54917. }),
  54918. Object.defineProperty(t.prototype, "subdivisionsX", {
  54919. get: function() {
  54920. return this._subdivisionsX
  54921. },
  54922. enumerable: !1,
  54923. configurable: !0
  54924. }),
  54925. Object.defineProperty(t.prototype, "subdivisionsY", {
  54926. get: function() {
  54927. return this._subdivisionsY
  54928. },
  54929. enumerable: !1,
  54930. configurable: !0
  54931. }),
  54932. t.prototype.optimize = function(e, t) {
  54933. void 0 === t && (t = 32),
  54934. this._subdivisionsX = e,
  54935. this._subdivisionsY = e,
  54936. this.subdivide(e),
  54937. this.createOrUpdateSubmeshesOctree && this.createOrUpdateSubmeshesOctree(t)
  54938. }
  54939. ,
  54940. t.prototype.getHeightAtCoordinates = function(e, t) {
  54941. var i = this.getWorldMatrix()
  54942. , n = I.Matrix[5];
  54943. i.invertToRef(n);
  54944. var r = I.Vector3[8];
  54945. if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, n, r),
  54946. e = r.x,
  54947. t = r.z,
  54948. e < this._minX || e > this._maxX || t < this._minZ || t > this._maxZ)
  54949. return this.position.y;
  54950. this._heightQuads && 0 != this._heightQuads.length || (this._initHeightQuads(),
  54951. this._computeHeightQuads());
  54952. var o = this._getFacetAt(e, t)
  54953. , a = -(o.x * e + o.z * t + o.w) / o.y;
  54954. return x.TransformCoordinatesFromFloatsToRef(0, a, 0, i, r),
  54955. r.y
  54956. }
  54957. ,
  54958. t.prototype.getNormalAtCoordinates = function(e, t) {
  54959. var i = new x(0,1,0);
  54960. return this.getNormalAtCoordinatesToRef(e, t, i),
  54961. i
  54962. }
  54963. ,
  54964. t.prototype.getNormalAtCoordinatesToRef = function(e, t, i) {
  54965. var n = this.getWorldMatrix()
  54966. , r = I.Matrix[5];
  54967. n.invertToRef(r);
  54968. var o = I.Vector3[8];
  54969. if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, r, o),
  54970. e = o.x,
  54971. t = o.z,
  54972. e < this._minX || e > this._maxX || t < this._minZ || t > this._maxZ)
  54973. return this;
  54974. this._heightQuads && 0 != this._heightQuads.length || (this._initHeightQuads(),
  54975. this._computeHeightQuads());
  54976. var a = this._getFacetAt(e, t);
  54977. return x.TransformNormalFromFloatsToRef(a.x, a.y, a.z, n, i),
  54978. this
  54979. }
  54980. ,
  54981. t.prototype.updateCoordinateHeights = function() {
  54982. return this._heightQuads && 0 != this._heightQuads.length || this._initHeightQuads(),
  54983. this._computeHeightQuads(),
  54984. this
  54985. }
  54986. ,
  54987. t.prototype._getFacetAt = function(e, t) {
  54988. var i = Math.floor((e + this._maxX) * this._subdivisionsX / this._width)
  54989. , n = Math.floor(-(t + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY)
  54990. , r = this._heightQuads[n * this._subdivisionsX + i];
  54991. return t < r.slope.x * e + r.slope.y ? r.facet1 : r.facet2
  54992. }
  54993. ,
  54994. t.prototype._initHeightQuads = function() {
  54995. var e = this._subdivisionsX
  54996. , t = this._subdivisionsY;
  54997. this._heightQuads = new Array;
  54998. for (var i = 0; i < t; i++)
  54999. for (var n = 0; n < e; n++) {
  55000. var r = {
  55001. slope: A.Zero(),
  55002. facet1: new R(0,0,0,0),
  55003. facet2: new R(0,0,0,0)
  55004. };
  55005. this._heightQuads[i * e + n] = r
  55006. }
  55007. return this
  55008. }
  55009. ,
  55010. t.prototype._computeHeightQuads = function() {
  55011. var e = this.getVerticesData(Bi.PositionKind);
  55012. if (!e)
  55013. return this;
  55014. for (var t = I.Vector3[3], i = I.Vector3[2], n = I.Vector3[1], r = I.Vector3[0], o = I.Vector3[4], a = I.Vector3[5], s = I.Vector3[6], l = I.Vector3[7], c = I.Vector3[8], u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0, m = 0, g = this._subdivisionsX, v = this._subdivisionsY, y = 0; y < v; y++)
  55015. for (var b = 0; b < g; b++) {
  55016. u = 3 * b,
  55017. h = y * (g + 1) * 3,
  55018. d = (y + 1) * (g + 1) * 3,
  55019. t.x = e[h + u],
  55020. t.y = e[h + u + 1],
  55021. t.z = e[h + u + 2],
  55022. i.x = e[h + u + 3],
  55023. i.y = e[h + u + 4],
  55024. i.z = e[h + u + 5],
  55025. n.x = e[d + u],
  55026. n.y = e[d + u + 1],
  55027. n.z = e[d + u + 2],
  55028. r.x = e[d + u + 3],
  55029. r.y = e[d + u + 4],
  55030. r.z = e[d + u + 5],
  55031. p = (r.z - t.z) / (r.x - t.x),
  55032. f = t.z - p * t.x,
  55033. i.subtractToRef(t, o),
  55034. n.subtractToRef(t, a),
  55035. r.subtractToRef(t, s),
  55036. x.CrossToRef(s, a, l),
  55037. x.CrossToRef(o, s, c),
  55038. l.normalize(),
  55039. c.normalize(),
  55040. _ = -(l.x * t.x + l.y * t.y + l.z * t.z),
  55041. m = -(c.x * i.x + c.y * i.y + c.z * i.z);
  55042. var T = this._heightQuads[y * g + b];
  55043. T.slope.copyFromFloats(p, f),
  55044. T.facet1.copyFromFloats(l.x, l.y, l.z, _),
  55045. T.facet2.copyFromFloats(c.x, c.y, c.z, m)
  55046. }
  55047. return this
  55048. }
  55049. ,
  55050. t.prototype.serialize = function(t) {
  55051. e.prototype.serialize.call(this, t),
  55052. t.subdivisionsX = this._subdivisionsX,
  55053. t.subdivisionsY = this._subdivisionsY,
  55054. t.minX = this._minX,
  55055. t.maxX = this._maxX,
  55056. t.minZ = this._minZ,
  55057. t.maxZ = this._maxZ,
  55058. t.width = this._width,
  55059. t.height = this._height
  55060. }
  55061. ,
  55062. t.Parse = function(e, i) {
  55063. var n = new t(e.name,i);
  55064. return n._subdivisionsX = e.subdivisionsX || 1,
  55065. n._subdivisionsY = e.subdivisionsY || 1,
  55066. n._minX = e.minX,
  55067. n._maxX = e.maxX,
  55068. n._minZ = e.minZ,
  55069. n._maxZ = e.maxZ,
  55070. n._width = e.width,
  55071. n._height = e.height,
  55072. n
  55073. }
  55074. ,
  55075. t
  55076. }(Vr);
  55077. function $s(e) {
  55078. var t, i, n = [], r = [], o = [], a = [], s = e.width || 1, l = e.height || 1, c = e.subdivisionsX || e.subdivisions || 1, u = e.subdivisionsY || e.subdivisions || 1;
  55079. for (t = 0; t <= u; t++)
  55080. for (i = 0; i <= c; i++) {
  55081. var h = new x(i * s / c - s / 2,0,(u - t) * l / u - l / 2)
  55082. , d = new x(0,1,0);
  55083. r.push(h.x, h.y, h.z),
  55084. o.push(d.x, d.y, d.z),
  55085. a.push(i / c, pr.UseOpenGLOrientationForUV ? t / u : 1 - t / u)
  55086. }
  55087. for (t = 0; t < u; t++)
  55088. for (i = 0; i < c; i++)
  55089. n.push(i + 1 + (t + 1) * (c + 1)),
  55090. n.push(i + 1 + t * (c + 1)),
  55091. n.push(i + t * (c + 1)),
  55092. n.push(i + (t + 1) * (c + 1)),
  55093. n.push(i + 1 + (t + 1) * (c + 1)),
  55094. n.push(i + t * (c + 1));
  55095. var p = new $n;
  55096. return p.indices = n,
  55097. p.positions = r,
  55098. p.normals = o,
  55099. p.uvs = a,
  55100. p
  55101. }
  55102. function el(e) {
  55103. var t, i, n, r, o = void 0 !== e.xmin && null !== e.xmin ? e.xmin : -1, a = void 0 !== e.zmin && null !== e.zmin ? e.zmin : -1, s = void 0 !== e.xmax && null !== e.xmax ? e.xmax : 1, l = void 0 !== e.zmax && null !== e.zmax ? e.zmax : 1, c = e.subdivisions || {
  55104. w: 1,
  55105. h: 1
  55106. }, u = e.precision || {
  55107. w: 1,
  55108. h: 1
  55109. }, h = new Array, d = new Array, p = new Array, f = new Array;
  55110. c.h = c.h < 1 ? 1 : c.h,
  55111. c.w = c.w < 1 ? 1 : c.w,
  55112. u.w = u.w < 1 ? 1 : u.w,
  55113. u.h = u.h < 1 ? 1 : u.h;
  55114. var _ = (s - o) / c.w
  55115. , m = (l - a) / c.h;
  55116. function g(e, n, r, o) {
  55117. var a = d.length / 3
  55118. , s = u.w + 1;
  55119. for (t = 0; t < u.h; t++)
  55120. for (i = 0; i < u.w; i++) {
  55121. var l = [a + i + t * s, a + (i + 1) + t * s, a + (i + 1) + (t + 1) * s, a + i + (t + 1) * s];
  55122. h.push(l[1]),
  55123. h.push(l[2]),
  55124. h.push(l[3]),
  55125. h.push(l[0]),
  55126. h.push(l[1]),
  55127. h.push(l[3])
  55128. }
  55129. var c = x.Zero()
  55130. , _ = new x(0,1,0);
  55131. for (t = 0; t <= u.h; t++)
  55132. for (c.z = t * (o - n) / u.h + n,
  55133. i = 0; i <= u.w; i++)
  55134. c.x = i * (r - e) / u.w + e,
  55135. c.y = 0,
  55136. d.push(c.x, c.y, c.z),
  55137. p.push(_.x, _.y, _.z),
  55138. f.push(i / u.w, t / u.h)
  55139. }
  55140. for (n = 0; n < c.h; n++)
  55141. for (r = 0; r < c.w; r++)
  55142. g(o + r * _, a + n * m, o + (r + 1) * _, a + (n + 1) * m);
  55143. var v = new $n;
  55144. return v.indices = h,
  55145. v.positions = d,
  55146. v.normals = p,
  55147. v.uvs = f,
  55148. v
  55149. }
  55150. function tl(e) {
  55151. var t, i, n = [], r = [], o = [], a = [], s = e.colorFilter || new D(.3,.59,.11), l = e.alphaFilter || 0, c = !1;
  55152. if (e.minHeight > e.maxHeight) {
  55153. c = !0;
  55154. var u = e.maxHeight;
  55155. e.maxHeight = e.minHeight,
  55156. e.minHeight = u
  55157. }
  55158. for (t = 0; t <= e.subdivisions; t++)
  55159. for (i = 0; i <= e.subdivisions; i++) {
  55160. var h = new x(i * e.width / e.subdivisions - e.width / 2,0,(e.subdivisions - t) * e.height / e.subdivisions - e.height / 2)
  55161. , d = 4 * (((h.x + e.width / 2) / e.width * (e.bufferWidth - 1) | 0) + ((1 - (h.z + e.height / 2) / e.height) * (e.bufferHeight - 1) | 0) * e.bufferWidth)
  55162. , p = e.buffer[d] / 255
  55163. , f = e.buffer[d + 1] / 255
  55164. , _ = e.buffer[d + 2] / 255
  55165. , g = e.buffer[d + 3] / 255;
  55166. c && (p = 1 - p,
  55167. f = 1 - f,
  55168. _ = 1 - _);
  55169. var v = p * s.r + f * s.g + _ * s.b;
  55170. h.y = g >= l ? e.minHeight + (e.maxHeight - e.minHeight) * v : e.minHeight - m,
  55171. r.push(h.x, h.y, h.z),
  55172. o.push(0, 0, 0),
  55173. a.push(i / e.subdivisions, 1 - t / e.subdivisions)
  55174. }
  55175. for (t = 0; t < e.subdivisions; t++)
  55176. for (i = 0; i < e.subdivisions; i++) {
  55177. var y = i + 1 + (t + 1) * (e.subdivisions + 1)
  55178. , b = i + 1 + t * (e.subdivisions + 1)
  55179. , T = i + t * (e.subdivisions + 1)
  55180. , E = i + (t + 1) * (e.subdivisions + 1)
  55181. , S = r[3 * y + 1] >= e.minHeight
  55182. , A = r[3 * b + 1] >= e.minHeight
  55183. , R = r[3 * T + 1] >= e.minHeight;
  55184. S && A && R && (n.push(y),
  55185. n.push(b),
  55186. n.push(T)),
  55187. r[3 * E + 1] >= e.minHeight && S && R && (n.push(E),
  55188. n.push(y),
  55189. n.push(T))
  55190. }
  55191. $n.ComputeNormals(r, n, o);
  55192. var C = new $n;
  55193. return C.indices = n,
  55194. C.positions = r,
  55195. C.normals = o,
  55196. C.uvs = a,
  55197. C
  55198. }
  55199. function il(e, t, i) {
  55200. void 0 === t && (t = {});
  55201. var n = new Js(e,i);
  55202. return n._setReady(!1),
  55203. n._subdivisionsX = t.subdivisionsX || t.subdivisions || 1,
  55204. n._subdivisionsY = t.subdivisionsY || t.subdivisions || 1,
  55205. n._width = t.width || 1,
  55206. n._height = t.height || 1,
  55207. n._maxX = n._width / 2,
  55208. n._maxZ = n._height / 2,
  55209. n._minX = -n._maxX,
  55210. n._minZ = -n._maxZ,
  55211. $s(t).applyToMesh(n, t.updatable),
  55212. n._setReady(!0),
  55213. n
  55214. }
  55215. function nl(e, t, i) {
  55216. void 0 === i && (i = null);
  55217. var n = new Vr(e,i);
  55218. return el(t).applyToMesh(n, t.updatable),
  55219. n
  55220. }
  55221. function rl(e, t, i, n) {
  55222. void 0 === i && (i = {}),
  55223. void 0 === n && (n = null);
  55224. var r = i.width || 10
  55225. , o = i.height || 10
  55226. , a = i.subdivisions || 1
  55227. , s = i.minHeight || 0
  55228. , l = i.maxHeight || 1
  55229. , c = i.colorFilter || new D(.3,.59,.11)
  55230. , u = i.alphaFilter || 0
  55231. , h = i.updatable
  55232. , d = i.onReady;
  55233. n = n || E.LastCreatedScene;
  55234. var p = new Js(e,n);
  55235. return p._subdivisionsX = a,
  55236. p._subdivisionsY = a,
  55237. p._width = r,
  55238. p._height = o,
  55239. p._maxX = p._width / 2,
  55240. p._maxZ = p._height / 2,
  55241. p._minX = -p._maxX,
  55242. p._minZ = -p._maxZ,
  55243. p._setReady(!1),
  55244. gi.LoadImage(t, (function(e) {
  55245. var t = e.width
  55246. , i = e.height;
  55247. if (!n.isDisposed) {
  55248. var f = null == n ? void 0 : n.getEngine().resizeImageBitmap(e, t, i);
  55249. tl({
  55250. width: r,
  55251. height: o,
  55252. subdivisions: a,
  55253. minHeight: s,
  55254. maxHeight: l,
  55255. colorFilter: c,
  55256. buffer: f,
  55257. bufferWidth: t,
  55258. bufferHeight: i,
  55259. alphaFilter: u
  55260. }).applyToMesh(p, h),
  55261. d && d(p),
  55262. p._setReady(!0)
  55263. }
  55264. }
  55265. ), (function() {}
  55266. ), n.offlineProvider),
  55267. p
  55268. }
  55269. var ol = {
  55270. CreateGround: il,
  55271. CreateGroundFromHeightMap: rl,
  55272. CreateTiledGround: nl
  55273. };
  55274. $n.CreateGround = $s,
  55275. $n.CreateTiledGround = el,
  55276. $n.CreateGroundFromHeightMap = tl,
  55277. Vr.CreateGround = function(e, t, i, n, r, o) {
  55278. return il(e, {
  55279. width: t,
  55280. height: i,
  55281. subdivisions: n,
  55282. updatable: o
  55283. }, r)
  55284. }
  55285. ,
  55286. Vr.CreateTiledGround = function(e, t, i, n, r, o, a, s, l) {
  55287. return nl(e, {
  55288. xmin: t,
  55289. zmin: i,
  55290. xmax: n,
  55291. zmax: r,
  55292. subdivisions: o,
  55293. precision: a,
  55294. updatable: l
  55295. }, s)
  55296. }
  55297. ,
  55298. Vr.CreateGroundFromHeightMap = function(e, t, i, n, r, o, a, s, l, c, u) {
  55299. return rl(e, t, {
  55300. width: i,
  55301. height: n,
  55302. subdivisions: r,
  55303. minHeight: o,
  55304. maxHeight: a,
  55305. updatable: l,
  55306. onReady: c,
  55307. alphaFilter: u
  55308. }, s)
  55309. }
  55310. ;
  55311. var al, sl = function() {
  55312. function e(t, i) {
  55313. if (void 0 === i && (i = null),
  55314. this.scene = t,
  55315. this._pointerDownOnMeshAsked = !1,
  55316. this._isActionableMesh = !1,
  55317. this._teleportationRequestInitiated = !1,
  55318. this._teleportationBackRequestInitiated = !1,
  55319. this._rotationRightAsked = !1,
  55320. this._rotationLeftAsked = !1,
  55321. this._dpadPressed = !0,
  55322. this._activePointer = !1,
  55323. this._id = e._IdCounter++,
  55324. i)
  55325. this._gazeTracker = i.clone("gazeTracker");
  55326. else {
  55327. this._gazeTracker = qs("gazeTracker", {
  55328. diameter: .0035,
  55329. thickness: .0025,
  55330. tessellation: 20,
  55331. updatable: !1
  55332. }, t),
  55333. this._gazeTracker.bakeCurrentTransformIntoVertices(),
  55334. this._gazeTracker.isPickable = !1,
  55335. this._gazeTracker.isVisible = !1;
  55336. var n = new Os("targetMat",t);
  55337. n.specularColor = D.Black(),
  55338. n.emissiveColor = new D(.7,.7,.7),
  55339. n.backFaceCulling = !1,
  55340. this._gazeTracker.material = n
  55341. }
  55342. }
  55343. return e.prototype._getForwardRay = function(e) {
  55344. return new _o(x.Zero(),new x(0,0,e))
  55345. }
  55346. ,
  55347. e.prototype._selectionPointerDown = function() {
  55348. this._pointerDownOnMeshAsked = !0,
  55349. this._currentHit && this.scene.simulatePointerDown(this._currentHit, {
  55350. pointerId: this._id
  55351. })
  55352. }
  55353. ,
  55354. e.prototype._selectionPointerUp = function() {
  55355. this._currentHit && this.scene.simulatePointerUp(this._currentHit, {
  55356. pointerId: this._id
  55357. }),
  55358. this._pointerDownOnMeshAsked = !1
  55359. }
  55360. ,
  55361. e.prototype._activatePointer = function() {
  55362. this._activePointer = !0
  55363. }
  55364. ,
  55365. e.prototype._deactivatePointer = function() {
  55366. this._activePointer = !1
  55367. }
  55368. ,
  55369. e.prototype._updatePointerDistance = function(e) {
  55370. void 0 === e && (e = 100)
  55371. }
  55372. ,
  55373. e.prototype.dispose = function() {
  55374. this._interactionsEnabled = !1,
  55375. this._teleportationEnabled = !1,
  55376. this._gazeTracker && this._gazeTracker.dispose()
  55377. }
  55378. ,
  55379. e._IdCounter = 0,
  55380. e
  55381. }(), ll = function(e) {
  55382. function t(t, i, n) {
  55383. var r = e.call(this, i, n) || this;
  55384. r.webVRController = t,
  55385. r._laserPointer = Ys("laserPointer", {
  55386. updatable: !1,
  55387. height: 1,
  55388. diameterTop: .004,
  55389. diameterBottom: 2e-4,
  55390. tessellation: 20,
  55391. subdivisions: 1
  55392. }, i);
  55393. var o = new Os("laserPointerMat",i);
  55394. if (o.emissiveColor = new D(.7,.7,.7),
  55395. o.alpha = .6,
  55396. r._laserPointer.material = o,
  55397. r._laserPointer.rotation.x = Math.PI / 2,
  55398. r._laserPointer.position.z = -.5,
  55399. r._laserPointer.isVisible = !1,
  55400. r._laserPointer.isPickable = !1,
  55401. !t.mesh) {
  55402. var a = new Vr("preloadControllerMesh",i)
  55403. , s = new Vr(Ra.POINTING_POSE,i);
  55404. s.rotation.x = -.7,
  55405. a.addChild(s),
  55406. t.attachToMesh(a)
  55407. }
  55408. return r._setLaserPointerParent(t.mesh),
  55409. r._meshAttachedObserver = t._meshAttachedObservable.add((function(e) {
  55410. r._setLaserPointerParent(e)
  55411. }
  55412. )),
  55413. r
  55414. }
  55415. return U(t, e),
  55416. t.prototype._getForwardRay = function(e) {
  55417. return this.webVRController.getForwardRay(e)
  55418. }
  55419. ,
  55420. t.prototype._activatePointer = function() {
  55421. e.prototype._activatePointer.call(this),
  55422. this._laserPointer.isVisible = !0
  55423. }
  55424. ,
  55425. t.prototype._deactivatePointer = function() {
  55426. e.prototype._deactivatePointer.call(this),
  55427. this._laserPointer.isVisible = !1
  55428. }
  55429. ,
  55430. t.prototype._setLaserPointerColor = function(e) {
  55431. this._laserPointer.material.emissiveColor = e
  55432. }
  55433. ,
  55434. t.prototype._setLaserPointerLightingDisabled = function(e) {
  55435. this._laserPointer.material.disableLighting = e
  55436. }
  55437. ,
  55438. t.prototype._setLaserPointerParent = function(e) {
  55439. var t = function(e) {
  55440. e.isPickable = !1,
  55441. e.getChildMeshes().forEach((function(e) {
  55442. t(e)
  55443. }
  55444. ))
  55445. };
  55446. t(e);
  55447. var i = e.getChildren(void 0, !1)
  55448. , n = e;
  55449. this.webVRController._pointingPoseNode = null;
  55450. for (var r = 0; r < i.length; r++)
  55451. if (i[r].name && i[r].name.indexOf(Ra.POINTING_POSE) >= 0) {
  55452. n = i[r],
  55453. this.webVRController._pointingPoseNode = n;
  55454. break
  55455. }
  55456. this._laserPointer.parent = n
  55457. }
  55458. ,
  55459. t.prototype._updatePointerDistance = function(e) {
  55460. void 0 === e && (e = 100),
  55461. this._laserPointer.scaling.y = e,
  55462. this._laserPointer.position.z = -e / 2
  55463. }
  55464. ,
  55465. t.prototype.dispose = function() {
  55466. e.prototype.dispose.call(this),
  55467. this._laserPointer.dispose(),
  55468. this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)
  55469. }
  55470. ,
  55471. t
  55472. }(sl), cl = function(e) {
  55473. function t(t, i) {
  55474. var n = e.call(this, i) || this;
  55475. return n._getCamera = t,
  55476. n
  55477. }
  55478. return U(t, e),
  55479. t.prototype._getForwardRay = function(e) {
  55480. var t = this._getCamera();
  55481. return t ? t.getForwardRay(e) : new _o(x.Zero(),x.Forward())
  55482. }
  55483. ,
  55484. t
  55485. }(sl), ul = function() {}, hl = function() {
  55486. function e(t, i) {
  55487. void 0 === i && (i = {});
  55488. var n = this;
  55489. if (this.webVROptions = i,
  55490. this._webVRsupported = !1,
  55491. this._webVRready = !1,
  55492. this._webVRrequesting = !1,
  55493. this._webVRpresenting = !1,
  55494. this._fullscreenVRpresenting = !1,
  55495. this.enableGazeEvenWhenNoPointerLock = !1,
  55496. this.exitVROnDoubleTap = !0,
  55497. this.onEnteringVRObservable = new h,
  55498. this.onAfterEnteringVRObservable = new h,
  55499. this.onExitingVRObservable = new h,
  55500. this.onControllerMeshLoadedObservable = new h,
  55501. this._useCustomVRButton = !1,
  55502. this._teleportationRequested = !1,
  55503. this._teleportActive = !1,
  55504. this._floorMeshesCollection = [],
  55505. this._teleportationMode = e.TELEPORTATIONMODE_CONSTANTTIME,
  55506. this._teleportationTime = 122,
  55507. this._teleportationSpeed = 20,
  55508. this._rotationAllowed = !0,
  55509. this._teleportBackwardsVector = new x(0,-1,-1),
  55510. this._isDefaultTeleportationTarget = !0,
  55511. this._teleportationFillColor = "#444444",
  55512. this._teleportationBorderColor = "#FFFFFF",
  55513. this._rotationAngle = 0,
  55514. this._haloCenter = new x(0,0,0),
  55515. this._padSensibilityUp = .65,
  55516. this._padSensibilityDown = .35,
  55517. this._leftController = null,
  55518. this._rightController = null,
  55519. this._gazeColor = new D(.7,.7,.7),
  55520. this._laserColor = new D(.7,.7,.7),
  55521. this._pickedLaserColor = new D(.2,.2,1),
  55522. this._pickedGazeColor = new D(0,0,1),
  55523. this.onNewMeshSelected = new h,
  55524. this.onMeshSelectedWithController = new h,
  55525. this.onNewMeshPicked = new h,
  55526. this.onBeforeCameraTeleport = new h,
  55527. this.onAfterCameraTeleport = new h,
  55528. this.onSelectedMeshUnselected = new h,
  55529. this.teleportationEnabled = !0,
  55530. this._teleportationInitialized = !1,
  55531. this._interactionsEnabled = !1,
  55532. this._interactionsRequested = !1,
  55533. this._displayGaze = !0,
  55534. this._displayLaserPointer = !0,
  55535. this.updateGazeTrackerScale = !0,
  55536. this.updateGazeTrackerColor = !0,
  55537. this.updateControllerLaserColor = !0,
  55538. this.requestPointerLockOnFullScreen = !0,
  55539. this.xrTestDone = !1,
  55540. this._onResize = function() {
  55541. n._moveButtonToBottomRight(),
  55542. n._fullscreenVRpresenting && n._webVRready && n.exitVR()
  55543. }
  55544. ,
  55545. this._onFullscreenChange = function() {
  55546. var e = document;
  55547. void 0 !== e.fullscreen ? n._fullscreenVRpresenting = document.fullscreen : void 0 !== e.mozFullScreen ? n._fullscreenVRpresenting = e.mozFullScreen : void 0 !== e.webkitIsFullScreen ? n._fullscreenVRpresenting = e.webkitIsFullScreen : void 0 !== e.msIsFullScreen ? n._fullscreenVRpresenting = e.msIsFullScreen : void 0 !== document.msFullscreenElement && (n._fullscreenVRpresenting = document.msFullscreenElement),
  55548. !n._fullscreenVRpresenting && n._inputElement && (n.exitVR(),
  55549. !n._useCustomVRButton && n._btnVR && (n._btnVR.style.top = n._inputElement.offsetTop + n._inputElement.offsetHeight - 70 + "px",
  55550. n._btnVR.style.left = n._inputElement.offsetLeft + n._inputElement.offsetWidth - 100 + "px",
  55551. n._updateButtonVisibility()))
  55552. }
  55553. ,
  55554. this._cachedAngularSensibility = {
  55555. angularSensibilityX: null,
  55556. angularSensibilityY: null,
  55557. angularSensibility: null
  55558. },
  55559. this._beforeRender = function() {
  55560. n._leftController && n._leftController._activePointer && n._castRayAndSelectObject(n._leftController),
  55561. n._rightController && n._rightController._activePointer && n._castRayAndSelectObject(n._rightController),
  55562. n._noControllerIsActive && (n._scene.getEngine().isPointerLock || n.enableGazeEvenWhenNoPointerLock) ? n._castRayAndSelectObject(n._cameraGazer) : n._cameraGazer._gazeTracker.isVisible = !1
  55563. }
  55564. ,
  55565. this._onNewGamepadConnected = function(e) {
  55566. if (e.type !== zo.POSE_ENABLED)
  55567. e.leftStick && e.onleftstickchanged((function(e) {
  55568. n._teleportationInitialized && n.teleportationEnabled && (!n._leftController && !n._rightController || n._leftController && !n._leftController._activePointer && n._rightController && !n._rightController._activePointer) && (n._checkTeleportWithRay(e, n._cameraGazer),
  55569. n._checkTeleportBackwards(e, n._cameraGazer))
  55570. }
  55571. )),
  55572. e.rightStick && e.onrightstickchanged((function(e) {
  55573. n._teleportationInitialized && n._checkRotate(e, n._cameraGazer)
  55574. }
  55575. )),
  55576. e.type === zo.XBOX && (e.onbuttondown((function(e) {
  55577. n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerDown()
  55578. }
  55579. )),
  55580. e.onbuttonup((function(e) {
  55581. n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerUp()
  55582. }
  55583. )));
  55584. else {
  55585. var t = e
  55586. , i = new ll(t,n._scene,n._cameraGazer._gazeTracker);
  55587. "right" === t.hand || n._leftController && n._leftController.webVRController != t ? n._rightController = i : n._leftController = i,
  55588. n._tryEnableInteractionOnController(i)
  55589. }
  55590. }
  55591. ,
  55592. this._tryEnableInteractionOnController = function(e) {
  55593. n._interactionsRequested && !e._interactionsEnabled && n._enableInteractionOnController(e),
  55594. n._teleportationRequested && !e._teleportationEnabled && n._enableTeleportationOnController(e)
  55595. }
  55596. ,
  55597. this._onNewGamepadDisconnected = function(e) {
  55598. e instanceof _s && ("left" === e.hand && null != n._leftController && (n._leftController.dispose(),
  55599. n._leftController = null),
  55600. "right" === e.hand && null != n._rightController && (n._rightController.dispose(),
  55601. n._rightController = null))
  55602. }
  55603. ,
  55604. this._workingVector = x.Zero(),
  55605. this._workingQuaternion = C.Identity(),
  55606. this._workingMatrix = P.Identity(),
  55607. K.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),
  55608. this._scene = t,
  55609. this._inputElement = t.getEngine().getInputElement(),
  55610. "getVRDisplays"in navigator || void 0 !== i.useXR || (i.useXR = !0),
  55611. void 0 === i.createFallbackVRDeviceOrientationFreeCamera && (i.createFallbackVRDeviceOrientationFreeCamera = !0),
  55612. void 0 === i.createDeviceOrientationCamera && (i.createDeviceOrientationCamera = !0),
  55613. void 0 === i.laserToggle && (i.laserToggle = !0),
  55614. void 0 === i.defaultHeight && (i.defaultHeight = 1.7),
  55615. i.useCustomVRButton && (this._useCustomVRButton = !0,
  55616. i.customVRButton && (this._btnVR = i.customVRButton)),
  55617. i.rayLength && (this._rayLength = i.rayLength),
  55618. this._defaultHeight = i.defaultHeight,
  55619. i.positionScale && (this._rayLength *= i.positionScale,
  55620. this._defaultHeight *= i.positionScale),
  55621. this._hasEnteredVR = !1,
  55622. this._scene.activeCamera ? this._position = this._scene.activeCamera.position.clone() : this._position = new x(0,this._defaultHeight,0),
  55623. i.createDeviceOrientationCamera || !this._scene.activeCamera) {
  55624. if (this._deviceOrientationCamera = new ma("deviceOrientationVRHelper",this._position.clone(),t),
  55625. this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ,
  55626. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ,
  55627. this._scene.activeCamera instanceof da && this._scene.activeCamera.rotation)) {
  55628. var r = this._scene.activeCamera;
  55629. r.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(C.RotationYawPitchRoll(r.rotation.y, r.rotation.x, r.rotation.z)),
  55630. this._deviceOrientationCamera.rotation = r.rotation.clone()
  55631. }
  55632. this._scene.activeCamera = this._deviceOrientationCamera,
  55633. this._inputElement && this._scene.activeCamera.attachControl()
  55634. } else
  55635. this._existingCamera = this._scene.activeCamera;
  55636. this.webVROptions.useXR && navigator.xr ? Xs.IsSessionSupportedAsync("immersive-vr").then((function(e) {
  55637. e ? (K.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),
  55638. t.createDefaultXRExperienceAsync({
  55639. floorMeshes: i.floorMeshes || []
  55640. }).then((function(e) {
  55641. n.xr = e,
  55642. n.xrTestDone = !0,
  55643. n._cameraGazer = new cl((function() {
  55644. return n.xr.baseExperience.camera
  55645. }
  55646. ),t),
  55647. n.xr.baseExperience.onStateChangedObservable.add((function(e) {
  55648. switch (e) {
  55649. case Ns.ENTERING_XR:
  55650. n.onEnteringVRObservable.notifyObservers(n),
  55651. n._interactionsEnabled || n.xr.pointerSelection.detach(),
  55652. n.xr.pointerSelection.displayLaserPointer = n._displayLaserPointer;
  55653. break;
  55654. case Ns.EXITING_XR:
  55655. n.onExitingVRObservable.notifyObservers(n),
  55656. n._scene.getEngine().resize();
  55657. break;
  55658. case Ns.IN_XR:
  55659. n._hasEnteredVR = !0;
  55660. break;
  55661. case Ns.NOT_IN_XR:
  55662. n._hasEnteredVR = !1
  55663. }
  55664. }
  55665. ))
  55666. }
  55667. ))) : n._completeVRInit(t, i)
  55668. }
  55669. )) : this._completeVRInit(t, i)
  55670. }
  55671. return Object.defineProperty(e.prototype, "onEnteringVR", {
  55672. get: function() {
  55673. return this.onEnteringVRObservable
  55674. },
  55675. enumerable: !1,
  55676. configurable: !0
  55677. }),
  55678. Object.defineProperty(e.prototype, "onExitingVR", {
  55679. get: function() {
  55680. return this.onExitingVRObservable
  55681. },
  55682. enumerable: !1,
  55683. configurable: !0
  55684. }),
  55685. Object.defineProperty(e.prototype, "onControllerMeshLoaded", {
  55686. get: function() {
  55687. return this.onControllerMeshLoadedObservable
  55688. },
  55689. enumerable: !1,
  55690. configurable: !0
  55691. }),
  55692. Object.defineProperty(e.prototype, "teleportationTarget", {
  55693. get: function() {
  55694. return this._teleportationTarget
  55695. },
  55696. set: function(e) {
  55697. e && (e.name = "teleportationTarget",
  55698. this._isDefaultTeleportationTarget = !1,
  55699. this._teleportationTarget = e)
  55700. },
  55701. enumerable: !1,
  55702. configurable: !0
  55703. }),
  55704. Object.defineProperty(e.prototype, "gazeTrackerMesh", {
  55705. get: function() {
  55706. return this._cameraGazer._gazeTracker
  55707. },
  55708. set: function(e) {
  55709. e && (this._cameraGazer._gazeTracker && this._cameraGazer._gazeTracker.dispose(),
  55710. this._leftController && this._leftController._gazeTracker && this._leftController._gazeTracker.dispose(),
  55711. this._rightController && this._rightController._gazeTracker && this._rightController._gazeTracker.dispose(),
  55712. this._cameraGazer._gazeTracker = e,
  55713. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),
  55714. this._cameraGazer._gazeTracker.isPickable = !1,
  55715. this._cameraGazer._gazeTracker.isVisible = !1,
  55716. this._cameraGazer._gazeTracker.name = "gazeTracker",
  55717. this._leftController && (this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")),
  55718. this._rightController && (this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")))
  55719. },
  55720. enumerable: !1,
  55721. configurable: !0
  55722. }),
  55723. Object.defineProperty(e.prototype, "leftControllerGazeTrackerMesh", {
  55724. get: function() {
  55725. return this._leftController ? this._leftController._gazeTracker : null
  55726. },
  55727. enumerable: !1,
  55728. configurable: !0
  55729. }),
  55730. Object.defineProperty(e.prototype, "rightControllerGazeTrackerMesh", {
  55731. get: function() {
  55732. return this._rightController ? this._rightController._gazeTracker : null
  55733. },
  55734. enumerable: !1,
  55735. configurable: !0
  55736. }),
  55737. Object.defineProperty(e.prototype, "displayGaze", {
  55738. get: function() {
  55739. return this._displayGaze
  55740. },
  55741. set: function(e) {
  55742. this._displayGaze = e,
  55743. e || (this._cameraGazer._gazeTracker.isVisible = !1,
  55744. this._leftController && (this._leftController._gazeTracker.isVisible = !1),
  55745. this._rightController && (this._rightController._gazeTracker.isVisible = !1))
  55746. },
  55747. enumerable: !1,
  55748. configurable: !0
  55749. }),
  55750. Object.defineProperty(e.prototype, "displayLaserPointer", {
  55751. get: function() {
  55752. return this._displayLaserPointer
  55753. },
  55754. set: function(e) {
  55755. this._displayLaserPointer = e,
  55756. e ? (this._rightController && this._rightController._activatePointer(),
  55757. this._leftController && this._leftController._activatePointer()) : (this._rightController && (this._rightController._deactivatePointer(),
  55758. this._rightController._gazeTracker.isVisible = !1),
  55759. this._leftController && (this._leftController._deactivatePointer(),
  55760. this._leftController._gazeTracker.isVisible = !1))
  55761. },
  55762. enumerable: !1,
  55763. configurable: !0
  55764. }),
  55765. Object.defineProperty(e.prototype, "deviceOrientationCamera", {
  55766. get: function() {
  55767. return this._deviceOrientationCamera
  55768. },
  55769. enumerable: !1,
  55770. configurable: !0
  55771. }),
  55772. Object.defineProperty(e.prototype, "currentVRCamera", {
  55773. get: function() {
  55774. return this._webVRready ? this._webVRCamera : this._scene.activeCamera
  55775. },
  55776. enumerable: !1,
  55777. configurable: !0
  55778. }),
  55779. Object.defineProperty(e.prototype, "webVRCamera", {
  55780. get: function() {
  55781. return this._webVRCamera
  55782. },
  55783. enumerable: !1,
  55784. configurable: !0
  55785. }),
  55786. Object.defineProperty(e.prototype, "vrDeviceOrientationCamera", {
  55787. get: function() {
  55788. return this._vrDeviceOrientationCamera
  55789. },
  55790. enumerable: !1,
  55791. configurable: !0
  55792. }),
  55793. Object.defineProperty(e.prototype, "vrButton", {
  55794. get: function() {
  55795. return this._btnVR
  55796. },
  55797. enumerable: !1,
  55798. configurable: !0
  55799. }),
  55800. Object.defineProperty(e.prototype, "_teleportationRequestInitiated", {
  55801. get: function() {
  55802. return this._cameraGazer._teleportationRequestInitiated || null !== this._leftController && this._leftController._teleportationRequestInitiated || null !== this._rightController && this._rightController._teleportationRequestInitiated
  55803. },
  55804. enumerable: !1,
  55805. configurable: !0
  55806. }),
  55807. e.prototype._completeVRInit = function(e, t) {
  55808. var i = this;
  55809. if (this.xrTestDone = !0,
  55810. t.createFallbackVRDeviceOrientationFreeCamera && (t.useMultiview && (t.vrDeviceOrientationCameraMetrics || (t.vrDeviceOrientationCameraMetrics = ts.GetDefault()),
  55811. t.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0),
  55812. this._vrDeviceOrientationCamera = new us("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),
  55813. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
  55814. this._webVRCamera = new fs("WebVRHelper",this._position,this._scene,t),
  55815. this._webVRCamera.useStandingMatrix(),
  55816. this._cameraGazer = new cl((function() {
  55817. return i.currentVRCamera
  55818. }
  55819. ),e),
  55820. !this._useCustomVRButton) {
  55821. this._btnVR = document.createElement("BUTTON"),
  55822. this._btnVR.className = "babylonVRicon",
  55823. this._btnVR.id = "babylonVRiconbtn",
  55824. this._btnVR.title = "Click to switch to VR";
  55825. var n = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A" : "https://cdn.babylonjs.com/Assets/vrButton.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
  55826. n += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  55827. var r = document.createElement("style");
  55828. r.appendChild(document.createTextNode(n)),
  55829. document.getElementsByTagName("head")[0].appendChild(r),
  55830. this._moveButtonToBottomRight()
  55831. }
  55832. this._btnVR && this._btnVR.addEventListener("click", (function() {
  55833. i.isInVRMode ? i._scene.getEngine().disableVR() : i.enterVR()
  55834. }
  55835. ));
  55836. var o = this._scene.getEngine().getHostWindow();
  55837. o && (o.addEventListener("resize", this._onResize),
  55838. document.addEventListener("fullscreenchange", this._onFullscreenChange, !1),
  55839. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, !1),
  55840. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1),
  55841. document.addEventListener("msfullscreenchange", this._onFullscreenChange, !1),
  55842. document.onmsfullscreenchange = this._onFullscreenChange,
  55843. t.createFallbackVRDeviceOrientationFreeCamera ? this._displayVRButton() : this._scene.getEngine().onVRDisplayChangedObservable.add((function(e) {
  55844. e.vrDisplay && i._displayVRButton()
  55845. }
  55846. )),
  55847. this._onKeyDown = function(e) {
  55848. 27 === e.keyCode && i.isInVRMode && i.exitVR()
  55849. }
  55850. ,
  55851. document.addEventListener("keydown", this._onKeyDown),
  55852. this._scene.onPrePointerObservable.add((function() {
  55853. i._hasEnteredVR && i.exitVROnDoubleTap && (i.exitVR(),
  55854. i._fullscreenVRpresenting && i._scene.getEngine().exitFullscreen())
  55855. }
  55856. ), Xi.POINTERDOUBLETAP, !1),
  55857. this._onVRDisplayChangedBind = function(e) {
  55858. return i._onVRDisplayChanged(e)
  55859. }
  55860. ,
  55861. this._onVrDisplayPresentChangeBind = function() {
  55862. return i._onVrDisplayPresentChange()
  55863. }
  55864. ,
  55865. this._onVRRequestPresentStart = function() {
  55866. i._webVRrequesting = !0,
  55867. i._updateButtonVisibility()
  55868. }
  55869. ,
  55870. this._onVRRequestPresentComplete = function() {
  55871. i._webVRrequesting = !1,
  55872. i._updateButtonVisibility()
  55873. }
  55874. ,
  55875. e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChangedBind),
  55876. e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),
  55877. e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),
  55878. o.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind),
  55879. e.onDisposeObservable.add((function() {
  55880. i.dispose()
  55881. }
  55882. )),
  55883. this._webVRCamera.onControllerMeshLoadedObservable.add((function(e) {
  55884. return i._onDefaultMeshLoaded(e)
  55885. }
  55886. )),
  55887. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),
  55888. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),
  55889. this._updateButtonVisibility(),
  55890. this._circleEase = new In,
  55891. this._circleEase.setEasingMode(Mn.EASINGMODE_EASEINOUT),
  55892. this._teleportationEasing = this._circleEase,
  55893. e.onPointerObservable.add((function(t) {
  55894. i._interactionsEnabled && e.activeCamera === i.vrDeviceOrientationCamera && "mouse" === t.event.pointerType && (t.type === Xi.POINTERDOWN ? i._cameraGazer._selectionPointerDown() : t.type === Xi.POINTERUP && i._cameraGazer._selectionPointerUp())
  55895. }
  55896. )),
  55897. this.webVROptions.floorMeshes && this.enableTeleportation({
  55898. floorMeshes: this.webVROptions.floorMeshes
  55899. }))
  55900. }
  55901. ,
  55902. e.prototype._onDefaultMeshLoaded = function(e) {
  55903. this._leftController && this._leftController.webVRController == e && e.mesh && this._leftController._setLaserPointerParent(e.mesh),
  55904. this._rightController && this._rightController.webVRController == e && e.mesh && this._rightController._setLaserPointerParent(e.mesh);
  55905. try {
  55906. this.onControllerMeshLoadedObservable.notifyObservers(e)
  55907. } catch (e) {
  55908. K.Warn("Error in your custom logic onControllerMeshLoaded: " + e)
  55909. }
  55910. }
  55911. ,
  55912. Object.defineProperty(e.prototype, "isInVRMode", {
  55913. get: function() {
  55914. return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === Ns.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting
  55915. },
  55916. enumerable: !1,
  55917. configurable: !0
  55918. }),
  55919. e.prototype._onVrDisplayPresentChange = function() {
  55920. var e = this._scene.getEngine().getVRDevice();
  55921. if (e) {
  55922. var t = this._webVRpresenting;
  55923. this._webVRpresenting = e.isPresenting,
  55924. t && !this._webVRpresenting && this.exitVR()
  55925. } else
  55926. K.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");
  55927. this._updateButtonVisibility()
  55928. }
  55929. ,
  55930. e.prototype._onVRDisplayChanged = function(e) {
  55931. this._webVRsupported = e.vrSupported,
  55932. this._webVRready = !!e.vrDisplay,
  55933. this._webVRpresenting = e.vrDisplay && e.vrDisplay.isPresenting,
  55934. this._updateButtonVisibility()
  55935. }
  55936. ,
  55937. e.prototype._moveButtonToBottomRight = function() {
  55938. if (this._inputElement && !this._useCustomVRButton && this._btnVR) {
  55939. var e = this._inputElement.getBoundingClientRect();
  55940. this._btnVR.style.top = e.top + e.height - 70 + "px",
  55941. this._btnVR.style.left = e.left + e.width - 100 + "px"
  55942. }
  55943. }
  55944. ,
  55945. e.prototype._displayVRButton = function() {
  55946. this._useCustomVRButton || this._btnVRDisplayed || !this._btnVR || (document.body.appendChild(this._btnVR),
  55947. this._btnVRDisplayed = !0)
  55948. }
  55949. ,
  55950. e.prototype._updateButtonVisibility = function() {
  55951. this._btnVR && !this._useCustomVRButton && (this._btnVR.className = "babylonVRicon",
  55952. this.isInVRMode ? this._btnVR.className += " vrdisplaypresenting" : (this._webVRready && (this._btnVR.className += " vrdisplayready"),
  55953. this._webVRsupported && (this._btnVR.className += " vrdisplaysupported"),
  55954. this._webVRrequesting && (this._btnVR.className += " vrdisplayrequesting")))
  55955. }
  55956. ,
  55957. e.prototype.enterVR = function() {
  55958. var e = this;
  55959. if (this.xr)
  55960. this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
  55961. else {
  55962. if (this.onEnteringVRObservable)
  55963. try {
  55964. this.onEnteringVRObservable.notifyObservers(this)
  55965. } catch (e) {
  55966. K.Warn("Error in your custom logic onEnteringVR: " + e)
  55967. }
  55968. if (this._scene.activeCamera) {
  55969. if (this._position = this._scene.activeCamera.position.clone(),
  55970. this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),
  55971. this.vrDeviceOrientationCamera.angularSensibility = 2e3),
  55972. this.webVRCamera) {
  55973. var t = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y
  55974. , i = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y - t
  55975. , n = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  55976. this.webVRCamera.rotationQuaternion = C.FromEulerAngles(0, n + i, 0)
  55977. }
  55978. this._existingCamera = this._scene.activeCamera,
  55979. this._existingCamera.angularSensibilityX && (this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX,
  55980. this._existingCamera.angularSensibilityX = Number.MAX_VALUE),
  55981. this._existingCamera.angularSensibilityY && (this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY,
  55982. this._existingCamera.angularSensibilityY = Number.MAX_VALUE),
  55983. this._existingCamera.angularSensibility && (this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility,
  55984. this._existingCamera.angularSensibility = Number.MAX_VALUE)
  55985. }
  55986. this._webVRrequesting || (this._webVRready ? this._webVRpresenting || (this._scene.getEngine().onVRRequestPresentComplete.addOnce((function(t) {
  55987. e.onAfterEnteringVRObservable.notifyObservers({
  55988. success: t
  55989. })
  55990. }
  55991. )),
  55992. this._webVRCamera.position = this._position,
  55993. this._scene.activeCamera = this._webVRCamera) : this._vrDeviceOrientationCamera && (this._vrDeviceOrientationCamera.position = this._position,
  55994. this._scene.activeCamera && (this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ),
  55995. this._scene.activeCamera = this._vrDeviceOrientationCamera,
  55996. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),
  55997. this._updateButtonVisibility(),
  55998. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce((function() {
  55999. e.onAfterEnteringVRObservable.notifyObservers({
  56000. success: !0
  56001. })
  56002. }
  56003. ))),
  56004. this._scene.activeCamera && this._inputElement && this._scene.activeCamera.attachControl(),
  56005. this._interactionsEnabled && this._scene.registerBeforeRender(this._beforeRender),
  56006. this._displayLaserPointer && [this._leftController, this._rightController].forEach((function(e) {
  56007. e && e._activatePointer()
  56008. }
  56009. )),
  56010. this._hasEnteredVR = !0)
  56011. }
  56012. }
  56013. ,
  56014. e.prototype.exitVR = function() {
  56015. if (this.xr)
  56016. this.xr.baseExperience.exitXRAsync();
  56017. else if (this._hasEnteredVR) {
  56018. if (this.onExitingVRObservable)
  56019. try {
  56020. this.onExitingVRObservable.notifyObservers(this)
  56021. } catch (e) {
  56022. K.Warn("Error in your custom logic onExitingVR: " + e)
  56023. }
  56024. this._webVRpresenting && this._scene.getEngine().disableVR(),
  56025. this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone()),
  56026. this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
  56027. this._deviceOrientationCamera ? (this._deviceOrientationCamera.position = this._position,
  56028. this._scene.activeCamera = this._deviceOrientationCamera,
  56029. this._cachedAngularSensibility.angularSensibilityX && (this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
  56030. this._cachedAngularSensibility.angularSensibilityX = null),
  56031. this._cachedAngularSensibility.angularSensibilityY && (this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
  56032. this._cachedAngularSensibility.angularSensibilityY = null),
  56033. this._cachedAngularSensibility.angularSensibility && (this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
  56034. this._cachedAngularSensibility.angularSensibility = null)) : this._existingCamera && (this._existingCamera.position = this._position,
  56035. this._scene.activeCamera = this._existingCamera,
  56036. this._inputElement && this._scene.activeCamera.attachControl(),
  56037. this._cachedAngularSensibility.angularSensibilityX && (this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
  56038. this._cachedAngularSensibility.angularSensibilityX = null),
  56039. this._cachedAngularSensibility.angularSensibilityY && (this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
  56040. this._cachedAngularSensibility.angularSensibilityY = null),
  56041. this._cachedAngularSensibility.angularSensibility && (this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
  56042. this._cachedAngularSensibility.angularSensibility = null)),
  56043. this._updateButtonVisibility(),
  56044. this._interactionsEnabled && (this._scene.unregisterBeforeRender(this._beforeRender),
  56045. this._cameraGazer._gazeTracker.isVisible = !1,
  56046. this._leftController && (this._leftController._gazeTracker.isVisible = !1),
  56047. this._rightController && (this._rightController._gazeTracker.isVisible = !1)),
  56048. this._scene.getEngine().resize(),
  56049. [this._leftController, this._rightController].forEach((function(e) {
  56050. e && e._deactivatePointer()
  56051. }
  56052. )),
  56053. this._hasEnteredVR = !1;
  56054. var e = this._scene.getEngine();
  56055. e._onVrDisplayPresentChange && e._onVrDisplayPresentChange()
  56056. }
  56057. }
  56058. ,
  56059. Object.defineProperty(e.prototype, "position", {
  56060. get: function() {
  56061. return this._position
  56062. },
  56063. set: function(e) {
  56064. this._position = e,
  56065. this._scene.activeCamera && (this._scene.activeCamera.position = e)
  56066. },
  56067. enumerable: !1,
  56068. configurable: !0
  56069. }),
  56070. e.prototype.enableInteractions = function() {
  56071. var e = this;
  56072. if (!this._interactionsEnabled) {
  56073. if (this._interactionsRequested = !0,
  56074. this.xr)
  56075. return void (this.xr.baseExperience.state === Ns.IN_XR && this.xr.pointerSelection.attach());
  56076. this._leftController && this._enableInteractionOnController(this._leftController),
  56077. this._rightController && this._enableInteractionOnController(this._rightController),
  56078. this.raySelectionPredicate = function(t) {
  56079. return t.isVisible && (t.isPickable || t.name === e._floorMeshName)
  56080. }
  56081. ,
  56082. this.meshSelectionPredicate = function() {
  56083. return !0
  56084. }
  56085. ,
  56086. this._raySelectionPredicate = function(t) {
  56087. return !!(e._isTeleportationFloor(t) || -1 === t.name.indexOf("gazeTracker") && -1 === t.name.indexOf("teleportationTarget") && -1 === t.name.indexOf("torusTeleportation")) && e.raySelectionPredicate(t)
  56088. }
  56089. ,
  56090. this._interactionsEnabled = !0
  56091. }
  56092. }
  56093. ,
  56094. Object.defineProperty(e.prototype, "_noControllerIsActive", {
  56095. get: function() {
  56096. return !(this._leftController && this._leftController._activePointer || this._rightController && this._rightController._activePointer)
  56097. },
  56098. enumerable: !1,
  56099. configurable: !0
  56100. }),
  56101. e.prototype._isTeleportationFloor = function(e) {
  56102. for (var t = 0; t < this._floorMeshesCollection.length; t++)
  56103. if (this._floorMeshesCollection[t].id === e.id)
  56104. return !0;
  56105. return !(!this._floorMeshName || e.name !== this._floorMeshName)
  56106. }
  56107. ,
  56108. e.prototype.addFloorMesh = function(e) {
  56109. this._floorMeshesCollection && (this._floorMeshesCollection.indexOf(e) > -1 || this._floorMeshesCollection.push(e))
  56110. }
  56111. ,
  56112. e.prototype.removeFloorMesh = function(e) {
  56113. if (this._floorMeshesCollection) {
  56114. var t = this._floorMeshesCollection.indexOf(e);
  56115. -1 !== t && this._floorMeshesCollection.splice(t, 1)
  56116. }
  56117. }
  56118. ,
  56119. e.prototype.enableTeleportation = function(e) {
  56120. var t = this;
  56121. if (void 0 === e && (e = {}),
  56122. !this._teleportationInitialized) {
  56123. if (this._teleportationRequested = !0,
  56124. this.enableInteractions(),
  56125. this.webVROptions.useXR && (e.floorMeshes || e.floorMeshName)) {
  56126. var i = e.floorMeshes || [];
  56127. if (!i.length) {
  56128. var n = this._scene.getMeshByName(e.floorMeshName);
  56129. n && i.push(n)
  56130. }
  56131. if (this.xr)
  56132. return i.forEach((function(e) {
  56133. t.xr.teleportation.addFloorMesh(e)
  56134. }
  56135. )),
  56136. void (this.xr.teleportation.attached || this.xr.teleportation.attach());
  56137. if (!this.xrTestDone) {
  56138. var r = function() {
  56139. t.xrTestDone && (t._scene.unregisterBeforeRender(r),
  56140. t.xr ? t.xr.teleportation.attached || t.xr.teleportation.attach() : t.enableTeleportation(e))
  56141. };
  56142. return void this._scene.registerBeforeRender(r)
  56143. }
  56144. }
  56145. e.floorMeshName && (this._floorMeshName = e.floorMeshName),
  56146. e.floorMeshes && (this._floorMeshesCollection = e.floorMeshes),
  56147. e.teleportationMode && (this._teleportationMode = e.teleportationMode),
  56148. e.teleportationTime && e.teleportationTime > 0 && (this._teleportationTime = e.teleportationTime),
  56149. e.teleportationSpeed && e.teleportationSpeed > 0 && (this._teleportationSpeed = e.teleportationSpeed),
  56150. void 0 !== e.easingFunction && (this._teleportationEasing = e.easingFunction),
  56151. null != this._leftController && this._enableTeleportationOnController(this._leftController),
  56152. null != this._rightController && this._enableTeleportationOnController(this._rightController);
  56153. var o = new Ri;
  56154. o.vignetteColor = new N(0,0,0,0),
  56155. o.vignetteEnabled = !0,
  56156. this._postProcessMove = new Fs("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),
  56157. this._webVRCamera.detachPostProcess(this._postProcessMove),
  56158. this._teleportationInitialized = !0,
  56159. this._isDefaultTeleportationTarget && (this._createTeleportationCircles(),
  56160. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))
  56161. }
  56162. }
  56163. ,
  56164. e.prototype._enableInteractionOnController = function(e) {
  56165. var t = this;
  56166. e.webVRController.mesh && (e._interactionsEnabled = !0,
  56167. this.isInVRMode && this._displayLaserPointer && e._activatePointer(),
  56168. this.webVROptions.laserToggle && e.webVRController.onMainButtonStateChangedObservable.add((function(i) {
  56169. t._displayLaserPointer && 1 === i.value && (e._activePointer ? e._deactivatePointer() : e._activatePointer(),
  56170. t.displayGaze && (e._gazeTracker.isVisible = e._activePointer))
  56171. }
  56172. )),
  56173. e.webVRController.onTriggerStateChangedObservable.add((function(i) {
  56174. var n = e;
  56175. t._noControllerIsActive && (n = t._cameraGazer),
  56176. n._pointerDownOnMeshAsked ? i.value < t._padSensibilityDown && n._selectionPointerUp() : i.value > t._padSensibilityUp && n._selectionPointerDown()
  56177. }
  56178. )))
  56179. }
  56180. ,
  56181. e.prototype._checkTeleportWithRay = function(e, t) {
  56182. this._teleportationRequestInitiated && !t._teleportationRequestInitiated || (t._teleportationRequestInitiated ? Math.sqrt(e.y * e.y + e.x * e.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter),
  56183. t._teleportationRequestInitiated = !1) : e.y < -this._padSensibilityUp && t._dpadPressed && (t._activatePointer(),
  56184. t._teleportationRequestInitiated = !0))
  56185. }
  56186. ,
  56187. e.prototype._checkRotate = function(e, t) {
  56188. t._teleportationRequestInitiated || (t._rotationLeftAsked ? e.x > -this._padSensibilityDown && (t._rotationLeftAsked = !1) : e.x < -this._padSensibilityUp && t._dpadPressed && (t._rotationLeftAsked = !0,
  56189. this._rotationAllowed && this._rotateCamera(!1)),
  56190. t._rotationRightAsked ? e.x < this._padSensibilityDown && (t._rotationRightAsked = !1) : e.x > this._padSensibilityUp && t._dpadPressed && (t._rotationRightAsked = !0,
  56191. this._rotationAllowed && this._rotateCamera(!0)))
  56192. }
  56193. ,
  56194. e.prototype._checkTeleportBackwards = function(e, t) {
  56195. if (!t._teleportationRequestInitiated)
  56196. if (e.y > this._padSensibilityUp && t._dpadPressed) {
  56197. if (!t._teleportationBackRequestInitiated) {
  56198. if (!this.currentVRCamera)
  56199. return;
  56200. var i = C.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix())
  56201. , n = this.currentVRCamera.position;
  56202. this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (i = this.currentVRCamera.deviceRotationQuaternion,
  56203. n = this.currentVRCamera.devicePosition),
  56204. i.toEulerAnglesToRef(this._workingVector),
  56205. this._workingVector.z = 0,
  56206. this._workingVector.x = 0,
  56207. C.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion),
  56208. this._workingQuaternion.toRotationMatrix(this._workingMatrix),
  56209. x.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  56210. var r = new _o(n,this._workingVector)
  56211. , o = this._scene.pickWithRay(r, this._raySelectionPredicate);
  56212. o && o.pickedPoint && o.pickedMesh && this._isTeleportationFloor(o.pickedMesh) && o.distance < 5 && this.teleportCamera(o.pickedPoint),
  56213. t._teleportationBackRequestInitiated = !0
  56214. }
  56215. } else
  56216. t._teleportationBackRequestInitiated = !1
  56217. }
  56218. ,
  56219. e.prototype._enableTeleportationOnController = function(e) {
  56220. var t = this;
  56221. e.webVRController.mesh && (e._interactionsEnabled || this._enableInteractionOnController(e),
  56222. e._interactionsEnabled = !0,
  56223. e._teleportationEnabled = !0,
  56224. e.webVRController.controllerType === ba.VIVE && (e._dpadPressed = !1,
  56225. e.webVRController.onPadStateChangedObservable.add((function(t) {
  56226. e._dpadPressed = t.pressed,
  56227. e._dpadPressed || (e._rotationLeftAsked = !1,
  56228. e._rotationRightAsked = !1,
  56229. e._teleportationBackRequestInitiated = !1)
  56230. }
  56231. ))),
  56232. e.webVRController.onPadValuesChangedObservable.add((function(i) {
  56233. t.teleportationEnabled && (t._checkTeleportBackwards(i, e),
  56234. t._checkTeleportWithRay(i, e)),
  56235. t._checkRotate(i, e)
  56236. }
  56237. )))
  56238. }
  56239. ,
  56240. e.prototype._createTeleportationCircles = function() {
  56241. this._teleportationTarget = il("teleportationTarget", {
  56242. width: 2,
  56243. height: 2,
  56244. subdivisions: 2
  56245. }, this._scene),
  56246. this._teleportationTarget.isPickable = !1;
  56247. var e = new Ds("DynamicTexture",512,this._scene,!0);
  56248. e.hasAlpha = !0;
  56249. var t = e.getContext();
  56250. t.beginPath(),
  56251. t.arc(256, 256, 200, 0, 2 * Math.PI, !1),
  56252. t.fillStyle = this._teleportationFillColor,
  56253. t.fill(),
  56254. t.lineWidth = 10,
  56255. t.strokeStyle = this._teleportationBorderColor,
  56256. t.stroke(),
  56257. t.closePath(),
  56258. e.update();
  56259. var i = new Os("TextPlaneMaterial",this._scene);
  56260. i.diffuseTexture = e,
  56261. this._teleportationTarget.material = i;
  56262. var n = qs("torusTeleportation", {
  56263. diameter: .75,
  56264. thickness: .1,
  56265. tessellation: 25,
  56266. updatable: !1
  56267. }, this._scene);
  56268. n.isPickable = !1,
  56269. n.parent = this._teleportationTarget;
  56270. var r = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CYCLE)
  56271. , o = [];
  56272. o.push({
  56273. frame: 0,
  56274. value: 0
  56275. }),
  56276. o.push({
  56277. frame: 30,
  56278. value: .4
  56279. }),
  56280. o.push({
  56281. frame: 60,
  56282. value: 0
  56283. }),
  56284. r.setKeys(o);
  56285. var a = new kn;
  56286. a.setEasingMode(Mn.EASINGMODE_EASEINOUT),
  56287. r.setEasingFunction(a),
  56288. n.animations = [],
  56289. n.animations.push(r),
  56290. this._scene.beginAnimation(n, 0, 60, !0),
  56291. this._hideTeleportationTarget()
  56292. }
  56293. ,
  56294. e.prototype._displayTeleportationTarget = function() {
  56295. this._teleportActive = !0,
  56296. this._teleportationInitialized && (this._teleportationTarget.isVisible = !0,
  56297. this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0))
  56298. }
  56299. ,
  56300. e.prototype._hideTeleportationTarget = function() {
  56301. this._teleportActive = !1,
  56302. this._teleportationInitialized && (this._teleportationTarget.isVisible = !1,
  56303. this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1))
  56304. }
  56305. ,
  56306. e.prototype._rotateCamera = function(e) {
  56307. var t = this;
  56308. if (this.currentVRCamera instanceof pa) {
  56309. e ? this._rotationAngle++ : this._rotationAngle--,
  56310. this.currentVRCamera.animations = [];
  56311. var i = C.FromRotationMatrix(P.RotationY(Math.PI / 4 * this._rotationAngle))
  56312. , n = new Qe("animationRotation","rotationQuaternion",90,Qe.ANIMATIONTYPE_QUATERNION,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56313. , r = [];
  56314. r.push({
  56315. frame: 0,
  56316. value: this.currentVRCamera.rotationQuaternion
  56317. }),
  56318. r.push({
  56319. frame: 6,
  56320. value: i
  56321. }),
  56322. n.setKeys(r),
  56323. n.setEasingFunction(this._circleEase),
  56324. this.currentVRCamera.animations.push(n),
  56325. this._postProcessMove.animations = [];
  56326. var o = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56327. , a = [];
  56328. a.push({
  56329. frame: 0,
  56330. value: 0
  56331. }),
  56332. a.push({
  56333. frame: 3,
  56334. value: 4
  56335. }),
  56336. a.push({
  56337. frame: 6,
  56338. value: 0
  56339. }),
  56340. o.setKeys(a),
  56341. o.setEasingFunction(this._circleEase),
  56342. this._postProcessMove.animations.push(o);
  56343. var s = new Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56344. , l = [];
  56345. l.push({
  56346. frame: 0,
  56347. value: 0
  56348. }),
  56349. l.push({
  56350. frame: 3,
  56351. value: 10
  56352. }),
  56353. l.push({
  56354. frame: 6,
  56355. value: 0
  56356. }),
  56357. s.setKeys(l),
  56358. s.setEasingFunction(this._circleEase),
  56359. this._postProcessMove.animations.push(s),
  56360. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
  56361. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
  56362. this._postProcessMove.samples = 4,
  56363. this._webVRCamera.attachPostProcess(this._postProcessMove),
  56364. this._scene.beginAnimation(this._postProcessMove, 0, 6, !1, 1, (function() {
  56365. t._webVRCamera.detachPostProcess(t._postProcessMove)
  56366. }
  56367. )),
  56368. this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1)
  56369. }
  56370. }
  56371. ,
  56372. e.prototype._moveTeleportationSelectorTo = function(e, t, i) {
  56373. if (e.pickedPoint) {
  56374. t._teleportationRequestInitiated && (this._displayTeleportationTarget(),
  56375. this._haloCenter.copyFrom(e.pickedPoint),
  56376. this._teleportationTarget.position.copyFrom(e.pickedPoint));
  56377. var n = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), i);
  56378. if (n) {
  56379. var r = x.Cross(vn.Y, n)
  56380. , o = x.Cross(n, r);
  56381. x.RotationFromAxisToRef(o, n, r, this._teleportationTarget.rotation)
  56382. }
  56383. this._teleportationTarget.position.y += .1
  56384. }
  56385. }
  56386. ,
  56387. e.prototype.teleportCamera = function(t) {
  56388. var i = this;
  56389. if (this.currentVRCamera instanceof pa) {
  56390. var n, r;
  56391. if (this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),
  56392. this._workingVector.subtractInPlace(this.webVRCamera.position),
  56393. t.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(t),
  56394. this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : this._workingVector.y += this._defaultHeight,
  56395. this.onBeforeCameraTeleport.notifyObservers(this._workingVector),
  56396. this._teleportationMode == e.TELEPORTATIONMODE_CONSTANTSPEED) {
  56397. r = 90;
  56398. var o = x.Distance(this.currentVRCamera.position, this._workingVector);
  56399. n = this._teleportationSpeed / o
  56400. } else
  56401. r = Math.round(90 * this._teleportationTime / 1e3),
  56402. n = 1;
  56403. this.currentVRCamera.animations = [];
  56404. var a = new Qe("animationCameraTeleportation","position",90,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56405. , s = [{
  56406. frame: 0,
  56407. value: this.currentVRCamera.position
  56408. }, {
  56409. frame: r,
  56410. value: this._workingVector
  56411. }];
  56412. a.setKeys(s),
  56413. a.setEasingFunction(this._teleportationEasing),
  56414. this.currentVRCamera.animations.push(a),
  56415. this._postProcessMove.animations = [];
  56416. var l = Math.round(r / 2)
  56417. , c = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56418. , u = [];
  56419. u.push({
  56420. frame: 0,
  56421. value: 0
  56422. }),
  56423. u.push({
  56424. frame: l,
  56425. value: 8
  56426. }),
  56427. u.push({
  56428. frame: r,
  56429. value: 0
  56430. }),
  56431. c.setKeys(u),
  56432. this._postProcessMove.animations.push(c);
  56433. var h = new Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
  56434. , d = [];
  56435. d.push({
  56436. frame: 0,
  56437. value: 0
  56438. }),
  56439. d.push({
  56440. frame: l,
  56441. value: 10
  56442. }),
  56443. d.push({
  56444. frame: r,
  56445. value: 0
  56446. }),
  56447. h.setKeys(d),
  56448. this._postProcessMove.animations.push(h),
  56449. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
  56450. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
  56451. this._webVRCamera.attachPostProcess(this._postProcessMove),
  56452. this._scene.beginAnimation(this._postProcessMove, 0, r, !1, n, (function() {
  56453. i._webVRCamera.detachPostProcess(i._postProcessMove)
  56454. }
  56455. )),
  56456. this._scene.beginAnimation(this.currentVRCamera, 0, r, !1, n, (function() {
  56457. i.onAfterCameraTeleport.notifyObservers(i._workingVector)
  56458. }
  56459. )),
  56460. this._hideTeleportationTarget()
  56461. }
  56462. }
  56463. ,
  56464. e.prototype._convertNormalToDirectionOfRay = function(e, t) {
  56465. return e && Math.acos(x.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1),
  56466. e
  56467. }
  56468. ,
  56469. e.prototype._castRayAndSelectObject = function(e) {
  56470. if (this.currentVRCamera instanceof pa) {
  56471. var t = e._getForwardRay(this._rayLength)
  56472. , i = this._scene.pickWithRay(t, this._raySelectionPredicate);
  56473. if (i && this._scene.simulatePointerMove(i, {
  56474. pointerId: e._id
  56475. }),
  56476. e._currentHit = i,
  56477. i && i.pickedPoint) {
  56478. if (this._displayGaze) {
  56479. var n = 1;
  56480. e._gazeTracker.isVisible = !0,
  56481. e._isActionableMesh && (n = 3),
  56482. this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = i.distance * n,
  56483. e._gazeTracker.scaling.y = i.distance * n,
  56484. e._gazeTracker.scaling.z = i.distance * n);
  56485. var r = this._convertNormalToDirectionOfRay(i.getNormal(), t)
  56486. , o = .002;
  56487. if (r) {
  56488. var a = x.Cross(vn.Y, r)
  56489. , s = x.Cross(r, a);
  56490. x.RotationFromAxisToRef(s, r, a, e._gazeTracker.rotation)
  56491. }
  56492. e._gazeTracker.position.copyFrom(i.pickedPoint),
  56493. e._gazeTracker.position.x < 0 ? e._gazeTracker.position.x += o : e._gazeTracker.position.x -= o,
  56494. e._gazeTracker.position.y < 0 ? e._gazeTracker.position.y += o : e._gazeTracker.position.y -= o,
  56495. e._gazeTracker.position.z < 0 ? e._gazeTracker.position.z += o : e._gazeTracker.position.z -= o
  56496. }
  56497. e._updatePointerDistance(i.distance)
  56498. } else
  56499. e._updatePointerDistance(),
  56500. e._gazeTracker.isVisible = !1;
  56501. if (i && i.pickedMesh) {
  56502. if (this._teleportationInitialized && this._isTeleportationFloor(i.pickedMesh) && i.pickedPoint)
  56503. return e._currentMeshSelected && !this._isTeleportationFloor(e._currentMeshSelected) && this._notifySelectedMeshUnselected(e._currentMeshSelected),
  56504. e._currentMeshSelected = null,
  56505. void (e._teleportationRequestInitiated && this._moveTeleportationSelectorTo(i, e, t));
  56506. if (i.pickedMesh !== e._currentMeshSelected)
  56507. if (this.meshSelectionPredicate(i.pickedMesh)) {
  56508. this.onNewMeshPicked.notifyObservers(i),
  56509. e._currentMeshSelected = i.pickedMesh,
  56510. i.pickedMesh.isPickable && i.pickedMesh.actionManager ? (this.changeGazeColor(this._pickedGazeColor),
  56511. this.changeLaserColor(this._pickedLaserColor),
  56512. e._isActionableMesh = !0) : (this.changeGazeColor(this._gazeColor),
  56513. this.changeLaserColor(this._laserColor),
  56514. e._isActionableMesh = !1);
  56515. try {
  56516. this.onNewMeshSelected.notifyObservers(i.pickedMesh);
  56517. var l = e;
  56518. l.webVRController && this.onMeshSelectedWithController.notifyObservers({
  56519. mesh: i.pickedMesh,
  56520. controller: l.webVRController
  56521. })
  56522. } catch (e) {
  56523. K.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + e)
  56524. }
  56525. } else
  56526. this._notifySelectedMeshUnselected(e._currentMeshSelected),
  56527. e._currentMeshSelected = null,
  56528. this.changeGazeColor(this._gazeColor),
  56529. this.changeLaserColor(this._laserColor)
  56530. } else
  56531. this._notifySelectedMeshUnselected(e._currentMeshSelected),
  56532. e._currentMeshSelected = null,
  56533. this.changeGazeColor(this._gazeColor),
  56534. this.changeLaserColor(this._laserColor)
  56535. }
  56536. }
  56537. ,
  56538. e.prototype._notifySelectedMeshUnselected = function(e) {
  56539. e && this.onSelectedMeshUnselected.notifyObservers(e)
  56540. }
  56541. ,
  56542. e.prototype.setLaserColor = function(e, t) {
  56543. void 0 === t && (t = this._pickedLaserColor),
  56544. this._laserColor = e,
  56545. this._pickedLaserColor = t
  56546. }
  56547. ,
  56548. e.prototype.setLaserLightingState = function(e) {
  56549. void 0 === e && (e = !0),
  56550. this._leftController && this._leftController._setLaserPointerLightingDisabled(!e),
  56551. this._rightController && this._rightController._setLaserPointerLightingDisabled(!e)
  56552. }
  56553. ,
  56554. e.prototype.setGazeColor = function(e, t) {
  56555. void 0 === t && (t = this._pickedGazeColor),
  56556. this._gazeColor = e,
  56557. this._pickedGazeColor = t
  56558. }
  56559. ,
  56560. e.prototype.changeLaserColor = function(e) {
  56561. this.updateControllerLaserColor && (this._leftController && this._leftController._setLaserPointerColor(e),
  56562. this._rightController && this._rightController._setLaserPointerColor(e))
  56563. }
  56564. ,
  56565. e.prototype.changeGazeColor = function(e) {
  56566. this.updateGazeTrackerColor && this._cameraGazer._gazeTracker.material && (this._cameraGazer._gazeTracker.material.emissiveColor = e,
  56567. this._leftController && (this._leftController._gazeTracker.material.emissiveColor = e),
  56568. this._rightController && (this._rightController._gazeTracker.material.emissiveColor = e))
  56569. }
  56570. ,
  56571. e.prototype.dispose = function() {
  56572. this.isInVRMode && this.exitVR(),
  56573. this._postProcessMove && this._postProcessMove.dispose(),
  56574. this._webVRCamera && this._webVRCamera.dispose(),
  56575. this._vrDeviceOrientationCamera && this._vrDeviceOrientationCamera.dispose(),
  56576. !this._useCustomVRButton && this._btnVR && this._btnVR.parentNode && document.body.removeChild(this._btnVR),
  56577. this._deviceOrientationCamera && this._scene.activeCamera != this._deviceOrientationCamera && this._deviceOrientationCamera.dispose(),
  56578. this._cameraGazer && this._cameraGazer.dispose(),
  56579. this._leftController && this._leftController.dispose(),
  56580. this._rightController && this._rightController.dispose(),
  56581. this._teleportationTarget && this._teleportationTarget.dispose(),
  56582. this.xr && this.xr.dispose(),
  56583. this._floorMeshesCollection = [],
  56584. document.removeEventListener("keydown", this._onKeyDown),
  56585. window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind),
  56586. window.removeEventListener("resize", this._onResize),
  56587. document.removeEventListener("fullscreenchange", this._onFullscreenChange),
  56588. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
  56589. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
  56590. document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
  56591. document.onmsfullscreenchange = null,
  56592. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChangedBind),
  56593. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),
  56594. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),
  56595. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),
  56596. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),
  56597. this._scene.unregisterBeforeRender(this._beforeRender)
  56598. }
  56599. ,
  56600. e.prototype.getClassName = function() {
  56601. return "VRExperienceHelper"
  56602. }
  56603. ,
  56604. e.TELEPORTATIONMODE_CONSTANTTIME = 0,
  56605. e.TELEPORTATIONMODE_CONSTANTSPEED = 1,
  56606. e
  56607. }(), dl = (al = {
  56608. root: 0,
  56609. found: !1
  56610. },
  56611. function(e, t, i, n) {
  56612. al.root = 0,
  56613. al.found = !1;
  56614. var r = t * t - 4 * e * i;
  56615. if (r < 0)
  56616. return al;
  56617. var o = Math.sqrt(r)
  56618. , a = (-t - o) / (2 * e)
  56619. , s = (-t + o) / (2 * e);
  56620. if (a > s) {
  56621. var l = s;
  56622. s = a,
  56623. a = l
  56624. }
  56625. return a > 0 && a < n ? (al.root = a,
  56626. al.found = !0,
  56627. al) : s > 0 && s < n ? (al.root = s,
  56628. al.found = !0,
  56629. al) : al
  56630. }
  56631. ), pl = function() {
  56632. function e() {
  56633. this._collisionPoint = x.Zero(),
  56634. this._planeIntersectionPoint = x.Zero(),
  56635. this._tempVector = x.Zero(),
  56636. this._tempVector2 = x.Zero(),
  56637. this._tempVector3 = x.Zero(),
  56638. this._tempVector4 = x.Zero(),
  56639. this._edge = x.Zero(),
  56640. this._baseToVertex = x.Zero(),
  56641. this._destinationPoint = x.Zero(),
  56642. this._slidePlaneNormal = x.Zero(),
  56643. this._displacementVector = x.Zero(),
  56644. this._radius = x.One(),
  56645. this._retry = 0,
  56646. this._basePointWorld = x.Zero(),
  56647. this._velocityWorld = x.Zero(),
  56648. this._normalizedVelocity = x.Zero(),
  56649. this._collisionMask = -1
  56650. }
  56651. return Object.defineProperty(e.prototype, "collisionMask", {
  56652. get: function() {
  56653. return this._collisionMask
  56654. },
  56655. set: function(e) {
  56656. this._collisionMask = isNaN(e) ? -1 : e
  56657. },
  56658. enumerable: !1,
  56659. configurable: !0
  56660. }),
  56661. Object.defineProperty(e.prototype, "slidePlaneNormal", {
  56662. get: function() {
  56663. return this._slidePlaneNormal
  56664. },
  56665. enumerable: !1,
  56666. configurable: !0
  56667. }),
  56668. e.prototype._initialize = function(e, t, i) {
  56669. this._velocity = t,
  56670. this._velocitySquaredLength = this._velocity.lengthSquared();
  56671. var n = Math.sqrt(this._velocitySquaredLength);
  56672. 0 === n || 1 === n ? this._normalizedVelocity.copyFromFloats(t._x, t._y, t._z) : t.scaleToRef(1 / n, this._normalizedVelocity),
  56673. this._basePoint = e,
  56674. e.multiplyToRef(this._radius, this._basePointWorld),
  56675. t.multiplyToRef(this._radius, this._velocityWorld),
  56676. this._velocityWorldLength = this._velocityWorld.length(),
  56677. this._epsilon = i,
  56678. this.collisionFound = !1
  56679. }
  56680. ,
  56681. e.prototype._checkPointInTriangle = function(e, t, i, n, r) {
  56682. t.subtractToRef(e, this._tempVector),
  56683. i.subtractToRef(e, this._tempVector2),
  56684. x.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  56685. var o = x.Dot(this._tempVector4, r);
  56686. return !(o < 0) && (n.subtractToRef(e, this._tempVector3),
  56687. x.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4),
  56688. !((o = x.Dot(this._tempVector4, r)) < 0) && (x.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4),
  56689. (o = x.Dot(this._tempVector4, r)) >= 0))
  56690. }
  56691. ,
  56692. e.prototype._canDoCollision = function(e, t, i, n) {
  56693. var r = x.Distance(this._basePointWorld, e)
  56694. , o = Math.max(this._radius.x, this._radius.y, this._radius.z);
  56695. return !(r > this._velocityWorldLength + o + t || !function(e, t, i, n) {
  56696. return !(e.x > i.x + n || i.x - n > t.x || e.y > i.y + n || i.y - n > t.y || e.z > i.z + n || i.z - n > t.z)
  56697. }(i, n, this._basePointWorld, this._velocityWorldLength + o))
  56698. }
  56699. ,
  56700. e.prototype._testTriangle = function(e, t, i, n, r, o, a) {
  56701. var s, l = !1;
  56702. t || (t = []),
  56703. t[e] || (t[e] = new hn(0,0,0,0),
  56704. t[e].copyFromPoints(i, n, r));
  56705. var c = t[e];
  56706. if (o || c.isFrontFacingTo(this._normalizedVelocity, 0)) {
  56707. var u = c.signedDistanceTo(this._basePoint)
  56708. , h = x.Dot(c.normal, this._velocity);
  56709. if (0 == h) {
  56710. if (Math.abs(u) >= 1)
  56711. return;
  56712. l = !0,
  56713. s = 0
  56714. } else {
  56715. var d = (1 - u) / h;
  56716. if ((s = (-1 - u) / h) > d) {
  56717. var p = d;
  56718. d = s,
  56719. s = p
  56720. }
  56721. if (s > 1 || d < 0)
  56722. return;
  56723. s < 0 && (s = 0),
  56724. s > 1 && (s = 1)
  56725. }
  56726. this._collisionPoint.copyFromFloats(0, 0, 0);
  56727. var f = !1
  56728. , _ = 1;
  56729. if (l || (this._basePoint.subtractToRef(c.normal, this._planeIntersectionPoint),
  56730. this._velocity.scaleToRef(s, this._tempVector),
  56731. this._planeIntersectionPoint.addInPlace(this._tempVector),
  56732. this._checkPointInTriangle(this._planeIntersectionPoint, i, n, r, c.normal) && (f = !0,
  56733. _ = s,
  56734. this._collisionPoint.copyFrom(this._planeIntersectionPoint))),
  56735. !f) {
  56736. var m = this._velocitySquaredLength;
  56737. this._basePoint.subtractToRef(i, this._tempVector);
  56738. var g = 2 * x.Dot(this._velocity, this._tempVector)
  56739. , v = this._tempVector.lengthSquared() - 1
  56740. , y = dl(m, g, v, _);
  56741. y.found && (_ = y.root,
  56742. f = !0,
  56743. this._collisionPoint.copyFrom(i)),
  56744. this._basePoint.subtractToRef(n, this._tempVector),
  56745. g = 2 * x.Dot(this._velocity, this._tempVector),
  56746. v = this._tempVector.lengthSquared() - 1,
  56747. (y = dl(m, g, v, _)).found && (_ = y.root,
  56748. f = !0,
  56749. this._collisionPoint.copyFrom(n)),
  56750. this._basePoint.subtractToRef(r, this._tempVector),
  56751. g = 2 * x.Dot(this._velocity, this._tempVector),
  56752. v = this._tempVector.lengthSquared() - 1,
  56753. (y = dl(m, g, v, _)).found && (_ = y.root,
  56754. f = !0,
  56755. this._collisionPoint.copyFrom(r)),
  56756. n.subtractToRef(i, this._edge),
  56757. i.subtractToRef(this._basePoint, this._baseToVertex);
  56758. var b, T = this._edge.lengthSquared(), E = x.Dot(this._edge, this._velocity), S = x.Dot(this._edge, this._baseToVertex);
  56759. m = T * -this._velocitySquaredLength + E * E,
  56760. g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
  56761. v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
  56762. (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
  56763. f = !0,
  56764. this._edge.scaleInPlace(b),
  56765. i.addToRef(this._edge, this._collisionPoint)),
  56766. r.subtractToRef(n, this._edge),
  56767. n.subtractToRef(this._basePoint, this._baseToVertex),
  56768. T = this._edge.lengthSquared(),
  56769. E = x.Dot(this._edge, this._velocity),
  56770. S = x.Dot(this._edge, this._baseToVertex),
  56771. m = T * -this._velocitySquaredLength + E * E,
  56772. g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
  56773. v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
  56774. (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
  56775. f = !0,
  56776. this._edge.scaleInPlace(b),
  56777. n.addToRef(this._edge, this._collisionPoint)),
  56778. i.subtractToRef(r, this._edge),
  56779. r.subtractToRef(this._basePoint, this._baseToVertex),
  56780. T = this._edge.lengthSquared(),
  56781. E = x.Dot(this._edge, this._velocity),
  56782. S = x.Dot(this._edge, this._baseToVertex),
  56783. m = T * -this._velocitySquaredLength + E * E,
  56784. g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
  56785. v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
  56786. (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
  56787. f = !0,
  56788. this._edge.scaleInPlace(b),
  56789. r.addToRef(this._edge, this._collisionPoint))
  56790. }
  56791. if (f) {
  56792. var A = _ * _ * this._velocitySquaredLength;
  56793. (!this.collisionFound || A < this._nearestDistanceSquared) && (a.collisionResponse && (this.intersectionPoint ? this.intersectionPoint.copyFrom(this._collisionPoint) : this.intersectionPoint = this._collisionPoint.clone(),
  56794. this._nearestDistanceSquared = A,
  56795. this._nearestDistance = Math.sqrt(A),
  56796. this.collisionFound = !0),
  56797. this.collidedMesh = a)
  56798. }
  56799. }
  56800. }
  56801. ,
  56802. e.prototype._collide = function(e, t, i, n, r, o, a, s, l, c) {
  56803. if (void 0 === c && (c = !1),
  56804. c)
  56805. if (i && 0 !== i.length)
  56806. for (p = n; p < r - 2; p += 1) {
  56807. var u = i[p]
  56808. , h = i[p + 1]
  56809. , d = i[p + 2];
  56810. 4294967295 !== d ? (f = t[u],
  56811. _ = t[h],
  56812. m = t[d],
  56813. f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s))) : p += 2
  56814. }
  56815. else
  56816. for (var p = 0; p < t.length - 2; p += 1) {
  56817. var f = t[p]
  56818. , _ = t[p + 1]
  56819. , m = t[p + 2];
  56820. f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s))
  56821. }
  56822. else if (i && 0 !== i.length)
  56823. for (p = n; p < r; p += 3)
  56824. f = t[i[p] - o],
  56825. _ = t[i[p + 1] - o],
  56826. m = t[i[p + 2] - o],
  56827. l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s);
  56828. else
  56829. for (p = 0; p < t.length; p += 3) {
  56830. f = t[p],
  56831. _ = t[p + 1],
  56832. m = t[p + 2];
  56833. l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s)
  56834. }
  56835. }
  56836. ,
  56837. e.prototype._getResponse = function(e, t) {
  56838. e.addToRef(t, this._destinationPoint),
  56839. t.scaleInPlace(this._nearestDistance / t.length()),
  56840. this._basePoint.addToRef(t, e),
  56841. e.subtractToRef(this.intersectionPoint, this._slidePlaneNormal),
  56842. this._slidePlaneNormal.normalize(),
  56843. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector),
  56844. e.addInPlace(this._displacementVector),
  56845. this.intersectionPoint.addInPlace(this._displacementVector),
  56846. this._slidePlaneNormal.scaleInPlace(hn.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)),
  56847. this._destinationPoint.subtractInPlace(this._slidePlaneNormal),
  56848. this._destinationPoint.subtractToRef(this.intersectionPoint, t)
  56849. }
  56850. ,
  56851. e
  56852. }(), fl = function() {
  56853. function e() {
  56854. this._scaledPosition = x.Zero(),
  56855. this._scaledVelocity = x.Zero(),
  56856. this._finalPosition = x.Zero()
  56857. }
  56858. return e.prototype.getNewPosition = function(e, t, i, n, r, o, a) {
  56859. e.divideToRef(i._radius, this._scaledPosition),
  56860. t.divideToRef(i._radius, this._scaledVelocity),
  56861. i.collidedMesh = null,
  56862. i._retry = 0,
  56863. i._initialVelocity = this._scaledVelocity,
  56864. i._initialPosition = this._scaledPosition,
  56865. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, i, n, this._finalPosition, r),
  56866. this._finalPosition.multiplyInPlace(i._radius),
  56867. o(a, this._finalPosition, i.collidedMesh)
  56868. }
  56869. ,
  56870. e.prototype.createCollider = function() {
  56871. return new pl
  56872. }
  56873. ,
  56874. e.prototype.init = function(e) {
  56875. this._scene = e
  56876. }
  56877. ,
  56878. e.prototype._collideWithWorld = function(e, t, i, n, r, o) {
  56879. void 0 === o && (o = null);
  56880. var a = 10 * vr.CollisionsEpsilon;
  56881. if (i._retry >= n)
  56882. r.copyFrom(e);
  56883. else {
  56884. var s = o ? o.collisionMask : i.collisionMask;
  56885. i._initialize(e, t, a);
  56886. for (var l = o && o.surroundingMeshes || this._scene.meshes, c = 0; c < l.length; c++) {
  56887. var u = l[c];
  56888. u.isEnabled() && u.checkCollisions && u.subMeshes && u !== o && 0 != (s & u.collisionGroup) && u._checkCollision(i)
  56889. }
  56890. i.collisionFound ? (0 === t.x && 0 === t.y && 0 === t.z || i._getResponse(e, t),
  56891. t.length() <= a ? r.copyFrom(e) : (i._retry++,
  56892. this._collideWithWorld(e, t, i, n, r, o))) : e.addToRef(t, r)
  56893. }
  56894. }
  56895. ,
  56896. e
  56897. }();
  56898. mn.CollisionCoordinatorFactory = function() {
  56899. return new fl
  56900. }
  56901. ;
  56902. var _l, ml = function() {
  56903. function e(t, i, n, r) {
  56904. void 0 === r && (r = "");
  56905. var o, a, s, l = this;
  56906. this.name = null,
  56907. this.defines = "",
  56908. this.onCompiled = null,
  56909. this.onError = null,
  56910. this.uniqueId = 0,
  56911. this.onCompileObservable = new h,
  56912. this.onErrorObservable = new h,
  56913. this.onBindObservable = new h,
  56914. this._wasPreviouslyReady = !1,
  56915. this._isReady = !1,
  56916. this._compilationError = "",
  56917. this._key = "",
  56918. this._computeSourceCodeOverride = "",
  56919. this._pipelineContext = null,
  56920. this._computeSourceCode = "",
  56921. this._rawComputeSourceCode = "",
  56922. this._shaderLanguage = st.WGSL,
  56923. this.name = t,
  56924. this._key = r,
  56925. this._engine = n,
  56926. this.uniqueId = e._UniqueIdSeed++,
  56927. this.defines = null !== (o = i.defines) && void 0 !== o ? o : "",
  56928. this.onError = i.onError,
  56929. this.onCompiled = i.onCompiled,
  56930. this._entryPoint = null !== (a = i.entryPoint) && void 0 !== a ? a : "main",
  56931. this._shaderStore = Pt.GetShadersStore(this._shaderLanguage),
  56932. this._shaderRepository = Pt.GetShadersRepository(this._shaderLanguage),
  56933. this._includeShaderStore = Pt.GetIncludesShadersStore(this._shaderLanguage);
  56934. var c = nt() ? this._engine.getHostDocument() : null;
  56935. t.computeSource ? s = "source:" + t.computeSource : t.computeElement ? (s = c ? c.getElementById(t.computeElement) : null) || (s = t.computeElement) : s = t.compute || t;
  56936. var u = {
  56937. defines: this.defines.split("\n"),
  56938. indexParameters: void 0,
  56939. isFragment: !1,
  56940. shouldUseHighPrecisionShader: !1,
  56941. processor: null,
  56942. supportsUniformBuffers: this._engine.supportsUniformBuffers,
  56943. shadersRepository: this._shaderRepository,
  56944. includesShadersStore: this._includeShaderStore,
  56945. version: (100 * this._engine.version).toString(),
  56946. platformName: this._engine.shaderPlatformName,
  56947. processingContext: null,
  56948. isNDCHalfZRange: this._engine.isNDCHalfZRange,
  56949. useReverseDepthBuffer: this._engine.useReverseDepthBuffer
  56950. };
  56951. this._loadShader(s, "Compute", "", (function(e) {
  56952. Ct.Initialize(u),
  56953. Ct.PreProcess(e, u, (function(n) {
  56954. l._rawComputeSourceCode = e,
  56955. i.processFinalCode && (n = i.processFinalCode(n));
  56956. var r = Ct.Finalize(n, "", u);
  56957. l._useFinalCode(r.vertexCode, t)
  56958. }
  56959. ), l._engine)
  56960. }
  56961. ))
  56962. }
  56963. return e.prototype._useFinalCode = function(e, t) {
  56964. if (t) {
  56965. var i = t.computeElement || t.compute || t.spectorName || t;
  56966. this._computeSourceCode = "//#define SHADER_NAME compute:" + i + "\n" + e
  56967. } else
  56968. this._computeSourceCode = e;
  56969. this._prepareEffect()
  56970. }
  56971. ,
  56972. Object.defineProperty(e.prototype, "key", {
  56973. get: function() {
  56974. return this._key
  56975. },
  56976. enumerable: !1,
  56977. configurable: !0
  56978. }),
  56979. e.prototype.isReady = function() {
  56980. try {
  56981. return this._isReadyInternal()
  56982. } catch (e) {
  56983. return !1
  56984. }
  56985. }
  56986. ,
  56987. e.prototype._isReadyInternal = function() {
  56988. return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady
  56989. }
  56990. ,
  56991. e.prototype.getEngine = function() {
  56992. return this._engine
  56993. }
  56994. ,
  56995. e.prototype.getPipelineContext = function() {
  56996. return this._pipelineContext
  56997. }
  56998. ,
  56999. e.prototype.getCompilationError = function() {
  57000. return this._compilationError
  57001. }
  57002. ,
  57003. e.prototype.executeWhenCompiled = function(e) {
  57004. var t = this;
  57005. this.isReady() ? e(this) : (this.onCompileObservable.add((function(t) {
  57006. e(t)
  57007. }
  57008. )),
  57009. this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function() {
  57010. t._checkIsReady(null)
  57011. }
  57012. ), 16))
  57013. }
  57014. ,
  57015. e.prototype._checkIsReady = function(e) {
  57016. var t = this;
  57017. try {
  57018. if (this._isReadyInternal())
  57019. return
  57020. } catch (t) {
  57021. return void this._processCompilationErrors(t, e)
  57022. }
  57023. setTimeout((function() {
  57024. t._checkIsReady(e)
  57025. }
  57026. ), 16)
  57027. }
  57028. ,
  57029. e.prototype._loadShader = function(e, t, i, n) {
  57030. var r;
  57031. "undefined" != typeof HTMLElement && e instanceof HTMLElement ? n(at(e)) : "source:" !== e.substr(0, 7) ? "base64:" !== e.substr(0, 7) ? this._shaderStore[e + t + "Shader"] ? n(this._shaderStore[e + t + "Shader"]) : i && this._shaderStore[e + i + "Shader"] ? n(this._shaderStore[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : this._shaderRepository + e,
  57032. this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n)) : n(window.atob(e.substr(7))) : n(e.substr(7))
  57033. }
  57034. ,
  57035. Object.defineProperty(e.prototype, "computeSourceCode", {
  57036. get: function() {
  57037. var e, t;
  57038. return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getComputeShaderCode()) && void 0 !== t ? t : this._computeSourceCode
  57039. },
  57040. enumerable: !1,
  57041. configurable: !0
  57042. }),
  57043. Object.defineProperty(e.prototype, "rawComputeSourceCode", {
  57044. get: function() {
  57045. return this._rawComputeSourceCode
  57046. },
  57047. enumerable: !1,
  57048. configurable: !0
  57049. }),
  57050. e.prototype._prepareEffect = function() {
  57051. var e = this
  57052. , t = this.defines
  57053. , i = this._pipelineContext;
  57054. this._isReady = !1;
  57055. try {
  57056. var n = this._engine;
  57057. this._pipelineContext = n.createComputePipelineContext(),
  57058. this._pipelineContext._name = this._key,
  57059. n._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : t, this._entryPoint),
  57060. n._executeWhenComputeStateIsCompiled(this._pipelineContext, (function() {
  57061. e._compilationError = "",
  57062. e._isReady = !0,
  57063. e.onCompiled && e.onCompiled(e),
  57064. e.onCompileObservable.notifyObservers(e),
  57065. e.onCompileObservable.clear(),
  57066. i && e.getEngine()._deleteComputePipelineContext(i)
  57067. }
  57068. )),
  57069. this._pipelineContext.isAsync && this._checkIsReady(i)
  57070. } catch (e) {
  57071. this._processCompilationErrors(e, i)
  57072. }
  57073. }
  57074. ,
  57075. e.prototype._getShaderCodeAndErrorLine = function(e, t) {
  57076. var i = null;
  57077. if (t && e) {
  57078. var n = t.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);
  57079. if (n && 2 === n.length) {
  57080. var r = parseInt(n[1])
  57081. , o = e.split("\n", -1);
  57082. o.length >= r && (i = "Offending line [".concat(r, "] in compute code: ").concat(o[r - 1]))
  57083. }
  57084. }
  57085. return [e, i]
  57086. }
  57087. ,
  57088. e.prototype._processCompilationErrors = function(t, i) {
  57089. var n, r;
  57090. if (void 0 === i && (i = null),
  57091. this._compilationError = t.message,
  57092. K.Error("Unable to compile compute effect:"),
  57093. K.Error("Defines:\r\n" + this.defines),
  57094. e.LogShaderCodeOnCompilationError) {
  57095. var o = null
  57096. , a = null;
  57097. (null === (r = this._pipelineContext) || void 0 === r ? void 0 : r._getComputeShaderCode()) && (a = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError))[0],
  57098. o = n[1],
  57099. a && (K.Error("Compute code:"),
  57100. K.Error(a))),
  57101. o && K.Error(o)
  57102. }
  57103. K.Error("Error: " + this._compilationError),
  57104. i && (this._pipelineContext = i,
  57105. this._isReady = !0,
  57106. this.onError && this.onError(this, this._compilationError),
  57107. this.onErrorObservable.notifyObservers(this))
  57108. }
  57109. ,
  57110. e.prototype.dispose = function() {
  57111. this._pipelineContext && this._pipelineContext.dispose(),
  57112. this._engine._releaseComputeEffect(this)
  57113. }
  57114. ,
  57115. e.RegisterShader = function(e, t) {
  57116. Pt.GetShadersStore(st.WGSL)["".concat(e, "ComputeShader")] = t
  57117. }
  57118. ,
  57119. e._UniqueIdSeed = 0,
  57120. e.LogShaderCodeOnCompilationError = !0,
  57121. e
  57122. }();
  57123. !function(e) {
  57124. e[e.Texture = 0] = "Texture",
  57125. e[e.StorageTexture = 1] = "StorageTexture",
  57126. e[e.UniformBuffer = 2] = "UniformBuffer",
  57127. e[e.StorageBuffer = 3] = "StorageBuffer",
  57128. e[e.TextureWithoutSampler = 4] = "TextureWithoutSampler",
  57129. e[e.Sampler = 5] = "Sampler"
  57130. }(_l || (_l = {})),
  57131. Ht.prototype.createComputeEffect = function(e, t) {
  57132. throw new Error("createComputeEffect: This engine does not support compute shaders!")
  57133. }
  57134. ,
  57135. Ht.prototype.createComputePipelineContext = function() {
  57136. throw new Error("createComputePipelineContext: This engine does not support compute shaders!")
  57137. }
  57138. ,
  57139. Ht.prototype.createComputeContext = function() {}
  57140. ,
  57141. Ht.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
  57142. throw new Error("computeDispatch: This engine does not support compute shaders!")
  57143. }
  57144. ,
  57145. Ht.prototype.areAllComputeEffectsReady = function() {
  57146. return !0
  57147. }
  57148. ,
  57149. Ht.prototype.releaseComputeEffects = function() {}
  57150. ,
  57151. Ht.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {}
  57152. ,
  57153. Ht.prototype._rebuildComputeEffects = function() {}
  57154. ,
  57155. Ht.prototype._executeWhenComputeStateIsCompiled = function(e, t) {
  57156. t()
  57157. }
  57158. ,
  57159. Ht.prototype._releaseComputeEffect = function(e) {}
  57160. ,
  57161. Ht.prototype._deleteComputePipelineContext = function(e) {}
  57162. ;
  57163. var gl = function() {
  57164. function e(e, t, i, n) {
  57165. void 0 === n && (n = {}),
  57166. this._bindings = {},
  57167. this._samplers = {},
  57168. this._contextIsDirty = !1,
  57169. this.onCompiled = null,
  57170. this.onError = null,
  57171. this.name = e,
  57172. this._engine = t,
  57173. this.uniqueId = pn.UniqueId,
  57174. this._engine.getCaps().supportComputeShaders ? n.bindingsMapping ? (this._context = t.createComputeContext(),
  57175. this._shaderPath = i,
  57176. this._options = V({
  57177. bindingsMapping: {},
  57178. defines: []
  57179. }, n)) : K.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!") : K.Error("This engine does not support compute shaders!")
  57180. }
  57181. return Object.defineProperty(e.prototype, "options", {
  57182. get: function() {
  57183. return this._options
  57184. },
  57185. enumerable: !1,
  57186. configurable: !0
  57187. }),
  57188. Object.defineProperty(e.prototype, "shaderPath", {
  57189. get: function() {
  57190. return this._shaderPath
  57191. },
  57192. enumerable: !1,
  57193. configurable: !0
  57194. }),
  57195. e.prototype.getClassName = function() {
  57196. return "ComputeShader"
  57197. }
  57198. ,
  57199. e.prototype.setTexture = function(e, t, i) {
  57200. void 0 === i && (i = !0);
  57201. var n = this._bindings[e];
  57202. this._bindings[e] = {
  57203. type: i ? _l.Texture : _l.TextureWithoutSampler,
  57204. object: t,
  57205. indexInGroupEntries: null == n ? void 0 : n.indexInGroupEntries
  57206. },
  57207. this._contextIsDirty || (this._contextIsDirty = !n || n.object !== t || n.type !== this._bindings[e].type)
  57208. }
  57209. ,
  57210. e.prototype.setStorageTexture = function(e, t) {
  57211. var i = this._bindings[e];
  57212. this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
  57213. this._bindings[e] = {
  57214. type: _l.StorageTexture,
  57215. object: t,
  57216. indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
  57217. }
  57218. }
  57219. ,
  57220. e.prototype.setUniformBuffer = function(e, t) {
  57221. var i = this._bindings[e];
  57222. this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
  57223. this._bindings[e] = {
  57224. type: _l.UniformBuffer,
  57225. object: t,
  57226. indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
  57227. }
  57228. }
  57229. ,
  57230. e.prototype.setStorageBuffer = function(e, t) {
  57231. var i = this._bindings[e];
  57232. this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
  57233. this._bindings[e] = {
  57234. type: _l.StorageBuffer,
  57235. object: t,
  57236. indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
  57237. }
  57238. }
  57239. ,
  57240. e.prototype.setTextureSampler = function(e, t) {
  57241. var i = this._bindings[e];
  57242. this._contextIsDirty || (this._contextIsDirty = !i || !t.compareSampler(i.object)),
  57243. this._bindings[e] = {
  57244. type: _l.Sampler,
  57245. object: t,
  57246. indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
  57247. }
  57248. }
  57249. ,
  57250. e.prototype.isReady = function() {
  57251. var e = this._effect;
  57252. for (var t in this._bindings) {
  57253. var i = this._bindings[t]
  57254. , n = i.type
  57255. , r = i.object;
  57256. switch (n) {
  57257. case _l.Texture:
  57258. case _l.TextureWithoutSampler:
  57259. case _l.StorageTexture:
  57260. if (!r.isReady())
  57261. return !1
  57262. }
  57263. }
  57264. var o = []
  57265. , a = this._shaderPath;
  57266. if (this._options.defines)
  57267. for (var s = 0; s < this._options.defines.length; s++)
  57268. o.push(this._options.defines[s]);
  57269. var l = o.join("\n");
  57270. return this._cachedDefines !== l && (this._cachedDefines = l,
  57271. e = this._engine.createComputeEffect(a, {
  57272. defines: l,
  57273. entryPoint: this._options.entryPoint,
  57274. onCompiled: this.onCompiled,
  57275. onError: this.onError
  57276. }),
  57277. this._effect = e),
  57278. !!e.isReady()
  57279. }
  57280. ,
  57281. e.prototype.dispatch = function(e, t, i) {
  57282. var n;
  57283. if (!this.isReady())
  57284. return !1;
  57285. for (var r in this._bindings) {
  57286. var o = this._bindings[r];
  57287. if (!this._options.bindingsMapping[r])
  57288. throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + r + "'");
  57289. if (o.type === _l.Texture) {
  57290. var a = this._samplers[r]
  57291. , s = o.object;
  57292. a && s._texture && a.compareSampler(s._texture) || (this._samplers[r] = (new Nt).setParameters(s.wrapU, s.wrapV, s.wrapR, s.anisotropicFilteringLevel, s._texture.samplingMode, null === (n = s._texture) || void 0 === n ? void 0 : n._comparisonFunction),
  57293. this._contextIsDirty = !0)
  57294. }
  57295. }
  57296. return this._contextIsDirty && (this._contextIsDirty = !1,
  57297. this._context.clear()),
  57298. this._engine.computeDispatch(this._effect, this._context, this._bindings, e, t, i, this._options.bindingsMapping),
  57299. !0
  57300. }
  57301. ,
  57302. e.prototype.dispatchWhenReady = function(e, t, i, n) {
  57303. var r = this;
  57304. return void 0 === n && (n = 10),
  57305. new Promise((function(o) {
  57306. var a = function() {
  57307. r.dispatch(e, t, i) ? o() : setTimeout(a, n)
  57308. };
  57309. a()
  57310. }
  57311. ))
  57312. }
  57313. ,
  57314. e.prototype.serialize = function() {
  57315. var e = Ge.Serialize(this);
  57316. for (var t in e.options = this._options,
  57317. e.shaderPath = this._shaderPath,
  57318. e.bindings = {},
  57319. e.textures = {},
  57320. this._bindings) {
  57321. var i = this._bindings[t]
  57322. , n = i.object;
  57323. switch (i.type) {
  57324. case _l.Texture:
  57325. case _l.TextureWithoutSampler:
  57326. case _l.StorageTexture:
  57327. var r = n.serialize();
  57328. r && (e.textures[t] = r,
  57329. e.bindings[t] = {
  57330. type: i.type
  57331. });
  57332. case _l.UniformBuffer:
  57333. }
  57334. }
  57335. return e
  57336. }
  57337. ,
  57338. e.Parse = function(t, i, n) {
  57339. var r = Ge.Parse((function() {
  57340. return new e(t.name,i.getEngine(),t.shaderPath,t.options)
  57341. }
  57342. ), t, i, n);
  57343. for (var o in t.textures) {
  57344. var a = t.bindings[o]
  57345. , s = io.Parse(t.textures[o], i, n);
  57346. a.type === _l.Texture ? r.setTexture(o, s) : a.type === _l.TextureWithoutSampler ? r.setTexture(o, s, !1) : r.setStorageTexture(o, s)
  57347. }
  57348. return r
  57349. }
  57350. ,
  57351. k([Ce()], e.prototype, "name", void 0),
  57352. e
  57353. }();
  57354. y("BABYLON.ComputeShader", gl);
  57355. var vl = function() {
  57356. function e(e, t, i, n, r, o) {
  57357. this.entries = new Array,
  57358. this._boundingVectors = new Array,
  57359. this._capacity = i,
  57360. this._depth = n,
  57361. this._maxDepth = r,
  57362. this._creationFunc = o,
  57363. this._minPoint = e,
  57364. this._maxPoint = t,
  57365. this._boundingVectors.push(e.clone()),
  57366. this._boundingVectors.push(t.clone()),
  57367. this._boundingVectors.push(e.clone()),
  57368. this._boundingVectors[2].x = t.x,
  57369. this._boundingVectors.push(e.clone()),
  57370. this._boundingVectors[3].y = t.y,
  57371. this._boundingVectors.push(e.clone()),
  57372. this._boundingVectors[4].z = t.z,
  57373. this._boundingVectors.push(t.clone()),
  57374. this._boundingVectors[5].z = e.z,
  57375. this._boundingVectors.push(t.clone()),
  57376. this._boundingVectors[6].x = e.x,
  57377. this._boundingVectors.push(t.clone()),
  57378. this._boundingVectors[7].y = e.y
  57379. }
  57380. return Object.defineProperty(e.prototype, "capacity", {
  57381. get: function() {
  57382. return this._capacity
  57383. },
  57384. enumerable: !1,
  57385. configurable: !0
  57386. }),
  57387. Object.defineProperty(e.prototype, "minPoint", {
  57388. get: function() {
  57389. return this._minPoint
  57390. },
  57391. enumerable: !1,
  57392. configurable: !0
  57393. }),
  57394. Object.defineProperty(e.prototype, "maxPoint", {
  57395. get: function() {
  57396. return this._maxPoint
  57397. },
  57398. enumerable: !1,
  57399. configurable: !0
  57400. }),
  57401. e.prototype.addEntry = function(e) {
  57402. if (this.blocks)
  57403. for (var t = 0; t < this.blocks.length; t++)
  57404. this.blocks[t].addEntry(e);
  57405. else
  57406. this._creationFunc(e, this),
  57407. this.entries.length > this.capacity && this._depth < this._maxDepth && this.createInnerBlocks()
  57408. }
  57409. ,
  57410. e.prototype.removeEntry = function(e) {
  57411. if (this.blocks)
  57412. for (var t = 0; t < this.blocks.length; t++)
  57413. this.blocks[t].removeEntry(e);
  57414. else {
  57415. var i = this.entries.indexOf(e);
  57416. i > -1 && this.entries.splice(i, 1)
  57417. }
  57418. }
  57419. ,
  57420. e.prototype.addEntries = function(e) {
  57421. for (var t = 0; t < e.length; t++) {
  57422. var i = e[t];
  57423. this.addEntry(i)
  57424. }
  57425. }
  57426. ,
  57427. e.prototype.select = function(e, t, i) {
  57428. if (tr.IsInFrustum(this._boundingVectors, e)) {
  57429. if (this.blocks) {
  57430. for (var n = 0; n < this.blocks.length; n++)
  57431. this.blocks[n].select(e, t, i);
  57432. return
  57433. }
  57434. i ? t.concat(this.entries) : t.concatWithNoDuplicate(this.entries)
  57435. }
  57436. }
  57437. ,
  57438. e.prototype.intersects = function(e, t, i, n) {
  57439. if (tr.IntersectsSphere(this._minPoint, this._maxPoint, e, t)) {
  57440. if (this.blocks) {
  57441. for (var r = 0; r < this.blocks.length; r++)
  57442. this.blocks[r].intersects(e, t, i, n);
  57443. return
  57444. }
  57445. n ? i.concat(this.entries) : i.concatWithNoDuplicate(this.entries)
  57446. }
  57447. }
  57448. ,
  57449. e.prototype.intersectsRay = function(e, t) {
  57450. if (e.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  57451. if (this.blocks) {
  57452. for (var i = 0; i < this.blocks.length; i++)
  57453. this.blocks[i].intersectsRay(e, t);
  57454. return
  57455. }
  57456. t.concatWithNoDuplicate(this.entries)
  57457. }
  57458. }
  57459. ,
  57460. e.prototype.createInnerBlocks = function() {
  57461. e._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc)
  57462. }
  57463. ,
  57464. e._CreateBlocks = function(t, i, n, r, o, a, s, l) {
  57465. s.blocks = new Array;
  57466. for (var c = new x((i.x - t.x) / 2,(i.y - t.y) / 2,(i.z - t.z) / 2), u = 0; u < 2; u++)
  57467. for (var h = 0; h < 2; h++)
  57468. for (var d = 0; d < 2; d++) {
  57469. var p = new e(t.add(c.multiplyByFloats(u, h, d)),t.add(c.multiplyByFloats(u + 1, h + 1, d + 1)),r,o + 1,a,l);
  57470. p.addEntries(n),
  57471. s.blocks.push(p)
  57472. }
  57473. }
  57474. ,
  57475. e
  57476. }()
  57477. , yl = function() {
  57478. function e(e, t, i) {
  57479. void 0 === i && (i = 2),
  57480. this.maxDepth = i,
  57481. this.dynamicContent = new Array,
  57482. this._maxBlockCapacity = t || 64,
  57483. this._selectionContent = new Ti(1024),
  57484. this._creationFunc = e
  57485. }
  57486. return e.prototype.update = function(e, t, i) {
  57487. vl._CreateBlocks(e, t, i, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc)
  57488. }
  57489. ,
  57490. e.prototype.addMesh = function(e) {
  57491. for (var t = 0; t < this.blocks.length; t++)
  57492. this.blocks[t].addEntry(e)
  57493. }
  57494. ,
  57495. e.prototype.removeMesh = function(e) {
  57496. for (var t = 0; t < this.blocks.length; t++)
  57497. this.blocks[t].removeEntry(e)
  57498. }
  57499. ,
  57500. e.prototype.select = function(e, t) {
  57501. this._selectionContent.reset();
  57502. for (var i = 0; i < this.blocks.length; i++)
  57503. this.blocks[i].select(e, this._selectionContent, t);
  57504. return t ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
  57505. this._selectionContent
  57506. }
  57507. ,
  57508. e.prototype.intersects = function(e, t, i) {
  57509. this._selectionContent.reset();
  57510. for (var n = 0; n < this.blocks.length; n++)
  57511. this.blocks[n].intersects(e, t, this._selectionContent, i);
  57512. return i ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
  57513. this._selectionContent
  57514. }
  57515. ,
  57516. e.prototype.intersectsRay = function(e) {
  57517. this._selectionContent.reset();
  57518. for (var t = 0; t < this.blocks.length; t++)
  57519. this.blocks[t].intersectsRay(e, this._selectionContent);
  57520. return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
  57521. this._selectionContent
  57522. }
  57523. ,
  57524. e.CreationFuncForMeshes = function(e, t) {
  57525. var i = e.getBoundingInfo();
  57526. !e.isBlocked && i.boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e)
  57527. }
  57528. ,
  57529. e.CreationFuncForSubMeshes = function(e, t) {
  57530. e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e)
  57531. }
  57532. ,
  57533. e
  57534. }();
  57535. mn.prototype.createOrUpdateSelectionOctree = function(e, t) {
  57536. void 0 === e && (e = 64),
  57537. void 0 === t && (t = 2);
  57538. var i = this._getComponent(Wi.NAME_OCTREE);
  57539. i || (i = new Tl(this),
  57540. this._addComponent(i)),
  57541. this._selectionOctree || (this._selectionOctree = new yl(yl.CreationFuncForMeshes,e,t));
  57542. var n = this.getWorldExtends();
  57543. return this._selectionOctree.update(n.min, n.max, this.meshes),
  57544. this._selectionOctree
  57545. }
  57546. ,
  57547. Object.defineProperty(mn.prototype, "selectionOctree", {
  57548. get: function() {
  57549. return this._selectionOctree
  57550. },
  57551. enumerable: !0,
  57552. configurable: !0
  57553. }),
  57554. Sr.prototype.createOrUpdateSubmeshesOctree = function(e, t) {
  57555. void 0 === e && (e = 64),
  57556. void 0 === t && (t = 2);
  57557. var i = this.getScene()
  57558. , n = i._getComponent(Wi.NAME_OCTREE);
  57559. n || (n = new Tl(i),
  57560. i._addComponent(n)),
  57561. this._submeshesOctree || (this._submeshesOctree = new yl(yl.CreationFuncForSubMeshes,e,t)),
  57562. this.computeWorldMatrix(!0);
  57563. var r = this.getBoundingInfo().boundingBox;
  57564. return this._submeshesOctree.update(r.minimumWorld, r.maximumWorld, this.subMeshes),
  57565. this._submeshesOctree
  57566. }
  57567. ;
  57568. var bl, Tl = function() {
  57569. function e(e) {
  57570. this.name = Wi.NAME_OCTREE,
  57571. this.checksIsEnabled = !0,
  57572. this._tempRay = new _o(x.Zero(),new x(1,1,1)),
  57573. (e = e || E.LastCreatedScene) && (this.scene = e,
  57574. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this),
  57575. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this),
  57576. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this),
  57577. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this))
  57578. }
  57579. return e.prototype.register = function() {
  57580. var e = this;
  57581. this.scene.onMeshRemovedObservable.add((function(t) {
  57582. var i = e.scene.selectionOctree;
  57583. if (null != i) {
  57584. var n = i.dynamicContent.indexOf(t);
  57585. -1 !== n && i.dynamicContent.splice(n, 1)
  57586. }
  57587. }
  57588. )),
  57589. this.scene.onMeshImportedObservable.add((function(t) {
  57590. var i = e.scene.selectionOctree;
  57591. null != i && i.addMesh(t)
  57592. }
  57593. ))
  57594. }
  57595. ,
  57596. e.prototype.getActiveMeshCandidates = function() {
  57597. return this.scene._selectionOctree ? this.scene._selectionOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultMeshCandidates()
  57598. }
  57599. ,
  57600. e.prototype.getActiveSubMeshCandidates = function(e) {
  57601. return e._submeshesOctree && e.useOctreeForRenderingSelection ? e._submeshesOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultSubMeshCandidates(e)
  57602. }
  57603. ,
  57604. e.prototype.getIntersectingSubMeshCandidates = function(e, t) {
  57605. return e._submeshesOctree && e.useOctreeForPicking ? (_o.TransformToRef(t, e.getWorldMatrix(), this._tempRay),
  57606. e._submeshesOctree.intersectsRay(this._tempRay)) : this.scene._getDefaultSubMeshCandidates(e)
  57607. }
  57608. ,
  57609. e.prototype.getCollidingSubMeshCandidates = function(e, t) {
  57610. if (e._submeshesOctree && e.useOctreeForCollisions) {
  57611. var i = t._velocityWorldLength + Math.max(t._radius.x, t._radius.y, t._radius.z);
  57612. return e._submeshesOctree.intersects(t._basePointWorld, i)
  57613. }
  57614. return this.scene._getDefaultSubMeshCandidates(e)
  57615. }
  57616. ,
  57617. e.prototype.rebuild = function() {}
  57618. ,
  57619. e.prototype.dispose = function() {}
  57620. ,
  57621. e
  57622. }(), El = function() {
  57623. function e(e, t) {
  57624. void 0 === t && (t = !0);
  57625. var i = this;
  57626. this.originalScene = e,
  57627. this._pointerCaptures = {},
  57628. this._lastPointerEvents = {},
  57629. this._sharedGizmoLight = null,
  57630. this._renderCamera = null,
  57631. this.pickUtilitySceneFirst = !0,
  57632. this.shouldRender = !0,
  57633. this.onlyCheckPointerDownEvents = !0,
  57634. this.processAllEvents = !1,
  57635. this.pickingEnabled = !0,
  57636. this.onPointerOutObservable = new h,
  57637. this.utilityLayerScene = new mn(e.getEngine(),{
  57638. virtual: !0
  57639. }),
  57640. this.utilityLayerScene.useRightHandedSystem = e.useRightHandedSystem,
  57641. this.utilityLayerScene._allowPostProcessClearColor = !1,
  57642. this.utilityLayerScene.postProcessesEnabled = !1,
  57643. this.utilityLayerScene.detachControl(),
  57644. t && (this._originalPointerObserver = e.onPrePointerObservable.add((function(t) {
  57645. if (i.utilityLayerScene.activeCamera && i.pickingEnabled && (i.processAllEvents || t.type === Xi.POINTERMOVE || t.type === Xi.POINTERUP || t.type === Xi.POINTERDOWN || t.type === Xi.POINTERDOUBLETAP)) {
  57646. i.utilityLayerScene.pointerX = e.pointerX,
  57647. i.utilityLayerScene.pointerY = e.pointerY;
  57648. var n = t.event;
  57649. if (e.isPointerCaptured(n.pointerId))
  57650. i._pointerCaptures[n.pointerId] = !1;
  57651. else {
  57652. var r = function(n) {
  57653. var r = null;
  57654. if (t.nearInteractionPickingInfo)
  57655. r = t.nearInteractionPickingInfo.pickedMesh.getScene() == n ? t.nearInteractionPickingInfo : new Ui;
  57656. else {
  57657. var o = null;
  57658. i._renderCamera && (o = n._activeCamera,
  57659. n._activeCamera = i._renderCamera,
  57660. t.ray = null),
  57661. r = t.ray ? n.pickWithRay(t.ray) : n.pick(e.pointerX, e.pointerY),
  57662. o && (n._activeCamera = o)
  57663. }
  57664. return r
  57665. }
  57666. , o = r(i.utilityLayerScene);
  57667. if (!t.ray && o && (t.ray = o.ray),
  57668. i.utilityLayerScene.onPrePointerObservable.notifyObservers(t),
  57669. i.onlyCheckPointerDownEvents && t.type != Xi.POINTERDOWN)
  57670. return t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
  57671. void (t.type === Xi.POINTERUP && i._pointerCaptures[n.pointerId] && (i._pointerCaptures[n.pointerId] = !1));
  57672. if (i.utilityLayerScene.autoClearDepthAndStencil || i.pickUtilitySceneFirst)
  57673. o && o.hit && (t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
  57674. t.skipOnPointerObservable = !0);
  57675. else {
  57676. var a = r(e)
  57677. , s = t.event;
  57678. a && o && (0 === o.distance && a.pickedMesh ? i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s),
  57679. t.skipOnPointerObservable = !0) : t.type === Xi.POINTERDOWN ? i._pointerCaptures[s.pointerId] = !0 : t.type !== Xi.POINTERMOVE && t.type !== Xi.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId),
  57680. delete i._lastPointerEvents[s.pointerId]),
  57681. i._notifyObservers(t, a, s)) : !i._pointerCaptures[s.pointerId] && (o.distance < a.distance || 0 === a.distance) ? (i._notifyObservers(t, o, s),
  57682. t.skipOnPointerObservable || (t.skipOnPointerObservable = o.distance > 0)) : !i._pointerCaptures[s.pointerId] && o.distance > a.distance && (i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s),
  57683. t.skipOnPointerObservable = !0) : t.type !== Xi.POINTERMOVE && t.type !== Xi.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId),
  57684. delete i._lastPointerEvents[s.pointerId]),
  57685. i._notifyObservers(t, o, s))),
  57686. t.type === Xi.POINTERUP && i._pointerCaptures[s.pointerId] && (i._pointerCaptures[s.pointerId] = !1))
  57687. }
  57688. }
  57689. }
  57690. }
  57691. )),
  57692. this._originalPointerObserver && e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),
  57693. this.utilityLayerScene.autoClear = !1,
  57694. this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add((function(e) {
  57695. i.shouldRender && e == i.getRenderCamera() && (e.outputRenderTarget && e.isRigCamera && i.originalScene.getEngine().clear(null, !1, !0, !1),
  57696. i.render())
  57697. }
  57698. )),
  57699. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add((function() {
  57700. i.dispose()
  57701. }
  57702. )),
  57703. this._updateCamera()
  57704. }
  57705. return e.prototype.getRenderCamera = function(e) {
  57706. if (this._renderCamera)
  57707. return this._renderCamera;
  57708. var t;
  57709. return t = this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : this.originalScene.activeCamera,
  57710. e && t && t.isRigCamera ? t.rigParent : t
  57711. }
  57712. ,
  57713. e.prototype.setRenderCamera = function(e) {
  57714. this._renderCamera = e
  57715. }
  57716. ,
  57717. e.prototype._getSharedGizmoLight = function() {
  57718. return this._sharedGizmoLight || (this._sharedGizmoLight = new ds("shared gizmo light",new x(0,1,0),this.utilityLayerScene),
  57719. this._sharedGizmoLight.intensity = 2,
  57720. this._sharedGizmoLight.groundColor = D.Gray()),
  57721. this._sharedGizmoLight
  57722. }
  57723. ,
  57724. Object.defineProperty(e, "DefaultUtilityLayer", {
  57725. get: function() {
  57726. return null == e._DefaultUtilityLayer ? e._CreateDefaultUtilityLayerFromScene(E.LastCreatedScene) : e._DefaultUtilityLayer
  57727. },
  57728. enumerable: !1,
  57729. configurable: !0
  57730. }),
  57731. e._CreateDefaultUtilityLayerFromScene = function(t) {
  57732. return e._DefaultUtilityLayer = new e(t),
  57733. e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function() {
  57734. e._DefaultUtilityLayer = null
  57735. }
  57736. )),
  57737. e._DefaultUtilityLayer
  57738. }
  57739. ,
  57740. Object.defineProperty(e, "DefaultKeepDepthUtilityLayer", {
  57741. get: function() {
  57742. return null == e._DefaultKeepDepthUtilityLayer && (e._DefaultKeepDepthUtilityLayer = new e(E.LastCreatedScene),
  57743. e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
  57744. e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function() {
  57745. e._DefaultKeepDepthUtilityLayer = null
  57746. }
  57747. ))),
  57748. e._DefaultKeepDepthUtilityLayer
  57749. },
  57750. enumerable: !1,
  57751. configurable: !0
  57752. }),
  57753. e.prototype._notifyObservers = function(e, t, i) {
  57754. e.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(e.type,e.event,t), e.type),
  57755. this._lastPointerEvents[i.pointerId] = !0)
  57756. }
  57757. ,
  57758. e.prototype.render = function() {
  57759. if (this._updateCamera(),
  57760. this.utilityLayerScene.activeCamera) {
  57761. var e = this.utilityLayerScene.activeCamera.getScene()
  57762. , t = this.utilityLayerScene.activeCamera;
  57763. t._scene = this.utilityLayerScene,
  57764. t.leftCamera && (t.leftCamera._scene = this.utilityLayerScene),
  57765. t.rightCamera && (t.rightCamera._scene = this.utilityLayerScene),
  57766. this.utilityLayerScene.render(!1),
  57767. t._scene = e,
  57768. t.leftCamera && (t.leftCamera._scene = e),
  57769. t.rightCamera && (t.rightCamera._scene = e)
  57770. }
  57771. }
  57772. ,
  57773. e.prototype.dispose = function() {
  57774. this.onPointerOutObservable.clear(),
  57775. this._afterRenderObserver && this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),
  57776. this._sceneDisposeObserver && this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),
  57777. this._originalPointerObserver && this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),
  57778. this.utilityLayerScene.dispose()
  57779. }
  57780. ,
  57781. e.prototype._updateCamera = function() {
  57782. this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(),
  57783. this.utilityLayerScene.activeCamera = this.getRenderCamera()
  57784. }
  57785. ,
  57786. e._DefaultUtilityLayer = null,
  57787. e._DefaultKeepDepthUtilityLayer = null,
  57788. e
  57789. }(), Sl = function() {
  57790. function e(e) {
  57791. void 0 === e && (e = El.DefaultUtilityLayer);
  57792. var t = this;
  57793. this.gizmoLayer = e,
  57794. this._attachedMesh = null,
  57795. this._attachedNode = null,
  57796. this._customRotationQuaternion = null,
  57797. this._scaleRatio = 1,
  57798. this._isHovered = !1,
  57799. this._customMeshSet = !1,
  57800. this._updateGizmoRotationToMatchAttachedMesh = !0,
  57801. this.updateGizmoPositionToMatchAttachedMesh = !0,
  57802. this.updateScale = !0,
  57803. this._interactionsEnabled = !0,
  57804. this._tempQuaternion = new C(0,0,0,1),
  57805. this._tempVector = new x,
  57806. this._tempVector2 = new x,
  57807. this._tempMatrix1 = new P,
  57808. this._tempMatrix2 = new P,
  57809. this._rightHandtoLeftHandMatrix = P.RotationY(Math.PI),
  57810. this._rootMesh = new Vr("gizmoRootNode",e.utilityLayerScene),
  57811. this._rootMesh.rotationQuaternion = C.Identity(),
  57812. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function() {
  57813. t._update()
  57814. }
  57815. ))
  57816. }
  57817. return Object.defineProperty(e.prototype, "scaleRatio", {
  57818. get: function() {
  57819. return this._scaleRatio
  57820. },
  57821. set: function(e) {
  57822. this._scaleRatio = e
  57823. },
  57824. enumerable: !1,
  57825. configurable: !0
  57826. }),
  57827. Object.defineProperty(e.prototype, "isHovered", {
  57828. get: function() {
  57829. return this._isHovered
  57830. },
  57831. enumerable: !1,
  57832. configurable: !0
  57833. }),
  57834. Object.defineProperty(e.prototype, "attachedMesh", {
  57835. get: function() {
  57836. return this._attachedMesh
  57837. },
  57838. set: function(e) {
  57839. this._attachedMesh = e,
  57840. e && (this._attachedNode = e),
  57841. this._rootMesh.setEnabled(!!e),
  57842. this._attachedNodeChanged(e)
  57843. },
  57844. enumerable: !1,
  57845. configurable: !0
  57846. }),
  57847. Object.defineProperty(e.prototype, "attachedNode", {
  57848. get: function() {
  57849. return this._attachedNode
  57850. },
  57851. set: function(e) {
  57852. this._attachedNode = e,
  57853. this._attachedMesh = null,
  57854. this._rootMesh.setEnabled(!!e),
  57855. this._attachedNodeChanged(e)
  57856. },
  57857. enumerable: !1,
  57858. configurable: !0
  57859. }),
  57860. e.prototype.setCustomMesh = function(e) {
  57861. if (e.getScene() != this.gizmoLayer.utilityLayerScene)
  57862. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  57863. this._rootMesh.getChildMeshes().forEach((function(e) {
  57864. e.dispose()
  57865. }
  57866. )),
  57867. e.parent = this._rootMesh,
  57868. this._customMeshSet = !0
  57869. }
  57870. ,
  57871. Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  57872. get: function() {
  57873. return this._updateGizmoRotationToMatchAttachedMesh
  57874. },
  57875. set: function(e) {
  57876. this._updateGizmoRotationToMatchAttachedMesh = e
  57877. },
  57878. enumerable: !1,
  57879. configurable: !0
  57880. }),
  57881. e.prototype._attachedNodeChanged = function(e) {}
  57882. ,
  57883. Object.defineProperty(e.prototype, "customRotationQuaternion", {
  57884. get: function() {
  57885. return this._customRotationQuaternion
  57886. },
  57887. set: function(e) {
  57888. this._customRotationQuaternion = e
  57889. },
  57890. enumerable: !1,
  57891. configurable: !0
  57892. }),
  57893. e.prototype._update = function() {
  57894. if (this.attachedNode) {
  57895. var e = this.attachedNode;
  57896. if (this.attachedMesh && (e = this.attachedMesh || this.attachedNode),
  57897. this.updateGizmoPositionToMatchAttachedMesh) {
  57898. var t = e.getWorldMatrix().getRow(3)
  57899. , i = t ? t.toVector3() : new x(0,0,0);
  57900. this._rootMesh.position.copyFrom(i)
  57901. }
  57902. if (this.updateGizmoRotationToMatchAttachedMesh ? e.getWorldMatrix().decompose(void 0, this._rootMesh.rotationQuaternion) : this._customRotationQuaternion ? this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion) : this._rootMesh.rotationQuaternion.set(0, 0, 0, 1),
  57903. this.updateScale) {
  57904. var n = this.gizmoLayer.utilityLayerScene.activeCamera
  57905. , r = n.globalPosition;
  57906. n.devicePosition && (r = n.devicePosition),
  57907. this._rootMesh.position.subtractToRef(r, this._tempVector);
  57908. var o = this._tempVector.length() * this.scaleRatio;
  57909. this._rootMesh.scaling.set(o, o, o),
  57910. e._getWorldMatrixDeterminant() < 0 && (this._rootMesh.scaling.y *= -1)
  57911. } else
  57912. this._rootMesh.scaling.setAll(this.scaleRatio)
  57913. }
  57914. }
  57915. ,
  57916. e.prototype._handlePivot = function() {
  57917. var e = this._attachedNode;
  57918. e.isUsingPivotMatrix && e.isUsingPivotMatrix() && e.position && e.getWorldMatrix().setTranslation(e.position)
  57919. }
  57920. ,
  57921. e.prototype._matrixChanged = function() {
  57922. if (this._attachedNode)
  57923. if (this._attachedNode._isCamera) {
  57924. var e = this._attachedNode
  57925. , t = void 0
  57926. , i = void 0;
  57927. if (e.parent) {
  57928. var n = this._tempMatrix2;
  57929. e.parent._worldMatrix.invertToRef(n),
  57930. this._attachedNode._worldMatrix.multiplyToRef(n, this._tempMatrix1),
  57931. t = this._tempMatrix1
  57932. } else
  57933. t = this._attachedNode._worldMatrix;
  57934. if (e.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(t, this._tempMatrix2),
  57935. i = this._tempMatrix2) : i = t,
  57936. i.decompose(this._tempVector2, this._tempQuaternion, this._tempVector),
  57937. "FreeCamera" === this._attachedNode.getClassName() || "FlyCamera" === this._attachedNode.getClassName() || "ArcFollowCamera" === this._attachedNode.getClassName() || "TargetCamera" === this._attachedNode.getClassName() || "TouchCamera" === this._attachedNode.getClassName() || "UniversalCamera" === this._attachedNode.getClassName()) {
  57938. var r = this._attachedNode;
  57939. r.rotation = this._tempQuaternion.toEulerAngles(),
  57940. r.rotationQuaternion && (r.rotationQuaternion.copyFrom(this._tempQuaternion),
  57941. r.rotationQuaternion.normalize())
  57942. }
  57943. e.position.copyFrom(this._tempVector)
  57944. } else if (this._attachedNode._isMesh || "AbstractMesh" === this._attachedNode.getClassName() || "TransformNode" === this._attachedNode.getClassName() || "InstancedMesh" === this._attachedNode.getClassName()) {
  57945. var o = this._attachedNode;
  57946. if (o.parent) {
  57947. n = this._tempMatrix1;
  57948. var a = this._tempMatrix2;
  57949. o.parent.getWorldMatrix().invertToRef(n),
  57950. this._attachedNode.getWorldMatrix().multiplyToRef(n, a),
  57951. a.decompose(o.scaling, this._tempQuaternion, o.position)
  57952. } else
  57953. this._attachedNode._worldMatrix.decompose(o.scaling, this._tempQuaternion, o.position);
  57954. o.billboardMode || (o.rotationQuaternion ? (o.rotationQuaternion.copyFrom(this._tempQuaternion),
  57955. o.rotationQuaternion.normalize()) : o.rotation = this._tempQuaternion.toEulerAngles())
  57956. } else if ("Bone" === this._attachedNode.getClassName()) {
  57957. var s = this._attachedNode
  57958. , l = s.getParent();
  57959. if (l) {
  57960. var c = this._tempMatrix1
  57961. , u = this._tempMatrix2;
  57962. l.getWorldMatrix().invertToRef(c),
  57963. s.getWorldMatrix().multiplyToRef(c, u),
  57964. s.getLocalMatrix().copyFrom(u)
  57965. } else
  57966. s.getLocalMatrix().copyFrom(s.getWorldMatrix());
  57967. s.markAsDirty()
  57968. } else {
  57969. var h = this._attachedNode;
  57970. if (h.getTypeID) {
  57971. var d = h.getTypeID();
  57972. if (d === Cr.LIGHTTYPEID_DIRECTIONALLIGHT || d === Cr.LIGHTTYPEID_SPOTLIGHT || d === Cr.LIGHTTYPEID_POINTLIGHT) {
  57973. var p = h.parent;
  57974. if (p) {
  57975. c = this._tempMatrix1;
  57976. var f = this._tempMatrix2;
  57977. p.getWorldMatrix().invertToRef(c),
  57978. h.getWorldMatrix().multiplyToRef(c, f),
  57979. f.decompose(void 0, this._tempQuaternion, this._tempVector)
  57980. } else
  57981. this._attachedNode._worldMatrix.decompose(void 0, this._tempQuaternion, this._tempVector);
  57982. h.position = new x(this._tempVector.x,this._tempVector.y,this._tempVector.z),
  57983. x.Backward(!1).rotateByQuaternionToRef(this._tempQuaternion, this._tempVector),
  57984. h.direction = new x(this._tempVector.x,this._tempVector.y,this._tempVector.z)
  57985. }
  57986. }
  57987. }
  57988. }
  57989. ,
  57990. e.prototype._setGizmoMeshMaterial = function(e, t) {
  57991. e && e.forEach((function(e) {
  57992. e.material = t,
  57993. e.color && (e.color = t.diffuseColor)
  57994. }
  57995. ))
  57996. }
  57997. ,
  57998. e.GizmoAxisPointerObserver = function(e, t) {
  57999. var i = !1
  58000. , n = e.utilityLayerScene.onPointerObservable.add((function(e) {
  58001. var n, r;
  58002. if (e.pickInfo) {
  58003. if (e.type === Xi.POINTERMOVE) {
  58004. if (i)
  58005. return;
  58006. t.forEach((function(t) {
  58007. var i, n;
  58008. if (t.colliderMeshes && t.gizmoMeshes) {
  58009. var r = -1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh))
  58010. , o = t.dragBehavior.enabled ? r || t.active ? t.hoverMaterial : t.material : t.disableMaterial;
  58011. t.gizmoMeshes.forEach((function(e) {
  58012. e.material = o,
  58013. e.color && (e.color = o.diffuseColor)
  58014. }
  58015. ))
  58016. }
  58017. }
  58018. ))
  58019. }
  58020. e.type === Xi.POINTERDOWN && t.has(null === (n = e.pickInfo.pickedMesh) || void 0 === n ? void 0 : n.parent) && (i = !0,
  58021. t.get(null === (r = e.pickInfo.pickedMesh) || void 0 === r ? void 0 : r.parent).active = !0,
  58022. t.forEach((function(t) {
  58023. var i, n, r = (-1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh)) || t.active) && t.dragBehavior.enabled ? t.hoverMaterial : t.disableMaterial;
  58024. t.gizmoMeshes.forEach((function(e) {
  58025. e.material = r,
  58026. e.color && (e.color = r.diffuseColor)
  58027. }
  58028. ))
  58029. }
  58030. ))),
  58031. e.type === Xi.POINTERUP && t.forEach((function(e) {
  58032. e.active = !1,
  58033. i = !1,
  58034. e.gizmoMeshes.forEach((function(t) {
  58035. t.material = e.dragBehavior.enabled ? e.material : e.disableMaterial,
  58036. t.color && (t.color = e.material.diffuseColor)
  58037. }
  58038. ))
  58039. }
  58040. ))
  58041. }
  58042. }
  58043. ));
  58044. return n
  58045. }
  58046. ,
  58047. e.prototype.dispose = function() {
  58048. this._rootMesh.dispose(),
  58049. this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)
  58050. }
  58051. ,
  58052. e
  58053. }(), Al = function(e) {
  58054. function t(i, n, r, o, a) {
  58055. void 0 === n && (n = D.Gray()),
  58056. void 0 === r && (r = El.DefaultUtilityLayer),
  58057. void 0 === o && (o = null),
  58058. void 0 === a && (a = 1);
  58059. var s, l = this;
  58060. (l = e.call(this, r) || this)._pointerObserver = null,
  58061. l.snapDistance = 0,
  58062. l.onSnapObservable = new h,
  58063. l._isEnabled = !0,
  58064. l._parent = null,
  58065. l._dragging = !1,
  58066. l._parent = o,
  58067. l._coloredMaterial = new Os("",r.utilityLayerScene),
  58068. l._coloredMaterial.diffuseColor = n,
  58069. l._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
  58070. l._hoverMaterial = new Os("",r.utilityLayerScene),
  58071. l._hoverMaterial.diffuseColor = D.Yellow(),
  58072. l._disableMaterial = new Os("",r.utilityLayerScene),
  58073. l._disableMaterial.diffuseColor = D.Gray(),
  58074. l._disableMaterial.alpha = .4;
  58075. var c = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a)
  58076. , u = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a + 4, !0);
  58077. l._gizmoMesh = new Vr("",r.utilityLayerScene),
  58078. l._gizmoMesh.addChild(c),
  58079. l._gizmoMesh.addChild(u),
  58080. l._gizmoMesh.lookAt(l._rootMesh.position.add(i)),
  58081. l._gizmoMesh.scaling.scaleInPlace(1 / 3),
  58082. l._gizmoMesh.parent = l._rootMesh;
  58083. var d = 0
  58084. , p = new x
  58085. , f = new x
  58086. , _ = {
  58087. snapDistance: 0
  58088. };
  58089. l.dragBehavior = new Ao({
  58090. dragAxis: i
  58091. }),
  58092. l.dragBehavior.moveAttached = !1,
  58093. l._rootMesh.addBehavior(l.dragBehavior),
  58094. l.dragBehavior.onDragObservable.add((function(e) {
  58095. if (l.attachedNode) {
  58096. l._handlePivot();
  58097. var t = !1;
  58098. if (0 == l.snapDistance)
  58099. l.attachedNode.getWorldMatrix().getTranslationToRef(f),
  58100. f.addInPlace(e.delta),
  58101. l.dragBehavior.validateDrag(f) && (l.attachedNode.position && l.attachedNode.position.addInPlaceFromFloats(e.delta.x, e.delta.y, e.delta.z),
  58102. l.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x, e.delta.y, e.delta.z),
  58103. l.attachedNode.updateCache(),
  58104. t = !0);
  58105. else if (d += e.dragDistance,
  58106. Math.abs(d) > l.snapDistance) {
  58107. var i = Math.floor(Math.abs(d) / l.snapDistance);
  58108. d %= l.snapDistance,
  58109. e.delta.normalizeToRef(p),
  58110. p.scaleInPlace(l.snapDistance * i),
  58111. l.attachedNode.getWorldMatrix().getTranslationToRef(f),
  58112. f.addInPlace(p),
  58113. l.dragBehavior.validateDrag(f) && (l.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x, p.y, p.z),
  58114. l.attachedNode.updateCache(),
  58115. _.snapDistance = l.snapDistance * i,
  58116. l.onSnapObservable.notifyObservers(_),
  58117. t = !0)
  58118. }
  58119. t && l._matrixChanged()
  58120. }
  58121. }
  58122. )),
  58123. l.dragBehavior.onDragStartObservable.add((function() {
  58124. l._dragging = !0
  58125. }
  58126. )),
  58127. l.dragBehavior.onDragEndObservable.add((function() {
  58128. l._dragging = !1
  58129. }
  58130. ));
  58131. var m = r._getSharedGizmoLight();
  58132. m.includedOnlyMeshes = m.includedOnlyMeshes.concat(l._rootMesh.getChildMeshes(!1));
  58133. var g = {
  58134. gizmoMeshes: c.getChildMeshes(),
  58135. colliderMeshes: u.getChildMeshes(),
  58136. material: l._coloredMaterial,
  58137. hoverMaterial: l._hoverMaterial,
  58138. disableMaterial: l._disableMaterial,
  58139. active: !1,
  58140. dragBehavior: l.dragBehavior
  58141. };
  58142. return null === (s = l._parent) || void 0 === s || s.addToAxisCache(u, g),
  58143. l._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
  58144. var t;
  58145. if (!l._customMeshSet && (l._isHovered = !(-1 == g.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
  58146. !l._parent)) {
  58147. var i = l.dragBehavior.enabled ? l._isHovered || l._dragging ? l._hoverMaterial : l._coloredMaterial : l._disableMaterial;
  58148. l._setGizmoMeshMaterial(g.gizmoMeshes, i)
  58149. }
  58150. }
  58151. )),
  58152. l.dragBehavior.onEnabledObservable.add((function(e) {
  58153. l._setGizmoMeshMaterial(g.gizmoMeshes, e ? g.material : g.disableMaterial)
  58154. }
  58155. )),
  58156. l
  58157. }
  58158. return U(t, e),
  58159. t._CreateArrow = function(e, t, i, n) {
  58160. void 0 === i && (i = 1),
  58161. void 0 === n && (n = !1);
  58162. var r = new yr("arrow",e)
  58163. , o = Ys("cylinder", {
  58164. diameterTop: 0,
  58165. height: .075,
  58166. diameterBottom: .0375 * (1 + (i - 1) / 4),
  58167. tessellation: 96
  58168. }, e)
  58169. , a = Ys("cylinder", {
  58170. diameterTop: .005 * i,
  58171. height: .275,
  58172. diameterBottom: .005 * i,
  58173. tessellation: 96
  58174. }, e);
  58175. return o.parent = r,
  58176. o.material = t,
  58177. o.rotation.x = Math.PI / 2,
  58178. o.position.z += .3,
  58179. a.parent = r,
  58180. a.material = t,
  58181. a.position.z += .1375,
  58182. a.rotation.x = Math.PI / 2,
  58183. n && (a.visibility = 0,
  58184. o.visibility = 0),
  58185. r
  58186. }
  58187. ,
  58188. t._CreateArrowInstance = function(e, t) {
  58189. for (var i = new yr("arrow",e), n = 0, r = t.getChildMeshes(); n < r.length; n++) {
  58190. var o = r[n];
  58191. o.createInstance(o.name).parent = i
  58192. }
  58193. return i
  58194. }
  58195. ,
  58196. t.prototype._attachedNodeChanged = function(e) {
  58197. this.dragBehavior && (this.dragBehavior.enabled = !!e)
  58198. }
  58199. ,
  58200. Object.defineProperty(t.prototype, "isEnabled", {
  58201. get: function() {
  58202. return this._isEnabled
  58203. },
  58204. set: function(e) {
  58205. this._isEnabled = e,
  58206. e ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
  58207. this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
  58208. this.attachedNode = null)
  58209. },
  58210. enumerable: !1,
  58211. configurable: !0
  58212. }),
  58213. t.prototype.dispose = function() {
  58214. this.onSnapObservable.clear(),
  58215. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  58216. this.dragBehavior.detach(),
  58217. this._gizmoMesh && this._gizmoMesh.dispose(),
  58218. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
  58219. e && e.dispose()
  58220. }
  58221. )),
  58222. e.prototype.dispose.call(this)
  58223. }
  58224. ,
  58225. t
  58226. }(Sl), xl = function() {
  58227. function e(t, i, n, r, o, a, s) {
  58228. if (void 0 === i && (i = 1),
  58229. void 0 === n && (n = 2),
  58230. void 0 === s && (s = 1),
  58231. this._scaleLinesFactor = 4,
  58232. this._instanced = !1,
  58233. this.scene = null,
  58234. this.scaleLines = 1,
  58235. t = t || E.LastCreatedScene) {
  58236. if (this.scaleLines = i,
  58237. !r) {
  58238. var l = new Os("",t);
  58239. l.disableLighting = !0,
  58240. l.emissiveColor = D.Red().scale(.5),
  58241. r = Al._CreateArrow(t, l, s)
  58242. }
  58243. if (!o) {
  58244. var c = new Os("",t);
  58245. c.disableLighting = !0,
  58246. c.emissiveColor = D.Green().scale(.5),
  58247. o = Al._CreateArrow(t, c, s)
  58248. }
  58249. if (!a) {
  58250. var u = new Os("",t);
  58251. u.disableLighting = !0,
  58252. u.emissiveColor = D.Blue().scale(.5),
  58253. a = Al._CreateArrow(t, u, s)
  58254. }
  58255. this._xAxis = r,
  58256. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
  58257. this._yAxis = o,
  58258. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
  58259. this._zAxis = a,
  58260. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
  58261. null != n && (e._SetRenderingGroupId(this._xAxis, n),
  58262. e._SetRenderingGroupId(this._yAxis, n),
  58263. e._SetRenderingGroupId(this._zAxis, n)),
  58264. this.scene = t,
  58265. this.update(new x, x.Right(), x.Up(), x.Forward())
  58266. }
  58267. }
  58268. return Object.defineProperty(e.prototype, "xAxis", {
  58269. get: function() {
  58270. return this._xAxis
  58271. },
  58272. enumerable: !1,
  58273. configurable: !0
  58274. }),
  58275. Object.defineProperty(e.prototype, "yAxis", {
  58276. get: function() {
  58277. return this._yAxis
  58278. },
  58279. enumerable: !1,
  58280. configurable: !0
  58281. }),
  58282. Object.defineProperty(e.prototype, "zAxis", {
  58283. get: function() {
  58284. return this._zAxis
  58285. },
  58286. enumerable: !1,
  58287. configurable: !0
  58288. }),
  58289. e.prototype.update = function(e, t, i, n) {
  58290. this._xAxis.position.copyFrom(e),
  58291. this._xAxis.setDirection(t),
  58292. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
  58293. this._yAxis.position.copyFrom(e),
  58294. this._yAxis.setDirection(i),
  58295. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
  58296. this._zAxis.position.copyFrom(e),
  58297. this._zAxis.setDirection(n),
  58298. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor)
  58299. }
  58300. ,
  58301. e.prototype.createInstance = function() {
  58302. var t = Al._CreateArrowInstance(this.scene, this._xAxis)
  58303. , i = Al._CreateArrowInstance(this.scene, this._yAxis)
  58304. , n = Al._CreateArrowInstance(this.scene, this._zAxis)
  58305. , r = new e(this.scene,this.scaleLines,null,t,i,n);
  58306. return r._instanced = !0,
  58307. r
  58308. }
  58309. ,
  58310. e.prototype.dispose = function() {
  58311. this._xAxis && this._xAxis.dispose(!1, !this._instanced),
  58312. this._yAxis && this._yAxis.dispose(!1, !this._instanced),
  58313. this._zAxis && this._zAxis.dispose(!1, !this._instanced),
  58314. this.scene = null
  58315. }
  58316. ,
  58317. e._SetRenderingGroupId = function(e, t) {
  58318. e.getChildMeshes().forEach((function(e) {
  58319. e.renderingGroupId = t
  58320. }
  58321. ))
  58322. }
  58323. ,
  58324. e
  58325. }(), Rl = function(e) {
  58326. function t(t, i, n, r) {
  58327. void 0 === r && (r = 1);
  58328. var o = e.call(this, t, r) || this;
  58329. return o.pos = x.Zero(),
  58330. o.xaxis = x.Zero(),
  58331. o.yaxis = x.Zero(),
  58332. o.zaxis = x.Zero(),
  58333. o.mesh = n,
  58334. o.bone = i,
  58335. o
  58336. }
  58337. return U(t, e),
  58338. t.prototype.update = function() {
  58339. if (this.mesh && this.bone) {
  58340. var t = this.bone;
  58341. t._markAsDirtyAndCompose(),
  58342. t.getAbsolutePositionToRef(this.mesh, this.pos),
  58343. t.getDirectionToRef(vn.X, this.mesh, this.xaxis),
  58344. t.getDirectionToRef(vn.Y, this.mesh, this.yaxis),
  58345. t.getDirectionToRef(vn.Z, this.mesh, this.zaxis),
  58346. e.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis)
  58347. }
  58348. }
  58349. ,
  58350. t.prototype.dispose = function() {
  58351. this.mesh && (this.mesh = null,
  58352. this.bone = null,
  58353. e.prototype.dispose.call(this))
  58354. }
  58355. ,
  58356. t
  58357. }(xl);
  58358. Object.defineProperty(mn.prototype, "debugLayer", {
  58359. get: function() {
  58360. return this._debugLayer || (this._debugLayer = new Cl(this)),
  58361. this._debugLayer
  58362. },
  58363. enumerable: !0,
  58364. configurable: !0
  58365. }),
  58366. function(e) {
  58367. e[e.Properties = 0] = "Properties",
  58368. e[e.Debug = 1] = "Debug",
  58369. e[e.Statistics = 2] = "Statistics",
  58370. e[e.Tools = 3] = "Tools",
  58371. e[e.Settings = 4] = "Settings"
  58372. }(bl || (bl = {}));
  58373. var Cl = function() {
  58374. function e(e) {
  58375. var t = this;
  58376. this.BJSINSPECTOR = this._getGlobalInspector(),
  58377. this._scene = e || E.LastCreatedScene,
  58378. this._scene && this._scene.onDisposeObservable.add((function() {
  58379. t._scene._debugLayer && t._scene._debugLayer.hide()
  58380. }
  58381. ))
  58382. }
  58383. return Object.defineProperty(e.prototype, "onPropertyChangedObservable", {
  58384. get: function() {
  58385. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable : (this._onPropertyChangedObservable || (this._onPropertyChangedObservable = new h),
  58386. this._onPropertyChangedObservable)
  58387. },
  58388. enumerable: !1,
  58389. configurable: !0
  58390. }),
  58391. e.prototype._createInspector = function(e) {
  58392. if (!this.isVisible()) {
  58393. if (this._onPropertyChangedObservable) {
  58394. for (var t = 0, i = this._onPropertyChangedObservable.observers; t < i.length; t++) {
  58395. var n = i[t];
  58396. this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(n)
  58397. }
  58398. this._onPropertyChangedObservable.clear(),
  58399. this._onPropertyChangedObservable = void 0
  58400. }
  58401. var r = V({
  58402. overlay: !1,
  58403. showExplorer: !0,
  58404. showInspector: !0,
  58405. embedMode: !1,
  58406. handleResize: !0,
  58407. enablePopup: !0
  58408. }, e);
  58409. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector(),
  58410. this.BJSINSPECTOR.Inspector.Show(this._scene, r)
  58411. }
  58412. }
  58413. ,
  58414. e.prototype.select = function(e, t) {
  58415. this.BJSINSPECTOR && (t && ("[object String]" == Object.prototype.toString.call(t) ? this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(t) : this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(t)),
  58416. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(e))
  58417. }
  58418. ,
  58419. e.prototype._getGlobalInspector = function() {
  58420. return "undefined" != typeof INSPECTOR ? INSPECTOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.Inspector ? BABYLON : void 0
  58421. }
  58422. ,
  58423. e.prototype.isVisible = function() {
  58424. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible
  58425. }
  58426. ,
  58427. e.prototype.hide = function() {
  58428. this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.Hide()
  58429. }
  58430. ,
  58431. e.prototype.setAsActiveScene = function() {
  58432. this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector._SetNewScene(this._scene)
  58433. }
  58434. ,
  58435. e.prototype.show = function(t) {
  58436. var i = this;
  58437. return new Promise((function(n) {
  58438. if (void 0 === i.BJSINSPECTOR) {
  58439. var r = t && t.inspectorURL ? t.inspectorURL : e.InspectorURL;
  58440. gi.LoadScript(r, (function() {
  58441. i._createInspector(t),
  58442. n(i)
  58443. }
  58444. ))
  58445. } else
  58446. i._createInspector(t),
  58447. n(i)
  58448. }
  58449. ))
  58450. }
  58451. ,
  58452. e.InspectorURL = "https://unpkg.com/babylonjs-inspector@".concat(vr.Version, "/babylon.inspector.bundle.js"),
  58453. e
  58454. }();
  58455. function Pl(e) {
  58456. var t, i = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23], n = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0], r = [], o = e.width || e.size || 1, a = e.height || e.size || 1, s = e.depth || e.size || 1, l = e.wrap || !1, c = void 0 === e.topBaseAt ? 1 : e.topBaseAt, u = void 0 === e.bottomBaseAt ? 0 : e.bottomBaseAt, h = [2, 0, 3, 1][c = (c + 4) % 4], d = [2, 0, 1, 3][u = (u + 4) % 4], p = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1];
  58457. if (l) {
  58458. i = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14],
  58459. p = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1];
  58460. for (var f = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], _ = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], m = [17, 18, 19, 16], g = [22, 23, 20, 21]; h > 0; )
  58461. f.unshift(f.pop()),
  58462. m.unshift(m.pop()),
  58463. h--;
  58464. for (; d > 0; )
  58465. _.unshift(_.pop()),
  58466. g.unshift(g.pop()),
  58467. d--;
  58468. f = f.flat(),
  58469. _ = _.flat(),
  58470. p = p.concat(f).concat(_),
  58471. i.push(m[0], m[2], m[3], m[0], m[1], m[2]),
  58472. i.push(g[0], g[2], g[3], g[0], g[1], g[2])
  58473. }
  58474. var v = [o / 2, a / 2, s / 2];
  58475. t = p.reduce((function(e, t, i) {
  58476. return e.concat(t * v[i % 3])
  58477. }
  58478. ), []);
  58479. for (var y = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, b = e.faceUV || new Array(6), T = e.faceColors, E = [], S = 0; S < 6; S++)
  58480. void 0 === b[S] && (b[S] = new R(0,0,1,1)),
  58481. T && void 0 === T[S] && (T[S] = new N(1,1,1,1));
  58482. for (var A = 0; A < 6; A++)
  58483. if (r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
  58484. r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
  58485. r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
  58486. r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
  58487. T)
  58488. for (var x = 0; x < 4; x++)
  58489. E.push(T[A].r, T[A].g, T[A].b, T[A].a);
  58490. $n._ComputeSides(y, t, i, n, r, e.frontUVs, e.backUVs);
  58491. var C = new $n;
  58492. if (C.indices = i,
  58493. C.positions = t,
  58494. C.normals = n,
  58495. C.uvs = r,
  58496. T) {
  58497. var P = y === $n.DOUBLESIDE ? E.concat(E) : E;
  58498. C.colors = P
  58499. }
  58500. return C
  58501. }
  58502. function Ml(e, t, i) {
  58503. void 0 === t && (t = {}),
  58504. void 0 === i && (i = null);
  58505. var n = new Vr(e,i);
  58506. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  58507. n._originalBuilderSideOrientation = t.sideOrientation,
  58508. Pl(t).applyToMesh(n, t.updatable),
  58509. n
  58510. }
  58511. var Il = {
  58512. CreateBox: Ml
  58513. };
  58514. function Ol(e) {
  58515. for (var t = e.segments || 32, i = e.diameterX || e.diameter || 1, n = e.diameterY || e.diameter || 1, r = e.diameterZ || e.diameter || 1, o = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, a = e.slice && e.slice <= 0 ? 1 : e.slice || 1, s = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, l = !!e.dedupTopBottomIndices, c = new x(i / 2,n / 2,r / 2), u = 2 + t, h = 2 * u, d = [], p = [], f = [], _ = [], m = 0; m <= u; m++) {
  58516. for (var g = m / u, v = g * Math.PI * a, y = 0; y <= h; y++) {
  58517. var b = y / h
  58518. , T = b * Math.PI * 2 * o
  58519. , E = P.RotationZ(-v)
  58520. , S = P.RotationY(T)
  58521. , A = x.TransformCoordinates(x.Up(), E)
  58522. , R = x.TransformCoordinates(A, S)
  58523. , C = R.multiply(c)
  58524. , M = R.divide(c).normalize();
  58525. p.push(C.x, C.y, C.z),
  58526. f.push(M.x, M.y, M.z),
  58527. _.push(b, pr.UseOpenGLOrientationForUV ? 1 - g : g)
  58528. }
  58529. if (m > 0)
  58530. for (var I = p.length / 3, O = I - 2 * (h + 1); O + h + 2 < I; O++)
  58531. l ? (m > 1 && (d.push(O),
  58532. d.push(O + 1),
  58533. d.push(O + h + 1)),
  58534. (m < u || a < 1) && (d.push(O + h + 1),
  58535. d.push(O + 1),
  58536. d.push(O + h + 2))) : (d.push(O),
  58537. d.push(O + 1),
  58538. d.push(O + h + 1),
  58539. d.push(O + h + 1),
  58540. d.push(O + 1),
  58541. d.push(O + h + 2))
  58542. }
  58543. $n._ComputeSides(s, p, d, f, _, e.frontUVs, e.backUVs);
  58544. var D = new $n;
  58545. return D.indices = d,
  58546. D.positions = p,
  58547. D.normals = f,
  58548. D.uvs = _,
  58549. D
  58550. }
  58551. function Dl(e, t, i) {
  58552. void 0 === t && (t = {}),
  58553. void 0 === i && (i = null);
  58554. var n = new Vr(e,i);
  58555. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  58556. n._originalBuilderSideOrientation = t.sideOrientation,
  58557. Ol(t).applyToMesh(n, t.updatable),
  58558. n
  58559. }
  58560. $n.CreateBox = Pl,
  58561. Vr.CreateBox = function(e, t, i, n, r) {
  58562. return void 0 === i && (i = null),
  58563. Ml(e, {
  58564. size: t,
  58565. sideOrientation: r,
  58566. updatable: n
  58567. }, i)
  58568. }
  58569. ;
  58570. var Nl = {
  58571. CreateSphere: Dl
  58572. };
  58573. $n.CreateSphere = Ol,
  58574. Vr.CreateSphere = function(e, t, i, n, r, o) {
  58575. return Dl(e, {
  58576. segments: t,
  58577. diameterX: i,
  58578. diameterY: i,
  58579. diameterZ: i,
  58580. sideOrientation: o,
  58581. updatable: r
  58582. }, n)
  58583. }
  58584. ;
  58585. var Ll = function() {
  58586. function e(e, t) {
  58587. this.type = e,
  58588. this.jointData = t,
  58589. t.nativeParams = t.nativeParams || {}
  58590. }
  58591. return Object.defineProperty(e.prototype, "physicsJoint", {
  58592. get: function() {
  58593. return this._physicsJoint
  58594. },
  58595. set: function(e) {
  58596. this._physicsJoint,
  58597. this._physicsJoint = e
  58598. },
  58599. enumerable: !1,
  58600. configurable: !0
  58601. }),
  58602. Object.defineProperty(e.prototype, "physicsPlugin", {
  58603. set: function(e) {
  58604. this._physicsPlugin = e
  58605. },
  58606. enumerable: !1,
  58607. configurable: !0
  58608. }),
  58609. e.prototype.executeNativeFunction = function(e) {
  58610. e(this._physicsPlugin.world, this._physicsJoint)
  58611. }
  58612. ,
  58613. e.DistanceJoint = 0,
  58614. e.HingeJoint = 1,
  58615. e.BallAndSocketJoint = 2,
  58616. e.WheelJoint = 3,
  58617. e.SliderJoint = 4,
  58618. e.PrismaticJoint = 5,
  58619. e.UniversalJoint = 6,
  58620. e.Hinge2Joint = e.WheelJoint,
  58621. e.PointToPointJoint = 8,
  58622. e.SpringJoint = 9,
  58623. e.LockJoint = 10,
  58624. e
  58625. }()
  58626. , Fl = function(e) {
  58627. function t(t) {
  58628. return e.call(this, Ll.DistanceJoint, t) || this
  58629. }
  58630. return U(t, e),
  58631. t.prototype.updateDistance = function(e, t) {
  58632. this._physicsPlugin.updateDistanceJoint(this, e, t)
  58633. }
  58634. ,
  58635. t
  58636. }(Ll)
  58637. , wl = function(e) {
  58638. function t(t, i) {
  58639. return e.call(this, t, i) || this
  58640. }
  58641. return U(t, e),
  58642. t.prototype.setMotor = function(e, t) {
  58643. this._physicsPlugin.setMotor(this, e || 0, t)
  58644. }
  58645. ,
  58646. t.prototype.setLimit = function(e, t) {
  58647. this._physicsPlugin.setLimit(this, e, t)
  58648. }
  58649. ,
  58650. t
  58651. }(Ll)
  58652. , Bl = function(e) {
  58653. function t(t) {
  58654. return e.call(this, Ll.HingeJoint, t) || this
  58655. }
  58656. return U(t, e),
  58657. t.prototype.setMotor = function(e, t) {
  58658. this._physicsPlugin.setMotor(this, e || 0, t)
  58659. }
  58660. ,
  58661. t.prototype.setLimit = function(e, t) {
  58662. this._physicsPlugin.setLimit(this, e, t)
  58663. }
  58664. ,
  58665. t
  58666. }(wl)
  58667. , Ul = function(e) {
  58668. function t(t) {
  58669. return e.call(this, Ll.Hinge2Joint, t) || this
  58670. }
  58671. return U(t, e),
  58672. t.prototype.setMotor = function(e, t, i) {
  58673. void 0 === i && (i = 0),
  58674. this._physicsPlugin.setMotor(this, e || 0, t, i)
  58675. }
  58676. ,
  58677. t.prototype.setLimit = function(e, t, i) {
  58678. void 0 === i && (i = 0),
  58679. this._physicsPlugin.setLimit(this, e, t, i)
  58680. }
  58681. ,
  58682. t
  58683. }(wl);
  58684. Vr._PhysicsImpostorParser = function(e, t, i) {
  58685. return new Vl(t,i.physicsImpostor,{
  58686. mass: i.physicsMass,
  58687. friction: i.physicsFriction,
  58688. restitution: i.physicsRestitution
  58689. },e)
  58690. }
  58691. ;
  58692. var Vl = function() {
  58693. function e(e, t, i, n) {
  58694. void 0 === i && (i = {
  58695. mass: 0
  58696. });
  58697. var r = this;
  58698. this.object = e,
  58699. this.type = t,
  58700. this._options = i,
  58701. this._scene = n,
  58702. this._pluginData = {},
  58703. this._bodyUpdateRequired = !1,
  58704. this._onBeforePhysicsStepCallbacks = new Array,
  58705. this._onAfterPhysicsStepCallbacks = new Array,
  58706. this._onPhysicsCollideCallbacks = [],
  58707. this._deltaPosition = x.Zero(),
  58708. this._isDisposed = !1,
  58709. this.soft = !1,
  58710. this.segments = 0,
  58711. this._tmpQuat = new C,
  58712. this._tmpQuat2 = new C,
  58713. this.beforeStep = function() {
  58714. r._physicsEngine && (r.object.translate(r._deltaPosition, -1),
  58715. r._deltaRotationConjugated && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotationConjugated, r.object.rotationQuaternion),
  58716. r.object.computeWorldMatrix(!1),
  58717. r.object.parent && r.object.rotationQuaternion ? (r.getParentsRotation(),
  58718. r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r._tmpQuat)) : r._tmpQuat.copyFrom(r.object.rotationQuaternion || new C),
  58719. r._options.disableBidirectionalTransformation || r.object.rotationQuaternion && r._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(r, r.object.getAbsolutePosition(), r._tmpQuat),
  58720. r._onBeforePhysicsStepCallbacks.forEach((function(e) {
  58721. e(r)
  58722. }
  58723. )))
  58724. }
  58725. ,
  58726. this.afterStep = function() {
  58727. r._physicsEngine && (r._onAfterPhysicsStepCallbacks.forEach((function(e) {
  58728. e(r)
  58729. }
  58730. )),
  58731. r._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(r),
  58732. r.object.parent && r.object.rotationQuaternion && (r.getParentsRotation(),
  58733. r._tmpQuat.conjugateInPlace(),
  58734. r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r.object.rotationQuaternion)),
  58735. r.object.setAbsolutePosition(r.object.position),
  58736. r._deltaRotation && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotation, r.object.rotationQuaternion),
  58737. r.object.translate(r._deltaPosition, 1))
  58738. }
  58739. ,
  58740. this.onCollideEvent = null,
  58741. this.onCollide = function(e) {
  58742. if ((r._onPhysicsCollideCallbacks.length || r.onCollideEvent) && r._physicsEngine) {
  58743. var t = r._physicsEngine.getImpostorWithPhysicsBody(e.body);
  58744. t && (r.onCollideEvent && r.onCollideEvent(r, t),
  58745. r._onPhysicsCollideCallbacks.filter((function(e) {
  58746. return -1 !== e.otherImpostors.indexOf(t)
  58747. }
  58748. )).forEach((function(i) {
  58749. i.callback(r, t, e.point)
  58750. }
  58751. )))
  58752. }
  58753. }
  58754. ,
  58755. this.object ? (this.object.parent && 0 !== i.mass && K.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),
  58756. !this._scene && e.getScene && (this._scene = e.getScene()),
  58757. this._scene && (this.type > 100 && (this.soft = !0),
  58758. this._physicsEngine = this._scene.getPhysicsEngine(),
  58759. this._physicsEngine ? (this.object.rotationQuaternion || (this.object.rotation ? this.object.rotationQuaternion = C.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new C),
  58760. this._options.mass = void 0 === i.mass ? 0 : i.mass,
  58761. this._options.friction = void 0 === i.friction ? .2 : i.friction,
  58762. this._options.restitution = void 0 === i.restitution ? .2 : i.restitution,
  58763. this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1,
  58764. this._options.pressure = void 0 === i.pressure ? 200 : i.pressure,
  58765. this._options.stiffness = void 0 === i.stiffness ? 1 : i.stiffness,
  58766. this._options.velocityIterations = void 0 === i.velocityIterations ? 20 : i.velocityIterations,
  58767. this._options.positionIterations = void 0 === i.positionIterations ? 20 : i.positionIterations,
  58768. this._options.fixedPoints = void 0 === i.fixedPoints ? 0 : i.fixedPoints,
  58769. this._options.margin = void 0 === i.margin ? 0 : i.margin,
  58770. this._options.damping = void 0 === i.damping ? 0 : i.damping,
  58771. this._options.path = void 0 === i.path ? null : i.path,
  58772. this._options.shape = void 0 === i.shape ? null : i.shape),
  58773. this._joints = [],
  58774. !this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && K.Warn("You must affect impostors to children before affecting impostor to parent.")) : K.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))) : K.Error("No object was provided. A physics object is obligatory")
  58775. }
  58776. return Object.defineProperty(e.prototype, "isDisposed", {
  58777. get: function() {
  58778. return this._isDisposed
  58779. },
  58780. enumerable: !1,
  58781. configurable: !0
  58782. }),
  58783. Object.defineProperty(e.prototype, "mass", {
  58784. get: function() {
  58785. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0
  58786. },
  58787. set: function(e) {
  58788. this.setMass(e)
  58789. },
  58790. enumerable: !1,
  58791. configurable: !0
  58792. }),
  58793. Object.defineProperty(e.prototype, "friction", {
  58794. get: function() {
  58795. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0
  58796. },
  58797. set: function(e) {
  58798. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, e)
  58799. },
  58800. enumerable: !1,
  58801. configurable: !0
  58802. }),
  58803. Object.defineProperty(e.prototype, "restitution", {
  58804. get: function() {
  58805. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0
  58806. },
  58807. set: function(e) {
  58808. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, e)
  58809. },
  58810. enumerable: !1,
  58811. configurable: !0
  58812. }),
  58813. Object.defineProperty(e.prototype, "pressure", {
  58814. get: function() {
  58815. if (!this._physicsEngine)
  58816. return 0;
  58817. var e = this._physicsEngine.getPhysicsPlugin();
  58818. return e.setBodyPressure ? e.getBodyPressure(this) : 0
  58819. },
  58820. set: function(e) {
  58821. if (this._physicsEngine) {
  58822. var t = this._physicsEngine.getPhysicsPlugin();
  58823. t.setBodyPressure && t.setBodyPressure(this, e)
  58824. }
  58825. },
  58826. enumerable: !1,
  58827. configurable: !0
  58828. }),
  58829. Object.defineProperty(e.prototype, "stiffness", {
  58830. get: function() {
  58831. if (!this._physicsEngine)
  58832. return 0;
  58833. var e = this._physicsEngine.getPhysicsPlugin();
  58834. return e.getBodyStiffness ? e.getBodyStiffness(this) : 0
  58835. },
  58836. set: function(e) {
  58837. if (this._physicsEngine) {
  58838. var t = this._physicsEngine.getPhysicsPlugin();
  58839. t.setBodyStiffness && t.setBodyStiffness(this, e)
  58840. }
  58841. },
  58842. enumerable: !1,
  58843. configurable: !0
  58844. }),
  58845. Object.defineProperty(e.prototype, "velocityIterations", {
  58846. get: function() {
  58847. if (!this._physicsEngine)
  58848. return 0;
  58849. var e = this._physicsEngine.getPhysicsPlugin();
  58850. return e.getBodyVelocityIterations ? e.getBodyVelocityIterations(this) : 0
  58851. },
  58852. set: function(e) {
  58853. if (this._physicsEngine) {
  58854. var t = this._physicsEngine.getPhysicsPlugin();
  58855. t.setBodyVelocityIterations && t.setBodyVelocityIterations(this, e)
  58856. }
  58857. },
  58858. enumerable: !1,
  58859. configurable: !0
  58860. }),
  58861. Object.defineProperty(e.prototype, "positionIterations", {
  58862. get: function() {
  58863. if (!this._physicsEngine)
  58864. return 0;
  58865. var e = this._physicsEngine.getPhysicsPlugin();
  58866. return e.getBodyPositionIterations ? e.getBodyPositionIterations(this) : 0
  58867. },
  58868. set: function(e) {
  58869. if (this._physicsEngine) {
  58870. var t = this._physicsEngine.getPhysicsPlugin();
  58871. t.setBodyPositionIterations && t.setBodyPositionIterations(this, e)
  58872. }
  58873. },
  58874. enumerable: !1,
  58875. configurable: !0
  58876. }),
  58877. e.prototype._init = function() {
  58878. this._physicsEngine && (this._physicsEngine.removeImpostor(this),
  58879. this.physicsBody = null,
  58880. this._parent = this._parent || this._getPhysicsParent(),
  58881. this._isDisposed || this.parent && !this._options.ignoreParent || this._physicsEngine.addImpostor(this))
  58882. }
  58883. ,
  58884. e.prototype._getPhysicsParent = function() {
  58885. return this.object.parent instanceof Sr ? this.object.parent.physicsImpostor : null
  58886. }
  58887. ,
  58888. e.prototype.isBodyInitRequired = function() {
  58889. return this._bodyUpdateRequired || !this._physicsBody && !this._parent
  58890. }
  58891. ,
  58892. e.prototype.setScalingUpdated = function() {
  58893. this.forceUpdate()
  58894. }
  58895. ,
  58896. e.prototype.forceUpdate = function() {
  58897. this._init(),
  58898. this.parent && !this._options.ignoreParent && this.parent.forceUpdate()
  58899. }
  58900. ,
  58901. Object.defineProperty(e.prototype, "physicsBody", {
  58902. get: function() {
  58903. return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody
  58904. },
  58905. set: function(e) {
  58906. this._physicsBody && this._physicsEngine && this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),
  58907. this._physicsBody = e,
  58908. this.resetUpdateFlags()
  58909. },
  58910. enumerable: !1,
  58911. configurable: !0
  58912. }),
  58913. Object.defineProperty(e.prototype, "parent", {
  58914. get: function() {
  58915. return !this._options.ignoreParent && this._parent ? this._parent : null
  58916. },
  58917. set: function(e) {
  58918. this._parent = e
  58919. },
  58920. enumerable: !1,
  58921. configurable: !0
  58922. }),
  58923. e.prototype.resetUpdateFlags = function() {
  58924. this._bodyUpdateRequired = !1
  58925. }
  58926. ,
  58927. e.prototype.getObjectExtendSize = function() {
  58928. if (this.object.getBoundingInfo) {
  58929. var t = this.object.rotationQuaternion
  58930. , i = this.object.scaling.clone();
  58931. this.object.rotationQuaternion = e.IDENTITY_QUATERNION;
  58932. var n = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
  58933. n && n.decompose(i, void 0, void 0);
  58934. var r = this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);
  58935. return r.x = Math.abs(r.x),
  58936. r.y = Math.abs(r.y),
  58937. r.z = Math.abs(r.z),
  58938. this.object.rotationQuaternion = t,
  58939. this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0),
  58940. r
  58941. }
  58942. return e.DEFAULT_OBJECT_SIZE
  58943. }
  58944. ,
  58945. e.prototype.getObjectCenter = function() {
  58946. return this.object.getBoundingInfo ? this.object.getBoundingInfo().boundingBox.centerWorld : this.object.position
  58947. }
  58948. ,
  58949. e.prototype.getParam = function(e) {
  58950. return this._options[e]
  58951. }
  58952. ,
  58953. e.prototype.setParam = function(e, t) {
  58954. this._options[e] = t,
  58955. this._bodyUpdateRequired = !0
  58956. }
  58957. ,
  58958. e.prototype.setMass = function(e) {
  58959. this.getParam("mass") !== e && this.setParam("mass", e),
  58960. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, e)
  58961. }
  58962. ,
  58963. e.prototype.getLinearVelocity = function() {
  58964. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : x.Zero()
  58965. }
  58966. ,
  58967. e.prototype.setLinearVelocity = function(e) {
  58968. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, e)
  58969. }
  58970. ,
  58971. e.prototype.getAngularVelocity = function() {
  58972. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : x.Zero()
  58973. }
  58974. ,
  58975. e.prototype.setAngularVelocity = function(e) {
  58976. this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, e)
  58977. }
  58978. ,
  58979. e.prototype.executeNativeFunction = function(e) {
  58980. this._physicsEngine && e(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody)
  58981. }
  58982. ,
  58983. e.prototype.registerBeforePhysicsStep = function(e) {
  58984. this._onBeforePhysicsStepCallbacks.push(e)
  58985. }
  58986. ,
  58987. e.prototype.unregisterBeforePhysicsStep = function(e) {
  58988. var t = this._onBeforePhysicsStepCallbacks.indexOf(e);
  58989. t > -1 ? this._onBeforePhysicsStepCallbacks.splice(t, 1) : K.Warn("Function to remove was not found")
  58990. }
  58991. ,
  58992. e.prototype.registerAfterPhysicsStep = function(e) {
  58993. this._onAfterPhysicsStepCallbacks.push(e)
  58994. }
  58995. ,
  58996. e.prototype.unregisterAfterPhysicsStep = function(e) {
  58997. var t = this._onAfterPhysicsStepCallbacks.indexOf(e);
  58998. t > -1 ? this._onAfterPhysicsStepCallbacks.splice(t, 1) : K.Warn("Function to remove was not found")
  58999. }
  59000. ,
  59001. e.prototype.registerOnPhysicsCollide = function(e, t) {
  59002. var i = e instanceof Array ? e : [e];
  59003. this._onPhysicsCollideCallbacks.push({
  59004. callback: t,
  59005. otherImpostors: i
  59006. })
  59007. }
  59008. ,
  59009. e.prototype.unregisterOnPhysicsCollide = function(e, t) {
  59010. var i = e instanceof Array ? e : [e]
  59011. , n = -1;
  59012. this._onPhysicsCollideCallbacks.some((function(e, r) {
  59013. if (e.callback === t && e.otherImpostors.length === i.length) {
  59014. var o = e.otherImpostors.every((function(e) {
  59015. return i.indexOf(e) > -1
  59016. }
  59017. ));
  59018. return o && (n = r),
  59019. o
  59020. }
  59021. return !1
  59022. }
  59023. )) ? this._onPhysicsCollideCallbacks.splice(n, 1) : K.Warn("Function to remove was not found")
  59024. }
  59025. ,
  59026. e.prototype.getParentsRotation = function() {
  59027. var e = this.object.parent;
  59028. for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); e; )
  59029. e.rotationQuaternion ? this._tmpQuat2.copyFrom(e.rotationQuaternion) : C.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, e.rotation.z, this._tmpQuat2),
  59030. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat),
  59031. e = e.parent;
  59032. return this._tmpQuat
  59033. }
  59034. ,
  59035. e.prototype.applyForce = function(e, t) {
  59036. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, e, t),
  59037. this
  59038. }
  59039. ,
  59040. e.prototype.applyImpulse = function(e, t) {
  59041. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, e, t),
  59042. this
  59043. }
  59044. ,
  59045. e.prototype.createJoint = function(e, t, i) {
  59046. var n = new Ll(t,i);
  59047. return this.addJoint(e, n),
  59048. this
  59049. }
  59050. ,
  59051. e.prototype.addJoint = function(e, t) {
  59052. return this._joints.push({
  59053. otherImpostor: e,
  59054. joint: t
  59055. }),
  59056. this._physicsEngine && this._physicsEngine.addJoint(this, e, t),
  59057. this
  59058. }
  59059. ,
  59060. e.prototype.addAnchor = function(e, t, i, n, r) {
  59061. if (!this._physicsEngine)
  59062. return this;
  59063. var o = this._physicsEngine.getPhysicsPlugin();
  59064. return o.appendAnchor ? (this._physicsEngine && o.appendAnchor(this, e, t, i, n, r),
  59065. this) : this
  59066. }
  59067. ,
  59068. e.prototype.addHook = function(e, t, i, n) {
  59069. if (!this._physicsEngine)
  59070. return this;
  59071. var r = this._physicsEngine.getPhysicsPlugin();
  59072. return r.appendAnchor ? (this._physicsEngine && r.appendHook(this, e, t, i, n),
  59073. this) : this
  59074. }
  59075. ,
  59076. e.prototype.sleep = function() {
  59077. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this),
  59078. this
  59079. }
  59080. ,
  59081. e.prototype.wakeUp = function() {
  59082. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),
  59083. this
  59084. }
  59085. ,
  59086. e.prototype.clone = function(t) {
  59087. return t ? new e(t,this.type,this._options,this._scene) : null
  59088. }
  59089. ,
  59090. e.prototype.dispose = function() {
  59091. var e = this;
  59092. this._physicsEngine && (this._joints.forEach((function(t) {
  59093. e._physicsEngine && e._physicsEngine.removeJoint(e, t.otherImpostor, t.joint)
  59094. }
  59095. )),
  59096. this._physicsEngine.removeImpostor(this),
  59097. this.parent && this.parent.forceUpdate(),
  59098. this._isDisposed = !0)
  59099. }
  59100. ,
  59101. e.prototype.setDeltaPosition = function(e) {
  59102. this._deltaPosition.copyFrom(e)
  59103. }
  59104. ,
  59105. e.prototype.setDeltaRotation = function(e) {
  59106. this._deltaRotation || (this._deltaRotation = new C),
  59107. this._deltaRotation.copyFrom(e),
  59108. this._deltaRotationConjugated = this._deltaRotation.conjugate()
  59109. }
  59110. ,
  59111. e.prototype.getBoxSizeToRef = function(e) {
  59112. return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, e),
  59113. this
  59114. }
  59115. ,
  59116. e.prototype.getRadius = function() {
  59117. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0
  59118. }
  59119. ,
  59120. e.prototype.syncBoneWithImpostor = function(t, i, n, r, o) {
  59121. var a = e._TmpVecs[0]
  59122. , s = this.object;
  59123. if (s.rotationQuaternion)
  59124. if (o) {
  59125. var l = e._TmpQuat;
  59126. s.rotationQuaternion.multiplyToRef(o, l),
  59127. t.setRotationQuaternion(l, Ji.WORLD, i)
  59128. } else
  59129. t.setRotationQuaternion(s.rotationQuaternion, Ji.WORLD, i);
  59130. a.x = 0,
  59131. a.y = 0,
  59132. a.z = 0,
  59133. n && (a.x = n.x,
  59134. a.y = n.y,
  59135. a.z = n.z,
  59136. t.getDirectionToRef(a, i, a),
  59137. null == r && (r = n.length()),
  59138. a.x *= r,
  59139. a.y *= r,
  59140. a.z *= r),
  59141. t.getParent() ? (a.addInPlace(s.getAbsolutePosition()),
  59142. t.setAbsolutePosition(a, i)) : (i.setAbsolutePosition(s.getAbsolutePosition()),
  59143. i.position.x -= a.x,
  59144. i.position.y -= a.y,
  59145. i.position.z -= a.z)
  59146. }
  59147. ,
  59148. e.prototype.syncImpostorWithBone = function(t, i, n, r, o, a) {
  59149. var s = this.object;
  59150. if (s.rotationQuaternion)
  59151. if (o) {
  59152. var l = e._TmpQuat;
  59153. t.getRotationQuaternionToRef(Ji.WORLD, i, l),
  59154. l.multiplyToRef(o, s.rotationQuaternion)
  59155. } else
  59156. t.getRotationQuaternionToRef(Ji.WORLD, i, s.rotationQuaternion);
  59157. var c = e._TmpVecs[0]
  59158. , u = e._TmpVecs[1];
  59159. a || ((a = e._TmpVecs[2]).x = 0,
  59160. a.y = 1,
  59161. a.z = 0),
  59162. t.getDirectionToRef(a, i, u),
  59163. t.getAbsolutePositionToRef(i, c),
  59164. null == r && n && (r = n.length()),
  59165. null != r && (c.x += u.x * r,
  59166. c.y += u.y * r,
  59167. c.z += u.z * r),
  59168. s.setAbsolutePosition(c)
  59169. }
  59170. ,
  59171. e.DEFAULT_OBJECT_SIZE = new x(1,1,1),
  59172. e.IDENTITY_QUATERNION = C.Identity(),
  59173. e._TmpVecs = g.BuildArray(3, x.Zero),
  59174. e._TmpQuat = C.Identity(),
  59175. e.NoImpostor = 0,
  59176. e.SphereImpostor = 1,
  59177. e.BoxImpostor = 2,
  59178. e.PlaneImpostor = 3,
  59179. e.MeshImpostor = 4,
  59180. e.CapsuleImpostor = 6,
  59181. e.CylinderImpostor = 7,
  59182. e.ParticleImpostor = 8,
  59183. e.HeightmapImpostor = 9,
  59184. e.ConvexHullImpostor = 10,
  59185. e.CustomImpostor = 100,
  59186. e.RopeImpostor = 101,
  59187. e.ClothImpostor = 102,
  59188. e.SoftbodyImpostor = 103,
  59189. e
  59190. }();
  59191. function kl(e) {
  59192. void 0 === e && (e = {
  59193. subdivisions: 2,
  59194. tessellation: 16,
  59195. height: 1,
  59196. radius: .25,
  59197. capSubdivisions: 6
  59198. });
  59199. var t, i, n = Math.max(e.subdivisions ? e.subdivisions : 2, 1), r = Math.max(e.tessellation ? e.tessellation : 16, 3), o = Math.max(e.height ? e.height : 1, 0), a = Math.max(e.radius ? e.radius : .25, 0), s = Math.max(e.capSubdivisions ? e.capSubdivisions : 6, 1), l = r, c = n, u = Math.max(e.radiusTop ? e.radiusTop : a, 0), h = Math.max(e.radiusBottom ? e.radiusBottom : a, 0), d = o - (u + h), p = 2 * Math.PI, f = Math.max(e.topCapSubdivisions ? e.topCapSubdivisions : s, 1), _ = Math.max(e.bottomCapSubdivisions ? e.bottomCapSubdivisions : s, 1), m = Math.acos((h - u) / o), g = [], v = [], y = [], b = [], T = 0, E = [], S = .5 * d, R = .5 * Math.PI, C = x.Zero(), M = x.Zero(), I = Math.cos(m), O = Math.sin(m), D = new A(u * O,S + u * I).subtract(new A(h * O,h * I - S)).length(), N = u * m + D + h * (R - m), L = 0;
  59200. for (i = 0; i <= f; i++) {
  59201. var F = []
  59202. , w = R - m * (i / f);
  59203. L += u * m / f;
  59204. var B = Math.cos(w)
  59205. , U = Math.sin(w)
  59206. , V = B * u;
  59207. for (t = 0; t <= l; t++) {
  59208. var k = (X = t / l) * p + 0
  59209. , G = Math.sin(k)
  59210. , z = Math.cos(k);
  59211. M.x = V * G,
  59212. M.y = S + U * u,
  59213. M.z = V * z,
  59214. v.push(M.x, M.y, M.z),
  59215. C.set(B * G, U, B * z),
  59216. y.push(C.x, C.y, C.z),
  59217. b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
  59218. F.push(T),
  59219. T++
  59220. }
  59221. E.push(F)
  59222. }
  59223. var W = o - u - h + I * u - I * h
  59224. , H = O * (h - u) / W;
  59225. for (i = 1; i <= c; i++) {
  59226. for (F = [],
  59227. L += D / c,
  59228. V = O * (i * (h - u) / c + u),
  59229. t = 0; t <= l; t++)
  59230. k = (X = t / l) * p + 0,
  59231. G = Math.sin(k),
  59232. z = Math.cos(k),
  59233. M.x = V * G,
  59234. M.y = S + I * u - i * W / c,
  59235. M.z = V * z,
  59236. v.push(M.x, M.y, M.z),
  59237. C.set(G, H, z).normalize(),
  59238. y.push(C.x, C.y, C.z),
  59239. b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
  59240. F.push(T),
  59241. T++;
  59242. E.push(F)
  59243. }
  59244. for (i = 1; i <= _; i++) {
  59245. for (F = [],
  59246. w = R - m - (Math.PI - m) * (i / _),
  59247. L += h * m / _,
  59248. B = Math.cos(w),
  59249. U = Math.sin(w),
  59250. V = B * h,
  59251. t = 0; t <= l; t++) {
  59252. var X;
  59253. k = (X = t / l) * p + 0,
  59254. G = Math.sin(k),
  59255. z = Math.cos(k),
  59256. M.x = V * G,
  59257. M.y = U * h - S,
  59258. M.z = V * z,
  59259. v.push(M.x, M.y, M.z),
  59260. C.set(B * G, U, B * z),
  59261. y.push(C.x, C.y, C.z),
  59262. b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
  59263. F.push(T),
  59264. T++
  59265. }
  59266. E.push(F)
  59267. }
  59268. for (t = 0; t < l; t++)
  59269. for (i = 0; i < f + c + _; i++) {
  59270. var j = E[i][t]
  59271. , Y = E[i + 1][t]
  59272. , K = E[i + 1][t + 1]
  59273. , Q = E[i][t + 1];
  59274. g.push(j),
  59275. g.push(Y),
  59276. g.push(Q),
  59277. g.push(Y),
  59278. g.push(K),
  59279. g.push(Q)
  59280. }
  59281. if (g = g.reverse(),
  59282. e.orientation && !e.orientation.equals(x.Up())) {
  59283. var q = new P;
  59284. e.orientation.clone().scale(.5 * Math.PI).cross(x.Up()).toQuaternion().toRotationMatrix(q);
  59285. for (var Z = x.Zero(), J = 0; J < v.length; J += 3)
  59286. Z.set(v[J], v[J + 1], v[J + 2]),
  59287. x.TransformCoordinatesToRef(Z.clone(), q, Z),
  59288. v[J] = Z.x,
  59289. v[J + 1] = Z.y,
  59290. v[J + 2] = Z.z
  59291. }
  59292. var $ = new $n;
  59293. return $.positions = v,
  59294. $.normals = y,
  59295. $.uvs = b,
  59296. $.indices = g,
  59297. $
  59298. }
  59299. function Gl(e, t, i) {
  59300. void 0 === t && (t = {
  59301. orientation: x.Up(),
  59302. subdivisions: 2,
  59303. tessellation: 16,
  59304. height: 1,
  59305. radius: .25,
  59306. capSubdivisions: 6,
  59307. updatable: !1
  59308. }),
  59309. void 0 === i && (i = null);
  59310. var n = new Vr(e,i);
  59311. return kl(t).applyToMesh(n, t.updatable),
  59312. n
  59313. }
  59314. var zl = {
  59315. CreateCapsule: Gl
  59316. };
  59317. Vr.CreateCapsule = function(e, t, i) {
  59318. return Gl(e, t, i)
  59319. }
  59320. ,
  59321. $n.CreateCapsule = kl;
  59322. var Wl = function() {
  59323. function e(e) {
  59324. if (this._impostors = [],
  59325. this._meshes = [],
  59326. this._numMeshes = 0,
  59327. this._debugMeshMeshes = new Array,
  59328. this._scene = e || E.LastCreatedScene,
  59329. this._scene) {
  59330. var t = this._scene.getPhysicsEngine();
  59331. t && (this._physicsEnginePlugin = t.getPhysicsPlugin()),
  59332. this._utilityLayer = new El(this._scene,!1),
  59333. this._utilityLayer.pickUtilitySceneFirst = !1,
  59334. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0
  59335. }
  59336. }
  59337. return e.prototype._updateDebugMeshes = function() {
  59338. for (var e = this._physicsEnginePlugin, t = 0; t < this._numMeshes; t++) {
  59339. var i = this._impostors[t];
  59340. if (i)
  59341. if (i.isDisposed)
  59342. this.hideImpostor(this._impostors[t--]);
  59343. else {
  59344. if (i.type === Vl.MeshImpostor)
  59345. continue;
  59346. var n = this._meshes[t];
  59347. n && e && e.syncMeshWithImpostor(n, i)
  59348. }
  59349. }
  59350. }
  59351. ,
  59352. e.prototype.showImpostor = function(e, t) {
  59353. if (!this._scene)
  59354. return null;
  59355. for (var i = 0; i < this._numMeshes; i++)
  59356. if (this._impostors[i] == e)
  59357. return null;
  59358. var n = this._getDebugMesh(e, t);
  59359. return n && (this._impostors[this._numMeshes] = e,
  59360. this._meshes[this._numMeshes] = n,
  59361. 0 === this._numMeshes && (this._renderFunction = this._updateDebugMeshes.bind(this),
  59362. this._scene.registerBeforeRender(this._renderFunction)),
  59363. this._numMeshes++),
  59364. n
  59365. }
  59366. ,
  59367. e.prototype.hideImpostor = function(e) {
  59368. if (e && this._scene && this._utilityLayer) {
  59369. for (var t = !1, i = this._utilityLayer.utilityLayerScene, n = 0; n < this._numMeshes; n++)
  59370. if (this._impostors[n] == e) {
  59371. var r = this._meshes[n];
  59372. if (!r)
  59373. continue;
  59374. i.removeMesh(r),
  59375. r.dispose();
  59376. var o = this._debugMeshMeshes.indexOf(r);
  59377. o > -1 && this._debugMeshMeshes.splice(o, 1),
  59378. this._numMeshes--,
  59379. this._numMeshes > 0 ? (this._meshes[n] = this._meshes[this._numMeshes],
  59380. this._impostors[n] = this._impostors[this._numMeshes],
  59381. this._meshes[this._numMeshes] = null,
  59382. this._impostors[this._numMeshes] = null) : (this._meshes[0] = null,
  59383. this._impostors[0] = null),
  59384. t = !0;
  59385. break
  59386. }
  59387. t && 0 === this._numMeshes && this._scene.unregisterBeforeRender(this._renderFunction)
  59388. }
  59389. }
  59390. ,
  59391. e.prototype._getDebugMaterial = function(e) {
  59392. return this._debugMaterial || (this._debugMaterial = new Os("",e),
  59393. this._debugMaterial.wireframe = !0,
  59394. this._debugMaterial.emissiveColor = D.White(),
  59395. this._debugMaterial.disableLighting = !0),
  59396. this._debugMaterial
  59397. }
  59398. ,
  59399. e.prototype._getDebugBoxMesh = function(e) {
  59400. return this._debugBoxMesh || (this._debugBoxMesh = Ml("physicsBodyBoxViewMesh", {
  59401. size: 1
  59402. }, e),
  59403. this._debugBoxMesh.rotationQuaternion = C.Identity(),
  59404. this._debugBoxMesh.material = this._getDebugMaterial(e),
  59405. this._debugBoxMesh.setEnabled(!1)),
  59406. this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")
  59407. }
  59408. ,
  59409. e.prototype._getDebugSphereMesh = function(e) {
  59410. return this._debugSphereMesh || (this._debugSphereMesh = Dl("physicsBodySphereViewMesh", {
  59411. diameter: 1
  59412. }, e),
  59413. this._debugSphereMesh.rotationQuaternion = C.Identity(),
  59414. this._debugSphereMesh.material = this._getDebugMaterial(e),
  59415. this._debugSphereMesh.setEnabled(!1)),
  59416. this._debugSphereMesh.createInstance("physicsBodySphereViewInstance")
  59417. }
  59418. ,
  59419. e.prototype._getDebugCapsuleMesh = function(e) {
  59420. return this._debugCapsuleMesh || (this._debugCapsuleMesh = Gl("physicsBodyCapsuleViewMesh", {
  59421. height: 1
  59422. }, e),
  59423. this._debugCapsuleMesh.rotationQuaternion = C.Identity(),
  59424. this._debugCapsuleMesh.material = this._getDebugMaterial(e),
  59425. this._debugCapsuleMesh.setEnabled(!1)),
  59426. this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance")
  59427. }
  59428. ,
  59429. e.prototype._getDebugCylinderMesh = function(e) {
  59430. return this._debugCylinderMesh || (this._debugCylinderMesh = Ys("physicsBodyCylinderViewMesh", {
  59431. diameterTop: 1,
  59432. diameterBottom: 1,
  59433. height: 1
  59434. }, e),
  59435. this._debugCylinderMesh.rotationQuaternion = C.Identity(),
  59436. this._debugCylinderMesh.material = this._getDebugMaterial(e),
  59437. this._debugCylinderMesh.setEnabled(!1)),
  59438. this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")
  59439. }
  59440. ,
  59441. e.prototype._getDebugMeshMesh = function(e, t) {
  59442. var i = new Vr(e.name,t,null,e);
  59443. return i.setParent(e),
  59444. i.position = x.Zero(),
  59445. i.material = this._getDebugMaterial(t),
  59446. this._debugMeshMeshes.push(i),
  59447. i
  59448. }
  59449. ,
  59450. e.prototype._getDebugMesh = function(e, t) {
  59451. var i = this;
  59452. if (!this._utilityLayer)
  59453. return null;
  59454. if (t && t.parent && t.parent.physicsImpostor)
  59455. return null;
  59456. var n = null
  59457. , r = this._utilityLayer.utilityLayerScene;
  59458. switch (e.type) {
  59459. case Vl.BoxImpostor:
  59460. n = this._getDebugBoxMesh(r),
  59461. e.getBoxSizeToRef(n.scaling);
  59462. break;
  59463. case Vl.SphereImpostor:
  59464. n = this._getDebugSphereMesh(r);
  59465. var o = e.getRadius();
  59466. n.scaling.x = 2 * o,
  59467. n.scaling.y = 2 * o,
  59468. n.scaling.z = 2 * o;
  59469. break;
  59470. case Vl.CapsuleImpostor:
  59471. n = this._getDebugCapsuleMesh(r);
  59472. var a = e.object.getBoundingInfo();
  59473. n.scaling.x = 2 * (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
  59474. n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
  59475. n.scaling.z = 2 * (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z;
  59476. break;
  59477. case Vl.MeshImpostor:
  59478. t && (n = this._getDebugMeshMesh(t, r));
  59479. break;
  59480. case Vl.NoImpostor:
  59481. t && t.getChildMeshes().filter((function(e) {
  59482. return e.physicsImpostor ? 1 : 0
  59483. }
  59484. )).forEach((function(e) {
  59485. if (e.physicsImpostor && "Mesh" === e.getClassName()) {
  59486. var t = e.getBoundingInfo()
  59487. , o = t.boundingBox.minimum
  59488. , a = t.boundingBox.maximum;
  59489. switch (e.physicsImpostor.type) {
  59490. case Vl.BoxImpostor:
  59491. (n = i._getDebugBoxMesh(r)).position.copyFrom(o),
  59492. n.position.addInPlace(a),
  59493. n.position.scaleInPlace(.5);
  59494. break;
  59495. case Vl.SphereImpostor:
  59496. n = i._getDebugSphereMesh(r);
  59497. break;
  59498. case Vl.CylinderImpostor:
  59499. n = i._getDebugCylinderMesh(r);
  59500. break;
  59501. default:
  59502. n = null
  59503. }
  59504. n && (n.scaling.x = a.x - o.x,
  59505. n.scaling.y = a.y - o.y,
  59506. n.scaling.z = a.z - o.z,
  59507. n.parent = e)
  59508. }
  59509. }
  59510. )),
  59511. n = null;
  59512. break;
  59513. case Vl.CylinderImpostor:
  59514. n = this._getDebugCylinderMesh(r),
  59515. a = e.object.getBoundingInfo(),
  59516. n.scaling.x = (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
  59517. n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
  59518. n.scaling.z = (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z
  59519. }
  59520. return n
  59521. }
  59522. ,
  59523. e.prototype.dispose = function() {
  59524. for (var e = this._numMeshes, t = 0; t < e; t++)
  59525. this.hideImpostor(this._impostors[0]);
  59526. this._debugBoxMesh && this._debugBoxMesh.dispose(),
  59527. this._debugSphereMesh && this._debugSphereMesh.dispose(),
  59528. this._debugCylinderMesh && this._debugCylinderMesh.dispose(),
  59529. this._debugMaterial && this._debugMaterial.dispose(),
  59530. this._impostors.length = 0,
  59531. this._scene = null,
  59532. this._physicsEnginePlugin = null,
  59533. this._utilityLayer && (this._utilityLayer.dispose(),
  59534. this._utilityLayer = null)
  59535. }
  59536. ,
  59537. e
  59538. }();
  59539. Vr._instancedMeshFactory = function(e, t) {
  59540. var i = new Hl(e,t);
  59541. if (t.instancedBuffers)
  59542. for (var n in i.instancedBuffers = {},
  59543. t.instancedBuffers)
  59544. i.instancedBuffers[n] = t.instancedBuffers[n];
  59545. return i
  59546. }
  59547. ;
  59548. var Hl = function(e) {
  59549. function t(t, i) {
  59550. var n = e.call(this, t, i.getScene()) || this;
  59551. n._indexInSourceMeshInstanceArray = -1,
  59552. n._distanceToCamera = 0,
  59553. i.addInstance(n),
  59554. n._sourceMesh = i,
  59555. n._unIndexed = i._unIndexed,
  59556. n.position.copyFrom(i.position),
  59557. n.rotation.copyFrom(i.rotation),
  59558. n.scaling.copyFrom(i.scaling),
  59559. i.rotationQuaternion && (n.rotationQuaternion = i.rotationQuaternion.clone()),
  59560. n.animations = gi.Slice(i.animations);
  59561. for (var r = 0, o = i.getAnimationRanges(); r < o.length; r++) {
  59562. var a = o[r];
  59563. null != a && n.createAnimationRange(a.name, a.from, a.to)
  59564. }
  59565. return n.infiniteDistance = i.infiniteDistance,
  59566. n.setPivotMatrix(i.getPivotMatrix()),
  59567. n.refreshBoundingInfo(!0, !0),
  59568. n._syncSubMeshes(),
  59569. n
  59570. }
  59571. return U(t, e),
  59572. t.prototype.getClassName = function() {
  59573. return "InstancedMesh"
  59574. }
  59575. ,
  59576. Object.defineProperty(t.prototype, "lightSources", {
  59577. get: function() {
  59578. return this._sourceMesh._lightSources
  59579. },
  59580. enumerable: !1,
  59581. configurable: !0
  59582. }),
  59583. t.prototype._resyncLightSources = function() {}
  59584. ,
  59585. t.prototype._resyncLightSource = function() {}
  59586. ,
  59587. t.prototype._removeLightSource = function() {}
  59588. ,
  59589. Object.defineProperty(t.prototype, "receiveShadows", {
  59590. get: function() {
  59591. return this._sourceMesh.receiveShadows
  59592. },
  59593. enumerable: !1,
  59594. configurable: !0
  59595. }),
  59596. Object.defineProperty(t.prototype, "material", {
  59597. get: function() {
  59598. return this._sourceMesh.material
  59599. },
  59600. enumerable: !1,
  59601. configurable: !0
  59602. }),
  59603. Object.defineProperty(t.prototype, "visibility", {
  59604. get: function() {
  59605. return this._sourceMesh.visibility
  59606. },
  59607. enumerable: !1,
  59608. configurable: !0
  59609. }),
  59610. Object.defineProperty(t.prototype, "skeleton", {
  59611. get: function() {
  59612. return this._sourceMesh.skeleton
  59613. },
  59614. enumerable: !1,
  59615. configurable: !0
  59616. }),
  59617. Object.defineProperty(t.prototype, "renderingGroupId", {
  59618. get: function() {
  59619. return this._sourceMesh.renderingGroupId
  59620. },
  59621. set: function(e) {
  59622. this._sourceMesh && e !== this._sourceMesh.renderingGroupId && K.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")
  59623. },
  59624. enumerable: !1,
  59625. configurable: !0
  59626. }),
  59627. t.prototype.getTotalVertices = function() {
  59628. return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0
  59629. }
  59630. ,
  59631. t.prototype.getTotalIndices = function() {
  59632. return this._sourceMesh.getTotalIndices()
  59633. }
  59634. ,
  59635. Object.defineProperty(t.prototype, "sourceMesh", {
  59636. get: function() {
  59637. return this._sourceMesh
  59638. },
  59639. enumerable: !1,
  59640. configurable: !0
  59641. }),
  59642. t.prototype.createInstance = function(e) {
  59643. return this._sourceMesh.createInstance(e)
  59644. }
  59645. ,
  59646. t.prototype.isReady = function(e) {
  59647. return void 0 === e && (e = !1),
  59648. this._sourceMesh.isReady(e, !0)
  59649. }
  59650. ,
  59651. t.prototype.getVerticesData = function(e, t) {
  59652. return this._sourceMesh.getVerticesData(e, t)
  59653. }
  59654. ,
  59655. t.prototype.setVerticesData = function(e, t, i, n) {
  59656. return this.sourceMesh && this.sourceMesh.setVerticesData(e, t, i, n),
  59657. this.sourceMesh
  59658. }
  59659. ,
  59660. t.prototype.updateVerticesData = function(e, t, i, n) {
  59661. return this.sourceMesh && this.sourceMesh.updateVerticesData(e, t, i, n),
  59662. this.sourceMesh
  59663. }
  59664. ,
  59665. t.prototype.setIndices = function(e, t) {
  59666. return void 0 === t && (t = null),
  59667. this.sourceMesh && this.sourceMesh.setIndices(e, t),
  59668. this.sourceMesh
  59669. }
  59670. ,
  59671. t.prototype.isVerticesDataPresent = function(e) {
  59672. return this._sourceMesh.isVerticesDataPresent(e)
  59673. }
  59674. ,
  59675. t.prototype.getIndices = function() {
  59676. return this._sourceMesh.getIndices()
  59677. }
  59678. ,
  59679. Object.defineProperty(t.prototype, "_positions", {
  59680. get: function() {
  59681. return this._sourceMesh._positions
  59682. },
  59683. enumerable: !1,
  59684. configurable: !0
  59685. }),
  59686. t.prototype.refreshBoundingInfo = function(e, t) {
  59687. if (void 0 === e && (e = !1),
  59688. void 0 === t && (t = !1),
  59689. this.hasBoundingInfo && this.getBoundingInfo().isLocked)
  59690. return this;
  59691. var i = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  59692. return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e, t), i),
  59693. this
  59694. }
  59695. ,
  59696. t.prototype._preActivate = function() {
  59697. return this._currentLOD && this._currentLOD._preActivate(),
  59698. this
  59699. }
  59700. ,
  59701. t.prototype._activate = function(e, t) {
  59702. if (this._sourceMesh.subMeshes || K.Warn("Instances should only be created for meshes with geometry."),
  59703. this._currentLOD) {
  59704. if (this._currentLOD._getWorldMatrixDeterminant() >= 0 != this._getWorldMatrixDeterminant() >= 0)
  59705. return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0,
  59706. !0;
  59707. if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1,
  59708. this._currentLOD._registerInstanceForRenderId(this, e),
  59709. t) {
  59710. if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)
  59711. return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !0,
  59712. !0
  59713. } else if (!this._currentLOD._internalAbstractMeshDataInfo._isActive)
  59714. return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = !0,
  59715. !0
  59716. }
  59717. return !1
  59718. }
  59719. ,
  59720. t.prototype._postActivate = function() {
  59721. this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup ? (this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),
  59722. this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())) : this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup && this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)
  59723. }
  59724. ,
  59725. t.prototype.getWorldMatrix = function() {
  59726. if (this._currentLOD && this._currentLOD.billboardMode !== yr.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
  59727. this._billboardWorldMatrix || (this._billboardWorldMatrix = new P);
  59728. var t = this._currentLOD._masterMesh;
  59729. return this._currentLOD._masterMesh = this,
  59730. I.Vector3[7].copyFrom(this._currentLOD.position),
  59731. this._currentLOD.position.set(0, 0, 0),
  59732. this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
  59733. this._currentLOD.position.copyFrom(I.Vector3[7]),
  59734. this._currentLOD._masterMesh = t,
  59735. this._billboardWorldMatrix
  59736. }
  59737. return e.prototype.getWorldMatrix.call(this)
  59738. }
  59739. ,
  59740. Object.defineProperty(t.prototype, "isAnInstance", {
  59741. get: function() {
  59742. return !0
  59743. },
  59744. enumerable: !1,
  59745. configurable: !0
  59746. }),
  59747. t.prototype.getLOD = function(e) {
  59748. if (!e)
  59749. return this;
  59750. var t = this.sourceMesh.getLODLevels();
  59751. if (t && 0 !== t.length) {
  59752. var i = this.getBoundingInfo();
  59753. this._currentLOD = this.sourceMesh.getLOD(e, i.boundingSphere)
  59754. } else
  59755. this._currentLOD = this.sourceMesh;
  59756. return this._currentLOD
  59757. }
  59758. ,
  59759. t.prototype._preActivateForIntermediateRendering = function(e) {
  59760. return this.sourceMesh._preActivateForIntermediateRendering(e)
  59761. }
  59762. ,
  59763. t.prototype._syncSubMeshes = function() {
  59764. if (this.releaseSubMeshes(),
  59765. this._sourceMesh.subMeshes)
  59766. for (var e = 0; e < this._sourceMesh.subMeshes.length; e++)
  59767. this._sourceMesh.subMeshes[e].clone(this, this._sourceMesh);
  59768. return this
  59769. }
  59770. ,
  59771. t.prototype._generatePointsArray = function() {
  59772. return this._sourceMesh._generatePointsArray()
  59773. }
  59774. ,
  59775. t.prototype._updateBoundingInfo = function() {
  59776. return this.hasBoundingInfo ? this.getBoundingInfo().update(this.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache),
  59777. this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),
  59778. this
  59779. }
  59780. ,
  59781. t.prototype.clone = function(e, t, i) {
  59782. void 0 === t && (t = null);
  59783. var n = this._sourceMesh.createInstance(e);
  59784. if (fe.DeepCopy(this, n, ["name", "subMeshes", "uniqueId", "parent", "lightSources", "receiveShadows", "material", "visibility", "skeleton", "sourceMesh", "isAnInstance", "facetNb", "isFacetDataEnabled", "isBlocked", "useBones", "hasInstances", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances"], []),
  59785. this.refreshBoundingInfo(),
  59786. t && (n.parent = t),
  59787. !i)
  59788. for (var r = 0; r < this.getScene().meshes.length; r++) {
  59789. var o = this.getScene().meshes[r];
  59790. o.parent === this && o.clone(o.name, n)
  59791. }
  59792. return n.computeWorldMatrix(!0),
  59793. this.onClonedObservable.notifyObservers(n),
  59794. n
  59795. }
  59796. ,
  59797. t.prototype.dispose = function(t, i) {
  59798. void 0 === i && (i = !1),
  59799. this._sourceMesh.removeInstance(this),
  59800. e.prototype.dispose.call(this, t, i)
  59801. }
  59802. ,
  59803. t
  59804. }(Sr);
  59805. Vr.prototype.edgesShareWithInstances = !1,
  59806. Vr.prototype.registerInstancedBuffer = function(e, t) {
  59807. var i, n;
  59808. if (null === (n = null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) || void 0 === n || n.dispose(),
  59809. !this.instancedBuffers) {
  59810. this.instancedBuffers = {};
  59811. for (var r = 0, o = this.instances; r < o.length; r++)
  59812. o[r].instancedBuffers = {};
  59813. this._userInstancedBuffersStorage = {
  59814. data: {},
  59815. vertexBuffers: {},
  59816. strides: {},
  59817. sizes: {},
  59818. vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
  59819. }
  59820. }
  59821. this.instancedBuffers[e] = null,
  59822. this._userInstancedBuffersStorage.strides[e] = t,
  59823. this._userInstancedBuffersStorage.sizes[e] = 32 * t,
  59824. this._userInstancedBuffersStorage.data[e] = new Float32Array(this._userInstancedBuffersStorage.sizes[e]),
  59825. this._userInstancedBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),this._userInstancedBuffersStorage.data[e],e,!0,!1,t,!0);
  59826. for (var a = 0, s = this.instances; a < s.length; a++)
  59827. s[a].instancedBuffers[e] = null;
  59828. this._invalidateInstanceVertexArrayObject()
  59829. }
  59830. ,
  59831. Vr.prototype._processInstancedBuffers = function(e, t) {
  59832. var i = e.length;
  59833. for (var n in this.instancedBuffers) {
  59834. for (var r = this._userInstancedBuffersStorage.sizes[n], o = this._userInstancedBuffersStorage.strides[n], a = (i + 1) * o; r < a; )
  59835. r *= 2;
  59836. this._userInstancedBuffersStorage.data[n].length != r && (this._userInstancedBuffersStorage.data[n] = new Float32Array(r),
  59837. this._userInstancedBuffersStorage.sizes[n] = r,
  59838. this._userInstancedBuffersStorage.vertexBuffers[n] && (this._userInstancedBuffersStorage.vertexBuffers[n].dispose(),
  59839. this._userInstancedBuffersStorage.vertexBuffers[n] = null));
  59840. var s = this._userInstancedBuffersStorage.data[n]
  59841. , l = 0;
  59842. t && ((u = this.instancedBuffers[n]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
  59843. l += o);
  59844. for (var c = 0; c < i; c++) {
  59845. var u;
  59846. (u = e[c].instancedBuffers[n]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
  59847. l += o
  59848. }
  59849. this._userInstancedBuffersStorage.vertexBuffers[n] ? this._userInstancedBuffersStorage.vertexBuffers[n].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[n] = new Bi(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,o,!0),
  59850. this._invalidateInstanceVertexArrayObject())
  59851. }
  59852. }
  59853. ,
  59854. Vr.prototype._invalidateInstanceVertexArrayObject = function() {
  59855. if (this._userInstancedBuffersStorage && void 0 !== this._userInstancedBuffersStorage.vertexArrayObjects) {
  59856. for (var e in this._userInstancedBuffersStorage.vertexArrayObjects)
  59857. this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[e]);
  59858. this._userInstancedBuffersStorage.vertexArrayObjects = {}
  59859. }
  59860. }
  59861. ,
  59862. Vr.prototype._disposeInstanceSpecificData = function() {
  59863. for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(),
  59864. this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
  59865. this.instances[0].dispose();
  59866. for (var e in this.instancedBuffers)
  59867. this._userInstancedBuffersStorage.vertexBuffers[e] && this._userInstancedBuffersStorage.vertexBuffers[e].dispose();
  59868. this._invalidateInstanceVertexArrayObject(),
  59869. this.instancedBuffers = {}
  59870. }
  59871. ;
  59872. var Xl = {
  59873. effect: null,
  59874. subMesh: null
  59875. }
  59876. , jl = function(e) {
  59877. function t(t, i, n, r, o) {
  59878. void 0 === r && (r = {}),
  59879. void 0 === o && (o = !0);
  59880. var a = e.call(this, t, i, o) || this;
  59881. return a._textures = {},
  59882. a._textureArrays = {},
  59883. a._externalTextures = {},
  59884. a._floats = {},
  59885. a._ints = {},
  59886. a._floatsArrays = {},
  59887. a._colors3 = {},
  59888. a._colors3Arrays = {},
  59889. a._colors4 = {},
  59890. a._colors4Arrays = {},
  59891. a._vectors2 = {},
  59892. a._vectors3 = {},
  59893. a._vectors4 = {},
  59894. a._matrices = {},
  59895. a._matrixArrays = {},
  59896. a._matrices3x3 = {},
  59897. a._matrices2x2 = {},
  59898. a._vectors2Arrays = {},
  59899. a._vectors3Arrays = {},
  59900. a._vectors4Arrays = {},
  59901. a._uniformBuffers = {},
  59902. a._textureSamplers = {},
  59903. a._storageBuffers = {},
  59904. a._cachedWorldViewMatrix = new P,
  59905. a._cachedWorldViewProjectionMatrix = new P,
  59906. a._multiview = !1,
  59907. a._shaderPath = n,
  59908. a._options = V({
  59909. needAlphaBlending: !1,
  59910. needAlphaTesting: !1,
  59911. attributes: ["position", "normal", "uv"],
  59912. uniforms: ["worldViewProjection"],
  59913. uniformBuffers: [],
  59914. samplers: [],
  59915. externalTextures: [],
  59916. samplerObjects: [],
  59917. storageBuffers: [],
  59918. defines: [],
  59919. useClipPlane: !1
  59920. }, r),
  59921. a
  59922. }
  59923. return U(t, e),
  59924. Object.defineProperty(t.prototype, "shaderPath", {
  59925. get: function() {
  59926. return this._shaderPath
  59927. },
  59928. set: function(e) {
  59929. this._shaderPath = e
  59930. },
  59931. enumerable: !1,
  59932. configurable: !0
  59933. }),
  59934. Object.defineProperty(t.prototype, "options", {
  59935. get: function() {
  59936. return this._options
  59937. },
  59938. enumerable: !1,
  59939. configurable: !0
  59940. }),
  59941. t.prototype.getClassName = function() {
  59942. return "ShaderMaterial"
  59943. }
  59944. ,
  59945. t.prototype.needAlphaBlending = function() {
  59946. return this.alpha < 1 || this._options.needAlphaBlending
  59947. }
  59948. ,
  59949. t.prototype.needAlphaTesting = function() {
  59950. return this._options.needAlphaTesting
  59951. }
  59952. ,
  59953. t.prototype._checkUniform = function(e) {
  59954. -1 === this._options.uniforms.indexOf(e) && this._options.uniforms.push(e)
  59955. }
  59956. ,
  59957. t.prototype.setTexture = function(e, t) {
  59958. return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e),
  59959. this._textures[e] = t,
  59960. this
  59961. }
  59962. ,
  59963. t.prototype.setTextureArray = function(e, t) {
  59964. return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e),
  59965. this._checkUniform(e),
  59966. this._textureArrays[e] = t,
  59967. this
  59968. }
  59969. ,
  59970. t.prototype.setExternalTexture = function(e, t) {
  59971. return -1 === this._options.externalTextures.indexOf(e) && this._options.externalTextures.push(e),
  59972. this._externalTextures[e] = t,
  59973. this
  59974. }
  59975. ,
  59976. t.prototype.setFloat = function(e, t) {
  59977. return this._checkUniform(e),
  59978. this._floats[e] = t,
  59979. this
  59980. }
  59981. ,
  59982. t.prototype.setInt = function(e, t) {
  59983. return this._checkUniform(e),
  59984. this._ints[e] = t,
  59985. this
  59986. }
  59987. ,
  59988. t.prototype.setFloats = function(e, t) {
  59989. return this._checkUniform(e),
  59990. this._floatsArrays[e] = t,
  59991. this
  59992. }
  59993. ,
  59994. t.prototype.setColor3 = function(e, t) {
  59995. return this._checkUniform(e),
  59996. this._colors3[e] = t,
  59997. this
  59998. }
  59999. ,
  60000. t.prototype.setColor3Array = function(e, t) {
  60001. return this._checkUniform(e),
  60002. this._colors3Arrays[e] = t.reduce((function(e, t) {
  60003. return t.toArray(e, e.length),
  60004. e
  60005. }
  60006. ), []),
  60007. this
  60008. }
  60009. ,
  60010. t.prototype.setColor4 = function(e, t) {
  60011. return this._checkUniform(e),
  60012. this._colors4[e] = t,
  60013. this
  60014. }
  60015. ,
  60016. t.prototype.setColor4Array = function(e, t) {
  60017. return this._checkUniform(e),
  60018. this._colors4Arrays[e] = t.reduce((function(e, t) {
  60019. return t.toArray(e, e.length),
  60020. e
  60021. }
  60022. ), []),
  60023. this
  60024. }
  60025. ,
  60026. t.prototype.setVector2 = function(e, t) {
  60027. return this._checkUniform(e),
  60028. this._vectors2[e] = t,
  60029. this
  60030. }
  60031. ,
  60032. t.prototype.setVector3 = function(e, t) {
  60033. return this._checkUniform(e),
  60034. this._vectors3[e] = t,
  60035. this
  60036. }
  60037. ,
  60038. t.prototype.setVector4 = function(e, t) {
  60039. return this._checkUniform(e),
  60040. this._vectors4[e] = t,
  60041. this
  60042. }
  60043. ,
  60044. t.prototype.setMatrix = function(e, t) {
  60045. return this._checkUniform(e),
  60046. this._matrices[e] = t,
  60047. this
  60048. }
  60049. ,
  60050. t.prototype.setMatrices = function(e, t) {
  60051. this._checkUniform(e);
  60052. for (var i = new Float32Array(16 * t.length), n = 0; n < t.length; n++)
  60053. t[n].copyToArray(i, 16 * n);
  60054. return this._matrixArrays[e] = i,
  60055. this
  60056. }
  60057. ,
  60058. t.prototype.setMatrix3x3 = function(e, t) {
  60059. return this._checkUniform(e),
  60060. this._matrices3x3[e] = t,
  60061. this
  60062. }
  60063. ,
  60064. t.prototype.setMatrix2x2 = function(e, t) {
  60065. return this._checkUniform(e),
  60066. this._matrices2x2[e] = t,
  60067. this
  60068. }
  60069. ,
  60070. t.prototype.setArray2 = function(e, t) {
  60071. return this._checkUniform(e),
  60072. this._vectors2Arrays[e] = t,
  60073. this
  60074. }
  60075. ,
  60076. t.prototype.setArray3 = function(e, t) {
  60077. return this._checkUniform(e),
  60078. this._vectors3Arrays[e] = t,
  60079. this
  60080. }
  60081. ,
  60082. t.prototype.setArray4 = function(e, t) {
  60083. return this._checkUniform(e),
  60084. this._vectors4Arrays[e] = t,
  60085. this
  60086. }
  60087. ,
  60088. t.prototype.setUniformBuffer = function(e, t) {
  60089. return -1 === this._options.uniformBuffers.indexOf(e) && this._options.uniformBuffers.push(e),
  60090. this._uniformBuffers[e] = t,
  60091. this
  60092. }
  60093. ,
  60094. t.prototype.setTextureSampler = function(e, t) {
  60095. return -1 === this._options.samplerObjects.indexOf(e) && this._options.samplerObjects.push(e),
  60096. this._textureSamplers[e] = t,
  60097. this
  60098. }
  60099. ,
  60100. t.prototype.setStorageBuffer = function(e, t) {
  60101. return -1 === this._options.storageBuffers.indexOf(e) && this._options.storageBuffers.push(e),
  60102. this._storageBuffers[e] = t,
  60103. this
  60104. }
  60105. ,
  60106. t.prototype.isReadyForSubMesh = function(e, t, i) {
  60107. return this.isReady(e, i, t)
  60108. }
  60109. ,
  60110. t.prototype.isReady = function(e, t, i) {
  60111. var n, r, o, a, s = i && this._storeEffectOnSubMeshes;
  60112. if (this.isFrozen)
  60113. if (s) {
  60114. if (i.effect && i.effect._wasPreviouslyReady)
  60115. return !0
  60116. } else {
  60117. var l = this._drawWrapper.effect;
  60118. if (l && l._wasPreviouslyReady && this._effectUsesInstances === t)
  60119. return !0
  60120. }
  60121. var c = this.getScene()
  60122. , u = c.getEngine()
  60123. , h = []
  60124. , d = []
  60125. , p = new ys
  60126. , f = this._shaderPath
  60127. , _ = this._options.uniforms
  60128. , m = this._options.uniformBuffers
  60129. , g = this._options.samplers;
  60130. u.getCaps().multiview && c.activeCamera && c.activeCamera.outputRenderTarget && c.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0,
  60131. h.push("#define MULTIVIEW"),
  60132. -1 !== this._options.uniforms.indexOf("viewProjection") && -1 === this._options.uniforms.indexOf("viewProjectionR") && this._options.uniforms.push("viewProjectionR"));
  60133. for (var v = 0; v < this._options.defines.length; v++) {
  60134. var y = 0 === this._options.defines[v].indexOf("#define") ? this._options.defines[v] : "#define ".concat(this._options.defines[v]);
  60135. h.push(y)
  60136. }
  60137. for (v = 0; v < this._options.attributes.length; v++)
  60138. d.push(this._options.attributes[v]);
  60139. if (e && e.isVerticesDataPresent(Bi.ColorKind) && (d.push(Bi.ColorKind),
  60140. h.push("#define VERTEXCOLOR")),
  60141. t && (h.push("#define INSTANCES"),
  60142. Mr.PushAttributesForInstances(d),
  60143. (null == e ? void 0 : e.hasThinInstances) && (h.push("#define THIN_INSTANCES"),
  60144. e && e.isVerticesDataPresent(Bi.ColorInstanceKind) && (d.push(Bi.ColorInstanceKind),
  60145. h.push("#define INSTANCESCOLOR")))),
  60146. e && e.useBones && e.computeBonesUsingShaders && e.skeleton) {
  60147. d.push(Bi.MatricesIndicesKind),
  60148. d.push(Bi.MatricesWeightsKind),
  60149. e.numBoneInfluencers > 4 && (d.push(Bi.MatricesIndicesExtraKind),
  60150. d.push(Bi.MatricesWeightsExtraKind));
  60151. var b = e.skeleton;
  60152. h.push("#define NUM_BONE_INFLUENCERS " + e.numBoneInfluencers),
  60153. p.addCPUSkinningFallback(0, e),
  60154. b.isUsingTextureForMatrices ? (h.push("#define BONETEXTURE"),
  60155. -1 === this._options.uniforms.indexOf("boneTextureWidth") && this._options.uniforms.push("boneTextureWidth"),
  60156. -1 === this._options.samplers.indexOf("boneSampler") && this._options.samplers.push("boneSampler")) : (h.push("#define BonesPerMesh " + (b.bones.length + 1)),
  60157. -1 === this._options.uniforms.indexOf("mBones") && this._options.uniforms.push("mBones"))
  60158. } else
  60159. h.push("#define NUM_BONE_INFLUENCERS 0");
  60160. var T = 0
  60161. , E = e ? e.morphTargetManager : null;
  60162. if (E) {
  60163. var S = E.supportsUVs && -1 !== h.indexOf("#define UV1")
  60164. , A = E.supportsTangents && -1 !== h.indexOf("#define TANGENT")
  60165. , x = E.supportsNormals && -1 !== h.indexOf("#define NORMAL");
  60166. for (T = E.numInfluencers,
  60167. S && h.push("#define MORPHTARGETS_UV"),
  60168. A && h.push("#define MORPHTARGETS_TANGENT"),
  60169. x && h.push("#define MORPHTARGETS_NORMAL"),
  60170. T > 0 && h.push("#define MORPHTARGETS"),
  60171. E.isUsingTextureForTargets && (h.push("#define MORPHTARGETS_TEXTURE"),
  60172. -1 === this._options.uniforms.indexOf("morphTargetTextureIndices") && this._options.uniforms.push("morphTargetTextureIndices"),
  60173. -1 === this._options.samplers.indexOf("morphTargets") && this._options.samplers.push("morphTargets")),
  60174. h.push("#define NUM_MORPH_INFLUENCERS " + T),
  60175. v = 0; v < T; v++)
  60176. d.push(Bi.PositionKind + v),
  60177. x && d.push(Bi.NormalKind + v),
  60178. A && d.push(Bi.TangentKind + v),
  60179. S && d.push(Bi.UVKind + "_" + v);
  60180. T > 0 && ((_ = _.slice()).push("morphTargetInfluences"),
  60181. _.push("morphTargetTextureInfo"),
  60182. _.push("morphTargetTextureIndices"))
  60183. } else
  60184. h.push("#define NUM_MORPH_INFLUENCERS 0");
  60185. if (e) {
  60186. var R = e.bakedVertexAnimationManager;
  60187. R && R.isEnabled && (h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),
  60188. -1 === this._options.uniforms.indexOf("bakedVertexAnimationSettings") && this._options.uniforms.push("bakedVertexAnimationSettings"),
  60189. -1 === this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),
  60190. -1 === this._options.uniforms.indexOf("bakedVertexAnimationTime") && this._options.uniforms.push("bakedVertexAnimationTime"),
  60191. -1 === this._options.samplers.indexOf("bakedVertexAnimationTexture") && this._options.samplers.push("bakedVertexAnimationTexture")),
  60192. Mr.PrepareAttributesForBakedVertexAnimation(d, e, h)
  60193. }
  60194. for (var C in this._textures)
  60195. if (!this._textures[C].isReady())
  60196. return !1;
  60197. e && this._shouldTurnAlphaTestOn(e) && h.push("#define ALPHATEST"),
  60198. (null === this._options.useClipPlane && c.clipPlane || this._options.useClipPlane) && (h.push("#define CLIPPLANE"),
  60199. -1 === _.indexOf("vClipPlane") && _.push("vClipPlane")),
  60200. (null === this._options.useClipPlane && c.clipPlane2 || this._options.useClipPlane) && (h.push("#define CLIPPLANE2"),
  60201. -1 === _.indexOf("vClipPlane2") && _.push("vClipPlane2")),
  60202. (null === this._options.useClipPlane && c.clipPlane3 || this._options.useClipPlane) && (h.push("#define CLIPPLANE3"),
  60203. -1 === _.indexOf("vClipPlane3") && _.push("vClipPlane3")),
  60204. (null === this._options.useClipPlane && c.clipPlane4 || this._options.useClipPlane) && (h.push("#define CLIPPLANE4"),
  60205. -1 === _.indexOf("vClipPlane4") && _.push("vClipPlane4")),
  60206. (null === this._options.useClipPlane && c.clipPlane5 || this._options.useClipPlane) && (h.push("#define CLIPPLANE5"),
  60207. -1 === _.indexOf("vClipPlane5") && _.push("vClipPlane5")),
  60208. (null === this._options.useClipPlane && c.clipPlane6 || this._options.useClipPlane) && (h.push("#define CLIPPLANE6"),
  60209. -1 === _.indexOf("vClipPlane6") && _.push("vClipPlane6")),
  60210. this.customShaderNameResolve && (_ = _.slice(),
  60211. m = m.slice(),
  60212. g = g.slice(),
  60213. f = this.customShaderNameResolve(f, _, m, g, h, d));
  60214. var P = s ? i._getDrawWrapper() : this._drawWrapper
  60215. , M = null !== (n = null == P ? void 0 : P.effect) && void 0 !== n ? n : null
  60216. , I = null !== (r = null == P ? void 0 : P.defines) && void 0 !== r ? r : null
  60217. , O = h.join("\n")
  60218. , D = M;
  60219. return I !== O && (D = u.createEffect(f, {
  60220. attributes: d,
  60221. uniformsNames: _,
  60222. uniformBuffersNames: m,
  60223. samplers: g,
  60224. defines: O,
  60225. fallbacks: p,
  60226. onCompiled: this.onCompiled,
  60227. onError: this.onError,
  60228. indexParameters: {
  60229. maxSimultaneousMorphTargets: T
  60230. },
  60231. shaderLanguage: this._options.shaderLanguage
  60232. }, u),
  60233. s ? i.setEffect(D, O, this._materialContext) : P && P.setEffect(D, O),
  60234. this._onEffectCreatedObservable && (Xl.effect = D,
  60235. Xl.subMesh = null !== (o = null != i ? i : null == e ? void 0 : e.subMeshes[0]) && void 0 !== o ? o : null,
  60236. this._onEffectCreatedObservable.notifyObservers(Xl))),
  60237. this._effectUsesInstances = !!t,
  60238. null !== (a = !(null == D ? void 0 : D.isReady())) && void 0 !== a && !a && (M !== D && c.resetCachedMaterial(),
  60239. D._wasPreviouslyReady = !0,
  60240. !0)
  60241. }
  60242. ,
  60243. t.prototype.bindOnlyWorldMatrix = function(e, t) {
  60244. var i = this.getScene()
  60245. , n = null != t ? t : this.getEffect();
  60246. n && (-1 !== this._options.uniforms.indexOf("world") && n.setMatrix("world", e),
  60247. -1 !== this._options.uniforms.indexOf("worldView") && (e.multiplyToRef(i.getViewMatrix(), this._cachedWorldViewMatrix),
  60248. n.setMatrix("worldView", this._cachedWorldViewMatrix)),
  60249. -1 !== this._options.uniforms.indexOf("worldViewProjection") && (e.multiplyToRef(i.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
  60250. n.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
  60251. }
  60252. ,
  60253. t.prototype.bindForSubMesh = function(e, t, i) {
  60254. var n;
  60255. this.bind(e, t, null === (n = i._drawWrapperOverride) || void 0 === n ? void 0 : n.effect, i)
  60256. }
  60257. ,
  60258. t.prototype.bind = function(e, t, i, n) {
  60259. var r, o = n && this._storeEffectOnSubMeshes, a = null != i ? i : o ? n.effect : this.getEffect();
  60260. if (a) {
  60261. this._activeEffect = a,
  60262. this.bindOnlyWorldMatrix(e, i);
  60263. var s = this._options.uniformBuffers
  60264. , l = !1;
  60265. if (a && s && s.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
  60266. for (var c = 0; c < s.length; ++c)
  60267. switch (s[c]) {
  60268. case "Mesh":
  60269. t && (t.getMeshUniformBuffer().bindToEffect(a, "Mesh"),
  60270. t.transferToEffect(e));
  60271. break;
  60272. case "Scene":
  60273. Mr.BindSceneUniformBuffer(a, this.getScene().getSceneUniformBuffer()),
  60274. this.getScene().finalizeSceneUbo(),
  60275. l = !0
  60276. }
  60277. var u = t && o ? this._mustRebind(this.getScene(), a, t.visibility) : this.getScene().getCachedMaterial() !== this;
  60278. if (a && u) {
  60279. var h;
  60280. for (h in l || -1 === this._options.uniforms.indexOf("view") || a.setMatrix("view", this.getScene().getViewMatrix()),
  60281. l || -1 === this._options.uniforms.indexOf("projection") || a.setMatrix("projection", this.getScene().getProjectionMatrix()),
  60282. l || -1 === this._options.uniforms.indexOf("viewProjection") || (a.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
  60283. this._multiview && a.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)),
  60284. this.getScene().activeCamera && -1 !== this._options.uniforms.indexOf("cameraPosition") && a.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition),
  60285. Mr.BindBonesParameters(t, a),
  60286. Mr.BindClipPlane(a, this.getScene()),
  60287. this._textures)
  60288. a.setTexture(h, this._textures[h]);
  60289. for (h in this._textureArrays)
  60290. a.setTextureArray(h, this._textureArrays[h]);
  60291. for (h in this._externalTextures)
  60292. a.setExternalTexture(h, this._externalTextures[h]);
  60293. for (h in this._ints)
  60294. a.setInt(h, this._ints[h]);
  60295. for (h in this._floats)
  60296. a.setFloat(h, this._floats[h]);
  60297. for (h in this._floatsArrays)
  60298. a.setArray(h, this._floatsArrays[h]);
  60299. for (h in this._colors3)
  60300. a.setColor3(h, this._colors3[h]);
  60301. for (h in this._colors3Arrays)
  60302. a.setArray3(h, this._colors3Arrays[h]);
  60303. for (h in this._colors4) {
  60304. var d = this._colors4[h];
  60305. a.setFloat4(h, d.r, d.g, d.b, d.a)
  60306. }
  60307. for (h in this._colors4Arrays)
  60308. a.setArray4(h, this._colors4Arrays[h]);
  60309. for (h in this._vectors2)
  60310. a.setVector2(h, this._vectors2[h]);
  60311. for (h in this._vectors3)
  60312. a.setVector3(h, this._vectors3[h]);
  60313. for (h in this._vectors4)
  60314. a.setVector4(h, this._vectors4[h]);
  60315. for (h in this._matrices)
  60316. a.setMatrix(h, this._matrices[h]);
  60317. for (h in this._matrixArrays)
  60318. a.setMatrices(h, this._matrixArrays[h]);
  60319. for (h in this._matrices3x3)
  60320. a.setMatrix3x3(h, this._matrices3x3[h]);
  60321. for (h in this._matrices2x2)
  60322. a.setMatrix2x2(h, this._matrices2x2[h]);
  60323. for (h in this._vectors2Arrays)
  60324. a.setArray2(h, this._vectors2Arrays[h]);
  60325. for (h in this._vectors3Arrays)
  60326. a.setArray3(h, this._vectors3Arrays[h]);
  60327. for (h in this._vectors4Arrays)
  60328. a.setArray4(h, this._vectors4Arrays[h]);
  60329. for (h in this._uniformBuffers) {
  60330. var p = this._uniformBuffers[h].getBuffer();
  60331. p && a.bindUniformBuffer(p, h)
  60332. }
  60333. for (h in this._textureSamplers)
  60334. a.setTextureSampler(h, this._textureSamplers[h]);
  60335. for (h in this._storageBuffers)
  60336. a.setStorageBuffer(h, this._storageBuffers[h])
  60337. }
  60338. if (a && t && (u || !this.isFrozen)) {
  60339. var f = t.morphTargetManager;
  60340. f && f.numInfluencers > 0 && Mr.BindMorphTargetParameters(t, a);
  60341. var _ = t.bakedVertexAnimationManager;
  60342. _ && _.isEnabled && (null === (r = t.bakedVertexAnimationManager) || void 0 === r || r.bind(a, this._effectUsesInstances))
  60343. }
  60344. this._afterBind(t, a)
  60345. }
  60346. }
  60347. ,
  60348. t.prototype.getActiveTextures = function() {
  60349. var t = e.prototype.getActiveTextures.call(this);
  60350. for (var i in this._textures)
  60351. t.push(this._textures[i]);
  60352. for (var n in this._textureArrays)
  60353. for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
  60354. t.push(r[o]);
  60355. return t
  60356. }
  60357. ,
  60358. t.prototype.hasTexture = function(t) {
  60359. if (e.prototype.hasTexture.call(this, t))
  60360. return !0;
  60361. for (var i in this._textures)
  60362. if (this._textures[i] === t)
  60363. return !0;
  60364. for (var n in this._textureArrays)
  60365. for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
  60366. if (r[o] === t)
  60367. return !0;
  60368. return !1
  60369. }
  60370. ,
  60371. t.prototype.clone = function(e) {
  60372. var i = this
  60373. , n = Ge.Clone((function() {
  60374. return new t(e,i.getScene(),i._shaderPath,i._options,i._storeEffectOnSubMeshes)
  60375. }
  60376. ), this);
  60377. for (var r in n.name = e,
  60378. n.id = e,
  60379. "object" == typeof n._shaderPath && (n._shaderPath = V({}, n._shaderPath)),
  60380. this._options = V({}, this._options),
  60381. Object.keys(this._options).forEach((function(e) {
  60382. var t = i._options[e];
  60383. Array.isArray(t) && (i._options[e] = t.slice(0))
  60384. }
  60385. )),
  60386. this.stencil.copyTo(n.stencil),
  60387. this._textures)
  60388. n.setTexture(r, this._textures[r]);
  60389. for (var r in this._textureArrays)
  60390. n.setTextureArray(r, this._textureArrays[r]);
  60391. for (var r in this._externalTextures)
  60392. n.setExternalTexture(r, this._externalTextures[r]);
  60393. for (var r in this._ints)
  60394. n.setInt(r, this._ints[r]);
  60395. for (var r in this._floats)
  60396. n.setFloat(r, this._floats[r]);
  60397. for (var r in this._floatsArrays)
  60398. n.setFloats(r, this._floatsArrays[r]);
  60399. for (var r in this._colors3)
  60400. n.setColor3(r, this._colors3[r]);
  60401. for (var r in this._colors3Arrays)
  60402. n._colors3Arrays[r] = this._colors3Arrays[r];
  60403. for (var r in this._colors4)
  60404. n.setColor4(r, this._colors4[r]);
  60405. for (var r in this._colors4Arrays)
  60406. n._colors4Arrays[r] = this._colors4Arrays[r];
  60407. for (var r in this._vectors2)
  60408. n.setVector2(r, this._vectors2[r]);
  60409. for (var r in this._vectors3)
  60410. n.setVector3(r, this._vectors3[r]);
  60411. for (var r in this._vectors4)
  60412. n.setVector4(r, this._vectors4[r]);
  60413. for (var r in this._matrices)
  60414. n.setMatrix(r, this._matrices[r]);
  60415. for (var r in this._matrixArrays)
  60416. n._matrixArrays[r] = this._matrixArrays[r].slice();
  60417. for (var r in this._matrices3x3)
  60418. n.setMatrix3x3(r, this._matrices3x3[r]);
  60419. for (var r in this._matrices2x2)
  60420. n.setMatrix2x2(r, this._matrices2x2[r]);
  60421. for (var r in this._vectors2Arrays)
  60422. n.setArray2(r, this._vectors2Arrays[r]);
  60423. for (var r in this._vectors3Arrays)
  60424. n.setArray3(r, this._vectors3Arrays[r]);
  60425. for (var r in this._vectors4Arrays)
  60426. n.setArray4(r, this._vectors4Arrays[r]);
  60427. for (var r in this._uniformBuffers)
  60428. n.setUniformBuffer(r, this._uniformBuffers[r]);
  60429. for (var r in this._textureSamplers)
  60430. n.setTextureSampler(r, this._textureSamplers[r]);
  60431. for (var r in this._storageBuffers)
  60432. n.setStorageBuffer(r, this._storageBuffers[r]);
  60433. return n
  60434. }
  60435. ,
  60436. t.prototype.dispose = function(t, i, n) {
  60437. if (i) {
  60438. var r;
  60439. for (r in this._textures)
  60440. this._textures[r].dispose();
  60441. for (r in this._textureArrays)
  60442. for (var o = this._textureArrays[r], a = 0; a < o.length; a++)
  60443. o[a].dispose()
  60444. }
  60445. this._textures = {},
  60446. e.prototype.dispose.call(this, t, i, n)
  60447. }
  60448. ,
  60449. t.prototype.serialize = function() {
  60450. var e, t = Ge.Serialize(this);
  60451. for (e in t.customType = "BABYLON.ShaderMaterial",
  60452. t.options = this._options,
  60453. t.shaderPath = this._shaderPath,
  60454. t.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes,
  60455. t.stencil = this.stencil.serialize(),
  60456. t.textures = {},
  60457. this._textures)
  60458. t.textures[e] = this._textures[e].serialize();
  60459. for (e in t.textureArrays = {},
  60460. this._textureArrays) {
  60461. t.textureArrays[e] = [];
  60462. for (var i = this._textureArrays[e], n = 0; n < i.length; n++)
  60463. t.textureArrays[e].push(i[n].serialize())
  60464. }
  60465. for (e in t.ints = {},
  60466. this._ints)
  60467. t.ints[e] = this._ints[e];
  60468. for (e in t.floats = {},
  60469. this._floats)
  60470. t.floats[e] = this._floats[e];
  60471. for (e in t.FloatArrays = {},
  60472. this._floatsArrays)
  60473. t.FloatArrays[e] = this._floatsArrays[e];
  60474. for (e in t.colors3 = {},
  60475. this._colors3)
  60476. t.colors3[e] = this._colors3[e].asArray();
  60477. for (e in t.colors3Arrays = {},
  60478. this._colors3Arrays)
  60479. t.colors3Arrays[e] = this._colors3Arrays[e];
  60480. for (e in t.colors4 = {},
  60481. this._colors4)
  60482. t.colors4[e] = this._colors4[e].asArray();
  60483. for (e in t.colors4Arrays = {},
  60484. this._colors4Arrays)
  60485. t.colors4Arrays[e] = this._colors4Arrays[e];
  60486. for (e in t.vectors2 = {},
  60487. this._vectors2)
  60488. t.vectors2[e] = this._vectors2[e].asArray();
  60489. for (e in t.vectors3 = {},
  60490. this._vectors3)
  60491. t.vectors3[e] = this._vectors3[e].asArray();
  60492. for (e in t.vectors4 = {},
  60493. this._vectors4)
  60494. t.vectors4[e] = this._vectors4[e].asArray();
  60495. for (e in t.matrices = {},
  60496. this._matrices)
  60497. t.matrices[e] = this._matrices[e].asArray();
  60498. for (e in t.matrixArray = {},
  60499. this._matrixArrays)
  60500. t.matrixArray[e] = this._matrixArrays[e];
  60501. for (e in t.matrices3x3 = {},
  60502. this._matrices3x3)
  60503. t.matrices3x3[e] = this._matrices3x3[e];
  60504. for (e in t.matrices2x2 = {},
  60505. this._matrices2x2)
  60506. t.matrices2x2[e] = this._matrices2x2[e];
  60507. for (e in t.vectors2Arrays = {},
  60508. this._vectors2Arrays)
  60509. t.vectors2Arrays[e] = this._vectors2Arrays[e];
  60510. for (e in t.vectors3Arrays = {},
  60511. this._vectors3Arrays)
  60512. t.vectors3Arrays[e] = this._vectors3Arrays[e];
  60513. for (e in t.vectors4Arrays = {},
  60514. this._vectors4Arrays)
  60515. t.vectors4Arrays[e] = this._vectors4Arrays[e];
  60516. return t
  60517. }
  60518. ,
  60519. t.Parse = function(e, i, n) {
  60520. var r, o = Ge.Parse((function() {
  60521. return new t(e.name,i,e.shaderPath,e.options,e.storeEffectOnSubMeshes)
  60522. }
  60523. ), e, i, n);
  60524. for (r in e.stencil && o.stencil.parse(e.stencil, i, n),
  60525. e.textures)
  60526. o.setTexture(r, io.Parse(e.textures[r], i, n));
  60527. for (r in e.textureArrays) {
  60528. for (var a = e.textureArrays[r], s = new Array, l = 0; l < a.length; l++)
  60529. s.push(io.Parse(a[l], i, n));
  60530. o.setTextureArray(r, s)
  60531. }
  60532. for (r in e.ints)
  60533. o.setInt(r, e.ints[r]);
  60534. for (r in e.floats)
  60535. o.setFloat(r, e.floats[r]);
  60536. for (r in e.floatsArrays)
  60537. o.setFloats(r, e.floatsArrays[r]);
  60538. for (r in e.colors3)
  60539. o.setColor3(r, D.FromArray(e.colors3[r]));
  60540. for (r in e.colors3Arrays) {
  60541. var c = e.colors3Arrays[r].reduce((function(e, t, i) {
  60542. return i % 3 == 0 ? e.push([t]) : e[e.length - 1].push(t),
  60543. e
  60544. }
  60545. ), []).map((function(e) {
  60546. return D.FromArray(e)
  60547. }
  60548. ));
  60549. o.setColor3Array(r, c)
  60550. }
  60551. for (r in e.colors4)
  60552. o.setColor4(r, N.FromArray(e.colors4[r]));
  60553. for (r in e.colors4Arrays)
  60554. c = e.colors4Arrays[r].reduce((function(e, t, i) {
  60555. return i % 4 == 0 ? e.push([t]) : e[e.length - 1].push(t),
  60556. e
  60557. }
  60558. ), []).map((function(e) {
  60559. return N.FromArray(e)
  60560. }
  60561. )),
  60562. o.setColor4Array(r, c);
  60563. for (r in e.vectors2)
  60564. o.setVector2(r, A.FromArray(e.vectors2[r]));
  60565. for (r in e.vectors3)
  60566. o.setVector3(r, x.FromArray(e.vectors3[r]));
  60567. for (r in e.vectors4)
  60568. o.setVector4(r, R.FromArray(e.vectors4[r]));
  60569. for (r in e.matrices)
  60570. o.setMatrix(r, P.FromArray(e.matrices[r]));
  60571. for (r in e.matrixArray)
  60572. o._matrixArrays[r] = new Float32Array(e.matrixArray[r]);
  60573. for (r in e.matrices3x3)
  60574. o.setMatrix3x3(r, e.matrices3x3[r]);
  60575. for (r in e.matrices2x2)
  60576. o.setMatrix2x2(r, e.matrices2x2[r]);
  60577. for (r in e.vectors2Arrays)
  60578. o.setArray2(r, e.vectors2Arrays[r]);
  60579. for (r in e.vectors3Arrays)
  60580. o.setArray3(r, e.vectors3Arrays[r]);
  60581. for (r in e.vectors4Arrays)
  60582. o.setArray4(r, e.vectors4Arrays[r]);
  60583. return o
  60584. }
  60585. ,
  60586. t.ParseFromFileAsync = function(e, t, i, n) {
  60587. var r = this;
  60588. return void 0 === n && (n = ""),
  60589. new Promise((function(o, a) {
  60590. var s = new Ye;
  60591. s.addEventListener("readystatechange", (function() {
  60592. if (4 == s.readyState)
  60593. if (200 == s.status) {
  60594. var t = JSON.parse(s.responseText)
  60595. , l = r.Parse(t, i || E.LastCreatedScene, n);
  60596. e && (l.name = e),
  60597. o(l)
  60598. } else
  60599. a("Unable to load the ShaderMaterial")
  60600. }
  60601. )),
  60602. s.open("GET", t),
  60603. s.send()
  60604. }
  60605. ))
  60606. }
  60607. ,
  60608. t.CreateFromSnippetAsync = function(e, t, i) {
  60609. var n = this;
  60610. return void 0 === i && (i = ""),
  60611. new Promise((function(r, o) {
  60612. var a = new Ye;
  60613. a.addEventListener("readystatechange", (function() {
  60614. if (4 == a.readyState)
  60615. if (200 == a.status) {
  60616. var s = JSON.parse(JSON.parse(a.responseText).jsonPayload)
  60617. , l = JSON.parse(s.shaderMaterial)
  60618. , c = n.Parse(l, t || E.LastCreatedScene, i);
  60619. c.snippetId = e,
  60620. r(c)
  60621. } else
  60622. o("Unable to load the snippet " + e)
  60623. }
  60624. )),
  60625. a.open("GET", n.SnippetUrl + "/" + e.replace(/#/g, "/")),
  60626. a.send()
  60627. }
  60628. ))
  60629. }
  60630. ,
  60631. t.SnippetUrl = "https://snippet.babylonjs.com",
  60632. t
  60633. }(gs);
  60634. y("BABYLON.ShaderMaterial", jl);
  60635. Pt.ShadersStore.colorPixelShader = "#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  60636. Pt.ShadersStore.colorVertexShader = "attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}",
  60637. Vr._LinesMeshParser = function(e, t) {
  60638. return Yl.Parse(e, t)
  60639. }
  60640. ;
  60641. var Yl = function(e) {
  60642. function t(t, i, n, r, o, a, s, l) {
  60643. void 0 === i && (i = null),
  60644. void 0 === n && (n = null),
  60645. void 0 === r && (r = null);
  60646. var c = e.call(this, t, i, n, r, o) || this;
  60647. c.useVertexColor = a,
  60648. c.useVertexAlpha = s,
  60649. c.color = new D(1,1,1),
  60650. c.alpha = 1,
  60651. r && (c.color = r.color.clone(),
  60652. c.alpha = r.alpha,
  60653. c.useVertexColor = r.useVertexColor,
  60654. c.useVertexAlpha = r.useVertexAlpha),
  60655. c.intersectionThreshold = .1;
  60656. var u = {
  60657. attributes: [Bi.PositionKind],
  60658. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
  60659. needAlphaBlending: !0,
  60660. defines: [],
  60661. useClipPlane: null
  60662. };
  60663. return !1 === s && (u.needAlphaBlending = !1),
  60664. a ? (u.defines.push("#define VERTEXCOLOR"),
  60665. u.attributes.push(Bi.ColorKind)) : (u.uniforms.push("color"),
  60666. c._color4 = new N),
  60667. c.material = l || new jl("colorShader",c.getScene(),"color",u,!1),
  60668. c
  60669. }
  60670. return U(t, e),
  60671. t.prototype._isShaderMaterial = function(e) {
  60672. return "ShaderMaterial" === e.getClassName()
  60673. }
  60674. ,
  60675. t.prototype.isReady = function() {
  60676. return !!this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage) && e.prototype.isReady.call(this)
  60677. }
  60678. ,
  60679. t.prototype.getClassName = function() {
  60680. return "LinesMesh"
  60681. }
  60682. ,
  60683. Object.defineProperty(t.prototype, "material", {
  60684. get: function() {
  60685. return this._lineMaterial
  60686. },
  60687. set: function(e) {
  60688. this._lineMaterial = e,
  60689. this._lineMaterial.fillMode = Or.LineListDrawMode
  60690. },
  60691. enumerable: !1,
  60692. configurable: !0
  60693. }),
  60694. Object.defineProperty(t.prototype, "checkCollisions", {
  60695. get: function() {
  60696. return !1
  60697. },
  60698. set: function(e) {},
  60699. enumerable: !1,
  60700. configurable: !0
  60701. }),
  60702. t.prototype._bind = function() {
  60703. if (!this._geometry)
  60704. return this;
  60705. var e = this._lineMaterial.getEffect()
  60706. , t = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
  60707. if (this._userInstancedBuffersStorage ? this._geometry._bind(e, t, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(e, t),
  60708. !this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
  60709. var i = this.color
  60710. , n = i.r
  60711. , r = i.g
  60712. , o = i.b;
  60713. this._color4.set(n, r, o, this.alpha),
  60714. this._lineMaterial.setColor4("color", this._color4)
  60715. }
  60716. return this
  60717. }
  60718. ,
  60719. t.prototype._draw = function(e, t, i) {
  60720. if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
  60721. return this;
  60722. var n = this.getScene().getEngine();
  60723. return this._unIndexed ? n.drawArraysType(Or.LineListDrawMode, e.verticesStart, e.verticesCount, i) : n.drawElementsType(Or.LineListDrawMode, e.indexStart, e.indexCount, i),
  60724. this
  60725. }
  60726. ,
  60727. t.prototype.dispose = function(t) {
  60728. this._lineMaterial.dispose(!1, !1, !0),
  60729. e.prototype.dispose.call(this, t)
  60730. }
  60731. ,
  60732. t.prototype.clone = function(e, i, n) {
  60733. return void 0 === i && (i = null),
  60734. new t(e,this.getScene(),i,this,n)
  60735. }
  60736. ,
  60737. t.prototype.createInstance = function(e) {
  60738. var t = new Kl(e,this);
  60739. if (this.instancedBuffers)
  60740. for (var i in t.instancedBuffers = {},
  60741. this.instancedBuffers)
  60742. t.instancedBuffers[i] = this.instancedBuffers[i];
  60743. return t
  60744. }
  60745. ,
  60746. t.prototype.serialize = function(t) {
  60747. e.prototype.serialize.call(this, t),
  60748. t.color = this.color.asArray(),
  60749. t.alpha = this.alpha
  60750. }
  60751. ,
  60752. t.Parse = function(e, i) {
  60753. var n = new t(e.name,i);
  60754. return n.color = D.FromArray(e.color),
  60755. n.alpha = e.alpha,
  60756. n
  60757. }
  60758. ,
  60759. t
  60760. }(Vr)
  60761. , Kl = function(e) {
  60762. function t(t, i) {
  60763. var n = e.call(this, t, i) || this;
  60764. return n.intersectionThreshold = i.intersectionThreshold,
  60765. n
  60766. }
  60767. return U(t, e),
  60768. t.prototype.getClassName = function() {
  60769. return "InstancedLinesMesh"
  60770. }
  60771. ,
  60772. t
  60773. }(Hl);
  60774. function Ql(e) {
  60775. for (var t = [], i = [], n = e.lines, r = e.colors, o = [], a = 0, s = 0; s < n.length; s++)
  60776. for (var l = n[s], c = 0; c < l.length; c++) {
  60777. if (i.push(l[c].x, l[c].y, l[c].z),
  60778. r) {
  60779. var u = r[s];
  60780. o.push(u[c].r, u[c].g, u[c].b, u[c].a)
  60781. }
  60782. c > 0 && (t.push(a - 1),
  60783. t.push(a)),
  60784. a++
  60785. }
  60786. var h = new $n;
  60787. return h.indices = t,
  60788. h.positions = i,
  60789. r && (h.colors = o),
  60790. h
  60791. }
  60792. function ql(e) {
  60793. var t, i, n = e.dashSize || 3, r = e.gapSize || 1, o = e.dashNb || 200, a = e.points, s = new Array, l = new Array, c = x.Zero(), u = 0, h = 0, d = 0, p = 0, f = 0;
  60794. for (f = 0; f < a.length - 1; f++)
  60795. a[f + 1].subtractToRef(a[f], c),
  60796. u += c.length();
  60797. for (i = n * (t = u / o) / (n + r),
  60798. f = 0; f < a.length - 1; f++) {
  60799. a[f + 1].subtractToRef(a[f], c),
  60800. h = Math.floor(c.length() / t),
  60801. c.normalize();
  60802. for (var _ = 0; _ < h; _++)
  60803. d = t * _,
  60804. s.push(a[f].x + d * c.x, a[f].y + d * c.y, a[f].z + d * c.z),
  60805. s.push(a[f].x + (d + i) * c.x, a[f].y + (d + i) * c.y, a[f].z + (d + i) * c.z),
  60806. l.push(p, p + 1),
  60807. p += 2
  60808. }
  60809. var m = new $n;
  60810. return m.positions = s,
  60811. m.indices = l,
  60812. m
  60813. }
  60814. function Zl(e, t, i) {
  60815. var n = t.instance
  60816. , r = t.lines
  60817. , o = t.colors;
  60818. if (n) {
  60819. var a = n.getVerticesData(Bi.PositionKind)
  60820. , s = void 0
  60821. , l = void 0;
  60822. o && (s = n.getVerticesData(Bi.ColorKind));
  60823. for (var c = 0, u = 0, h = 0; h < r.length; h++)
  60824. for (var d = r[h], p = 0; p < d.length; p++)
  60825. a[c] = d[p].x,
  60826. a[c + 1] = d[p].y,
  60827. a[c + 2] = d[p].z,
  60828. o && s && (l = o[h],
  60829. s[u] = l[p].r,
  60830. s[u + 1] = l[p].g,
  60831. s[u + 2] = l[p].b,
  60832. s[u + 3] = l[p].a,
  60833. u += 4),
  60834. c += 3;
  60835. return n.updateVerticesData(Bi.PositionKind, a, !1, !1),
  60836. o && s && n.updateVerticesData(Bi.ColorKind, s, !1, !1),
  60837. n
  60838. }
  60839. var f = new Yl(e,i,null,void 0,void 0,!!o,t.useVertexAlpha,t.material);
  60840. return Ql(t).applyToMesh(f, t.updatable),
  60841. f
  60842. }
  60843. function Jl(e, t, i) {
  60844. void 0 === i && (i = null);
  60845. var n = t.colors ? [t.colors] : null;
  60846. return Zl(e, {
  60847. lines: [t.points],
  60848. updatable: t.updatable,
  60849. instance: t.instance,
  60850. colors: n,
  60851. useVertexAlpha: t.useVertexAlpha,
  60852. material: t.material
  60853. }, i)
  60854. }
  60855. function $l(e, t, i) {
  60856. void 0 === i && (i = null);
  60857. var n = t.points
  60858. , r = t.instance
  60859. , o = t.gapSize || 1
  60860. , a = t.dashSize || 3;
  60861. if (r)
  60862. return r.updateMeshPositions((function(e) {
  60863. var t, i, o = x.Zero(), a = e.length / 6, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0;
  60864. for (h = 0; h < n.length - 1; h++)
  60865. n[h + 1].subtractToRef(n[h], o),
  60866. s += o.length();
  60867. t = s / a;
  60868. var p = r._creationDataStorage.dashSize;
  60869. for (i = p * t / (p + r._creationDataStorage.gapSize),
  60870. h = 0; h < n.length - 1; h++)
  60871. for (n[h + 1].subtractToRef(n[h], o),
  60872. l = Math.floor(o.length() / t),
  60873. o.normalize(),
  60874. d = 0; d < l && u < e.length; )
  60875. c = t * d,
  60876. e[u] = n[h].x + c * o.x,
  60877. e[u + 1] = n[h].y + c * o.y,
  60878. e[u + 2] = n[h].z + c * o.z,
  60879. e[u + 3] = n[h].x + (c + i) * o.x,
  60880. e[u + 4] = n[h].y + (c + i) * o.y,
  60881. e[u + 5] = n[h].z + (c + i) * o.z,
  60882. u += 6,
  60883. d++;
  60884. for (; u < e.length; )
  60885. e[u] = n[h].x,
  60886. e[u + 1] = n[h].y,
  60887. e[u + 2] = n[h].z,
  60888. u += 3
  60889. }
  60890. ), !1),
  60891. r;
  60892. var s = new Yl(e,i,null,void 0,void 0,void 0,t.useVertexAlpha,t.material);
  60893. return ql(t).applyToMesh(s, t.updatable),
  60894. s._creationDataStorage = new Lr,
  60895. s._creationDataStorage.dashSize = a,
  60896. s._creationDataStorage.gapSize = o,
  60897. s
  60898. }
  60899. var ec = {
  60900. CreateDashedLines: $l,
  60901. CreateLineSystem: Zl,
  60902. CreateLines: Jl
  60903. };
  60904. $n.CreateLineSystem = Ql,
  60905. $n.CreateDashedLines = ql,
  60906. Vr.CreateLines = function(e, t, i, n, r) {
  60907. return void 0 === i && (i = null),
  60908. void 0 === n && (n = !1),
  60909. void 0 === r && (r = null),
  60910. Jl(e, {
  60911. points: t,
  60912. updatable: n,
  60913. instance: r
  60914. }, i)
  60915. }
  60916. ,
  60917. Vr.CreateDashedLines = function(e, t, i, n, r, o, a, s) {
  60918. return void 0 === o && (o = null),
  60919. $l(e, {
  60920. points: t,
  60921. dashSize: i,
  60922. gapSize: n,
  60923. dashNb: r,
  60924. updatable: a,
  60925. instance: s
  60926. }, o)
  60927. }
  60928. ;
  60929. var tc = function() {
  60930. function e(e) {
  60931. this.ray = e
  60932. }
  60933. return e.CreateAndShow = function(t, i, n) {
  60934. var r = new e(t);
  60935. return r.show(i, n),
  60936. r
  60937. }
  60938. ,
  60939. e.prototype.show = function(e, t) {
  60940. if (!this._renderFunction && this.ray) {
  60941. var i = this.ray;
  60942. this._renderFunction = this._render.bind(this),
  60943. this._scene = e,
  60944. this._renderPoints = [i.origin, i.origin.add(i.direction.scale(i.length))],
  60945. this._renderLine = Jl("ray", {
  60946. points: this._renderPoints,
  60947. updatable: !0
  60948. }, e),
  60949. this._renderLine.isPickable = !1,
  60950. this._renderFunction && this._scene.registerBeforeRender(this._renderFunction)
  60951. }
  60952. t && this._renderLine && this._renderLine.color.copyFrom(t)
  60953. }
  60954. ,
  60955. e.prototype.hide = function() {
  60956. this._renderFunction && this._scene && (this._scene.unregisterBeforeRender(this._renderFunction),
  60957. this._scene = null,
  60958. this._renderFunction = null,
  60959. this._renderLine && (this._renderLine.dispose(),
  60960. this._renderLine = null),
  60961. this._renderPoints = [])
  60962. }
  60963. ,
  60964. e.prototype._render = function() {
  60965. var e, t = this.ray;
  60966. if (t) {
  60967. var i = this._renderPoints[1]
  60968. , n = Math.min(t.length, 1e6);
  60969. i.copyFrom(t.direction),
  60970. i.scaleInPlace(n),
  60971. i.addInPlace(t.origin),
  60972. this._renderPoints[0].copyFrom(t.origin),
  60973. Jl("ray", {
  60974. points: this._renderPoints,
  60975. updatable: !0,
  60976. instance: this._renderLine
  60977. }, this._scene),
  60978. null === (e = this._renderLine) || void 0 === e || e.refreshBoundingInfo()
  60979. }
  60980. }
  60981. ,
  60982. e.prototype.attachToMesh = function(e, t, i, n) {
  60983. var r = this;
  60984. this._attachedToMesh = e;
  60985. var o = this.ray;
  60986. o && (o.direction || (o.direction = x.Zero()),
  60987. o.origin || (o.origin = x.Zero()),
  60988. n && (o.length = n),
  60989. i || (i = x.Zero()),
  60990. t || (t = new x(0,0,-1)),
  60991. this._scene || (this._scene = e.getScene()),
  60992. this._meshSpaceDirection ? (this._meshSpaceDirection.copyFrom(t),
  60993. this._meshSpaceOrigin.copyFrom(i)) : (this._meshSpaceDirection = t.clone(),
  60994. this._meshSpaceOrigin = i.clone()),
  60995. this._onAfterRenderObserver || (this._onAfterRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
  60996. return r._updateToMesh()
  60997. }
  60998. )),
  60999. this._onAfterStepObserver = this._scene.onAfterStepObservable.add((function() {
  61000. return r._updateToMesh()
  61001. }
  61002. ))),
  61003. this._attachedToMesh.computeWorldMatrix(!0),
  61004. this._updateToMesh())
  61005. }
  61006. ,
  61007. e.prototype.detachFromMesh = function() {
  61008. this._attachedToMesh && this._scene && (this._onAfterRenderObserver && (this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver),
  61009. this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)),
  61010. this._attachedToMesh = null,
  61011. this._onAfterRenderObserver = null,
  61012. this._onAfterStepObserver = null,
  61013. this._scene = null)
  61014. }
  61015. ,
  61016. e.prototype._updateToMesh = function() {
  61017. var e = this.ray;
  61018. this._attachedToMesh && e && (this._attachedToMesh.isDisposed() ? this.detachFromMesh() : (this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, e.direction),
  61019. x.TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), e.origin)))
  61020. }
  61021. ,
  61022. e.prototype.dispose = function() {
  61023. this.hide(),
  61024. this.detachFromMesh(),
  61025. this.ray = null
  61026. }
  61027. ,
  61028. e
  61029. }();
  61030. function ic(e) {
  61031. var t = e.pathArray
  61032. , i = e.closeArray || !1
  61033. , n = e.closePath || !1
  61034. , r = e.invertUV || !1
  61035. , o = Math.floor(t[0].length / 2)
  61036. , a = e.offset || o;
  61037. a = a > o ? o : Math.floor(a);
  61038. var s, l, c, u, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = e.uvs, p = e.colors, f = [], _ = [], m = [], g = [], v = [], y = [], b = [], T = [], E = [], S = [];
  61039. if (t.length < 2) {
  61040. var A = []
  61041. , x = [];
  61042. for (c = 0; c < t[0].length - a; c++)
  61043. A.push(t[0][c]),
  61044. x.push(t[0][c + a]);
  61045. t = [A, x]
  61046. }
  61047. var R, C, P, M, I, O = 0, D = n ? 1 : 0;
  61048. for (s = t[0].length,
  61049. l = 0; l < t.length; l++) {
  61050. for (b[l] = 0,
  61051. v[l] = [0],
  61052. s = s < (C = (R = t[l]).length) ? s : C,
  61053. u = 0; u < C; )
  61054. f.push(R[u].x, R[u].y, R[u].z),
  61055. u > 0 && (P = R[u].subtract(R[u - 1]).length() + b[l],
  61056. v[l].push(P),
  61057. b[l] = P),
  61058. u++;
  61059. n && (u--,
  61060. f.push(R[0].x, R[0].y, R[0].z),
  61061. P = R[u].subtract(R[0]).length() + b[l],
  61062. v[l].push(P),
  61063. b[l] = P),
  61064. E[l] = C + D,
  61065. S[l] = O,
  61066. O += C + D
  61067. }
  61068. var N, L, F = null, w = null;
  61069. for (c = 0; c < s + D; c++) {
  61070. for (T[c] = 0,
  61071. y[c] = [0],
  61072. l = 0; l < t.length - 1; l++)
  61073. M = t[l],
  61074. I = t[l + 1],
  61075. c === s ? (F = M[0],
  61076. w = I[0]) : (F = M[c],
  61077. w = I[c]),
  61078. P = w.subtract(F).length() + T[c],
  61079. y[c].push(P),
  61080. T[c] = P;
  61081. i && w && F && (M = t[l],
  61082. I = t[0],
  61083. c === s && (w = I[0]),
  61084. P = w.subtract(F).length() + T[c],
  61085. T[c] = P)
  61086. }
  61087. if (d)
  61088. for (l = 0; l < d.length; l++)
  61089. g.push(d[l].x, pr.UseOpenGLOrientationForUV ? 1 - d[l].y : d[l].y);
  61090. else
  61091. for (l = 0; l < t.length; l++)
  61092. for (c = 0; c < s + D; c++)
  61093. N = 0 != b[l] ? v[l][c] / b[l] : 0,
  61094. L = 0 != T[c] ? y[c][l] / T[c] : 0,
  61095. r ? g.push(L, N) : g.push(N, pr.UseOpenGLOrientationForUV ? 1 - L : L);
  61096. for (var B = 0, U = E[l = 0] - 1, V = E[l + 1] - 1, k = U < V ? U : V, G = S[1] - S[0], z = i ? E.length : E.length - 1; B <= k && l < z; )
  61097. _.push(B, B + G, B + 1),
  61098. _.push(B + G + 1, B + 1, B + G),
  61099. (B += 1) === k && (++l == E.length - 1 ? (G = S[0] - S[l],
  61100. U = E[l] - 1,
  61101. V = E[0] - 1) : (G = S[l + 1] - S[l],
  61102. U = E[l] - 1,
  61103. V = E[l + 1] - 1),
  61104. B = S[l],
  61105. k = U < V ? U + B : V + B);
  61106. if ($n.ComputeNormals(f, _, m),
  61107. n) {
  61108. var W = 0
  61109. , H = 0;
  61110. for (l = 0; l < t.length; l++)
  61111. W = 3 * S[l],
  61112. H = l + 1 < t.length ? 3 * (S[l + 1] - 1) : m.length - 3,
  61113. m[W] = .5 * (m[W] + m[H]),
  61114. m[W + 1] = .5 * (m[W + 1] + m[H + 1]),
  61115. m[W + 2] = .5 * (m[W + 2] + m[H + 2]),
  61116. m[H] = m[W],
  61117. m[H + 1] = m[W + 1],
  61118. m[H + 2] = m[W + 2]
  61119. }
  61120. $n._ComputeSides(h, f, _, m, g, e.frontUVs, e.backUVs);
  61121. var X = null;
  61122. if (p) {
  61123. X = new Float32Array(4 * p.length);
  61124. for (var j = 0; j < p.length; j++)
  61125. X[4 * j] = p[j].r,
  61126. X[4 * j + 1] = p[j].g,
  61127. X[4 * j + 2] = p[j].b,
  61128. X[4 * j + 3] = p[j].a
  61129. }
  61130. var Y = new $n
  61131. , K = new Float32Array(f)
  61132. , Q = new Float32Array(m)
  61133. , q = new Float32Array(g);
  61134. return Y.indices = _,
  61135. Y.positions = K,
  61136. Y.normals = Q,
  61137. Y.uvs = q,
  61138. X && Y.set(X, Bi.ColorKind),
  61139. n && (Y._idx = S),
  61140. Y
  61141. }
  61142. function nc(e, t, i) {
  61143. void 0 === i && (i = null);
  61144. var n = t.pathArray
  61145. , r = t.closeArray
  61146. , o = t.closePath
  61147. , a = Vr._GetDefaultSideOrientation(t.sideOrientation)
  61148. , s = t.instance
  61149. , l = t.updatable;
  61150. if (s) {
  61151. var c = I.Vector3[0].setAll(Number.MAX_VALUE)
  61152. , u = I.Vector3[1].setAll(-Number.MAX_VALUE)
  61153. , h = s.getVerticesData(Bi.PositionKind);
  61154. if (function(e) {
  61155. for (var t = n[0].length, i = s, r = 0, o = i._originalBuilderSideOrientation === Vr.DOUBLESIDE ? 2 : 1, a = 1; a <= o; ++a)
  61156. for (var l = 0; l < n.length; ++l) {
  61157. var h = n[l]
  61158. , d = h.length;
  61159. t = t < d ? t : d;
  61160. for (var p = 0; p < t; ++p) {
  61161. var f = h[p];
  61162. e[r] = f.x,
  61163. e[r + 1] = f.y,
  61164. e[r + 2] = f.z,
  61165. c.minimizeInPlaceFromFloats(f.x, f.y, f.z),
  61166. u.maximizeInPlaceFromFloats(f.x, f.y, f.z),
  61167. r += 3
  61168. }
  61169. i._creationDataStorage && i._creationDataStorage.closePath && (f = h[0],
  61170. e[r] = f.x,
  61171. e[r + 1] = f.y,
  61172. e[r + 2] = f.z,
  61173. r += 3)
  61174. }
  61175. }(h),
  61176. s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(c, u, s._worldMatrix) : s.buildBoundingInfo(c, u, s._worldMatrix),
  61177. s.updateVerticesData(Bi.PositionKind, h, !1, !1),
  61178. t.colors) {
  61179. for (var d = s.getVerticesData(Bi.ColorKind), p = 0, f = 0; p < t.colors.length; p++,
  61180. f += 4) {
  61181. var _ = t.colors[p];
  61182. d[f] = _.r,
  61183. d[f + 1] = _.g,
  61184. d[f + 2] = _.b,
  61185. d[f + 3] = _.a
  61186. }
  61187. s.updateVerticesData(Bi.ColorKind, d, !1, !1)
  61188. }
  61189. if (t.uvs) {
  61190. for (var m = s.getVerticesData(Bi.UVKind), g = 0; g < t.uvs.length; g++)
  61191. m[2 * g] = t.uvs[g].x,
  61192. m[2 * g + 1] = pr.UseOpenGLOrientationForUV ? 1 - t.uvs[g].y : t.uvs[g].y;
  61193. s.updateVerticesData(Bi.UVKind, m, !1, !1)
  61194. }
  61195. if (!s.areNormalsFrozen || s.isFacetDataEnabled) {
  61196. var v = s.getIndices()
  61197. , y = s.getVerticesData(Bi.NormalKind)
  61198. , b = s.isFacetDataEnabled ? s.getFacetDataParameters() : null;
  61199. if ($n.ComputeNormals(h, v, y, b),
  61200. s._creationDataStorage && s._creationDataStorage.closePath)
  61201. for (var T = 0, E = 0, S = 0; S < n.length; S++)
  61202. T = 3 * s._creationDataStorage.idx[S],
  61203. E = S + 1 < n.length ? 3 * (s._creationDataStorage.idx[S + 1] - 1) : y.length - 3,
  61204. y[T] = .5 * (y[T] + y[E]),
  61205. y[T + 1] = .5 * (y[T + 1] + y[E + 1]),
  61206. y[T + 2] = .5 * (y[T + 2] + y[E + 2]),
  61207. y[E] = y[T],
  61208. y[E + 1] = y[T + 1],
  61209. y[E + 2] = y[T + 2];
  61210. s.areNormalsFrozen || s.updateVerticesData(Bi.NormalKind, y, !1, !1)
  61211. }
  61212. return s
  61213. }
  61214. var A = new Vr(e,i);
  61215. A._originalBuilderSideOrientation = a,
  61216. A._creationDataStorage = new Lr;
  61217. var x = ic(t);
  61218. return o && (A._creationDataStorage.idx = x._idx),
  61219. A._creationDataStorage.closePath = o,
  61220. A._creationDataStorage.closeArray = r,
  61221. x.applyToMesh(A, l),
  61222. A
  61223. }
  61224. var rc = {
  61225. CreateRibbon: nc
  61226. };
  61227. function oc(e, t, i) {
  61228. void 0 === i && (i = null);
  61229. var n = t.path
  61230. , r = t.shape
  61231. , o = t.scale || 1
  61232. , a = t.rotation || 0
  61233. , s = 0 === t.cap ? 0 : t.cap || Vr.NO_CAP
  61234. , l = t.updatable
  61235. , c = Vr._GetDefaultSideOrientation(t.sideOrientation)
  61236. , u = t.instance || null
  61237. , h = t.invertUV || !1
  61238. , d = t.closeShape || !1;
  61239. return sc(e, r, n, o, a, null, null, t.closePath || !1, d, s, !1, i, !!l, c, u, h, t.frontUVs || null, t.backUVs || null)
  61240. }
  61241. function ac(e, t, i) {
  61242. void 0 === i && (i = null);
  61243. var n = t.path;
  61244. return sc(e, t.shape, n, null, null, t.scaleFunction || function() {
  61245. return 1
  61246. }
  61247. , t.rotationFunction || function() {
  61248. return 0
  61249. }
  61250. , t.closePath || t.ribbonCloseArray || !1, t.closeShape || t.ribbonClosePath || !1, 0 === t.cap ? 0 : t.cap || Vr.NO_CAP, !0, i, !!t.updatable, Vr._GetDefaultSideOrientation(t.sideOrientation), t.instance || null, t.invertUV || !1, t.frontUVs || null, t.backUVs || null)
  61251. }
  61252. function sc(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g) {
  61253. var v, y, b = function(e, t, i, n, r, o, a, s, l, c) {
  61254. for (var u = i.getTangents(), h = i.getNormals(), d = i.getBinormals(), p = i.getDistances(), f = 0, _ = c && s ? s : function() {
  61255. return null !== o ? o : 0
  61256. }
  61257. , m = c && a ? a : function() {
  61258. return null !== r ? r : 1
  61259. }
  61260. , g = l === Vr.NO_CAP || l === Vr.CAP_END ? 0 : 2, v = I.Matrix[0], y = 0; y < t.length; y++) {
  61261. for (var b = new Array, T = _(y, p[y]), E = m(y, p[y]), S = 0; S < e.length; S++) {
  61262. P.RotationAxisToRef(u[y], f, v);
  61263. var A = u[y].scale(e[S].z).add(h[y].scale(e[S].x)).add(d[y].scale(e[S].y))
  61264. , R = b[S] ? b[S] : x.Zero();
  61265. x.TransformCoordinatesToRef(A, v, R),
  61266. R.scaleInPlace(E).addInPlace(t[y]),
  61267. b[S] = R
  61268. }
  61269. n[g] = b,
  61270. f += T,
  61271. g++
  61272. }
  61273. var C = function(e) {
  61274. var t, i = Array(), n = x.Zero();
  61275. for (t = 0; t < e.length; t++)
  61276. n.addInPlace(e[t]);
  61277. for (n.scaleInPlace(1 / e.length),
  61278. t = 0; t < e.length; t++)
  61279. i.push(n);
  61280. return i
  61281. };
  61282. switch (l) {
  61283. case Vr.NO_CAP:
  61284. break;
  61285. case Vr.CAP_START:
  61286. n[0] = C(n[2]),
  61287. n[1] = n[2];
  61288. break;
  61289. case Vr.CAP_END:
  61290. n[g] = n[g - 1],
  61291. n[g + 1] = C(n[g - 1]);
  61292. break;
  61293. case Vr.CAP_ALL:
  61294. n[0] = C(n[2]),
  61295. n[1] = n[2],
  61296. n[g] = n[g - 1],
  61297. n[g + 1] = C(n[g - 1])
  61298. }
  61299. return n
  61300. };
  61301. if (f) {
  61302. var T = f._creationDataStorage;
  61303. return v = T.path3D.update(i),
  61304. nc("", {
  61305. pathArray: y = b(t, i, T.path3D, T.pathArray, n, r, o, a, T.cap, u),
  61306. closeArray: !1,
  61307. closePath: !1,
  61308. offset: 0,
  61309. updatable: !1,
  61310. sideOrientation: 0,
  61311. instance: f
  61312. }, h || void 0)
  61313. }
  61314. c = c < 0 || c > 3 ? 0 : c;
  61315. var E = nc(e, {
  61316. pathArray: y = b(t, i, v = new Cn(i), new Array, n, r, o, a, c, u),
  61317. closeArray: s,
  61318. closePath: l,
  61319. updatable: d,
  61320. sideOrientation: p,
  61321. invertUV: _,
  61322. frontUVs: m || void 0,
  61323. backUVs: g || void 0
  61324. }, h);
  61325. return E._creationDataStorage.pathArray = y,
  61326. E._creationDataStorage.path3D = v,
  61327. E._creationDataStorage.cap = c,
  61328. E
  61329. }
  61330. $n.CreateRibbon = ic,
  61331. Vr.CreateRibbon = function(e, t, i, n, r, o, a, s, l) {
  61332. return void 0 === i && (i = !1),
  61333. void 0 === a && (a = !1),
  61334. nc(e, {
  61335. pathArray: t,
  61336. closeArray: i,
  61337. closePath: n,
  61338. offset: r,
  61339. updatable: a,
  61340. sideOrientation: s,
  61341. instance: l
  61342. }, o)
  61343. }
  61344. ;
  61345. var lc = {
  61346. ExtrudeShape: oc,
  61347. ExtrudeShapeCustom: ac
  61348. };
  61349. Vr.ExtrudeShape = function(e, t, i, n, r, o, a, s, l, c) {
  61350. return void 0 === a && (a = null),
  61351. oc(e, {
  61352. shape: t,
  61353. path: i,
  61354. scale: n,
  61355. rotation: r,
  61356. cap: 0 === o ? 0 : o || Vr.NO_CAP,
  61357. sideOrientation: l,
  61358. instance: c,
  61359. updatable: s
  61360. }, a)
  61361. }
  61362. ,
  61363. Vr.ExtrudeShapeCustom = function(e, t, i, n, r, o, a, s, l, c, u, h) {
  61364. return ac(e, {
  61365. shape: t,
  61366. path: i,
  61367. scaleFunction: n,
  61368. rotationFunction: r,
  61369. ribbonCloseArray: o,
  61370. ribbonClosePath: a,
  61371. cap: 0 === s ? 0 : s || Vr.NO_CAP,
  61372. sideOrientation: u,
  61373. instance: h,
  61374. updatable: c
  61375. }, l)
  61376. }
  61377. ;
  61378. var cc = function() {
  61379. function e(t, i, n, r, o, a) {
  61380. var s, l, c, u, h, d, p, f, _, m, g, v, y, b;
  61381. void 0 === r && (r = !0),
  61382. void 0 === o && (o = 3),
  61383. void 0 === a && (a = {}),
  61384. this.skeleton = t,
  61385. this.mesh = i,
  61386. this.autoUpdateBonesMatrices = r,
  61387. this.renderingGroupId = o,
  61388. this.options = a,
  61389. this.color = D.White(),
  61390. this._debugLines = new Array,
  61391. this._localAxes = null,
  61392. this._isEnabled = !0,
  61393. this._obs = null,
  61394. this._scene = n,
  61395. this._ready = !1,
  61396. a.pauseAnimations = null === (s = a.pauseAnimations) || void 0 === s || s,
  61397. a.returnToRest = null !== (l = a.returnToRest) && void 0 !== l && l,
  61398. a.displayMode = null !== (c = a.displayMode) && void 0 !== c ? c : e.DISPLAY_LINES,
  61399. a.displayOptions = null !== (u = a.displayOptions) && void 0 !== u ? u : {},
  61400. a.displayOptions.midStep = null !== (h = a.displayOptions.midStep) && void 0 !== h ? h : .235,
  61401. a.displayOptions.midStepFactor = null !== (d = a.displayOptions.midStepFactor) && void 0 !== d ? d : .155,
  61402. a.displayOptions.sphereBaseSize = null !== (p = a.displayOptions.sphereBaseSize) && void 0 !== p ? p : .15,
  61403. a.displayOptions.sphereScaleUnit = null !== (f = a.displayOptions.sphereScaleUnit) && void 0 !== f ? f : 2,
  61404. a.displayOptions.sphereFactor = null !== (_ = a.displayOptions.sphereFactor) && void 0 !== _ ? _ : .865,
  61405. a.displayOptions.spurFollowsChild = null !== (m = a.displayOptions.spurFollowsChild) && void 0 !== m && m,
  61406. a.displayOptions.showLocalAxes = null !== (g = a.displayOptions.showLocalAxes) && void 0 !== g && g,
  61407. a.displayOptions.localAxesSize = null !== (v = a.displayOptions.localAxesSize) && void 0 !== v ? v : .075,
  61408. a.computeBonesUsingShaders = null === (y = a.computeBonesUsingShaders) || void 0 === y || y,
  61409. a.useAllBones = null === (b = a.useAllBones) || void 0 === b || b;
  61410. var T = i.getVerticesData(Bi.MatricesIndicesKind)
  61411. , E = i.getVerticesData(Bi.MatricesWeightsKind);
  61412. if (this._boneIndices = new Set,
  61413. !a.useAllBones && T && E)
  61414. for (var S = 0; S < T.length; ++S) {
  61415. var A = T[S];
  61416. 0 !== E[S] && this._boneIndices.add(A)
  61417. }
  61418. this._utilityLayer = new El(this._scene,!1),
  61419. this._utilityLayer.pickUtilitySceneFirst = !1,
  61420. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
  61421. var x = this.options.displayMode || 0;
  61422. x > e.DISPLAY_SPHERE_AND_SPURS && (x = e.DISPLAY_LINES),
  61423. this.displayMode = x,
  61424. this.update(),
  61425. this._bindObs()
  61426. }
  61427. return e.CreateBoneWeightShader = function(e, t) {
  61428. var i, n, r, o, a, s, l = e.skeleton, c = null !== (i = e.colorBase) && void 0 !== i ? i : D.Black(), u = null !== (n = e.colorZero) && void 0 !== n ? n : D.Blue(), h = null !== (r = e.colorQuarter) && void 0 !== r ? r : D.Green(), d = null !== (o = e.colorHalf) && void 0 !== o ? o : D.Yellow(), p = null !== (a = e.colorFull) && void 0 !== a ? a : D.Red(), f = null !== (s = e.targetBoneIndex) && void 0 !== s ? s : 0;
  61429. Mt.ShadersStore["boneWeights:" + l.name + "VertexShader"] = "precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include<bakedVertexAnimationDeclaration>\n\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n uniform vec3 colorBase;\n uniform vec3 colorZero;\n uniform vec3 colorQuarter;\n uniform vec3 colorHalf;\n uniform vec3 colorFull;\n\n uniform float targetBoneIndex;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n #include<bakedVertexAnimation>\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n vec3 color = colorBase;\n float totalWeight = 0.;\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\n totalWeight += matricesWeights[0];\n }\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\n totalWeight += matricesWeights[1];\n }\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\n totalWeight += matricesWeights[2];\n }\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\n totalWeight += matricesWeights[3];\n }\n\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\n vColor = color;\n\n gl_Position = projection * view * worldPos;\n }",
  61430. Mt.ShadersStore["boneWeights:" + l.name + "FragmentShader"] = "\n precision highp float;\n varying vec3 vPosition;\n\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4(vColor, 1.0);\n gl_FragColor = color;\n }\n ";
  61431. var _ = new jl("boneWeight:" + l.name,t,{
  61432. vertex: "boneWeights:" + l.name,
  61433. fragment: "boneWeights:" + l.name
  61434. },{
  61435. attributes: ["position", "normal", "matricesIndices", "matricesWeights"],
  61436. uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorBase", "colorZero", "colorQuarter", "colorHalf", "colorFull", "targetBoneIndex"]
  61437. });
  61438. return _.setColor3("colorBase", c),
  61439. _.setColor3("colorZero", u),
  61440. _.setColor3("colorQuarter", h),
  61441. _.setColor3("colorHalf", d),
  61442. _.setColor3("colorFull", p),
  61443. _.setFloat("targetBoneIndex", f),
  61444. _.getClassName = function() {
  61445. return "BoneWeightShader"
  61446. }
  61447. ,
  61448. _.transparencyMode = Or.MATERIAL_OPAQUE,
  61449. _
  61450. }
  61451. ,
  61452. e.CreateSkeletonMapShader = function(t, i) {
  61453. var n, r = t.skeleton, o = null !== (n = t.colorMap) && void 0 !== n ? n : [{
  61454. color: new D(1,.38,.18),
  61455. location: 0
  61456. }, {
  61457. color: new D(.59,.18,1),
  61458. location: .2
  61459. }, {
  61460. color: new D(.59,1,.18),
  61461. location: .4
  61462. }, {
  61463. color: new D(1,.87,.17),
  61464. location: .6
  61465. }, {
  61466. color: new D(1,.17,.42),
  61467. location: .8
  61468. }, {
  61469. color: new D(.17,.68,1),
  61470. location: 1
  61471. }], a = r.bones.length + 1, s = e._CreateBoneMapColorBuffer(a, o, i), l = new jl("boneWeights:" + r.name,i,{
  61472. vertexSource: "precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n uniform float colorMap[" + 4 * r.bones.length + "];\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include<bakedVertexAnimationDeclaration>\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n #include<bakedVertexAnimation>\n\n vec3 color = vec3(0.);\n bool first = true;\n\n for (int i = 0; i < 4; i++) {\n int boneIdx = int(matricesIndices[i]);\n float boneWgt = matricesWeights[i];\n\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\n\n if (boneWgt > 0.) {\n if (first) {\n first = false;\n color = c;\n } else {\n color = mix(color, c, boneWgt);\n }\n }\n }\n\n vColor = color;\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n gl_Position = projection * view * worldPos;\n }",
  61473. fragmentSource: "\n precision highp float;\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4( vColor, 1.0 );\n gl_FragColor = color;\n }\n "
  61474. },{
  61475. attributes: ["position", "normal", "matricesIndices", "matricesWeights"],
  61476. uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorMap"]
  61477. });
  61478. return l.setFloats("colorMap", s),
  61479. l.getClassName = function() {
  61480. return "SkeletonMapShader"
  61481. }
  61482. ,
  61483. l.transparencyMode = Or.MATERIAL_OPAQUE,
  61484. l
  61485. }
  61486. ,
  61487. e._CreateBoneMapColorBuffer = function(e, t, i) {
  61488. var n = new Ds("temp",{
  61489. width: e,
  61490. height: 1
  61491. },i,!1)
  61492. , r = n.getContext()
  61493. , o = r.createLinearGradient(0, 0, e, 0);
  61494. t.forEach((function(e) {
  61495. o.addColorStop(e.location, e.color.toHexString())
  61496. }
  61497. )),
  61498. r.fillStyle = o,
  61499. r.fillRect(0, 0, e, 1),
  61500. n.update();
  61501. for (var a = [], s = r.getImageData(0, 0, e, 1).data, l = 0; l < s.length; l++)
  61502. a.push(.00392156862745098 * s[l]);
  61503. return n.dispose(),
  61504. a
  61505. }
  61506. ,
  61507. Object.defineProperty(e.prototype, "scene", {
  61508. get: function() {
  61509. return this._scene
  61510. },
  61511. enumerable: !1,
  61512. configurable: !0
  61513. }),
  61514. Object.defineProperty(e.prototype, "utilityLayer", {
  61515. get: function() {
  61516. return this._utilityLayer
  61517. },
  61518. enumerable: !1,
  61519. configurable: !0
  61520. }),
  61521. Object.defineProperty(e.prototype, "isReady", {
  61522. get: function() {
  61523. return this._ready
  61524. },
  61525. enumerable: !1,
  61526. configurable: !0
  61527. }),
  61528. Object.defineProperty(e.prototype, "ready", {
  61529. set: function(e) {
  61530. this._ready = e
  61531. },
  61532. enumerable: !1,
  61533. configurable: !0
  61534. }),
  61535. Object.defineProperty(e.prototype, "debugMesh", {
  61536. get: function() {
  61537. return this._debugMesh
  61538. },
  61539. set: function(e) {
  61540. this._debugMesh = e
  61541. },
  61542. enumerable: !1,
  61543. configurable: !0
  61544. }),
  61545. Object.defineProperty(e.prototype, "displayMode", {
  61546. get: function() {
  61547. return this.options.displayMode || e.DISPLAY_LINES
  61548. },
  61549. set: function(t) {
  61550. t > e.DISPLAY_SPHERE_AND_SPURS && (t = e.DISPLAY_LINES),
  61551. this.options.displayMode = t
  61552. },
  61553. enumerable: !1,
  61554. configurable: !0
  61555. }),
  61556. e.prototype._bindObs = function() {
  61557. var t = this;
  61558. this.displayMode === e.DISPLAY_LINES && (this._obs = this.scene.onBeforeRenderObservable.add((function() {
  61559. t._displayLinesUpdate()
  61560. }
  61561. )))
  61562. }
  61563. ,
  61564. e.prototype.update = function() {
  61565. switch (this.displayMode) {
  61566. case e.DISPLAY_LINES:
  61567. this._displayLinesUpdate();
  61568. break;
  61569. case e.DISPLAY_SPHERES:
  61570. this._buildSpheresAndSpurs(!0);
  61571. break;
  61572. case e.DISPLAY_SPHERE_AND_SPURS:
  61573. this._buildSpheresAndSpurs(!1)
  61574. }
  61575. this._buildLocalAxes()
  61576. }
  61577. ,
  61578. Object.defineProperty(e.prototype, "isEnabled", {
  61579. get: function() {
  61580. return this._isEnabled
  61581. },
  61582. set: function(e) {
  61583. this.isEnabled !== e && (this._isEnabled = e,
  61584. this.debugMesh && this.debugMesh.setEnabled(e),
  61585. e && !this._obs ? this._bindObs() : !e && this._obs && (this.scene.onBeforeRenderObservable.remove(this._obs),
  61586. this._obs = null))
  61587. },
  61588. enumerable: !1,
  61589. configurable: !0
  61590. }),
  61591. e.prototype._getBonePosition = function(e, t, i, n, r, o) {
  61592. void 0 === n && (n = 0),
  61593. void 0 === r && (r = 0),
  61594. void 0 === o && (o = 0);
  61595. var a = I.Matrix[0]
  61596. , s = t.getParent();
  61597. if (a.copyFrom(t.getLocalMatrix()),
  61598. 0 !== n || 0 !== r || 0 !== o) {
  61599. var l = I.Matrix[1];
  61600. P.IdentityToRef(l),
  61601. l.setTranslationFromFloats(n, r, o),
  61602. l.multiplyToRef(a, a)
  61603. }
  61604. s && a.multiplyToRef(s.getAbsoluteTransform(), a),
  61605. a.multiplyToRef(i, a),
  61606. e.x = a.m[12],
  61607. e.y = a.m[13],
  61608. e.z = a.m[14]
  61609. }
  61610. ,
  61611. e.prototype._getLinesForBonesWithLength = function(e, t) {
  61612. for (var i = e.length, n = this.mesh.position, r = 0, o = 0; o < i; o++) {
  61613. var a = e[o]
  61614. , s = this._debugLines[r];
  61615. -1 !== a._index && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones) && (s || (s = [x.Zero(), x.Zero()],
  61616. this._debugLines[r] = s),
  61617. this._getBonePosition(s[0], a, t),
  61618. this._getBonePosition(s[1], a, t, 0, a.length, 0),
  61619. s[0].subtractInPlace(n),
  61620. s[1].subtractInPlace(n),
  61621. r++)
  61622. }
  61623. }
  61624. ,
  61625. e.prototype._getLinesForBonesNoLength = function(e) {
  61626. for (var t = e.length, i = 0, n = this.mesh, r = n.position, o = t - 1; o >= 0; o--) {
  61627. var a = e[o]
  61628. , s = a.getParent();
  61629. if (s && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones)) {
  61630. var l = this._debugLines[i];
  61631. l || (l = [x.Zero(), x.Zero()],
  61632. this._debugLines[i] = l),
  61633. a.getAbsolutePositionToRef(n, l[0]),
  61634. s.getAbsolutePositionToRef(n, l[1]),
  61635. l[0].subtractInPlace(r),
  61636. l[1].subtractInPlace(r),
  61637. i++
  61638. }
  61639. }
  61640. }
  61641. ,
  61642. e.prototype._revert = function(e) {
  61643. this.options.pauseAnimations && (this.scene.animationsEnabled = e,
  61644. this.utilityLayer.utilityLayerScene.animationsEnabled = e)
  61645. }
  61646. ,
  61647. e.prototype._getAbsoluteBindPoseToRef = function(e, t) {
  61648. null !== e && -1 !== e._index ? (this._getAbsoluteBindPoseToRef(e.getParent(), t),
  61649. e.getBaseMatrix().multiplyToRef(t, t)) : t.copyFrom(P.Identity())
  61650. }
  61651. ,
  61652. e.prototype._buildSpheresAndSpurs = function(e) {
  61653. var t, i;
  61654. void 0 === e && (e = !0),
  61655. this._debugMesh && (this._debugMesh.dispose(),
  61656. this._debugMesh = null,
  61657. this.ready = !1),
  61658. this._ready = !1;
  61659. var n = null === (t = this.utilityLayer) || void 0 === t ? void 0 : t.utilityLayerScene
  61660. , r = this.skeleton.bones
  61661. , o = []
  61662. , a = []
  61663. , s = this.scene.animationsEnabled;
  61664. try {
  61665. this.options.pauseAnimations && (this.scene.animationsEnabled = !1,
  61666. n.animationsEnabled = !1),
  61667. this.options.returnToRest && this.skeleton.returnToRest(),
  61668. this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms();
  61669. for (var l = Number.NEGATIVE_INFINITY, c = this.options.displayOptions || {}, u = function(t) {
  61670. var i = r[t];
  61671. if (-1 === i._index || !h._boneIndices.has(i.getIndex()) && !h.options.useAllBones)
  61672. return "continue";
  61673. var s = new P;
  61674. h._getAbsoluteBindPoseToRef(i, s);
  61675. var u = new x;
  61676. s.decompose(void 0, void 0, u),
  61677. i.children.forEach((function(t) {
  61678. var r = new P;
  61679. t.getBaseMatrix().multiplyToRef(s, r);
  61680. var o = new x;
  61681. r.decompose(void 0, void 0, o);
  61682. var h = x.Distance(u, o);
  61683. if (h > l && (l = h),
  61684. !e) {
  61685. for (var d = o.clone().subtract(u.clone()), p = d.length(), f = d.normalize().scale(p), _ = c.midStep || .165, m = c.midStepFactor || .215, g = f.scale(_), v = ac("skeletonViewer", {
  61686. shape: [new x(1,-1,0), new x(1,1,0), new x(-1,1,0), new x(-1,-1,0), new x(1,-1,0)],
  61687. path: [x.Zero(), g, f],
  61688. scaleFunction: function(e) {
  61689. switch (e) {
  61690. case 0:
  61691. case 2:
  61692. return 0;
  61693. case 1:
  61694. return p * m
  61695. }
  61696. return 0
  61697. },
  61698. sideOrientation: Vr.DEFAULTSIDE,
  61699. updatable: !1
  61700. }, n), y = v.getTotalVertices(), b = [], T = [], E = 0; E < y; E++)
  61701. b.push(1, 0, 0, 0),
  61702. c.spurFollowsChild && E > 9 ? T.push(t.getIndex(), 0, 0, 0) : T.push(i.getIndex(), 0, 0, 0);
  61703. v.position = u.clone(),
  61704. v.setVerticesData(Bi.MatricesWeightsKind, b, !1),
  61705. v.setVerticesData(Bi.MatricesIndicesKind, T, !1),
  61706. v.convertToFlatShadedMesh(),
  61707. a.push(v)
  61708. }
  61709. }
  61710. ));
  61711. for (var d = Dl("skeletonViewer", {
  61712. segments: 6,
  61713. diameter: c.sphereBaseSize || .2,
  61714. updatable: !0
  61715. }, n), p = d.getTotalVertices(), f = [], _ = [], m = 0; m < p; m++)
  61716. f.push(1, 0, 0, 0),
  61717. _.push(i.getIndex(), 0, 0, 0);
  61718. d.setVerticesData(Bi.MatricesWeightsKind, f, !1),
  61719. d.setVerticesData(Bi.MatricesIndicesKind, _, !1),
  61720. d.position = u.clone(),
  61721. o.push([d, i])
  61722. }, h = this, d = 0; d < r.length; d++)
  61723. u(d);
  61724. var p = c.sphereScaleUnit || 2
  61725. , f = c.sphereFactor || .85
  61726. , _ = [];
  61727. for (d = 0; d < o.length; d++) {
  61728. for (var m = o[d], g = m[0], v = m[1], y = 1 / (p / l), b = 0, T = v; T.getParent() && -1 !== T.getParent().getIndex(); )
  61729. b++,
  61730. T = T.getParent();
  61731. g.scaling.scaleInPlace(y * Math.pow(f, b)),
  61732. _.push(g)
  61733. }
  61734. this.debugMesh = Vr.MergeMeshes(_.concat(a), !0, !0),
  61735. this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId,
  61736. this.debugMesh.skeleton = this.skeleton,
  61737. this.debugMesh.parent = this.mesh,
  61738. this.debugMesh.computeBonesUsingShaders = null === (i = this.options.computeBonesUsingShaders) || void 0 === i || i,
  61739. this.debugMesh.alwaysSelectAsActiveMesh = !0),
  61740. this.utilityLayer._getSharedGizmoLight().intensity = .7,
  61741. this._revert(s),
  61742. this.ready = !0
  61743. } catch (e) {
  61744. console.error(e),
  61745. this._revert(s),
  61746. this.dispose()
  61747. }
  61748. }
  61749. ,
  61750. e.prototype._buildLocalAxes = function() {
  61751. var e;
  61752. this._localAxes && this._localAxes.dispose(),
  61753. this._localAxes = null;
  61754. var t = this.options.displayOptions || {};
  61755. if (t.showLocalAxes) {
  61756. var i = this._utilityLayer.utilityLayerScene
  61757. , n = t.localAxesSize || .075
  61758. , r = []
  61759. , o = []
  61760. , a = new N(1,0,0,1)
  61761. , s = new N(0,1,0,1)
  61762. , l = new N(0,0,1,1)
  61763. , c = []
  61764. , u = [];
  61765. for (var h in this.skeleton.bones) {
  61766. var d = this.skeleton.bones[h];
  61767. if (-1 !== d._index && (this._boneIndices.has(d.getIndex()) || this.options.useAllBones)) {
  61768. var p = new P
  61769. , f = new x;
  61770. this._getAbsoluteBindPoseToRef(d, p),
  61771. p.decompose(void 0, void 0, f);
  61772. var _ = d.getBaseMatrix().getRotationMatrix()
  61773. , m = x.TransformCoordinates(new x(0 + n,0,0), _)
  61774. , g = x.TransformCoordinates(new x(0,0 + n,0), _)
  61775. , v = x.TransformCoordinates(new x(0,0,0 + n), _)
  61776. , y = [[f, f.add(m)], [f, f.add(g)], [f, f.add(v)]]
  61777. , b = [[a, a], [s, s], [l, l]];
  61778. r.push.apply(r, y),
  61779. o.push.apply(o, b);
  61780. for (var T = 0; T < 6; T++)
  61781. c.push(1, 0, 0, 0),
  61782. u.push(d.getIndex(), 0, 0, 0)
  61783. }
  61784. }
  61785. this._localAxes = Zl("localAxes", {
  61786. lines: r,
  61787. colors: o,
  61788. updatable: !0
  61789. }, i),
  61790. this._localAxes.setVerticesData(Bi.MatricesWeightsKind, c, !1),
  61791. this._localAxes.setVerticesData(Bi.MatricesIndicesKind, u, !1),
  61792. this._localAxes.skeleton = this.skeleton,
  61793. this._localAxes.renderingGroupId = this.renderingGroupId,
  61794. this._localAxes.parent = this.mesh,
  61795. this._localAxes.computeBonesUsingShaders = null === (e = this.options.computeBonesUsingShaders) || void 0 === e || e
  61796. }
  61797. }
  61798. ,
  61799. e.prototype._displayLinesUpdate = function() {
  61800. if (this._utilityLayer) {
  61801. this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms(),
  61802. void 0 === this.skeleton.bones[0].length ? this._getLinesForBonesNoLength(this.skeleton.bones) : this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  61803. var e = this._utilityLayer.utilityLayerScene;
  61804. e && (this._debugMesh ? Zl("", {
  61805. lines: this._debugLines,
  61806. updatable: !0,
  61807. instance: this._debugMesh
  61808. }, e) : (this._debugMesh = Zl("", {
  61809. lines: this._debugLines,
  61810. updatable: !0,
  61811. instance: null
  61812. }, e),
  61813. this._debugMesh.renderingGroupId = this.renderingGroupId),
  61814. this._debugMesh.position.copyFrom(this.mesh.position),
  61815. this._debugMesh.color = this.color)
  61816. }
  61817. }
  61818. ,
  61819. e.prototype.changeDisplayMode = function(e) {
  61820. var t = !!this.isEnabled;
  61821. this.displayMode !== e && (this.isEnabled = !1,
  61822. this._debugMesh && (this._debugMesh.dispose(),
  61823. this._debugMesh = null,
  61824. this.ready = !1),
  61825. this.displayMode = e,
  61826. this.update(),
  61827. this._bindObs(),
  61828. this.isEnabled = t)
  61829. }
  61830. ,
  61831. e.prototype.changeDisplayOptions = function(e, t) {
  61832. var i = !!this.isEnabled;
  61833. this.options.displayOptions[e] = t,
  61834. this.isEnabled = !1,
  61835. this._debugMesh && (this._debugMesh.dispose(),
  61836. this._debugMesh = null,
  61837. this.ready = !1),
  61838. this.update(),
  61839. this._bindObs(),
  61840. this.isEnabled = i
  61841. }
  61842. ,
  61843. e.prototype.dispose = function() {
  61844. this.isEnabled = !1,
  61845. this._debugMesh && (this._debugMesh.dispose(),
  61846. this._debugMesh = null),
  61847. this._utilityLayer && (this._utilityLayer.dispose(),
  61848. this._utilityLayer = null),
  61849. this.ready = !1
  61850. }
  61851. ,
  61852. e.DISPLAY_LINES = 0,
  61853. e.DISPLAY_SPHERES = 1,
  61854. e.DISPLAY_SPHERE_AND_SPURS = 2,
  61855. e
  61856. }()
  61857. , uc = function() {
  61858. function e(e, t) {
  61859. this._oldPosition = new x(Number.NaN,Number.NaN,Number.NaN),
  61860. this._oldDirection = new x(Number.NaN,Number.NaN,Number.NaN),
  61861. this._transparency = .3,
  61862. this._showLines = !0,
  61863. this._showPlanes = !0,
  61864. this._scene = e.getScene(),
  61865. this._light = e,
  61866. this._camera = t,
  61867. this._inverseViewMatrix = P.Identity(),
  61868. this._lightHelperFrustumMeshes = [],
  61869. this._createGeometry(),
  61870. this.show(),
  61871. this.update()
  61872. }
  61873. return Object.defineProperty(e.prototype, "transparency", {
  61874. get: function() {
  61875. return this._transparency
  61876. },
  61877. set: function(e) {
  61878. this._transparency = e;
  61879. for (var t = 6; t < 12; ++t)
  61880. this._lightHelperFrustumMeshes[t].material.alpha = e
  61881. },
  61882. enumerable: !1,
  61883. configurable: !0
  61884. }),
  61885. Object.defineProperty(e.prototype, "showLines", {
  61886. get: function() {
  61887. return this._showLines
  61888. },
  61889. set: function(e) {
  61890. if (this._showLines !== e) {
  61891. this._showLines = e;
  61892. for (var t = 0; t < 6; ++t)
  61893. this._lightHelperFrustumMeshes[t].setEnabled(e)
  61894. }
  61895. },
  61896. enumerable: !1,
  61897. configurable: !0
  61898. }),
  61899. Object.defineProperty(e.prototype, "showPlanes", {
  61900. get: function() {
  61901. return this._showPlanes
  61902. },
  61903. set: function(e) {
  61904. if (this._showPlanes !== e) {
  61905. this._showPlanes = e;
  61906. for (var t = 6; t < 12; ++t)
  61907. this._lightHelperFrustumMeshes[t].setEnabled(e)
  61908. }
  61909. },
  61910. enumerable: !1,
  61911. configurable: !0
  61912. }),
  61913. e.prototype.show = function() {
  61914. var e = this;
  61915. this._lightHelperFrustumMeshes.forEach((function(t, i) {
  61916. t.setEnabled(i < 6 && e._showLines || i >= 6 && e._showPlanes)
  61917. }
  61918. )),
  61919. this._oldPosition.set(Number.NaN, Number.NaN, Number.NaN),
  61920. this._visible = !0
  61921. }
  61922. ,
  61923. e.prototype.hide = function() {
  61924. this._lightHelperFrustumMeshes.forEach((function(e) {
  61925. e.setEnabled(!1)
  61926. }
  61927. )),
  61928. this._visible = !1
  61929. }
  61930. ,
  61931. e.prototype.update = function() {
  61932. var e, t, i, n, r, o;
  61933. if (this._visible && (!this._oldPosition.equals(this._light.position) || !this._oldDirection.equals(this._light.direction) || this._oldAutoCalc !== this._light.autoCalcShadowZBounds || this._oldMinZ !== this._light.shadowMinZ || this._oldMaxZ !== this._light.shadowMaxZ)) {
  61934. this._oldPosition.copyFrom(this._light.position),
  61935. this._oldDirection.copyFrom(this._light.direction),
  61936. this._oldAutoCalc = this._light.autoCalcShadowZBounds,
  61937. this._oldMinZ = this._light.shadowMinZ,
  61938. this._oldMaxZ = this._light.shadowMaxZ,
  61939. I.Vector3[0].set(this._light.orthoLeft, this._light.orthoBottom, void 0 !== this._light.shadowMinZ ? this._light.shadowMinZ : this._camera.minZ),
  61940. I.Vector3[1].set(this._light.orthoRight, this._light.orthoTop, void 0 !== this._light.shadowMaxZ ? this._light.shadowMaxZ : this._camera.maxZ);
  61941. var a = this._getInvertViewMatrix();
  61942. I.Vector3[2].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[0].z),
  61943. I.Vector3[3].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[0].z),
  61944. I.Vector3[4].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z),
  61945. I.Vector3[5].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[0].z),
  61946. x.TransformCoordinatesToRef(I.Vector3[2], a, I.Vector3[2]),
  61947. x.TransformCoordinatesToRef(I.Vector3[3], a, I.Vector3[3]),
  61948. x.TransformCoordinatesToRef(I.Vector3[4], a, I.Vector3[4]),
  61949. x.TransformCoordinatesToRef(I.Vector3[5], a, I.Vector3[5]),
  61950. I.Vector3[6].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[1].z),
  61951. I.Vector3[7].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[1].z),
  61952. I.Vector3[8].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[1].z),
  61953. I.Vector3[9].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[1].z),
  61954. x.TransformCoordinatesToRef(I.Vector3[6], a, I.Vector3[6]),
  61955. x.TransformCoordinatesToRef(I.Vector3[7], a, I.Vector3[7]),
  61956. x.TransformCoordinatesToRef(I.Vector3[8], a, I.Vector3[8]),
  61957. x.TransformCoordinatesToRef(I.Vector3[9], a, I.Vector3[9]),
  61958. Jl("nearlines", {
  61959. updatable: !0,
  61960. points: this._nearLinesPoints,
  61961. instance: this._lightHelperFrustumMeshes[0]
  61962. }, this._scene),
  61963. Jl("farlines", {
  61964. updatable: !0,
  61965. points: this._farLinesPoints,
  61966. instance: this._lightHelperFrustumMeshes[1]
  61967. }, this._scene),
  61968. Jl("trlines", {
  61969. updatable: !0,
  61970. points: this._trLinesPoints,
  61971. instance: this._lightHelperFrustumMeshes[2]
  61972. }, this._scene),
  61973. Jl("brlines", {
  61974. updatable: !0,
  61975. points: this._brLinesPoints,
  61976. instance: this._lightHelperFrustumMeshes[3]
  61977. }, this._scene),
  61978. Jl("tllines", {
  61979. updatable: !0,
  61980. points: this._tlLinesPoints,
  61981. instance: this._lightHelperFrustumMeshes[4]
  61982. }, this._scene),
  61983. Jl("bllines", {
  61984. updatable: !0,
  61985. points: this._blLinesPoints,
  61986. instance: this._lightHelperFrustumMeshes[5]
  61987. }, this._scene),
  61988. I.Vector3[2].toArray(this._nearPlaneVertices, 0),
  61989. I.Vector3[3].toArray(this._nearPlaneVertices, 3),
  61990. I.Vector3[4].toArray(this._nearPlaneVertices, 6),
  61991. I.Vector3[5].toArray(this._nearPlaneVertices, 9),
  61992. null === (e = this._lightHelperFrustumMeshes[6].geometry) || void 0 === e || e.updateVerticesDataDirectly("position", this._nearPlaneVertices, 0),
  61993. I.Vector3[6].toArray(this._farPlaneVertices, 0),
  61994. I.Vector3[7].toArray(this._farPlaneVertices, 3),
  61995. I.Vector3[8].toArray(this._farPlaneVertices, 6),
  61996. I.Vector3[9].toArray(this._farPlaneVertices, 9),
  61997. null === (t = this._lightHelperFrustumMeshes[7].geometry) || void 0 === t || t.updateVerticesDataDirectly("position", this._farPlaneVertices, 0),
  61998. I.Vector3[2].toArray(this._rightPlaneVertices, 0),
  61999. I.Vector3[6].toArray(this._rightPlaneVertices, 3),
  62000. I.Vector3[7].toArray(this._rightPlaneVertices, 6),
  62001. I.Vector3[3].toArray(this._rightPlaneVertices, 9),
  62002. null === (i = this._lightHelperFrustumMeshes[8].geometry) || void 0 === i || i.updateVerticesDataDirectly("position", this._rightPlaneVertices, 0),
  62003. I.Vector3[5].toArray(this._leftPlaneVertices, 0),
  62004. I.Vector3[9].toArray(this._leftPlaneVertices, 3),
  62005. I.Vector3[8].toArray(this._leftPlaneVertices, 6),
  62006. I.Vector3[4].toArray(this._leftPlaneVertices, 9),
  62007. null === (n = this._lightHelperFrustumMeshes[9].geometry) || void 0 === n || n.updateVerticesDataDirectly("position", this._leftPlaneVertices, 0),
  62008. I.Vector3[2].toArray(this._topPlaneVertices, 0),
  62009. I.Vector3[6].toArray(this._topPlaneVertices, 3),
  62010. I.Vector3[9].toArray(this._topPlaneVertices, 6),
  62011. I.Vector3[5].toArray(this._topPlaneVertices, 9),
  62012. null === (r = this._lightHelperFrustumMeshes[10].geometry) || void 0 === r || r.updateVerticesDataDirectly("position", this._topPlaneVertices, 0),
  62013. I.Vector3[3].toArray(this._bottomPlaneVertices, 0),
  62014. I.Vector3[7].toArray(this._bottomPlaneVertices, 3),
  62015. I.Vector3[8].toArray(this._bottomPlaneVertices, 6),
  62016. I.Vector3[4].toArray(this._bottomPlaneVertices, 9),
  62017. null === (o = this._lightHelperFrustumMeshes[11].geometry) || void 0 === o || o.updateVerticesDataDirectly("position", this._bottomPlaneVertices, 0)
  62018. }
  62019. }
  62020. ,
  62021. e.prototype.dispose = function() {
  62022. this._lightHelperFrustumMeshes.forEach((function(e) {
  62023. var t;
  62024. null === (t = e.material) || void 0 === t || t.dispose(),
  62025. e.dispose()
  62026. }
  62027. )),
  62028. this._rootNode.dispose()
  62029. }
  62030. ,
  62031. e.prototype._createGeometry = function() {
  62032. var e = this;
  62033. this._rootNode = new yr("directionalLightHelperRoot_" + this._light.name,this._scene),
  62034. this._rootNode.parent = this._light.parent,
  62035. this._nearLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
  62036. var t = Jl("nearlines", {
  62037. updatable: !0,
  62038. points: this._nearLinesPoints
  62039. }, this._scene);
  62040. t.parent = this._rootNode,
  62041. t.alwaysSelectAsActiveMesh = !0,
  62042. this._farLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
  62043. var i = Jl("farlines", {
  62044. updatable: !0,
  62045. points: this._farLinesPoints
  62046. }, this._scene);
  62047. i.parent = this._rootNode,
  62048. i.alwaysSelectAsActiveMesh = !0,
  62049. this._trLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
  62050. var n = Jl("trlines", {
  62051. updatable: !0,
  62052. points: this._trLinesPoints
  62053. }, this._scene);
  62054. n.parent = this._rootNode,
  62055. n.alwaysSelectAsActiveMesh = !0,
  62056. this._brLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
  62057. var r = Jl("brlines", {
  62058. updatable: !0,
  62059. points: this._brLinesPoints
  62060. }, this._scene);
  62061. r.parent = this._rootNode,
  62062. r.alwaysSelectAsActiveMesh = !0,
  62063. this._tlLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
  62064. var o = Jl("tllines", {
  62065. updatable: !0,
  62066. points: this._tlLinesPoints
  62067. }, this._scene);
  62068. o.parent = this._rootNode,
  62069. o.alwaysSelectAsActiveMesh = !0,
  62070. this._blLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
  62071. var a = Jl("bllines", {
  62072. updatable: !0,
  62073. points: this._blLinesPoints
  62074. }, this._scene);
  62075. a.parent = this._rootNode,
  62076. a.alwaysSelectAsActiveMesh = !0,
  62077. this._lightHelperFrustumMeshes.push(t, i, n, r, o, a);
  62078. var s = function(t, i, n) {
  62079. var r = new Vr(t + "plane",e._scene)
  62080. , o = new Os(t + "PlaneMat",e._scene);
  62081. r.material = o,
  62082. r.parent = e._rootNode,
  62083. r.alwaysSelectAsActiveMesh = !0,
  62084. o.emissiveColor = i,
  62085. o.alpha = e.transparency,
  62086. o.backFaceCulling = !1,
  62087. o.disableLighting = !0;
  62088. var a = new $n;
  62089. a.positions = n,
  62090. a.indices = [0, 1, 2, 0, 2, 3],
  62091. a.applyToMesh(r, !0),
  62092. e._lightHelperFrustumMeshes.push(r)
  62093. };
  62094. this._nearPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62095. this._farPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62096. this._rightPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62097. this._leftPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62098. this._topPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62099. this._bottomPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  62100. s("near", new D(1,0,0), this._nearPlaneVertices),
  62101. s("far", new D(.3,0,0), this._farPlaneVertices),
  62102. s("right", new D(0,1,0), this._rightPlaneVertices),
  62103. s("left", new D(0,.3,0), this._leftPlaneVertices),
  62104. s("top", new D(0,0,1), this._topPlaneVertices),
  62105. s("bottom", new D(0,0,.3), this._bottomPlaneVertices),
  62106. this._nearLinesPoints[0] = I.Vector3[2],
  62107. this._nearLinesPoints[1] = I.Vector3[3],
  62108. this._nearLinesPoints[2] = I.Vector3[4],
  62109. this._nearLinesPoints[3] = I.Vector3[5],
  62110. this._nearLinesPoints[4] = I.Vector3[2],
  62111. this._farLinesPoints[0] = I.Vector3[6],
  62112. this._farLinesPoints[1] = I.Vector3[7],
  62113. this._farLinesPoints[2] = I.Vector3[8],
  62114. this._farLinesPoints[3] = I.Vector3[9],
  62115. this._farLinesPoints[4] = I.Vector3[6],
  62116. this._trLinesPoints[0] = I.Vector3[2],
  62117. this._trLinesPoints[1] = I.Vector3[6],
  62118. this._brLinesPoints[0] = I.Vector3[3],
  62119. this._brLinesPoints[1] = I.Vector3[7],
  62120. this._tlLinesPoints[0] = I.Vector3[4],
  62121. this._tlLinesPoints[1] = I.Vector3[8],
  62122. this._blLinesPoints[0] = I.Vector3[5],
  62123. this._blLinesPoints[1] = I.Vector3[9]
  62124. }
  62125. ,
  62126. e.prototype._getInvertViewMatrix = function() {
  62127. return P.LookAtLHToRef(this._light.position, this._light.position.add(this._light.direction), x.UpReadOnly, this._inverseViewMatrix),
  62128. this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),
  62129. this._inverseViewMatrix
  62130. }
  62131. ,
  62132. e
  62133. }()
  62134. , hc = function() {
  62135. this.renderWidth = 512,
  62136. this.renderHeight = 256,
  62137. this.textureSize = 512,
  62138. this.deterministicLockstep = !1,
  62139. this.lockstepMaxSteps = 4
  62140. }
  62141. , dc = function(t) {
  62142. function i(i) {
  62143. void 0 === i && (i = new hc);
  62144. var n = t.call(this, null) || this;
  62145. vr.Instances.push(n),
  62146. void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
  62147. void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
  62148. n._options = i,
  62149. T.SetMatrixPrecision(!!i.useHighPrecisionMatrix),
  62150. n._caps = {
  62151. maxTexturesImageUnits: 16,
  62152. maxVertexTextureImageUnits: 16,
  62153. maxCombinedTexturesImageUnits: 32,
  62154. maxTextureSize: 512,
  62155. maxCubemapTextureSize: 512,
  62156. maxRenderTextureSize: 512,
  62157. maxVertexAttribs: 16,
  62158. maxVaryingVectors: 16,
  62159. maxFragmentUniformVectors: 16,
  62160. maxVertexUniformVectors: 16,
  62161. standardDerivatives: !1,
  62162. astc: null,
  62163. pvrtc: null,
  62164. etc1: null,
  62165. etc2: null,
  62166. bptc: null,
  62167. maxAnisotropy: 0,
  62168. uintIndices: !1,
  62169. fragmentDepthSupported: !1,
  62170. highPrecisionShaderSupported: !0,
  62171. colorBufferFloat: !1,
  62172. textureFloat: !1,
  62173. textureFloatLinearFiltering: !1,
  62174. textureFloatRender: !1,
  62175. textureHalfFloat: !1,
  62176. textureHalfFloatLinearFiltering: !1,
  62177. textureHalfFloatRender: !1,
  62178. textureLOD: !1,
  62179. drawBuffersExtension: !1,
  62180. depthTextureExtension: !1,
  62181. vertexArrayObject: !1,
  62182. instancedArrays: !1,
  62183. supportOcclusionQuery: !1,
  62184. canUseTimestampForTimerQuery: !1,
  62185. maxMSAASamples: 1,
  62186. blendMinMax: !1,
  62187. canUseGLInstanceID: !1,
  62188. canUseGLVertexID: !1,
  62189. supportComputeShaders: !1,
  62190. supportSRGBBuffers: !1,
  62191. supportTransformFeedbacks: !1,
  62192. textureMaxLevel: !1
  62193. },
  62194. n._features = {
  62195. forceBitmapOverHTMLImageElement: !1,
  62196. supportRenderAndCopyToLodForFloatTextures: !1,
  62197. supportDepthStencilTexture: !1,
  62198. supportShadowSamplers: !1,
  62199. uniformBufferHardCheckMatrix: !1,
  62200. allowTexturePrefiltering: !1,
  62201. trackUbosInFrame: !1,
  62202. checkUbosContentBeforeUpload: !1,
  62203. supportCSM: !1,
  62204. basisNeedsPOT: !1,
  62205. support3DTextures: !1,
  62206. needTypeSuffixInShaderConstants: !1,
  62207. supportMSAA: !1,
  62208. supportSSAO2: !1,
  62209. supportExtendedTextureFormats: !1,
  62210. supportSwitchCaseInShader: !1,
  62211. supportSyncTextureRead: !1,
  62212. needsInvertingBitmap: !1,
  62213. useUBOBindingCache: !1,
  62214. needShaderCodeInlining: !1,
  62215. needToAlwaysBindUniformBuffers: !1,
  62216. supportRenderPasses: !0,
  62217. _collectUbosUpdatedInFrame: !1
  62218. },
  62219. K.Log("Babylon.js v".concat(vr.Version, " - Null engine"));
  62220. var r = "undefined" != typeof self ? self : void 0 !== e.g ? e.g : window;
  62221. return "undefined" == typeof URL && (r.URL = {
  62222. createObjectURL: function() {},
  62223. revokeObjectURL: function() {}
  62224. }),
  62225. "undefined" == typeof Blob && (r.Blob = function() {}
  62226. ),
  62227. n
  62228. }
  62229. return U(i, t),
  62230. i.prototype.isDeterministicLockStep = function() {
  62231. return this._options.deterministicLockstep
  62232. }
  62233. ,
  62234. i.prototype.getLockstepMaxSteps = function() {
  62235. return this._options.lockstepMaxSteps
  62236. }
  62237. ,
  62238. i.prototype.getHardwareScalingLevel = function() {
  62239. return 1
  62240. }
  62241. ,
  62242. i.prototype.createVertexBuffer = function(e) {
  62243. var t = new Bt;
  62244. return t.references = 1,
  62245. t
  62246. }
  62247. ,
  62248. i.prototype.createIndexBuffer = function(e) {
  62249. var t = new Bt;
  62250. return t.references = 1,
  62251. t
  62252. }
  62253. ,
  62254. i.prototype.clear = function(e, t, i, n) {
  62255. void 0 === n && (n = !1)
  62256. }
  62257. ,
  62258. i.prototype.getRenderWidth = function(e) {
  62259. return void 0 === e && (e = !1),
  62260. !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._options.renderWidth
  62261. }
  62262. ,
  62263. i.prototype.getRenderHeight = function(e) {
  62264. return void 0 === e && (e = !1),
  62265. !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._options.renderHeight
  62266. }
  62267. ,
  62268. i.prototype.setViewport = function(e, t, i) {
  62269. this._cachedViewport = e
  62270. }
  62271. ,
  62272. i.prototype.createShaderProgram = function(e, t, i, n, r) {
  62273. return {
  62274. __SPECTOR_rebuildProgram: null
  62275. }
  62276. }
  62277. ,
  62278. i.prototype.getUniforms = function(e, t) {
  62279. return []
  62280. }
  62281. ,
  62282. i.prototype.getAttributes = function(e, t) {
  62283. return []
  62284. }
  62285. ,
  62286. i.prototype.bindSamplers = function(e) {
  62287. this._currentEffect = null
  62288. }
  62289. ,
  62290. i.prototype.enableEffect = function(e) {
  62291. e = null !== e && Gt.IsWrapper(e) ? e.effect : e,
  62292. this._currentEffect = e,
  62293. e && (e.onBind && e.onBind(e),
  62294. e._onBindObservable && e._onBindObservable.notifyObservers(e))
  62295. }
  62296. ,
  62297. i.prototype.setState = function(e, t, i, n, r, o, a) {
  62298. void 0 === t && (t = 0),
  62299. void 0 === n && (n = !1),
  62300. void 0 === a && (a = 0)
  62301. }
  62302. ,
  62303. i.prototype.setIntArray = function(e, t) {
  62304. return !0
  62305. }
  62306. ,
  62307. i.prototype.setIntArray2 = function(e, t) {
  62308. return !0
  62309. }
  62310. ,
  62311. i.prototype.setIntArray3 = function(e, t) {
  62312. return !0
  62313. }
  62314. ,
  62315. i.prototype.setIntArray4 = function(e, t) {
  62316. return !0
  62317. }
  62318. ,
  62319. i.prototype.setFloatArray = function(e, t) {
  62320. return !0
  62321. }
  62322. ,
  62323. i.prototype.setFloatArray2 = function(e, t) {
  62324. return !0
  62325. }
  62326. ,
  62327. i.prototype.setFloatArray3 = function(e, t) {
  62328. return !0
  62329. }
  62330. ,
  62331. i.prototype.setFloatArray4 = function(e, t) {
  62332. return !0
  62333. }
  62334. ,
  62335. i.prototype.setArray = function(e, t) {
  62336. return !0
  62337. }
  62338. ,
  62339. i.prototype.setArray2 = function(e, t) {
  62340. return !0
  62341. }
  62342. ,
  62343. i.prototype.setArray3 = function(e, t) {
  62344. return !0
  62345. }
  62346. ,
  62347. i.prototype.setArray4 = function(e, t) {
  62348. return !0
  62349. }
  62350. ,
  62351. i.prototype.setMatrices = function(e, t) {
  62352. return !0
  62353. }
  62354. ,
  62355. i.prototype.setMatrix3x3 = function(e, t) {
  62356. return !0
  62357. }
  62358. ,
  62359. i.prototype.setMatrix2x2 = function(e, t) {
  62360. return !0
  62361. }
  62362. ,
  62363. i.prototype.setFloat = function(e, t) {
  62364. return !0
  62365. }
  62366. ,
  62367. i.prototype.setFloat2 = function(e, t, i) {
  62368. return !0
  62369. }
  62370. ,
  62371. i.prototype.setFloat3 = function(e, t, i, n) {
  62372. return !0
  62373. }
  62374. ,
  62375. i.prototype.setBool = function(e, t) {
  62376. return !0
  62377. }
  62378. ,
  62379. i.prototype.setFloat4 = function(e, t, i, n, r) {
  62380. return !0
  62381. }
  62382. ,
  62383. i.prototype.setAlphaMode = function(e, t) {
  62384. void 0 === t && (t = !1),
  62385. this._alphaMode !== e && (this.alphaState.alphaBlend = e !== a.ALPHA_DISABLE,
  62386. t || this.setDepthWrite(e === a.ALPHA_DISABLE),
  62387. this._alphaMode = e)
  62388. }
  62389. ,
  62390. i.prototype.bindBuffers = function(e, t, i) {}
  62391. ,
  62392. i.prototype.wipeCaches = function(e) {
  62393. this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
  62394. this._currentEffect = null,
  62395. e && (this._currentProgram = null,
  62396. this._stencilStateComposer.reset(),
  62397. this.depthCullingState.reset(),
  62398. this.alphaState.reset()),
  62399. this._cachedVertexBuffers = null,
  62400. this._cachedIndexBuffer = null,
  62401. this._cachedEffectForVertexBuffers = null)
  62402. }
  62403. ,
  62404. i.prototype.draw = function(e, t, i, n) {}
  62405. ,
  62406. i.prototype.drawElementsType = function(e, t, i, n) {}
  62407. ,
  62408. i.prototype.drawArraysType = function(e, t, i, n) {}
  62409. ,
  62410. i.prototype._createTexture = function() {
  62411. return {}
  62412. }
  62413. ,
  62414. i.prototype._releaseTexture = function(e) {}
  62415. ,
  62416. i.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d) {
  62417. void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  62418. void 0 === o && (o = null),
  62419. void 0 === s && (s = null),
  62420. void 0 === l && (l = null),
  62421. void 0 === c && (c = null),
  62422. void 0 === u && (u = null),
  62423. void 0 === h && (h = null);
  62424. var p = new Lt(this,At.Url)
  62425. , f = String(e);
  62426. return p.url = f,
  62427. p.generateMipMaps = !t,
  62428. p.samplingMode = r,
  62429. p.invertY = i,
  62430. p.baseWidth = this._options.textureSize,
  62431. p.baseHeight = this._options.textureSize,
  62432. p.width = this._options.textureSize,
  62433. p.height = this._options.textureSize,
  62434. u && (p.format = u),
  62435. p.isReady = !0,
  62436. o && o(),
  62437. this._internalTexturesCache.push(p),
  62438. p
  62439. }
  62440. ,
  62441. i.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
  62442. var n = new Fa(e,t,i,this);
  62443. return this._renderTargetWrapperCache.push(n),
  62444. n
  62445. }
  62446. ,
  62447. i.prototype.createRenderTargetTexture = function(e, t) {
  62448. var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
  62449. , n = {};
  62450. void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
  62451. n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
  62452. n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
  62453. n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
  62454. n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode) : (n.generateMipMaps = t,
  62455. n.generateDepthBuffer = !0,
  62456. n.generateStencilBuffer = !1,
  62457. n.type = a.TEXTURETYPE_UNSIGNED_INT,
  62458. n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE);
  62459. var r = new Lt(this,At.RenderTarget)
  62460. , o = e.width || e
  62461. , s = e.height || e;
  62462. return i._generateDepthBuffer = n.generateDepthBuffer,
  62463. i._generateStencilBuffer = !!n.generateStencilBuffer,
  62464. r.baseWidth = o,
  62465. r.baseHeight = s,
  62466. r.width = o,
  62467. r.height = s,
  62468. r.isReady = !0,
  62469. r.samples = 1,
  62470. r.generateMipMaps = !!n.generateMipMaps,
  62471. r.samplingMode = n.samplingMode,
  62472. r.type = n.type,
  62473. this._internalTexturesCache.push(r),
  62474. i
  62475. }
  62476. ,
  62477. i.prototype.updateTextureSamplingMode = function(e, t) {
  62478. t.samplingMode = e
  62479. }
  62480. ,
  62481. i.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
  62482. void 0 === l && (l = null),
  62483. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  62484. void 0 === u && (u = 0);
  62485. var h = new Lt(this,At.Raw);
  62486. return h.baseWidth = t,
  62487. h.baseHeight = i,
  62488. h.width = t,
  62489. h.height = i,
  62490. h.format = n,
  62491. h.generateMipMaps = r,
  62492. h.samplingMode = s,
  62493. h.invertY = o,
  62494. h._compression = l,
  62495. h.type = c,
  62496. this._doNotHandleContextLost || (h._bufferView = e),
  62497. h
  62498. }
  62499. ,
  62500. i.prototype.updateRawTexture = function(e, t, i, n, r, o) {
  62501. void 0 === r && (r = null),
  62502. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  62503. e && (e._bufferView = t,
  62504. e.format = i,
  62505. e.invertY = n,
  62506. e._compression = r,
  62507. e.type = o)
  62508. }
  62509. ,
  62510. i.prototype.bindFramebuffer = function(e, t, i, n, r) {
  62511. this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  62512. this._currentRenderTarget = e,
  62513. this._currentFramebuffer = null,
  62514. this._cachedViewport && !r && this.setViewport(this._cachedViewport, i, n)
  62515. }
  62516. ,
  62517. i.prototype.unBindFramebuffer = function(e, t, i) {
  62518. void 0 === t && (t = !1),
  62519. this._currentRenderTarget = null,
  62520. i && i(),
  62521. this._currentFramebuffer = null
  62522. }
  62523. ,
  62524. i.prototype.createDynamicVertexBuffer = function(e) {
  62525. var t = new Bt;
  62526. return t.references = 1,
  62527. t.capacity = 1,
  62528. t
  62529. }
  62530. ,
  62531. i.prototype.updateDynamicTexture = function(e, t, i, n, r) {
  62532. void 0 === n && (n = !1)
  62533. }
  62534. ,
  62535. i.prototype.areAllEffectsReady = function() {
  62536. return !0
  62537. }
  62538. ,
  62539. i.prototype.getError = function() {
  62540. return 0
  62541. }
  62542. ,
  62543. i.prototype._getUnpackAlignement = function() {
  62544. return 1
  62545. }
  62546. ,
  62547. i.prototype._unpackFlipY = function(e) {}
  62548. ,
  62549. i.prototype.updateDynamicIndexBuffer = function(e, t, i) {
  62550. void 0 === i && (i = 0)
  62551. }
  62552. ,
  62553. i.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {}
  62554. ,
  62555. i.prototype._bindTextureDirectly = function(e, t) {
  62556. return this._boundTexturesCache[this._activeChannel] !== t && (this._boundTexturesCache[this._activeChannel] = t,
  62557. !0)
  62558. }
  62559. ,
  62560. i.prototype._bindTexture = function(e, t) {
  62561. e < 0 || this._bindTextureDirectly(0, t)
  62562. }
  62563. ,
  62564. i.prototype._deleteBuffer = function(e) {}
  62565. ,
  62566. i.prototype.releaseEffects = function() {}
  62567. ,
  62568. i.prototype.displayLoadingUI = function() {}
  62569. ,
  62570. i.prototype.hideLoadingUI = function() {}
  62571. ,
  62572. i.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
  62573. void 0 === o && (o = 0),
  62574. void 0 === a && (a = 0)
  62575. }
  62576. ,
  62577. i.prototype._uploadDataToTextureDirectly = function(e, t, i, n) {
  62578. void 0 === i && (i = 0),
  62579. void 0 === n && (n = 0)
  62580. }
  62581. ,
  62582. i.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
  62583. void 0 === i && (i = 0),
  62584. void 0 === n && (n = 0)
  62585. }
  62586. ,
  62587. i.prototype._uploadImageToTexture = function(e, t, i, n) {
  62588. void 0 === i && (i = 0),
  62589. void 0 === n && (n = 0)
  62590. }
  62591. ,
  62592. i
  62593. }(vr);
  62594. Ht.prototype._debugPushGroup = function(e, t) {}
  62595. ,
  62596. Ht.prototype._debugPopGroup = function(e) {}
  62597. ,
  62598. Ht.prototype._debugInsertMarker = function(e, t) {}
  62599. ,
  62600. Ht.prototype._debugFlushPendingCommands = function() {}
  62601. ;
  62602. var pc = function() {
  62603. this._timeElapsedQueryEnded = !1
  62604. }
  62605. , fc = function() {
  62606. this.occlusionInternalRetryCounter = 0,
  62607. this.isOcclusionQueryInProgress = !1,
  62608. this.isOccluded = !1,
  62609. this.occlusionRetryCount = -1,
  62610. this.occlusionType = Sr.OCCLUSION_TYPE_NONE,
  62611. this.occlusionQueryAlgorithmType = Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,
  62612. this.forceRenderingWhenOccluded = !1
  62613. };
  62614. vr.prototype.createQuery = function() {
  62615. return this._gl.createQuery()
  62616. }
  62617. ,
  62618. vr.prototype.deleteQuery = function(e) {
  62619. return this._gl.deleteQuery(e),
  62620. this
  62621. }
  62622. ,
  62623. vr.prototype.isQueryResultAvailable = function(e) {
  62624. return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT_AVAILABLE)
  62625. }
  62626. ,
  62627. vr.prototype.getQueryResult = function(e) {
  62628. return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT)
  62629. }
  62630. ,
  62631. vr.prototype.beginOcclusionQuery = function(e, t) {
  62632. var i = this._getGlAlgorithmType(e);
  62633. return this._gl.beginQuery(i, t),
  62634. !0
  62635. }
  62636. ,
  62637. vr.prototype.endOcclusionQuery = function(e) {
  62638. var t = this._getGlAlgorithmType(e);
  62639. return this._gl.endQuery(t),
  62640. this
  62641. }
  62642. ,
  62643. vr.prototype._createTimeQuery = function() {
  62644. var e = this.getCaps().timerQuery;
  62645. return e.createQueryEXT ? e.createQueryEXT() : this.createQuery()
  62646. }
  62647. ,
  62648. vr.prototype._deleteTimeQuery = function(e) {
  62649. var t = this.getCaps().timerQuery;
  62650. t.deleteQueryEXT ? t.deleteQueryEXT(e) : this.deleteQuery(e)
  62651. }
  62652. ,
  62653. vr.prototype._getTimeQueryResult = function(e) {
  62654. var t = this.getCaps().timerQuery;
  62655. return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) : this.getQueryResult(e)
  62656. }
  62657. ,
  62658. vr.prototype._getTimeQueryAvailability = function(e) {
  62659. var t = this.getCaps().timerQuery;
  62660. return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(e)
  62661. }
  62662. ,
  62663. vr.prototype.startTimeQuery = function() {
  62664. var e = this.getCaps()
  62665. , t = e.timerQuery;
  62666. if (!t)
  62667. return null;
  62668. var i = new pc;
  62669. if (this._gl.getParameter(t.GPU_DISJOINT_EXT),
  62670. e.canUseTimestampForTimerQuery)
  62671. i._startTimeQuery = this._createTimeQuery(),
  62672. t.queryCounterEXT(i._startTimeQuery, t.TIMESTAMP_EXT);
  62673. else {
  62674. if (this._currentNonTimestampToken)
  62675. return this._currentNonTimestampToken;
  62676. i._timeElapsedQuery = this._createTimeQuery(),
  62677. t.beginQueryEXT ? t.beginQueryEXT(t.TIME_ELAPSED_EXT, i._timeElapsedQuery) : this._gl.beginQuery(t.TIME_ELAPSED_EXT, i._timeElapsedQuery),
  62678. this._currentNonTimestampToken = i
  62679. }
  62680. return i
  62681. }
  62682. ,
  62683. vr.prototype.endTimeQuery = function(e) {
  62684. var t = this.getCaps()
  62685. , i = t.timerQuery;
  62686. if (!i || !e)
  62687. return -1;
  62688. if (t.canUseTimestampForTimerQuery) {
  62689. if (!e._startTimeQuery)
  62690. return -1;
  62691. e._endTimeQuery || (e._endTimeQuery = this._createTimeQuery(),
  62692. i.queryCounterEXT(e._endTimeQuery, i.TIMESTAMP_EXT))
  62693. } else if (!e._timeElapsedQueryEnded) {
  62694. if (!e._timeElapsedQuery)
  62695. return -1;
  62696. i.endQueryEXT ? i.endQueryEXT(i.TIME_ELAPSED_EXT) : this._gl.endQuery(i.TIME_ELAPSED_EXT),
  62697. e._timeElapsedQueryEnded = !0
  62698. }
  62699. var n = this._gl.getParameter(i.GPU_DISJOINT_EXT)
  62700. , r = !1;
  62701. if (e._endTimeQuery ? r = this._getTimeQueryAvailability(e._endTimeQuery) : e._timeElapsedQuery && (r = this._getTimeQueryAvailability(e._timeElapsedQuery)),
  62702. r && !n) {
  62703. var o = 0;
  62704. if (t.canUseTimestampForTimerQuery) {
  62705. if (!e._startTimeQuery || !e._endTimeQuery)
  62706. return -1;
  62707. var a = this._getTimeQueryResult(e._startTimeQuery);
  62708. o = this._getTimeQueryResult(e._endTimeQuery) - a,
  62709. this._deleteTimeQuery(e._startTimeQuery),
  62710. this._deleteTimeQuery(e._endTimeQuery),
  62711. e._startTimeQuery = null,
  62712. e._endTimeQuery = null
  62713. } else {
  62714. if (!e._timeElapsedQuery)
  62715. return -1;
  62716. o = this._getTimeQueryResult(e._timeElapsedQuery),
  62717. this._deleteTimeQuery(e._timeElapsedQuery),
  62718. e._timeElapsedQuery = null,
  62719. e._timeElapsedQueryEnded = !1,
  62720. this._currentNonTimestampToken = null
  62721. }
  62722. return o
  62723. }
  62724. return -1
  62725. }
  62726. ,
  62727. vr.prototype._captureGPUFrameTime = !1,
  62728. vr.prototype._gpuFrameTime = new un,
  62729. vr.prototype.getGPUFrameTimeCounter = function() {
  62730. return this._gpuFrameTime
  62731. }
  62732. ,
  62733. vr.prototype.captureGPUFrameTime = function(e) {
  62734. var t = this;
  62735. e !== this._captureGPUFrameTime && (this._captureGPUFrameTime = e,
  62736. e ? (this._onBeginFrameObserver = this.onBeginFrameObservable.add((function() {
  62737. t._gpuFrameTimeToken || (t._gpuFrameTimeToken = t.startTimeQuery())
  62738. }
  62739. )),
  62740. this._onEndFrameObserver = this.onEndFrameObservable.add((function() {
  62741. if (t._gpuFrameTimeToken) {
  62742. var e = t.endTimeQuery(t._gpuFrameTimeToken);
  62743. e > -1 && (t._gpuFrameTimeToken = null,
  62744. t._gpuFrameTime.fetchNewFrame(),
  62745. t._gpuFrameTime.addCount(e, !0))
  62746. }
  62747. }
  62748. ))) : (this.onBeginFrameObservable.remove(this._onBeginFrameObserver),
  62749. this._onBeginFrameObserver = null,
  62750. this.onEndFrameObservable.remove(this._onEndFrameObserver),
  62751. this._onEndFrameObserver = null))
  62752. }
  62753. ,
  62754. vr.prototype._getGlAlgorithmType = function(e) {
  62755. return e === Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED
  62756. }
  62757. ,
  62758. Object.defineProperty(Sr.prototype, "isOcclusionQueryInProgress", {
  62759. get: function() {
  62760. return this._occlusionDataStorage.isOcclusionQueryInProgress
  62761. },
  62762. set: function(e) {
  62763. this._occlusionDataStorage.isOcclusionQueryInProgress = e
  62764. },
  62765. enumerable: !1,
  62766. configurable: !0
  62767. }),
  62768. Object.defineProperty(Sr.prototype, "_occlusionDataStorage", {
  62769. get: function() {
  62770. return this.__occlusionDataStorage || (this.__occlusionDataStorage = new fc),
  62771. this.__occlusionDataStorage
  62772. },
  62773. enumerable: !1,
  62774. configurable: !0
  62775. }),
  62776. Object.defineProperty(Sr.prototype, "isOccluded", {
  62777. get: function() {
  62778. return this._occlusionDataStorage.isOccluded
  62779. },
  62780. set: function(e) {
  62781. this._occlusionDataStorage.isOccluded = e
  62782. },
  62783. enumerable: !0,
  62784. configurable: !0
  62785. }),
  62786. Object.defineProperty(Sr.prototype, "occlusionQueryAlgorithmType", {
  62787. get: function() {
  62788. return this._occlusionDataStorage.occlusionQueryAlgorithmType
  62789. },
  62790. set: function(e) {
  62791. this._occlusionDataStorage.occlusionQueryAlgorithmType = e
  62792. },
  62793. enumerable: !0,
  62794. configurable: !0
  62795. }),
  62796. Object.defineProperty(Sr.prototype, "occlusionType", {
  62797. get: function() {
  62798. return this._occlusionDataStorage.occlusionType
  62799. },
  62800. set: function(e) {
  62801. this._occlusionDataStorage.occlusionType = e
  62802. },
  62803. enumerable: !0,
  62804. configurable: !0
  62805. }),
  62806. Object.defineProperty(Sr.prototype, "occlusionRetryCount", {
  62807. get: function() {
  62808. return this._occlusionDataStorage.occlusionRetryCount
  62809. },
  62810. set: function(e) {
  62811. this._occlusionDataStorage.occlusionRetryCount = e
  62812. },
  62813. enumerable: !0,
  62814. configurable: !0
  62815. }),
  62816. Object.defineProperty(Sr.prototype, "forceRenderingWhenOccluded", {
  62817. get: function() {
  62818. return this._occlusionDataStorage.forceRenderingWhenOccluded
  62819. },
  62820. set: function(e) {
  62821. this._occlusionDataStorage.forceRenderingWhenOccluded = e
  62822. },
  62823. enumerable: !0,
  62824. configurable: !0
  62825. }),
  62826. Sr.prototype._checkOcclusionQuery = function() {
  62827. var e = this._occlusionDataStorage;
  62828. if (e.occlusionType === Sr.OCCLUSION_TYPE_NONE)
  62829. return e.isOccluded = !1,
  62830. !1;
  62831. var t = this.getEngine();
  62832. if (!t.getCaps().supportOcclusionQuery)
  62833. return e.isOccluded = !1,
  62834. !1;
  62835. if (!t.isQueryResultAvailable)
  62836. return e.isOccluded = !1,
  62837. !1;
  62838. if (this.isOcclusionQueryInProgress && this._occlusionQuery)
  62839. if (t.isQueryResultAvailable(this._occlusionQuery)) {
  62840. var i = t.getQueryResult(this._occlusionQuery);
  62841. e.isOcclusionQueryInProgress = !1,
  62842. e.occlusionInternalRetryCounter = 0,
  62843. e.isOccluded = !(i > 0)
  62844. } else {
  62845. if (e.occlusionInternalRetryCounter++,
  62846. !(-1 !== e.occlusionRetryCount && e.occlusionInternalRetryCounter > e.occlusionRetryCount))
  62847. return e.occlusionType !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded;
  62848. e.isOcclusionQueryInProgress = !1,
  62849. e.occlusionInternalRetryCounter = 0,
  62850. e.isOccluded = e.occlusionType !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded
  62851. }
  62852. var n = this.getScene();
  62853. if (n.getBoundingBoxRenderer) {
  62854. var r = n.getBoundingBoxRenderer();
  62855. null === this._occlusionQuery && (this._occlusionQuery = t.createQuery()),
  62856. t.beginOcclusionQuery(e.occlusionQueryAlgorithmType, this._occlusionQuery) && (r.renderOcclusionBoundingBox(this),
  62857. t.endOcclusionQuery(e.occlusionQueryAlgorithmType),
  62858. this._occlusionDataStorage.isOcclusionQueryInProgress = !0)
  62859. }
  62860. return e.isOccluded
  62861. }
  62862. ;
  62863. var _c = !0;
  62864. vr.prototype.createTransformFeedback = function() {
  62865. return this._gl.createTransformFeedback()
  62866. }
  62867. ,
  62868. vr.prototype.deleteTransformFeedback = function(e) {
  62869. this._gl.deleteTransformFeedback(e)
  62870. }
  62871. ,
  62872. vr.prototype.bindTransformFeedback = function(e) {
  62873. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, e)
  62874. }
  62875. ,
  62876. vr.prototype.beginTransformFeedback = function(e) {
  62877. void 0 === e && (e = !0),
  62878. this._gl.beginTransformFeedback(e ? this._gl.POINTS : this._gl.TRIANGLES)
  62879. }
  62880. ,
  62881. vr.prototype.endTransformFeedback = function() {
  62882. this._gl.endTransformFeedback()
  62883. }
  62884. ,
  62885. vr.prototype.setTranformFeedbackVaryings = function(e, t) {
  62886. this._gl.transformFeedbackVaryings(e, t, this._gl.INTERLEAVED_ATTRIBS)
  62887. }
  62888. ,
  62889. vr.prototype.bindTransformFeedbackBuffer = function(e) {
  62890. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, e ? e.underlyingResource : null)
  62891. }
  62892. ,
  62893. Ht.prototype.createExternalTexture = function(e) {
  62894. return null
  62895. }
  62896. ,
  62897. Ht.prototype.setExternalTexture = function(e, t) {
  62898. throw new Error("setExternalTexture: This engine does not support external textures!")
  62899. }
  62900. ,
  62901. Ht.prototype.updateVideoTexture = function(e, t, i) {
  62902. if (e && !e._isDisabled) {
  62903. var n = this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0);
  62904. this._unpackFlipY(!i);
  62905. try {
  62906. if (void 0 === this._videoTextureSupported && (this._gl.getError(),
  62907. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t),
  62908. 0 !== this._gl.getError() ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0),
  62909. this._videoTextureSupported)
  62910. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t);
  62911. else {
  62912. if (!e._workingCanvas) {
  62913. e._workingCanvas = this.createCanvas(e.width, e.height);
  62914. var r = e._workingCanvas.getContext("2d");
  62915. if (!r)
  62916. throw new Error("Unable to get 2d context");
  62917. e._workingContext = r,
  62918. e._workingCanvas.width = e.width,
  62919. e._workingCanvas.height = e.height
  62920. }
  62921. e._workingContext.clearRect(0, 0, e.width, e.height),
  62922. e._workingContext.drawImage(t, 0, 0, t.videoWidth, t.videoHeight, 0, 0, e.width, e.height),
  62923. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e._workingCanvas)
  62924. }
  62925. e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  62926. n || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
  62927. e.isReady = !0
  62928. } catch (t) {
  62929. e._isDisabled = !0
  62930. }
  62931. }
  62932. }
  62933. ,
  62934. Ht.prototype.restoreSingleAttachment = function() {
  62935. var e = this._gl;
  62936. this.bindAttachments([e.BACK])
  62937. }
  62938. ,
  62939. Ht.prototype.restoreSingleAttachmentForRenderTarget = function() {
  62940. var e = this._gl;
  62941. this.bindAttachments([e.COLOR_ATTACHMENT0])
  62942. }
  62943. ,
  62944. Ht.prototype.buildTextureLayout = function(e) {
  62945. for (var t = this._gl, i = [], n = 0; n < e.length; n++)
  62946. e[n] ? i.push(t["COLOR_ATTACHMENT" + n]) : i.push(t.NONE);
  62947. return i
  62948. }
  62949. ,
  62950. Ht.prototype.bindAttachments = function(e) {
  62951. this._gl.drawBuffers(e)
  62952. }
  62953. ,
  62954. Ht.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
  62955. void 0 === t && (t = !1),
  62956. this._currentRenderTarget = null;
  62957. var n = this._gl
  62958. , r = e._attachments
  62959. , o = r.length;
  62960. if (e._MSAAFramebuffer) {
  62961. n.bindFramebuffer(n.READ_FRAMEBUFFER, e._MSAAFramebuffer),
  62962. n.bindFramebuffer(n.DRAW_FRAMEBUFFER, e._framebuffer);
  62963. for (var a = 0; a < o; a++) {
  62964. for (var s = e.textures[a], l = 0; l < o; l++)
  62965. r[l] = n.NONE;
  62966. r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"],
  62967. n.readBuffer(r[a]),
  62968. n.drawBuffers(r),
  62969. n.blitFramebuffer(0, 0, s.width, s.height, 0, 0, s.width, s.height, n.COLOR_BUFFER_BIT, n.NEAREST)
  62970. }
  62971. for (a = 0; a < o; a++)
  62972. r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
  62973. n.drawBuffers(r)
  62974. }
  62975. for (a = 0; a < o; a++)
  62976. !(s = e.textures[a]).generateMipMaps || t || s.isCube || (this._bindTextureDirectly(n.TEXTURE_2D, s, !0),
  62977. n.generateMipmap(n.TEXTURE_2D),
  62978. this._bindTextureDirectly(n.TEXTURE_2D, null));
  62979. i && (e._MSAAFramebuffer && this._bindUnboundFramebuffer(e._framebuffer),
  62980. i()),
  62981. this._bindUnboundFramebuffer(null)
  62982. }
  62983. ,
  62984. Ht.prototype.createMultipleRenderTarget = function(e, t, i) {
  62985. void 0 === i && (i = !0);
  62986. var n = !1
  62987. , r = !0
  62988. , o = !1
  62989. , s = !1
  62990. , l = a.TEXTUREFORMAT_DEPTH16
  62991. , c = 1
  62992. , u = a.TEXTURETYPE_UNSIGNED_INT
  62993. , h = a.TEXTURE_TRILINEAR_SAMPLINGMODE
  62994. , d = new Array
  62995. , p = new Array
  62996. , f = this._createHardwareRenderTargetWrapper(!0, !1, e);
  62997. void 0 !== t && (n = void 0 !== t.generateMipMaps && t.generateMipMaps,
  62998. r = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
  62999. o = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer,
  63000. s = void 0 !== t.generateDepthTexture && t.generateDepthTexture,
  63001. c = t.textureCount || 1,
  63002. t.types && (d = t.types),
  63003. t.samplingModes && (p = t.samplingModes),
  63004. this.webGLVersion > 1 && (t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH32_FLOAT) && (l = t.depthTextureFormat));
  63005. var _ = this._gl
  63006. , m = _.createFramebuffer();
  63007. this._bindUnboundFramebuffer(m);
  63008. var g = e.width || e
  63009. , v = e.height || e
  63010. , y = []
  63011. , b = []
  63012. , T = this.webGLVersion > 1 && s && t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8
  63013. , E = this._setupFramebufferDepthAttachments(!T && o, !s && r, g, v);
  63014. f._framebuffer = m,
  63015. f._depthStencilBuffer = E,
  63016. f._generateDepthBuffer = !s && r,
  63017. f._generateStencilBuffer = !T && o,
  63018. f._attachments = b;
  63019. for (var S = 0; S < c; S++) {
  63020. var A = p[S] || h
  63021. , x = d[S] || u;
  63022. (x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (x !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (A = a.TEXTURE_NEAREST_SAMPLINGMODE);
  63023. var R = this._getSamplingParameters(A, n);
  63024. x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (x = a.TEXTURETYPE_UNSIGNED_INT,
  63025. K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  63026. var C = new Lt(this,At.MultiRenderTarget)
  63027. , P = _[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + S : "COLOR_ATTACHMENT" + S + "_WEBGL"];
  63028. y.push(C),
  63029. b.push(P),
  63030. _.activeTexture(_["TEXTURE" + S]),
  63031. _.bindTexture(_.TEXTURE_2D, C._hardwareTexture.underlyingResource),
  63032. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, R.mag),
  63033. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, R.min),
  63034. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
  63035. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
  63036. _.texImage2D(_.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(x), g, v, 0, _.RGBA, this._getWebGLTextureType(x), null),
  63037. _.framebufferTexture2D(_.DRAW_FRAMEBUFFER, P, _.TEXTURE_2D, C._hardwareTexture.underlyingResource, 0),
  63038. n && this._gl.generateMipmap(this._gl.TEXTURE_2D),
  63039. this._bindTextureDirectly(_.TEXTURE_2D, null),
  63040. C.baseWidth = g,
  63041. C.baseHeight = v,
  63042. C.width = g,
  63043. C.height = v,
  63044. C.isReady = !0,
  63045. C.samples = 1,
  63046. C.generateMipMaps = n,
  63047. C.samplingMode = A,
  63048. C.type = x,
  63049. this._internalTexturesCache.push(C)
  63050. }
  63051. if (s && this._caps.depthTextureExtension) {
  63052. var M = new Lt(this,At.Depth)
  63053. , I = a.TEXTURETYPE_UNSIGNED_SHORT
  63054. , O = _.DEPTH_COMPONENT16
  63055. , D = _.DEPTH_COMPONENT
  63056. , N = _.UNSIGNED_SHORT
  63057. , L = _.DEPTH_ATTACHMENT;
  63058. this.webGLVersion < 2 ? O = _.DEPTH_COMPONENT : l === a.TEXTUREFORMAT_DEPTH32_FLOAT ? (I = a.TEXTURETYPE_FLOAT,
  63059. N = _.FLOAT,
  63060. O = _.DEPTH_COMPONENT32F) : l === a.TEXTUREFORMAT_DEPTH24 ? (I = a.TEXTURETYPE_UNSIGNED_INT,
  63061. N = _.UNSIGNED_INT,
  63062. O = _.DEPTH_COMPONENT24,
  63063. L = _.DEPTH_ATTACHMENT) : l === a.TEXTUREFORMAT_DEPTH24_STENCIL8 && (I = a.TEXTURETYPE_UNSIGNED_INT_24_8,
  63064. N = _.UNSIGNED_INT_24_8,
  63065. O = _.DEPTH24_STENCIL8,
  63066. D = _.DEPTH_STENCIL,
  63067. L = _.DEPTH_STENCIL_ATTACHMENT),
  63068. _.activeTexture(_.TEXTURE0),
  63069. _.bindTexture(_.TEXTURE_2D, M._hardwareTexture.underlyingResource),
  63070. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, _.NEAREST),
  63071. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, _.NEAREST),
  63072. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
  63073. _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
  63074. _.texImage2D(_.TEXTURE_2D, 0, O, g, v, 0, D, N, null),
  63075. _.framebufferTexture2D(_.FRAMEBUFFER, L, _.TEXTURE_2D, M._hardwareTexture.underlyingResource, 0),
  63076. M.baseWidth = g,
  63077. M.baseHeight = v,
  63078. M.width = g,
  63079. M.height = v,
  63080. M.isReady = !0,
  63081. M.samples = 1,
  63082. M.generateMipMaps = n,
  63083. M.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE,
  63084. M.format = l,
  63085. M.type = I,
  63086. y.push(M),
  63087. this._internalTexturesCache.push(M)
  63088. }
  63089. return f.setTextures(y),
  63090. i && _.drawBuffers(b),
  63091. this._bindUnboundFramebuffer(null),
  63092. this.resetTextureCache(),
  63093. f
  63094. }
  63095. ,
  63096. Ht.prototype.updateMultipleRenderTargetTextureSampleCount = function(e, t, i) {
  63097. if (void 0 === i && (i = !0),
  63098. this.webGLVersion < 2 || !e || !e.texture)
  63099. return 1;
  63100. if (e.samples === t)
  63101. return t;
  63102. var n = e._attachments.length;
  63103. if (0 === n)
  63104. return 1;
  63105. var r = this._gl;
  63106. t = Math.min(t, this.getCaps().maxMSAASamples),
  63107. e._depthStencilBuffer && (r.deleteRenderbuffer(e._depthStencilBuffer),
  63108. e._depthStencilBuffer = null),
  63109. e._MSAAFramebuffer && (r.deleteFramebuffer(e._MSAAFramebuffer),
  63110. e._MSAAFramebuffer = null);
  63111. for (var o = 0; o < n; o++)
  63112. (null == (c = e.textures[o]._hardwareTexture) ? void 0 : c._MSAARenderBuffer) && (r.deleteRenderbuffer(c._MSAARenderBuffer),
  63113. c._MSAARenderBuffer = null);
  63114. if (t > 1 && r.renderbufferStorageMultisample) {
  63115. var a = r.createFramebuffer();
  63116. if (!a)
  63117. throw new Error("Unable to create multi sampled framebuffer");
  63118. e._MSAAFramebuffer = a,
  63119. this._bindUnboundFramebuffer(a);
  63120. var s = [];
  63121. for (o = 0; o < n; o++) {
  63122. var l = e.textures[o]
  63123. , c = l._hardwareTexture
  63124. , u = r[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + o : "COLOR_ATTACHMENT" + o + "_WEBGL"]
  63125. , h = this._createRenderBuffer(l.width, l.height, t, -1, this._getRGBAMultiSampleBufferFormat(l.type), u);
  63126. if (!h)
  63127. throw new Error("Unable to create multi sampled framebuffer");
  63128. c._MSAARenderBuffer = h,
  63129. l.samples = t,
  63130. s.push(u)
  63131. }
  63132. i && r.drawBuffers(s)
  63133. } else
  63134. this._bindUnboundFramebuffer(e._framebuffer);
  63135. return e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
  63136. this._bindUnboundFramebuffer(null),
  63137. t
  63138. }
  63139. ,
  63140. Ht.prototype._createDepthStencilCubeTexture = function(e, t, i) {
  63141. var n = new Lt(this,At.DepthStencil);
  63142. if (n.isCube = !0,
  63143. 1 === this.webGLVersion)
  63144. return K.Error("Depth cube texture is not supported by WebGL 1."),
  63145. n;
  63146. var r = V({
  63147. bilinearFiltering: !1,
  63148. comparisonFunction: 0,
  63149. generateStencil: !1
  63150. }, t)
  63151. , o = this._gl;
  63152. this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, n, !0),
  63153. this._setupDepthStencilTexture(n, e, r.generateStencil, r.bilinearFiltering, r.comparisonFunction),
  63154. i._depthStencilTexture = n,
  63155. i._depthStencilTextureWithStencil = r.generateStencil;
  63156. for (var a = 0; a < 6; a++)
  63157. r.generateStencil ? o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH24_STENCIL8, e, e, 0, o.DEPTH_STENCIL, o.UNSIGNED_INT_24_8, null) : o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH_COMPONENT24, e, e, 0, o.DEPTH_COMPONENT, o.UNSIGNED_INT, null);
  63158. return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, null),
  63159. this._internalTexturesCache.push(n),
  63160. n
  63161. }
  63162. ,
  63163. Ht.prototype._partialLoadFile = function(e, t, i, n, r) {
  63164. void 0 === r && (r = null),
  63165. this._loadFile(e, (function(e) {
  63166. i[t] = e,
  63167. i._internalCount++,
  63168. 6 === i._internalCount && n(i)
  63169. }
  63170. ), void 0, void 0, !0, (function(e, t) {
  63171. r && e && r(e.status + " " + e.statusText, t)
  63172. }
  63173. ))
  63174. }
  63175. ,
  63176. Ht.prototype._cascadeLoadFiles = function(e, t, i, n) {
  63177. void 0 === n && (n = null);
  63178. var r = [];
  63179. r._internalCount = 0;
  63180. for (var o = 0; o < 6; o++)
  63181. this._partialLoadFile(i[o], o, r, t, n)
  63182. }
  63183. ,
  63184. Ht.prototype._cascadeLoadImgs = function(e, t, i, n, r, o) {
  63185. void 0 === r && (r = null);
  63186. var a = [];
  63187. a._internalCount = 0;
  63188. for (var s = 0; s < 6; s++)
  63189. this._partialLoadImg(n[s], s, a, e, t, i, r, o)
  63190. }
  63191. ,
  63192. Ht.prototype._partialLoadImg = function(e, t, i, n, r, o, a, s) {
  63193. void 0 === a && (a = null);
  63194. var l = fi();
  63195. $t(e, (function(e) {
  63196. i[t] = e,
  63197. i._internalCount++,
  63198. n && n._removePendingData(l),
  63199. 6 === i._internalCount && o && o(r, i)
  63200. }
  63201. ), (function(e, t) {
  63202. n && n._removePendingData(l),
  63203. a && a(e, t)
  63204. }
  63205. ), n ? n.offlineProvider : null, s),
  63206. n && n._addPendingData(l)
  63207. }
  63208. ,
  63209. Ht.prototype._setCubeMapTextureParams = function(e, t, i) {
  63210. var n = this._gl;
  63211. n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAG_FILTER, n.LINEAR),
  63212. n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, t ? n.LINEAR_MIPMAP_LINEAR : n.LINEAR),
  63213. n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE),
  63214. n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE),
  63215. e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_LINEAR_LINEAR,
  63216. t && this.getCaps().textureMaxLevel && void 0 !== i && i > 0 && (n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_LEVEL, i),
  63217. e._maxLodLevel = i),
  63218. this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null)
  63219. }
  63220. ,
  63221. Ht.prototype.createCubeTextureBase = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f) {
  63222. var _ = this;
  63223. void 0 === r && (r = null),
  63224. void 0 === o && (o = null),
  63225. void 0 === s && (s = null),
  63226. void 0 === l && (l = !1),
  63227. void 0 === c && (c = 0),
  63228. void 0 === u && (u = 0),
  63229. void 0 === h && (h = null),
  63230. void 0 === d && (d = null),
  63231. void 0 === p && (p = null),
  63232. void 0 === f && (f = !1);
  63233. var m = h || new Lt(this,At.Cube);
  63234. m.isCube = !0,
  63235. m.url = e,
  63236. m.generateMipMaps = !n,
  63237. m._lodGenerationScale = c,
  63238. m._lodGenerationOffset = u,
  63239. m._useSRGBBuffer = !!f && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!n),
  63240. this._doNotHandleContextLost || (m._extension = s,
  63241. m._files = i);
  63242. var g = e;
  63243. this._transformTextureUrl && !h && (e = this._transformTextureUrl(e));
  63244. for (var v = e.lastIndexOf("."), y = s || (v > -1 ? e.substring(v).toLowerCase() : ""), b = null, T = 0, E = Ht._TextureLoaders; T < E.length; T++) {
  63245. var S = E[T];
  63246. if (S.canLoad(y)) {
  63247. b = S;
  63248. break
  63249. }
  63250. }
  63251. if (b) {
  63252. var A = function(e) {
  63253. d && d(m, e),
  63254. b.loadCubeData(e, m, l, r, o)
  63255. };
  63256. i && 6 === i.length ? b.supportCascades ? this._cascadeLoadFiles(t, (function(e) {
  63257. return A(e.map((function(e) {
  63258. return new Uint8Array(e)
  63259. }
  63260. )))
  63261. }
  63262. ), i, o) : o ? o("Textures type does not support cascades.") : K.Warn("Texture loader does not support cascades.") : this._loadFile(e, (function(e) {
  63263. return A(new Uint8Array(e))
  63264. }
  63265. ), void 0, void 0, !0, (function(h, v) {
  63266. e === g ? o && h && o(h.status + " " + h.statusText, v) : (K.Warn("Failed to load ".concat(e, ", falling back to the ").concat(g)),
  63267. _.createCubeTextureBase(g, t, i, !!n, r, o, a, s, l, c, u, m, d, p, f))
  63268. }
  63269. ))
  63270. } else {
  63271. if (!i)
  63272. throw new Error("Cannot load cubemap because files were not defined");
  63273. this._cascadeLoadImgs(t, m, (function(e, t) {
  63274. p && p(e, t)
  63275. }
  63276. ), i, o)
  63277. }
  63278. return this._internalTexturesCache.push(m),
  63279. m
  63280. }
  63281. ,
  63282. Ht.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p) {
  63283. var f = this;
  63284. void 0 === r && (r = null),
  63285. void 0 === o && (o = null),
  63286. void 0 === s && (s = null),
  63287. void 0 === l && (l = !1),
  63288. void 0 === c && (c = 0),
  63289. void 0 === u && (u = 0),
  63290. void 0 === h && (h = null),
  63291. void 0 === p && (p = !1);
  63292. var _ = this._gl;
  63293. return this.createCubeTextureBase(e, t, i, !!n, r, o, a, s, l, c, u, h, (function(e) {
  63294. return f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0)
  63295. }
  63296. ), (function(e, t) {
  63297. var i = f.needPOTTextures ? Ht.GetExponentOfTwo(t[0].width, f._caps.maxCubemapTextureSize) : t[0].width
  63298. , o = i
  63299. , s = [_.TEXTURE_CUBE_MAP_POSITIVE_X, _.TEXTURE_CUBE_MAP_POSITIVE_Y, _.TEXTURE_CUBE_MAP_POSITIVE_Z, _.TEXTURE_CUBE_MAP_NEGATIVE_X, _.TEXTURE_CUBE_MAP_NEGATIVE_Y, _.TEXTURE_CUBE_MAP_NEGATIVE_Z];
  63300. f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0),
  63301. f._unpackFlipY(!1);
  63302. var l = a ? f._getInternalFormat(a, e._useSRGBBuffer) : e._useSRGBBuffer ? _.SRGB8_ALPHA8 : _.RGBA
  63303. , c = a ? f._getInternalFormat(a) : _.RGBA;
  63304. e._useSRGBBuffer && 1 === f.webGLVersion && (c = l);
  63305. for (var u = 0; u < s.length; u++)
  63306. if (t[u].width !== i || t[u].height !== o) {
  63307. if (f._prepareWorkingCanvas(),
  63308. !f._workingCanvas || !f._workingContext)
  63309. return void K.Warn("Cannot create canvas to resize texture.");
  63310. f._workingCanvas.width = i,
  63311. f._workingCanvas.height = o,
  63312. f._workingContext.drawImage(t[u], 0, 0, t[u].width, t[u].height, 0, 0, i, o),
  63313. _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, f._workingCanvas)
  63314. } else
  63315. _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, t[u]);
  63316. n || _.generateMipmap(_.TEXTURE_CUBE_MAP),
  63317. f._setCubeMapTextureParams(e, !n),
  63318. e.width = i,
  63319. e.height = o,
  63320. e.isReady = !0,
  63321. a && (e.format = a),
  63322. e.onLoadedObservable.notifyObservers(e),
  63323. e.onLoadedObservable.clear(),
  63324. r && r()
  63325. }
  63326. ), !!p)
  63327. }
  63328. ,
  63329. Ht.prototype.setTextureSampler = function(e, t) {
  63330. throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!")
  63331. }
  63332. ;
  63333. var mc = function() {};
  63334. function gc(e) {
  63335. if (this._excludedCompressedTextures && this._excludedCompressedTextures.some((function(t) {
  63336. var i = "\\b" + t + "\\b";
  63337. return e && (e === t || e.match(new RegExp(i,"g")))
  63338. }
  63339. )))
  63340. return e;
  63341. var t = e.lastIndexOf(".")
  63342. , i = e.lastIndexOf("?")
  63343. , n = i > -1 ? e.substring(i, e.length) : "";
  63344. return (t > -1 ? e.substring(0, t) : e) + this._textureFormatInUse + n
  63345. }
  63346. Object.defineProperty(vr.prototype, "inputElement", {
  63347. get: function() {
  63348. return this._inputElement
  63349. },
  63350. set: function(e) {
  63351. var t;
  63352. this._inputElement !== e && (this._inputElement = e,
  63353. null === (t = this._onEngineViewChanged) || void 0 === t || t.call(this))
  63354. }
  63355. }),
  63356. vr.prototype.getInputElement = function() {
  63357. return this.inputElement || this.getRenderingCanvas()
  63358. }
  63359. ,
  63360. vr.prototype.registerView = function(e, t, i) {
  63361. var n = this;
  63362. this.views || (this.views = []);
  63363. for (var r = 0, o = this.views; r < o.length; r++) {
  63364. var a = o[r];
  63365. if (a.target === e)
  63366. return a
  63367. }
  63368. var s = this.getRenderingCanvas();
  63369. s && (e.width = s.width,
  63370. e.height = s.height);
  63371. var l = {
  63372. target: e,
  63373. camera: t,
  63374. clearBeforeCopy: i,
  63375. enabled: !0
  63376. };
  63377. return this.views.push(l),
  63378. t && t.onDisposeObservable.add((function() {
  63379. n.unRegisterView(e)
  63380. }
  63381. )),
  63382. l
  63383. }
  63384. ,
  63385. vr.prototype.unRegisterView = function(e) {
  63386. if (!this.views)
  63387. return this;
  63388. for (var t = 0, i = this.views; t < i.length; t++) {
  63389. var n = i[t];
  63390. if (n.target === e) {
  63391. var r = this.views.indexOf(n);
  63392. -1 !== r && this.views.splice(r, 1);
  63393. break
  63394. }
  63395. }
  63396. return this
  63397. }
  63398. ,
  63399. vr.prototype._renderViews = function() {
  63400. if (!this.views)
  63401. return !1;
  63402. var e = this.getRenderingCanvas();
  63403. if (!e)
  63404. return !1;
  63405. for (var t = 0, i = this.views; t < i.length; t++) {
  63406. var n = i[t];
  63407. if (n.enabled) {
  63408. var r = n.target
  63409. , o = r.getContext("2d");
  63410. if (o) {
  63411. var a = n.camera
  63412. , s = null
  63413. , l = null;
  63414. if (a) {
  63415. if ((l = a.getScene()).activeCameras && l.activeCameras.length)
  63416. continue;
  63417. this.activeView = n,
  63418. s = l.activeCamera,
  63419. l.activeCamera = a
  63420. }
  63421. if (n.customResize)
  63422. n.customResize(r);
  63423. else {
  63424. var c = Math.floor(r.clientWidth / this._hardwareScalingLevel)
  63425. , u = Math.floor(r.clientHeight / this._hardwareScalingLevel)
  63426. , h = c !== r.width || e.width !== r.width || u !== r.height || e.height !== r.height;
  63427. r.clientWidth && r.clientHeight && h && (r.width = c,
  63428. r.height = u,
  63429. this.setSize(c, u))
  63430. }
  63431. if (!e.width || !e.height)
  63432. return !1;
  63433. this._renderFrame(),
  63434. this.flushFramebuffer(),
  63435. n.clearBeforeCopy && o.clearRect(0, 0, e.width, e.height),
  63436. o.drawImage(e, 0, 0),
  63437. s && l && (l.activeCamera = s)
  63438. }
  63439. }
  63440. }
  63441. return this.activeView = null,
  63442. !0
  63443. }
  63444. ,
  63445. Ht.prototype.createStorageBuffer = function(e, t) {
  63446. throw new Error("createStorageBuffer: Unsupported method in this engine!")
  63447. }
  63448. ,
  63449. Ht.prototype.updateStorageBuffer = function(e, t, i, n) {}
  63450. ,
  63451. Ht.prototype.readFromStorageBuffer = function(e, t, i, n) {
  63452. throw new Error("readFromStorageBuffer: Unsupported method in this engine!")
  63453. }
  63454. ,
  63455. Ht.prototype.setStorageBuffer = function(e, t) {
  63456. throw new Error("setStorageBuffer: Unsupported method in this engine!")
  63457. }
  63458. ,
  63459. Object.defineProperty(vr.prototype, "texturesSupported", {
  63460. get: function() {
  63461. var e = new Array;
  63462. return this._caps.astc && e.push("-astc.ktx"),
  63463. this._caps.s3tc && e.push("-dxt.ktx"),
  63464. this._caps.pvrtc && e.push("-pvrtc.ktx"),
  63465. this._caps.etc2 && e.push("-etc2.ktx"),
  63466. this._caps.etc1 && e.push("-etc1.ktx"),
  63467. e
  63468. },
  63469. enumerable: !0,
  63470. configurable: !0
  63471. }),
  63472. Object.defineProperty(vr.prototype, "textureFormatInUse", {
  63473. get: function() {
  63474. return this._textureFormatInUse || null
  63475. },
  63476. enumerable: !0,
  63477. configurable: !0
  63478. }),
  63479. vr.prototype.setCompressedTextureExclusions = function(e) {
  63480. this._excludedCompressedTextures = e
  63481. }
  63482. ,
  63483. vr.prototype.setTextureFormatToUse = function(e) {
  63484. for (var t = this.texturesSupported, i = 0, n = t.length; i < n; i++)
  63485. for (var r = 0, o = e.length; r < o; r++)
  63486. if (t[i] === e[r].toLowerCase())
  63487. return this._transformTextureUrl = gc.bind(this),
  63488. this._textureFormatInUse = t[i];
  63489. return this._textureFormatInUse = "",
  63490. this._transformTextureUrl = null,
  63491. null
  63492. }
  63493. ;
  63494. var vc, yc, bc = function() {
  63495. function e() {
  63496. var t = this
  63497. , i = new ArrayBuffer(e.DEFAULT_BUFFER_SIZE);
  63498. this._uint32s = new Uint32Array(i),
  63499. this._int32s = new Int32Array(i),
  63500. this._float32s = new Float32Array(i),
  63501. this._length = e.DEFAULT_BUFFER_SIZE / 4,
  63502. this._position = 0,
  63503. this._nativeDataStream = new _native.NativeDataStream((function() {
  63504. t._flush()
  63505. }
  63506. ))
  63507. }
  63508. return e.prototype.writeUint32 = function(e) {
  63509. this._flushIfNecessary(1),
  63510. this._uint32s[this._position++] = e
  63511. }
  63512. ,
  63513. e.prototype.writeInt32 = function(e) {
  63514. this._flushIfNecessary(1),
  63515. this._int32s[this._position++] = e
  63516. }
  63517. ,
  63518. e.prototype.writeFloat32 = function(e) {
  63519. this._flushIfNecessary(1),
  63520. this._float32s[this._position++] = e
  63521. }
  63522. ,
  63523. e.prototype.writeUint32Array = function(e) {
  63524. this._flushIfNecessary(1 + e.length),
  63525. this._uint32s[this._position++] = e.length,
  63526. this._uint32s.set(e, this._position),
  63527. this._position += e.length
  63528. }
  63529. ,
  63530. e.prototype.writeInt32Array = function(e) {
  63531. this._flushIfNecessary(1 + e.length),
  63532. this._uint32s[this._position++] = e.length,
  63533. this._int32s.set(e, this._position),
  63534. this._position += e.length
  63535. }
  63536. ,
  63537. e.prototype.writeFloat32Array = function(e) {
  63538. this._flushIfNecessary(1 + e.length),
  63539. this._uint32s[this._position++] = e.length,
  63540. this._float32s.set(e, this._position),
  63541. this._position += e.length
  63542. }
  63543. ,
  63544. e.prototype.writeNativeData = function(e) {
  63545. this._flushIfNecessary(e.length),
  63546. this._uint32s.set(e, this._position),
  63547. this._position += e.length
  63548. }
  63549. ,
  63550. e.prototype.writeBoolean = function(e) {
  63551. this.writeUint32(e ? 1 : 0)
  63552. }
  63553. ,
  63554. e.prototype._flushIfNecessary = function(e) {
  63555. this._position + e > this._length && this._flush()
  63556. }
  63557. ,
  63558. e.prototype._flush = function() {
  63559. this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position),
  63560. this._position = 0
  63561. }
  63562. ,
  63563. e.DEFAULT_BUFFER_SIZE = 65536,
  63564. e
  63565. }(), Tc = function() {
  63566. function e(e, t) {
  63567. void 0 === e && (e = x.Zero()),
  63568. void 0 === t && (t = x.Up()),
  63569. this.position = e,
  63570. this.normal = t
  63571. }
  63572. return e.prototype.clone = function() {
  63573. return new e(this.position.clone(),this.normal.clone())
  63574. }
  63575. ,
  63576. e
  63577. }(), Ec = function() {
  63578. function e(e, t, i) {
  63579. void 0 === e && (e = x.Zero()),
  63580. void 0 === t && (t = x.Up()),
  63581. void 0 === i && (i = A.Zero()),
  63582. this.position = e,
  63583. this.normal = t,
  63584. this.uv = i
  63585. }
  63586. return e.prototype.clone = function() {
  63587. return new e(this.position.clone(),this.normal.clone(),this.uv.clone())
  63588. }
  63589. ,
  63590. e
  63591. }(), Sc = [Math.sqrt(1 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(3 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(15 / (4 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(5 / (16 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(15 / (16 * Math.PI))], Ac = [function() {
  63592. return 1
  63593. }
  63594. , function(e) {
  63595. return e.y
  63596. }
  63597. , function(e) {
  63598. return e.z
  63599. }
  63600. , function(e) {
  63601. return e.x
  63602. }
  63603. , function(e) {
  63604. return e.x * e.y
  63605. }
  63606. , function(e) {
  63607. return e.y * e.z
  63608. }
  63609. , function(e) {
  63610. return 3 * e.z * e.z - 1
  63611. }
  63612. , function(e) {
  63613. return e.x * e.z
  63614. }
  63615. , function(e) {
  63616. return e.x * e.x - e.y * e.y
  63617. }
  63618. ], xc = function(e, t) {
  63619. return Sc[e] * Ac[e](t)
  63620. }, Rc = [Math.PI, 2 * Math.PI / 3, 2 * Math.PI / 3, 2 * Math.PI / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4], Cc = function() {
  63621. function e() {
  63622. this.preScaled = !1,
  63623. this.l00 = x.Zero(),
  63624. this.l1_1 = x.Zero(),
  63625. this.l10 = x.Zero(),
  63626. this.l11 = x.Zero(),
  63627. this.l2_2 = x.Zero(),
  63628. this.l2_1 = x.Zero(),
  63629. this.l20 = x.Zero(),
  63630. this.l21 = x.Zero(),
  63631. this.l22 = x.Zero()
  63632. }
  63633. return e.prototype.addLight = function(e, t, i) {
  63634. I.Vector3[0].set(t.r, t.g, t.b);
  63635. var n = I.Vector3[0]
  63636. , r = I.Vector3[1];
  63637. n.scaleToRef(i, r),
  63638. r.scaleToRef(xc(0, e), I.Vector3[2]),
  63639. this.l00.addInPlace(I.Vector3[2]),
  63640. r.scaleToRef(xc(1, e), I.Vector3[2]),
  63641. this.l1_1.addInPlace(I.Vector3[2]),
  63642. r.scaleToRef(xc(2, e), I.Vector3[2]),
  63643. this.l10.addInPlace(I.Vector3[2]),
  63644. r.scaleToRef(xc(3, e), I.Vector3[2]),
  63645. this.l11.addInPlace(I.Vector3[2]),
  63646. r.scaleToRef(xc(4, e), I.Vector3[2]),
  63647. this.l2_2.addInPlace(I.Vector3[2]),
  63648. r.scaleToRef(xc(5, e), I.Vector3[2]),
  63649. this.l2_1.addInPlace(I.Vector3[2]),
  63650. r.scaleToRef(xc(6, e), I.Vector3[2]),
  63651. this.l20.addInPlace(I.Vector3[2]),
  63652. r.scaleToRef(xc(7, e), I.Vector3[2]),
  63653. this.l21.addInPlace(I.Vector3[2]),
  63654. r.scaleToRef(xc(8, e), I.Vector3[2]),
  63655. this.l22.addInPlace(I.Vector3[2])
  63656. }
  63657. ,
  63658. e.prototype.scaleInPlace = function(e) {
  63659. this.l00.scaleInPlace(e),
  63660. this.l1_1.scaleInPlace(e),
  63661. this.l10.scaleInPlace(e),
  63662. this.l11.scaleInPlace(e),
  63663. this.l2_2.scaleInPlace(e),
  63664. this.l2_1.scaleInPlace(e),
  63665. this.l20.scaleInPlace(e),
  63666. this.l21.scaleInPlace(e),
  63667. this.l22.scaleInPlace(e)
  63668. }
  63669. ,
  63670. e.prototype.convertIncidentRadianceToIrradiance = function() {
  63671. this.l00.scaleInPlace(Rc[0]),
  63672. this.l1_1.scaleInPlace(Rc[1]),
  63673. this.l10.scaleInPlace(Rc[2]),
  63674. this.l11.scaleInPlace(Rc[3]),
  63675. this.l2_2.scaleInPlace(Rc[4]),
  63676. this.l2_1.scaleInPlace(Rc[5]),
  63677. this.l20.scaleInPlace(Rc[6]),
  63678. this.l21.scaleInPlace(Rc[7]),
  63679. this.l22.scaleInPlace(Rc[8])
  63680. }
  63681. ,
  63682. e.prototype.convertIrradianceToLambertianRadiance = function() {
  63683. this.scaleInPlace(1 / Math.PI)
  63684. }
  63685. ,
  63686. e.prototype.preScaleForRendering = function() {
  63687. this.preScaled = !0,
  63688. this.l00.scaleInPlace(Sc[0]),
  63689. this.l1_1.scaleInPlace(Sc[1]),
  63690. this.l10.scaleInPlace(Sc[2]),
  63691. this.l11.scaleInPlace(Sc[3]),
  63692. this.l2_2.scaleInPlace(Sc[4]),
  63693. this.l2_1.scaleInPlace(Sc[5]),
  63694. this.l20.scaleInPlace(Sc[6]),
  63695. this.l21.scaleInPlace(Sc[7]),
  63696. this.l22.scaleInPlace(Sc[8])
  63697. }
  63698. ,
  63699. e.prototype.updateFromArray = function(e) {
  63700. return x.FromArrayToRef(e[0], 0, this.l00),
  63701. x.FromArrayToRef(e[1], 0, this.l1_1),
  63702. x.FromArrayToRef(e[2], 0, this.l10),
  63703. x.FromArrayToRef(e[3], 0, this.l11),
  63704. x.FromArrayToRef(e[4], 0, this.l2_2),
  63705. x.FromArrayToRef(e[5], 0, this.l2_1),
  63706. x.FromArrayToRef(e[6], 0, this.l20),
  63707. x.FromArrayToRef(e[7], 0, this.l21),
  63708. x.FromArrayToRef(e[8], 0, this.l22),
  63709. this
  63710. }
  63711. ,
  63712. e.prototype.updateFromFloatsArray = function(e) {
  63713. return x.FromFloatsToRef(e[0], e[1], e[2], this.l00),
  63714. x.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
  63715. x.FromFloatsToRef(e[6], e[7], e[8], this.l10),
  63716. x.FromFloatsToRef(e[9], e[10], e[11], this.l11),
  63717. x.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
  63718. x.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
  63719. x.FromFloatsToRef(e[18], e[19], e[20], this.l20),
  63720. x.FromFloatsToRef(e[21], e[22], e[23], this.l21),
  63721. x.FromFloatsToRef(e[24], e[25], e[26], this.l22),
  63722. this
  63723. }
  63724. ,
  63725. e.FromArray = function(t) {
  63726. return (new e).updateFromArray(t)
  63727. }
  63728. ,
  63729. e.FromPolynomial = function(t) {
  63730. var i = new e;
  63731. return i.l00 = t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),
  63732. i.l1_1 = t.y.scale(.977204),
  63733. i.l10 = t.z.scale(.977204),
  63734. i.l11 = t.x.scale(.977204),
  63735. i.l2_2 = t.xy.scale(1.16538),
  63736. i.l2_1 = t.yz.scale(1.16538),
  63737. i.l20 = t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),
  63738. i.l21 = t.zx.scale(1.16538),
  63739. i.l22 = t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),
  63740. i.l1_1.scaleInPlace(-1),
  63741. i.l11.scaleInPlace(-1),
  63742. i.l2_1.scaleInPlace(-1),
  63743. i.l21.scaleInPlace(-1),
  63744. i.scaleInPlace(Math.PI),
  63745. i
  63746. }
  63747. ,
  63748. e
  63749. }(), Pc = function() {
  63750. function e() {
  63751. this.x = x.Zero(),
  63752. this.y = x.Zero(),
  63753. this.z = x.Zero(),
  63754. this.xx = x.Zero(),
  63755. this.yy = x.Zero(),
  63756. this.zz = x.Zero(),
  63757. this.xy = x.Zero(),
  63758. this.yz = x.Zero(),
  63759. this.zx = x.Zero()
  63760. }
  63761. return Object.defineProperty(e.prototype, "preScaledHarmonics", {
  63762. get: function() {
  63763. return this._harmonics || (this._harmonics = Cc.FromPolynomial(this)),
  63764. this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
  63765. this._harmonics
  63766. },
  63767. enumerable: !1,
  63768. configurable: !0
  63769. }),
  63770. e.prototype.addAmbient = function(e) {
  63771. I.Vector3[0].copyFromFloats(e.r, e.g, e.b);
  63772. var t = I.Vector3[0];
  63773. this.xx.addInPlace(t),
  63774. this.yy.addInPlace(t),
  63775. this.zz.addInPlace(t)
  63776. }
  63777. ,
  63778. e.prototype.scaleInPlace = function(e) {
  63779. this.x.scaleInPlace(e),
  63780. this.y.scaleInPlace(e),
  63781. this.z.scaleInPlace(e),
  63782. this.xx.scaleInPlace(e),
  63783. this.yy.scaleInPlace(e),
  63784. this.zz.scaleInPlace(e),
  63785. this.yz.scaleInPlace(e),
  63786. this.zx.scaleInPlace(e),
  63787. this.xy.scaleInPlace(e)
  63788. }
  63789. ,
  63790. e.prototype.updateFromHarmonics = function(e) {
  63791. return this._harmonics = e,
  63792. this.x.copyFrom(e.l11),
  63793. this.x.scaleInPlace(1.02333).scaleInPlace(-1),
  63794. this.y.copyFrom(e.l1_1),
  63795. this.y.scaleInPlace(1.02333).scaleInPlace(-1),
  63796. this.z.copyFrom(e.l10),
  63797. this.z.scaleInPlace(1.02333),
  63798. this.xx.copyFrom(e.l00),
  63799. I.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
  63800. I.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
  63801. this.xx.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).addInPlace(I.Vector3[1]),
  63802. this.yy.copyFrom(e.l00),
  63803. this.yy.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).subtractInPlace(I.Vector3[1]),
  63804. this.zz.copyFrom(e.l00),
  63805. I.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
  63806. this.zz.scaleInPlace(.886277).addInPlace(I.Vector3[0]),
  63807. this.yz.copyFrom(e.l2_1),
  63808. this.yz.scaleInPlace(.858086).scaleInPlace(-1),
  63809. this.zx.copyFrom(e.l21),
  63810. this.zx.scaleInPlace(.858086).scaleInPlace(-1),
  63811. this.xy.copyFrom(e.l2_2),
  63812. this.xy.scaleInPlace(.858086),
  63813. this.scaleInPlace(1 / Math.PI),
  63814. this
  63815. }
  63816. ,
  63817. e.FromHarmonics = function(t) {
  63818. return (new e).updateFromHarmonics(t)
  63819. }
  63820. ,
  63821. e.FromArray = function(t) {
  63822. var i = new e;
  63823. return x.FromArrayToRef(t[0], 0, i.x),
  63824. x.FromArrayToRef(t[1], 0, i.y),
  63825. x.FromArrayToRef(t[2], 0, i.z),
  63826. x.FromArrayToRef(t[3], 0, i.xx),
  63827. x.FromArrayToRef(t[4], 0, i.yy),
  63828. x.FromArrayToRef(t[5], 0, i.zz),
  63829. x.FromArrayToRef(t[6], 0, i.yz),
  63830. x.FromArrayToRef(t[7], 0, i.zx),
  63831. x.FromArrayToRef(t[8], 0, i.xy),
  63832. i
  63833. }
  63834. ,
  63835. e
  63836. }();
  63837. function Mc(e, t, i, n) {
  63838. void 0 === n && (n = !0);
  63839. var r = e.getScene()
  63840. , o = r.getEngine()
  63841. , s = new ns("resized" + e.name,{
  63842. width: t,
  63843. height: i
  63844. },r,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);
  63845. s.wrapU = e.wrapU,
  63846. s.wrapV = e.wrapV,
  63847. s.uOffset = e.uOffset,
  63848. s.vOffset = e.vOffset,
  63849. s.uScale = e.uScale,
  63850. s.vScale = e.vScale,
  63851. s.uAng = e.uAng,
  63852. s.vAng = e.vAng,
  63853. s.wAng = e.wAng,
  63854. s.coordinatesIndex = e.coordinatesIndex,
  63855. s.level = e.level,
  63856. s.anisotropicFilteringLevel = e.anisotropicFilteringLevel,
  63857. s._texture.isReady = !1,
  63858. e.wrapU = io.CLAMP_ADDRESSMODE,
  63859. e.wrapV = io.CLAMP_ADDRESSMODE;
  63860. var l = new Ua("pass",1,null,n ? io.BILINEAR_SAMPLINGMODE : io.NEAREST_SAMPLINGMODE,o,!1,a.TEXTURETYPE_UNSIGNED_INT);
  63861. return l.externalTextureSamplerBinding = !0,
  63862. l.getEffect().executeWhenCompiled((function() {
  63863. l.onApply = function(t) {
  63864. t.setTexture("textureSampler", e)
  63865. }
  63866. ;
  63867. var t = s.renderTarget;
  63868. t && (r.postProcessManager.directRender([l], t),
  63869. o.unBindFramebuffer(t),
  63870. s.disposeFramebufferObjects(),
  63871. l.dispose(),
  63872. s.getInternalTexture().isReady = !0)
  63873. }
  63874. )),
  63875. s
  63876. }
  63877. function Ic(e, t, i, n, r, o) {
  63878. var s = t.getEngine();
  63879. return t.isReady = !1,
  63880. r = null != r ? r : t.samplingMode,
  63881. n = null != n ? n : t.type,
  63882. o = null != o ? o : t.format,
  63883. -1 === n && (n = a.TEXTURETYPE_UNSIGNED_BYTE),
  63884. new Promise((function(l) {
  63885. var c = new Ba("postprocess",e,null,null,1,null,r,s,!1,void 0,n,void 0,null,!1,o);
  63886. c.externalTextureSamplerBinding = !0;
  63887. var u = s.createRenderTargetTexture({
  63888. width: t.width,
  63889. height: t.height
  63890. }, {
  63891. generateDepthBuffer: !1,
  63892. generateMipMaps: !1,
  63893. generateStencilBuffer: !1,
  63894. samplingMode: r,
  63895. type: n,
  63896. format: o
  63897. });
  63898. c.getEffect().executeWhenCompiled((function() {
  63899. c.onApply = function(e) {
  63900. e._bindTexture("textureSampler", t),
  63901. e.setFloat2("scale", 1, 1)
  63902. }
  63903. ,
  63904. i.postProcessManager.directRender([c], u, !0),
  63905. s.restoreDefaultFramebuffer(),
  63906. s._releaseTexture(t),
  63907. c && c.dispose(),
  63908. u._swapAndDie(t),
  63909. t.type = n,
  63910. t.format = a.TEXTUREFORMAT_RGBA,
  63911. t.isReady = !0,
  63912. l(t)
  63913. }
  63914. ))
  63915. }
  63916. ))
  63917. }
  63918. function Oc(e) {
  63919. vc || (vc = new Float32Array(1),
  63920. yc = new Int32Array(vc.buffer)),
  63921. vc[0] = e;
  63922. var t = yc[0]
  63923. , i = t >> 16 & 32768
  63924. , n = t >> 12 & 2047
  63925. , r = t >> 23 & 255;
  63926. return r < 103 ? i : r > 142 ? (i |= 31744,
  63927. i |= (255 == r ? 0 : 1) && 8388607 & t) : r < 113 ? i |= ((n |= 2048) >> 114 - r) + (n >> 113 - r & 1) : (i |= r - 112 << 10 | n >> 1,
  63928. i += 1 & n)
  63929. }
  63930. function Dc(e) {
  63931. var t = (32768 & e) >> 15
  63932. , i = (31744 & e) >> 10
  63933. , n = 1023 & e;
  63934. return 0 === i ? (t ? -1 : 1) * Math.pow(2, -14) * (n / Math.pow(2, 10)) : 31 == i ? n ? NaN : 1 / 0 * (t ? -1 : 1) : (t ? -1 : 1) * Math.pow(2, i - 15) * (1 + n / Math.pow(2, 10))
  63935. }
  63936. Pt.ShadersStore.rgbdDecodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";
  63937. var Nc = {
  63938. CreateResizedCopy: Mc,
  63939. ApplyPostProcess: Ic,
  63940. ToHalfFloat: Oc,
  63941. FromHalfFloat: Dc
  63942. }
  63943. , Lc = function() {
  63944. function e() {}
  63945. return e.ExpandRGBDTexture = function(e) {
  63946. var t = e._texture;
  63947. if (t && e.isRGBD) {
  63948. var i = t.getEngine()
  63949. , n = i.getCaps()
  63950. , r = t.isReady
  63951. , o = !1;
  63952. n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? (o = !0,
  63953. t.type = a.TEXTURETYPE_HALF_FLOAT) : n.textureFloatRender && n.textureFloatLinearFiltering && (o = !0,
  63954. t.type = a.TEXTURETYPE_FLOAT),
  63955. o && (t.isReady = !1,
  63956. t._isRGBD = !1,
  63957. t.invertY = !1);
  63958. var s = function() {
  63959. if (o) {
  63960. var n = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1);
  63961. n.externalTextureSamplerBinding = !0;
  63962. var r = i.createRenderTargetTexture(t.width, {
  63963. generateDepthBuffer: !1,
  63964. generateMipMaps: !1,
  63965. generateStencilBuffer: !1,
  63966. samplingMode: t.samplingMode,
  63967. type: t.type,
  63968. format: a.TEXTUREFORMAT_RGBA
  63969. });
  63970. n.getEffect().executeWhenCompiled((function() {
  63971. n.onApply = function(e) {
  63972. e._bindTexture("textureSampler", t),
  63973. e.setFloat2("scale", 1, 1)
  63974. }
  63975. ,
  63976. e.getScene().postProcessManager.directRender([n], r, !0),
  63977. i.restoreDefaultFramebuffer(),
  63978. i._releaseTexture(t),
  63979. n && n.dispose(),
  63980. r._swapAndDie(t),
  63981. t.isReady = !0
  63982. }
  63983. ))
  63984. }
  63985. };
  63986. r ? s() : e.onLoadObservable.addOnce(s)
  63987. }
  63988. }
  63989. ,
  63990. e.EncodeTextureToRGBD = function(e, t, i) {
  63991. return void 0 === i && (i = a.TEXTURETYPE_UNSIGNED_BYTE),
  63992. Ic("rgbdEncode", e, t, i, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTUREFORMAT_RGBA)
  63993. }
  63994. ,
  63995. e
  63996. }()
  63997. , Fc = function(e, t, i, n) {
  63998. this.name = e,
  63999. this.worldAxisForNormal = t,
  64000. this.worldAxisForFileX = i,
  64001. this.worldAxisForFileY = n
  64002. }
  64003. , wc = function() {
  64004. function e() {}
  64005. return e.ConvertCubeMapTextureToSphericalPolynomial = function(e) {
  64006. var t, i = this;
  64007. if (!e.isCube)
  64008. return null;
  64009. null === (t = e.getScene()) || void 0 === t || t.getEngine().flushFramebuffer();
  64010. var n, r, o = e.getSize().width, s = e.readPixels(0, void 0, void 0, !1), l = e.readPixels(1, void 0, void 0, !1);
  64011. e.isRenderTarget ? (n = e.readPixels(3, void 0, void 0, !1),
  64012. r = e.readPixels(2, void 0, void 0, !1)) : (n = e.readPixels(2, void 0, void 0, !1),
  64013. r = e.readPixels(3, void 0, void 0, !1));
  64014. var c = e.readPixels(4, void 0, void 0, !1)
  64015. , u = e.readPixels(5, void 0, void 0, !1)
  64016. , h = e.gammaSpace
  64017. , d = a.TEXTUREFORMAT_RGBA
  64018. , p = a.TEXTURETYPE_UNSIGNED_INT;
  64019. return e.textureType != a.TEXTURETYPE_FLOAT && e.textureType != a.TEXTURETYPE_HALF_FLOAT || (p = a.TEXTURETYPE_FLOAT),
  64020. new Promise((function(e) {
  64021. Promise.all([l, s, n, r, c, u]).then((function(t) {
  64022. var n = t[0]
  64023. , r = t[1]
  64024. , a = t[2]
  64025. , s = t[3]
  64026. , l = t[4]
  64027. , c = t[5]
  64028. , u = {
  64029. size: o,
  64030. right: r,
  64031. left: n,
  64032. up: a,
  64033. down: s,
  64034. front: l,
  64035. back: c,
  64036. format: d,
  64037. type: p,
  64038. gammaSpace: h
  64039. };
  64040. e(i.ConvertCubeMapToSphericalPolynomial(u))
  64041. }
  64042. ))
  64043. }
  64044. ))
  64045. }
  64046. ,
  64047. e._AreaElement = function(e, t) {
  64048. return Math.atan2(e * t, Math.sqrt(e * e + t * t + 1))
  64049. }
  64050. ,
  64051. e.ConvertCubeMapToSphericalPolynomial = function(e) {
  64052. for (var t = new Cc, i = 0, n = 2 / e.size, r = n, o = .5 * n, s = o - 1, l = 0; l < 6; l++)
  64053. for (var c = this._FileFaces[l], u = e[c.name], h = s, p = e.format === a.TEXTUREFORMAT_RGBA ? 4 : 3, _ = 0; _ < e.size; _++) {
  64054. for (var m = s, g = 0; g < e.size; g++) {
  64055. var v = c.worldAxisForFileX.scale(m).add(c.worldAxisForFileY.scale(h)).add(c.worldAxisForNormal);
  64056. v.normalize();
  64057. var y = this._AreaElement(m - o, h - o) - this._AreaElement(m - o, h + o) - this._AreaElement(m + o, h - o) + this._AreaElement(m + o, h + o)
  64058. , b = u[_ * e.size * p + g * p + 0]
  64059. , T = u[_ * e.size * p + g * p + 1]
  64060. , E = u[_ * e.size * p + g * p + 2];
  64061. isNaN(b) && (b = 0),
  64062. isNaN(T) && (T = 0),
  64063. isNaN(E) && (E = 0),
  64064. e.type === a.TEXTURETYPE_UNSIGNED_INT && (b /= 255,
  64065. T /= 255,
  64066. E /= 255),
  64067. e.gammaSpace && (b = Math.pow(d.Clamp(b), f),
  64068. T = Math.pow(d.Clamp(T), f),
  64069. E = Math.pow(d.Clamp(E), f));
  64070. var S = 4096;
  64071. b = d.Clamp(b, 0, S),
  64072. T = d.Clamp(T, 0, S),
  64073. E = d.Clamp(E, 0, S);
  64074. var A = new D(b,T,E);
  64075. t.addLight(v, A, y),
  64076. i += y,
  64077. m += n
  64078. }
  64079. h += r
  64080. }
  64081. var x = 4 * Math.PI * 6 / 6 / i;
  64082. return t.scaleInPlace(x),
  64083. t.convertIncidentRadianceToIrradiance(),
  64084. t.convertIrradianceToLambertianRadiance(),
  64085. Pc.FromHarmonics(t)
  64086. }
  64087. ,
  64088. e._FileFaces = [new Fc("right",new x(1,0,0),new x(0,0,-1),new x(0,-1,0)), new Fc("left",new x(-1,0,0),new x(0,0,1),new x(0,-1,0)), new Fc("up",new x(0,1,0),new x(1,0,0),new x(0,0,1)), new Fc("down",new x(0,-1,0),new x(1,0,0),new x(0,0,-1)), new Fc("front",new x(0,0,1),new x(1,0,0),new x(0,-1,0)), new Fc("back",new x(0,0,-1),new x(-1,0,0),new x(0,-1,0))],
  64089. e
  64090. }();
  64091. Zr.prototype.forceSphericalPolynomialsRecompute = function() {
  64092. this._texture && (this._texture._sphericalPolynomial = null,
  64093. this._texture._sphericalPolynomialPromise = null,
  64094. this._texture._sphericalPolynomialComputed = !1)
  64095. }
  64096. ,
  64097. Object.defineProperty(Zr.prototype, "sphericalPolynomial", {
  64098. get: function() {
  64099. var e = this;
  64100. if (this._texture) {
  64101. if (this._texture._sphericalPolynomial || this._texture._sphericalPolynomialComputed)
  64102. return this._texture._sphericalPolynomial;
  64103. if (this._texture.isReady)
  64104. return this._texture._sphericalPolynomialPromise || (this._texture._sphericalPolynomialPromise = wc.ConvertCubeMapTextureToSphericalPolynomial(this),
  64105. null === this._texture._sphericalPolynomialPromise ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then((function(t) {
  64106. e._texture._sphericalPolynomial = t,
  64107. e._texture._sphericalPolynomialComputed = !0
  64108. }
  64109. ))),
  64110. null
  64111. }
  64112. return null
  64113. },
  64114. set: function(e) {
  64115. this._texture && (this._texture._sphericalPolynomial = e)
  64116. },
  64117. enumerable: !0,
  64118. configurable: !0
  64119. });
  64120. Pt.ShadersStore.rgbdEncodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  64121. var Bc = "image/png"
  64122. , Uc = [134, 22, 135, 150, 246, 214, 150, 54];
  64123. function Vc(e) {
  64124. for (var t = new DataView(e.buffer,e.byteOffset,e.byteLength), i = 0, n = 0; n < Uc.length; n++)
  64125. if (t.getUint8(i++) !== Uc[n])
  64126. return K.Error("Not a babylon environment map"),
  64127. null;
  64128. for (var r = "", o = 0; o = t.getUint8(i++); )
  64129. r += String.fromCharCode(o);
  64130. var a = JSON.parse(r);
  64131. return (a = kc(a)).specular && (a.specular.specularDataPosition = i,
  64132. a.specular.lodGenerationScale = a.specular.lodGenerationScale || .8),
  64133. a
  64134. }
  64135. function kc(e) {
  64136. if (e.version > 2)
  64137. throw new Error('Unsupported babylon environment map version "'.concat(e.version, '". Latest supported version is "').concat(2, '".'));
  64138. return 2 === e.version ? e : e = V(V({}, e), {
  64139. version: 2,
  64140. imageType: Bc
  64141. })
  64142. }
  64143. function Gc(e, t) {
  64144. var i;
  64145. return void 0 === t && (t = {}),
  64146. G(this, void 0, void 0, (function() {
  64147. var n, r, o, s, l, c, u, h, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L;
  64148. return z(this, (function(F) {
  64149. switch (F.label) {
  64150. case 0:
  64151. if (!(n = e.getInternalTexture()))
  64152. return [2, Promise.reject("The cube texture is invalid.")];
  64153. if (r = null !== (i = t.imageType) && void 0 !== i ? i : Bc,
  64154. o = n.getEngine(),
  64155. e.textureType !== a.TEXTURETYPE_HALF_FLOAT && e.textureType !== a.TEXTURETYPE_FLOAT && e.textureType !== a.TEXTURETYPE_UNSIGNED_BYTE && e.textureType !== a.TEXTURETYPE_UNSIGNED_INT && e.textureType !== a.TEXTURETYPE_UNSIGNED_INTEGER && -1 !== e.textureType)
  64156. return [2, Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];
  64157. if (s = a.TEXTURETYPE_FLOAT,
  64158. !o.getCaps().textureFloatRender && (s = a.TEXTURETYPE_HALF_FLOAT,
  64159. !o.getCaps().textureHalfFloatRender))
  64160. return [2, Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];
  64161. l = n.width,
  64162. c = new mn(o),
  64163. u = {},
  64164. o.flushFramebuffer(),
  64165. h = d.ILog2(n.width),
  64166. D = 0,
  64167. F.label = 1;
  64168. case 1:
  64169. if (!(D <= h))
  64170. return [3, 9];
  64171. p = Math.pow(2, h - D),
  64172. N = 0,
  64173. F.label = 2;
  64174. case 2:
  64175. return N < 6 ? [4, e.readPixels(N, D, void 0, !1)] : [3, 8];
  64176. case 3:
  64177. if ((f = F.sent()) && f.byteLength === f.length) {
  64178. for (_ = new Float32Array(4 * f.byteLength),
  64179. m = 0; m < f.byteLength; m++)
  64180. _[m] = f[m] / 255,
  64181. _[m] = Math.pow(_[m], 2.2);
  64182. f = _
  64183. }
  64184. return g = o.createRawTexture(f, p, p, a.TEXTUREFORMAT_RGBA, !1, !0, a.TEXTURE_NEAREST_SAMPLINGMODE, null, s),
  64185. [4, Lc.EncodeTextureToRGBD(g, c, s)];
  64186. case 4:
  64187. return F.sent(),
  64188. [4, o._readTexturePixels(g, p, p)];
  64189. case 5:
  64190. return v = F.sent(),
  64191. [4, gi.DumpDataAsync(p, p, v, r, void 0, !1, !0, t.imageQuality)];
  64192. case 6:
  64193. y = F.sent(),
  64194. u[6 * D + N] = y,
  64195. g.dispose(),
  64196. F.label = 7;
  64197. case 7:
  64198. return N++,
  64199. [3, 2];
  64200. case 8:
  64201. return D++,
  64202. [3, 1];
  64203. case 9:
  64204. for (c.dispose(),
  64205. b = {
  64206. version: 2,
  64207. width: l,
  64208. imageType: r,
  64209. irradiance: zc(e),
  64210. specular: {
  64211. mipmaps: [],
  64212. lodGenerationScale: e.lodGenerationScale
  64213. }
  64214. },
  64215. T = 0,
  64216. D = 0; D <= h; D++)
  64217. for (N = 0; N < 6; N++)
  64218. E = u[6 * D + N].byteLength,
  64219. b.specular.mipmaps.push({
  64220. length: E,
  64221. position: T
  64222. }),
  64223. T += E;
  64224. for (S = JSON.stringify(b),
  64225. A = new ArrayBuffer(S.length + 1),
  64226. x = new Uint8Array(A),
  64227. D = 0,
  64228. R = S.length; D < R; D++)
  64229. x[D] = S.charCodeAt(D);
  64230. for (x[S.length] = 0,
  64231. C = Uc.length + T + A.byteLength,
  64232. P = new ArrayBuffer(C),
  64233. M = new Uint8Array(P),
  64234. I = new DataView(P),
  64235. O = 0,
  64236. D = 0; D < Uc.length; D++)
  64237. I.setUint8(O++, Uc[D]);
  64238. for (M.set(new Uint8Array(A), O),
  64239. O += A.byteLength,
  64240. D = 0; D <= h; D++)
  64241. for (N = 0; N < 6; N++)
  64242. L = u[6 * D + N],
  64243. M.set(new Uint8Array(L), O),
  64244. O += L.byteLength;
  64245. return [2, P]
  64246. }
  64247. }
  64248. ))
  64249. }
  64250. ))
  64251. }
  64252. function zc(e) {
  64253. var t = e.sphericalPolynomial;
  64254. return null == t ? null : {
  64255. x: [t.x.x, t.x.y, t.x.z],
  64256. y: [t.y.x, t.y.y, t.y.z],
  64257. z: [t.z.x, t.z.y, t.z.z],
  64258. xx: [t.xx.x, t.xx.y, t.xx.z],
  64259. yy: [t.yy.x, t.yy.y, t.yy.z],
  64260. zz: [t.zz.x, t.zz.y, t.zz.z],
  64261. yz: [t.yz.x, t.yz.y, t.yz.z],
  64262. zx: [t.zx.x, t.zx.y, t.zx.z],
  64263. xy: [t.xy.x, t.xy.y, t.xy.z]
  64264. }
  64265. }
  64266. function Wc(e, t) {
  64267. var i = (t = kc(t)).specular
  64268. , n = d.Log2(t.width);
  64269. if (n = Math.round(n) + 1,
  64270. i.mipmaps.length !== 6 * n)
  64271. throw new Error('Unsupported specular mipmaps number "'.concat(i.mipmaps.length, '"'));
  64272. for (var r = new Array(n), o = 0; o < n; o++) {
  64273. r[o] = new Array(6);
  64274. for (var a = 0; a < 6; a++) {
  64275. var s = i.mipmaps[6 * o + a];
  64276. r[o][a] = new Uint8Array(e.buffer,e.byteOffset + i.specularDataPosition + s.position,s.length)
  64277. }
  64278. }
  64279. return r
  64280. }
  64281. function Hc(e, t, i) {
  64282. var n = (i = kc(i)).specular;
  64283. return n ? (e._lodGenerationScale = n.lodGenerationScale,
  64284. jc(e, Wc(t, i), i.imageType)) : Promise.resolve()
  64285. }
  64286. function Xc(e, t, i, n, r, o, s, l, c, u, h) {
  64287. return new Promise((function(d, p) {
  64288. if (i) {
  64289. var f = t.createTexture(null, !0, !0, null, a.TEXTURE_NEAREST_SAMPLINGMODE, null, (function(e) {
  64290. p(e)
  64291. }
  64292. ), e);
  64293. n.getEffect().executeWhenCompiled((function() {
  64294. n.externalTextureSamplerBinding = !0,
  64295. n.onApply = function(i) {
  64296. i._bindTexture("textureSampler", f),
  64297. i.setFloat2("scale", 1, t._features.needsInvertingBitmap && e instanceof ImageBitmap ? -1 : 1)
  64298. }
  64299. ,
  64300. t.scenes.length && (t.scenes[0].postProcessManager.directRender([n], u, !0, o, s),
  64301. t.restoreDefaultFramebuffer(),
  64302. f.dispose(),
  64303. URL.revokeObjectURL(r),
  64304. d())
  64305. }
  64306. ))
  64307. } else {
  64308. if (t._uploadImageToTexture(h, e, o, s),
  64309. l) {
  64310. var _ = c[s];
  64311. _ && t._uploadImageToTexture(_._texture, e, o, 0)
  64312. }
  64313. d()
  64314. }
  64315. }
  64316. ))
  64317. }
  64318. function jc(e, t, i) {
  64319. if (void 0 === i && (i = Bc),
  64320. !gi.IsExponentOfTwo(e.width))
  64321. throw new Error("Texture size must be a power of two");
  64322. var n = d.ILog2(e.width) + 1
  64323. , r = e.getEngine()
  64324. , o = !1
  64325. , s = !1
  64326. , l = null
  64327. , c = null
  64328. , u = null
  64329. , h = r.getCaps();
  64330. if (e.format = a.TEXTUREFORMAT_RGBA,
  64331. e.type = a.TEXTURETYPE_UNSIGNED_INT,
  64332. e.generateMipMaps = !0,
  64333. e._cachedAnisotropicFilteringLevel = null,
  64334. r.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, e),
  64335. h.textureLOD ? r._features.supportRenderAndCopyToLodForFloatTextures ? h.textureHalfFloatRender && h.textureHalfFloatLinearFiltering ? (o = !0,
  64336. e.type = a.TEXTURETYPE_HALF_FLOAT) : h.textureFloatRender && h.textureFloatLinearFiltering && (o = !0,
  64337. e.type = a.TEXTURETYPE_FLOAT) : o = !1 : (o = !1,
  64338. s = !0,
  64339. u = {}),
  64340. o)
  64341. l = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,r,!1,void 0,e.type,void 0,null,!1),
  64342. e._isRGBD = !1,
  64343. e.invertY = !1,
  64344. c = r.createRenderTargetCubeTexture(e.width, {
  64345. generateDepthBuffer: !1,
  64346. generateMipMaps: !0,
  64347. generateStencilBuffer: !1,
  64348. samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  64349. type: e.type,
  64350. format: a.TEXTUREFORMAT_RGBA
  64351. });
  64352. else if (e._isRGBD = !0,
  64353. e.invertY = !0,
  64354. s)
  64355. for (var p = e._lodGenerationScale, f = e._lodGenerationOffset, _ = 0; _ < 3; _++) {
  64356. var m = (n - 1) * p + f
  64357. , g = f + (m - f) * (1 - _ / 2)
  64358. , v = Math.round(Math.min(Math.max(g, 0), m))
  64359. , y = new Lt(r,At.Temp);
  64360. y.isCube = !0,
  64361. y.invertY = !0,
  64362. y.generateMipMaps = !1,
  64363. r.updateTextureSamplingMode(a.TEXTURE_LINEAR_LINEAR, y);
  64364. var b = new Zr(null);
  64365. switch (b.isCube = !0,
  64366. b._texture = y,
  64367. u[v] = b,
  64368. _) {
  64369. case 0:
  64370. e._lodTextureLow = b;
  64371. break;
  64372. case 1:
  64373. e._lodTextureMid = b;
  64374. break;
  64375. case 2:
  64376. e._lodTextureHigh = b
  64377. }
  64378. }
  64379. var T = []
  64380. , E = function(n) {
  64381. for (var a = function(a) {
  64382. var h = t[n][a]
  64383. , d = new Blob([h],{
  64384. type: i
  64385. })
  64386. , p = URL.createObjectURL(d)
  64387. , f = void 0;
  64388. if ("undefined" == typeof Image || r._features.forceBitmapOverHTMLImageElement)
  64389. f = r.createImageBitmap(d, {
  64390. premultiplyAlpha: "none"
  64391. }).then((function(t) {
  64392. return Xc(t, r, o, l, p, a, n, s, u, c, e)
  64393. }
  64394. ));
  64395. else {
  64396. var _ = new Image;
  64397. _.src = p,
  64398. f = new Promise((function(t, i) {
  64399. _.onload = function() {
  64400. Xc(_, r, o, l, p, a, n, s, u, c, e).then((function() {
  64401. return t()
  64402. }
  64403. )).catch((function(e) {
  64404. i(e)
  64405. }
  64406. ))
  64407. }
  64408. ,
  64409. _.onerror = function(e) {
  64410. i(e)
  64411. }
  64412. }
  64413. ))
  64414. }
  64415. T.push(f)
  64416. }, h = 0; h < 6; h++)
  64417. a(h)
  64418. };
  64419. for (_ = 0; _ < t.length; _++)
  64420. E(_);
  64421. if (t.length < n) {
  64422. var S = void 0
  64423. , A = Math.pow(2, n - 1 - t.length)
  64424. , x = A * A * 4;
  64425. switch (e.type) {
  64426. case a.TEXTURETYPE_UNSIGNED_INT:
  64427. S = new Uint8Array(x);
  64428. break;
  64429. case a.TEXTURETYPE_HALF_FLOAT:
  64430. S = new Uint16Array(x);
  64431. break;
  64432. case a.TEXTURETYPE_FLOAT:
  64433. S = new Float32Array(x)
  64434. }
  64435. for (_ = t.length; _ < n; _++)
  64436. for (var R = 0; R < 6; R++)
  64437. r._uploadArrayBufferViewToTexture(e, S, R, _)
  64438. }
  64439. return Promise.all(T).then((function() {
  64440. c && (r._releaseTexture(e),
  64441. c._swapAndDie(e)),
  64442. l && l.dispose(),
  64443. s && (e._lodTextureHigh && e._lodTextureHigh._texture && (e._lodTextureHigh._texture.isReady = !0),
  64444. e._lodTextureMid && e._lodTextureMid._texture && (e._lodTextureMid._texture.isReady = !0),
  64445. e._lodTextureLow && e._lodTextureLow._texture && (e._lodTextureLow._texture.isReady = !0))
  64446. }
  64447. ))
  64448. }
  64449. function Yc(e, t) {
  64450. var i = (t = kc(t)).irradiance;
  64451. if (i) {
  64452. var n = new Pc;
  64453. x.FromArrayToRef(i.x, 0, n.x),
  64454. x.FromArrayToRef(i.y, 0, n.y),
  64455. x.FromArrayToRef(i.z, 0, n.z),
  64456. x.FromArrayToRef(i.xx, 0, n.xx),
  64457. x.FromArrayToRef(i.yy, 0, n.yy),
  64458. x.FromArrayToRef(i.zz, 0, n.zz),
  64459. x.FromArrayToRef(i.yz, 0, n.yz),
  64460. x.FromArrayToRef(i.zx, 0, n.zx),
  64461. x.FromArrayToRef(i.xy, 0, n.xy),
  64462. e._sphericalPolynomial = n
  64463. }
  64464. }
  64465. function Kc(e, t, i, n, r) {
  64466. var o = jc(e.getEngine().createRawCubeTexture(null, e.width, e.format, e.type, e.generateMipMaps, e.invertY, e.samplingMode, e._compression), t).then((function() {
  64467. return e
  64468. }
  64469. ));
  64470. return e.onRebuildCallback = function(e) {
  64471. return {
  64472. proxy: o,
  64473. isReady: !0,
  64474. isAsync: !0
  64475. }
  64476. }
  64477. ,
  64478. e._source = At.CubeRawRGBD,
  64479. e._bufferViewArrayArray = t,
  64480. e._lodGenerationScale = n,
  64481. e._lodGenerationOffset = r,
  64482. e._sphericalPolynomial = i,
  64483. jc(e, t).then((function() {
  64484. return e.isReady = !0,
  64485. e
  64486. }
  64487. ))
  64488. }
  64489. var Qc = {
  64490. GetEnvInfo: Vc,
  64491. CreateEnvTextureAsync: Gc,
  64492. CreateImageDataArrayBufferViews: Wc,
  64493. UploadEnvLevelsAsync: Hc,
  64494. UploadLevelsAsync: jc,
  64495. UploadEnvSpherical: Yc
  64496. };
  64497. function qc(e, t, i, n) {
  64498. for (var r = n, o = 0, a = ""; r < i.length; ) {
  64499. var s = i.charAt(r);
  64500. if (a)
  64501. s === a ? '"' === a || "'" === a ? "\\" !== i.charAt(r - 1) && (a = "") : a = "" : "*/" === a && "*" === s && r + 1 < i.length && ("/" === i.charAt(r + 1) && (a = ""),
  64502. "" === a && r++);
  64503. else
  64504. switch (s) {
  64505. case e:
  64506. o++;
  64507. break;
  64508. case t:
  64509. o--;
  64510. break;
  64511. case '"':
  64512. case "'":
  64513. case "`":
  64514. a = s;
  64515. break;
  64516. case "/":
  64517. if (r + 1 < i.length) {
  64518. var l = i.charAt(r + 1);
  64519. "/" === l ? a = "\n" : "*" === l && (a = "*/")
  64520. }
  64521. }
  64522. if (r++,
  64523. 0 === o)
  64524. break
  64525. }
  64526. return 0 === o ? r - 1 : -1
  64527. }
  64528. function Zc(e, t) {
  64529. for (; t < e.length; ) {
  64530. var i = e[t];
  64531. if (" " !== i && "\n" !== i && "\r" !== i && "\t" !== i && "\n" !== i && " " !== i)
  64532. break;
  64533. t++
  64534. }
  64535. return t
  64536. }
  64537. function Jc(e) {
  64538. var t = e.charCodeAt(0);
  64539. return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || 95 == t
  64540. }
  64541. function $c(e) {
  64542. for (var t = 0, i = "", n = !1, r = []; t < e.length; ) {
  64543. var o = e.charAt(t);
  64544. if (i)
  64545. o === i ? '"' === i || "'" === i ? ("\\" !== e.charAt(t - 1) && (i = ""),
  64546. r.push(o)) : (i = "",
  64547. n = !1) : "*/" === i && "*" === o && t + 1 < e.length ? ("/" === e.charAt(t + 1) && (i = ""),
  64548. "" === i && (n = !1,
  64549. t++)) : n || r.push(o);
  64550. else {
  64551. switch (o) {
  64552. case '"':
  64553. case "'":
  64554. case "`":
  64555. i = o;
  64556. break;
  64557. case "/":
  64558. if (t + 1 < e.length) {
  64559. var a = e.charAt(t + 1);
  64560. "/" === a ? (i = "\n",
  64561. n = !0) : "*" === a && (i = "*/",
  64562. n = !0)
  64563. }
  64564. }
  64565. n || r.push(o)
  64566. }
  64567. t++
  64568. }
  64569. return r.join("")
  64570. }
  64571. function eu(e, t, i) {
  64572. for (; t >= 0 && e.charAt(t) !== i; )
  64573. t--;
  64574. return t
  64575. }
  64576. var tu, iu = function() {
  64577. function e(e, t) {
  64578. void 0 === t && (t = 20),
  64579. this.debug = !1,
  64580. this._sourceCode = e,
  64581. this._numMaxIterations = t,
  64582. this._functionDescr = [],
  64583. this.inlineToken = "#define inline"
  64584. }
  64585. return Object.defineProperty(e.prototype, "code", {
  64586. get: function() {
  64587. return this._sourceCode
  64588. },
  64589. enumerable: !1,
  64590. configurable: !0
  64591. }),
  64592. e.prototype.processCode = function() {
  64593. this.debug && console.log("Start inlining process (code size=".concat(this._sourceCode.length, ")...")),
  64594. this._collectFunctions(),
  64595. this._processInlining(this._numMaxIterations),
  64596. this.debug && console.log("End of inlining process.")
  64597. }
  64598. ,
  64599. e.prototype._collectFunctions = function() {
  64600. for (var t = 0; t < this._sourceCode.length; ) {
  64601. var i = this._sourceCode.indexOf(this.inlineToken, t);
  64602. if (i < 0)
  64603. break;
  64604. var n = this._sourceCode.indexOf("(", i + this.inlineToken.length);
  64605. if (n < 0)
  64606. this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=".concat(t)),
  64607. t = i + this.inlineToken.length;
  64608. else {
  64609. var r = e._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, n));
  64610. if (r) {
  64611. var o = [r[3], r[4]]
  64612. , a = o[0]
  64613. , s = o[1]
  64614. , l = qc("(", ")", this._sourceCode, n);
  64615. if (l < 0)
  64616. this.debug && console.warn("Could not extract the parameters the function '".concat(s, "' (type=").concat(a, "). funcParamsStartIndex=").concat(n)),
  64617. t = i + this.inlineToken.length;
  64618. else {
  64619. var c = this._sourceCode.substring(n + 1, l)
  64620. , u = Zc(this._sourceCode, l + 1);
  64621. if (u !== this._sourceCode.length) {
  64622. var h = qc("{", "}", this._sourceCode, u);
  64623. if (h < 0)
  64624. this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcBodyStartIndex=").concat(u)),
  64625. t = i + this.inlineToken.length;
  64626. else {
  64627. for (var d = this._sourceCode.substring(u, h + 1), p = $c(c).split(","), f = [], _ = 0; _ < p.length; ++_) {
  64628. var m = p[_].trim()
  64629. , g = m.lastIndexOf(" ");
  64630. g >= 0 && f.push(m.substring(g + 1))
  64631. }
  64632. "void" !== a && f.push("return"),
  64633. this._functionDescr.push({
  64634. name: s,
  64635. type: a,
  64636. parameters: f,
  64637. body: d,
  64638. callIndex: 0
  64639. }),
  64640. t = h + 1;
  64641. var v = i > 0 ? this._sourceCode.substring(0, i) : ""
  64642. , y = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
  64643. this._sourceCode = v + y,
  64644. t -= h + 1 - i
  64645. }
  64646. } else
  64647. this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcParamsEndIndex=").concat(l)),
  64648. t = i + this.inlineToken.length
  64649. }
  64650. } else
  64651. this.debug && console.warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(i + this.inlineToken.length, n))),
  64652. t = i + this.inlineToken.length
  64653. }
  64654. }
  64655. this.debug && console.log("Collect functions: ".concat(this._functionDescr.length, " functions found. functionDescr="), this._functionDescr)
  64656. }
  64657. ,
  64658. e.prototype._processInlining = function(e) {
  64659. for (void 0 === e && (e = 20); e-- >= 0 && this._replaceFunctionCallsByCode(); )
  64660. ;
  64661. return this.debug && console.log("numMaxIterations is ".concat(e, " after inlining process")),
  64662. e >= 0
  64663. }
  64664. ,
  64665. e.prototype._replaceFunctionCallsByCode = function() {
  64666. for (var e = !1, t = 0, i = this._functionDescr; t < i.length; t++)
  64667. for (var n = i[t], r = n.name, o = n.type, a = n.parameters, s = n.body, l = 0; l < this._sourceCode.length; ) {
  64668. var c = this._sourceCode.indexOf(r, l);
  64669. if (c < 0)
  64670. break;
  64671. if (0 === c || Jc(this._sourceCode.charAt(c - 1)))
  64672. l = c + r.length;
  64673. else {
  64674. var u = Zc(this._sourceCode, c + r.length);
  64675. if (u !== this._sourceCode.length && "(" === this._sourceCode.charAt(u)) {
  64676. var h = qc("(", ")", this._sourceCode, u);
  64677. if (h < 0)
  64678. this.debug && console.warn("Could not extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u)),
  64679. l = c + r.length;
  64680. else {
  64681. var d = this._sourceCode.substring(u + 1, h)
  64682. , p = function(e) {
  64683. for (var t = [], i = 0, n = 0; i < e.length; ) {
  64684. if ("(" === e.charAt(i)) {
  64685. var r = qc("(", ")", e, i);
  64686. if (r < 0)
  64687. return null;
  64688. i = r
  64689. } else
  64690. "," === e.charAt(i) && (t.push(e.substring(n, i)),
  64691. n = i + 1);
  64692. i++
  64693. }
  64694. return n < i && t.push(e.substring(n, i)),
  64695. t
  64696. }($c(d));
  64697. if (null !== p) {
  64698. for (var f = [], _ = 0; _ < p.length; ++_) {
  64699. var m = p[_].trim();
  64700. f.push(m)
  64701. }
  64702. var g = "void" !== o ? r + "_" + n.callIndex++ : null;
  64703. if (g && f.push(g + " ="),
  64704. f.length === a.length) {
  64705. l = h + 1;
  64706. var v = this._replaceNames(s, a, f)
  64707. , y = c > 0 ? this._sourceCode.substring(0, c) : ""
  64708. , b = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
  64709. if (g) {
  64710. var T = eu(this._sourceCode, c - 1, "\n");
  64711. y = this._sourceCode.substring(0, T + 1);
  64712. var E = this._sourceCode.substring(T + 1, c);
  64713. this._sourceCode = y + o + " " + g + ";\n" + v + "\n" + E + g + b,
  64714. this.debug && console.log("Replace function call by code. Function '".concat(r, "' (type=").concat(o, "). injectDeclarationIndex=").concat(T, ", call parameters=").concat(f))
  64715. } else
  64716. this._sourceCode = y + v + b,
  64717. l += v.length - (h + 1 - c),
  64718. this.debug && console.log("Replace function call by code. Function '".concat(r, "' (type=").concat(o, "). functionCallIndex=").concat(c, ", call parameters=").concat(f));
  64719. e = !0
  64720. } else
  64721. this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(r, "' (type=").concat(o, "). function parameters=").concat(a, ", call parameters=").concat(f)),
  64722. l = c + r.length
  64723. } else
  64724. this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u, ", callParams=") + d),
  64725. l = c + r.length
  64726. }
  64727. } else
  64728. l = c + r.length
  64729. }
  64730. }
  64731. return e
  64732. }
  64733. ,
  64734. e.prototype._replaceNames = function(e, t, i) {
  64735. for (var n = function(n) {
  64736. var r = new RegExp(t[n].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),"g")
  64737. , o = t[n].length
  64738. , a = i[n];
  64739. e = e.replace(r, (function(i) {
  64740. for (var r = [], s = 1; s < arguments.length; s++)
  64741. r[s - 1] = arguments[s];
  64742. var l = r[0];
  64743. return Jc(e.charAt(l - 1)) || Jc(e.charAt(l + o)) ? t[n] : a
  64744. }
  64745. ))
  64746. }, r = 0; r < t.length; ++r)
  64747. n(r);
  64748. return e
  64749. }
  64750. ,
  64751. e._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/,
  64752. e
  64753. }(), nu = new h;
  64754. function ru() {
  64755. return new Promise((function(e) {
  64756. "undefined" == typeof _native ? nu.addOnce((function(t) {
  64757. return e(t)
  64758. }
  64759. )) : e(_native)
  64760. }
  64761. ))
  64762. }
  64763. function ou(e, t) {
  64764. return G(this, void 0, void 0, (function() {
  64765. return z(this, (function(i) {
  64766. switch (i.label) {
  64767. case 0:
  64768. return [4, ru()];
  64769. case 1:
  64770. return i.sent()[e] = t,
  64771. [2]
  64772. }
  64773. }
  64774. ))
  64775. }
  64776. ))
  64777. }
  64778. "undefined" == typeof self || Object.prototype.hasOwnProperty.call(self, "_native") || Object.defineProperty(self, "_native", {
  64779. get: function() {
  64780. return tu
  64781. },
  64782. set: function(e) {
  64783. (tu = e) && nu.notifyObservers(tu)
  64784. }
  64785. });
  64786. var au = function() {
  64787. function e(e) {
  64788. this.isAsync = !1,
  64789. this.isReady = !1,
  64790. this._valueCache = {},
  64791. this.engine = e
  64792. }
  64793. return e.prototype._getVertexShaderCode = function() {
  64794. return null
  64795. }
  64796. ,
  64797. e.prototype._getFragmentShaderCode = function() {
  64798. return null
  64799. }
  64800. ,
  64801. e.prototype._handlesSpectorRebuildCallback = function(e) {
  64802. throw new Error("Not implemented")
  64803. }
  64804. ,
  64805. e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
  64806. var l, c = this.engine;
  64807. if (c.supportsUniformBuffers)
  64808. for (var u in t)
  64809. e.bindUniformBlock(u, t[u]);
  64810. for (this.engine.getUniforms(this, i).forEach((function(e, t) {
  64811. n[i[t]] = e
  64812. }
  64813. )),
  64814. this._uniforms = n,
  64815. l = 0; l < r.length; l++)
  64816. null == e.getUniform(r[l]) && (r.splice(l, 1),
  64817. l--);
  64818. r.forEach((function(e, t) {
  64819. o[e] = t
  64820. }
  64821. )),
  64822. s.push.apply(s, c.getAttributes(this, a))
  64823. }
  64824. ,
  64825. e.prototype.dispose = function() {
  64826. this._uniforms = {}
  64827. }
  64828. ,
  64829. e.prototype._cacheMatrix = function(e, t) {
  64830. var i = this._valueCache[e]
  64831. , n = t.updateFlag;
  64832. return (void 0 === i || i !== n) && (this._valueCache[e] = n,
  64833. !0)
  64834. }
  64835. ,
  64836. e.prototype._cacheFloat2 = function(e, t, i) {
  64837. var n = this._valueCache[e];
  64838. if (!n)
  64839. return n = [t, i],
  64840. this._valueCache[e] = n,
  64841. !0;
  64842. var r = !1;
  64843. return n[0] !== t && (n[0] = t,
  64844. r = !0),
  64845. n[1] !== i && (n[1] = i,
  64846. r = !0),
  64847. r
  64848. }
  64849. ,
  64850. e.prototype._cacheFloat3 = function(e, t, i, n) {
  64851. var r = this._valueCache[e];
  64852. if (!r)
  64853. return r = [t, i, n],
  64854. this._valueCache[e] = r,
  64855. !0;
  64856. var o = !1;
  64857. return r[0] !== t && (r[0] = t,
  64858. o = !0),
  64859. r[1] !== i && (r[1] = i,
  64860. o = !0),
  64861. r[2] !== n && (r[2] = n,
  64862. o = !0),
  64863. o
  64864. }
  64865. ,
  64866. e.prototype._cacheFloat4 = function(e, t, i, n, r) {
  64867. var o = this._valueCache[e];
  64868. if (!o)
  64869. return o = [t, i, n, r],
  64870. this._valueCache[e] = o,
  64871. !0;
  64872. var a = !1;
  64873. return o[0] !== t && (o[0] = t,
  64874. a = !0),
  64875. o[1] !== i && (o[1] = i,
  64876. a = !0),
  64877. o[2] !== n && (o[2] = n,
  64878. a = !0),
  64879. o[3] !== r && (o[3] = r,
  64880. a = !0),
  64881. a
  64882. }
  64883. ,
  64884. e.prototype.setInt = function(e, t) {
  64885. var i = this._valueCache[e];
  64886. void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t)
  64887. }
  64888. ,
  64889. e.prototype.setInt2 = function(e, t, i) {
  64890. this._cacheFloat2(e, t, i) && (this.engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
  64891. }
  64892. ,
  64893. e.prototype.setInt3 = function(e, t, i, n) {
  64894. this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
  64895. }
  64896. ,
  64897. e.prototype.setInt4 = function(e, t, i, n, r) {
  64898. this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
  64899. }
  64900. ,
  64901. e.prototype.setIntArray = function(e, t) {
  64902. this._valueCache[e] = null,
  64903. this.engine.setIntArray(this._uniforms[e], t)
  64904. }
  64905. ,
  64906. e.prototype.setIntArray2 = function(e, t) {
  64907. this._valueCache[e] = null,
  64908. this.engine.setIntArray2(this._uniforms[e], t)
  64909. }
  64910. ,
  64911. e.prototype.setIntArray3 = function(e, t) {
  64912. this._valueCache[e] = null,
  64913. this.engine.setIntArray3(this._uniforms[e], t)
  64914. }
  64915. ,
  64916. e.prototype.setIntArray4 = function(e, t) {
  64917. this._valueCache[e] = null,
  64918. this.engine.setIntArray4(this._uniforms[e], t)
  64919. }
  64920. ,
  64921. e.prototype.setFloatArray = function(e, t) {
  64922. this._valueCache[e] = null,
  64923. this.engine.setFloatArray(this._uniforms[e], t)
  64924. }
  64925. ,
  64926. e.prototype.setFloatArray2 = function(e, t) {
  64927. this._valueCache[e] = null,
  64928. this.engine.setFloatArray2(this._uniforms[e], t)
  64929. }
  64930. ,
  64931. e.prototype.setFloatArray3 = function(e, t) {
  64932. this._valueCache[e] = null,
  64933. this.engine.setFloatArray3(this._uniforms[e], t)
  64934. }
  64935. ,
  64936. e.prototype.setFloatArray4 = function(e, t) {
  64937. this._valueCache[e] = null,
  64938. this.engine.setFloatArray4(this._uniforms[e], t)
  64939. }
  64940. ,
  64941. e.prototype.setArray = function(e, t) {
  64942. this._valueCache[e] = null,
  64943. this.engine.setArray(this._uniforms[e], t)
  64944. }
  64945. ,
  64946. e.prototype.setArray2 = function(e, t) {
  64947. this._valueCache[e] = null,
  64948. this.engine.setArray2(this._uniforms[e], t)
  64949. }
  64950. ,
  64951. e.prototype.setArray3 = function(e, t) {
  64952. this._valueCache[e] = null,
  64953. this.engine.setArray3(this._uniforms[e], t)
  64954. }
  64955. ,
  64956. e.prototype.setArray4 = function(e, t) {
  64957. this._valueCache[e] = null,
  64958. this.engine.setArray4(this._uniforms[e], t)
  64959. }
  64960. ,
  64961. e.prototype.setMatrices = function(e, t) {
  64962. t && (this._valueCache[e] = null,
  64963. this.engine.setMatrices(this._uniforms[e], t))
  64964. }
  64965. ,
  64966. e.prototype.setMatrix = function(e, t) {
  64967. this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null))
  64968. }
  64969. ,
  64970. e.prototype.setMatrix3x3 = function(e, t) {
  64971. this._valueCache[e] = null,
  64972. this.engine.setMatrix3x3(this._uniforms[e], t)
  64973. }
  64974. ,
  64975. e.prototype.setMatrix2x2 = function(e, t) {
  64976. this._valueCache[e] = null,
  64977. this.engine.setMatrix2x2(this._uniforms[e], t)
  64978. }
  64979. ,
  64980. e.prototype.setFloat = function(e, t) {
  64981. var i = this._valueCache[e];
  64982. void 0 !== i && i === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t)
  64983. }
  64984. ,
  64985. e.prototype.setBool = function(e, t) {
  64986. var i = this._valueCache[e];
  64987. void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t ? 1 : 0) && (this._valueCache[e] = t ? 1 : 0)
  64988. }
  64989. ,
  64990. e.prototype.setVector2 = function(e, t) {
  64991. this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null))
  64992. }
  64993. ,
  64994. e.prototype.setFloat2 = function(e, t, i) {
  64995. this._cacheFloat2(e, t, i) && (this.engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
  64996. }
  64997. ,
  64998. e.prototype.setVector3 = function(e, t) {
  64999. this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null))
  65000. }
  65001. ,
  65002. e.prototype.setFloat3 = function(e, t, i, n) {
  65003. this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
  65004. }
  65005. ,
  65006. e.prototype.setVector4 = function(e, t) {
  65007. this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null))
  65008. }
  65009. ,
  65010. e.prototype.setFloat4 = function(e, t, i, n, r) {
  65011. this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
  65012. }
  65013. ,
  65014. e.prototype.setColor3 = function(e, t) {
  65015. this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null))
  65016. }
  65017. ,
  65018. e.prototype.setColor4 = function(e, t, i) {
  65019. this._cacheFloat4(e, t.r, t.g, t.b, i) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null))
  65020. }
  65021. ,
  65022. e.prototype.setDirectColor4 = function(e, t) {
  65023. this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null))
  65024. }
  65025. ,
  65026. e
  65027. }()
  65028. , su = function(e) {
  65029. function t(t, i, n, r) {
  65030. var o = e.call(this, t, i, n, r) || this;
  65031. return o.__framebuffer = null,
  65032. o.__framebufferDepthStencil = null,
  65033. o._engine = r,
  65034. o
  65035. }
  65036. return U(t, e),
  65037. Object.defineProperty(t.prototype, "_framebuffer", {
  65038. get: function() {
  65039. return this.__framebuffer
  65040. },
  65041. set: function(e) {
  65042. this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer),
  65043. this.__framebuffer = e
  65044. },
  65045. enumerable: !1,
  65046. configurable: !0
  65047. }),
  65048. Object.defineProperty(t.prototype, "_framebufferDepthStencil", {
  65049. get: function() {
  65050. return this.__framebufferDepthStencil
  65051. },
  65052. set: function(e) {
  65053. this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil),
  65054. this.__framebufferDepthStencil = e
  65055. },
  65056. enumerable: !1,
  65057. configurable: !0
  65058. }),
  65059. t.prototype.dispose = function(t) {
  65060. void 0 === t && (t = !1),
  65061. this._framebuffer = null,
  65062. this._framebufferDepthStencil = null,
  65063. e.prototype.dispose.call(this, t)
  65064. }
  65065. ,
  65066. t
  65067. }(Fa)
  65068. , lu = function(e) {
  65069. function t() {
  65070. return null !== e && e.apply(this, arguments) || this
  65071. }
  65072. return U(t, e),
  65073. t
  65074. }(Bt)
  65075. , cu = function() {
  65076. function e(e) {
  65077. this._engine = e,
  65078. this._pending = new Array,
  65079. this._isCommandBufferScopeActive = !1,
  65080. this._commandStream = uu._createNativeDataStream(),
  65081. this._engine.setCommandDataStream(this._commandStream)
  65082. }
  65083. return e.prototype.beginCommandScope = function() {
  65084. if (this._isCommandBufferScopeActive)
  65085. throw new Error("Command scope already active.");
  65086. this._isCommandBufferScopeActive = !0
  65087. }
  65088. ,
  65089. e.prototype.endCommandScope = function() {
  65090. if (!this._isCommandBufferScopeActive)
  65091. throw new Error("Command scope is not active.");
  65092. this._isCommandBufferScopeActive = !1,
  65093. this._submit()
  65094. }
  65095. ,
  65096. e.prototype.startEncodingCommand = function(e) {
  65097. this._commandStream.writeNativeData(e)
  65098. }
  65099. ,
  65100. e.prototype.encodeCommandArgAsUInt32 = function(e) {
  65101. this._commandStream.writeUint32(e)
  65102. }
  65103. ,
  65104. e.prototype.encodeCommandArgAsUInt32s = function(e) {
  65105. this._commandStream.writeUint32Array(e)
  65106. }
  65107. ,
  65108. e.prototype.encodeCommandArgAsInt32 = function(e) {
  65109. this._commandStream.writeInt32(e)
  65110. }
  65111. ,
  65112. e.prototype.encodeCommandArgAsInt32s = function(e) {
  65113. this._commandStream.writeInt32Array(e)
  65114. }
  65115. ,
  65116. e.prototype.encodeCommandArgAsFloat32 = function(e) {
  65117. this._commandStream.writeFloat32(e)
  65118. }
  65119. ,
  65120. e.prototype.encodeCommandArgAsFloat32s = function(e) {
  65121. this._commandStream.writeFloat32Array(e)
  65122. }
  65123. ,
  65124. e.prototype.encodeCommandArgAsNativeData = function(e) {
  65125. this._commandStream.writeNativeData(e),
  65126. this._pending.push(e)
  65127. }
  65128. ,
  65129. e.prototype.finishEncodingCommand = function() {
  65130. this._isCommandBufferScopeActive || this._submit()
  65131. }
  65132. ,
  65133. e.prototype._submit = function() {
  65134. this._engine.submitCommands(),
  65135. this._pending.length = 0
  65136. }
  65137. ,
  65138. e
  65139. }()
  65140. , uu = function(e) {
  65141. function t(i) {
  65142. void 0 === i && (i = {});
  65143. var n = e.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this;
  65144. if (n._engine = new _native.Engine,
  65145. n._camera = _native.Camera ? new _native.Camera : null,
  65146. n._commandBufferEncoder = new cu(n._engine),
  65147. n._boundBuffersVertexArray = null,
  65148. n._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL,
  65149. n._stencilTest = !1,
  65150. n._stencilMask = 255,
  65151. n._stencilFunc = a.ALWAYS,
  65152. n._stencilFuncRef = 0,
  65153. n._stencilFuncMask = 255,
  65154. n._stencilOpStencilFail = a.KEEP,
  65155. n._stencilOpDepthFail = a.KEEP,
  65156. n._stencilOpStencilDepthPass = a.REPLACE,
  65157. n._zOffset = 0,
  65158. n._zOffsetUnits = 0,
  65159. n._depthWrite = !0,
  65160. _native.Engine.PROTOCOL_VERSION !== t.PROTOCOL_VERSION)
  65161. throw new Error("Protocol version mismatch: ".concat(_native.Engine.PROTOCOL_VERSION, " (Native) !== ").concat(t.PROTOCOL_VERSION, " (JS)"));
  65162. n._webGLVersion = 2,
  65163. n.disableUniformBuffers = !0,
  65164. n._caps = {
  65165. maxTexturesImageUnits: 16,
  65166. maxVertexTextureImageUnits: 16,
  65167. maxCombinedTexturesImageUnits: 32,
  65168. maxTextureSize: 512,
  65169. maxCubemapTextureSize: 512,
  65170. maxRenderTextureSize: 512,
  65171. maxVertexAttribs: 16,
  65172. maxVaryingVectors: 16,
  65173. maxFragmentUniformVectors: 16,
  65174. maxVertexUniformVectors: 16,
  65175. standardDerivatives: !0,
  65176. astc: null,
  65177. pvrtc: null,
  65178. etc1: null,
  65179. etc2: null,
  65180. bptc: null,
  65181. maxAnisotropy: 16,
  65182. uintIndices: !0,
  65183. fragmentDepthSupported: !1,
  65184. highPrecisionShaderSupported: !0,
  65185. colorBufferFloat: !1,
  65186. textureFloat: !0,
  65187. textureFloatLinearFiltering: !1,
  65188. textureFloatRender: !1,
  65189. textureHalfFloat: !1,
  65190. textureHalfFloatLinearFiltering: !1,
  65191. textureHalfFloatRender: !1,
  65192. textureLOD: !0,
  65193. drawBuffersExtension: !1,
  65194. depthTextureExtension: !1,
  65195. vertexArrayObject: !0,
  65196. instancedArrays: !1,
  65197. supportOcclusionQuery: !1,
  65198. canUseTimestampForTimerQuery: !1,
  65199. blendMinMax: !1,
  65200. maxMSAASamples: 1,
  65201. canUseGLInstanceID: !0,
  65202. canUseGLVertexID: !0,
  65203. supportComputeShaders: !1,
  65204. supportSRGBBuffers: !0,
  65205. supportTransformFeedbacks: !1,
  65206. textureMaxLevel: !1
  65207. },
  65208. n._features = {
  65209. forceBitmapOverHTMLImageElement: !1,
  65210. supportRenderAndCopyToLodForFloatTextures: !1,
  65211. supportDepthStencilTexture: !1,
  65212. supportShadowSamplers: !1,
  65213. uniformBufferHardCheckMatrix: !1,
  65214. allowTexturePrefiltering: !1,
  65215. trackUbosInFrame: !1,
  65216. checkUbosContentBeforeUpload: !1,
  65217. supportCSM: !1,
  65218. basisNeedsPOT: !1,
  65219. support3DTextures: !1,
  65220. needTypeSuffixInShaderConstants: !1,
  65221. supportMSAA: !1,
  65222. supportSSAO2: !1,
  65223. supportExtendedTextureFormats: !1,
  65224. supportSwitchCaseInShader: !1,
  65225. supportSyncTextureRead: !1,
  65226. needsInvertingBitmap: !0,
  65227. useUBOBindingCache: !0,
  65228. needShaderCodeInlining: !0,
  65229. needToAlwaysBindUniformBuffers: !1,
  65230. supportRenderPasses: !0,
  65231. _collectUbosUpdatedInFrame: !1
  65232. },
  65233. gi.Log("Babylon Native (v" + vr.Version + ") launched"),
  65234. gi.LoadScript = function(e, t, i, n) {
  65235. gi.LoadFile(e, (function(e) {
  65236. Function(e).apply(null),
  65237. t && t()
  65238. }
  65239. ), void 0, void 0, !1, (function(e, t) {
  65240. i && i("LoadScript Error", t)
  65241. }
  65242. ))
  65243. }
  65244. ,
  65245. "undefined" == typeof URL && (window.URL = {
  65246. createObjectURL: function() {},
  65247. revokeObjectURL: function() {}
  65248. }),
  65249. "undefined" == typeof Blob && (window.Blob = function(e) {
  65250. return e
  65251. }
  65252. );
  65253. var r = window && window.devicePixelRatio || 1;
  65254. n._hardwareScalingLevel = i.adaptToDeviceRatio ? r : 1,
  65255. n.resize();
  65256. var o = n.getDepthFunction();
  65257. return o && n.setDepthFunction(o),
  65258. n._shaderProcessor = new wt,
  65259. n.onNewSceneAddedObservable.add((function(e) {
  65260. var t = e.render;
  65261. e.render = function() {
  65262. for (var i = [], r = 0; r < arguments.length; r++)
  65263. i[r] = arguments[r];
  65264. n._commandBufferEncoder.beginCommandScope(),
  65265. t.apply(e, i),
  65266. n._commandBufferEncoder.endCommandScope()
  65267. }
  65268. }
  65269. )),
  65270. n
  65271. }
  65272. return U(t, e),
  65273. t.prototype.getHardwareScalingLevel = function() {
  65274. return this._engine.getHardwareScalingLevel()
  65275. }
  65276. ,
  65277. t.prototype.setHardwareScalingLevel = function(e) {
  65278. this._engine.setHardwareScalingLevel(e)
  65279. }
  65280. ,
  65281. t.prototype.dispose = function() {
  65282. e.prototype.dispose.call(this),
  65283. this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
  65284. this._engine.dispose()
  65285. }
  65286. ,
  65287. t._createNativeDataStream = function() {
  65288. return new bc
  65289. }
  65290. ,
  65291. t.prototype._queueNewFrame = function(e, t) {
  65292. return t.requestAnimationFrame && t !== window ? t.requestAnimationFrame(e) : this._engine.requestAnimationFrame(e),
  65293. 0
  65294. }
  65295. ,
  65296. t.prototype._bindUnboundFramebuffer = function(e) {
  65297. this._currentFramebuffer !== e && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER),
  65298. this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer),
  65299. this._commandBufferEncoder.finishEncodingCommand()),
  65300. e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER),
  65301. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65302. this._commandBufferEncoder.finishEncodingCommand()),
  65303. this._currentFramebuffer = e)
  65304. }
  65305. ,
  65306. t.prototype.getHostDocument = function() {
  65307. return null
  65308. }
  65309. ,
  65310. t.prototype.clear = function(e, t, i, n) {
  65311. if (void 0 === n && (n = !1),
  65312. this.useReverseDepthBuffer)
  65313. throw new Error("reverse depth buffer is not currently implemented");
  65314. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR),
  65315. this._commandBufferEncoder.encodeCommandArgAsUInt32(t && e ? 1 : 0),
  65316. this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.r : 0),
  65317. this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.g : 0),
  65318. this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.b : 0),
  65319. this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.a : 1),
  65320. this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? 1 : 0),
  65321. this._commandBufferEncoder.encodeCommandArgAsFloat32(1),
  65322. this._commandBufferEncoder.encodeCommandArgAsUInt32(n ? 1 : 0),
  65323. this._commandBufferEncoder.encodeCommandArgAsUInt32(0),
  65324. this._commandBufferEncoder.finishEncodingCommand()
  65325. }
  65326. ,
  65327. t.prototype.createIndexBuffer = function(e, t) {
  65328. var i = this._normalizeIndexData(e)
  65329. , n = new lu;
  65330. return n.references = 1,
  65331. n.is32Bits = 4 === i.BYTES_PER_ELEMENT,
  65332. i.byteLength && (n.nativeIndexBuffer = this._engine.createIndexBuffer(i.buffer, i.byteOffset, i.byteLength, n.is32Bits, null != t && t)),
  65333. n
  65334. }
  65335. ,
  65336. t.prototype.createVertexBuffer = function(e, t) {
  65337. var i = ArrayBuffer.isView(e) ? e : new Float32Array(e)
  65338. , n = new lu;
  65339. return n.references = 1,
  65340. i.byteLength && (n.nativeVertexBuffer = this._engine.createVertexBuffer(i.buffer, i.byteOffset, i.byteLength, null != t && t)),
  65341. n
  65342. }
  65343. ,
  65344. t.prototype._recordVertexArrayObject = function(e, t, i, n) {
  65345. i && this._engine.recordIndexBuffer(e, i.nativeIndexBuffer);
  65346. for (var r = n.getAttributesNames(), o = 0; o < r.length; o++) {
  65347. var a = n.getAttributeLocation(o);
  65348. if (a >= 0) {
  65349. var s = t[r[o]];
  65350. if (s) {
  65351. var l = s.getBuffer();
  65352. l && this._engine.recordVertexBuffer(e, l.nativeVertexBuffer, a, s.byteOffset, s.byteStride, s.getSize(), this._getNativeAttribType(s.type), s.normalized, s.getInstanceDivisor())
  65353. }
  65354. }
  65355. }
  65356. }
  65357. ,
  65358. t.prototype.bindBuffers = function(e, t, i) {
  65359. this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
  65360. this._boundBuffersVertexArray = this._engine.createVertexArray(),
  65361. this._recordVertexArrayObject(this._boundBuffersVertexArray, e, t, i),
  65362. this.bindVertexArrayObject(this._boundBuffersVertexArray)
  65363. }
  65364. ,
  65365. t.prototype.recordVertexArrayObject = function(e, t, i) {
  65366. var n = this._engine.createVertexArray();
  65367. return this._recordVertexArrayObject(n, e, t, i),
  65368. n
  65369. }
  65370. ,
  65371. t.prototype._deleteVertexArray = function(e) {
  65372. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),
  65373. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65374. this._commandBufferEncoder.finishEncodingCommand()
  65375. }
  65376. ,
  65377. t.prototype.bindVertexArrayObject = function(e) {
  65378. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),
  65379. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65380. this._commandBufferEncoder.finishEncodingCommand()
  65381. }
  65382. ,
  65383. t.prototype.releaseVertexArrayObject = function(e) {
  65384. this._deleteVertexArray(e)
  65385. }
  65386. ,
  65387. t.prototype.getAttributes = function(e, t) {
  65388. var i = e;
  65389. return this._engine.getAttributes(i.nativeProgram, t)
  65390. }
  65391. ,
  65392. t.prototype.drawElementsType = function(e, t, i, n) {
  65393. this._drawCalls.addCount(1, !1),
  65394. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),
  65395. this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
  65396. this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
  65397. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  65398. this._commandBufferEncoder.finishEncodingCommand()
  65399. }
  65400. ,
  65401. t.prototype.drawArraysType = function(e, t, i, n) {
  65402. this._drawCalls.addCount(1, !1),
  65403. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),
  65404. this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
  65405. this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
  65406. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  65407. this._commandBufferEncoder.finishEncodingCommand()
  65408. }
  65409. ,
  65410. t.prototype.createPipelineContext = function() {
  65411. return new au(this)
  65412. }
  65413. ,
  65414. t.prototype.createMaterialContext = function() {}
  65415. ,
  65416. t.prototype.createDrawContext = function() {}
  65417. ,
  65418. t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l) {
  65419. e.nativeProgram = n ? this.createRawShaderProgram(e, t, i, void 0, l) : this.createShaderProgram(e, t, i, s, void 0, l)
  65420. }
  65421. ,
  65422. t.prototype._isRenderingStateCompiled = function(e) {
  65423. return !0
  65424. }
  65425. ,
  65426. t.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
  65427. t()
  65428. }
  65429. ,
  65430. t.prototype.createRawShaderProgram = function(e, t, i, n, r) {
  65431. throw void 0 === r && (r = null),
  65432. new Error("Not Supported")
  65433. }
  65434. ,
  65435. t.prototype.createShaderProgram = function(e, t, i, n, r, o) {
  65436. void 0 === o && (o = null),
  65437. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  65438. var a = new iu(t);
  65439. a.processCode(),
  65440. t = a.code;
  65441. var s = new iu(i);
  65442. s.processCode(),
  65443. i = s.code,
  65444. t = Ht._ConcatenateShader(t, n),
  65445. i = Ht._ConcatenateShader(i, n);
  65446. var l = this._engine.createProgram(t, i);
  65447. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  65448. l
  65449. }
  65450. ,
  65451. t.prototype.inlineShaderCode = function(e) {
  65452. var t = new iu(e);
  65453. return t.debug = !1,
  65454. t.processCode(),
  65455. t.code
  65456. }
  65457. ,
  65458. t.prototype._setProgram = function(e) {
  65459. this._currentProgram !== e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),
  65460. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65461. this._commandBufferEncoder.finishEncodingCommand(),
  65462. this._currentProgram = e)
  65463. }
  65464. ,
  65465. t.prototype._deletePipelineContext = function(e) {
  65466. var t = e;
  65467. t && t.nativeProgram && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),
  65468. this._commandBufferEncoder.encodeCommandArgAsNativeData(t.nativeProgram),
  65469. this._commandBufferEncoder.finishEncodingCommand())
  65470. }
  65471. ,
  65472. t.prototype.getUniforms = function(e, t) {
  65473. var i = e;
  65474. return this._engine.getUniforms(i.nativeProgram, t)
  65475. }
  65476. ,
  65477. t.prototype.bindUniformBlock = function(e, t, i) {
  65478. throw new Error("Not Implemented")
  65479. }
  65480. ,
  65481. t.prototype.bindSamplers = function(e) {
  65482. var t = e.getPipelineContext();
  65483. this._setProgram(t.nativeProgram);
  65484. for (var i = e.getSamplers(), n = 0; n < i.length; n++) {
  65485. var r = e.getUniform(i[n]);
  65486. r && (this._boundUniforms[n] = r)
  65487. }
  65488. this._currentEffect = null
  65489. }
  65490. ,
  65491. t.prototype.setMatrix = function(e, t) {
  65492. if (e) {
  65493. var i = t.toArray();
  65494. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX),
  65495. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65496. this._commandBufferEncoder.encodeCommandArgAsFloat32s(i),
  65497. this._commandBufferEncoder.finishEncodingCommand()
  65498. }
  65499. }
  65500. ,
  65501. t.prototype.getRenderWidth = function(e) {
  65502. return void 0 === e && (e = !1),
  65503. !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth()
  65504. }
  65505. ,
  65506. t.prototype.getRenderHeight = function(e) {
  65507. return void 0 === e && (e = !1),
  65508. !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight()
  65509. }
  65510. ,
  65511. t.prototype.setViewport = function(e, t, i) {
  65512. this._cachedViewport = e,
  65513. this._engine.setViewPort(e.x, e.y, e.width, e.height)
  65514. }
  65515. ,
  65516. t.prototype.setState = function(e, t, i, n, r, o, a) {
  65517. var s, l;
  65518. void 0 === t && (t = 0),
  65519. void 0 === n && (n = !1),
  65520. void 0 === a && (a = 0),
  65521. this._zOffset = t,
  65522. this._zOffsetUnits = a,
  65523. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE),
  65524. this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? 1 : 0),
  65525. this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
  65526. this._commandBufferEncoder.encodeCommandArgAsFloat32(a),
  65527. this._commandBufferEncoder.encodeCommandArgAsUInt32(null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? 1 : 0),
  65528. this._commandBufferEncoder.encodeCommandArgAsUInt32(n ? 1 : 0),
  65529. this._commandBufferEncoder.finishEncodingCommand()
  65530. }
  65531. ,
  65532. t.prototype.getInputElementClientRect = function() {
  65533. return {
  65534. bottom: this.getRenderHeight(),
  65535. height: this.getRenderHeight(),
  65536. left: 0,
  65537. right: this.getRenderWidth(),
  65538. top: 0,
  65539. width: this.getRenderWidth(),
  65540. x: 0,
  65541. y: 0,
  65542. toJSON: function() {}
  65543. }
  65544. }
  65545. ,
  65546. t.prototype.setZOffset = function(e) {
  65547. e !== this._zOffset && (this._zOffset = e,
  65548. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET),
  65549. this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e),
  65550. this._commandBufferEncoder.finishEncodingCommand())
  65551. }
  65552. ,
  65553. t.prototype.getZOffset = function() {
  65554. return this._zOffset
  65555. }
  65556. ,
  65557. t.prototype.setZOffsetUnits = function(e) {
  65558. e !== this._zOffsetUnits && (this._zOffsetUnits = e,
  65559. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS),
  65560. this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e),
  65561. this._commandBufferEncoder.finishEncodingCommand())
  65562. }
  65563. ,
  65564. t.prototype.getZOffsetUnits = function() {
  65565. return this._zOffsetUnits
  65566. }
  65567. ,
  65568. t.prototype.setDepthBuffer = function(e) {
  65569. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
  65570. this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS),
  65571. this._commandBufferEncoder.finishEncodingCommand()
  65572. }
  65573. ,
  65574. t.prototype.getDepthWrite = function() {
  65575. return this._depthWrite
  65576. }
  65577. ,
  65578. t.prototype.getDepthFunction = function() {
  65579. switch (this._currentDepthTest) {
  65580. case _native.Engine.DEPTH_TEST_NEVER:
  65581. return a.NEVER;
  65582. case _native.Engine.DEPTH_TEST_ALWAYS:
  65583. return a.ALWAYS;
  65584. case _native.Engine.DEPTH_TEST_GREATER:
  65585. return a.GREATER;
  65586. case _native.Engine.DEPTH_TEST_GEQUAL:
  65587. return a.GEQUAL;
  65588. case _native.Engine.DEPTH_TEST_NOTEQUAL:
  65589. return a.NOTEQUAL;
  65590. case _native.Engine.DEPTH_TEST_EQUAL:
  65591. return a.EQUAL;
  65592. case _native.Engine.DEPTH_TEST_LESS:
  65593. return a.LESS;
  65594. case _native.Engine.DEPTH_TEST_LEQUAL:
  65595. return a.LEQUAL
  65596. }
  65597. return null
  65598. }
  65599. ,
  65600. t.prototype.setDepthFunction = function(e) {
  65601. var t = 0;
  65602. switch (e) {
  65603. case a.NEVER:
  65604. t = _native.Engine.DEPTH_TEST_NEVER;
  65605. break;
  65606. case a.ALWAYS:
  65607. t = _native.Engine.DEPTH_TEST_ALWAYS;
  65608. break;
  65609. case a.GREATER:
  65610. t = _native.Engine.DEPTH_TEST_GREATER;
  65611. break;
  65612. case a.GEQUAL:
  65613. t = _native.Engine.DEPTH_TEST_GEQUAL;
  65614. break;
  65615. case a.NOTEQUAL:
  65616. t = _native.Engine.DEPTH_TEST_NOTEQUAL;
  65617. break;
  65618. case a.EQUAL:
  65619. t = _native.Engine.DEPTH_TEST_EQUAL;
  65620. break;
  65621. case a.LESS:
  65622. t = _native.Engine.DEPTH_TEST_LESS;
  65623. break;
  65624. case a.LEQUAL:
  65625. t = _native.Engine.DEPTH_TEST_LEQUAL
  65626. }
  65627. this._currentDepthTest = t,
  65628. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
  65629. this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest),
  65630. this._commandBufferEncoder.finishEncodingCommand()
  65631. }
  65632. ,
  65633. t.prototype.setDepthWrite = function(e) {
  65634. this._depthWrite = e,
  65635. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE),
  65636. this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),
  65637. this._commandBufferEncoder.finishEncodingCommand()
  65638. }
  65639. ,
  65640. t.prototype.setColorWrite = function(e) {
  65641. this._colorWrite = e,
  65642. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE),
  65643. this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),
  65644. this._commandBufferEncoder.finishEncodingCommand()
  65645. }
  65646. ,
  65647. t.prototype.getColorWrite = function() {
  65648. return this._colorWrite
  65649. }
  65650. ,
  65651. t.prototype.applyStencil = function() {
  65652. this._setStencil(this._stencilMask, this._getStencilOpFail(this._stencilOpStencilFail), this._getStencilDepthFail(this._stencilOpDepthFail), this._getStencilDepthPass(this._stencilOpStencilDepthPass), this._getStencilFunc(this._stencilFunc), this._stencilFuncRef)
  65653. }
  65654. ,
  65655. t.prototype._setStencil = function(e, t, i, n, r, o) {
  65656. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),
  65657. this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
  65658. this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
  65659. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  65660. this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
  65661. this._commandBufferEncoder.encodeCommandArgAsUInt32(r),
  65662. this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
  65663. this._commandBufferEncoder.finishEncodingCommand()
  65664. }
  65665. ,
  65666. t.prototype.setStencilBuffer = function(e) {
  65667. this._stencilTest = e,
  65668. e ? this.applyStencil() : this._setStencil(255, _native.Engine.STENCIL_OP_FAIL_S_KEEP, _native.Engine.STENCIL_OP_FAIL_Z_KEEP, _native.Engine.STENCIL_OP_PASS_Z_KEEP, _native.Engine.STENCIL_TEST_ALWAYS, 0)
  65669. }
  65670. ,
  65671. t.prototype.getStencilBuffer = function() {
  65672. return this._stencilTest
  65673. }
  65674. ,
  65675. t.prototype.getStencilOperationPass = function() {
  65676. return this._stencilOpStencilDepthPass
  65677. }
  65678. ,
  65679. t.prototype.setStencilOperationPass = function(e) {
  65680. this._stencilOpStencilDepthPass = e,
  65681. this.applyStencil()
  65682. }
  65683. ,
  65684. t.prototype.setStencilMask = function(e) {
  65685. this._stencilMask = e,
  65686. this.applyStencil()
  65687. }
  65688. ,
  65689. t.prototype.setStencilFunction = function(e) {
  65690. this._stencilFunc = e,
  65691. this.applyStencil()
  65692. }
  65693. ,
  65694. t.prototype.setStencilFunctionReference = function(e) {
  65695. this._stencilFuncRef = e,
  65696. this.applyStencil()
  65697. }
  65698. ,
  65699. t.prototype.setStencilFunctionMask = function(e) {
  65700. this._stencilFuncMask = e
  65701. }
  65702. ,
  65703. t.prototype.setStencilOperationFail = function(e) {
  65704. this._stencilOpStencilFail = e,
  65705. this.applyStencil()
  65706. }
  65707. ,
  65708. t.prototype.setStencilOperationDepthFail = function(e) {
  65709. this._stencilOpDepthFail = e,
  65710. this.applyStencil()
  65711. }
  65712. ,
  65713. t.prototype.getStencilMask = function() {
  65714. return this._stencilMask
  65715. }
  65716. ,
  65717. t.prototype.getStencilFunction = function() {
  65718. return this._stencilFunc
  65719. }
  65720. ,
  65721. t.prototype.getStencilFunctionReference = function() {
  65722. return this._stencilFuncRef
  65723. }
  65724. ,
  65725. t.prototype.getStencilFunctionMask = function() {
  65726. return this._stencilFuncMask
  65727. }
  65728. ,
  65729. t.prototype.getStencilOperationFail = function() {
  65730. return this._stencilOpStencilFail
  65731. }
  65732. ,
  65733. t.prototype.getStencilOperationDepthFail = function() {
  65734. return this._stencilOpDepthFail
  65735. }
  65736. ,
  65737. t.prototype.setAlphaConstants = function(e, t, i, n) {
  65738. throw new Error("Setting alpha blend constant color not yet implemented.")
  65739. }
  65740. ,
  65741. t.prototype.setAlphaMode = function(e, t) {
  65742. if (void 0 === t && (t = !1),
  65743. this._alphaMode !== e) {
  65744. var i = this._getNativeAlphaMode(e);
  65745. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE),
  65746. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  65747. this._commandBufferEncoder.finishEncodingCommand(),
  65748. t || this.setDepthWrite(e === a.ALPHA_DISABLE),
  65749. this._alphaMode = e
  65750. }
  65751. }
  65752. ,
  65753. t.prototype.getAlphaMode = function() {
  65754. return this._alphaMode
  65755. }
  65756. ,
  65757. t.prototype.setInt = function(e, t) {
  65758. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT),
  65759. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65760. this._commandBufferEncoder.encodeCommandArgAsInt32(t),
  65761. this._commandBufferEncoder.finishEncodingCommand(),
  65762. !0)
  65763. }
  65764. ,
  65765. t.prototype.setIntArray = function(e, t) {
  65766. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY),
  65767. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65768. this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
  65769. this._commandBufferEncoder.finishEncodingCommand(),
  65770. !0)
  65771. }
  65772. ,
  65773. t.prototype.setIntArray2 = function(e, t) {
  65774. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2),
  65775. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65776. this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
  65777. this._commandBufferEncoder.finishEncodingCommand(),
  65778. !0)
  65779. }
  65780. ,
  65781. t.prototype.setIntArray3 = function(e, t) {
  65782. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3),
  65783. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65784. this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
  65785. this._commandBufferEncoder.finishEncodingCommand(),
  65786. !0)
  65787. }
  65788. ,
  65789. t.prototype.setIntArray4 = function(e, t) {
  65790. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4),
  65791. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65792. this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
  65793. this._commandBufferEncoder.finishEncodingCommand(),
  65794. !0)
  65795. }
  65796. ,
  65797. t.prototype.setFloatArray = function(e, t) {
  65798. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY),
  65799. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65800. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65801. this._commandBufferEncoder.finishEncodingCommand(),
  65802. !0)
  65803. }
  65804. ,
  65805. t.prototype.setFloatArray2 = function(e, t) {
  65806. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2),
  65807. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65808. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65809. this._commandBufferEncoder.finishEncodingCommand(),
  65810. !0)
  65811. }
  65812. ,
  65813. t.prototype.setFloatArray3 = function(e, t) {
  65814. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3),
  65815. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65816. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65817. this._commandBufferEncoder.finishEncodingCommand(),
  65818. !0)
  65819. }
  65820. ,
  65821. t.prototype.setFloatArray4 = function(e, t) {
  65822. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4),
  65823. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65824. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65825. this._commandBufferEncoder.finishEncodingCommand(),
  65826. !0)
  65827. }
  65828. ,
  65829. t.prototype.setArray = function(e, t) {
  65830. return !!e && this.setFloatArray(e, new Float32Array(t))
  65831. }
  65832. ,
  65833. t.prototype.setArray2 = function(e, t) {
  65834. return !!e && this.setFloatArray2(e, new Float32Array(t))
  65835. }
  65836. ,
  65837. t.prototype.setArray3 = function(e, t) {
  65838. return !!e && this.setFloatArray3(e, new Float32Array(t))
  65839. }
  65840. ,
  65841. t.prototype.setArray4 = function(e, t) {
  65842. return !!e && this.setFloatArray4(e, new Float32Array(t))
  65843. }
  65844. ,
  65845. t.prototype.setMatrices = function(e, t) {
  65846. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES),
  65847. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65848. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65849. this._commandBufferEncoder.finishEncodingCommand(),
  65850. !0)
  65851. }
  65852. ,
  65853. t.prototype.setMatrix3x3 = function(e, t) {
  65854. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3),
  65855. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65856. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65857. this._commandBufferEncoder.finishEncodingCommand(),
  65858. !0)
  65859. }
  65860. ,
  65861. t.prototype.setMatrix2x2 = function(e, t) {
  65862. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2),
  65863. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65864. this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
  65865. this._commandBufferEncoder.finishEncodingCommand(),
  65866. !0)
  65867. }
  65868. ,
  65869. t.prototype.setFloat = function(e, t) {
  65870. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT),
  65871. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65872. this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
  65873. this._commandBufferEncoder.finishEncodingCommand(),
  65874. !0)
  65875. }
  65876. ,
  65877. t.prototype.setFloat2 = function(e, t, i) {
  65878. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2),
  65879. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65880. this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
  65881. this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
  65882. this._commandBufferEncoder.finishEncodingCommand(),
  65883. !0)
  65884. }
  65885. ,
  65886. t.prototype.setFloat3 = function(e, t, i, n) {
  65887. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),
  65888. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65889. this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
  65890. this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
  65891. this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
  65892. this._commandBufferEncoder.finishEncodingCommand(),
  65893. !0)
  65894. }
  65895. ,
  65896. t.prototype.setFloat4 = function(e, t, i, n, r) {
  65897. return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),
  65898. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  65899. this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
  65900. this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
  65901. this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
  65902. this._commandBufferEncoder.encodeCommandArgAsFloat32(r),
  65903. this._commandBufferEncoder.finishEncodingCommand(),
  65904. !0)
  65905. }
  65906. ,
  65907. t.prototype.setColor3 = function(e, t) {
  65908. return !!e && (this.setFloat3(e, t.r, t.g, t.b),
  65909. !0)
  65910. }
  65911. ,
  65912. t.prototype.setColor4 = function(e, t, i) {
  65913. return !!e && (this.setFloat4(e, t.r, t.g, t.b, i),
  65914. !0)
  65915. }
  65916. ,
  65917. t.prototype.wipeCaches = function(e) {
  65918. this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
  65919. this._currentEffect = null,
  65920. e && (this._currentProgram = null,
  65921. this._stencilStateComposer.reset(),
  65922. this._depthCullingState.reset(),
  65923. this._alphaState.reset()),
  65924. this._cachedVertexBuffers = null,
  65925. this._cachedIndexBuffer = null,
  65926. this._cachedEffectForVertexBuffers = null)
  65927. }
  65928. ,
  65929. t.prototype._createTexture = function() {
  65930. return this._engine.createTexture()
  65931. }
  65932. ,
  65933. t.prototype._deleteTexture = function(e) {
  65934. e && this._engine.deleteTexture(e)
  65935. }
  65936. ,
  65937. t.prototype.updateDynamicTexture = function(e, t, i, n, r) {
  65938. if (void 0 === n && (n = !1),
  65939. void 0 === n && (n = !1),
  65940. e && e._hardwareTexture) {
  65941. var o = t.getCanvasTexture()
  65942. , a = e._hardwareTexture.underlyingResource;
  65943. this._engine.copyTexture(a, o),
  65944. e.isReady = !0
  65945. }
  65946. }
  65947. ,
  65948. t.prototype.createDynamicTexture = function(e, t, i, n) {
  65949. return e = Math.max(e, 1),
  65950. t = Math.max(t, 1),
  65951. this.createRawTexture(new Uint8Array(e * t * 4), e, t, a.TEXTUREFORMAT_RGBA, !1, !1, n)
  65952. }
  65953. ,
  65954. t.prototype.createVideoElement = function(e) {
  65955. return this._camera ? this._camera.createVideo(e) : null
  65956. }
  65957. ,
  65958. t.prototype.updateVideoTexture = function(e, t, i) {
  65959. if (e && e._hardwareTexture && this._camera) {
  65960. var n = e._hardwareTexture.underlyingResource;
  65961. this._camera.updateVideoTexture(n, t, i)
  65962. }
  65963. }
  65964. ,
  65965. t.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
  65966. void 0 === l && (l = null),
  65967. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
  65968. var u = new Lt(this,At.Raw);
  65969. if (u.format = n,
  65970. u.generateMipMaps = r,
  65971. u.samplingMode = s,
  65972. u.invertY = o,
  65973. u.baseWidth = t,
  65974. u.baseHeight = i,
  65975. u.width = u.baseWidth,
  65976. u.height = u.baseHeight,
  65977. u._compression = l,
  65978. u.type = c,
  65979. this.updateRawTexture(u, e, n, o, l, c),
  65980. u._hardwareTexture) {
  65981. var h = u._hardwareTexture.underlyingResource
  65982. , d = this._getNativeSamplingMode(s);
  65983. this._setTextureSampling(h, d)
  65984. }
  65985. return this._internalTexturesCache.push(u),
  65986. u
  65987. }
  65988. ,
  65989. t.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
  65990. void 0 === c && (c = null),
  65991. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT);
  65992. var h = new Lt(this,At.Raw2DArray);
  65993. if (h.baseWidth = t,
  65994. h.baseHeight = i,
  65995. h.baseDepth = n,
  65996. h.width = t,
  65997. h.height = i,
  65998. h.depth = n,
  65999. h.format = r,
  66000. h.type = u,
  66001. h.generateMipMaps = o,
  66002. h.samplingMode = l,
  66003. h.is2DArray = !0,
  66004. h._hardwareTexture) {
  66005. var d = h._hardwareTexture.underlyingResource;
  66006. this._engine.loadRawTexture2DArray(d, e, t, i, n, this._getNativeTextureFormat(r, u), o, s);
  66007. var p = this._getNativeSamplingMode(l);
  66008. this._setTextureSampling(d, p)
  66009. }
  66010. return h.isReady = !0,
  66011. this._internalTexturesCache.push(h),
  66012. h
  66013. }
  66014. ,
  66015. t.prototype.updateRawTexture = function(e, t, i, n, r, o) {
  66016. if (void 0 === r && (r = null),
  66017. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  66018. e) {
  66019. if (t && e._hardwareTexture) {
  66020. var s = e._hardwareTexture.underlyingResource;
  66021. this._engine.loadRawTexture(s, t, e.width, e.height, this._getNativeTextureFormat(i, o), e.generateMipMaps, e.invertY)
  66022. }
  66023. e.isReady = !0
  66024. }
  66025. }
  66026. ,
  66027. t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
  66028. var m = this;
  66029. void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  66030. void 0 === o && (o = null),
  66031. void 0 === s && (s = null),
  66032. void 0 === l && (l = null),
  66033. void 0 === c && (c = null),
  66034. void 0 === u && (u = null),
  66035. void 0 === h && (h = null),
  66036. void 0 === _ && (_ = !1);
  66037. var g = "data:" === (e = e || "").substr(0, 5)
  66038. , v = g && -1 !== e.indexOf(";base64,")
  66039. , y = c || new Lt(this,At.Url)
  66040. , b = e;
  66041. !this._transformTextureUrl || v || c || l || (e = this._transformTextureUrl(e));
  66042. for (var T = e.lastIndexOf("."), S = h || (T > -1 ? e.substring(T).toLowerCase() : ""), A = null, x = 0, R = vr._TextureLoaders; x < R.length; x++) {
  66043. var C = R[x];
  66044. if (C.canLoad(S)) {
  66045. A = C;
  66046. break
  66047. }
  66048. }
  66049. n && n._addPendingData(y),
  66050. y.url = e,
  66051. y.generateMipMaps = !t,
  66052. y.samplingMode = r,
  66053. y.invertY = i,
  66054. y._useSRGBBuffer = this._getUseSRGBBuffer(_, t),
  66055. this.doNotHandleContextLost || (y._buffer = l);
  66056. var P = null;
  66057. if (o && !c && (P = y.onLoadedObservable.add(o)),
  66058. c || this._internalTexturesCache.push(y),
  66059. A)
  66060. throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
  66061. var M = function(e) {
  66062. if (y._hardwareTexture) {
  66063. var o = y._hardwareTexture.underlyingResource;
  66064. m._engine.loadTexture(o, e, !t, i, _, (function() {
  66065. y.baseWidth = m._engine.getTextureWidth(o),
  66066. y.baseHeight = m._engine.getTextureHeight(o),
  66067. y.width = y.baseWidth,
  66068. y.height = y.baseHeight,
  66069. y.isReady = !0;
  66070. var e = m._getNativeSamplingMode(r);
  66071. m._setTextureSampling(o, e),
  66072. n && n._removePendingData(y),
  66073. y.onLoadedObservable.notifyObservers(y),
  66074. y.onLoadedObservable.clear()
  66075. }
  66076. ), (function() {
  66077. throw new Error("Could not load a native texture.")
  66078. }
  66079. ))
  66080. } else
  66081. n && n._removePendingData(y)
  66082. };
  66083. if (g && l)
  66084. if (l instanceof ArrayBuffer)
  66085. M(new Uint8Array(l));
  66086. else if (ArrayBuffer.isView(l))
  66087. M(l);
  66088. else {
  66089. if ("string" != typeof l)
  66090. throw new Error("Unsupported buffer type");
  66091. M(new Uint8Array(gi.DecodeBase64(l)))
  66092. }
  66093. else
  66094. v ? M(new Uint8Array(gi.DecodeBase64(e))) : this._loadFile(e, (function(e) {
  66095. return M(new Uint8Array(e))
  66096. }
  66097. ), void 0, void 0, !0, (function(i, a) {
  66098. var c;
  66099. c = "Unable to load " + (i && i.responseURL,
  66100. a),
  66101. n && n._removePendingData(y),
  66102. e === b ? (P && y.onLoadedObservable.remove(P),
  66103. E.UseFallbackTexture && m.createTexture(E.FallbackTexture, t, y.invertY, n, r, null, s, l, y),
  66104. s && s((c || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""), void 0)) : (K.Warn("Failed to load ".concat(e, ", falling back to ").concat(b)),
  66105. m.createTexture(b, t, y.invertY, n, r, o, s, l, y, u, h, d, p))
  66106. }
  66107. ));
  66108. return y
  66109. }
  66110. ,
  66111. t.prototype._createDepthStencilTexture = function(e, t, i) {
  66112. var n = i
  66113. , r = new Lt(this,At.DepthStencil)
  66114. , o = e.width || e
  66115. , a = e.height || e
  66116. , s = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, a, _native.Engine.TEXTURE_FORMAT_RGBA8, !1, !0, !1);
  66117. return n._framebufferDepthStencil = s,
  66118. r
  66119. }
  66120. ,
  66121. t.prototype._releaseFramebufferObjects = function(e) {
  66122. e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER),
  66123. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  66124. this._commandBufferEncoder.finishEncodingCommand())
  66125. }
  66126. ,
  66127. t.prototype.createImageBitmapFromSource = function(e, t) {
  66128. var i = this;
  66129. return new Promise((function(t, n) {
  66130. var r = i.createCanvasImage();
  66131. r.onload = function() {
  66132. var e = i._engine.createImageBitmap(r);
  66133. e ? t(e) : n("Error loading image ".concat(r.src))
  66134. }
  66135. ,
  66136. r.onerror = function() {
  66137. n("Error loading image ".concat(r.src))
  66138. }
  66139. ,
  66140. r.src = e
  66141. }
  66142. ))
  66143. }
  66144. ,
  66145. t.prototype.createImageBitmap = function(e, t) {
  66146. var i = this;
  66147. return new Promise((function(t, n) {
  66148. if (Array.isArray(e)) {
  66149. var r = e;
  66150. if (r.length) {
  66151. var o = i._engine.createImageBitmap(r[0]);
  66152. if (o)
  66153. return void t(o)
  66154. }
  66155. }
  66156. n("Unsupported data for createImageBitmap.")
  66157. }
  66158. ))
  66159. }
  66160. ,
  66161. t.prototype.resizeImageBitmap = function(e, t, i) {
  66162. return this._engine.resizeImageBitmap(e, t, i)
  66163. }
  66164. ,
  66165. t.prototype.createCubeTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f) {
  66166. var _ = this;
  66167. void 0 === r && (r = null),
  66168. void 0 === o && (o = null),
  66169. void 0 === l && (l = null),
  66170. void 0 === c && (c = !1),
  66171. void 0 === u && (u = 0),
  66172. void 0 === h && (h = 0),
  66173. void 0 === d && (d = null),
  66174. void 0 === f && (f = !1);
  66175. var m = d || new Lt(this,At.Cube);
  66176. m.isCube = !0,
  66177. m.url = e,
  66178. m.generateMipMaps = !n,
  66179. m._lodGenerationScale = u,
  66180. m._lodGenerationOffset = h,
  66181. this._doNotHandleContextLost || (m._extension = l,
  66182. m._files = i);
  66183. var g = e.lastIndexOf(".");
  66184. if (".env" === (l || (g > -1 ? e.substring(g).toLowerCase() : ""))) {
  66185. if (i && 6 === i.length)
  66186. throw new Error("Multi-file loading not allowed on env files.");
  66187. this._loadFile(e, (function(e) {
  66188. return function(e) {
  66189. var t = Vc(e);
  66190. m.width = t.width,
  66191. m.height = t.width,
  66192. Yc(m, t);
  66193. var i = t.specular;
  66194. if (!i)
  66195. throw new Error("Nothing else parsed so far");
  66196. m._lodGenerationScale = i.lodGenerationScale;
  66197. var n = Wc(e, t);
  66198. m.format = a.TEXTUREFORMAT_RGBA,
  66199. m.type = a.TEXTURETYPE_UNSIGNED_INT,
  66200. m.generateMipMaps = !0,
  66201. m.getEngine().updateTextureSamplingMode(io.TRILINEAR_SAMPLINGMODE, m),
  66202. m._isRGBD = !0,
  66203. m.invertY = !0,
  66204. _._engine.loadCubeTextureWithMips(m._hardwareTexture.underlyingResource, n, !1, f, (function() {
  66205. m.isReady = !0,
  66206. r && r()
  66207. }
  66208. ), (function() {
  66209. throw new Error("Could not load a native cube texture.")
  66210. }
  66211. ))
  66212. }(new Uint8Array(e))
  66213. }
  66214. ), void 0, void 0, !0, (function(e, t) {
  66215. o && e && o(e.status + " " + e.statusText, t)
  66216. }
  66217. ))
  66218. } else {
  66219. if (!i || 6 !== i.length)
  66220. throw new Error("Cannot load cubemap because 6 files were not defined");
  66221. var v = [i[0], i[3], i[1], i[4], i[2], i[5]];
  66222. Promise.all(v.map((function(e) {
  66223. return gi.LoadFileAsync(e).then((function(e) {
  66224. return new Uint8Array(e)
  66225. }
  66226. ))
  66227. }
  66228. ))).then((function(e) {
  66229. return new Promise((function(t, i) {
  66230. _._engine.loadCubeTexture(m._hardwareTexture.underlyingResource, e, !n, !0, f, t, i)
  66231. }
  66232. ))
  66233. }
  66234. )).then((function() {
  66235. m.isReady = !0,
  66236. r && r()
  66237. }
  66238. ), (function(e) {
  66239. o && o("Failed to load cubemap: ".concat(e.message), e)
  66240. }
  66241. ))
  66242. }
  66243. return this._internalTexturesCache.push(m),
  66244. m
  66245. }
  66246. ,
  66247. t.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
  66248. var n = new su(e,t,i,this);
  66249. return this._renderTargetWrapperCache.push(n),
  66250. n
  66251. }
  66252. ,
  66253. t.prototype.createRenderTargetTexture = function(e, t) {
  66254. var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
  66255. , n = {};
  66256. void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
  66257. n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
  66258. n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
  66259. n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
  66260. n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
  66261. n.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (n.generateMipMaps = t,
  66262. n.generateDepthBuffer = !0,
  66263. n.generateStencilBuffer = !1,
  66264. n.type = a.TEXTURETYPE_UNSIGNED_INT,
  66265. n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  66266. n.format = a.TEXTUREFORMAT_RGBA),
  66267. (n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
  66268. var r = new Lt(this,At.RenderTarget)
  66269. , o = e.width || e
  66270. , s = e.height || e;
  66271. n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
  66272. K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  66273. var l = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, s, this._getNativeTextureFormat(n.format, n.type), !!n.generateStencilBuffer, n.generateDepthBuffer, !!n.generateMipMaps);
  66274. return i._framebuffer = l,
  66275. i._generateDepthBuffer = n.generateDepthBuffer,
  66276. i._generateStencilBuffer = !!n.generateStencilBuffer,
  66277. r.baseWidth = o,
  66278. r.baseHeight = s,
  66279. r.width = o,
  66280. r.height = s,
  66281. r.isReady = !0,
  66282. r.samples = 1,
  66283. r.generateMipMaps = !!n.generateMipMaps,
  66284. r.samplingMode = n.samplingMode,
  66285. r.type = n.type,
  66286. r.format = n.format,
  66287. this._internalTexturesCache.push(r),
  66288. i.setTextures(r),
  66289. i
  66290. }
  66291. ,
  66292. t.prototype.updateTextureSamplingMode = function(e, t) {
  66293. if (t._hardwareTexture) {
  66294. var i = this._getNativeSamplingMode(e);
  66295. this._setTextureSampling(t._hardwareTexture.underlyingResource, i)
  66296. }
  66297. t.samplingMode = e
  66298. }
  66299. ,
  66300. t.prototype.bindFramebuffer = function(e, t, i, n, r) {
  66301. var o = e;
  66302. if (t)
  66303. throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
  66304. if (i || n)
  66305. throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
  66306. o._framebufferDepthStencil ? this._bindUnboundFramebuffer(o._framebufferDepthStencil) : this._bindUnboundFramebuffer(o._framebuffer)
  66307. }
  66308. ,
  66309. t.prototype.unBindFramebuffer = function(e, t, i) {
  66310. void 0 === t && (t = !1),
  66311. i && i(),
  66312. this._bindUnboundFramebuffer(null)
  66313. }
  66314. ,
  66315. t.prototype.createDynamicVertexBuffer = function(e) {
  66316. return this.createVertexBuffer(e, !0)
  66317. }
  66318. ,
  66319. t.prototype.updateDynamicIndexBuffer = function(e, t, i) {
  66320. void 0 === i && (i = 0);
  66321. var n = e
  66322. , r = this._normalizeIndexData(t);
  66323. n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
  66324. this._engine.updateDynamicIndexBuffer(n.nativeIndexBuffer, r.buffer, r.byteOffset, r.byteLength, i)
  66325. }
  66326. ,
  66327. t.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
  66328. var r = e
  66329. , o = ArrayBuffer.isView(t) ? t : new Float32Array(t);
  66330. this._engine.updateDynamicVertexBuffer(r.nativeVertexBuffer, o.buffer, o.byteOffset + (null != i ? i : 0), null != n ? n : o.byteLength)
  66331. }
  66332. ,
  66333. t.prototype._setTexture = function(e, t, i, n) {
  66334. void 0 === i && (i = !1),
  66335. void 0 === n && (n = !1);
  66336. var r, o = this._boundUniforms[e];
  66337. if (!o)
  66338. return !1;
  66339. if (!t)
  66340. return null != this._boundTexturesCache[e] && (this._activeChannel = e,
  66341. this._setTextureCore(o, null)),
  66342. !1;
  66343. if (t.video)
  66344. this._activeChannel = e,
  66345. t.update();
  66346. else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
  66347. return t.delayLoad(),
  66348. !1;
  66349. return r = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
  66350. this._activeChannel = e,
  66351. !(!r || !r._hardwareTexture || (this._setTextureWrapMode(r._hardwareTexture.underlyingResource, this._getAddressMode(t.wrapU), this._getAddressMode(t.wrapV), this._getAddressMode(t.wrapR)),
  66352. this._updateAnisotropicLevel(t),
  66353. this._setTextureCore(o, r._hardwareTexture.underlyingResource),
  66354. 0))
  66355. }
  66356. ,
  66357. t.prototype._setTextureSampling = function(e, t) {
  66358. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),
  66359. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  66360. this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
  66361. this._commandBufferEncoder.finishEncodingCommand()
  66362. }
  66363. ,
  66364. t.prototype._setTextureWrapMode = function(e, t, i, n) {
  66365. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),
  66366. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  66367. this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
  66368. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  66369. this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
  66370. this._commandBufferEncoder.finishEncodingCommand()
  66371. }
  66372. ,
  66373. t.prototype._setTextureCore = function(e, t) {
  66374. this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),
  66375. this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
  66376. this._commandBufferEncoder.encodeCommandArgAsNativeData(t),
  66377. this._commandBufferEncoder.finishEncodingCommand()
  66378. }
  66379. ,
  66380. t.prototype._updateAnisotropicLevel = function(e) {
  66381. var t = e.getInternalTexture()
  66382. , i = e.anisotropicFilteringLevel;
  66383. t && t._hardwareTexture && t._cachedAnisotropicFilteringLevel !== i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),
  66384. this._commandBufferEncoder.encodeCommandArgAsNativeData(t._hardwareTexture.underlyingResource),
  66385. this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
  66386. this._commandBufferEncoder.finishEncodingCommand(),
  66387. t._cachedAnisotropicFilteringLevel = i)
  66388. }
  66389. ,
  66390. t.prototype._getAddressMode = function(e) {
  66391. switch (e) {
  66392. case a.TEXTURE_WRAP_ADDRESSMODE:
  66393. return _native.Engine.ADDRESS_MODE_WRAP;
  66394. case a.TEXTURE_CLAMP_ADDRESSMODE:
  66395. return _native.Engine.ADDRESS_MODE_CLAMP;
  66396. case a.TEXTURE_MIRROR_ADDRESSMODE:
  66397. return _native.Engine.ADDRESS_MODE_MIRROR;
  66398. default:
  66399. throw new Error("Unexpected wrap mode: " + e + ".")
  66400. }
  66401. }
  66402. ,
  66403. t.prototype._bindTexture = function(e, t) {
  66404. var i = this._boundUniforms[e];
  66405. if (i && t && t._hardwareTexture) {
  66406. var n = t._hardwareTexture.underlyingResource;
  66407. this._setTextureCore(i, n)
  66408. }
  66409. }
  66410. ,
  66411. t.prototype._deleteBuffer = function(e) {
  66412. e.nativeIndexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),
  66413. this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer),
  66414. this._commandBufferEncoder.finishEncodingCommand(),
  66415. delete e.nativeIndexBuffer),
  66416. e.nativeVertexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),
  66417. this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer),
  66418. this._commandBufferEncoder.finishEncodingCommand(),
  66419. delete e.nativeVertexBuffer)
  66420. }
  66421. ,
  66422. t.prototype.createCanvas = function(e, t) {
  66423. if (!_native.Canvas)
  66424. throw new Error("Native Canvas plugin not available.");
  66425. var i = new _native.Canvas;
  66426. return i.width = e,
  66427. i.height = t,
  66428. i
  66429. }
  66430. ,
  66431. t.prototype.createCanvasImage = function() {
  66432. if (!_native.Canvas)
  66433. throw new Error("Native Canvas plugin not available.");
  66434. return new _native.Image
  66435. }
  66436. ,
  66437. t.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
  66438. throw void 0 === o && (o = 0),
  66439. void 0 === a && (a = 0),
  66440. new Error("_uploadCompressedDataToTextureDirectly not implemented.")
  66441. }
  66442. ,
  66443. t.prototype._uploadDataToTextureDirectly = function(e, t, i, n) {
  66444. throw void 0 === i && (i = 0),
  66445. void 0 === n && (n = 0),
  66446. new Error("_uploadDataToTextureDirectly not implemented.")
  66447. }
  66448. ,
  66449. t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
  66450. throw void 0 === i && (i = 0),
  66451. void 0 === n && (n = 0),
  66452. new Error("_uploadArrayBufferViewToTexture not implemented.")
  66453. }
  66454. ,
  66455. t.prototype._uploadImageToTexture = function(e, t, i, n) {
  66456. throw void 0 === i && (i = 0),
  66457. void 0 === n && (n = 0),
  66458. new Error("_uploadArrayBufferViewToTexture not implemented.")
  66459. }
  66460. ,
  66461. t.prototype._getNativeSamplingMode = function(e) {
  66462. switch (e) {
  66463. case a.TEXTURE_NEAREST_NEAREST:
  66464. return _native.Engine.TEXTURE_NEAREST_NEAREST;
  66465. case a.TEXTURE_LINEAR_LINEAR:
  66466. return _native.Engine.TEXTURE_LINEAR_LINEAR;
  66467. case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
  66468. return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  66469. case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  66470. return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  66471. case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  66472. return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  66473. case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  66474. return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  66475. case a.TEXTURE_NEAREST_LINEAR:
  66476. return _native.Engine.TEXTURE_NEAREST_LINEAR;
  66477. case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
  66478. return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  66479. case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  66480. return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  66481. case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  66482. return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  66483. case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
  66484. return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  66485. case a.TEXTURE_LINEAR_NEAREST:
  66486. return _native.Engine.TEXTURE_LINEAR_NEAREST;
  66487. default:
  66488. throw new Error("Unsupported sampling mode: ".concat(e, "."))
  66489. }
  66490. }
  66491. ,
  66492. t.prototype._getStencilFunc = function(e) {
  66493. switch (e) {
  66494. case a.LESS:
  66495. return _native.Engine.STENCIL_TEST_LESS;
  66496. case a.LEQUAL:
  66497. return _native.Engine.STENCIL_TEST_LEQUAL;
  66498. case a.EQUAL:
  66499. return _native.Engine.STENCIL_TEST_EQUAL;
  66500. case a.GEQUAL:
  66501. return _native.Engine.STENCIL_TEST_GEQUAL;
  66502. case a.GREATER:
  66503. return _native.Engine.STENCIL_TEST_GREATER;
  66504. case a.NOTEQUAL:
  66505. return _native.Engine.STENCIL_TEST_NOTEQUAL;
  66506. case a.NEVER:
  66507. return _native.Engine.STENCIL_TEST_NEVER;
  66508. case a.ALWAYS:
  66509. return _native.Engine.STENCIL_TEST_ALWAYS;
  66510. default:
  66511. throw new Error("Unsupported stencil func mode: ".concat(e, "."))
  66512. }
  66513. }
  66514. ,
  66515. t.prototype._getStencilOpFail = function(e) {
  66516. switch (e) {
  66517. case a.KEEP:
  66518. return _native.Engine.STENCIL_OP_FAIL_S_KEEP;
  66519. case a.ZERO:
  66520. return _native.Engine.STENCIL_OP_FAIL_S_ZERO;
  66521. case a.REPLACE:
  66522. return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;
  66523. case a.INCR:
  66524. return _native.Engine.STENCIL_OP_FAIL_S_INCR;
  66525. case a.DECR:
  66526. return _native.Engine.STENCIL_OP_FAIL_S_DECR;
  66527. case a.INVERT:
  66528. return _native.Engine.STENCIL_OP_FAIL_S_INVERT;
  66529. case a.INCR_WRAP:
  66530. return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;
  66531. case a.DECR_WRAP:
  66532. return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;
  66533. default:
  66534. throw new Error("Unsupported stencil OpFail mode: ".concat(e, "."))
  66535. }
  66536. }
  66537. ,
  66538. t.prototype._getStencilDepthFail = function(e) {
  66539. switch (e) {
  66540. case a.KEEP:
  66541. return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;
  66542. case a.ZERO:
  66543. return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;
  66544. case a.REPLACE:
  66545. return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;
  66546. case a.INCR:
  66547. return _native.Engine.STENCIL_OP_FAIL_Z_INCR;
  66548. case a.DECR:
  66549. return _native.Engine.STENCIL_OP_FAIL_Z_DECR;
  66550. case a.INVERT:
  66551. return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;
  66552. case a.INCR_WRAP:
  66553. return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;
  66554. case a.DECR_WRAP:
  66555. return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;
  66556. default:
  66557. throw new Error("Unsupported stencil depthFail mode: ".concat(e, "."))
  66558. }
  66559. }
  66560. ,
  66561. t.prototype._getStencilDepthPass = function(e) {
  66562. switch (e) {
  66563. case a.KEEP:
  66564. return _native.Engine.STENCIL_OP_PASS_Z_KEEP;
  66565. case a.ZERO:
  66566. return _native.Engine.STENCIL_OP_PASS_Z_ZERO;
  66567. case a.REPLACE:
  66568. return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;
  66569. case a.INCR:
  66570. return _native.Engine.STENCIL_OP_PASS_Z_INCR;
  66571. case a.DECR:
  66572. return _native.Engine.STENCIL_OP_PASS_Z_DECR;
  66573. case a.INVERT:
  66574. return _native.Engine.STENCIL_OP_PASS_Z_INVERT;
  66575. case a.INCR_WRAP:
  66576. return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;
  66577. case a.DECR_WRAP:
  66578. return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;
  66579. default:
  66580. throw new Error("Unsupported stencil opPass mode: ".concat(e, "."))
  66581. }
  66582. }
  66583. ,
  66584. t.prototype._getNativeTextureFormat = function(e, t) {
  66585. if (e == a.TEXTUREFORMAT_RGB && t == a.TEXTURETYPE_UNSIGNED_INT)
  66586. return _native.Engine.TEXTURE_FORMAT_RGB8;
  66587. if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_UNSIGNED_INT)
  66588. return _native.Engine.TEXTURE_FORMAT_RGBA8;
  66589. if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_FLOAT)
  66590. return _native.Engine.TEXTURE_FORMAT_RGBA32F;
  66591. throw new ft("Unsupported texture format or type: format ".concat(e, ", type ").concat(t, "."),pt.UnsupportedTextureError)
  66592. }
  66593. ,
  66594. t.prototype._getNativeAlphaMode = function(e) {
  66595. switch (e) {
  66596. case a.ALPHA_DISABLE:
  66597. return _native.Engine.ALPHA_DISABLE;
  66598. case a.ALPHA_ADD:
  66599. return _native.Engine.ALPHA_ADD;
  66600. case a.ALPHA_COMBINE:
  66601. return _native.Engine.ALPHA_COMBINE;
  66602. case a.ALPHA_SUBTRACT:
  66603. return _native.Engine.ALPHA_SUBTRACT;
  66604. case a.ALPHA_MULTIPLY:
  66605. return _native.Engine.ALPHA_MULTIPLY;
  66606. case a.ALPHA_MAXIMIZED:
  66607. return _native.Engine.ALPHA_MAXIMIZED;
  66608. case a.ALPHA_ONEONE:
  66609. return _native.Engine.ALPHA_ONEONE;
  66610. case a.ALPHA_PREMULTIPLIED:
  66611. return _native.Engine.ALPHA_PREMULTIPLIED;
  66612. case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
  66613. return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
  66614. case a.ALPHA_INTERPOLATE:
  66615. return _native.Engine.ALPHA_INTERPOLATE;
  66616. case a.ALPHA_SCREENMODE:
  66617. return _native.Engine.ALPHA_SCREENMODE;
  66618. default:
  66619. throw new Error("Unsupported alpha mode: ".concat(e, "."))
  66620. }
  66621. }
  66622. ,
  66623. t.prototype._getNativeAttribType = function(e) {
  66624. switch (e) {
  66625. case Bi.BYTE:
  66626. return _native.Engine.ATTRIB_TYPE_INT8;
  66627. case Bi.UNSIGNED_BYTE:
  66628. return _native.Engine.ATTRIB_TYPE_UINT8;
  66629. case Bi.SHORT:
  66630. return _native.Engine.ATTRIB_TYPE_INT16;
  66631. case Bi.UNSIGNED_SHORT:
  66632. return _native.Engine.ATTRIB_TYPE_UINT16;
  66633. case Bi.FLOAT:
  66634. return _native.Engine.ATTRIB_TYPE_FLOAT;
  66635. default:
  66636. throw new Error("Unsupported attribute type: ".concat(e, "."))
  66637. }
  66638. }
  66639. ,
  66640. t.prototype.getFontOffset = function(e) {
  66641. return {
  66642. ascent: 0,
  66643. height: 0,
  66644. descent: 0
  66645. }
  66646. }
  66647. ,
  66648. t.PROTOCOL_VERSION = 5,
  66649. t
  66650. }(vr);
  66651. uu._createNativeDataStream = function() {
  66652. return _native.NativeDataStream.VALIDATION_ENABLED ? new Ku : new bc
  66653. }
  66654. ;
  66655. var hu, du, pu, fu, _u, mu, gu, vu, yu, bu, Tu, Eu, Su, Au, xu, Ru, Cu, Pu, Mu, Iu, Ou, Du, Nu, Lu, Fu, wu, Bu, Uu, Vu, ku, Gu, zu, Wu, Hu, Xu, ju, Yu, Ku = function(e) {
  66656. function t() {
  66657. return e.call(this) || this
  66658. }
  66659. return U(t, e),
  66660. t.prototype.writeUint32 = function(t) {
  66661. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32),
  66662. e.prototype.writeUint32.call(this, t)
  66663. }
  66664. ,
  66665. t.prototype.writeInt32 = function(t) {
  66666. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32),
  66667. e.prototype.writeInt32.call(this, t)
  66668. }
  66669. ,
  66670. t.prototype.writeFloat32 = function(t) {
  66671. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32),
  66672. e.prototype.writeFloat32.call(this, t)
  66673. }
  66674. ,
  66675. t.prototype.writeUint32Array = function(t) {
  66676. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32_ARRAY),
  66677. e.prototype.writeUint32Array.call(this, t)
  66678. }
  66679. ,
  66680. t.prototype.writeInt32Array = function(t) {
  66681. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32_ARRAY),
  66682. e.prototype.writeInt32Array.call(this, t)
  66683. }
  66684. ,
  66685. t.prototype.writeFloat32Array = function(t) {
  66686. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),
  66687. e.prototype.writeFloat32Array.call(this, t)
  66688. }
  66689. ,
  66690. t.prototype.writeNativeData = function(t) {
  66691. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_NATIVE_DATA),
  66692. e.prototype.writeNativeData.call(this, t)
  66693. }
  66694. ,
  66695. t.prototype.writeBoolean = function(t) {
  66696. e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_BOOLEAN),
  66697. e.prototype.writeBoolean.call(this, t)
  66698. }
  66699. ,
  66700. t
  66701. }(bc);
  66702. !function(e) {
  66703. e.SRGB = "srgb"
  66704. }(hu || (hu = {})),
  66705. function(e) {
  66706. e.LowPower = "low-power",
  66707. e.HighPerformance = "high-performance"
  66708. }(du || (du = {})),
  66709. function(e) {
  66710. e.DepthClipControl = "depth-clip-control",
  66711. e.Depth24UnormStencil8 = "depth24unorm-stencil8",
  66712. e.Depth32FloatStencil8 = "depth32float-stencil8",
  66713. e.TextureCompressionBC = "texture-compression-bc",
  66714. e.TextureCompressionETC2 = "texture-compression-etc2",
  66715. e.TextureCompressionASTC = "texture-compression-astc",
  66716. e.TimestampQuery = "timestamp-query",
  66717. e.IndirectFirstInstance = "indirect-first-instance"
  66718. }(pu || (pu = {})),
  66719. function(e) {
  66720. e[e.MapRead = 1] = "MapRead",
  66721. e[e.MapWrite = 2] = "MapWrite",
  66722. e[e.CopySrc = 4] = "CopySrc",
  66723. e[e.CopyDst = 8] = "CopyDst",
  66724. e[e.Index = 16] = "Index",
  66725. e[e.Vertex = 32] = "Vertex",
  66726. e[e.Uniform = 64] = "Uniform",
  66727. e[e.Storage = 128] = "Storage",
  66728. e[e.Indirect = 256] = "Indirect",
  66729. e[e.QueryResolve = 512] = "QueryResolve"
  66730. }(fu || (fu = {})),
  66731. function(e) {
  66732. e[e.Read = 1] = "Read",
  66733. e[e.Write = 2] = "Write"
  66734. }(_u || (_u = {})),
  66735. function(e) {
  66736. e.E1d = "1d",
  66737. e.E2d = "2d",
  66738. e.E3d = "3d"
  66739. }(mu || (mu = {})),
  66740. function(e) {
  66741. e[e.CopySrc = 1] = "CopySrc",
  66742. e[e.CopyDst = 2] = "CopyDst",
  66743. e[e.TextureBinding = 4] = "TextureBinding",
  66744. e[e.StorageBinding = 8] = "StorageBinding",
  66745. e[e.RenderAttachment = 16] = "RenderAttachment"
  66746. }(gu || (gu = {})),
  66747. function(e) {
  66748. e.E1d = "1d",
  66749. e.E2d = "2d",
  66750. e.E2dArray = "2d-array",
  66751. e.Cube = "cube",
  66752. e.CubeArray = "cube-array",
  66753. e.E3d = "3d"
  66754. }(vu || (vu = {})),
  66755. function(e) {
  66756. e.All = "all",
  66757. e.StencilOnly = "stencil-only",
  66758. e.DepthOnly = "depth-only"
  66759. }(yu || (yu = {})),
  66760. function(e) {
  66761. e.R8Unorm = "r8unorm",
  66762. e.R8Snorm = "r8snorm",
  66763. e.R8Uint = "r8uint",
  66764. e.R8Sint = "r8sint",
  66765. e.R16Uint = "r16uint",
  66766. e.R16Sint = "r16sint",
  66767. e.R16Float = "r16float",
  66768. e.RG8Unorm = "rg8unorm",
  66769. e.RG8Snorm = "rg8snorm",
  66770. e.RG8Uint = "rg8uint",
  66771. e.RG8Sint = "rg8sint",
  66772. e.R32Uint = "r32uint",
  66773. e.R32Sint = "r32sint",
  66774. e.R32Float = "r32float",
  66775. e.RG16Uint = "rg16uint",
  66776. e.RG16Sint = "rg16sint",
  66777. e.RG16Float = "rg16float",
  66778. e.RGBA8Unorm = "rgba8unorm",
  66779. e.RGBA8UnormSRGB = "rgba8unorm-srgb",
  66780. e.RGBA8Snorm = "rgba8snorm",
  66781. e.RGBA8Uint = "rgba8uint",
  66782. e.RGBA8Sint = "rgba8sint",
  66783. e.BGRA8Unorm = "bgra8unorm",
  66784. e.BGRA8UnormSRGB = "bgra8unorm-srgb",
  66785. e.RGB9E5UFloat = "rgb9e5ufloat",
  66786. e.RGB10A2Unorm = "rgb10a2unorm",
  66787. e.RG11B10UFloat = "rg11b10ufloat",
  66788. e.RG32Uint = "rg32uint",
  66789. e.RG32Sint = "rg32sint",
  66790. e.RG32Float = "rg32float",
  66791. e.RGBA16Uint = "rgba16uint",
  66792. e.RGBA16Sint = "rgba16sint",
  66793. e.RGBA16Float = "rgba16float",
  66794. e.RGBA32Uint = "rgba32uint",
  66795. e.RGBA32Sint = "rgba32sint",
  66796. e.RGBA32Float = "rgba32float",
  66797. e.Stencil8 = "stencil8",
  66798. e.Depth16Unorm = "depth16unorm",
  66799. e.Depth24Plus = "depth24plus",
  66800. e.Depth24PlusStencil8 = "depth24plus-stencil8",
  66801. e.Depth32Float = "depth32float",
  66802. e.BC1RGBAUnorm = "bc1-rgba-unorm",
  66803. e.BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  66804. e.BC2RGBAUnorm = "bc2-rgba-unorm",
  66805. e.BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  66806. e.BC3RGBAUnorm = "bc3-rgba-unorm",
  66807. e.BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  66808. e.BC4RUnorm = "bc4-r-unorm",
  66809. e.BC4RSnorm = "bc4-r-snorm",
  66810. e.BC5RGUnorm = "bc5-rg-unorm",
  66811. e.BC5RGSnorm = "bc5-rg-snorm",
  66812. e.BC6HRGBUFloat = "bc6h-rgb-ufloat",
  66813. e.BC6HRGBFloat = "bc6h-rgb-float",
  66814. e.BC7RGBAUnorm = "bc7-rgba-unorm",
  66815. e.BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  66816. e.ETC2RGB8Unorm = "etc2-rgb8unorm",
  66817. e.ETC2RGB8UnormSRGB = "etc2-rgb8unorm-srgb",
  66818. e.ETC2RGB8A1Unorm = "etc2-rgb8a1unorm",
  66819. e.ETC2RGB8A1UnormSRGB = "etc2-rgb8a1unorm-srgb",
  66820. e.ETC2RGBA8Unorm = "etc2-rgba8unorm",
  66821. e.ETC2RGBA8UnormSRGB = "etc2-rgba8unorm-srgb",
  66822. e.EACR11Unorm = "eac-r11unorm",
  66823. e.EACR11Snorm = "eac-r11snorm",
  66824. e.EACRG11Unorm = "eac-rg11unorm",
  66825. e.EACRG11Snorm = "eac-rg11snorm",
  66826. e.ASTC4x4Unorm = "astc-4x4-unorm",
  66827. e.ASTC4x4UnormSRGB = "astc-4x4-unorm-srgb",
  66828. e.ASTC5x4Unorm = "astc-5x4-unorm",
  66829. e.ASTC5x4UnormSRGB = "astc-5x4-unorm-srgb",
  66830. e.ASTC5x5Unorm = "astc-5x5-unorm",
  66831. e.ASTC5x5UnormSRGB = "astc-5x5-unorm-srgb",
  66832. e.ASTC6x5Unorm = "astc-6x5-unorm",
  66833. e.ASTC6x5UnormSRGB = "astc-6x5-unorm-srgb",
  66834. e.ASTC6x6Unorm = "astc-6x6-unorm",
  66835. e.ASTC6x6UnormSRGB = "astc-6x6-unorm-srgb",
  66836. e.ASTC8x5Unorm = "astc-8x5-unorm",
  66837. e.ASTC8x5UnormSRGB = "astc-8x5-unorm-srgb",
  66838. e.ASTC8x6Unorm = "astc-8x6-unorm",
  66839. e.ASTC8x6UnormSRGB = "astc-8x6-unorm-srgb",
  66840. e.ASTC8x8Unorm = "astc-8x8-unorm",
  66841. e.ASTC8x8UnormSRGB = "astc-8x8-unorm-srgb",
  66842. e.ASTC10x5Unorm = "astc-10x5-unorm",
  66843. e.ASTC10x5UnormSRGB = "astc-10x5-unorm-srgb",
  66844. e.ASTC10x6Unorm = "astc-10x6-unorm",
  66845. e.ASTC10x6UnormSRGB = "astc-10x6-unorm-srgb",
  66846. e.ASTC10x8Unorm = "astc-10x8-unorm",
  66847. e.ASTC10x8UnormSRGB = "astc-10x8-unorm-srgb",
  66848. e.ASTC10x10Unorm = "astc-10x10-unorm",
  66849. e.ASTC10x10UnormSRGB = "astc-10x10-unorm-srgb",
  66850. e.ASTC12x10Unorm = "astc-12x10-unorm",
  66851. e.ASTC12x10UnormSRGB = "astc-12x10-unorm-srgb",
  66852. e.ASTC12x12Unorm = "astc-12x12-unorm",
  66853. e.ASTC12x12UnormSRGB = "astc-12x12-unorm-srgb",
  66854. e.Depth24UnormStencil8 = "depth24unorm-stencil8",
  66855. e.Depth32FloatStencil8 = "depth32float-stencil8"
  66856. }(bu || (bu = {})),
  66857. function(e) {
  66858. e.ClampToEdge = "clamp-to-edge",
  66859. e.Repeat = "repeat",
  66860. e.MirrorRepeat = "mirror-repeat"
  66861. }(Tu || (Tu = {})),
  66862. function(e) {
  66863. e.Nearest = "nearest",
  66864. e.Linear = "linear"
  66865. }(Eu || (Eu = {})),
  66866. function(e) {
  66867. e.Never = "never",
  66868. e.Less = "less",
  66869. e.Equal = "equal",
  66870. e.LessEqual = "less-equal",
  66871. e.Greater = "greater",
  66872. e.NotEqual = "not-equal",
  66873. e.GreaterEqual = "greater-equal",
  66874. e.Always = "always"
  66875. }(Su || (Su = {})),
  66876. function(e) {
  66877. e[e.Vertex = 1] = "Vertex",
  66878. e[e.Fragment = 2] = "Fragment",
  66879. e[e.Compute = 4] = "Compute"
  66880. }(Au || (Au = {})),
  66881. function(e) {
  66882. e.Uniform = "uniform",
  66883. e.Storage = "storage",
  66884. e.ReadOnlyStorage = "read-only-storage"
  66885. }(xu || (xu = {})),
  66886. function(e) {
  66887. e.Filtering = "filtering",
  66888. e.NonFiltering = "non-filtering",
  66889. e.Comparison = "comparison"
  66890. }(Ru || (Ru = {})),
  66891. function(e) {
  66892. e.Float = "float",
  66893. e.UnfilterableFloat = "unfilterable-float",
  66894. e.Depth = "depth",
  66895. e.Sint = "sint",
  66896. e.Uint = "uint"
  66897. }(Cu || (Cu = {})),
  66898. function(e) {
  66899. e.WriteOnly = "write-only"
  66900. }(Pu || (Pu = {})),
  66901. function(e) {
  66902. e.Error = "error",
  66903. e.Warning = "warning",
  66904. e.Info = "info"
  66905. }(Mu || (Mu = {})),
  66906. function(e) {
  66907. e.PointList = "point-list",
  66908. e.LineList = "line-list",
  66909. e.LineStrip = "line-strip",
  66910. e.TriangleList = "triangle-list",
  66911. e.TriangleStrip = "triangle-strip"
  66912. }(Iu || (Iu = {})),
  66913. function(e) {
  66914. e.CCW = "ccw",
  66915. e.CW = "cw"
  66916. }(Ou || (Ou = {})),
  66917. function(e) {
  66918. e.None = "none",
  66919. e.Front = "front",
  66920. e.Back = "back"
  66921. }(Du || (Du = {})),
  66922. function(e) {
  66923. e[e.Red = 1] = "Red",
  66924. e[e.Green = 2] = "Green",
  66925. e[e.Blue = 4] = "Blue",
  66926. e[e.Alpha = 8] = "Alpha",
  66927. e[e.All = 15] = "All"
  66928. }(Nu || (Nu = {})),
  66929. function(e) {
  66930. e.Zero = "zero",
  66931. e.One = "one",
  66932. e.Src = "src",
  66933. e.OneMinusSrc = "one-minus-src",
  66934. e.SrcAlpha = "src-alpha",
  66935. e.OneMinusSrcAlpha = "one-minus-src-alpha",
  66936. e.Dst = "dst",
  66937. e.OneMinusDst = "one-minus-dst",
  66938. e.DstAlpha = "dst-alpha",
  66939. e.OneMinusDstAlpha = "one-minus-dst-alpha",
  66940. e.SrcAlphaSaturated = "src-alpha-saturated",
  66941. e.Constant = "constant",
  66942. e.OneMinusConstant = "one-minus-constant"
  66943. }(Lu || (Lu = {})),
  66944. function(e) {
  66945. e.Add = "add",
  66946. e.Subtract = "subtract",
  66947. e.ReverseSubtract = "reverse-subtract",
  66948. e.Min = "min",
  66949. e.Max = "max"
  66950. }(Fu || (Fu = {})),
  66951. function(e) {
  66952. e.Keep = "keep",
  66953. e.Zero = "zero",
  66954. e.Replace = "replace",
  66955. e.Invert = "invert",
  66956. e.IncrementClamp = "increment-clamp",
  66957. e.DecrementClamp = "decrement-clamp",
  66958. e.IncrementWrap = "increment-wrap",
  66959. e.DecrementWrap = "decrement-wrap"
  66960. }(wu || (wu = {})),
  66961. function(e) {
  66962. e.Uint16 = "uint16",
  66963. e.Uint32 = "uint32"
  66964. }(Bu || (Bu = {})),
  66965. function(e) {
  66966. e.Uint8x2 = "uint8x2",
  66967. e.Uint8x4 = "uint8x4",
  66968. e.Sint8x2 = "sint8x2",
  66969. e.Sint8x4 = "sint8x4",
  66970. e.Unorm8x2 = "unorm8x2",
  66971. e.Unorm8x4 = "unorm8x4",
  66972. e.Snorm8x2 = "snorm8x2",
  66973. e.Snorm8x4 = "snorm8x4",
  66974. e.Uint16x2 = "uint16x2",
  66975. e.Uint16x4 = "uint16x4",
  66976. e.Sint16x2 = "sint16x2",
  66977. e.Sint16x4 = "sint16x4",
  66978. e.Unorm16x2 = "unorm16x2",
  66979. e.Unorm16x4 = "unorm16x4",
  66980. e.Snorm16x2 = "snorm16x2",
  66981. e.Snorm16x4 = "snorm16x4",
  66982. e.Float16x2 = "float16x2",
  66983. e.Float16x4 = "float16x4",
  66984. e.Float32 = "float32",
  66985. e.Float32x2 = "float32x2",
  66986. e.Float32x3 = "float32x3",
  66987. e.Float32x4 = "float32x4",
  66988. e.Uint32 = "uint32",
  66989. e.Uint32x2 = "uint32x2",
  66990. e.Uint32x3 = "uint32x3",
  66991. e.Uint32x4 = "uint32x4",
  66992. e.Sint32 = "sint32",
  66993. e.Sint32x2 = "sint32x2",
  66994. e.Sint32x3 = "sint32x3",
  66995. e.Sint32x4 = "sint32x4"
  66996. }(Uu || (Uu = {})),
  66997. function(e) {
  66998. e.Vertex = "vertex",
  66999. e.Instance = "instance"
  67000. }(Vu || (Vu = {})),
  67001. function(e) {
  67002. e.Beginning = "beginning",
  67003. e.End = "end"
  67004. }(ku || (ku = {})),
  67005. function(e) {
  67006. e.Beginning = "beginning",
  67007. e.End = "end"
  67008. }(Gu || (Gu = {})),
  67009. function(e) {
  67010. e.Load = "load",
  67011. e.Clear = "clear"
  67012. }(zu || (zu = {})),
  67013. function(e) {
  67014. e.Store = "store",
  67015. e.Discard = "discard"
  67016. }(Wu || (Wu = {})),
  67017. function(e) {
  67018. e.Occlusion = "occlusion",
  67019. e.Timestamp = "timestamp"
  67020. }(Hu || (Hu = {})),
  67021. function(e) {
  67022. e.Opaque = "opaque",
  67023. e.Premultiplied = "premultiplied"
  67024. }(Xu || (Xu = {})),
  67025. function(e) {
  67026. e.Destroyed = "destroyed"
  67027. }(ju || (ju = {})),
  67028. function(e) {
  67029. e.OutOfMemory = "out-of-memory",
  67030. e.Validation = "validation"
  67031. }(Yu || (Yu = {}));
  67032. var Qu = function() {
  67033. function e() {
  67034. this.shaderLanguage = st.GLSL
  67035. }
  67036. return e.prototype._addUniformToLeftOverUBO = function(e, t, i) {
  67037. var n, r;
  67038. e = (n = this._getArraySize(e, t, i))[0],
  67039. t = n[1],
  67040. r = n[2];
  67041. for (var o = 0; o < this._webgpuProcessingContext.leftOverUniforms.length; o++)
  67042. if (this._webgpuProcessingContext.leftOverUniforms[o].name === e)
  67043. return;
  67044. this._webgpuProcessingContext.leftOverUniforms.push({
  67045. name: e,
  67046. type: t,
  67047. length: r
  67048. })
  67049. }
  67050. ,
  67051. e.prototype._buildLeftOverUBO = function() {
  67052. if (!this._webgpuProcessingContext.leftOverUniforms.length)
  67053. return "";
  67054. var t = e.LeftOvertUBOName
  67055. , i = this._webgpuProcessingContext.availableBuffers[t];
  67056. return i || (i = {
  67057. binding: this._webgpuProcessingContext.getNextFreeUBOBinding()
  67058. },
  67059. this._webgpuProcessingContext.availableBuffers[t] = i,
  67060. this._addBufferBindingDescription(t, i, xu.Uniform, !0),
  67061. this._addBufferBindingDescription(t, i, xu.Uniform, !1)),
  67062. this._generateLeftOverUBOCode(t, i)
  67063. }
  67064. ,
  67065. e.prototype._collectBindingNames = function() {
  67066. for (var e = 0; e < this._webgpuProcessingContext.bindGroupLayoutEntries.length; e++) {
  67067. var t = this._webgpuProcessingContext.bindGroupLayoutEntries[e];
  67068. if (void 0 !== t)
  67069. for (var i = 0; i < t.length; i++) {
  67070. var n = this._webgpuProcessingContext.bindGroupLayoutEntries[e][i]
  67071. , r = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].name
  67072. , o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].nameInArrayOfTexture;
  67073. n && (n.texture || n.externalTexture || n.storageTexture ? this._webgpuProcessingContext.textureNames.push(o) : n.sampler ? this._webgpuProcessingContext.samplerNames.push(r) : n.buffer && this._webgpuProcessingContext.bufferNames.push(r))
  67074. }
  67075. else
  67076. this._webgpuProcessingContext.bindGroupLayoutEntries[e] = []
  67077. }
  67078. }
  67079. ,
  67080. e.prototype._preCreateBindGroupEntries = function() {
  67081. for (var e = this._webgpuProcessingContext.bindGroupEntries, t = 0; t < this._webgpuProcessingContext.bindGroupLayoutEntries.length; t++) {
  67082. for (var i = this._webgpuProcessingContext.bindGroupLayoutEntries[t], n = [], r = 0; r < i.length; r++) {
  67083. var o = this._webgpuProcessingContext.bindGroupLayoutEntries[t][r];
  67084. o.sampler || o.texture || o.storageTexture || o.externalTexture ? n.push({
  67085. binding: o.binding,
  67086. resource: void 0
  67087. }) : o.buffer && n.push({
  67088. binding: o.binding,
  67089. resource: {
  67090. buffer: void 0,
  67091. offset: 0,
  67092. size: 0
  67093. }
  67094. })
  67095. }
  67096. e[t] = n
  67097. }
  67098. }
  67099. ,
  67100. e.prototype._addTextureBindingDescription = function(e, t, i, n, r, o) {
  67101. var a = t.textures[i]
  67102. , s = a.groupIndex
  67103. , l = a.bindingIndex;
  67104. if (this._webgpuProcessingContext.bindGroupLayoutEntries[s] || (this._webgpuProcessingContext.bindGroupLayoutEntries[s] = [],
  67105. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s] = []),
  67106. !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l]) {
  67107. var c;
  67108. c = null === n ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
  67109. binding: l,
  67110. visibility: 0,
  67111. externalTexture: {}
  67112. }) : r ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
  67113. binding: l,
  67114. visibility: 0,
  67115. storageTexture: {
  67116. access: Pu.WriteOnly,
  67117. format: r,
  67118. viewDimension: n
  67119. }
  67120. }) : this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
  67121. binding: l,
  67122. visibility: 0,
  67123. texture: {
  67124. sampleType: t.sampleType,
  67125. viewDimension: n,
  67126. multisampled: !1
  67127. }
  67128. });
  67129. var u = t.isTextureArray ? e + i : e;
  67130. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l] = {
  67131. name: e,
  67132. index: c - 1,
  67133. nameInArrayOfTexture: u
  67134. }
  67135. }
  67136. l = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l].index,
  67137. this._webgpuProcessingContext.bindGroupLayoutEntries[s][l].visibility |= o ? Au.Vertex : Au.Fragment
  67138. }
  67139. ,
  67140. e.prototype._addSamplerBindingDescription = function(e, t, i) {
  67141. var n = t.binding
  67142. , r = n.groupIndex
  67143. , o = n.bindingIndex;
  67144. if (this._webgpuProcessingContext.bindGroupLayoutEntries[r] || (this._webgpuProcessingContext.bindGroupLayoutEntries[r] = [],
  67145. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r] = []),
  67146. !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o]) {
  67147. var a = this._webgpuProcessingContext.bindGroupLayoutEntries[r].push({
  67148. binding: o,
  67149. visibility: 0,
  67150. sampler: {
  67151. type: t.type
  67152. }
  67153. });
  67154. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o] = {
  67155. name: e,
  67156. index: a - 1
  67157. }
  67158. }
  67159. o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o].index,
  67160. this._webgpuProcessingContext.bindGroupLayoutEntries[r][o].visibility |= i ? Au.Vertex : Au.Fragment
  67161. }
  67162. ,
  67163. e.prototype._addBufferBindingDescription = function(e, t, i, n) {
  67164. var r = t.binding
  67165. , o = r.groupIndex
  67166. , a = r.bindingIndex;
  67167. if (this._webgpuProcessingContext.bindGroupLayoutEntries[o] || (this._webgpuProcessingContext.bindGroupLayoutEntries[o] = [],
  67168. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o] = []),
  67169. !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]) {
  67170. var s = this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({
  67171. binding: a,
  67172. visibility: 0,
  67173. buffer: {
  67174. type: i
  67175. }
  67176. });
  67177. this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a] = {
  67178. name: e,
  67179. index: s - 1
  67180. }
  67181. }
  67182. a = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a].index,
  67183. this._webgpuProcessingContext.bindGroupLayoutEntries[o][a].visibility |= n ? Au.Vertex : Au.Fragment
  67184. }
  67185. ,
  67186. e.prototype._injectStartingAndEndingCode = function(e, t, i, n) {
  67187. if (i) {
  67188. var r = e.indexOf(t);
  67189. if (r >= 0) {
  67190. for (; r++ < e.length && "{" != e.charAt(r); )
  67191. ;
  67192. if (r < e.length) {
  67193. for (; r++ < e.length && "\n" != e.charAt(r); )
  67194. ;
  67195. if (r < e.length) {
  67196. var o = e.substring(0, r + 1)
  67197. , a = e.substring(r + 1);
  67198. e = o + i + a
  67199. }
  67200. }
  67201. }
  67202. }
  67203. if (n) {
  67204. var s = e.lastIndexOf("}");
  67205. e = e.substring(0, s),
  67206. e += n + "\n}"
  67207. }
  67208. return e
  67209. }
  67210. ,
  67211. e.AutoSamplerSuffix = "Sampler",
  67212. e.LeftOvertUBOName = "LeftOver",
  67213. e.InternalsUBOName = "Internals",
  67214. e.UniformSizes = {
  67215. bool: 1,
  67216. int: 1,
  67217. float: 1,
  67218. vec2: 2,
  67219. ivec2: 2,
  67220. vec3: 3,
  67221. ivec3: 3,
  67222. vec4: 4,
  67223. ivec4: 4,
  67224. mat2: 4,
  67225. mat3: 12,
  67226. mat4: 16,
  67227. i32: 1,
  67228. u32: 1,
  67229. f32: 1,
  67230. mat2x2: 4,
  67231. mat3x3: 12,
  67232. mat4x4: 16
  67233. },
  67234. e._SamplerFunctionByWebGLSamplerType = {
  67235. sampler2D: "sampler2D",
  67236. sampler2DArray: "sampler2DArray",
  67237. sampler2DShadow: "sampler2DShadow",
  67238. sampler2DArrayShadow: "sampler2DArrayShadow",
  67239. samplerCube: "samplerCube",
  67240. sampler3D: "sampler3D"
  67241. },
  67242. e._TextureTypeByWebGLSamplerType = {
  67243. sampler2D: "texture2D",
  67244. sampler2DArray: "texture2DArray",
  67245. sampler2DShadow: "texture2D",
  67246. sampler2DArrayShadow: "texture2DArray",
  67247. samplerCube: "textureCube",
  67248. samplerCubeArray: "textureCubeArray",
  67249. sampler3D: "texture3D"
  67250. },
  67251. e._GpuTextureViewDimensionByWebGPUTextureType = {
  67252. textureCube: vu.Cube,
  67253. textureCubeArray: vu.CubeArray,
  67254. texture2D: vu.E2d,
  67255. texture2DArray: vu.E2dArray,
  67256. texture3D: vu.E3d
  67257. },
  67258. e._SamplerTypeByWebGLSamplerType = {
  67259. sampler2DShadow: "samplerShadow",
  67260. sampler2DArrayShadow: "samplerShadow"
  67261. },
  67262. e._IsComparisonSamplerByWebGPUSamplerType = {
  67263. samplerShadow: !0,
  67264. samplerArrayShadow: !0,
  67265. sampler: !1
  67266. },
  67267. e
  67268. }()
  67269. , qu = function() {
  67270. function e(e, t) {
  67271. this._name = "unnamed",
  67272. this.shaderProcessingContext = e,
  67273. this._leftOverUniformsByName = {},
  67274. this.engine = t
  67275. }
  67276. return Object.defineProperty(e.prototype, "isAsync", {
  67277. get: function() {
  67278. return !1
  67279. },
  67280. enumerable: !1,
  67281. configurable: !0
  67282. }),
  67283. Object.defineProperty(e.prototype, "isReady", {
  67284. get: function() {
  67285. return !!this.stages
  67286. },
  67287. enumerable: !1,
  67288. configurable: !0
  67289. }),
  67290. e.prototype._handlesSpectorRebuildCallback = function() {}
  67291. ,
  67292. e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
  67293. var l = this.engine;
  67294. e._fragmentSourceCode = "",
  67295. e._vertexSourceCode = "";
  67296. var c, u = this.shaderProcessingContext.availableTextures;
  67297. for (c = 0; c < r.length; c++) {
  67298. var h = r[c]
  67299. , d = u[r[c]];
  67300. null == d || null == d ? (r.splice(c, 1),
  67301. c--) : o[h] = c
  67302. }
  67303. for (var p = 0, f = l.getAttributes(this, a); p < f.length; p++) {
  67304. var _ = f[p];
  67305. s.push(_)
  67306. }
  67307. this.buildUniformLayout();
  67308. var m = []
  67309. , g = [];
  67310. for (c = 0; c < a.length; c++) {
  67311. var v = s[c];
  67312. v >= 0 && (m.push(a[c]),
  67313. g.push(v))
  67314. }
  67315. this.shaderProcessingContext.attributeNamesFromEffect = m,
  67316. this.shaderProcessingContext.attributeLocationsFromEffect = g
  67317. }
  67318. ,
  67319. e.prototype.buildUniformLayout = function() {
  67320. if (this.shaderProcessingContext.leftOverUniforms.length) {
  67321. this.uniformBuffer = new Fi(this.engine,void 0,void 0,"leftOver-" + this._name);
  67322. for (var e = 0, t = this.shaderProcessingContext.leftOverUniforms; e < t.length; e++) {
  67323. var i = t[e]
  67324. , n = i.type.replace(/^(.*?)(<.*>)?$/, "$1")
  67325. , r = Qu.UniformSizes[n];
  67326. this.uniformBuffer.addUniform(i.name, r, i.length),
  67327. this._leftOverUniformsByName[i.name] = i.type
  67328. }
  67329. this.uniformBuffer.create()
  67330. }
  67331. }
  67332. ,
  67333. e.prototype.dispose = function() {
  67334. this.uniformBuffer && this.uniformBuffer.dispose()
  67335. }
  67336. ,
  67337. e.prototype.setInt = function(e, t) {
  67338. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt(e, t)
  67339. }
  67340. ,
  67341. e.prototype.setInt2 = function(e, t, i) {
  67342. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt2(e, t, i)
  67343. }
  67344. ,
  67345. e.prototype.setInt3 = function(e, t, i, n) {
  67346. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt3(e, t, i, n)
  67347. }
  67348. ,
  67349. e.prototype.setInt4 = function(e, t, i, n, r) {
  67350. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt4(e, t, i, n, r)
  67351. }
  67352. ,
  67353. e.prototype.setIntArray = function(e, t) {
  67354. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateIntArray(e, t)
  67355. }
  67356. ,
  67357. e.prototype.setIntArray2 = function(e, t) {
  67358. this.setIntArray(e, t)
  67359. }
  67360. ,
  67361. e.prototype.setIntArray3 = function(e, t) {
  67362. this.setIntArray(e, t)
  67363. }
  67364. ,
  67365. e.prototype.setIntArray4 = function(e, t) {
  67366. this.setIntArray(e, t)
  67367. }
  67368. ,
  67369. e.prototype.setArray = function(e, t) {
  67370. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateArray(e, t)
  67371. }
  67372. ,
  67373. e.prototype.setArray2 = function(e, t) {
  67374. this.setArray(e, t)
  67375. }
  67376. ,
  67377. e.prototype.setArray3 = function(e, t) {
  67378. this.setArray(e, t)
  67379. }
  67380. ,
  67381. e.prototype.setArray4 = function(e, t) {
  67382. this.setArray(e, t)
  67383. }
  67384. ,
  67385. e.prototype.setMatrices = function(e, t) {
  67386. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrices(e, t)
  67387. }
  67388. ,
  67389. e.prototype.setMatrix = function(e, t) {
  67390. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix(e, t)
  67391. }
  67392. ,
  67393. e.prototype.setMatrix3x3 = function(e, t) {
  67394. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix3x3(e, t)
  67395. }
  67396. ,
  67397. e.prototype.setMatrix2x2 = function(e, t) {
  67398. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix2x2(e, t)
  67399. }
  67400. ,
  67401. e.prototype.setFloat = function(e, t) {
  67402. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat(e, t)
  67403. }
  67404. ,
  67405. e.prototype.setVector2 = function(e, t) {
  67406. this.setFloat2(e, t.x, t.y)
  67407. }
  67408. ,
  67409. e.prototype.setFloat2 = function(e, t, i) {
  67410. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat2(e, t, i)
  67411. }
  67412. ,
  67413. e.prototype.setVector3 = function(e, t) {
  67414. this.setFloat3(e, t.x, t.y, t.z)
  67415. }
  67416. ,
  67417. e.prototype.setFloat3 = function(e, t, i, n) {
  67418. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat3(e, t, i, n)
  67419. }
  67420. ,
  67421. e.prototype.setVector4 = function(e, t) {
  67422. this.setFloat4(e, t.x, t.y, t.z, t.w)
  67423. }
  67424. ,
  67425. e.prototype.setFloat4 = function(e, t, i, n, r) {
  67426. this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat4(e, t, i, n, r)
  67427. }
  67428. ,
  67429. e.prototype.setColor3 = function(e, t) {
  67430. this.setFloat3(e, t.r, t.g, t.b)
  67431. }
  67432. ,
  67433. e.prototype.setColor4 = function(e, t, i) {
  67434. this.setFloat4(e, t.r, t.g, t.b, i)
  67435. }
  67436. ,
  67437. e.prototype.setDirectColor4 = function(e, t) {
  67438. this.setFloat4(e, t.r, t.g, t.b, t.a)
  67439. }
  67440. ,
  67441. e.prototype._getVertexShaderCode = function() {
  67442. var e;
  67443. return null === (e = this.sources) || void 0 === e ? void 0 : e.vertex
  67444. }
  67445. ,
  67446. e.prototype._getFragmentShaderCode = function() {
  67447. var e;
  67448. return null === (e = this.sources) || void 0 === e ? void 0 : e.fragment
  67449. }
  67450. ,
  67451. e
  67452. }()
  67453. , Zu = {
  67454. mat2: 2,
  67455. mat3: 3,
  67456. mat4: 4,
  67457. mat2x2: 2,
  67458. mat3x3: 3,
  67459. mat4x4: 4
  67460. }
  67461. , Ju = function() {
  67462. function e(e) {
  67463. this.shaderLanguage = e,
  67464. this._attributeNextLocation = 0,
  67465. this._varyingNextLocation = 0,
  67466. this.freeGroupIndex = 0,
  67467. this.freeBindingIndex = 0,
  67468. this.availableVaryings = {},
  67469. this.availableAttributes = {},
  67470. this.availableBuffers = {},
  67471. this.availableTextures = {},
  67472. this.availableSamplers = {},
  67473. this.orderedAttributes = [],
  67474. this.bindGroupLayoutEntries = [],
  67475. this.bindGroupLayoutEntryInfo = [],
  67476. this.bindGroupEntries = [],
  67477. this.bufferNames = [],
  67478. this.textureNames = [],
  67479. this.samplerNames = [],
  67480. this.leftOverUniforms = [],
  67481. this._findStartingGroupBinding()
  67482. }
  67483. return Object.defineProperty(e, "KnownUBOs", {
  67484. get: function() {
  67485. return e._SimplifiedKnownBindings ? e._SimplifiedKnownUBOs : e._KnownUBOs
  67486. },
  67487. enumerable: !1,
  67488. configurable: !0
  67489. }),
  67490. e.prototype._findStartingGroupBinding = function() {
  67491. var t = e.KnownUBOs
  67492. , i = [];
  67493. for (var n in t) {
  67494. var r = t[n].binding;
  67495. -1 !== r.groupIndex && (void 0 === i[r.groupIndex] ? i[r.groupIndex] = r.bindingIndex : i[r.groupIndex] = Math.max(i[r.groupIndex], r.bindingIndex))
  67496. }
  67497. this.freeGroupIndex = i.length - 1,
  67498. 0 === this.freeGroupIndex ? (this.freeGroupIndex++,
  67499. this.freeBindingIndex = 0) : this.freeBindingIndex = i[i.length - 1] + 1
  67500. }
  67501. ,
  67502. e.prototype.getAttributeNextLocation = function(e, t) {
  67503. var i;
  67504. void 0 === t && (t = 0);
  67505. var n = this._attributeNextLocation;
  67506. return this._attributeNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
  67507. n
  67508. }
  67509. ,
  67510. e.prototype.getVaryingNextLocation = function(e, t) {
  67511. var i;
  67512. void 0 === t && (t = 0);
  67513. var n = this._varyingNextLocation;
  67514. return this._varyingNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
  67515. n
  67516. }
  67517. ,
  67518. e.prototype.getNextFreeUBOBinding = function() {
  67519. return this._getNextFreeBinding(1)
  67520. }
  67521. ,
  67522. e.prototype._getNextFreeBinding = function(e) {
  67523. if (this.freeBindingIndex > 65536 - e && (this.freeGroupIndex++,
  67524. this.freeBindingIndex = 0),
  67525. 4 === this.freeGroupIndex)
  67526. throw "Too many textures or UBOs have been declared and it is not supported in WebGPU.";
  67527. var t = {
  67528. groupIndex: this.freeGroupIndex,
  67529. bindingIndex: this.freeBindingIndex
  67530. };
  67531. return this.freeBindingIndex += e,
  67532. t
  67533. }
  67534. ,
  67535. e._SimplifiedKnownBindings = !0,
  67536. e._SimplifiedKnownUBOs = {
  67537. Scene: {
  67538. binding: {
  67539. groupIndex: 0,
  67540. bindingIndex: 0
  67541. }
  67542. },
  67543. Light0: {
  67544. binding: {
  67545. groupIndex: -1,
  67546. bindingIndex: -1
  67547. }
  67548. },
  67549. Light1: {
  67550. binding: {
  67551. groupIndex: -1,
  67552. bindingIndex: -1
  67553. }
  67554. },
  67555. Light2: {
  67556. binding: {
  67557. groupIndex: -1,
  67558. bindingIndex: -1
  67559. }
  67560. },
  67561. Light3: {
  67562. binding: {
  67563. groupIndex: -1,
  67564. bindingIndex: -1
  67565. }
  67566. },
  67567. Light4: {
  67568. binding: {
  67569. groupIndex: -1,
  67570. bindingIndex: -1
  67571. }
  67572. },
  67573. Light5: {
  67574. binding: {
  67575. groupIndex: -1,
  67576. bindingIndex: -1
  67577. }
  67578. },
  67579. Light6: {
  67580. binding: {
  67581. groupIndex: -1,
  67582. bindingIndex: -1
  67583. }
  67584. },
  67585. Light7: {
  67586. binding: {
  67587. groupIndex: -1,
  67588. bindingIndex: -1
  67589. }
  67590. },
  67591. Light8: {
  67592. binding: {
  67593. groupIndex: -1,
  67594. bindingIndex: -1
  67595. }
  67596. },
  67597. Light9: {
  67598. binding: {
  67599. groupIndex: -1,
  67600. bindingIndex: -1
  67601. }
  67602. },
  67603. Light10: {
  67604. binding: {
  67605. groupIndex: -1,
  67606. bindingIndex: -1
  67607. }
  67608. },
  67609. Light11: {
  67610. binding: {
  67611. groupIndex: -1,
  67612. bindingIndex: -1
  67613. }
  67614. },
  67615. Light12: {
  67616. binding: {
  67617. groupIndex: -1,
  67618. bindingIndex: -1
  67619. }
  67620. },
  67621. Light13: {
  67622. binding: {
  67623. groupIndex: -1,
  67624. bindingIndex: -1
  67625. }
  67626. },
  67627. Light14: {
  67628. binding: {
  67629. groupIndex: -1,
  67630. bindingIndex: -1
  67631. }
  67632. },
  67633. Light15: {
  67634. binding: {
  67635. groupIndex: -1,
  67636. bindingIndex: -1
  67637. }
  67638. },
  67639. Light16: {
  67640. binding: {
  67641. groupIndex: -1,
  67642. bindingIndex: -1
  67643. }
  67644. },
  67645. Light17: {
  67646. binding: {
  67647. groupIndex: -1,
  67648. bindingIndex: -1
  67649. }
  67650. },
  67651. Light18: {
  67652. binding: {
  67653. groupIndex: -1,
  67654. bindingIndex: -1
  67655. }
  67656. },
  67657. Light19: {
  67658. binding: {
  67659. groupIndex: -1,
  67660. bindingIndex: -1
  67661. }
  67662. },
  67663. Light20: {
  67664. binding: {
  67665. groupIndex: -1,
  67666. bindingIndex: -1
  67667. }
  67668. },
  67669. Light21: {
  67670. binding: {
  67671. groupIndex: -1,
  67672. bindingIndex: -1
  67673. }
  67674. },
  67675. Light22: {
  67676. binding: {
  67677. groupIndex: -1,
  67678. bindingIndex: -1
  67679. }
  67680. },
  67681. Light23: {
  67682. binding: {
  67683. groupIndex: -1,
  67684. bindingIndex: -1
  67685. }
  67686. },
  67687. Light24: {
  67688. binding: {
  67689. groupIndex: -1,
  67690. bindingIndex: -1
  67691. }
  67692. },
  67693. Light25: {
  67694. binding: {
  67695. groupIndex: -1,
  67696. bindingIndex: -1
  67697. }
  67698. },
  67699. Light26: {
  67700. binding: {
  67701. groupIndex: -1,
  67702. bindingIndex: -1
  67703. }
  67704. },
  67705. Light27: {
  67706. binding: {
  67707. groupIndex: -1,
  67708. bindingIndex: -1
  67709. }
  67710. },
  67711. Light28: {
  67712. binding: {
  67713. groupIndex: -1,
  67714. bindingIndex: -1
  67715. }
  67716. },
  67717. Light29: {
  67718. binding: {
  67719. groupIndex: -1,
  67720. bindingIndex: -1
  67721. }
  67722. },
  67723. Light30: {
  67724. binding: {
  67725. groupIndex: -1,
  67726. bindingIndex: -1
  67727. }
  67728. },
  67729. Light31: {
  67730. binding: {
  67731. groupIndex: -1,
  67732. bindingIndex: -1
  67733. }
  67734. },
  67735. Material: {
  67736. binding: {
  67737. groupIndex: -1,
  67738. bindingIndex: -1
  67739. }
  67740. },
  67741. Mesh: {
  67742. binding: {
  67743. groupIndex: -1,
  67744. bindingIndex: -1
  67745. }
  67746. },
  67747. Internals: {
  67748. binding: {
  67749. groupIndex: -1,
  67750. bindingIndex: -1
  67751. }
  67752. }
  67753. },
  67754. e._KnownUBOs = {
  67755. Scene: {
  67756. binding: {
  67757. groupIndex: 0,
  67758. bindingIndex: 0
  67759. }
  67760. },
  67761. Light0: {
  67762. binding: {
  67763. groupIndex: 1,
  67764. bindingIndex: 0
  67765. }
  67766. },
  67767. Light1: {
  67768. binding: {
  67769. groupIndex: 1,
  67770. bindingIndex: 1
  67771. }
  67772. },
  67773. Light2: {
  67774. binding: {
  67775. groupIndex: 1,
  67776. bindingIndex: 2
  67777. }
  67778. },
  67779. Light3: {
  67780. binding: {
  67781. groupIndex: 1,
  67782. bindingIndex: 3
  67783. }
  67784. },
  67785. Light4: {
  67786. binding: {
  67787. groupIndex: 1,
  67788. bindingIndex: 4
  67789. }
  67790. },
  67791. Light5: {
  67792. binding: {
  67793. groupIndex: 1,
  67794. bindingIndex: 5
  67795. }
  67796. },
  67797. Light6: {
  67798. binding: {
  67799. groupIndex: 1,
  67800. bindingIndex: 6
  67801. }
  67802. },
  67803. Light7: {
  67804. binding: {
  67805. groupIndex: 1,
  67806. bindingIndex: 7
  67807. }
  67808. },
  67809. Light8: {
  67810. binding: {
  67811. groupIndex: 1,
  67812. bindingIndex: 8
  67813. }
  67814. },
  67815. Light9: {
  67816. binding: {
  67817. groupIndex: 1,
  67818. bindingIndex: 9
  67819. }
  67820. },
  67821. Light10: {
  67822. binding: {
  67823. groupIndex: 1,
  67824. bindingIndex: 10
  67825. }
  67826. },
  67827. Light11: {
  67828. binding: {
  67829. groupIndex: 1,
  67830. bindingIndex: 11
  67831. }
  67832. },
  67833. Light12: {
  67834. binding: {
  67835. groupIndex: 1,
  67836. bindingIndex: 12
  67837. }
  67838. },
  67839. Light13: {
  67840. binding: {
  67841. groupIndex: 1,
  67842. bindingIndex: 13
  67843. }
  67844. },
  67845. Light14: {
  67846. binding: {
  67847. groupIndex: 1,
  67848. bindingIndex: 14
  67849. }
  67850. },
  67851. Light15: {
  67852. binding: {
  67853. groupIndex: 1,
  67854. bindingIndex: 15
  67855. }
  67856. },
  67857. Light16: {
  67858. binding: {
  67859. groupIndex: 1,
  67860. bindingIndex: 16
  67861. }
  67862. },
  67863. Light17: {
  67864. binding: {
  67865. groupIndex: 1,
  67866. bindingIndex: 17
  67867. }
  67868. },
  67869. Light18: {
  67870. binding: {
  67871. groupIndex: 1,
  67872. bindingIndex: 18
  67873. }
  67874. },
  67875. Light19: {
  67876. binding: {
  67877. groupIndex: 1,
  67878. bindingIndex: 19
  67879. }
  67880. },
  67881. Light20: {
  67882. binding: {
  67883. groupIndex: 1,
  67884. bindingIndex: 20
  67885. }
  67886. },
  67887. Light21: {
  67888. binding: {
  67889. groupIndex: 1,
  67890. bindingIndex: 21
  67891. }
  67892. },
  67893. Light22: {
  67894. binding: {
  67895. groupIndex: 1,
  67896. bindingIndex: 22
  67897. }
  67898. },
  67899. Light23: {
  67900. binding: {
  67901. groupIndex: 1,
  67902. bindingIndex: 23
  67903. }
  67904. },
  67905. Light24: {
  67906. binding: {
  67907. groupIndex: 1,
  67908. bindingIndex: 24
  67909. }
  67910. },
  67911. Light25: {
  67912. binding: {
  67913. groupIndex: 1,
  67914. bindingIndex: 25
  67915. }
  67916. },
  67917. Light26: {
  67918. binding: {
  67919. groupIndex: 1,
  67920. bindingIndex: 26
  67921. }
  67922. },
  67923. Light27: {
  67924. binding: {
  67925. groupIndex: 1,
  67926. bindingIndex: 27
  67927. }
  67928. },
  67929. Light28: {
  67930. binding: {
  67931. groupIndex: 1,
  67932. bindingIndex: 28
  67933. }
  67934. },
  67935. Light29: {
  67936. binding: {
  67937. groupIndex: 1,
  67938. bindingIndex: 29
  67939. }
  67940. },
  67941. Light30: {
  67942. binding: {
  67943. groupIndex: 1,
  67944. bindingIndex: 30
  67945. }
  67946. },
  67947. Light31: {
  67948. binding: {
  67949. groupIndex: 1,
  67950. bindingIndex: 31
  67951. }
  67952. },
  67953. Material: {
  67954. binding: {
  67955. groupIndex: 2,
  67956. bindingIndex: 0
  67957. }
  67958. },
  67959. Mesh: {
  67960. binding: {
  67961. groupIndex: 2,
  67962. bindingIndex: 1
  67963. }
  67964. },
  67965. Internals: {
  67966. binding: {
  67967. groupIndex: 2,
  67968. bindingIndex: 2
  67969. }
  67970. }
  67971. },
  67972. e
  67973. }()
  67974. , $u = function(e) {
  67975. function t() {
  67976. var t = null !== e && e.apply(this, arguments) || this;
  67977. return t._missingVaryings = [],
  67978. t._textureArrayProcessing = [],
  67979. t.shaderLanguage = st.GLSL,
  67980. t
  67981. }
  67982. return U(t, e),
  67983. t.prototype._getArraySize = function(e, t, i) {
  67984. var n = 0
  67985. , r = e.indexOf("[")
  67986. , o = e.indexOf("]");
  67987. if (r > 0 && o > 0) {
  67988. var a = e.substring(r + 1, o);
  67989. n = +a,
  67990. isNaN(n) && (n = +i[a.trim()]),
  67991. e = e.substr(0, r)
  67992. }
  67993. return [e, t, n]
  67994. }
  67995. ,
  67996. t.prototype.initializeShaders = function(e) {
  67997. this._webgpuProcessingContext = e,
  67998. this._missingVaryings.length = 0,
  67999. this._textureArrayProcessing.length = 0
  68000. }
  68001. ,
  68002. t.prototype.preProcessShaderCode = function(e, t) {
  68003. var i = "uniform ".concat(Qu.InternalsUBOName, " {\nfloat yFactor__;\nfloat textureOutputHeight__;\n};\n");
  68004. return t ? i + "##INJECTCODE##\n" + e : i + e
  68005. }
  68006. ,
  68007. t.prototype.varyingProcessor = function(e, t, i) {
  68008. this._preProcessors = i;
  68009. var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
  68010. if (null != n) {
  68011. var r, o = n[1], a = n[2];
  68012. t ? (r = this._webgpuProcessingContext.availableVaryings[a],
  68013. this._missingVaryings[r] = "",
  68014. void 0 === r && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.'))) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
  68015. this._webgpuProcessingContext.availableVaryings[a] = r,
  68016. this._missingVaryings[r] = "layout(location = ".concat(r, ") in ").concat(o, " ").concat(a, ";")),
  68017. e = e.replace(n[0], void 0 === r ? "" : "layout(location = ".concat(r, ") ").concat(t ? "in" : "out", " ").concat(o, " ").concat(a, ";"))
  68018. }
  68019. return e
  68020. }
  68021. ,
  68022. t.prototype.attributeProcessor = function(e, t) {
  68023. this._preProcessors = t;
  68024. var i = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm.exec(e);
  68025. if (null != i) {
  68026. var n = i[1]
  68027. , r = i[2]
  68028. , o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
  68029. this._webgpuProcessingContext.availableAttributes[r] = o,
  68030. this._webgpuProcessingContext.orderedAttributes[o] = r,
  68031. e = e.replace(i[0], "layout(location = ".concat(o, ") in ").concat(n, " ").concat(r, ";"))
  68032. }
  68033. return e
  68034. }
  68035. ,
  68036. t.prototype.uniformProcessor = function(e, t, i) {
  68037. var n, r;
  68038. this._preProcessors = i;
  68039. var o = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
  68040. if (null != o) {
  68041. var a = o[1]
  68042. , s = o[2];
  68043. if (0 === a.indexOf("sampler") || 1 === a.indexOf("sampler")) {
  68044. var l = 0;
  68045. s = (n = this._getArraySize(s, a, i))[0],
  68046. a = n[1],
  68047. l = n[2];
  68048. var c = this._webgpuProcessingContext.availableTextures[s];
  68049. if (!c) {
  68050. c = {
  68051. autoBindSampler: !0,
  68052. isTextureArray: l > 0,
  68053. isStorageTexture: !1,
  68054. textures: [],
  68055. sampleType: Cu.Float
  68056. };
  68057. for (var u = 0; u < (l || 1); ++u)
  68058. c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
  68059. }
  68060. var h = null !== (r = Qu._SamplerTypeByWebGLSamplerType[a]) && void 0 !== r ? r : "sampler"
  68061. , d = !!Qu._IsComparisonSamplerByWebGPUSamplerType[h]
  68062. , p = d ? Ru.Comparison : Ru.Filtering
  68063. , f = s + Qu.AutoSamplerSuffix
  68064. , _ = this._webgpuProcessingContext.availableSamplers[f];
  68065. _ || (_ = {
  68066. binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),
  68067. type: p
  68068. });
  68069. var m = "u" === a.charAt(0) ? "u" : "i" === a.charAt(0) ? "i" : "";
  68070. m && (a = a.substr(1));
  68071. var g = d ? Cu.Depth : "u" === m ? Cu.Uint : "i" === m ? Cu.Sint : Cu.Float;
  68072. c.sampleType = g;
  68073. var v = l > 0
  68074. , y = _.binding.groupIndex
  68075. , b = _.binding.bindingIndex
  68076. , T = Qu._SamplerFunctionByWebGLSamplerType[a]
  68077. , E = Qu._TextureTypeByWebGLSamplerType[a]
  68078. , S = Qu._GpuTextureViewDimensionByWebGPUTextureType[E];
  68079. if (v) {
  68080. var A = [];
  68081. for (A.push("layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";")),
  68082. e = "\r\n",
  68083. u = 0; u < l; ++u) {
  68084. var x = c.textures[u].groupIndex
  68085. , R = c.textures[u].bindingIndex;
  68086. A.push("layout(set = ".concat(x, ", binding = ").concat(R, ") uniform ").concat(E, " ").concat(s, "Texture").concat(u, ";")),
  68087. e += "".concat(u > 0 ? "\r\n" : "", "#define ").concat(s).concat(u, " ").concat(m).concat(T, "(").concat(s, "Texture").concat(u, ", ").concat(f, ")")
  68088. }
  68089. e = A.join("\r\n") + e,
  68090. this._textureArrayProcessing.push(s)
  68091. } else
  68092. l = 1,
  68093. e = "layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";\n layout(set = ").concat(c.textures[0].groupIndex, ", binding = ").concat(c.textures[0].bindingIndex, ") uniform ").concat(E, " ").concat(s, "Texture;\n #define ").concat(s, " ").concat(m).concat(T, "(").concat(s, "Texture, ").concat(f, ")");
  68094. for (this._webgpuProcessingContext.availableTextures[s] = c,
  68095. this._webgpuProcessingContext.availableSamplers[f] = _,
  68096. this._addSamplerBindingDescription(f, _, !t),
  68097. u = 0; u < l; ++u)
  68098. this._addTextureBindingDescription(s, c, u, S, null, !t)
  68099. } else
  68100. this._addUniformToLeftOverUBO(s, a, i),
  68101. e = ""
  68102. }
  68103. return e
  68104. }
  68105. ,
  68106. t.prototype.uniformBufferProcessor = function(e, t) {
  68107. var i = /uniform\s+(\w+)/gm.exec(e);
  68108. if (null != i) {
  68109. var n = i[1]
  68110. , r = this._webgpuProcessingContext.availableBuffers[n];
  68111. if (!r) {
  68112. var o = Ju.KnownUBOs[n];
  68113. r = {
  68114. binding: o && -1 !== o.binding.groupIndex ? o.binding : this._webgpuProcessingContext.getNextFreeUBOBinding()
  68115. },
  68116. this._webgpuProcessingContext.availableBuffers[n] = r
  68117. }
  68118. this._addBufferBindingDescription(n, r, xu.Uniform, !t),
  68119. e = e.replace("uniform", "layout(set = ".concat(r.binding.groupIndex, ", binding = ").concat(r.binding.bindingIndex, ") uniform"))
  68120. }
  68121. return e
  68122. }
  68123. ,
  68124. t.prototype.postProcessor = function(e, t, i, n, r) {
  68125. var o = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/);
  68126. if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("),
  68127. i) {
  68128. var a = e.indexOf("gl_FragCoord") >= 0
  68129. , s = a ? "vec4 glFragCoord__;\n" : "";
  68130. e = (e = (e = (e = (e = (e = (e = (e = (e = (e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/gl_FragCoord/g, "glFragCoord__")).replace(/void\s+?main\s*\(/g, (o ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(")).replace(/dFdy/g, "(-yFactor__)*dFdy")).replace("##INJECTCODE##", s),
  68131. a && (e = this._injectStartingAndEndingCode(e, "void main", "\n glFragCoord__ = gl_FragCoord;\n if (yFactor__ == 1.) {\n glFragCoord__.y = textureOutputHeight__ - glFragCoord__.y;\n }\n "))
  68132. } else if (e = (e = e.replace(/gl_InstanceID/g, "gl_InstanceIndex")).replace(/gl_VertexID/g, "gl_VertexIndex"),
  68133. -1 !== t.indexOf("#define MULTIVIEW"))
  68134. return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + e;
  68135. if (!i) {
  68136. var l = e.lastIndexOf("}");
  68137. e = e.substring(0, l),
  68138. e += "gl_Position.y *= yFactor__;\n",
  68139. r.isNDCHalfZRange || (e += "gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;\n"),
  68140. e += "}"
  68141. }
  68142. return e
  68143. }
  68144. ,
  68145. t.prototype._applyTextureArrayProcessing = function(e, t) {
  68146. for (var i = new RegExp(t + "\\s*\\[(.+)?\\]","gm"), n = i.exec(e); null != n; ) {
  68147. var r = n[1]
  68148. , o = +r;
  68149. this._preProcessors && isNaN(o) && (o = +this._preProcessors[r.trim()]),
  68150. e = e.replace(n[0], t + o),
  68151. n = i.exec(e)
  68152. }
  68153. return e
  68154. }
  68155. ,
  68156. t.prototype._generateLeftOverUBOCode = function(e, t) {
  68157. for (var i = "layout(set = ".concat(t.binding.groupIndex, ", binding = ").concat(t.binding.bindingIndex, ") uniform ").concat(e, " {\n "), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
  68158. var o = r[n];
  68159. o.length > 0 ? i += " ".concat(o.type, " ").concat(o.name, "[").concat(o.length, "];\n") : i += " ".concat(o.type, " ").concat(o.name, ";\n")
  68160. }
  68161. return i + "};\n\n"
  68162. }
  68163. ,
  68164. t.prototype.finalizeShaders = function(e, t) {
  68165. for (var i = 0; i < this._textureArrayProcessing.length; ++i) {
  68166. var n = this._textureArrayProcessing[i];
  68167. e = this._applyTextureArrayProcessing(e, n),
  68168. t = this._applyTextureArrayProcessing(t, n)
  68169. }
  68170. for (i = 0; i < this._missingVaryings.length; ++i) {
  68171. var r = this._missingVaryings[i];
  68172. r && r.length > 0 && (t = r + "\n" + t)
  68173. }
  68174. var o = this._buildLeftOverUBO();
  68175. return e = o + e,
  68176. t = o + t,
  68177. this._collectBindingNames(),
  68178. this._preCreateBindGroupEntries(),
  68179. this._preProcessors = null,
  68180. {
  68181. vertexCode: e,
  68182. fragmentCode: t
  68183. }
  68184. }
  68185. ,
  68186. t
  68187. }(Qu);
  68188. Pt.IncludesShadersStoreWGSL.bonesDeclaration = "#if NUM_BONE_INFLUENCERS>0\nattribute matricesIndices : vec4<f32>;\nattribute matricesWeights : vec4<f32>;\n#if NUM_BONE_INFLUENCERS>4\nattribute matricesIndicesExtra : vec4<f32>;\nattribute matricesWeightsExtra : vec4<f32>;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nvar boneSampler : texture_2d<f32>;\nuniform boneTextureWidth : f32;\n#else\nuniform mBones : array<mat4x4,BonesPerMesh>;\n#ifdef BONES_VELOCITY_ENABLED\nuniform mPreviousBones : array<mat4x4,BonesPerMesh>;\n#endif\n#endif\n#ifdef BONETEXTURE\nfn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32)->mat4x4<f32>\n{\nlet offset=i32(index) *4; \nlet m0=textureLoad(smp,vec2<i32>(offset+0,0),0);\nlet m1=textureLoad(smp,vec2<i32>(offset+1,0),0);\nlet m2=textureLoad(smp,vec2<i32>(offset+2,0),0);\nlet m3=textureLoad(smp,vec2<i32>(offset+3,0),0);\nreturn mat4x4<f32>(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif\n";
  68189. Pt.IncludesShadersStoreWGSL.bonesVertex = "#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nvar influence : mat4x4<f32>;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif \n#else \ninfluence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";
  68190. Pt.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;\nuniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;\nuniform bakedVertexAnimationSettings: vec4<f32>;\nvar bakedVertexAnimationTexture : texture_2d<f32>;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4<f32>;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32)->mat4x4<f32>\n{\nlet offset=i32(index)*4;\nlet frameUV=i32(frame);\nlet m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);\nlet m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);\nlet m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);\nlet m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);\nreturn mat4x4<f32>(m0,m1,m2,m3);\n}\n#endif\n";
  68191. Pt.IncludesShadersStoreWGSL.bakedVertexAnimation = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\nlet VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;\nlet VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;\nlet VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;\nlet VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;\nlet VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;\nlet VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;\nlet VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;\nlet time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;\nlet frameCorrection: f32=select(1.0,0.0,time<1.0);\nlet numOfFrames: f32=totalFrames-frameCorrection;\nvar VATFrameNum: f32=fract(time)*numOfFrames;\nVATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;\nvar VATInfluence : mat4x4<f32>;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif\n";
  68192. Pt.IncludesShadersStoreWGSL.clipPlaneFragment = "#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelseif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelseif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelseif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelseif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelseif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelseif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif\n";
  68193. Pt.IncludesShadersStoreWGSL.clipPlaneFragmentDeclaration = "#ifdef CLIPPLANE\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nvarying fClipDistance6: f32;\n#endif\n";
  68194. Pt.IncludesShadersStoreWGSL.clipPlaneVertex = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,uniforms.vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,uniforms.vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,uniforms.vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,uniforms.vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,uniforms.vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,uniforms.vClipPlane6);\n#endif\n";
  68195. Pt.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration = "#ifdef CLIPPLANE\nuniform vClipPlane: vec4<f32>;\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nuniform vClipPlane2: vec4<f32>;\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nuniform vClipPlane3: vec4<f32>;\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nuniform vClipPlane4: vec4<f32>;\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nuniform vClipPlane5: vec4<f32>;\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nuniform vClipPlane6: vec4<f32>;\nvarying fClipDistance6: f32;\n#endif\n";
  68196. Pt.IncludesShadersStoreWGSL.instancesDeclaration = "#ifdef INSTANCES\nattribute world0 : vec4<f32>;\nattribute world1 : vec4<f32>;\nattribute world2 : vec4<f32>;\nattribute world3 : vec4<f32>;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4<f32>;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute previousWorld0 : vec4<f32>;\nattribute previousWorld1 : vec4<f32>;\nattribute previousWorld2 : vec4<f32>;\nattribute previousWorld3 : vec4<f32>;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n";
  68197. Pt.IncludesShadersStoreWGSL.instancesVertex = "#ifdef INSTANCES\nvar finalWorld=mat4x4<f32>(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=mat4x4<f32>(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=previousWorld;\n#endif\n#endif\n";
  68198. Pt.IncludesShadersStoreWGSL.meshUboDeclaration = "struct Mesh {\nworld : mat4x4<f32>;\nvisibility : f32;\n};\nvar<uniform> mesh : Mesh;\n#define WORLD_UBO\n";
  68199. Pt.IncludesShadersStoreWGSL.morphTargetsVertex = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \nvertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;\npositionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -normal)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";
  68200. Pt.IncludesShadersStoreWGSL.morphTargetsVertexDeclaration = "#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute position{X} : vec3<f32>;\n#ifdef MORPHTARGETS_NORMAL\nattribute normal{X} : vec3<f32>;\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute tangent{X} : vec3<f32>;\n#endif\n#ifdef MORPHTARGETS_UV\nattribute uv_{X} : vec2<f32>;\n#endif\n#endif\n#endif\n";
  68201. Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n";
  68202. Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration = "#ifdef MORPHTARGETS\nuniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;\n#ifdef MORPHTARGETS_TEXTURE \nuniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;\nuniform morphTargetTextureInfo : vec3<f32>;\nvar morphTargets : texture_2d_array<f32>;\nvar morphTargetsSampler : sampler;\nfn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3<f32>\n{ \nlet y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);\nlet x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;\nlet textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);\nreturn textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;\n}\n#endif\n#endif\n";
  68203. Pt.IncludesShadersStoreWGSL.sceneUboDeclaration = "struct Scene {\nviewProjection : mat4x4<f32>;\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4<f32>;\n#endif \nview : mat4x4<f32>;\nprojection : mat4x4<f32>;\nvEyePosition : vec4<f32>;\n};\nvar<uniform> scene : Scene;\n";
  68204. var eh, th = "gl_VertexID", ih = "gl_InstanceID", nh = "gl_Position", rh = "gl_FragCoord", oh = "gl_FrontFacing", ah = "gl_FragDepth", sh = "gl_FragColor", lh = {
  68205. texture_1d: vu.E1d,
  68206. texture_2d: vu.E2d,
  68207. texture_2d_array: vu.E2dArray,
  68208. texture_3d: vu.E3d,
  68209. texture_cube: vu.Cube,
  68210. texture_cube_array: vu.CubeArray,
  68211. texture_multisampled_2d: vu.E2d,
  68212. texture_depth_2d: vu.E2d,
  68213. texture_depth_2d_array: vu.E2dArray,
  68214. texture_depth_cube: vu.Cube,
  68215. texture_depth_cube_array: vu.CubeArray,
  68216. texture_depth_multisampled_2d: vu.E2d,
  68217. texture_storage_1d: vu.E1d,
  68218. texture_storage_2d: vu.E2d,
  68219. texture_storage_2d_array: vu.E2dArray,
  68220. texture_storage_3d: vu.E3d,
  68221. texture_external: null
  68222. }, ch = function(e) {
  68223. function t() {
  68224. var t = null !== e && e.apply(this, arguments) || this;
  68225. return t.shaderLanguage = st.WGSL,
  68226. t.uniformRegexp = /uniform\s+(\w+)\s*:\s*(.+)\s*;/,
  68227. t.textureRegexp = /var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,
  68228. t.noPrecision = !0,
  68229. t
  68230. }
  68231. return U(t, e),
  68232. t.prototype._getArraySize = function(e, t, i) {
  68233. var n = 0
  68234. , r = t.lastIndexOf(">");
  68235. if (t.indexOf("array") >= 0 && r > 0) {
  68236. for (var o = r; o > 0 && " " !== t.charAt(o) && "," !== t.charAt(o); )
  68237. o--;
  68238. var a = t.substring(o + 1, r);
  68239. for (n = +a,
  68240. isNaN(n) && (n = +i[a.trim()]); o > 0 && (" " === t.charAt(o) || "," === t.charAt(o)); )
  68241. o--;
  68242. t = t.substring(t.indexOf("<") + 1, o + 1)
  68243. }
  68244. return [e, t, n]
  68245. }
  68246. ,
  68247. t.prototype.initializeShaders = function(e) {
  68248. this._webgpuProcessingContext = e,
  68249. this._attributesWGSL = [],
  68250. this._attributesDeclWGSL = [],
  68251. this._attributeNamesWGSL = [],
  68252. this._varyingsWGSL = [],
  68253. this._varyingsDeclWGSL = [],
  68254. this._varyingNamesWGSL = []
  68255. }
  68256. ,
  68257. t.prototype.preProcessShaderCode = function(e) {
  68258. return "struct ".concat(Qu.InternalsUBOName, " {\nyFactor__: f32;\ntextureOutputHeight__: f32;\n};\nvar<uniform> ").concat("internals", " : ").concat(Qu.InternalsUBOName, ";\n") + $c(e)
  68259. }
  68260. ,
  68261. t.prototype.varyingProcessor = function(e, t, i) {
  68262. var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
  68263. if (null !== n) {
  68264. var r, o = n[2], a = n[1];
  68265. t ? void 0 === (r = this._webgpuProcessingContext.availableVaryings[a]) && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.')) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
  68266. this._webgpuProcessingContext.availableVaryings[a] = r,
  68267. this._varyingsWGSL.push("@location(".concat(r, ") ").concat(a, " : ").concat(o, ";")),
  68268. this._varyingsDeclWGSL.push("var<private> ".concat(a, " : ").concat(o, ";")),
  68269. this._varyingNamesWGSL.push(a)),
  68270. e = ""
  68271. }
  68272. return e
  68273. }
  68274. ,
  68275. t.prototype.attributeProcessor = function(e, t) {
  68276. var i = /\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
  68277. if (null !== i) {
  68278. var n = i[2]
  68279. , r = i[1]
  68280. , o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
  68281. this._webgpuProcessingContext.availableAttributes[r] = o,
  68282. this._webgpuProcessingContext.orderedAttributes[o] = r,
  68283. this._attributesWGSL.push("@location(".concat(o, ") ").concat(r, " : ").concat(n, ";")),
  68284. this._attributesDeclWGSL.push("var<private> ".concat(r, " : ").concat(n, ";")),
  68285. this._attributeNamesWGSL.push(r),
  68286. e = ""
  68287. }
  68288. return e
  68289. }
  68290. ,
  68291. t.prototype.uniformProcessor = function(e, t, i) {
  68292. var n = this.uniformRegexp.exec(e);
  68293. if (null !== n) {
  68294. var r = n[2]
  68295. , o = n[1];
  68296. this._addUniformToLeftOverUBO(o, r, i),
  68297. e = ""
  68298. }
  68299. return e
  68300. }
  68301. ,
  68302. t.prototype.textureProcessor = function(e, t, i) {
  68303. var n = this.textureRegexp.exec(e);
  68304. if (null !== n) {
  68305. var r = n[1]
  68306. , o = n[2]
  68307. , a = !!n[3]
  68308. , s = n[4]
  68309. , l = s.indexOf("storage") > 0
  68310. , c = n[6]
  68311. , u = l ? c.substring(0, c.indexOf(",")).trim() : null
  68312. , h = a ? this._getArraySize(r, o, i)[2] : 0
  68313. , d = this._webgpuProcessingContext.availableTextures[r];
  68314. if (d)
  68315. h = d.textures.length;
  68316. else {
  68317. d = {
  68318. isTextureArray: h > 0,
  68319. isStorageTexture: l,
  68320. textures: [],
  68321. sampleType: Cu.Float
  68322. },
  68323. h = h || 1;
  68324. for (var p = 0; p < h; ++p)
  68325. d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
  68326. }
  68327. this._webgpuProcessingContext.availableTextures[r] = d;
  68328. var f = s.indexOf("depth") > 0
  68329. , _ = lh[s]
  68330. , m = f ? Cu.Depth : "u32" === c ? Cu.Uint : "i32" === c ? Cu.Sint : Cu.Float;
  68331. if (d.sampleType = m,
  68332. void 0 === _)
  68333. throw "Can't get the texture dimension corresponding to the texture function \"".concat(s, '"!');
  68334. for (p = 0; p < h; ++p) {
  68335. var g = d.textures[p]
  68336. , v = g.groupIndex
  68337. , y = g.bindingIndex;
  68338. 0 === p && (e = "@group(".concat(v, ") @binding(").concat(y, ") ").concat(e)),
  68339. this._addTextureBindingDescription(r, d, p, _, u, !t)
  68340. }
  68341. }
  68342. return e
  68343. }
  68344. ,
  68345. t.prototype.postProcessor = function(e) {
  68346. return e
  68347. }
  68348. ,
  68349. t.prototype.finalizeShaders = function(e, t) {
  68350. var i = t.indexOf("gl_FragCoord") >= 0 ? "\n if (internals.yFactor__ == 1.) {\n gl_FragCoord.y = internals.textureOutputHeight__ - gl_FragCoord.y;\n }\n " : "";
  68351. e = this._processSamplers(e, !0),
  68352. t = this._processSamplers(t, !1),
  68353. e = this._processCustomBuffers(e, !0),
  68354. t = this._processCustomBuffers(t, !1);
  68355. var n = this._buildLeftOverUBO();
  68356. t = n + t,
  68357. e = (e = n + e).replace(/#define /g, "//#define ");
  68358. var r = this._varyingsDeclWGSL.join("\n") + "\n"
  68359. , o = "var<private> ".concat(th, " : u32;\nvar<private> ").concat(ih, " : u32;\nvar<private> ").concat(nh, " : vec4<f32>;\n")
  68360. , a = this._attributesDeclWGSL.join("\n") + "\n"
  68361. , s = "struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32;\n @builtin(instance_index) instanceIndex : u32;\n";
  68362. this._attributesWGSL.length > 0 && (s += this._attributesWGSL.join("\n")),
  68363. s += "\n};\n";
  68364. var l = "struct FragmentInputs {\n @builtin(position) position : vec4<f32>;\n";
  68365. this._varyingsWGSL.length > 0 && (l += this._varyingsWGSL.join("\n")),
  68366. e = o + s + a + (l += "\n};\n") + r + e;
  68367. for (var c = " var output : FragmentInputs;\n ".concat(th, " = input.vertexIndex;\n ").concat(ih, " = input.instanceIndex;\n"), u = 0; u < this._attributeNamesWGSL.length; ++u) {
  68368. var h = this._attributeNamesWGSL[u];
  68369. c += " ".concat(h, " = input.").concat(h, ";\n")
  68370. }
  68371. var d = " output.position = ".concat(nh, ";\n output.position.y = output.position.y * internals.yFactor__;\n");
  68372. for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
  68373. var p = this._varyingNamesWGSL[u];
  68374. d += " output.".concat(p, " = ").concat(p, ";\n")
  68375. }
  68376. d += " return output;",
  68377. e = this._injectStartingAndEndingCode(e, "fn main", c, d),
  68378. t = (t = t.replace(/#define /g, "//#define ")).replace(/dpdy/g, "(-internals.yFactor__)*dpdy");
  68379. var f = "var<private> ".concat(rh, " : vec4<f32>;\nvar<private> ").concat(oh, " : bool;\nvar<private> ").concat(sh, " : vec4<f32>;\nvar<private> ").concat(ah, " : f32;\n")
  68380. , _ = "struct FragmentInputs {\n @builtin(position) position : vec4<f32>;\n @builtin(front_facing) frontFacing : bool;\n";
  68381. this._varyingsWGSL.length > 0 && (_ += this._varyingsWGSL.join("\n")),
  68382. _ += "\n};\n";
  68383. for (var m = "struct FragmentOutputs {\n @location(0) color : vec4<f32>;\n", g = !1, v = 0; !(g || (v = t.indexOf(ah, v)) < 0); ) {
  68384. var y = v;
  68385. for (g = !0; v > 1 && "\n" !== t.charAt(v); ) {
  68386. if ("/" === t.charAt(v) && "/" === t.charAt(v - 1)) {
  68387. g = !1;
  68388. break
  68389. }
  68390. v--
  68391. }
  68392. v = y + ah.length
  68393. }
  68394. g && (m += " @builtin(frag_depth) fragDepth: f32;\n"),
  68395. t = f + _ + r + (m += "};\n") + t;
  68396. var b = " var output : FragmentOutputs;\n ".concat(rh, " = input.position;\n ").concat(oh, " = input.frontFacing;\n") + i;
  68397. for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
  68398. var T = this._varyingNamesWGSL[u];
  68399. b += " ".concat(T, " = input.").concat(T, ";\n")
  68400. }
  68401. var E = " output.color = ".concat(sh, ";\n");
  68402. return g && (E += " output.fragDepth = ".concat(ah, ";\n")),
  68403. E += " return output;",
  68404. t = this._injectStartingAndEndingCode(t, "fn main", b, E),
  68405. this._collectBindingNames(),
  68406. this._preCreateBindGroupEntries(),
  68407. {
  68408. vertexCode: e,
  68409. fragmentCode: t
  68410. }
  68411. }
  68412. ,
  68413. t.prototype._generateLeftOverUBOCode = function(e, t) {
  68414. for (var i = "struct ".concat(e, " {\n"), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
  68415. var o = r[n]
  68416. , a = o.type.replace(/^(.*?)(<.*>)?$/, "$1")
  68417. , s = Qu.UniformSizes[a];
  68418. o.length > 0 ? i += s <= 2 ? " @align(16) ".concat(o.name, " : @stride(16) array<").concat(o.type, ", ").concat(o.length, ">;\n") : " ".concat(o.name, " : array<").concat(o.type, ", ").concat(o.length, ">;\n") : i += " ".concat(o.name, " : ").concat(o.type, ";\n")
  68419. }
  68420. return (i += "};\n") + "@group(".concat(t.binding.groupIndex, ") @binding(").concat(t.binding.bindingIndex, ") var<uniform> ").concat("uniforms", " : ").concat(e, ";\n")
  68421. }
  68422. ,
  68423. t.prototype._processSamplers = function(e, t) {
  68424. for (var i = /var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm; ; ) {
  68425. var n = i.exec(e);
  68426. if (null === n)
  68427. break;
  68428. var r = n[1]
  68429. , o = n[2]
  68430. , a = r.indexOf(Qu.AutoSamplerSuffix) === r.length - Qu.AutoSamplerSuffix.length ? r.substring(0, r.indexOf(Qu.AutoSamplerSuffix)) : null
  68431. , s = "sampler_comparison" === o ? Ru.Comparison : Ru.Filtering;
  68432. if (a) {
  68433. var l = this._webgpuProcessingContext.availableTextures[a];
  68434. l && (l.autoBindSampler = !0)
  68435. }
  68436. var c = this._webgpuProcessingContext.availableSamplers[r];
  68437. c || (c = {
  68438. binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),
  68439. type: s
  68440. },
  68441. this._webgpuProcessingContext.availableSamplers[r] = c),
  68442. this._addSamplerBindingDescription(r, c, t);
  68443. var u = e.substring(0, n.index)
  68444. , h = "@group(".concat(c.binding.groupIndex, ") @binding(").concat(c.binding.bindingIndex, ") ")
  68445. , d = e.substring(n.index);
  68446. e = u + h + d,
  68447. i.lastIndex += h.length
  68448. }
  68449. return e
  68450. }
  68451. ,
  68452. t.prototype._processCustomBuffers = function(e, t) {
  68453. for (var i = /var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm; ; ) {
  68454. var n = i.exec(e);
  68455. if (null === n)
  68456. break;
  68457. var r = n[1]
  68458. , o = n[3]
  68459. , a = n[4]
  68460. , s = n[5]
  68461. , l = this._webgpuProcessingContext.availableBuffers[a];
  68462. if (!l) {
  68463. var c = "uniform" === r ? Ju.KnownUBOs[s] : null
  68464. , u = void 0;
  68465. c ? (a = s,
  68466. -1 === (u = c.binding).groupIndex && (u = this._webgpuProcessingContext.getNextFreeUBOBinding())) : u = this._webgpuProcessingContext.getNextFreeUBOBinding(),
  68467. l = {
  68468. binding: u
  68469. },
  68470. this._webgpuProcessingContext.availableBuffers[a] = l
  68471. }
  68472. this._addBufferBindingDescription(a, this._webgpuProcessingContext.availableBuffers[a], "read_write" === o ? xu.Storage : "storage" === r ? xu.ReadOnlyStorage : xu.Uniform, t);
  68473. var h = l.binding.groupIndex
  68474. , d = l.binding.bindingIndex
  68475. , p = e.substring(0, n.index)
  68476. , f = "@group(".concat(h, ") @binding(").concat(d, ") ")
  68477. , _ = e.substring(n.index);
  68478. e = p + f + _,
  68479. i.lastIndex += f.length
  68480. }
  68481. return e
  68482. }
  68483. ,
  68484. t
  68485. }(Qu), uh = function() {
  68486. function e(e) {
  68487. void 0 === e && (e = null),
  68488. this.format = bu.RGBA8Unorm,
  68489. this.textureUsages = 0,
  68490. this.textureAdditionalUsages = 0,
  68491. this._webgpuTexture = e,
  68492. this._webgpuMSAATexture = null,
  68493. this.view = null,
  68494. this.viewForWriting = null
  68495. }
  68496. return Object.defineProperty(e.prototype, "underlyingResource", {
  68497. get: function() {
  68498. return this._webgpuTexture
  68499. },
  68500. enumerable: !1,
  68501. configurable: !0
  68502. }),
  68503. Object.defineProperty(e.prototype, "msaaTexture", {
  68504. get: function() {
  68505. return this._webgpuMSAATexture
  68506. },
  68507. set: function(e) {
  68508. this._webgpuMSAATexture = e
  68509. },
  68510. enumerable: !1,
  68511. configurable: !0
  68512. }),
  68513. e.prototype.set = function(e) {
  68514. this._webgpuTexture = e
  68515. }
  68516. ,
  68517. e.prototype.setUsage = function(e, t, i, n, r) {
  68518. t = e !== At.RenderTarget && t,
  68519. this.createView({
  68520. format: this.format,
  68521. dimension: i ? vu.Cube : vu.E2d,
  68522. mipLevelCount: t ? d.ILog2(Math.max(n, r)) + 1 : 1,
  68523. baseArrayLayer: 0,
  68524. baseMipLevel: 0,
  68525. arrayLayerCount: i ? 6 : 1,
  68526. aspect: yu.All
  68527. })
  68528. }
  68529. ,
  68530. e.prototype.createView = function(e, t) {
  68531. if (void 0 === t && (t = !1),
  68532. this.view = this._webgpuTexture.createView(e),
  68533. t && e) {
  68534. var i = e.mipLevelCount;
  68535. e.mipLevelCount = 1,
  68536. this.viewForWriting = this._webgpuTexture.createView(e),
  68537. e.mipLevelCount = i
  68538. }
  68539. }
  68540. ,
  68541. e.prototype.reset = function() {
  68542. this._webgpuTexture = null,
  68543. this._webgpuMSAATexture = null,
  68544. this.view = null,
  68545. this.viewForWriting = null
  68546. }
  68547. ,
  68548. e.prototype.release = function() {
  68549. var e, t, i;
  68550. null === (e = this._webgpuTexture) || void 0 === e || e.destroy(),
  68551. null === (t = this._webgpuMSAATexture) || void 0 === t || t.destroy(),
  68552. null === (i = this._copyInvertYTempTexture) || void 0 === i || i.destroy(),
  68553. this.reset()
  68554. }
  68555. ,
  68556. e
  68557. }();
  68558. !function(e) {
  68559. e[e.MipMap = 0] = "MipMap",
  68560. e[e.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha",
  68561. e[e.Clear = 2] = "Clear",
  68562. e[e.InvertYPremultiplyAlphaWithOfst = 3] = "InvertYPremultiplyAlphaWithOfst"
  68563. }(eh || (eh = {}));
  68564. var hh, dh = [{
  68565. vertex: "\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(location = 0) out vec2 vTex;\n\n void main() {\n vTex = tex[gl_VertexIndex];\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
  68566. fragment: "\n layout(set = 0, binding = 0) uniform sampler imgSampler;\n layout(set = 0, binding = 1) uniform texture2D img;\n\n layout(location = 0) in vec2 vTex;\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n }\n "
  68567. }, {
  68568. vertex: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
  68569. fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "
  68570. }, {
  68571. vertex: "\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n\n void main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
  68572. fragment: "\n layout(set = 0, binding = 0) uniform Uniforms {\n uniform vec4 color;\n };\n\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = color;\n }\n "
  68573. }, {
  68574. vertex: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
  68575. fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n layout(set = 0, binding = 1) uniform Params {\n float ofstX;\n float ofstY;\n float width;\n float height;\n };\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n if (gl_FragCoord.x < ofstX || gl_FragCoord.x >= ofstX + width) {\n discard;\n }\n if (gl_FragCoord.y < ofstY || gl_FragCoord.y >= ofstY + height) {\n discard;\n }\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, ofstY + height - (gl_FragCoord.y - ofstY)), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "
  68576. }], ph = {
  68577. "": 0,
  68578. r8unorm: 1,
  68579. r8uint: 2,
  68580. r8sint: 3,
  68581. r16uint: 4,
  68582. r16sint: 5,
  68583. r16float: 6,
  68584. rg8unorm: 7,
  68585. rg8uint: 8,
  68586. rg8sint: 9,
  68587. r32uint: 10,
  68588. r32sint: 11,
  68589. r32float: 12,
  68590. rg16uint: 13,
  68591. rg16sint: 14,
  68592. rg16float: 15,
  68593. rgba8unorm: 16,
  68594. "rgba8unorm-srgb": 17,
  68595. rgba8uint: 18,
  68596. rgba8sint: 19,
  68597. bgra8unorm: 20,
  68598. "bgra8unorm-srgb": 21,
  68599. rgb10a2unorm: 22,
  68600. rg32uint: 23,
  68601. rg32sint: 24,
  68602. rg32float: 25,
  68603. rgba16uint: 26,
  68604. rgba16sint: 27,
  68605. rgba16float: 28,
  68606. rgba32uint: 29,
  68607. rgba32sint: 30,
  68608. rgba32float: 31,
  68609. stencil8: 32,
  68610. depth16unorm: 33,
  68611. depth24plus: 34,
  68612. "depth24plus-stencil8": 35,
  68613. depth32float: 36,
  68614. "depth24unorm-stencil8": 37,
  68615. "depth32float-stencil8": 38
  68616. }, fh = function() {
  68617. function e(e, t, i, n) {
  68618. this._pipelines = {},
  68619. this._compiledShaders = [],
  68620. this._deferredReleaseTextures = [],
  68621. this._device = e,
  68622. this._glslang = t,
  68623. this._tintWASM = i,
  68624. this._bufferManager = n,
  68625. this._mipmapSampler = e.createSampler({
  68626. minFilter: Eu.Linear
  68627. }),
  68628. this._ubCopyWithOfst = this._bufferManager.createBuffer(16, fu.Uniform | fu.CopyDst).underlyingResource,
  68629. this._getPipeline(bu.RGBA8Unorm)
  68630. }
  68631. return e.ComputeNumMipmapLevels = function(e, t) {
  68632. return d.ILog2(Math.max(e, t)) + 1
  68633. }
  68634. ,
  68635. e.prototype._getPipeline = function(e, t, i) {
  68636. void 0 === t && (t = eh.MipMap);
  68637. var n = t === eh.MipMap ? 1 : t === eh.InvertYPremultiplyAlpha ? ((i.invertY ? 1 : 0) << 1) + ((i.premultiplyAlpha ? 1 : 0) << 2) : t === eh.Clear ? 8 : t === eh.InvertYPremultiplyAlphaWithOfst ? ((i.invertY ? 1 : 0) << 4) + ((i.premultiplyAlpha ? 1 : 0) << 5) : 0;
  68638. this._pipelines[e] || (this._pipelines[e] = []);
  68639. var r = this._pipelines[e][n];
  68640. if (!r) {
  68641. var o = "#version 450\r\n";
  68642. t !== eh.InvertYPremultiplyAlpha && t !== eh.InvertYPremultiplyAlphaWithOfst || (i.invertY && (o += "#define INVERTY\r\n"),
  68643. i.premultiplyAlpha && (o += "#define PREMULTIPLYALPHA\r\n"));
  68644. var a = this._compiledShaders[n];
  68645. if (!a) {
  68646. var s = this._glslang.compileGLSL(o + dh[t].vertex, "vertex")
  68647. , l = this._glslang.compileGLSL(o + dh[t].fragment, "fragment");
  68648. this._tintWASM && (s = this._tintWASM.convertSpirV2WGSL(s),
  68649. l = this._tintWASM.convertSpirV2WGSL(l));
  68650. var c = this._device.createShaderModule({
  68651. code: s
  68652. })
  68653. , u = this._device.createShaderModule({
  68654. code: l
  68655. });
  68656. a = this._compiledShaders[n] = [c, u]
  68657. }
  68658. var h = this._device.createRenderPipeline({
  68659. vertex: {
  68660. module: a[0],
  68661. entryPoint: "main"
  68662. },
  68663. fragment: {
  68664. module: a[1],
  68665. entryPoint: "main",
  68666. targets: [{
  68667. format: e
  68668. }]
  68669. },
  68670. primitive: {
  68671. topology: Iu.TriangleStrip,
  68672. stripIndexFormat: Bu.Uint16
  68673. }
  68674. });
  68675. r = this._pipelines[e][n] = [h, h.getBindGroupLayout(0)]
  68676. }
  68677. return r
  68678. }
  68679. ,
  68680. e._GetTextureTypeFromFormat = function(e) {
  68681. switch (e) {
  68682. case bu.R8Unorm:
  68683. case bu.R8Snorm:
  68684. case bu.R8Uint:
  68685. case bu.R8Sint:
  68686. case bu.RG8Unorm:
  68687. case bu.RG8Snorm:
  68688. case bu.RG8Uint:
  68689. case bu.RG8Sint:
  68690. case bu.RGBA8Unorm:
  68691. case bu.RGBA8UnormSRGB:
  68692. case bu.RGBA8Snorm:
  68693. case bu.RGBA8Uint:
  68694. case bu.RGBA8Sint:
  68695. case bu.BGRA8Unorm:
  68696. case bu.BGRA8UnormSRGB:
  68697. case bu.RGB10A2Unorm:
  68698. case bu.RGB9E5UFloat:
  68699. case bu.RG11B10UFloat:
  68700. case bu.Depth24UnormStencil8:
  68701. case bu.Depth32FloatStencil8:
  68702. case bu.BC7RGBAUnorm:
  68703. case bu.BC7RGBAUnormSRGB:
  68704. case bu.BC6HRGBUFloat:
  68705. case bu.BC6HRGBFloat:
  68706. case bu.BC5RGUnorm:
  68707. case bu.BC5RGSnorm:
  68708. case bu.BC3RGBAUnorm:
  68709. case bu.BC3RGBAUnormSRGB:
  68710. case bu.BC2RGBAUnorm:
  68711. case bu.BC2RGBAUnormSRGB:
  68712. case bu.BC4RUnorm:
  68713. case bu.BC4RSnorm:
  68714. case bu.BC1RGBAUnorm:
  68715. case bu.BC1RGBAUnormSRGB:
  68716. case bu.ETC2RGB8Unorm:
  68717. case bu.ETC2RGB8UnormSRGB:
  68718. case bu.ETC2RGB8A1Unorm:
  68719. case bu.ETC2RGB8A1UnormSRGB:
  68720. case bu.ETC2RGBA8Unorm:
  68721. case bu.ETC2RGBA8UnormSRGB:
  68722. case bu.EACR11Unorm:
  68723. case bu.EACR11Snorm:
  68724. case bu.EACRG11Unorm:
  68725. case bu.EACRG11Snorm:
  68726. case bu.ASTC4x4Unorm:
  68727. case bu.ASTC4x4UnormSRGB:
  68728. case bu.ASTC5x4Unorm:
  68729. case bu.ASTC5x4UnormSRGB:
  68730. case bu.ASTC5x5Unorm:
  68731. case bu.ASTC5x5UnormSRGB:
  68732. case bu.ASTC6x5Unorm:
  68733. case bu.ASTC6x5UnormSRGB:
  68734. case bu.ASTC6x6Unorm:
  68735. case bu.ASTC6x6UnormSRGB:
  68736. case bu.ASTC8x5Unorm:
  68737. case bu.ASTC8x5UnormSRGB:
  68738. case bu.ASTC8x6Unorm:
  68739. case bu.ASTC8x6UnormSRGB:
  68740. case bu.ASTC8x8Unorm:
  68741. case bu.ASTC8x8UnormSRGB:
  68742. case bu.ASTC10x5Unorm:
  68743. case bu.ASTC10x5UnormSRGB:
  68744. case bu.ASTC10x6Unorm:
  68745. case bu.ASTC10x6UnormSRGB:
  68746. case bu.ASTC10x8Unorm:
  68747. case bu.ASTC10x8UnormSRGB:
  68748. case bu.ASTC10x10Unorm:
  68749. case bu.ASTC10x10UnormSRGB:
  68750. case bu.ASTC12x10Unorm:
  68751. case bu.ASTC12x10UnormSRGB:
  68752. case bu.ASTC12x12Unorm:
  68753. case bu.ASTC12x12UnormSRGB:
  68754. return a.TEXTURETYPE_UNSIGNED_BYTE;
  68755. case bu.R16Uint:
  68756. case bu.R16Sint:
  68757. case bu.RG16Uint:
  68758. case bu.RG16Sint:
  68759. case bu.RGBA16Uint:
  68760. case bu.RGBA16Sint:
  68761. case bu.Depth16Unorm:
  68762. return a.TEXTURETYPE_UNSIGNED_SHORT;
  68763. case bu.R16Float:
  68764. case bu.RG16Float:
  68765. case bu.RGBA16Float:
  68766. return a.TEXTURETYPE_HALF_FLOAT;
  68767. case bu.R32Uint:
  68768. case bu.R32Sint:
  68769. case bu.RG32Uint:
  68770. case bu.RG32Sint:
  68771. case bu.RGBA32Uint:
  68772. case bu.RGBA32Sint:
  68773. return a.TEXTURETYPE_UNSIGNED_INTEGER;
  68774. case bu.R32Float:
  68775. case bu.RG32Float:
  68776. case bu.RGBA32Float:
  68777. case bu.Depth32Float:
  68778. return a.TEXTURETYPE_FLOAT;
  68779. case bu.Stencil8:
  68780. throw "No fixed size for Stencil8 format!";
  68781. case bu.Depth24Plus:
  68782. throw "No fixed size for Depth24Plus format!";
  68783. case bu.Depth24PlusStencil8:
  68784. throw "No fixed size for Depth24PlusStencil8 format!"
  68785. }
  68786. return a.TEXTURETYPE_UNSIGNED_BYTE
  68787. }
  68788. ,
  68789. e._GetBlockInformationFromFormat = function(e) {
  68790. switch (e) {
  68791. case bu.R8Unorm:
  68792. case bu.R8Snorm:
  68793. case bu.R8Uint:
  68794. case bu.R8Sint:
  68795. return {
  68796. width: 1,
  68797. height: 1,
  68798. length: 1
  68799. };
  68800. case bu.R16Uint:
  68801. case bu.R16Sint:
  68802. case bu.R16Float:
  68803. case bu.RG8Unorm:
  68804. case bu.RG8Snorm:
  68805. case bu.RG8Uint:
  68806. case bu.RG8Sint:
  68807. return {
  68808. width: 1,
  68809. height: 1,
  68810. length: 2
  68811. };
  68812. case bu.R32Uint:
  68813. case bu.R32Sint:
  68814. case bu.R32Float:
  68815. case bu.RG16Uint:
  68816. case bu.RG16Sint:
  68817. case bu.RG16Float:
  68818. case bu.RGBA8Unorm:
  68819. case bu.RGBA8UnormSRGB:
  68820. case bu.RGBA8Snorm:
  68821. case bu.RGBA8Uint:
  68822. case bu.RGBA8Sint:
  68823. case bu.BGRA8Unorm:
  68824. case bu.BGRA8UnormSRGB:
  68825. case bu.RGB9E5UFloat:
  68826. case bu.RGB10A2Unorm:
  68827. case bu.RG11B10UFloat:
  68828. return {
  68829. width: 1,
  68830. height: 1,
  68831. length: 4
  68832. };
  68833. case bu.RG32Uint:
  68834. case bu.RG32Sint:
  68835. case bu.RG32Float:
  68836. case bu.RGBA16Uint:
  68837. case bu.RGBA16Sint:
  68838. case bu.RGBA16Float:
  68839. return {
  68840. width: 1,
  68841. height: 1,
  68842. length: 8
  68843. };
  68844. case bu.RGBA32Uint:
  68845. case bu.RGBA32Sint:
  68846. case bu.RGBA32Float:
  68847. return {
  68848. width: 1,
  68849. height: 1,
  68850. length: 16
  68851. };
  68852. case bu.Stencil8:
  68853. throw "No fixed size for Stencil8 format!";
  68854. case bu.Depth16Unorm:
  68855. return {
  68856. width: 1,
  68857. height: 1,
  68858. length: 2
  68859. };
  68860. case bu.Depth24Plus:
  68861. throw "No fixed size for Depth24Plus format!";
  68862. case bu.Depth24PlusStencil8:
  68863. throw "No fixed size for Depth24PlusStencil8 format!";
  68864. case bu.Depth32Float:
  68865. case bu.Depth24UnormStencil8:
  68866. return {
  68867. width: 1,
  68868. height: 1,
  68869. length: 4
  68870. };
  68871. case bu.Depth32FloatStencil8:
  68872. return {
  68873. width: 1,
  68874. height: 1,
  68875. length: 5
  68876. };
  68877. case bu.BC7RGBAUnorm:
  68878. case bu.BC7RGBAUnormSRGB:
  68879. case bu.BC6HRGBUFloat:
  68880. case bu.BC6HRGBFloat:
  68881. case bu.BC5RGUnorm:
  68882. case bu.BC5RGSnorm:
  68883. case bu.BC3RGBAUnorm:
  68884. case bu.BC3RGBAUnormSRGB:
  68885. case bu.BC2RGBAUnorm:
  68886. case bu.BC2RGBAUnormSRGB:
  68887. return {
  68888. width: 4,
  68889. height: 4,
  68890. length: 16
  68891. };
  68892. case bu.BC4RUnorm:
  68893. case bu.BC4RSnorm:
  68894. case bu.BC1RGBAUnorm:
  68895. case bu.BC1RGBAUnormSRGB:
  68896. case bu.ETC2RGB8Unorm:
  68897. case bu.ETC2RGB8UnormSRGB:
  68898. case bu.ETC2RGB8A1Unorm:
  68899. case bu.ETC2RGB8A1UnormSRGB:
  68900. case bu.EACR11Unorm:
  68901. case bu.EACR11Snorm:
  68902. return {
  68903. width: 4,
  68904. height: 4,
  68905. length: 8
  68906. };
  68907. case bu.ETC2RGBA8Unorm:
  68908. case bu.ETC2RGBA8UnormSRGB:
  68909. case bu.EACRG11Unorm:
  68910. case bu.EACRG11Snorm:
  68911. case bu.ASTC4x4Unorm:
  68912. case bu.ASTC4x4UnormSRGB:
  68913. return {
  68914. width: 4,
  68915. height: 4,
  68916. length: 16
  68917. };
  68918. case bu.ASTC5x4Unorm:
  68919. case bu.ASTC5x4UnormSRGB:
  68920. return {
  68921. width: 5,
  68922. height: 4,
  68923. length: 16
  68924. };
  68925. case bu.ASTC5x5Unorm:
  68926. case bu.ASTC5x5UnormSRGB:
  68927. return {
  68928. width: 5,
  68929. height: 5,
  68930. length: 16
  68931. };
  68932. case bu.ASTC6x5Unorm:
  68933. case bu.ASTC6x5UnormSRGB:
  68934. return {
  68935. width: 6,
  68936. height: 5,
  68937. length: 16
  68938. };
  68939. case bu.ASTC6x6Unorm:
  68940. case bu.ASTC6x6UnormSRGB:
  68941. return {
  68942. width: 6,
  68943. height: 6,
  68944. length: 16
  68945. };
  68946. case bu.ASTC8x5Unorm:
  68947. case bu.ASTC8x5UnormSRGB:
  68948. return {
  68949. width: 8,
  68950. height: 5,
  68951. length: 16
  68952. };
  68953. case bu.ASTC8x6Unorm:
  68954. case bu.ASTC8x6UnormSRGB:
  68955. return {
  68956. width: 8,
  68957. height: 6,
  68958. length: 16
  68959. };
  68960. case bu.ASTC8x8Unorm:
  68961. case bu.ASTC8x8UnormSRGB:
  68962. return {
  68963. width: 8,
  68964. height: 8,
  68965. length: 16
  68966. };
  68967. case bu.ASTC10x5Unorm:
  68968. case bu.ASTC10x5UnormSRGB:
  68969. return {
  68970. width: 10,
  68971. height: 5,
  68972. length: 16
  68973. };
  68974. case bu.ASTC10x6Unorm:
  68975. case bu.ASTC10x6UnormSRGB:
  68976. return {
  68977. width: 10,
  68978. height: 6,
  68979. length: 16
  68980. };
  68981. case bu.ASTC10x8Unorm:
  68982. case bu.ASTC10x8UnormSRGB:
  68983. return {
  68984. width: 10,
  68985. height: 8,
  68986. length: 16
  68987. };
  68988. case bu.ASTC10x10Unorm:
  68989. case bu.ASTC10x10UnormSRGB:
  68990. return {
  68991. width: 10,
  68992. height: 10,
  68993. length: 16
  68994. };
  68995. case bu.ASTC12x10Unorm:
  68996. case bu.ASTC12x10UnormSRGB:
  68997. return {
  68998. width: 12,
  68999. height: 10,
  69000. length: 16
  69001. };
  69002. case bu.ASTC12x12Unorm:
  69003. case bu.ASTC12x12UnormSRGB:
  69004. return {
  69005. width: 12,
  69006. height: 12,
  69007. length: 16
  69008. }
  69009. }
  69010. return {
  69011. width: 1,
  69012. height: 1,
  69013. length: 4
  69014. }
  69015. }
  69016. ,
  69017. e._IsHardwareTexture = function(e) {
  69018. return !!e.release
  69019. }
  69020. ,
  69021. e._IsInternalTexture = function(e) {
  69022. return !!e.dispose
  69023. }
  69024. ,
  69025. e.IsImageBitmap = function(e) {
  69026. return void 0 !== e.close
  69027. }
  69028. ,
  69029. e.IsImageBitmapArray = function(e) {
  69030. return Array.isArray(e) && void 0 !== e[0].close
  69031. }
  69032. ,
  69033. e.prototype.setCommandEncoder = function(e) {
  69034. this._commandEncoderForCreation = e
  69035. }
  69036. ,
  69037. e.IsCompressedFormat = function(e) {
  69038. switch (e) {
  69039. case bu.BC7RGBAUnormSRGB:
  69040. case bu.BC7RGBAUnorm:
  69041. case bu.BC6HRGBFloat:
  69042. case bu.BC6HRGBUFloat:
  69043. case bu.BC5RGSnorm:
  69044. case bu.BC5RGUnorm:
  69045. case bu.BC4RSnorm:
  69046. case bu.BC4RUnorm:
  69047. case bu.BC3RGBAUnormSRGB:
  69048. case bu.BC3RGBAUnorm:
  69049. case bu.BC2RGBAUnormSRGB:
  69050. case bu.BC2RGBAUnorm:
  69051. case bu.BC1RGBAUnormSRGB:
  69052. case bu.BC1RGBAUnorm:
  69053. case bu.ETC2RGB8Unorm:
  69054. case bu.ETC2RGB8UnormSRGB:
  69055. case bu.ETC2RGB8A1Unorm:
  69056. case bu.ETC2RGB8A1UnormSRGB:
  69057. case bu.ETC2RGBA8Unorm:
  69058. case bu.ETC2RGBA8UnormSRGB:
  69059. case bu.EACR11Unorm:
  69060. case bu.EACR11Snorm:
  69061. case bu.EACRG11Unorm:
  69062. case bu.EACRG11Snorm:
  69063. case bu.ASTC4x4Unorm:
  69064. case bu.ASTC4x4UnormSRGB:
  69065. case bu.ASTC5x4Unorm:
  69066. case bu.ASTC5x4UnormSRGB:
  69067. case bu.ASTC5x5Unorm:
  69068. case bu.ASTC5x5UnormSRGB:
  69069. case bu.ASTC6x5Unorm:
  69070. case bu.ASTC6x5UnormSRGB:
  69071. case bu.ASTC6x6Unorm:
  69072. case bu.ASTC6x6UnormSRGB:
  69073. case bu.ASTC8x5Unorm:
  69074. case bu.ASTC8x5UnormSRGB:
  69075. case bu.ASTC8x6Unorm:
  69076. case bu.ASTC8x6UnormSRGB:
  69077. case bu.ASTC8x8Unorm:
  69078. case bu.ASTC8x8UnormSRGB:
  69079. case bu.ASTC10x5Unorm:
  69080. case bu.ASTC10x5UnormSRGB:
  69081. case bu.ASTC10x6Unorm:
  69082. case bu.ASTC10x6UnormSRGB:
  69083. case bu.ASTC10x8Unorm:
  69084. case bu.ASTC10x8UnormSRGB:
  69085. case bu.ASTC10x10Unorm:
  69086. case bu.ASTC10x10UnormSRGB:
  69087. case bu.ASTC12x10Unorm:
  69088. case bu.ASTC12x10UnormSRGB:
  69089. case bu.ASTC12x12Unorm:
  69090. case bu.ASTC12x12UnormSRGB:
  69091. return !0
  69092. }
  69093. return !1
  69094. }
  69095. ,
  69096. e.GetWebGPUTextureFormat = function(e, t, i) {
  69097. switch (void 0 === i && (i = !1),
  69098. t) {
  69099. case a.TEXTUREFORMAT_DEPTH16:
  69100. return bu.Depth16Unorm;
  69101. case a.TEXTUREFORMAT_DEPTH24:
  69102. return bu.Depth24Plus;
  69103. case a.TEXTUREFORMAT_DEPTH24_STENCIL8:
  69104. return bu.Depth24PlusStencil8;
  69105. case a.TEXTUREFORMAT_DEPTH32_FLOAT:
  69106. return bu.Depth32Float;
  69107. case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
  69108. return i ? bu.BC7RGBAUnormSRGB : bu.BC7RGBAUnorm;
  69109. case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
  69110. return bu.BC6HRGBUFloat;
  69111. case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
  69112. return bu.BC6HRGBFloat;
  69113. case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
  69114. return i ? bu.BC3RGBAUnormSRGB : bu.BC3RGBAUnorm;
  69115. case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:
  69116. return i ? bu.BC2RGBAUnormSRGB : bu.BC2RGBAUnorm;
  69117. case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
  69118. case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
  69119. return i ? bu.BC1RGBAUnormSRGB : bu.BC1RGBAUnorm;
  69120. case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
  69121. return i ? bu.ASTC4x4UnormSRGB : bu.ASTC4x4Unorm;
  69122. case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
  69123. return i ? bu.ETC2RGB8UnormSRGB : bu.ETC2RGB8Unorm
  69124. }
  69125. switch (e) {
  69126. case a.TEXTURETYPE_BYTE:
  69127. switch (t) {
  69128. case a.TEXTUREFORMAT_RED:
  69129. return bu.R8Snorm;
  69130. case a.TEXTUREFORMAT_RG:
  69131. return bu.RG8Snorm;
  69132. case a.TEXTUREFORMAT_RGB:
  69133. throw "RGB format not supported in WebGPU";
  69134. case a.TEXTUREFORMAT_RED_INTEGER:
  69135. return bu.R8Sint;
  69136. case a.TEXTUREFORMAT_RG_INTEGER:
  69137. return bu.RG8Sint;
  69138. case a.TEXTUREFORMAT_RGB_INTEGER:
  69139. throw "RGB_INTEGER format not supported in WebGPU";
  69140. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69141. return bu.RGBA8Sint;
  69142. default:
  69143. return bu.RGBA8Snorm
  69144. }
  69145. case a.TEXTURETYPE_UNSIGNED_BYTE:
  69146. switch (t) {
  69147. case a.TEXTUREFORMAT_RED:
  69148. return bu.R8Unorm;
  69149. case a.TEXTUREFORMAT_RG:
  69150. return bu.RG8Unorm;
  69151. case a.TEXTUREFORMAT_RGB:
  69152. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  69153. case a.TEXTUREFORMAT_RGBA:
  69154. return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm;
  69155. case a.TEXTUREFORMAT_BGRA:
  69156. return i ? bu.BGRA8UnormSRGB : bu.BGRA8Unorm;
  69157. case a.TEXTUREFORMAT_RED_INTEGER:
  69158. return bu.R8Uint;
  69159. case a.TEXTUREFORMAT_RG_INTEGER:
  69160. return bu.RG8Uint;
  69161. case a.TEXTUREFORMAT_RGB_INTEGER:
  69162. throw "RGB_INTEGER format not supported in WebGPU";
  69163. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69164. return bu.RGBA8Uint;
  69165. case a.TEXTUREFORMAT_ALPHA:
  69166. throw "TEXTUREFORMAT_ALPHA format not supported in WebGPU";
  69167. case a.TEXTUREFORMAT_LUMINANCE:
  69168. throw "TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";
  69169. case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
  69170. throw "TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";
  69171. default:
  69172. return bu.RGBA8Unorm
  69173. }
  69174. case a.TEXTURETYPE_SHORT:
  69175. switch (t) {
  69176. case a.TEXTUREFORMAT_RED_INTEGER:
  69177. return bu.R16Sint;
  69178. case a.TEXTUREFORMAT_RG_INTEGER:
  69179. return bu.RG16Sint;
  69180. case a.TEXTUREFORMAT_RGB_INTEGER:
  69181. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  69182. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69183. default:
  69184. return bu.RGBA16Sint
  69185. }
  69186. case a.TEXTURETYPE_UNSIGNED_SHORT:
  69187. switch (t) {
  69188. case a.TEXTUREFORMAT_RED_INTEGER:
  69189. return bu.R16Uint;
  69190. case a.TEXTUREFORMAT_RG_INTEGER:
  69191. return bu.RG16Uint;
  69192. case a.TEXTUREFORMAT_RGB_INTEGER:
  69193. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  69194. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69195. default:
  69196. return bu.RGBA16Uint
  69197. }
  69198. case a.TEXTURETYPE_INT:
  69199. switch (t) {
  69200. case a.TEXTUREFORMAT_RED_INTEGER:
  69201. return bu.R32Sint;
  69202. case a.TEXTUREFORMAT_RG_INTEGER:
  69203. return bu.RG32Sint;
  69204. case a.TEXTUREFORMAT_RGB_INTEGER:
  69205. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  69206. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69207. default:
  69208. return bu.RGBA32Sint
  69209. }
  69210. case a.TEXTURETYPE_UNSIGNED_INTEGER:
  69211. switch (t) {
  69212. case a.TEXTUREFORMAT_RED_INTEGER:
  69213. return bu.R32Uint;
  69214. case a.TEXTUREFORMAT_RG_INTEGER:
  69215. return bu.RG32Uint;
  69216. case a.TEXTUREFORMAT_RGB_INTEGER:
  69217. throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
  69218. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69219. default:
  69220. return bu.RGBA32Uint
  69221. }
  69222. case a.TEXTURETYPE_FLOAT:
  69223. switch (t) {
  69224. case a.TEXTUREFORMAT_RED:
  69225. return bu.R32Float;
  69226. case a.TEXTUREFORMAT_RG:
  69227. return bu.RG32Float;
  69228. case a.TEXTUREFORMAT_RGB:
  69229. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  69230. case a.TEXTUREFORMAT_RGBA:
  69231. default:
  69232. return bu.RGBA32Float
  69233. }
  69234. case a.TEXTURETYPE_HALF_FLOAT:
  69235. switch (t) {
  69236. case a.TEXTUREFORMAT_RED:
  69237. return bu.R16Float;
  69238. case a.TEXTUREFORMAT_RG:
  69239. return bu.RG16Float;
  69240. case a.TEXTUREFORMAT_RGB:
  69241. throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
  69242. case a.TEXTUREFORMAT_RGBA:
  69243. default:
  69244. return bu.RGBA16Float
  69245. }
  69246. case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  69247. throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
  69248. case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  69249. throw "TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";
  69250. case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  69251. throw "TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";
  69252. case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  69253. throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
  69254. case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  69255. throw "TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";
  69256. case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  69257. switch (t) {
  69258. case a.TEXTUREFORMAT_RGBA:
  69259. return bu.RGB10A2Unorm;
  69260. case a.TEXTUREFORMAT_RGBA_INTEGER:
  69261. throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV";
  69262. default:
  69263. return bu.RGB10A2Unorm
  69264. }
  69265. }
  69266. return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm
  69267. }
  69268. ,
  69269. e.GetNumChannelsFromWebGPUTextureFormat = function(e) {
  69270. switch (e) {
  69271. case bu.R8Unorm:
  69272. case bu.R8Snorm:
  69273. case bu.R8Uint:
  69274. case bu.R8Sint:
  69275. case bu.BC4RUnorm:
  69276. case bu.BC4RSnorm:
  69277. case bu.R16Uint:
  69278. case bu.R16Sint:
  69279. case bu.Depth16Unorm:
  69280. case bu.R16Float:
  69281. case bu.R32Uint:
  69282. case bu.R32Sint:
  69283. case bu.R32Float:
  69284. case bu.Depth32Float:
  69285. case bu.Stencil8:
  69286. case bu.Depth24Plus:
  69287. case bu.EACR11Unorm:
  69288. case bu.EACR11Snorm:
  69289. return 1;
  69290. case bu.RG8Unorm:
  69291. case bu.RG8Snorm:
  69292. case bu.RG8Uint:
  69293. case bu.RG8Sint:
  69294. case bu.Depth24UnormStencil8:
  69295. case bu.Depth32FloatStencil8:
  69296. case bu.BC5RGUnorm:
  69297. case bu.BC5RGSnorm:
  69298. case bu.RG16Uint:
  69299. case bu.RG16Sint:
  69300. case bu.RG16Float:
  69301. case bu.RG32Uint:
  69302. case bu.RG32Sint:
  69303. case bu.RG32Float:
  69304. case bu.Depth24PlusStencil8:
  69305. case bu.EACRG11Unorm:
  69306. case bu.EACRG11Snorm:
  69307. return 2;
  69308. case bu.RGB9E5UFloat:
  69309. case bu.RG11B10UFloat:
  69310. case bu.BC6HRGBUFloat:
  69311. case bu.BC6HRGBFloat:
  69312. case bu.ETC2RGB8Unorm:
  69313. case bu.ETC2RGB8UnormSRGB:
  69314. return 3;
  69315. case bu.RGBA8Unorm:
  69316. case bu.RGBA8UnormSRGB:
  69317. case bu.RGBA8Snorm:
  69318. case bu.RGBA8Uint:
  69319. case bu.RGBA8Sint:
  69320. case bu.BGRA8Unorm:
  69321. case bu.BGRA8UnormSRGB:
  69322. case bu.RGB10A2Unorm:
  69323. case bu.BC7RGBAUnorm:
  69324. case bu.BC7RGBAUnormSRGB:
  69325. case bu.BC3RGBAUnorm:
  69326. case bu.BC3RGBAUnormSRGB:
  69327. case bu.BC2RGBAUnorm:
  69328. case bu.BC2RGBAUnormSRGB:
  69329. case bu.BC1RGBAUnorm:
  69330. case bu.BC1RGBAUnormSRGB:
  69331. case bu.RGBA16Uint:
  69332. case bu.RGBA16Sint:
  69333. case bu.RGBA16Float:
  69334. case bu.RGBA32Uint:
  69335. case bu.RGBA32Sint:
  69336. case bu.RGBA32Float:
  69337. case bu.ETC2RGB8A1Unorm:
  69338. case bu.ETC2RGB8A1UnormSRGB:
  69339. case bu.ETC2RGBA8Unorm:
  69340. case bu.ETC2RGBA8UnormSRGB:
  69341. case bu.ASTC4x4Unorm:
  69342. case bu.ASTC4x4UnormSRGB:
  69343. case bu.ASTC5x4Unorm:
  69344. case bu.ASTC5x4UnormSRGB:
  69345. case bu.ASTC5x5Unorm:
  69346. case bu.ASTC5x5UnormSRGB:
  69347. case bu.ASTC6x5Unorm:
  69348. case bu.ASTC6x5UnormSRGB:
  69349. case bu.ASTC6x6Unorm:
  69350. case bu.ASTC6x6UnormSRGB:
  69351. case bu.ASTC8x5Unorm:
  69352. case bu.ASTC8x5UnormSRGB:
  69353. case bu.ASTC8x6Unorm:
  69354. case bu.ASTC8x6UnormSRGB:
  69355. case bu.ASTC8x8Unorm:
  69356. case bu.ASTC8x8UnormSRGB:
  69357. case bu.ASTC10x5Unorm:
  69358. case bu.ASTC10x5UnormSRGB:
  69359. case bu.ASTC10x6Unorm:
  69360. case bu.ASTC10x6UnormSRGB:
  69361. case bu.ASTC10x8Unorm:
  69362. case bu.ASTC10x8UnormSRGB:
  69363. case bu.ASTC10x10Unorm:
  69364. case bu.ASTC10x10UnormSRGB:
  69365. case bu.ASTC12x10Unorm:
  69366. case bu.ASTC12x10UnormSRGB:
  69367. case bu.ASTC12x12Unorm:
  69368. case bu.ASTC12x12UnormSRGB:
  69369. return 4
  69370. }
  69371. throw "Unknown format ".concat(e, "!")
  69372. }
  69373. ,
  69374. e.HasStencilAspect = function(e) {
  69375. switch (e) {
  69376. case bu.Stencil8:
  69377. case bu.Depth24UnormStencil8:
  69378. case bu.Depth32FloatStencil8:
  69379. case bu.Depth24PlusStencil8:
  69380. return !0
  69381. }
  69382. return !1
  69383. }
  69384. ,
  69385. e.prototype.invertYPreMultiplyAlpha = function(t, i, n, r, o, a, s, l, c, u, h, d, p, f, _) {
  69386. var m, g, v, y, b, T;
  69387. void 0 === o && (o = !1),
  69388. void 0 === a && (a = !1),
  69389. void 0 === s && (s = 0),
  69390. void 0 === l && (l = 0),
  69391. void 0 === c && (c = 1),
  69392. void 0 === u && (u = 0),
  69393. void 0 === h && (h = 0),
  69394. void 0 === d && (d = 0),
  69395. void 0 === p && (p = 0);
  69396. var E, S = 0 !== d, A = void 0 === f, x = this._getPipeline(r, S ? eh.InvertYPremultiplyAlphaWithOfst : eh.InvertYPremultiplyAlpha, {
  69397. invertY: o,
  69398. premultiplyAlpha: a
  69399. }), R = x[0], C = x[1];
  69400. if (s = Math.max(s, 0),
  69401. A && (f = this._device.createCommandEncoder({})),
  69402. null === (g = (m = f).pushDebugGroup) || void 0 === g || g.call(m, "internal process texture - invertY=".concat(o, " premultiplyAlpha=").concat(a)),
  69403. e._IsHardwareTexture(t) ? (E = t.underlyingResource,
  69404. o && !a && 1 === c && 0 === s || (t = void 0)) : (E = t,
  69405. t = void 0),
  69406. E) {
  69407. S && this._bufferManager.setRawData(this._ubCopyWithOfst, 0, new Float32Array([u, h, d, p]), 0, 16);
  69408. var P = t
  69409. , M = null !== (v = null == P ? void 0 : P._copyInvertYTempTexture) && void 0 !== v ? v : this.createTexture({
  69410. width: i,
  69411. height: n,
  69412. layers: 1
  69413. }, !1, !1, !1, !1, !1, r, 1, f, gu.CopySrc | gu.RenderAttachment | gu.TextureBinding)
  69414. , I = null !== (y = null == P ? void 0 : P._copyInvertYRenderPassDescr) && void 0 !== y ? y : {
  69415. colorAttachments: [{
  69416. view: M.createView({
  69417. format: r,
  69418. dimension: vu.E2d,
  69419. baseMipLevel: 0,
  69420. mipLevelCount: 1,
  69421. arrayLayerCount: 1,
  69422. baseArrayLayer: 0
  69423. }),
  69424. loadOp: zu.Load,
  69425. storeOp: Wu.Store
  69426. }]
  69427. }
  69428. , O = f.beginRenderPass(I)
  69429. , D = S ? null == P ? void 0 : P._copyInvertYBindGroupWithOfst : null == P ? void 0 : P._copyInvertYBindGroup;
  69430. if (!D) {
  69431. var N = {
  69432. layout: C,
  69433. entries: [{
  69434. binding: 0,
  69435. resource: E.createView({
  69436. format: r,
  69437. dimension: vu.E2d,
  69438. baseMipLevel: l,
  69439. mipLevelCount: 1,
  69440. arrayLayerCount: c,
  69441. baseArrayLayer: s
  69442. })
  69443. }]
  69444. };
  69445. S && N.entries.push({
  69446. binding: 1,
  69447. resource: {
  69448. buffer: this._ubCopyWithOfst
  69449. }
  69450. }),
  69451. D = this._device.createBindGroup(N)
  69452. }
  69453. O.setPipeline(R),
  69454. O.setBindGroup(0, D),
  69455. O.draw(4, 1, 0, 0),
  69456. O.end(),
  69457. f.copyTextureToTexture({
  69458. texture: M
  69459. }, {
  69460. texture: E,
  69461. mipLevel: l,
  69462. origin: {
  69463. x: 0,
  69464. y: 0,
  69465. z: s
  69466. }
  69467. }, {
  69468. width: i,
  69469. height: n,
  69470. depthOrArrayLayers: 1
  69471. }),
  69472. P ? (P._copyInvertYTempTexture = M,
  69473. P._copyInvertYRenderPassDescr = I,
  69474. S ? P._copyInvertYBindGroupWithOfst = D : P._copyInvertYBindGroup = D) : this._deferredReleaseTextures.push([M, null]),
  69475. null === (T = (b = f).popDebugGroup) || void 0 === T || T.call(b),
  69476. A && (this._device.queue.submit([f.finish()]),
  69477. f = null)
  69478. }
  69479. }
  69480. ,
  69481. e.prototype.copyWithInvertY = function(e, t, i, n) {
  69482. var r, o, a, s, l = void 0 === n, c = this._getPipeline(t, eh.InvertYPremultiplyAlpha, {
  69483. invertY: !0,
  69484. premultiplyAlpha: !1
  69485. }), u = c[0], h = c[1];
  69486. l && (n = this._device.createCommandEncoder({})),
  69487. null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "internal copy texture with invertY");
  69488. var d = n.beginRenderPass(i)
  69489. , p = this._device.createBindGroup({
  69490. layout: h,
  69491. entries: [{
  69492. binding: 0,
  69493. resource: e
  69494. }]
  69495. });
  69496. d.setPipeline(u),
  69497. d.setBindGroup(0, p),
  69498. d.draw(4, 1, 0, 0),
  69499. d.end(),
  69500. null === (s = (a = n).popDebugGroup) || void 0 === s || s.call(a),
  69501. l && (this._device.queue.submit([n.finish()]),
  69502. n = null)
  69503. }
  69504. ,
  69505. e.prototype.createTexture = function(t, i, n, r, o, a, s, l, c, u, h) {
  69506. void 0 === i && (i = !1),
  69507. void 0 === n && (n = !1),
  69508. void 0 === r && (r = !1),
  69509. void 0 === o && (o = !1),
  69510. void 0 === a && (a = !1),
  69511. void 0 === s && (s = bu.RGBA8Unorm),
  69512. void 0 === l && (l = 1),
  69513. void 0 === u && (u = -1),
  69514. void 0 === h && (h = 0),
  69515. l > 1 && (l = 4);
  69516. var d = t.layers || 1
  69517. , p = {
  69518. width: t.width,
  69519. height: t.height,
  69520. depthOrArrayLayers: d
  69521. }
  69522. , f = e.IsCompressedFormat(s)
  69523. , _ = i ? e.ComputeNumMipmapLevels(t.width, t.height) : 1
  69524. , m = u >= 0 ? u : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
  69525. h |= i && !f ? gu.CopySrc | gu.RenderAttachment : 0,
  69526. f || (h |= gu.RenderAttachment | gu.CopyDst);
  69527. var g = this._device.createTexture({
  69528. size: p,
  69529. dimension: a ? mu.E3d : mu.E2d,
  69530. format: s,
  69531. usage: m | h,
  69532. sampleCount: l,
  69533. mipLevelCount: _
  69534. });
  69535. return e.IsImageBitmap(t) && (this.updateTexture(t, g, t.width, t.height, d, s, 0, 0, r, o, 0, 0),
  69536. i && n && this.generateMipmaps(g, s, _, 0, c)),
  69537. g
  69538. }
  69539. ,
  69540. e.prototype.createCubeTexture = function(t, i, n, r, o, a, s, l, c, u) {
  69541. void 0 === i && (i = !1),
  69542. void 0 === n && (n = !1),
  69543. void 0 === r && (r = !1),
  69544. void 0 === o && (o = !1),
  69545. void 0 === a && (a = bu.RGBA8Unorm),
  69546. void 0 === s && (s = 1),
  69547. void 0 === c && (c = -1),
  69548. void 0 === u && (u = 0),
  69549. s > 1 && (s = 4);
  69550. var h = e.IsImageBitmapArray(t) ? t[0].width : t.width
  69551. , d = e.IsImageBitmapArray(t) ? t[0].height : t.height
  69552. , p = e.IsCompressedFormat(a)
  69553. , f = i ? e.ComputeNumMipmapLevels(h, d) : 1
  69554. , _ = c >= 0 ? c : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
  69555. u |= i && !p ? gu.CopySrc | gu.RenderAttachment : 0,
  69556. p || (u |= gu.RenderAttachment | gu.CopyDst);
  69557. var m = this._device.createTexture({
  69558. size: {
  69559. width: h,
  69560. height: d,
  69561. depthOrArrayLayers: 6
  69562. },
  69563. dimension: mu.E2d,
  69564. format: a,
  69565. usage: _ | u,
  69566. sampleCount: s,
  69567. mipLevelCount: f
  69568. });
  69569. return e.IsImageBitmapArray(t) && (this.updateCubeTextures(t, m, h, d, a, r, o, 0, 0),
  69570. i && n && this.generateCubeMipmaps(m, a, f, l)),
  69571. m
  69572. }
  69573. ,
  69574. e.prototype.generateCubeMipmaps = function(e, t, i, n) {
  69575. var r, o, a, s, l = void 0 === n;
  69576. l && (n = this._device.createCommandEncoder({})),
  69577. null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "create cube mipmaps - ".concat(i, " levels"));
  69578. for (var c = 0; c < 6; ++c)
  69579. this.generateMipmaps(e, t, i, c, n);
  69580. null === (s = (a = n).popDebugGroup) || void 0 === s || s.call(a),
  69581. l && (this._device.queue.submit([n.finish()]),
  69582. n = null)
  69583. }
  69584. ,
  69585. e.prototype.generateMipmaps = function(t, i, n, r, o) {
  69586. var a, s, l, c, u, h, d, p;
  69587. void 0 === r && (r = 0);
  69588. var f, _ = void 0 === o, m = this._getPipeline(i), g = m[0], v = m[1];
  69589. if (r = Math.max(r, 0),
  69590. _ && (o = this._device.createCommandEncoder({})),
  69591. null === (s = (a = o).pushDebugGroup) || void 0 === s || s.call(a, "create mipmaps for face #".concat(r, " - ").concat(n, " levels")),
  69592. e._IsHardwareTexture(t) ? (f = t.underlyingResource,
  69593. t._mipmapGenRenderPassDescr = t._mipmapGenRenderPassDescr || [],
  69594. t._mipmapGenBindGroup = t._mipmapGenBindGroup || []) : (f = t,
  69595. t = void 0),
  69596. f) {
  69597. for (var y = t, b = 1; b < n; ++b) {
  69598. var T = null !== (c = null === (l = null == y ? void 0 : y._mipmapGenRenderPassDescr[r]) || void 0 === l ? void 0 : l[b - 1]) && void 0 !== c ? c : {
  69599. colorAttachments: [{
  69600. view: f.createView({
  69601. format: i,
  69602. dimension: vu.E2d,
  69603. baseMipLevel: b,
  69604. mipLevelCount: 1,
  69605. arrayLayerCount: 1,
  69606. baseArrayLayer: r
  69607. }),
  69608. loadOp: zu.Load,
  69609. storeOp: Wu.Store
  69610. }]
  69611. };
  69612. y && (y._mipmapGenRenderPassDescr[r] = y._mipmapGenRenderPassDescr[r] || [],
  69613. y._mipmapGenRenderPassDescr[r][b - 1] = T);
  69614. var E = o.beginRenderPass(T)
  69615. , S = null !== (h = null === (u = null == y ? void 0 : y._mipmapGenBindGroup[r]) || void 0 === u ? void 0 : u[b - 1]) && void 0 !== h ? h : this._device.createBindGroup({
  69616. layout: v,
  69617. entries: [{
  69618. binding: 0,
  69619. resource: this._mipmapSampler
  69620. }, {
  69621. binding: 1,
  69622. resource: f.createView({
  69623. format: i,
  69624. dimension: vu.E2d,
  69625. baseMipLevel: b - 1,
  69626. mipLevelCount: 1,
  69627. arrayLayerCount: 1,
  69628. baseArrayLayer: r
  69629. })
  69630. }]
  69631. });
  69632. y && (y._mipmapGenBindGroup[r] = y._mipmapGenBindGroup[r] || [],
  69633. y._mipmapGenBindGroup[r][b - 1] = S),
  69634. E.setPipeline(g),
  69635. E.setBindGroup(0, S),
  69636. E.draw(4, 1, 0, 0),
  69637. E.end()
  69638. }
  69639. null === (p = (d = o).popDebugGroup) || void 0 === p || p.call(d),
  69640. _ && (this._device.queue.submit([o.finish()]),
  69641. o = null)
  69642. }
  69643. }
  69644. ,
  69645. e.prototype.createGPUTextureForInternalTexture = function(t, i, n, r, o) {
  69646. t._hardwareTexture || (t._hardwareTexture = new uh),
  69647. void 0 === i && (i = t.width),
  69648. void 0 === n && (n = t.height),
  69649. void 0 === r && (r = t.depth);
  69650. var s = t._hardwareTexture
  69651. , l = 0 != ((null != o ? o : 0) & a.TEXTURE_CREATIONFLAG_STORAGE);
  69652. s.format = e.GetWebGPUTextureFormat(t.type, t.format, t._useSRGBBuffer),
  69653. s.textureUsages = t._source === At.RenderTarget || t.source === At.MultiRenderTarget ? gu.TextureBinding | gu.CopySrc | gu.RenderAttachment : t._source === At.DepthStencil ? gu.TextureBinding | gu.RenderAttachment : -1,
  69654. s.textureAdditionalUsages = l ? gu.StorageBinding : 0;
  69655. var c, u = t.generateMipMaps, h = r || 1;
  69656. if (c = null !== t._maxLodLevel ? t._maxLodLevel : u ? e.ComputeNumMipmapLevels(i, n) : 1,
  69657. t.isCube) {
  69658. var d = this.createCubeTexture({
  69659. width: i,
  69660. height: n
  69661. }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages);
  69662. s.set(d),
  69663. s.createView({
  69664. format: s.format,
  69665. dimension: vu.Cube,
  69666. mipLevelCount: c,
  69667. baseArrayLayer: 0,
  69668. baseMipLevel: 0,
  69669. arrayLayerCount: 6,
  69670. aspect: yu.All
  69671. }, l)
  69672. } else
  69673. d = this.createTexture({
  69674. width: i,
  69675. height: n,
  69676. layers: h
  69677. }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, t.is3D, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages),
  69678. s.set(d),
  69679. s.createView({
  69680. format: s.format,
  69681. dimension: t.is2DArray ? vu.E2dArray : t.is3D ? mu.E3d : vu.E2d,
  69682. mipLevelCount: c,
  69683. baseArrayLayer: 0,
  69684. baseMipLevel: 0,
  69685. arrayLayerCount: t.is3D ? 1 : h,
  69686. aspect: yu.All
  69687. }, l);
  69688. return t.width = t.baseWidth = i,
  69689. t.height = t.baseHeight = n,
  69690. t.depth = t.baseDepth = r,
  69691. this.createMSAATexture(t, t.samples),
  69692. s
  69693. }
  69694. ,
  69695. e.prototype.createMSAATexture = function(e, t) {
  69696. var i = e._hardwareTexture;
  69697. if ((null == i ? void 0 : i.msaaTexture) && (this.releaseTexture(i.msaaTexture),
  69698. i.msaaTexture = null),
  69699. i && !((null != t ? t : 1) <= 1)) {
  69700. var n = e.width
  69701. , r = e.height
  69702. , o = e.depth || 1;
  69703. if (e.isCube) {
  69704. var a = this.createCubeTexture({
  69705. width: n,
  69706. height: r
  69707. }, !1, !1, e.invertY, !1, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages);
  69708. i.msaaTexture = a
  69709. } else
  69710. a = this.createTexture({
  69711. width: n,
  69712. height: r,
  69713. layers: o
  69714. }, !1, !1, e.invertY, !1, e.is3D, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages),
  69715. i.msaaTexture = a
  69716. }
  69717. }
  69718. ,
  69719. e.prototype.updateCubeTextures = function(e, t, i, n, r, o, a, s, l) {
  69720. void 0 === o && (o = !1),
  69721. void 0 === a && (a = !1),
  69722. void 0 === s && (s = 0),
  69723. void 0 === l && (l = 0);
  69724. for (var c = [0, 3, 1, 4, 2, 5], u = 0; u < c.length; ++u) {
  69725. var h = e[c[u]];
  69726. this.updateTexture(h, t, i, n, 1, r, u, 0, o, a, s, l)
  69727. }
  69728. }
  69729. ,
  69730. e.prototype.updateTexture = function(t, i, n, r, o, a, s, l, c, u, h, d, p) {
  69731. void 0 === s && (s = 0),
  69732. void 0 === l && (l = 0),
  69733. void 0 === c && (c = !1),
  69734. void 0 === u && (u = !1),
  69735. void 0 === h && (h = 0),
  69736. void 0 === d && (d = 0);
  69737. var f = e._IsInternalTexture(i) ? i._hardwareTexture.underlyingResource : i
  69738. , _ = e._GetBlockInformationFromFormat(a)
  69739. , m = e._IsInternalTexture(i) ? i._hardwareTexture : i
  69740. , g = {
  69741. texture: f,
  69742. origin: {
  69743. x: h,
  69744. y: d,
  69745. z: Math.max(s, 0)
  69746. },
  69747. mipLevel: l,
  69748. premultipliedAlpha: u
  69749. }
  69750. , v = {
  69751. width: Math.ceil(n / _.width) * _.width,
  69752. height: Math.ceil(r / _.height) * _.height,
  69753. depthOrArrayLayers: o || 1
  69754. };
  69755. if (void 0 !== t.byteLength) {
  69756. t = t;
  69757. var y = Math.ceil(n / _.width) * _.length;
  69758. if (256 * Math.ceil(y / 256) === y) {
  69759. var b = this._device.createCommandEncoder({})
  69760. , T = this._bufferManager.createRawBuffer(t.byteLength, fu.MapWrite | fu.CopySrc, !0)
  69761. , E = T.getMappedRange();
  69762. new Uint8Array(E).set(t),
  69763. T.unmap(),
  69764. b.copyBufferToTexture({
  69765. buffer: T,
  69766. offset: 0,
  69767. bytesPerRow: y,
  69768. rowsPerImage: r
  69769. }, g, v),
  69770. this._device.queue.submit([b.finish()]),
  69771. this._bufferManager.releaseBuffer(T)
  69772. } else
  69773. this._device.queue.writeTexture(g, t, {
  69774. offset: 0,
  69775. bytesPerRow: y,
  69776. rowsPerImage: r
  69777. }, v);
  69778. if (c || u) {
  69779. if (!e._IsInternalTexture(i))
  69780. throw "updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!";
  69781. var S = 0 === h && 0 === d && n === i.width && r === i.height;
  69782. this.invertYPreMultiplyAlpha(m, i.width, i.height, a, c, u, s, l, o || 1, h, d, S ? 0 : n, S ? 0 : r, void 0, p)
  69783. }
  69784. } else if (t = t,
  69785. c)
  69786. if (g.premultipliedAlpha = !1,
  69787. e._IsInternalTexture(i) && 0 === h && 0 === d && n === i.width && r === i.height)
  69788. this._device.queue.copyExternalImageToTexture({
  69789. source: t
  69790. }, g, v),
  69791. this.invertYPreMultiplyAlpha(m, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, void 0, p);
  69792. else {
  69793. b = this._device.createCommandEncoder({});
  69794. var A = this.createTexture({
  69795. width: n,
  69796. height: r,
  69797. layers: 1
  69798. }, !1, !1, !1, !1, !1, a, 1, b, gu.CopySrc | gu.TextureBinding);
  69799. this._deferredReleaseTextures.push([A, null]),
  69800. v.depthOrArrayLayers = 1,
  69801. this._device.queue.copyExternalImageToTexture({
  69802. source: t
  69803. }, {
  69804. texture: A
  69805. }, v),
  69806. v.depthOrArrayLayers = o || 1,
  69807. this.invertYPreMultiplyAlpha(A, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, b, p),
  69808. b.copyTextureToTexture({
  69809. texture: A
  69810. }, g, v),
  69811. this._device.queue.submit([b.finish()])
  69812. }
  69813. else
  69814. this._device.queue.copyExternalImageToTexture({
  69815. source: t
  69816. }, g, v)
  69817. }
  69818. ,
  69819. e.prototype.readPixels = function(t, i, n, r, o, a, s, l, c, u) {
  69820. void 0 === s && (s = 0),
  69821. void 0 === l && (l = 0),
  69822. void 0 === c && (c = null),
  69823. void 0 === u && (u = !1);
  69824. var h = e._GetBlockInformationFromFormat(a)
  69825. , d = Math.ceil(r / h.width) * h.length
  69826. , p = 256 * Math.ceil(d / 256)
  69827. , f = p * o
  69828. , _ = this._bufferManager.createRawBuffer(f, fu.MapRead | fu.CopyDst)
  69829. , m = this._device.createCommandEncoder({});
  69830. return m.copyTextureToBuffer({
  69831. texture: t,
  69832. mipLevel: l,
  69833. origin: {
  69834. x: i,
  69835. y: n,
  69836. z: Math.max(s, 0)
  69837. }
  69838. }, {
  69839. buffer: _,
  69840. offset: 0,
  69841. bytesPerRow: p
  69842. }, {
  69843. width: r,
  69844. height: o,
  69845. depthOrArrayLayers: 1
  69846. }),
  69847. this._device.queue.submit([m.finish()]),
  69848. this._bufferManager.readDataFromBuffer(_, f, r, o, d, p, e._GetTextureTypeFromFormat(a), 0, c, !0, u)
  69849. }
  69850. ,
  69851. e.prototype.releaseTexture = function(t) {
  69852. if (e._IsInternalTexture(t)) {
  69853. var i = t._hardwareTexture
  69854. , n = t._irradianceTexture;
  69855. this._deferredReleaseTextures.push([i, n])
  69856. } else
  69857. this._deferredReleaseTextures.push([t, null])
  69858. }
  69859. ,
  69860. e.prototype.destroyDeferredTextures = function() {
  69861. for (var t = 0; t < this._deferredReleaseTextures.length; ++t) {
  69862. var i = this._deferredReleaseTextures[t]
  69863. , n = i[0]
  69864. , r = i[1];
  69865. n && (e._IsHardwareTexture(n) ? n.release() : n.destroy()),
  69866. null == r || r.dispose()
  69867. }
  69868. this._deferredReleaseTextures.length = 0
  69869. }
  69870. ,
  69871. e
  69872. }(), _h = function(e) {
  69873. function t(t) {
  69874. var i = e.call(this) || this;
  69875. return i._buffer = t,
  69876. i
  69877. }
  69878. return U(t, e),
  69879. Object.defineProperty(t.prototype, "underlyingResource", {
  69880. get: function() {
  69881. return this._buffer
  69882. },
  69883. enumerable: !1,
  69884. configurable: !0
  69885. }),
  69886. t
  69887. }(Bt), mh = function() {
  69888. function e(e) {
  69889. this._deferredReleaseBuffers = [],
  69890. this._device = e
  69891. }
  69892. return e._IsGPUBuffer = function(e) {
  69893. return void 0 === e.underlyingResource
  69894. }
  69895. ,
  69896. e.prototype.createRawBuffer = function(e, t, i) {
  69897. void 0 === i && (i = !1);
  69898. var n = {
  69899. mappedAtCreation: i,
  69900. size: void 0 !== e.byteLength ? e.byteLength + 3 & -4 : e + 3 & -4,
  69901. usage: t
  69902. };
  69903. return this._device.createBuffer(n)
  69904. }
  69905. ,
  69906. e.prototype.createBuffer = function(e, t) {
  69907. var i = void 0 !== e.byteLength
  69908. , n = this.createRawBuffer(e, t)
  69909. , r = new _h(n);
  69910. return r.references = 1,
  69911. r.capacity = i ? e.byteLength : e,
  69912. i && this.setSubData(r, 0, e),
  69913. r
  69914. }
  69915. ,
  69916. e.prototype.setRawData = function(e, t, i, n, r) {
  69917. this._device.queue.writeBuffer(e, t, i.buffer, n, r)
  69918. }
  69919. ,
  69920. e.prototype.setSubData = function(e, t, i, n, r) {
  69921. void 0 === n && (n = 0),
  69922. void 0 === r && (r = 0);
  69923. var o = e.underlyingResource;
  69924. r = r || i.byteLength,
  69925. r = Math.min(r, e.capacity - t);
  69926. var a = i.byteOffset + n
  69927. , s = a + r
  69928. , l = r + 3 & -4;
  69929. if (l !== r) {
  69930. var c = new Uint8Array(i.buffer.slice(a, s));
  69931. (i = new Uint8Array(l)).set(c),
  69932. n = 0,
  69933. a = 0,
  69934. s = l,
  69935. r = l
  69936. }
  69937. for (var u = 15728640, h = 0; s - (a + h) > u; )
  69938. this._device.queue.writeBuffer(o, t + h, i.buffer, a + h, u),
  69939. h += u;
  69940. this._device.queue.writeBuffer(o, t + h, i.buffer, a + h, r - h)
  69941. }
  69942. ,
  69943. e.prototype._getHalfFloatAsFloatRGBAArrayBuffer = function(e, t, i) {
  69944. i || (i = new Float32Array(e));
  69945. for (var n = new Uint16Array(t); e--; )
  69946. i[e] = Dc(n[e]);
  69947. return i
  69948. }
  69949. ,
  69950. e.prototype.readDataFromBuffer = function(e, t, i, n, r, o, s, l, c, u, h) {
  69951. var d = this;
  69952. void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_BYTE),
  69953. void 0 === l && (l = 0),
  69954. void 0 === c && (c = null),
  69955. void 0 === u && (u = !0),
  69956. void 0 === h && (h = !1);
  69957. var p = s === a.TEXTURETYPE_FLOAT ? 2 : s === a.TEXTURETYPE_HALF_FLOAT ? 1 : 0;
  69958. return new Promise((function(i, a) {
  69959. e.mapAsync(_u.Read, l, t).then((function() {
  69960. var a = e.getMappedRange(l, t)
  69961. , f = c;
  69962. if (h)
  69963. f = null === f ? gr(s, t, !0, a) : gr(s, f.buffer, void 0, a);
  69964. else if (null === f)
  69965. switch (p) {
  69966. case 0:
  69967. (f = new Uint8Array(t)).set(new Uint8Array(a));
  69968. break;
  69969. case 1:
  69970. f = d._getHalfFloatAsFloatRGBAArrayBuffer(t / 2, a);
  69971. break;
  69972. case 2:
  69973. (f = new Float32Array(t / 4)).set(new Float32Array(a))
  69974. }
  69975. else
  69976. switch (p) {
  69977. case 0:
  69978. (f = new Uint8Array(f.buffer)).set(new Uint8Array(a));
  69979. break;
  69980. case 1:
  69981. f = d._getHalfFloatAsFloatRGBAArrayBuffer(t / 2, a, c);
  69982. break;
  69983. case 2:
  69984. (f = new Float32Array(f.buffer)).set(new Float32Array(a))
  69985. }
  69986. if (r !== o) {
  69987. 1 !== p || h || (r *= 2,
  69988. o *= 2);
  69989. for (var _ = new Uint8Array(f.buffer), m = r, g = 0, v = 1; v < n; ++v) {
  69990. g = v * o;
  69991. for (var y = 0; y < r; ++y)
  69992. _[m++] = _[g++]
  69993. }
  69994. f = 0 === p || h ? new Uint8Array(_.buffer,0,m) : new Float32Array(_.buffer,0,m / 4)
  69995. }
  69996. e.unmap(),
  69997. u && d.releaseBuffer(e),
  69998. i(f)
  69999. }
  70000. ), (function(e) {
  70001. return a(e)
  70002. }
  70003. ))
  70004. }
  70005. ))
  70006. }
  70007. ,
  70008. e.prototype.releaseBuffer = function(t) {
  70009. return e._IsGPUBuffer(t) ? (this._deferredReleaseBuffers.push(t),
  70010. !0) : (t.references--,
  70011. 0 === t.references && (this._deferredReleaseBuffers.push(t.underlyingResource),
  70012. !0))
  70013. }
  70014. ,
  70015. e.prototype.destroyDeferredBuffers = function() {
  70016. for (var e = 0; e < this._deferredReleaseBuffers.length; ++e)
  70017. this._deferredReleaseBuffers[e].destroy();
  70018. this._deferredReleaseBuffers.length = 0
  70019. }
  70020. ,
  70021. e
  70022. }(), gh = function() {
  70023. function e() {
  70024. this.colorAttachmentGPUTextures = [],
  70025. this.reset()
  70026. }
  70027. return e.prototype.reset = function(e) {
  70028. void 0 === e && (e = !1),
  70029. this.renderPass = null,
  70030. e && (this.renderPassDescriptor = null,
  70031. this.colorAttachmentViewDescriptor = null,
  70032. this.depthAttachmentViewDescriptor = null,
  70033. this.colorAttachmentGPUTextures = [],
  70034. this.depthTextureFormat = void 0)
  70035. }
  70036. ,
  70037. e
  70038. }(), vh = [0, 0, 3, 7, 0, 2, 6, 2, 4, 1, 5, 3, 1], yh = [0, 64, 32, 96, 16, 80, 48, 112, 8], bh = [0, 128, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128], Th = function() {
  70039. function e(e) {
  70040. this._samplers = {},
  70041. this._device = e,
  70042. this.disabled = !1
  70043. }
  70044. return e.GetSamplerHashCode = function(e) {
  70045. var t, i, n, r = e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1;
  70046. return vh[e.samplingMode] + yh[(e._comparisonFunction || 514) - 512 + 1] + bh[e.samplingMode] + ((null !== (t = e._cachedWrapU) && void 0 !== t ? t : 1) << 8) + ((null !== (i = e._cachedWrapV) && void 0 !== i ? i : 1) << 10) + ((null !== (n = e._cachedWrapR) && void 0 !== n ? n : 1) << 12) + ((e.useMipMaps ? 1 : 0) << 14) + (r << 15)
  70047. }
  70048. ,
  70049. e._GetSamplerFilterDescriptor = function(e, t) {
  70050. var i, n, r, o, s, l = e.useMipMaps;
  70051. switch (e.samplingMode) {
  70052. case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
  70053. i = Eu.Linear,
  70054. n = Eu.Linear,
  70055. r = Eu.Nearest,
  70056. l || (o = s = 0);
  70057. break;
  70058. case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
  70059. case a.TEXTURE_TRILINEAR_SAMPLINGMODE:
  70060. i = Eu.Linear,
  70061. n = Eu.Linear,
  70062. l ? r = Eu.Linear : (r = Eu.Nearest,
  70063. o = s = 0);
  70064. break;
  70065. case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
  70066. i = Eu.Nearest,
  70067. n = Eu.Nearest,
  70068. l ? r = Eu.Linear : (r = Eu.Nearest,
  70069. o = s = 0);
  70070. break;
  70071. case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  70072. i = Eu.Nearest,
  70073. n = Eu.Nearest,
  70074. r = Eu.Nearest,
  70075. l || (o = s = 0);
  70076. break;
  70077. case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  70078. i = Eu.Nearest,
  70079. n = Eu.Linear,
  70080. r = Eu.Nearest,
  70081. l || (o = s = 0);
  70082. break;
  70083. case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  70084. i = Eu.Nearest,
  70085. n = Eu.Linear,
  70086. l ? r = Eu.Linear : (r = Eu.Nearest,
  70087. o = s = 0);
  70088. break;
  70089. case a.TEXTURE_NEAREST_LINEAR:
  70090. i = Eu.Nearest,
  70091. n = Eu.Linear,
  70092. r = Eu.Nearest,
  70093. o = s = 0;
  70094. break;
  70095. case a.TEXTURE_NEAREST_NEAREST:
  70096. case a.TEXTURE_NEAREST_SAMPLINGMODE:
  70097. i = Eu.Nearest,
  70098. n = Eu.Nearest,
  70099. r = Eu.Nearest,
  70100. o = s = 0;
  70101. break;
  70102. case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  70103. i = Eu.Linear,
  70104. n = Eu.Nearest,
  70105. r = Eu.Nearest,
  70106. l || (o = s = 0);
  70107. break;
  70108. case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  70109. i = Eu.Linear,
  70110. n = Eu.Nearest,
  70111. l ? r = Eu.Linear : (r = Eu.Nearest,
  70112. o = s = 0);
  70113. break;
  70114. case a.TEXTURE_LINEAR_LINEAR:
  70115. case a.TEXTURE_BILINEAR_SAMPLINGMODE:
  70116. i = Eu.Linear,
  70117. n = Eu.Linear,
  70118. r = Eu.Nearest,
  70119. o = s = 0;
  70120. break;
  70121. case a.TEXTURE_LINEAR_NEAREST:
  70122. i = Eu.Linear,
  70123. n = Eu.Nearest,
  70124. r = Eu.Nearest,
  70125. o = s = 0;
  70126. break;
  70127. default:
  70128. i = Eu.Nearest,
  70129. n = Eu.Nearest,
  70130. r = Eu.Nearest,
  70131. o = s = 0
  70132. }
  70133. return t > 1 && (0 !== o || 0 !== s) ? {
  70134. magFilter: Eu.Linear,
  70135. minFilter: Eu.Linear,
  70136. mipmapFilter: Eu.Linear,
  70137. anisotropyEnabled: !0
  70138. } : {
  70139. magFilter: i,
  70140. minFilter: n,
  70141. mipmapFilter: r,
  70142. lodMinClamp: o,
  70143. lodMaxClamp: s
  70144. }
  70145. }
  70146. ,
  70147. e._GetWrappingMode = function(e) {
  70148. switch (e) {
  70149. case a.TEXTURE_WRAP_ADDRESSMODE:
  70150. return Tu.Repeat;
  70151. case a.TEXTURE_CLAMP_ADDRESSMODE:
  70152. return Tu.ClampToEdge;
  70153. case a.TEXTURE_MIRROR_ADDRESSMODE:
  70154. return Tu.MirrorRepeat
  70155. }
  70156. return Tu.Repeat
  70157. }
  70158. ,
  70159. e._GetSamplerWrappingDescriptor = function(e) {
  70160. return {
  70161. addressModeU: this._GetWrappingMode(e._cachedWrapU),
  70162. addressModeV: this._GetWrappingMode(e._cachedWrapV),
  70163. addressModeW: this._GetWrappingMode(e._cachedWrapR)
  70164. }
  70165. }
  70166. ,
  70167. e._GetSamplerDescriptor = function(t) {
  70168. var i = t.useMipMaps && t._cachedAnisotropicFilteringLevel && t._cachedAnisotropicFilteringLevel > 1 ? 4 : 1
  70169. , n = this._GetSamplerFilterDescriptor(t, i);
  70170. return V(V(V({}, n), this._GetSamplerWrappingDescriptor(t)), {
  70171. compare: t._comparisonFunction ? e.GetCompareFunction(t._comparisonFunction) : void 0,
  70172. maxAnisotropy: n.anisotropyEnabled ? i : 1
  70173. })
  70174. }
  70175. ,
  70176. e.GetCompareFunction = function(e) {
  70177. switch (e) {
  70178. case a.ALWAYS:
  70179. return Su.Always;
  70180. case a.EQUAL:
  70181. return Su.Equal;
  70182. case a.GREATER:
  70183. return Su.Greater;
  70184. case a.GEQUAL:
  70185. return Su.GreaterEqual;
  70186. case a.LESS:
  70187. return Su.Less;
  70188. case a.LEQUAL:
  70189. return Su.LessEqual;
  70190. case a.NEVER:
  70191. return Su.Never;
  70192. case a.NOTEQUAL:
  70193. return Su.NotEqual;
  70194. default:
  70195. return Su.Less
  70196. }
  70197. }
  70198. ,
  70199. e.prototype.getSampler = function(t, i, n) {
  70200. if (void 0 === i && (i = !1),
  70201. void 0 === n && (n = 0),
  70202. this.disabled)
  70203. return this._device.createSampler(e._GetSamplerDescriptor(t));
  70204. i ? n = 0 : 0 === n && (n = e.GetSamplerHashCode(t));
  70205. var r = i ? void 0 : this._samplers[n];
  70206. return r || (r = this._device.createSampler(e._GetSamplerDescriptor(t)),
  70207. i || (this._samplers[n] = r)),
  70208. r
  70209. }
  70210. ,
  70211. e
  70212. }();
  70213. !function(e) {
  70214. e[e.StencilReadMask = 0] = "StencilReadMask",
  70215. e[e.StencilWriteMask = 1] = "StencilWriteMask",
  70216. e[e.DepthBias = 2] = "DepthBias",
  70217. e[e.DepthBiasSlopeScale = 3] = "DepthBiasSlopeScale",
  70218. e[e.DepthStencilState = 4] = "DepthStencilState",
  70219. e[e.MRTAttachments1 = 5] = "MRTAttachments1",
  70220. e[e.MRTAttachments2 = 6] = "MRTAttachments2",
  70221. e[e.RasterizationState = 7] = "RasterizationState",
  70222. e[e.ColorStates = 8] = "ColorStates",
  70223. e[e.ShaderStage = 9] = "ShaderStage",
  70224. e[e.TextureStage = 10] = "TextureStage",
  70225. e[e.VertexState = 11] = "VertexState",
  70226. e[e.NumStates = 12] = "NumStates"
  70227. }(hh || (hh = {}));
  70228. var Eh = {
  70229. 0: 1,
  70230. 1: 2,
  70231. 768: 3,
  70232. 769: 4,
  70233. 770: 5,
  70234. 771: 6,
  70235. 772: 7,
  70236. 773: 8,
  70237. 774: 9,
  70238. 775: 10,
  70239. 776: 11,
  70240. 32769: 12,
  70241. 32770: 13,
  70242. 32771: 12,
  70243. 32772: 13
  70244. }
  70245. , Sh = {
  70246. 0: 0,
  70247. 7680: 1,
  70248. 7681: 2,
  70249. 7682: 3,
  70250. 7683: 4,
  70251. 5386: 5,
  70252. 34055: 6,
  70253. 34056: 7
  70254. }
  70255. , Ah = function() {
  70256. function e(e, t, i) {
  70257. this.mrtTextureCount = 0,
  70258. this._device = e,
  70259. this._useTextureStage = i,
  70260. this._states = new Array(30),
  70261. this._statesLength = 0,
  70262. this._stateDirtyLowestIndex = 0,
  70263. this._emptyVertexBuffer = t,
  70264. this._mrtFormats = [],
  70265. this._parameter = {
  70266. token: void 0,
  70267. pipeline: null
  70268. },
  70269. this.disabled = !1,
  70270. this.vertexBuffers = [],
  70271. this._kMaxVertexBufferStride = e.limits.maxVertexBufferArrayStride || 2048,
  70272. this.reset()
  70273. }
  70274. return e.prototype.reset = function() {
  70275. this._isDirty = !0,
  70276. this.vertexBuffers.length = 0,
  70277. this.setAlphaToCoverage(!1),
  70278. this.resetDepthCullingState(),
  70279. this.setClampDepth(!1),
  70280. this.setDepthBias(0),
  70281. this._webgpuColorFormat = [bu.BGRA8Unorm],
  70282. this.setColorFormat(bu.BGRA8Unorm),
  70283. this.setMRT([]),
  70284. this.setAlphaBlendEnabled(!1),
  70285. this.setAlphaBlendFactors([null, null, null, null], [null, null]),
  70286. this.setWriteMask(15),
  70287. this.setDepthStencilFormat(bu.Depth24PlusStencil8),
  70288. this.setStencilEnabled(!1),
  70289. this.resetStencilState(),
  70290. this.setBuffers(null, null, null),
  70291. this._setTextureState(0)
  70292. }
  70293. ,
  70294. Object.defineProperty(e.prototype, "colorFormats", {
  70295. get: function() {
  70296. return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat
  70297. },
  70298. enumerable: !1,
  70299. configurable: !0
  70300. }),
  70301. e.prototype.getRenderPipeline = function(t, i, n, r) {
  70302. if (void 0 === r && (r = 0),
  70303. n > 1 && (n = 4),
  70304. this.disabled) {
  70305. var o = e._GetTopology(t);
  70306. return this._setVertexState(i),
  70307. this._parameter.pipeline = this._createRenderPipeline(i, o, n),
  70308. e.NumCacheMiss++,
  70309. e._NumPipelineCreationCurrentFrame++,
  70310. this._parameter.pipeline
  70311. }
  70312. if (this._setShaderStage(i.uniqueId),
  70313. this._setRasterizationState(t, n),
  70314. this._setColorStates(),
  70315. this._setDepthStencilState(),
  70316. this._setVertexState(i),
  70317. this._setTextureState(r),
  70318. this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex,
  70319. !this._isDirty && this._parameter.pipeline)
  70320. return this._stateDirtyLowestIndex = this._statesLength,
  70321. e.NumCacheHitWithoutHash++,
  70322. this._parameter.pipeline;
  70323. if (this._getRenderPipeline(this._parameter),
  70324. this._isDirty = !1,
  70325. this._stateDirtyLowestIndex = this._statesLength,
  70326. this._parameter.pipeline)
  70327. return e.NumCacheHitWithHash++,
  70328. this._parameter.pipeline;
  70329. var a = e._GetTopology(t);
  70330. return this._parameter.pipeline = this._createRenderPipeline(i, a, n),
  70331. this._setRenderPipeline(this._parameter),
  70332. e.NumCacheMiss++,
  70333. e._NumPipelineCreationCurrentFrame++,
  70334. this._parameter.pipeline
  70335. }
  70336. ,
  70337. e.prototype.endFrame = function() {
  70338. e.NumPipelineCreationLastFrame = e._NumPipelineCreationCurrentFrame,
  70339. e._NumPipelineCreationCurrentFrame = 0
  70340. }
  70341. ,
  70342. e.prototype.setAlphaToCoverage = function(e) {
  70343. this._alphaToCoverageEnabled = e
  70344. }
  70345. ,
  70346. e.prototype.setFrontFace = function(e) {
  70347. this._frontFace = e
  70348. }
  70349. ,
  70350. e.prototype.setCullEnabled = function(e) {
  70351. this._cullEnabled = e
  70352. }
  70353. ,
  70354. e.prototype.setCullFace = function(e) {
  70355. this._cullFace = e
  70356. }
  70357. ,
  70358. e.prototype.setClampDepth = function(e) {
  70359. this._clampDepth = e
  70360. }
  70361. ,
  70362. e.prototype.resetDepthCullingState = function() {
  70363. this.setDepthCullingState(!1, 2, 1, 0, 0, !0, !0, a.ALWAYS)
  70364. }
  70365. ,
  70366. e.prototype.setDepthCullingState = function(e, t, i, n, r, o, s, l) {
  70367. this._depthWriteEnabled = s,
  70368. this._depthTestEnabled = o,
  70369. this._depthCompare = (null != l ? l : a.ALWAYS) - 512,
  70370. this._cullFace = i,
  70371. this._cullEnabled = e,
  70372. this._frontFace = t,
  70373. this.setDepthBiasSlopeScale(n),
  70374. this.setDepthBias(r)
  70375. }
  70376. ,
  70377. e.prototype.setDepthBias = function(e) {
  70378. this._depthBias !== e && (this._depthBias = e,
  70379. this._states[hh.DepthBias] = e,
  70380. this._isDirty = !0,
  70381. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBias))
  70382. }
  70383. ,
  70384. e.prototype.setDepthBiasSlopeScale = function(e) {
  70385. this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e,
  70386. this._states[hh.DepthBiasSlopeScale] = e,
  70387. this._isDirty = !0,
  70388. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBiasSlopeScale))
  70389. }
  70390. ,
  70391. e.prototype.setColorFormat = function(e) {
  70392. this._webgpuColorFormat[0] = e,
  70393. this._colorFormat = ph[e]
  70394. }
  70395. ,
  70396. e.prototype.setMRTAttachments = function(e) {
  70397. this.mrtAttachments = e;
  70398. for (var t = 0, i = 0; i < e.length; ++i)
  70399. 0 !== e[i] && (t += 1 << i);
  70400. this._mrtEnabledMask !== t && (this._mrtEnabledMask = t,
  70401. this._isDirty = !0,
  70402. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.MRTAttachments1))
  70403. }
  70404. ,
  70405. e.prototype.setMRT = function(e, t) {
  70406. var i;
  70407. if ((t = null != t ? t : e.length) > 10)
  70408. throw "Can't handle more than 10 attachments for a MRT in cache render pipeline!";
  70409. this.mrtTextureArray = e,
  70410. this.mrtTextureCount = t,
  70411. this._mrtEnabledMask = 65535;
  70412. for (var n = [0, 0], r = 0, o = 0, a = 0, s = 0; s < t; ++s) {
  70413. var l = e[s]
  70414. , c = null == l ? void 0 : l._hardwareTexture;
  70415. this._mrtFormats[a] = null !== (i = null == c ? void 0 : c.format) && void 0 !== i ? i : this._webgpuColorFormat[0],
  70416. n[r] += ph[this._mrtFormats[a]] << o,
  70417. a++,
  70418. (o += 6) >= 32 && (o = 0,
  70419. r++)
  70420. }
  70421. this._mrtFormats.length = a,
  70422. this._mrtAttachments1 === n[0] && this._mrtAttachments2 === n[1] || (this._mrtAttachments1 = n[0],
  70423. this._mrtAttachments2 = n[1],
  70424. this._states[hh.MRTAttachments1] = n[0],
  70425. this._states[hh.MRTAttachments2] = n[1],
  70426. this._isDirty = !0,
  70427. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.MRTAttachments1))
  70428. }
  70429. ,
  70430. e.prototype.setAlphaBlendEnabled = function(e) {
  70431. this._alphaBlendEnabled = e
  70432. }
  70433. ,
  70434. e.prototype.setAlphaBlendFactors = function(e, t) {
  70435. this._alphaBlendFuncParams = e,
  70436. this._alphaBlendEqParams = t
  70437. }
  70438. ,
  70439. e.prototype.setWriteMask = function(e) {
  70440. this._writeMask = e
  70441. }
  70442. ,
  70443. e.prototype.setDepthStencilFormat = function(e) {
  70444. this._webgpuDepthStencilFormat = e,
  70445. this._depthStencilFormat = void 0 === e ? 0 : ph[e]
  70446. }
  70447. ,
  70448. e.prototype.setDepthTestEnabled = function(e) {
  70449. this._depthTestEnabled = e
  70450. }
  70451. ,
  70452. e.prototype.setDepthWriteEnabled = function(e) {
  70453. this._depthWriteEnabled = e
  70454. }
  70455. ,
  70456. e.prototype.setDepthCompare = function(e) {
  70457. this._depthCompare = (null != e ? e : a.ALWAYS) - 512
  70458. }
  70459. ,
  70460. e.prototype.setStencilEnabled = function(e) {
  70461. this._stencilEnabled = e
  70462. }
  70463. ,
  70464. e.prototype.setStencilCompare = function(e) {
  70465. this._stencilFrontCompare = (null != e ? e : a.ALWAYS) - 512
  70466. }
  70467. ,
  70468. e.prototype.setStencilDepthFailOp = function(e) {
  70469. this._stencilFrontDepthFailOp = null === e ? 1 : Sh[e]
  70470. }
  70471. ,
  70472. e.prototype.setStencilPassOp = function(e) {
  70473. this._stencilFrontPassOp = null === e ? 2 : Sh[e]
  70474. }
  70475. ,
  70476. e.prototype.setStencilFailOp = function(e) {
  70477. this._stencilFrontFailOp = null === e ? 1 : Sh[e]
  70478. }
  70479. ,
  70480. e.prototype.setStencilReadMask = function(e) {
  70481. this._stencilReadMask !== e && (this._stencilReadMask = e,
  70482. this._states[hh.StencilReadMask] = e,
  70483. this._isDirty = !0,
  70484. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.StencilReadMask))
  70485. }
  70486. ,
  70487. e.prototype.setStencilWriteMask = function(e) {
  70488. this._stencilWriteMask !== e && (this._stencilWriteMask = e,
  70489. this._states[hh.StencilWriteMask] = e,
  70490. this._isDirty = !0,
  70491. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.StencilWriteMask))
  70492. }
  70493. ,
  70494. e.prototype.resetStencilState = function() {
  70495. this.setStencilState(!1, a.ALWAYS, a.KEEP, a.REPLACE, a.KEEP, 255, 255)
  70496. }
  70497. ,
  70498. e.prototype.setStencilState = function(e, t, i, n, r, o, s) {
  70499. this._stencilEnabled = e,
  70500. this._stencilFrontCompare = (null != t ? t : a.ALWAYS) - 512,
  70501. this._stencilFrontDepthFailOp = null === i ? 1 : Sh[i],
  70502. this._stencilFrontPassOp = null === n ? 2 : Sh[n],
  70503. this._stencilFrontFailOp = null === r ? 1 : Sh[r],
  70504. this.setStencilReadMask(o),
  70505. this.setStencilWriteMask(s)
  70506. }
  70507. ,
  70508. e.prototype.setBuffers = function(e, t, i) {
  70509. this._vertexBuffers = e,
  70510. this._overrideVertexBuffers = i,
  70511. this._indexBuffer = t
  70512. }
  70513. ,
  70514. e._GetTopology = function(e) {
  70515. switch (e) {
  70516. case a.MATERIAL_TriangleFillMode:
  70517. return Iu.TriangleList;
  70518. case a.MATERIAL_PointFillMode:
  70519. return Iu.PointList;
  70520. case a.MATERIAL_WireFrameFillMode:
  70521. return Iu.LineList;
  70522. case a.MATERIAL_PointListDrawMode:
  70523. return Iu.PointList;
  70524. case a.MATERIAL_LineListDrawMode:
  70525. return Iu.LineList;
  70526. case a.MATERIAL_LineLoopDrawMode:
  70527. throw "LineLoop is an unsupported fillmode in WebGPU";
  70528. case a.MATERIAL_LineStripDrawMode:
  70529. return Iu.LineStrip;
  70530. case a.MATERIAL_TriangleStripDrawMode:
  70531. return Iu.TriangleStrip;
  70532. case a.MATERIAL_TriangleFanDrawMode:
  70533. throw "TriangleFan is an unsupported fillmode in WebGPU";
  70534. default:
  70535. return Iu.TriangleList
  70536. }
  70537. }
  70538. ,
  70539. e._GetAphaBlendOperation = function(e) {
  70540. switch (e) {
  70541. case a.GL_ALPHA_EQUATION_ADD:
  70542. return Fu.Add;
  70543. case a.GL_ALPHA_EQUATION_SUBTRACT:
  70544. return Fu.Subtract;
  70545. case a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:
  70546. return Fu.ReverseSubtract;
  70547. case a.GL_ALPHA_EQUATION_MIN:
  70548. return Fu.Min;
  70549. case a.GL_ALPHA_EQUATION_MAX:
  70550. return Fu.Max;
  70551. default:
  70552. return Fu.Add
  70553. }
  70554. }
  70555. ,
  70556. e._GetAphaBlendFactor = function(e) {
  70557. switch (e) {
  70558. case 0:
  70559. return Lu.Zero;
  70560. case 1:
  70561. return Lu.One;
  70562. case a.GL_ALPHA_FUNCTION_SRC:
  70563. return Lu.Src;
  70564. case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:
  70565. return Lu.OneMinusSrc;
  70566. case a.GL_ALPHA_FUNCTION_SRC_ALPHA:
  70567. return Lu.SrcAlpha;
  70568. case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:
  70569. return Lu.OneMinusSrcAlpha;
  70570. case a.GL_ALPHA_FUNCTION_DST_ALPHA:
  70571. return Lu.DstAlpha;
  70572. case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:
  70573. return Lu.OneMinusDstAlpha;
  70574. case a.GL_ALPHA_FUNCTION_DST_COLOR:
  70575. return Lu.Dst;
  70576. case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:
  70577. return Lu.OneMinusDst;
  70578. case a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:
  70579. return Lu.SrcAlphaSaturated;
  70580. case a.GL_ALPHA_FUNCTION_CONSTANT_COLOR:
  70581. return Lu.Constant;
  70582. case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:
  70583. return Lu.OneMinusConstant;
  70584. case a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:
  70585. return Lu.Constant;
  70586. case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:
  70587. return Lu.OneMinusConstant;
  70588. default:
  70589. return Lu.One
  70590. }
  70591. }
  70592. ,
  70593. e._GetCompareFunction = function(e) {
  70594. switch (e) {
  70595. case 0:
  70596. return Su.Never;
  70597. case 1:
  70598. return Su.Less;
  70599. case 2:
  70600. return Su.Equal;
  70601. case 3:
  70602. return Su.LessEqual;
  70603. case 4:
  70604. return Su.Greater;
  70605. case 5:
  70606. return Su.NotEqual;
  70607. case 6:
  70608. return Su.GreaterEqual;
  70609. case 7:
  70610. return Su.Always
  70611. }
  70612. return Su.Never
  70613. }
  70614. ,
  70615. e._GetStencilOpFunction = function(e) {
  70616. switch (e) {
  70617. case 0:
  70618. return wu.Zero;
  70619. case 1:
  70620. return wu.Keep;
  70621. case 2:
  70622. return wu.Replace;
  70623. case 3:
  70624. return wu.IncrementClamp;
  70625. case 4:
  70626. return wu.DecrementClamp;
  70627. case 5:
  70628. return wu.Invert;
  70629. case 6:
  70630. return wu.IncrementWrap;
  70631. case 7:
  70632. return wu.DecrementWrap
  70633. }
  70634. return wu.Keep
  70635. }
  70636. ,
  70637. e._GetVertexInputDescriptorFormat = function(e) {
  70638. var t = e.type
  70639. , i = e.normalized
  70640. , n = e.getSize();
  70641. switch (t) {
  70642. case Bi.BYTE:
  70643. switch (n) {
  70644. case 1:
  70645. case 2:
  70646. return i ? Uu.Snorm8x2 : Uu.Sint8x2;
  70647. case 3:
  70648. case 4:
  70649. return i ? Uu.Snorm8x4 : Uu.Sint8x4
  70650. }
  70651. break;
  70652. case Bi.UNSIGNED_BYTE:
  70653. switch (n) {
  70654. case 1:
  70655. case 2:
  70656. return i ? Uu.Unorm8x2 : Uu.Uint8x2;
  70657. case 3:
  70658. case 4:
  70659. return i ? Uu.Unorm8x4 : Uu.Uint8x4
  70660. }
  70661. break;
  70662. case Bi.SHORT:
  70663. switch (n) {
  70664. case 1:
  70665. case 2:
  70666. return i ? Uu.Snorm16x2 : Uu.Sint16x2;
  70667. case 3:
  70668. case 4:
  70669. return i ? Uu.Snorm16x4 : Uu.Sint16x4
  70670. }
  70671. break;
  70672. case Bi.UNSIGNED_SHORT:
  70673. switch (n) {
  70674. case 1:
  70675. case 2:
  70676. return i ? Uu.Unorm16x2 : Uu.Uint16x2;
  70677. case 3:
  70678. case 4:
  70679. return i ? Uu.Unorm16x4 : Uu.Uint16x4
  70680. }
  70681. break;
  70682. case Bi.INT:
  70683. switch (n) {
  70684. case 1:
  70685. return Uu.Sint32;
  70686. case 2:
  70687. return Uu.Sint32x2;
  70688. case 3:
  70689. return Uu.Sint32x3;
  70690. case 4:
  70691. return Uu.Sint32x4
  70692. }
  70693. break;
  70694. case Bi.UNSIGNED_INT:
  70695. switch (n) {
  70696. case 1:
  70697. return Uu.Uint32;
  70698. case 2:
  70699. return Uu.Uint32x2;
  70700. case 3:
  70701. return Uu.Uint32x3;
  70702. case 4:
  70703. return Uu.Uint32x4
  70704. }
  70705. break;
  70706. case Bi.FLOAT:
  70707. switch (n) {
  70708. case 1:
  70709. return Uu.Float32;
  70710. case 2:
  70711. return Uu.Float32x2;
  70712. case 3:
  70713. return Uu.Float32x3;
  70714. case 4:
  70715. return Uu.Float32x4
  70716. }
  70717. }
  70718. throw new Error("Invalid Format '".concat(e.getKind(), "' - type=").concat(t, ", normalized=").concat(i, ", size=").concat(n))
  70719. }
  70720. ,
  70721. e.prototype._getAphaBlendState = function() {
  70722. return this._alphaBlendEnabled ? {
  70723. srcFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),
  70724. dstFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),
  70725. operation: e._GetAphaBlendOperation(this._alphaBlendEqParams[1])
  70726. } : null
  70727. }
  70728. ,
  70729. e.prototype._getColorBlendState = function() {
  70730. return this._alphaBlendEnabled ? {
  70731. srcFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),
  70732. dstFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),
  70733. operation: e._GetAphaBlendOperation(this._alphaBlendEqParams[0])
  70734. } : null
  70735. }
  70736. ,
  70737. e.prototype._setShaderStage = function(e) {
  70738. this._shaderId !== e && (this._shaderId = e,
  70739. this._states[hh.ShaderStage] = e,
  70740. this._isDirty = !0,
  70741. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.ShaderStage))
  70742. }
  70743. ,
  70744. e.prototype._setRasterizationState = function(e, t) {
  70745. var i = this._frontFace - 1 + ((this._cullEnabled ? this._cullFace : 0) << 1) + ((this._clampDepth ? 1 : 0) << 3) + ((this._alphaToCoverageEnabled ? 1 : 0) << 4) + (e << 5) + (t << 8);
  70746. this._rasterizationState !== i && (this._rasterizationState = i,
  70747. this._states[hh.RasterizationState] = this._rasterizationState,
  70748. this._isDirty = !0,
  70749. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.RasterizationState))
  70750. }
  70751. ,
  70752. e.prototype._setColorStates = function() {
  70753. var e = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29);
  70754. this._alphaBlendEnabled && (e += ((null === this._alphaBlendFuncParams[0] ? 2 : Eh[this._alphaBlendFuncParams[0]]) << 0) + ((null === this._alphaBlendFuncParams[1] ? 2 : Eh[this._alphaBlendFuncParams[1]]) << 4) + ((null === this._alphaBlendFuncParams[2] ? 2 : Eh[this._alphaBlendFuncParams[2]]) << 8) + ((null === this._alphaBlendFuncParams[3] ? 2 : Eh[this._alphaBlendFuncParams[3]]) << 12) + ((null === this._alphaBlendEqParams[0] ? 1 : this._alphaBlendEqParams[0] - 32773) << 16) + ((null === this._alphaBlendEqParams[1] ? 1 : this._alphaBlendEqParams[1] - 32773) << 19)),
  70755. e !== this._colorStates && (this._colorStates = e,
  70756. this._states[hh.ColorStates] = this._colorStates,
  70757. this._isDirty = !0,
  70758. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.ColorStates))
  70759. }
  70760. ,
  70761. e.prototype._setDepthStencilState = function() {
  70762. var e = this._stencilEnabled ? this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9) : 591
  70763. , t = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) << 6) + (e << 10);
  70764. this._depthStencilState !== t && (this._depthStencilState = t,
  70765. this._states[hh.DepthStencilState] = this._depthStencilState,
  70766. this._isDirty = !0,
  70767. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthStencilState))
  70768. }
  70769. ,
  70770. e.prototype._setVertexState = function(e) {
  70771. for (var t, i, n, r = this._statesLength, o = hh.VertexState, a = e._pipelineContext, s = a.shaderProcessingContext.attributeNamesFromEffect, l = a.shaderProcessingContext.attributeLocationsFromEffect, c = 0, u = 0; u < s.length; u++) {
  70772. var h = l[u]
  70773. , d = null !== (t = this._overrideVertexBuffers && this._overrideVertexBuffers[s[u]]) && void 0 !== t ? t : this._vertexBuffers[s[u]];
  70774. d || (d = this._emptyVertexBuffer);
  70775. var p = null === (i = d.getBuffer()) || void 0 === i ? void 0 : i.underlyingResource;
  70776. if (void 0 === d._validOffsetRange) {
  70777. var f = d.byteOffset
  70778. , _ = d.getSize(!0)
  70779. , m = d.byteStride;
  70780. d._validOffsetRange = f <= this._kMaxVertexBufferStride - _ && (0 === m || f + _ <= m)
  70781. }
  70782. n && n === p && d._validOffsetRange || (this.vertexBuffers[c++] = d,
  70783. n = d._validOffsetRange ? p : null);
  70784. var g = d.hashCode + (h << 7);
  70785. this._isDirty = this._isDirty || this._states[o] !== g,
  70786. this._states[o++] = g
  70787. }
  70788. this.vertexBuffers.length = c,
  70789. this._statesLength = o,
  70790. this._isDirty = this._isDirty || o !== r,
  70791. this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.VertexState))
  70792. }
  70793. ,
  70794. e.prototype._setTextureState = function(e) {
  70795. this._textureState !== e && (this._textureState = e,
  70796. this._states[hh.TextureStage] = this._textureState,
  70797. this._isDirty = !0,
  70798. this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.TextureStage))
  70799. }
  70800. ,
  70801. e.prototype._createPipelineLayout = function(e) {
  70802. if (this._useTextureStage)
  70803. return this._createPipelineLayoutWithTextureStage(e);
  70804. for (var t = [], i = e.shaderProcessingContext.bindGroupLayoutEntries, n = 0; n < i.length; n++) {
  70805. var r = i[n];
  70806. t[n] = this._device.createBindGroupLayout({
  70807. entries: r
  70808. })
  70809. }
  70810. return e.bindGroupLayouts = t,
  70811. this._device.createPipelineLayout({
  70812. bindGroupLayouts: t
  70813. })
  70814. }
  70815. ,
  70816. e.prototype._createPipelineLayoutWithTextureStage = function(e) {
  70817. for (var t, i = e.shaderProcessingContext, n = i.bindGroupLayoutEntries, r = 1, o = 0; o < n.length; o++)
  70818. for (var a = n[o], s = 0; s < a.length; s++) {
  70819. var l = n[o][s];
  70820. if (l.texture) {
  70821. var c = i.bindGroupLayoutEntryInfo[o][l.binding].name
  70822. , u = i.availableTextures[c]
  70823. , h = u.autoBindSampler ? i.availableSamplers[c + Qu.AutoSamplerSuffix] : null
  70824. , d = u.sampleType
  70825. , p = null !== (t = null == h ? void 0 : h.type) && void 0 !== t ? t : Ru.Filtering;
  70826. if (this._textureState & r && d !== Cu.Depth && (u.autoBindSampler && (p = Ru.NonFiltering),
  70827. d = Cu.UnfilterableFloat),
  70828. l.texture.sampleType = d,
  70829. h) {
  70830. var f = i.bindGroupLayoutEntryInfo[h.binding.groupIndex][h.binding.bindingIndex].index;
  70831. n[h.binding.groupIndex][f].sampler.type = p
  70832. }
  70833. r <<= 1
  70834. }
  70835. }
  70836. var _ = [];
  70837. for (o = 0; o < n.length; ++o)
  70838. _[o] = this._device.createBindGroupLayout({
  70839. entries: n[o]
  70840. });
  70841. return e.bindGroupLayouts = _,
  70842. this._device.createPipelineLayout({
  70843. bindGroupLayouts: _
  70844. })
  70845. }
  70846. ,
  70847. e.prototype._getVertexInputDescriptor = function(t) {
  70848. for (var i, n, r, o, a = [], s = t._pipelineContext, l = s.shaderProcessingContext.attributeNamesFromEffect, c = s.shaderProcessingContext.attributeLocationsFromEffect, u = 0; u < l.length; u++) {
  70849. var h = c[u]
  70850. , d = null !== (i = this._overrideVertexBuffers && this._overrideVertexBuffers[l[u]]) && void 0 !== i ? i : this._vertexBuffers[l[u]];
  70851. d || (d = this._emptyVertexBuffer);
  70852. var p = null === (n = d.getBuffer()) || void 0 === n ? void 0 : n.underlyingResource
  70853. , f = d.byteOffset
  70854. , _ = !d._validOffsetRange;
  70855. if (!r || !o || r !== p || _) {
  70856. var m = {
  70857. arrayStride: d.byteStride,
  70858. stepMode: d.getIsInstanced() ? Vu.Instance : Vu.Vertex,
  70859. attributes: []
  70860. };
  70861. a.push(m),
  70862. o = m.attributes,
  70863. _ && (f = 0,
  70864. p = null)
  70865. }
  70866. o.push({
  70867. shaderLocation: h,
  70868. offset: f,
  70869. format: e._GetVertexInputDescriptorFormat(d)
  70870. }),
  70871. r = p
  70872. }
  70873. return a
  70874. }
  70875. ,
  70876. e.prototype._createRenderPipeline = function(t, i, n) {
  70877. var r = t._pipelineContext
  70878. , o = this._getVertexInputDescriptor(t)
  70879. , a = this._createPipelineLayout(r)
  70880. , s = []
  70881. , l = this._getAphaBlendState()
  70882. , c = this._getColorBlendState();
  70883. if (this._mrtAttachments1 > 0)
  70884. for (var u = 0; u < this._mrtFormats.length; ++u) {
  70885. var h = {
  70886. format: this._mrtFormats[u],
  70887. writeMask: 0 != (this._mrtEnabledMask & 1 << u) ? this._writeMask : 0
  70888. };
  70889. l && c && (h.blend = {
  70890. alpha: l,
  70891. color: c
  70892. }),
  70893. s.push(h)
  70894. }
  70895. else
  70896. h = {
  70897. format: this._webgpuColorFormat[0],
  70898. writeMask: this._writeMask
  70899. },
  70900. l && c && (h.blend = {
  70901. alpha: l,
  70902. color: c
  70903. }),
  70904. s.push(h);
  70905. var d = {
  70906. compare: e._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7),
  70907. depthFailOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1),
  70908. failOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1),
  70909. passOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1)
  70910. }
  70911. , p = void 0;
  70912. i !== Iu.LineStrip && i !== Iu.TriangleStrip || (p = !this._indexBuffer || this._indexBuffer.is32Bits ? Bu.Uint32 : Bu.Uint16);
  70913. var f = !!this._webgpuDepthStencilFormat && fh.HasStencilAspect(this._webgpuDepthStencilFormat);
  70914. return this._device.createRenderPipeline({
  70915. layout: a,
  70916. vertex: {
  70917. module: r.stages.vertexStage.module,
  70918. entryPoint: r.stages.vertexStage.entryPoint,
  70919. buffers: o
  70920. },
  70921. primitive: {
  70922. topology: i,
  70923. stripIndexFormat: p,
  70924. frontFace: 1 === this._frontFace ? Ou.CCW : Ou.CW,
  70925. cullMode: this._cullEnabled ? 2 === this._cullFace ? Du.Front : Du.Back : Du.None
  70926. },
  70927. fragment: r.stages.fragmentStage ? {
  70928. module: r.stages.fragmentStage.module,
  70929. entryPoint: r.stages.fragmentStage.entryPoint,
  70930. targets: s
  70931. } : void 0,
  70932. multisample: {
  70933. count: n
  70934. },
  70935. depthStencil: void 0 === this._webgpuDepthStencilFormat ? void 0 : {
  70936. depthWriteEnabled: this._depthWriteEnabled,
  70937. depthCompare: this._depthTestEnabled ? e._GetCompareFunction(this._depthCompare) : Su.Always,
  70938. format: this._webgpuDepthStencilFormat,
  70939. stencilFront: this._stencilEnabled && f ? d : void 0,
  70940. stencilBack: this._stencilEnabled && f ? d : void 0,
  70941. stencilReadMask: this._stencilEnabled && f ? this._stencilReadMask : void 0,
  70942. stencilWriteMask: this._stencilEnabled && f ? this._stencilWriteMask : void 0,
  70943. depthBias: this._depthBias,
  70944. depthBiasClamp: this._depthBiasClamp,
  70945. depthBiasSlopeScale: this._depthBiasSlopeScale
  70946. }
  70947. })
  70948. }
  70949. ,
  70950. e.NumCacheHitWithoutHash = 0,
  70951. e.NumCacheHitWithHash = 0,
  70952. e.NumCacheMiss = 0,
  70953. e.NumPipelineCreationLastFrame = 0,
  70954. e._NumPipelineCreationCurrentFrame = 0,
  70955. e
  70956. }()
  70957. , xh = function() {
  70958. function e() {
  70959. this.values = {}
  70960. }
  70961. return e.prototype.count = function() {
  70962. var e = 0
  70963. , t = this.pipeline ? 1 : 0;
  70964. for (var i in this.values) {
  70965. var n = this.values[i].count();
  70966. e += n[0],
  70967. t += n[1],
  70968. e++
  70969. }
  70970. return [e, t]
  70971. }
  70972. ,
  70973. e
  70974. }()
  70975. , Rh = function(e) {
  70976. function t(i, n, r) {
  70977. var o = e.call(this, i, n, r) || this;
  70978. return o._nodeStack = [],
  70979. o._nodeStack[0] = t._Cache,
  70980. o
  70981. }
  70982. return U(t, e),
  70983. t.GetNodeCounts = function() {
  70984. var e = t._Cache.count();
  70985. return {
  70986. nodeCount: e[0],
  70987. pipelineCount: e[1]
  70988. }
  70989. }
  70990. ,
  70991. t._GetPipelines = function(e, i, n, r) {
  70992. if (e.pipeline) {
  70993. var o = n.slice();
  70994. o.length = r,
  70995. i.push(o)
  70996. }
  70997. for (var a in e.values) {
  70998. var s = e.values[a];
  70999. n[r] = parseInt(a),
  71000. t._GetPipelines(s, i, n, r + 1)
  71001. }
  71002. }
  71003. ,
  71004. t.GetPipelines = function() {
  71005. var e = [];
  71006. return t._GetPipelines(t._Cache, e, [], 0),
  71007. e
  71008. }
  71009. ,
  71010. t.prototype._getRenderPipeline = function(e) {
  71011. for (var t = this._nodeStack[this._stateDirtyLowestIndex], i = this._stateDirtyLowestIndex; i < this._statesLength; ++i) {
  71012. var n = t.values[this._states[i]];
  71013. n || (n = new xh,
  71014. t.values[this._states[i]] = n),
  71015. t = n,
  71016. this._nodeStack[i + 1] = t
  71017. }
  71018. e.token = t,
  71019. e.pipeline = t.pipeline
  71020. }
  71021. ,
  71022. t.prototype._setRenderPipeline = function(e) {
  71023. e.token.pipeline = e.pipeline
  71024. }
  71025. ,
  71026. t._Cache = new xh,
  71027. t
  71028. }(Ah)
  71029. , Ch = function(e) {
  71030. function t(t) {
  71031. var i = e.call(this, !1) || this;
  71032. return i._cache = t,
  71033. i.reset(),
  71034. i
  71035. }
  71036. return U(t, e),
  71037. Object.defineProperty(t.prototype, "func", {
  71038. get: function() {
  71039. return this._func
  71040. },
  71041. set: function(e) {
  71042. this._func !== e && (this._func = e,
  71043. this._cache.setStencilCompare(e))
  71044. },
  71045. enumerable: !1,
  71046. configurable: !0
  71047. }),
  71048. Object.defineProperty(t.prototype, "funcMask", {
  71049. get: function() {
  71050. return this._funcMask
  71051. },
  71052. set: function(e) {
  71053. this._funcMask !== e && (this._funcMask = e,
  71054. this._cache.setStencilReadMask(e))
  71055. },
  71056. enumerable: !1,
  71057. configurable: !0
  71058. }),
  71059. Object.defineProperty(t.prototype, "opStencilFail", {
  71060. get: function() {
  71061. return this._opStencilFail
  71062. },
  71063. set: function(e) {
  71064. this._opStencilFail !== e && (this._opStencilFail = e,
  71065. this._cache.setStencilFailOp(e))
  71066. },
  71067. enumerable: !1,
  71068. configurable: !0
  71069. }),
  71070. Object.defineProperty(t.prototype, "opDepthFail", {
  71071. get: function() {
  71072. return this._opDepthFail
  71073. },
  71074. set: function(e) {
  71075. this._opDepthFail !== e && (this._opDepthFail = e,
  71076. this._cache.setStencilDepthFailOp(e))
  71077. },
  71078. enumerable: !1,
  71079. configurable: !0
  71080. }),
  71081. Object.defineProperty(t.prototype, "opStencilDepthPass", {
  71082. get: function() {
  71083. return this._opStencilDepthPass
  71084. },
  71085. set: function(e) {
  71086. this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
  71087. this._cache.setStencilPassOp(e))
  71088. },
  71089. enumerable: !1,
  71090. configurable: !0
  71091. }),
  71092. Object.defineProperty(t.prototype, "mask", {
  71093. get: function() {
  71094. return this._mask
  71095. },
  71096. set: function(e) {
  71097. this._mask !== e && (this._mask = e,
  71098. this._cache.setStencilWriteMask(e))
  71099. },
  71100. enumerable: !1,
  71101. configurable: !0
  71102. }),
  71103. Object.defineProperty(t.prototype, "enabled", {
  71104. get: function() {
  71105. return this._enabled
  71106. },
  71107. set: function(e) {
  71108. this._enabled !== e && (this._enabled = e,
  71109. this._cache.setStencilEnabled(e))
  71110. },
  71111. enumerable: !1,
  71112. configurable: !0
  71113. }),
  71114. t.prototype.reset = function() {
  71115. e.prototype.reset.call(this),
  71116. this._cache.resetStencilState()
  71117. }
  71118. ,
  71119. t.prototype.apply = function() {
  71120. var e, t = null === (e = this.stencilMaterial) || void 0 === e ? void 0 : e.enabled;
  71121. this.enabled = t ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
  71122. this.enabled && (this.func = t ? this.stencilMaterial.func : this.stencilGlobal.func,
  71123. this.funcRef = t ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
  71124. this.funcMask = t ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
  71125. this.opStencilFail = t ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
  71126. this.opDepthFail = t ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
  71127. this.opStencilDepthPass = t ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
  71128. this.mask = t ? this.stencilMaterial.mask : this.stencilGlobal.mask)
  71129. }
  71130. ,
  71131. t
  71132. }(zt)
  71133. , Ph = function(e) {
  71134. function t(t) {
  71135. var i = e.call(this, !1) || this;
  71136. return i._cache = t,
  71137. i.reset(),
  71138. i
  71139. }
  71140. return U(t, e),
  71141. Object.defineProperty(t.prototype, "zOffset", {
  71142. get: function() {
  71143. return this._zOffset
  71144. },
  71145. set: function(e) {
  71146. this._zOffset !== e && (this._zOffset = e,
  71147. this._isZOffsetDirty = !0,
  71148. this._cache.setDepthBiasSlopeScale(e))
  71149. },
  71150. enumerable: !1,
  71151. configurable: !0
  71152. }),
  71153. Object.defineProperty(t.prototype, "zOffsetUnits", {
  71154. get: function() {
  71155. return this._zOffsetUnits
  71156. },
  71157. set: function(e) {
  71158. this._zOffsetUnits !== e && (this._zOffsetUnits = e,
  71159. this._isZOffsetDirty = !0,
  71160. this._cache.setDepthBias(e))
  71161. },
  71162. enumerable: !1,
  71163. configurable: !0
  71164. }),
  71165. Object.defineProperty(t.prototype, "cullFace", {
  71166. get: function() {
  71167. return this._cullFace
  71168. },
  71169. set: function(e) {
  71170. this._cullFace !== e && (this._cullFace = e,
  71171. this._isCullFaceDirty = !0,
  71172. this._cache.setCullFace(null != e ? e : 1))
  71173. },
  71174. enumerable: !1,
  71175. configurable: !0
  71176. }),
  71177. Object.defineProperty(t.prototype, "cull", {
  71178. get: function() {
  71179. return this._cull
  71180. },
  71181. set: function(e) {
  71182. this._cull !== e && (this._cull = e,
  71183. this._isCullDirty = !0,
  71184. this._cache.setCullEnabled(!!e))
  71185. },
  71186. enumerable: !1,
  71187. configurable: !0
  71188. }),
  71189. Object.defineProperty(t.prototype, "depthFunc", {
  71190. get: function() {
  71191. return this._depthFunc
  71192. },
  71193. set: function(e) {
  71194. this._depthFunc !== e && (this._depthFunc = e,
  71195. this._isDepthFuncDirty = !0,
  71196. this._cache.setDepthCompare(e))
  71197. },
  71198. enumerable: !1,
  71199. configurable: !0
  71200. }),
  71201. Object.defineProperty(t.prototype, "depthMask", {
  71202. get: function() {
  71203. return this._depthMask
  71204. },
  71205. set: function(e) {
  71206. this._depthMask !== e && (this._depthMask = e,
  71207. this._isDepthMaskDirty = !0,
  71208. this._cache.setDepthWriteEnabled(e))
  71209. },
  71210. enumerable: !1,
  71211. configurable: !0
  71212. }),
  71213. Object.defineProperty(t.prototype, "depthTest", {
  71214. get: function() {
  71215. return this._depthTest
  71216. },
  71217. set: function(e) {
  71218. this._depthTest !== e && (this._depthTest = e,
  71219. this._isDepthTestDirty = !0,
  71220. this._cache.setDepthTestEnabled(e))
  71221. },
  71222. enumerable: !1,
  71223. configurable: !0
  71224. }),
  71225. Object.defineProperty(t.prototype, "frontFace", {
  71226. get: function() {
  71227. return this._frontFace
  71228. },
  71229. set: function(e) {
  71230. this._frontFace !== e && (this._frontFace = e,
  71231. this._isFrontFaceDirty = !0,
  71232. this._cache.setFrontFace(null != e ? e : 2))
  71233. },
  71234. enumerable: !1,
  71235. configurable: !0
  71236. }),
  71237. t.prototype.reset = function() {
  71238. e.prototype.reset.call(this),
  71239. this._cache.resetDepthCullingState()
  71240. }
  71241. ,
  71242. t.prototype.apply = function() {}
  71243. ,
  71244. t
  71245. }(It)
  71246. , Mh = function() {
  71247. function e(e) {
  71248. this.useMipMaps = !1,
  71249. this.type = a.TEXTURETYPE_UNDEFINED,
  71250. this._video = e,
  71251. this.uniqueId = Lt._Counter++
  71252. }
  71253. return e.IsExternalTexture = function(e) {
  71254. return void 0 !== e.underlyingResource
  71255. }
  71256. ,
  71257. e.prototype.getClassName = function() {
  71258. return "ExternalTexture"
  71259. }
  71260. ,
  71261. Object.defineProperty(e.prototype, "underlyingResource", {
  71262. get: function() {
  71263. return this._video
  71264. },
  71265. enumerable: !1,
  71266. configurable: !0
  71267. }),
  71268. e.prototype.isReady = function() {
  71269. return this._video.readyState >= this._video.HAVE_CURRENT_DATA
  71270. }
  71271. ,
  71272. e.prototype.dispose = function() {}
  71273. ,
  71274. e
  71275. }()
  71276. , Ih = function() {
  71277. function e() {
  71278. this.uniqueId = e._Counter++,
  71279. this.updateId = 0,
  71280. this.reset()
  71281. }
  71282. return Object.defineProperty(e.prototype, "forceBindGroupCreation", {
  71283. get: function() {
  71284. return this._numExternalTextures > 0
  71285. },
  71286. enumerable: !1,
  71287. configurable: !0
  71288. }),
  71289. Object.defineProperty(e.prototype, "hasFloatTextures", {
  71290. get: function() {
  71291. return this._numFloatTextures > 0
  71292. },
  71293. enumerable: !1,
  71294. configurable: !0
  71295. }),
  71296. e.prototype.reset = function() {
  71297. this.samplers = {},
  71298. this.textures = {},
  71299. this.isDirty = !0,
  71300. this._numFloatTextures = 0,
  71301. this._numExternalTextures = 0
  71302. }
  71303. ,
  71304. e.prototype.setSampler = function(e, t) {
  71305. var i = this.samplers[e]
  71306. , n = -1;
  71307. i ? n = i.hashCode : this.samplers[e] = i = {
  71308. sampler: t,
  71309. hashCode: 0
  71310. },
  71311. i.sampler = t,
  71312. i.hashCode = t ? Th.GetSamplerHashCode(t) : 0;
  71313. var r = n !== i.hashCode;
  71314. r && this.updateId++,
  71315. this.isDirty || (this.isDirty = r)
  71316. }
  71317. ,
  71318. e.prototype.setTexture = function(e, t) {
  71319. var i, n, r, o = this.textures[e], s = -1;
  71320. o ? s = null !== (n = null === (i = o.texture) || void 0 === i ? void 0 : i.uniqueId) && void 0 !== n ? n : -1 : this.textures[e] = o = {
  71321. texture: t,
  71322. isFloatTexture: !1,
  71323. isExternalTexture: !1
  71324. },
  71325. o.isExternalTexture && this._numExternalTextures--,
  71326. o.isFloatTexture && this._numFloatTextures--,
  71327. t ? (o.isFloatTexture = t.type === a.TEXTURETYPE_FLOAT,
  71328. o.isExternalTexture = Mh.IsExternalTexture(t),
  71329. o.isFloatTexture && this._numFloatTextures++,
  71330. o.isExternalTexture && this._numExternalTextures++) : (o.isFloatTexture = !1,
  71331. o.isExternalTexture = !1),
  71332. o.texture = t;
  71333. var l = s !== (null !== (r = null == t ? void 0 : t.uniqueId) && void 0 !== r ? r : -1);
  71334. l && this.updateId++,
  71335. this.isDirty || (this.isDirty = l)
  71336. }
  71337. ,
  71338. e._Counter = 0,
  71339. e
  71340. }()
  71341. , Oh = function() {
  71342. function e(t) {
  71343. this._bufferManager = t,
  71344. this.uniqueId = e._Counter++,
  71345. this._useInstancing = !1,
  71346. this._currentInstanceCount = 0,
  71347. this.reset()
  71348. }
  71349. return e.prototype.isDirty = function(e) {
  71350. return this._isDirty || this._materialContextUpdateId !== e
  71351. }
  71352. ,
  71353. e.prototype.resetIsDirty = function(e) {
  71354. this._isDirty = !1,
  71355. this._materialContextUpdateId = e
  71356. }
  71357. ,
  71358. Object.defineProperty(e.prototype, "useInstancing", {
  71359. get: function() {
  71360. return this._useInstancing
  71361. },
  71362. set: function(e) {
  71363. this._useInstancing !== e && (e ? (this.indirectDrawBuffer = this._bufferManager.createRawBuffer(40, fu.CopyDst | fu.Indirect),
  71364. this._indirectDrawData = new Uint32Array(5),
  71365. this._indirectDrawData[3] = 0,
  71366. this._indirectDrawData[4] = 0) : (this.indirectDrawBuffer && this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
  71367. this.indirectDrawBuffer = void 0,
  71368. this._indirectDrawData = void 0),
  71369. this._useInstancing = e,
  71370. this._currentInstanceCount = -1)
  71371. },
  71372. enumerable: !1,
  71373. configurable: !0
  71374. }),
  71375. e.prototype.reset = function() {
  71376. this.buffers = {},
  71377. this._isDirty = !0,
  71378. this._materialContextUpdateId = 0,
  71379. this.fastBundle = void 0,
  71380. this.bindGroups = void 0
  71381. }
  71382. ,
  71383. e.prototype.setBuffer = function(e, t) {
  71384. var i;
  71385. this._isDirty || (this._isDirty = (null == t ? void 0 : t.uniqueId) !== (null === (i = this.buffers[e]) || void 0 === i ? void 0 : i.uniqueId)),
  71386. this.buffers[e] = t
  71387. }
  71388. ,
  71389. e.prototype.setIndirectData = function(e, t, i) {
  71390. t !== this._currentInstanceCount && this.indirectDrawBuffer && this._indirectDrawData && (this._currentInstanceCount = t,
  71391. this._indirectDrawData[0] = e,
  71392. this._indirectDrawData[1] = t,
  71393. this._indirectDrawData[2] = i,
  71394. this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20))
  71395. }
  71396. ,
  71397. e.prototype.dispose = function() {
  71398. this.indirectDrawBuffer && (this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
  71399. this.indirectDrawBuffer = void 0,
  71400. this._indirectDrawData = void 0),
  71401. this.fastBundle = void 0,
  71402. this.bindGroups = void 0,
  71403. this.buffers = void 0
  71404. }
  71405. ,
  71406. e._Counter = 0,
  71407. e
  71408. }()
  71409. , Dh = function() {
  71410. this.values = {}
  71411. }
  71412. , Nh = function() {
  71413. function e(e, t, i) {
  71414. this.disabled = !1,
  71415. this._device = e,
  71416. this._cacheSampler = t,
  71417. this._engine = i
  71418. }
  71419. return Object.defineProperty(e, "Statistics", {
  71420. get: function() {
  71421. return {
  71422. totalCreated: e.NumBindGroupsCreatedTotal,
  71423. lastFrameCreated: e.NumBindGroupsCreatedLastFrame,
  71424. lookupLastFrame: e.NumBindGroupsLookupLastFrame,
  71425. noLookupLastFrame: e.NumBindGroupsNoLookupLastFrame
  71426. }
  71427. },
  71428. enumerable: !1,
  71429. configurable: !0
  71430. }),
  71431. e.prototype.endFrame = function() {
  71432. e.NumBindGroupsCreatedLastFrame = e._NumBindGroupsCreatedCurrentFrame,
  71433. e.NumBindGroupsLookupLastFrame = e._NumBindGroupsLookupCurrentFrame,
  71434. e.NumBindGroupsNoLookupLastFrame = e._NumBindGroupsNoLookupCurrentFrame,
  71435. e._NumBindGroupsCreatedCurrentFrame = 0,
  71436. e._NumBindGroupsLookupCurrentFrame = 0,
  71437. e._NumBindGroupsNoLookupCurrentFrame = 0
  71438. }
  71439. ,
  71440. e.prototype.getBindGroups = function(t, i, n) {
  71441. var r, o, a, s, l, c, u, h, d, p, f = void 0, _ = e._Cache, m = this.disabled || n.forceBindGroupCreation;
  71442. if (!m) {
  71443. if (!i.isDirty(n.updateId) && !n.isDirty)
  71444. return e._NumBindGroupsNoLookupCurrentFrame++,
  71445. i.bindGroups;
  71446. for (var g = 0, v = t.shaderProcessingContext.bufferNames; g < v.length; g++) {
  71447. var y = v[g]
  71448. , b = null !== (o = null === (r = i.buffers[y]) || void 0 === r ? void 0 : r.uniqueId) && void 0 !== o ? o : 0;
  71449. (C = _.values[b]) || (C = new Dh,
  71450. _.values[b] = C),
  71451. _ = C
  71452. }
  71453. for (var T = 0, E = t.shaderProcessingContext.samplerNames; T < E.length; T++) {
  71454. var S = E[T]
  71455. , A = null !== (s = null === (a = n.samplers[S]) || void 0 === a ? void 0 : a.hashCode) && void 0 !== s ? s : 0;
  71456. (C = _.values[A]) || (C = new Dh,
  71457. _.values[A] = C),
  71458. _ = C
  71459. }
  71460. for (var x = 0, R = t.shaderProcessingContext.textureNames; x < R.length; x++) {
  71461. var C, P = R[x], M = null !== (u = null === (c = null === (l = n.textures[P]) || void 0 === l ? void 0 : l.texture) || void 0 === c ? void 0 : c.uniqueId) && void 0 !== u ? u : 0;
  71462. (C = _.values[M]) || (C = new Dh,
  71463. _.values[M] = C),
  71464. _ = C
  71465. }
  71466. f = _.bindGroups
  71467. }
  71468. if (i.resetIsDirty(n.updateId),
  71469. n.isDirty = !1,
  71470. f)
  71471. return i.bindGroups = f,
  71472. e._NumBindGroupsLookupCurrentFrame++,
  71473. f;
  71474. f = [],
  71475. i.bindGroups = f,
  71476. m || (_.bindGroups = f),
  71477. e.NumBindGroupsCreatedTotal++,
  71478. e._NumBindGroupsCreatedCurrentFrame++;
  71479. for (var I = t.bindGroupLayouts, O = 0; O < t.shaderProcessingContext.bindGroupLayoutEntries.length; O++) {
  71480. for (var D = t.shaderProcessingContext.bindGroupLayoutEntries[O], N = t.shaderProcessingContext.bindGroupEntries[O], L = 0; L < D.length; L++) {
  71481. var F = t.shaderProcessingContext.bindGroupLayoutEntries[O][L]
  71482. , w = t.shaderProcessingContext.bindGroupLayoutEntryInfo[O][F.binding]
  71483. , B = null !== (h = w.nameInArrayOfTexture) && void 0 !== h ? h : w.name;
  71484. if (F.sampler)
  71485. if (k = n.samplers[B]) {
  71486. var U = k.sampler;
  71487. if (!U) {
  71488. this._engine.dbgSanityChecks && K.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
  71489. return "texture" === e ? "<no dump>" : t
  71490. }
  71491. )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
  71492. continue
  71493. }
  71494. N[L].resource = this._cacheSampler.getSampler(U, !1, k.hashCode)
  71495. } else
  71496. K.Error('Sampler "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
  71497. return "texture" === e || "sampler" === e ? "<no dump>" : t
  71498. }
  71499. ))), 50);
  71500. else if (F.texture || F.storageTexture)
  71501. if (k = n.textures[B]) {
  71502. if (this._engine.dbgSanityChecks && null === k.texture) {
  71503. K.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(F), ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
  71504. return "texture" === e ? "<no dump>" : t
  71505. }
  71506. )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
  71507. continue
  71508. }
  71509. var V = k.texture._hardwareTexture;
  71510. if (this._engine.dbgSanityChecks && (!V || F.texture && !V.view || F.storageTexture && !V.viewForWriting)) {
  71511. K.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
  71512. return "texture" === e ? "<no dump>" : t
  71513. }
  71514. )), ", isReady=").concat(null === (d = k.texture) || void 0 === d ? void 0 : d.isReady, ", materialContext.uniqueId=").concat(n.uniqueId), 50);
  71515. continue
  71516. }
  71517. N[L].resource = F.storageTexture ? V.viewForWriting : V.view
  71518. } else
  71519. K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
  71520. return "texture" === e || "sampler" === e ? "<no dump>" : t
  71521. }
  71522. ))), 50);
  71523. else if (F.externalTexture) {
  71524. var k;
  71525. if (k = n.textures[B]) {
  71526. if (this._engine.dbgSanityChecks && null === k.texture) {
  71527. K.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
  71528. return "texture" === e ? "<no dump>" : t
  71529. }
  71530. )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
  71531. continue
  71532. }
  71533. var G = k.texture.underlyingResource;
  71534. if (this._engine.dbgSanityChecks && !G) {
  71535. K.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
  71536. return "texture" === e ? "<no dump>" : t
  71537. }
  71538. )), ", isReady=").concat(null === (p = k.texture) || void 0 === p ? void 0 : p.isReady, ", materialContext.uniqueId=").concat(n.uniqueId), 50);
  71539. continue
  71540. }
  71541. N[L].resource = this._device.importExternalTexture({
  71542. source: G
  71543. })
  71544. } else
  71545. K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
  71546. return "texture" === e || "sampler" === e ? "<no dump>" : t
  71547. }
  71548. ))), 50)
  71549. } else if (F.buffer) {
  71550. var z = i.buffers[B];
  71551. if (z) {
  71552. var W = z.underlyingResource;
  71553. N[L].resource.buffer = W,
  71554. N[L].resource.size = z.capacity
  71555. } else
  71556. K.Error("Can't find buffer \"".concat(B, '". entry=').concat(JSON.stringify(F), ", buffers=").concat(JSON.stringify(i.buffers), ", drawContext.uniqueId=").concat(i.uniqueId), 50)
  71557. }
  71558. }
  71559. var H = I[O];
  71560. f[O] = this._device.createBindGroup({
  71561. layout: H,
  71562. entries: N
  71563. })
  71564. }
  71565. return f
  71566. }
  71567. ,
  71568. e.NumBindGroupsCreatedTotal = 0,
  71569. e.NumBindGroupsCreatedLastFrame = 0,
  71570. e.NumBindGroupsLookupLastFrame = 0,
  71571. e.NumBindGroupsNoLookupLastFrame = 0,
  71572. e._Cache = new Dh,
  71573. e._NumBindGroupsCreatedCurrentFrame = 0,
  71574. e._NumBindGroupsLookupCurrentFrame = 0,
  71575. e._NumBindGroupsNoLookupCurrentFrame = 0,
  71576. e
  71577. }();
  71578. Pt.ShadersStore.clearQuadVertexShader = "uniform float depthValue;\nconst vec2 pos[4]={\nvec2(-1.0,1.0),\nvec2(1.0,1.0),\nvec2(-1.0,-1.0),\nvec2(1.0,-1.0)\n};\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=vec4(pos[gl_VertexID],depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  71579. Pt.ShadersStore.clearQuadPixelShader = "uniform vec4 color;\nvoid main() {\ngl_FragColor=color;\n}\n";
  71580. var Lh = function() {
  71581. function e(e, t, i) {
  71582. this._bindGroups = {},
  71583. this._bundleCache = {},
  71584. this._keyTemp = [],
  71585. this._device = e,
  71586. this._engine = t,
  71587. this._cacheRenderPipeline = new Rh(this._device,i,!t._caps.textureFloatLinearFiltering),
  71588. this._cacheRenderPipeline.setDepthTestEnabled(!1),
  71589. this._cacheRenderPipeline.setStencilReadMask(255),
  71590. this._effect = t.createEffect("clearQuad", [], ["color", "depthValue"])
  71591. }
  71592. return e.prototype.setDepthStencilFormat = function(e) {
  71593. this._depthTextureFormat = e,
  71594. this._cacheRenderPipeline.setDepthStencilFormat(e)
  71595. }
  71596. ,
  71597. e.prototype.setColorFormat = function(e) {
  71598. this._cacheRenderPipeline.setColorFormat(e)
  71599. }
  71600. ,
  71601. e.prototype.setMRTAttachments = function(e, t, i) {
  71602. this._cacheRenderPipeline.setMRT(t, i),
  71603. this._cacheRenderPipeline.setMRTAttachments(e)
  71604. }
  71605. ,
  71606. e.prototype.clear = function(e, t, i, n, r) {
  71607. var o, s;
  71608. void 0 === r && (r = 1);
  71609. var l, c = null, u = !!this._engine._currentRenderTarget;
  71610. if (e)
  71611. s = e;
  71612. else {
  71613. var h = 0;
  71614. this._keyTemp.length = 0;
  71615. for (var d = 0; d < this._cacheRenderPipeline.colorFormats.length; ++d)
  71616. this._keyTemp[h++] = ph[this._cacheRenderPipeline.colorFormats[d]];
  71617. var p = ph[null !== (o = this._depthTextureFormat) && void 0 !== o ? o : 0];
  71618. if (this._keyTemp[h] = (t ? t.r + 256 * t.g + 256 * t.b * 256 + 256 * t.a * 256 * 256 : 0) + (i ? Math.pow(2, 32) : 0) + (n ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + (u ? Math.pow(2, 35) : 0) + (r > 1 ? Math.pow(2, 36) : 0) + p * Math.pow(2, 37),
  71619. l = this._keyTemp.join("_"),
  71620. c = this._bundleCache[l])
  71621. return c;
  71622. s = this._device.createRenderBundleEncoder({
  71623. colorFormats: this._cacheRenderPipeline.colorFormats,
  71624. depthStencilFormat: this._depthTextureFormat,
  71625. sampleCount: r
  71626. })
  71627. }
  71628. this._cacheRenderPipeline.setDepthWriteEnabled(!!i),
  71629. this._cacheRenderPipeline.setStencilEnabled(!!n && !!this._depthTextureFormat && fh.HasStencilAspect(this._depthTextureFormat)),
  71630. this._cacheRenderPipeline.setStencilWriteMask(n ? 255 : 0),
  71631. this._cacheRenderPipeline.setStencilCompare(n ? a.ALWAYS : a.NEVER),
  71632. this._cacheRenderPipeline.setStencilPassOp(n ? a.REPLACE : a.KEEP),
  71633. this._cacheRenderPipeline.setWriteMask(t ? 15 : 0);
  71634. var f = this._cacheRenderPipeline.getRenderPipeline(a.MATERIAL_TriangleStripDrawMode, this._effect, r)
  71635. , _ = this._effect._pipelineContext;
  71636. t && this._effect.setDirectColor4("color", t),
  71637. this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue),
  71638. _.uniformBuffer.update();
  71639. var m = u ? this._engine._ubInvertY : this._engine._ubDontInvertY
  71640. , g = _.uniformBuffer.getBuffer()
  71641. , v = g.uniqueId + "-" + m.uniqueId
  71642. , y = this._bindGroups[v];
  71643. if (!y) {
  71644. var b = _.bindGroupLayouts;
  71645. (y = this._bindGroups[v] = []).push(this._device.createBindGroup({
  71646. layout: b[0],
  71647. entries: []
  71648. })),
  71649. Ju._SimplifiedKnownBindings || y.push(this._device.createBindGroup({
  71650. layout: b[1],
  71651. entries: []
  71652. })),
  71653. y.push(this._device.createBindGroup({
  71654. layout: b[Ju._SimplifiedKnownBindings ? 1 : 2],
  71655. entries: [{
  71656. binding: 0,
  71657. resource: {
  71658. buffer: m.underlyingResource,
  71659. size: m.capacity
  71660. }
  71661. }, {
  71662. binding: 1,
  71663. resource: {
  71664. buffer: g.underlyingResource,
  71665. size: g.capacity
  71666. }
  71667. }]
  71668. }))
  71669. }
  71670. for (s.setPipeline(f),
  71671. d = 0; d < y.length; ++d)
  71672. s.setBindGroup(d, y[d]);
  71673. return s.draw(4, 1, 0, 0),
  71674. e || (c = s.finish(),
  71675. this._bundleCache[l] = c),
  71676. c
  71677. }
  71678. ,
  71679. e
  71680. }()
  71681. , Fh = function() {
  71682. function e(e, t, i, n) {
  71683. this.x = Math.floor(e),
  71684. this.y = Math.floor(t),
  71685. this.w = Math.floor(i),
  71686. this.h = Math.floor(n)
  71687. }
  71688. return e.prototype.run = function(e) {
  71689. e.setViewport(this.x, this.y, this.w, this.h, 0, 1)
  71690. }
  71691. ,
  71692. e.prototype.clone = function() {
  71693. return new e(this.x,this.y,this.w,this.h)
  71694. }
  71695. ,
  71696. e
  71697. }()
  71698. , wh = function() {
  71699. function e(e, t, i, n) {
  71700. this.x = e,
  71701. this.y = t,
  71702. this.w = i,
  71703. this.h = n
  71704. }
  71705. return e.prototype.run = function(e) {
  71706. e.setScissorRect(this.x, this.y, this.w, this.h)
  71707. }
  71708. ,
  71709. e.prototype.clone = function() {
  71710. return new e(this.x,this.y,this.w,this.h)
  71711. }
  71712. ,
  71713. e
  71714. }()
  71715. , Bh = function() {
  71716. function e(e) {
  71717. this.ref = e
  71718. }
  71719. return e.prototype.run = function(e) {
  71720. e.setStencilReference(this.ref)
  71721. }
  71722. ,
  71723. e.prototype.clone = function() {
  71724. return new e(this.ref)
  71725. }
  71726. ,
  71727. e
  71728. }()
  71729. , Uh = function() {
  71730. function e(e) {
  71731. this.color = e
  71732. }
  71733. return e.prototype.run = function(e) {
  71734. e.setBlendConstant(this.color)
  71735. }
  71736. ,
  71737. e.prototype.clone = function() {
  71738. return new e(this.color)
  71739. }
  71740. ,
  71741. e
  71742. }()
  71743. , Vh = function() {
  71744. function e(e) {
  71745. this.query = e
  71746. }
  71747. return e.prototype.run = function(e) {
  71748. e.beginOcclusionQuery(this.query)
  71749. }
  71750. ,
  71751. e.prototype.clone = function() {
  71752. return new e(this.query)
  71753. }
  71754. ,
  71755. e
  71756. }()
  71757. , kh = function() {
  71758. function e() {}
  71759. return e.prototype.run = function(e) {
  71760. e.endOcclusionQuery()
  71761. }
  71762. ,
  71763. e.prototype.clone = function() {
  71764. return new e
  71765. }
  71766. ,
  71767. e
  71768. }()
  71769. , Gh = function() {
  71770. function e() {
  71771. this.bundles = []
  71772. }
  71773. return e.prototype.run = function(e) {
  71774. e.executeBundles(this.bundles)
  71775. }
  71776. ,
  71777. e.prototype.clone = function() {
  71778. var t = new e;
  71779. return t.bundles = this.bundles,
  71780. t
  71781. }
  71782. ,
  71783. e
  71784. }()
  71785. , zh = function() {
  71786. function e(e) {
  71787. this.numDrawCalls = 0,
  71788. this._device = e,
  71789. this._list = new Array(10),
  71790. this._listLength = 0
  71791. }
  71792. return e.prototype.addBundle = function(e) {
  71793. if (!this._currentItemIsBundle) {
  71794. var t = new Gh;
  71795. this._list[this._listLength++] = t,
  71796. this._currentBundleList = t.bundles,
  71797. this._currentItemIsBundle = !0
  71798. }
  71799. e && this._currentBundleList.push(e)
  71800. }
  71801. ,
  71802. e.prototype._finishBundle = function() {
  71803. this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()),
  71804. this._bundleEncoder = void 0,
  71805. this._currentItemIsBundle = !1)
  71806. }
  71807. ,
  71808. e.prototype.addItem = function(e) {
  71809. this._finishBundle(),
  71810. this._list[this._listLength++] = e,
  71811. this._currentItemIsBundle = !1
  71812. }
  71813. ,
  71814. e.prototype.getBundleEncoder = function(e, t, i) {
  71815. return this._currentItemIsBundle || (this.addBundle(),
  71816. this._bundleEncoder = this._device.createRenderBundleEncoder({
  71817. colorFormats: e,
  71818. depthStencilFormat: t,
  71819. sampleCount: i
  71820. })),
  71821. this._bundleEncoder
  71822. }
  71823. ,
  71824. e.prototype.close = function() {
  71825. this._finishBundle()
  71826. }
  71827. ,
  71828. e.prototype.run = function(e) {
  71829. this.close();
  71830. for (var t = 0; t < this._listLength; ++t)
  71831. this._list[t].run(e)
  71832. }
  71833. ,
  71834. e.prototype.reset = function() {
  71835. this._listLength = 0,
  71836. this._currentItemIsBundle = !1,
  71837. this.numDrawCalls = 0
  71838. }
  71839. ,
  71840. e.prototype.clone = function() {
  71841. this.close();
  71842. var t = new e(this._device);
  71843. t._list = new Array(this._listLength),
  71844. t._listLength = this._listLength,
  71845. t.numDrawCalls = this.numDrawCalls;
  71846. for (var i = 0; i < this._listLength; ++i)
  71847. t._list[i] = this._list[i].clone();
  71848. return t
  71849. }
  71850. ,
  71851. e
  71852. }()
  71853. , Wh = function() {
  71854. function e(e, t, i, n, r) {
  71855. void 0 === r && (r = !0),
  71856. this._dstBuffers = [],
  71857. this._device = i,
  71858. this._bufferManager = n,
  71859. this._count = e,
  71860. this._canUseMultipleBuffers = r,
  71861. this._querySet = i.createQuerySet({
  71862. type: t,
  71863. count: e
  71864. }),
  71865. this._queryBuffer = n.createRawBuffer(8 * e, fu.QueryResolve | fu.CopySrc),
  71866. r || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.CopyDst))
  71867. }
  71868. return Object.defineProperty(e.prototype, "querySet", {
  71869. get: function() {
  71870. return this._querySet
  71871. },
  71872. enumerable: !1,
  71873. configurable: !0
  71874. }),
  71875. e.prototype._getBuffer = function(e, t) {
  71876. if (!this._canUseMultipleBuffers && 0 === this._dstBuffers.length)
  71877. return null;
  71878. var i, n = this._device.createCommandEncoder();
  71879. return 0 === this._dstBuffers.length ? i = this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.CopyDst) : (i = this._dstBuffers[this._dstBuffers.length - 1],
  71880. this._dstBuffers.length--),
  71881. n.resolveQuerySet(this._querySet, e, t, this._queryBuffer, 0),
  71882. n.copyBufferToBuffer(this._queryBuffer, 0, i, 0, 8 * t),
  71883. this._device.queue.submit([n.finish()]),
  71884. i
  71885. }
  71886. ,
  71887. e.prototype.readValues = function(e, t) {
  71888. return void 0 === e && (e = 0),
  71889. void 0 === t && (t = 1),
  71890. G(this, void 0, void 0, (function() {
  71891. var i, n;
  71892. return z(this, (function(r) {
  71893. switch (r.label) {
  71894. case 0:
  71895. return null === (i = this._getBuffer(e, t)) ? [2, null] : [4, i.mapAsync(_u.Read)];
  71896. case 1:
  71897. return r.sent(),
  71898. n = new BigUint64Array(i.getMappedRange()).slice(),
  71899. i.unmap(),
  71900. this._dstBuffers[this._dstBuffers.length] = i,
  71901. [2, n]
  71902. }
  71903. }
  71904. ))
  71905. }
  71906. ))
  71907. }
  71908. ,
  71909. e.prototype.readValue = function(e) {
  71910. return void 0 === e && (e = 0),
  71911. G(this, void 0, void 0, (function() {
  71912. var t, i, n;
  71913. return z(this, (function(r) {
  71914. switch (r.label) {
  71915. case 0:
  71916. return null === (t = this._getBuffer(e, 1)) ? [2, null] : [4, t.mapAsync(_u.Read)];
  71917. case 1:
  71918. return r.sent(),
  71919. i = new BigUint64Array(t.getMappedRange()),
  71920. n = Number(i[0]),
  71921. t.unmap(),
  71922. this._dstBuffers[this._dstBuffers.length] = t,
  71923. [2, n]
  71924. }
  71925. }
  71926. ))
  71927. }
  71928. ))
  71929. }
  71930. ,
  71931. e.prototype.readTwoValuesAndSubtract = function(e) {
  71932. return void 0 === e && (e = 0),
  71933. G(this, void 0, void 0, (function() {
  71934. var t, i, n;
  71935. return z(this, (function(r) {
  71936. switch (r.label) {
  71937. case 0:
  71938. return null === (t = this._getBuffer(e, 2)) ? [2, null] : [4, t.mapAsync(_u.Read)];
  71939. case 1:
  71940. return r.sent(),
  71941. i = new BigUint64Array(t.getMappedRange()),
  71942. n = Number(i[1] - i[0]),
  71943. t.unmap(),
  71944. this._dstBuffers[this._dstBuffers.length] = t,
  71945. [2, n]
  71946. }
  71947. }
  71948. ))
  71949. }
  71950. ))
  71951. }
  71952. ,
  71953. e.prototype.dispose = function() {
  71954. this._querySet.destroy(),
  71955. this._bufferManager.releaseBuffer(this._queryBuffer);
  71956. for (var e = 0; e < this._dstBuffers.length; ++e)
  71957. this._bufferManager.releaseBuffer(this._dstBuffers[e])
  71958. }
  71959. ,
  71960. e
  71961. }()
  71962. , Hh = function() {
  71963. function e(e, t) {
  71964. this._enabled = !1,
  71965. this._gpuFrameTimeCounter = new un,
  71966. this._measureDurationState = 0,
  71967. this._device = e,
  71968. this._bufferManager = t
  71969. }
  71970. return Object.defineProperty(e.prototype, "gpuFrameTimeCounter", {
  71971. get: function() {
  71972. return this._gpuFrameTimeCounter
  71973. },
  71974. enumerable: !1,
  71975. configurable: !0
  71976. }),
  71977. Object.defineProperty(e.prototype, "enable", {
  71978. get: function() {
  71979. return this._enabled
  71980. },
  71981. set: function(e) {
  71982. this._enabled !== e && (this._enabled = e,
  71983. this._measureDurationState = 0,
  71984. e ? this._measureDuration = new Xh(this._device,this._bufferManager) : this._measureDuration.dispose())
  71985. },
  71986. enumerable: !1,
  71987. configurable: !0
  71988. }),
  71989. e.prototype.startFrame = function(e) {
  71990. this._enabled && 0 === this._measureDurationState && (this._measureDuration.start(e),
  71991. this._measureDurationState = 1)
  71992. }
  71993. ,
  71994. e.prototype.endFrame = function(e) {
  71995. var t = this;
  71996. 1 === this._measureDurationState && (this._measureDurationState = 2,
  71997. this._measureDuration.stop(e).then((function(e) {
  71998. null !== e && e >= 0 && (t._gpuFrameTimeCounter.fetchNewFrame(),
  71999. t._gpuFrameTimeCounter.addCount(e, !0)),
  72000. t._measureDurationState = 0
  72001. }
  72002. )))
  72003. }
  72004. ,
  72005. e
  72006. }()
  72007. , Xh = function() {
  72008. function e(e, t) {
  72009. this._querySet = new Wh(2,Hu.Timestamp,e,t)
  72010. }
  72011. return e.prototype.start = function(e) {
  72012. e.writeTimestamp(this._querySet.querySet, 0)
  72013. }
  72014. ,
  72015. e.prototype.stop = function(e) {
  72016. return G(this, void 0, void 0, (function() {
  72017. return z(this, (function(t) {
  72018. return e.writeTimestamp(this._querySet.querySet, 1),
  72019. [2, this._querySet.readTwoValuesAndSubtract(0)]
  72020. }
  72021. ))
  72022. }
  72023. ))
  72024. }
  72025. ,
  72026. e.prototype.dispose = function() {
  72027. this._querySet.dispose()
  72028. }
  72029. ,
  72030. e
  72031. }()
  72032. , jh = function() {
  72033. function e(e, t, i, n, r) {
  72034. void 0 === n && (n = 50),
  72035. void 0 === r && (r = 100),
  72036. this._availableIndices = [],
  72037. this._engine = e,
  72038. this._device = t,
  72039. this._bufferManager = i,
  72040. this._frameLastBuffer = -1,
  72041. this._currentTotalIndices = 0,
  72042. this._countIncrement = r,
  72043. this._allocateNewIndices(n)
  72044. }
  72045. return Object.defineProperty(e.prototype, "querySet", {
  72046. get: function() {
  72047. return this._querySet.querySet
  72048. },
  72049. enumerable: !1,
  72050. configurable: !0
  72051. }),
  72052. Object.defineProperty(e.prototype, "hasQueries", {
  72053. get: function() {
  72054. return this._currentTotalIndices !== this._availableIndices.length
  72055. },
  72056. enumerable: !1,
  72057. configurable: !0
  72058. }),
  72059. Object.defineProperty(e.prototype, "canBeginQuery", {
  72060. get: function() {
  72061. switch (this._engine._getCurrentRenderPassIndex()) {
  72062. case 0:
  72063. return void 0 !== this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet;
  72064. case 1:
  72065. return void 0 !== this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet
  72066. }
  72067. return !1
  72068. },
  72069. enumerable: !1,
  72070. configurable: !0
  72071. }),
  72072. e.prototype.createQuery = function() {
  72073. 0 === this._availableIndices.length && this._allocateNewIndices();
  72074. var e = this._availableIndices[this._availableIndices.length - 1];
  72075. return this._availableIndices.length--,
  72076. e
  72077. }
  72078. ,
  72079. e.prototype.deleteQuery = function(e) {
  72080. this._availableIndices[this._availableIndices.length - 1] = e
  72081. }
  72082. ,
  72083. e.prototype.isQueryResultAvailable = function(e) {
  72084. return this._retrieveQueryBuffer(),
  72085. !!this._lastBuffer && e < this._lastBuffer.length
  72086. }
  72087. ,
  72088. e.prototype.getQueryResult = function(e) {
  72089. var t, i;
  72090. return Number(null !== (i = null === (t = this._lastBuffer) || void 0 === t ? void 0 : t[e]) && void 0 !== i ? i : -1)
  72091. }
  72092. ,
  72093. e.prototype._retrieveQueryBuffer = function() {
  72094. var e = this;
  72095. this._lastBuffer && this._frameLastBuffer === this._engine.frameId || this._frameLastBuffer !== this._engine.frameId && (this._frameLastBuffer = this._engine.frameId,
  72096. this._querySet.readValues(0, this._currentTotalIndices).then((function(t) {
  72097. e._lastBuffer = t
  72098. }
  72099. )))
  72100. }
  72101. ,
  72102. e.prototype._allocateNewIndices = function(e) {
  72103. e = null != e ? e : this._countIncrement,
  72104. this._delayQuerySetDispose();
  72105. for (var t = 0; t < e; ++t)
  72106. this._availableIndices.push(this._currentTotalIndices + t);
  72107. this._currentTotalIndices += e,
  72108. this._querySet = new Wh(this._currentTotalIndices,Hu.Occlusion,this._device,this._bufferManager,!1)
  72109. }
  72110. ,
  72111. e.prototype._delayQuerySetDispose = function() {
  72112. var e = this._querySet;
  72113. e && setTimeout((function() {
  72114. return e.dispose
  72115. }
  72116. ), 1e3)
  72117. }
  72118. ,
  72119. e.prototype.dispose = function() {
  72120. var e;
  72121. null === (e = this._querySet) || void 0 === e || e.dispose(),
  72122. this._availableIndices = []
  72123. }
  72124. ,
  72125. e
  72126. }()
  72127. , Yh = function() {
  72128. function e() {
  72129. this._twgsl = null
  72130. }
  72131. return e.prototype.initTwgsl = function(t) {
  72132. return G(this, void 0, void 0, (function() {
  72133. var i;
  72134. return z(this, (function(n) {
  72135. switch (n.label) {
  72136. case 0:
  72137. return t = t || {},
  72138. (t = V(V({}, e._TWgslDefaultOptions), t)).twgsl ? (this._twgsl = t.twgsl,
  72139. [2, Promise.resolve()]) : t.jsPath && t.wasmPath ? nt() ? [4, gi.LoadScriptAsync(t.jsPath)] : [3, 2] : [3, 3];
  72140. case 1:
  72141. return n.sent(),
  72142. [3, 3];
  72143. case 2:
  72144. importScripts(t.jsPath),
  72145. n.label = 3;
  72146. case 3:
  72147. return self.twgsl ? (i = this,
  72148. [4, self.twgsl(t.wasmPath)]) : [3, 5];
  72149. case 4:
  72150. return i._twgsl = n.sent(),
  72151. [2, Promise.resolve()];
  72152. case 5:
  72153. return [2, Promise.reject("twgsl is not available.")]
  72154. }
  72155. }
  72156. ))
  72157. }
  72158. ))
  72159. }
  72160. ,
  72161. e.prototype.convertSpirV2WGSL = function(e) {
  72162. return this._twgsl.convertSpirV2WGSL(e)
  72163. }
  72164. ,
  72165. e._TWgslDefaultOptions = {
  72166. jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js",
  72167. wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm"
  72168. },
  72169. e
  72170. }()
  72171. , Kh = function() {
  72172. function e(e, t, i, n) {
  72173. this._record = !1,
  72174. this._play = !1,
  72175. this._mainPassBundleList = [],
  72176. this._enabled = !1,
  72177. this._engine = e,
  72178. this._mode = t,
  72179. this._bundleList = i,
  72180. this._bundleListRenderTarget = n
  72181. }
  72182. return Object.defineProperty(e.prototype, "enabled", {
  72183. get: function() {
  72184. return this._enabled
  72185. },
  72186. set: function(e) {
  72187. this._mainPassBundleList.length = 0,
  72188. this._record = this._enabled = e,
  72189. this._play = !1,
  72190. e && (this._modeSaved = this._mode,
  72191. this._mode = a.SNAPSHOTRENDERING_STANDARD)
  72192. },
  72193. enumerable: !1,
  72194. configurable: !0
  72195. }),
  72196. Object.defineProperty(e.prototype, "play", {
  72197. get: function() {
  72198. return this._play
  72199. },
  72200. enumerable: !1,
  72201. configurable: !0
  72202. }),
  72203. Object.defineProperty(e.prototype, "record", {
  72204. get: function() {
  72205. return this._record
  72206. },
  72207. enumerable: !1,
  72208. configurable: !0
  72209. }),
  72210. Object.defineProperty(e.prototype, "mode", {
  72211. get: function() {
  72212. return this._mode
  72213. },
  72214. set: function(e) {
  72215. this._record ? this._modeSaved = e : this._mode = e
  72216. },
  72217. enumerable: !1,
  72218. configurable: !0
  72219. }),
  72220. e.prototype.endMainRenderPass = function() {
  72221. this._record && this._mainPassBundleList.push(this._bundleList.clone())
  72222. }
  72223. ,
  72224. e.prototype.endRenderTargetPass = function(e, t) {
  72225. var i, n, r, o;
  72226. if (this._play)
  72227. null === (n = null === (i = t._bundleLists) || void 0 === i ? void 0 : i[t._currentLayer]) || void 0 === n || n.run(e),
  72228. this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(null === (o = null === (r = t._bundleLists) || void 0 === r ? void 0 : r[t._currentLayer]) || void 0 === o ? void 0 : o.numDrawCalls);
  72229. else {
  72230. if (!this._record)
  72231. return !1;
  72232. t._bundleLists || (t._bundleLists = []),
  72233. t._bundleLists[t._currentLayer] = this._bundleListRenderTarget.clone(),
  72234. t._bundleLists[t._currentLayer].run(e),
  72235. this._bundleListRenderTarget.reset()
  72236. }
  72237. return !0
  72238. }
  72239. ,
  72240. e.prototype.endFrame = function(e) {
  72241. if (this._record && (this._mainPassBundleList.push(this._bundleList.clone()),
  72242. this._record = !1,
  72243. this._play = !0,
  72244. this._mode = this._modeSaved),
  72245. null !== e && this._play)
  72246. for (var t = 0; t < this._mainPassBundleList.length; ++t)
  72247. this._mainPassBundleList[t].run(e),
  72248. this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(this._mainPassBundleList[t].numDrawCalls)
  72249. }
  72250. ,
  72251. e.prototype.reset = function() {
  72252. this.enabled = !1,
  72253. this.enabled = !0
  72254. }
  72255. ,
  72256. e
  72257. }()
  72258. , Qh = function(e) {
  72259. function t(t, i) {
  72260. void 0 === i && (i = {});
  72261. var n, r, o, a, s = this;
  72262. if ((s = e.call(this, null) || this)._uploadEncoderDescriptor = {
  72263. label: "upload"
  72264. },
  72265. s._renderEncoderDescriptor = {
  72266. label: "render"
  72267. },
  72268. s._renderTargetEncoderDescriptor = {
  72269. label: "renderTarget"
  72270. },
  72271. s._clearDepthValue = 1,
  72272. s._clearReverseDepthValue = 0,
  72273. s._clearStencilValue = 0,
  72274. s._defaultSampleCount = 4,
  72275. s._glslang = null,
  72276. s._tintWASM = null,
  72277. s._compiledComputeEffects = {},
  72278. s._counters = {
  72279. numEnableEffects: 0,
  72280. numEnableDrawWrapper: 0,
  72281. numBundleCreationNonCompatMode: 0,
  72282. numBundleReuseNonCompatMode: 0
  72283. },
  72284. s.countersLastFrame = {
  72285. numEnableEffects: 0,
  72286. numEnableDrawWrapper: 0,
  72287. numBundleCreationNonCompatMode: 0,
  72288. numBundleReuseNonCompatMode: 0
  72289. },
  72290. s.numMaxUncapturedErrors = 20,
  72291. s._commandBuffers = [null, null, null],
  72292. s._currentRenderPass = null,
  72293. s._mainRenderPassWrapper = new gh,
  72294. s._rttRenderPassWrapper = new gh,
  72295. s._pendingDebugCommands = [],
  72296. s._onAfterUnbindFrameBufferObservable = new h,
  72297. s._currentOverrideVertexBuffers = null,
  72298. s._currentIndexBuffer = null,
  72299. s._colorWriteLocal = !0,
  72300. s._forceEnableEffect = !1,
  72301. s.dbgShowShaderCode = !1,
  72302. s.dbgSanityChecks = !0,
  72303. s.dbgVerboseLogsForFirstFrames = !1,
  72304. s.dbgVerboseLogsNumFrames = 10,
  72305. s.dbgLogIfNotDrawWrapper = !0,
  72306. s.dbgShowEmptyEnableEffectCalls = !0,
  72307. s._viewportsCurrent = [{
  72308. x: 0,
  72309. y: 0,
  72310. w: 0,
  72311. h: 0
  72312. }, {
  72313. x: 0,
  72314. y: 0,
  72315. w: 0,
  72316. h: 0
  72317. }],
  72318. s._scissorsCurrent = [{
  72319. x: 0,
  72320. y: 0,
  72321. w: 0,
  72322. h: 0
  72323. }, {
  72324. x: 0,
  72325. y: 0,
  72326. w: 0,
  72327. h: 0
  72328. }],
  72329. s._scissorCached = {
  72330. x: 0,
  72331. y: 0,
  72332. z: 0,
  72333. w: 0
  72334. },
  72335. s._stencilRefsCurrent = [-1, -1],
  72336. s._blendColorsCurrent = [[null, null, null, null], [null, null, null, null]],
  72337. s._name = "WebGPU",
  72338. s.isNDCHalfZRange = !0,
  72339. s.hasOriginBottomLeft = !1,
  72340. i.deviceDescriptor = i.deviceDescriptor || {},
  72341. i.swapChainFormat = i.swapChainFormat || bu.BGRA8Unorm,
  72342. i.antialiasing = void 0 === i.antialiasing || i.antialiasing,
  72343. i.stencil = null === (n = i.stencil) || void 0 === n || n,
  72344. i.enableGPUDebugMarkers = null !== (r = i.enableGPUDebugMarkers) && void 0 !== r && r,
  72345. K.Log("Babylon.js v".concat(vr.Version, " - ").concat(s.description, " engine")),
  72346. !navigator.gpu)
  72347. return K.Error("WebGPU is not supported by your browser."),
  72348. s;
  72349. s._isWebGPU = !0,
  72350. s._shaderPlatformName = "WEBGPU",
  72351. void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
  72352. void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
  72353. void 0 === i.audioEngine && (i.audioEngine = !0),
  72354. s._deterministicLockstep = i.deterministicLockstep,
  72355. s._lockstepMaxSteps = i.lockstepMaxSteps,
  72356. s._timeStep = i.timeStep || 1 / 60,
  72357. s._doNotHandleContextLost = !!i.doNotHandleContextLost,
  72358. s._canvas = t,
  72359. s._options = i,
  72360. s.premultipliedAlpha = null === (o = i.premultipliedAlpha) || void 0 === o || o;
  72361. var l = nt() && window.devicePixelRatio || 1
  72362. , c = i.limitDeviceRatio || l
  72363. , u = null !== (a = i.adaptToDeviceRatio) && void 0 !== a && a;
  72364. return s._hardwareScalingLevel = u ? 1 / Math.min(c, l) : 1,
  72365. s._mainPassSampleCount = i.antialiasing ? s._defaultSampleCount : 1,
  72366. s._isStencilEnable = i.stencil,
  72367. s._sharedInit(t, !!i.doNotHandleTouchAction, i.audioEngine),
  72368. s._shaderProcessor = new $u,
  72369. s._shaderProcessorWGSL = new ch,
  72370. s
  72371. }
  72372. return U(t, e),
  72373. Object.defineProperty(t.prototype, "snapshotRenderingMode", {
  72374. get: function() {
  72375. return this._snapshotRendering.mode
  72376. },
  72377. set: function(e) {
  72378. this._snapshotRendering.mode = e
  72379. },
  72380. enumerable: !1,
  72381. configurable: !0
  72382. }),
  72383. t.prototype.snapshotRenderingReset = function() {
  72384. this._snapshotRendering.reset()
  72385. }
  72386. ,
  72387. Object.defineProperty(t.prototype, "snapshotRendering", {
  72388. get: function() {
  72389. return this._snapshotRendering.enabled
  72390. },
  72391. set: function(e) {
  72392. this._snapshotRendering.enabled = e
  72393. },
  72394. enumerable: !1,
  72395. configurable: !0
  72396. }),
  72397. Object.defineProperty(t.prototype, "disableCacheSamplers", {
  72398. get: function() {
  72399. return !!this._cacheSampler && this._cacheSampler.disabled
  72400. },
  72401. set: function(e) {
  72402. this._cacheSampler && (this._cacheSampler.disabled = e)
  72403. },
  72404. enumerable: !1,
  72405. configurable: !0
  72406. }),
  72407. Object.defineProperty(t.prototype, "disableCacheRenderPipelines", {
  72408. get: function() {
  72409. return !!this._cacheRenderPipeline && this._cacheRenderPipeline.disabled
  72410. },
  72411. set: function(e) {
  72412. this._cacheRenderPipeline && (this._cacheRenderPipeline.disabled = e)
  72413. },
  72414. enumerable: !1,
  72415. configurable: !0
  72416. }),
  72417. Object.defineProperty(t.prototype, "disableCacheBindGroups", {
  72418. get: function() {
  72419. return !!this._cacheBindGroups && this._cacheBindGroups.disabled
  72420. },
  72421. set: function(e) {
  72422. this._cacheBindGroups && (this._cacheBindGroups.disabled = e)
  72423. },
  72424. enumerable: !1,
  72425. configurable: !0
  72426. }),
  72427. Object.defineProperty(t, "IsSupportedAsync", {
  72428. get: function() {
  72429. return navigator.gpu ? navigator.gpu.requestAdapter().then((function(e) {
  72430. return !!e
  72431. }
  72432. ), (function() {
  72433. return !1
  72434. }
  72435. )).catch((function() {
  72436. return !1
  72437. }
  72438. )) : Promise.resolve(!1)
  72439. },
  72440. enumerable: !1,
  72441. configurable: !0
  72442. }),
  72443. Object.defineProperty(t, "IsSupported", {
  72444. get: function() {
  72445. return K.Warn("You must call IsSupportedAsync for WebGPU!"),
  72446. !1
  72447. },
  72448. enumerable: !1,
  72449. configurable: !0
  72450. }),
  72451. Object.defineProperty(t.prototype, "supportsUniformBuffers", {
  72452. get: function() {
  72453. return !0
  72454. },
  72455. enumerable: !1,
  72456. configurable: !0
  72457. }),
  72458. Object.defineProperty(t.prototype, "supportedExtensions", {
  72459. get: function() {
  72460. return this._adapterSupportedExtensions
  72461. },
  72462. enumerable: !1,
  72463. configurable: !0
  72464. }),
  72465. Object.defineProperty(t.prototype, "enabledExtensions", {
  72466. get: function() {
  72467. return this._deviceEnabledExtensions
  72468. },
  72469. enumerable: !1,
  72470. configurable: !0
  72471. }),
  72472. Object.defineProperty(t.prototype, "description", {
  72473. get: function() {
  72474. return this.name + this.version
  72475. },
  72476. enumerable: !1,
  72477. configurable: !0
  72478. }),
  72479. Object.defineProperty(t.prototype, "version", {
  72480. get: function() {
  72481. return 1
  72482. },
  72483. enumerable: !1,
  72484. configurable: !0
  72485. }),
  72486. t.prototype.getInfo = function() {
  72487. return {
  72488. vendor: "unknown vendor",
  72489. renderer: "unknown renderer",
  72490. version: "unknown version"
  72491. }
  72492. }
  72493. ,
  72494. Object.defineProperty(t.prototype, "compatibilityMode", {
  72495. get: function() {
  72496. return this._compatibilityMode
  72497. },
  72498. set: function(e) {
  72499. this._compatibilityMode = e
  72500. },
  72501. enumerable: !1,
  72502. configurable: !0
  72503. }),
  72504. Object.defineProperty(t.prototype, "currentSampleCount", {
  72505. get: function() {
  72506. return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount
  72507. },
  72508. enumerable: !1,
  72509. configurable: !0
  72510. }),
  72511. t.CreateAsync = function(e, i) {
  72512. void 0 === i && (i = {});
  72513. var n = new t(e,i);
  72514. return new Promise((function(e) {
  72515. n.initAsync(i.glslangOptions, i.twgslOptions).then((function() {
  72516. return e(n)
  72517. }
  72518. ))
  72519. }
  72520. ))
  72521. }
  72522. ,
  72523. t.prototype.initAsync = function(e, i) {
  72524. var n, r = this;
  72525. return this._initGlslang(null != e ? e : null === (n = this._options) || void 0 === n ? void 0 : n.glslangOptions).then((function(e) {
  72526. var n;
  72527. return r._glslang = e,
  72528. r._tintWASM = t.UseTWGSL ? new Yh : null,
  72529. r._tintWASM ? r._tintWASM.initTwgsl(null != i ? i : null === (n = r._options) || void 0 === n ? void 0 : n.twgslOptions).then((function() {
  72530. return navigator.gpu.requestAdapter(r._options)
  72531. }
  72532. ), (function(e) {
  72533. throw K.Error("Can not initialize twgsl!"),
  72534. K.Error(e),
  72535. Error("WebGPU initializations stopped.")
  72536. }
  72537. )) : navigator.gpu.requestAdapter(r._options)
  72538. }
  72539. ), (function(e) {
  72540. throw K.Error("Can not initialize glslang!"),
  72541. K.Error(e),
  72542. Error("WebGPU initializations stopped.")
  72543. }
  72544. )).then((function(e) {
  72545. var t;
  72546. if (e) {
  72547. r._adapter = e,
  72548. r._adapterSupportedExtensions = [],
  72549. null === (t = r._adapter.features) || void 0 === t || t.forEach((function(e) {
  72550. return r._adapterSupportedExtensions.push(e)
  72551. }
  72552. ));
  72553. var i = r._options.deviceDescriptor;
  72554. if (null == i ? void 0 : i.requiredFeatures) {
  72555. for (var n = [], o = 0, a = i.requiredFeatures; o < a.length; o++) {
  72556. var s = a[o];
  72557. -1 !== r._adapterSupportedExtensions.indexOf(s) && n.push(s)
  72558. }
  72559. i.requiredFeatures = n
  72560. }
  72561. return r._adapter.requestDevice(r._options.deviceDescriptor)
  72562. }
  72563. throw "Could not retrieve a WebGPU adapter (adapter is null)."
  72564. }
  72565. )).then((function(e) {
  72566. var t, i;
  72567. r._device = e,
  72568. r._deviceEnabledExtensions = [],
  72569. null === (t = r._device.features) || void 0 === t || t.forEach((function(e) {
  72570. return r._deviceEnabledExtensions.push(e)
  72571. }
  72572. ));
  72573. var n = -1;
  72574. r._device.addEventListener("uncapturederror", (function(e) {
  72575. ++n < r.numMaxUncapturedErrors ? K.Warn("WebGPU uncaptured error (".concat(n + 1, "): ").concat(e.error, " - ").concat(e.error.message)) : n++ === r.numMaxUncapturedErrors && K.Warn("WebGPU uncaptured error: too many warnings (".concat(r.numMaxUncapturedErrors, "), no more warnings will be reported to the console for this engine."))
  72576. }
  72577. )),
  72578. r._doNotHandleContextLost || null === (i = r._device.lost) || void 0 === i || i.then((function(e) {
  72579. r._contextWasLost = !0,
  72580. K.Warn("WebGPU context lost. " + e),
  72581. r.onContextLostObservable.notifyObservers(r),
  72582. r._restoreEngineAfterContextLost(r.initAsync.bind(r))
  72583. }
  72584. ))
  72585. }
  72586. ), (function(e) {
  72587. K.Error("Could not retrieve a WebGPU device."),
  72588. K.Error(e)
  72589. }
  72590. )).then((function() {
  72591. r._bufferManager = new mh(r._device),
  72592. r._textureHelper = new fh(r._device,r._glslang,r._tintWASM,r._bufferManager),
  72593. r._cacheSampler = new Th(r._device),
  72594. r._cacheBindGroups = new Nh(r._device,r._cacheSampler,r),
  72595. r._timestampQuery = new Hh(r._device,r._bufferManager),
  72596. r._occlusionQuery = r._device.createQuerySet ? new jh(r,r._device,r._bufferManager) : void 0,
  72597. r._bundleList = new zh(r._device),
  72598. r._bundleListRenderTarget = new zh(r._device),
  72599. r._snapshotRendering = new Kh(r,r._snapshotRenderingMode,r._bundleList,r._bundleListRenderTarget),
  72600. r._ubInvertY = r._bufferManager.createBuffer(new Float32Array([-1, 0]), fu.Uniform | fu.CopyDst),
  72601. r._ubDontInvertY = r._bufferManager.createBuffer(new Float32Array([1, 0]), fu.Uniform | fu.CopyDst),
  72602. r.dbgVerboseLogsForFirstFrames && void 0 === r._count && (r._count = 0,
  72603. console.log("%c frame #" + r._count + " - begin", "background: #ffff00")),
  72604. r._uploadEncoder = r._device.createCommandEncoder(r._uploadEncoderDescriptor),
  72605. r._renderEncoder = r._device.createCommandEncoder(r._renderEncoderDescriptor),
  72606. r._renderTargetEncoder = r._device.createCommandEncoder(r._renderTargetEncoderDescriptor),
  72607. r._emptyVertexBuffer = new Bi(r,[0],"",!1,!1,1,!1,0,1),
  72608. r._initializeLimits(),
  72609. r._cacheRenderPipeline = new Rh(r._device,r._emptyVertexBuffer,!r._caps.textureFloatLinearFiltering),
  72610. r._depthCullingState = new Ph(r._cacheRenderPipeline),
  72611. r._stencilStateComposer = new Ch(r._cacheRenderPipeline),
  72612. r._stencilStateComposer.stencilGlobal = r._stencilState,
  72613. r._depthCullingState.depthTest = !0,
  72614. r._depthCullingState.depthFunc = a.LEQUAL,
  72615. r._depthCullingState.depthMask = !0,
  72616. r._textureHelper.setCommandEncoder(r._uploadEncoder),
  72617. r._clearQuad = new Lh(r._device,r,r._emptyVertexBuffer),
  72618. r._defaultDrawContext = r.createDrawContext(),
  72619. r._currentDrawContext = r._defaultDrawContext,
  72620. r._defaultMaterialContext = r.createMaterialContext(),
  72621. r._currentMaterialContext = r._defaultMaterialContext,
  72622. r._initializeContextAndSwapChain(),
  72623. r._initializeMainAttachments(),
  72624. r.resize()
  72625. }
  72626. )).catch((function(e) {
  72627. K.Error("Can not create WebGPU Device and/or context."),
  72628. K.Error(e),
  72629. console.trace && console.trace()
  72630. }
  72631. ))
  72632. }
  72633. ,
  72634. t.prototype._initGlslang = function(e) {
  72635. return e = e || {},
  72636. (e = V(V({}, t._GLSLslangDefaultOptions), e)).glslang ? Promise.resolve(e.glslang) : self.glslang ? self.glslang(e.wasmPath) : e.jsPath && e.wasmPath ? nt() ? gi.LoadScriptAsync(e.jsPath).then((function() {
  72637. return self.glslang(e.wasmPath)
  72638. }
  72639. )) : (importScripts(e.jsPath),
  72640. self.glslang(e.wasmPath)) : Promise.reject("gslang is not available.")
  72641. }
  72642. ,
  72643. t.prototype._initializeLimits = function() {
  72644. this._caps = {
  72645. maxTexturesImageUnits: 16,
  72646. maxVertexTextureImageUnits: 16,
  72647. maxCombinedTexturesImageUnits: 32,
  72648. maxTextureSize: 8192,
  72649. maxCubemapTextureSize: 2048,
  72650. maxRenderTextureSize: 8192,
  72651. maxVertexAttribs: 16,
  72652. maxVaryingVectors: 15,
  72653. maxFragmentUniformVectors: 1024,
  72654. maxVertexUniformVectors: 1024,
  72655. standardDerivatives: !0,
  72656. astc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionASTC) >= 0 || void 0,
  72657. s3tc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 0 || void 0,
  72658. pvrtc: null,
  72659. etc1: null,
  72660. etc2: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionETC2) >= 0 || void 0,
  72661. bptc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 0 || void 0,
  72662. maxAnisotropy: 4,
  72663. uintIndices: !0,
  72664. fragmentDepthSupported: !0,
  72665. highPrecisionShaderSupported: !0,
  72666. colorBufferFloat: !0,
  72667. textureFloat: !0,
  72668. textureFloatLinearFiltering: !1,
  72669. textureFloatRender: !0,
  72670. textureHalfFloat: !0,
  72671. textureHalfFloatLinearFiltering: !0,
  72672. textureHalfFloatRender: !0,
  72673. textureLOD: !0,
  72674. drawBuffersExtension: !0,
  72675. depthTextureExtension: !0,
  72676. vertexArrayObject: !1,
  72677. instancedArrays: !0,
  72678. timerQuery: "undefined" != typeof BigUint64Array && -1 !== this.enabledExtensions.indexOf(pu.TimestampQuery) || void 0,
  72679. supportOcclusionQuery: "undefined" != typeof BigUint64Array,
  72680. canUseTimestampForTimerQuery: !0,
  72681. multiview: !1,
  72682. oculusMultiview: !1,
  72683. parallelShaderCompile: void 0,
  72684. blendMinMax: !0,
  72685. maxMSAASamples: 4,
  72686. canUseGLInstanceID: !0,
  72687. canUseGLVertexID: !0,
  72688. supportComputeShaders: !0,
  72689. supportSRGBBuffers: !0,
  72690. supportTransformFeedbacks: !1,
  72691. textureMaxLevel: !0
  72692. },
  72693. this._caps.parallelShaderCompile = null,
  72694. this._features = {
  72695. forceBitmapOverHTMLImageElement: !0,
  72696. supportRenderAndCopyToLodForFloatTextures: !0,
  72697. supportDepthStencilTexture: !0,
  72698. supportShadowSamplers: !0,
  72699. uniformBufferHardCheckMatrix: !1,
  72700. allowTexturePrefiltering: !0,
  72701. trackUbosInFrame: !0,
  72702. checkUbosContentBeforeUpload: !0,
  72703. supportCSM: !0,
  72704. basisNeedsPOT: !1,
  72705. support3DTextures: !0,
  72706. needTypeSuffixInShaderConstants: !0,
  72707. supportMSAA: !0,
  72708. supportSSAO2: !0,
  72709. supportExtendedTextureFormats: !0,
  72710. supportSwitchCaseInShader: !0,
  72711. supportSyncTextureRead: !1,
  72712. needsInvertingBitmap: !1,
  72713. useUBOBindingCache: !1,
  72714. needShaderCodeInlining: !0,
  72715. needToAlwaysBindUniformBuffers: !0,
  72716. supportRenderPasses: !0,
  72717. _collectUbosUpdatedInFrame: !1
  72718. }
  72719. }
  72720. ,
  72721. t.prototype._initializeContextAndSwapChain = function() {
  72722. this._context = this._canvas.getContext("webgpu"),
  72723. this._configureContext(this._canvas.width, this._canvas.height),
  72724. this._colorFormat = this._options.swapChainFormat,
  72725. this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new uh],
  72726. this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat
  72727. }
  72728. ,
  72729. t.prototype._initializeMainAttachments = function() {
  72730. var e;
  72731. this._mainTextureExtends = {
  72732. width: this.getRenderWidth(),
  72733. height: this.getRenderHeight(),
  72734. depthOrArrayLayers: 1
  72735. };
  72736. var t, i = new Float32Array([this.getRenderHeight()]);
  72737. if (this._bufferManager.setSubData(this._ubInvertY, 4, i),
  72738. this._bufferManager.setSubData(this._ubDontInvertY, 4, i),
  72739. this._options.antialiasing) {
  72740. var n = {
  72741. size: this._mainTextureExtends,
  72742. mipLevelCount: 1,
  72743. sampleCount: this._mainPassSampleCount,
  72744. dimension: mu.E2d,
  72745. format: this._options.swapChainFormat,
  72746. usage: gu.RenderAttachment
  72747. };
  72748. null === (e = this._mainTexture) || void 0 === e || e.destroy(),
  72749. this._mainTexture = this._device.createTexture(n),
  72750. t = [{
  72751. view: this._mainTexture.createView(),
  72752. clearValue: new N(0,0,0,1),
  72753. loadOp: zu.Clear,
  72754. storeOp: Wu.Store
  72755. }]
  72756. } else
  72757. t = [{
  72758. view: void 0,
  72759. clearValue: new N(0,0,0,1),
  72760. loadOp: zu.Clear,
  72761. storeOp: Wu.Store
  72762. }];
  72763. this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? bu.Depth24PlusStencil8 : bu.Depth32Float,
  72764. this._setDepthTextureFormat(this._mainRenderPassWrapper);
  72765. var r = {
  72766. size: this._mainTextureExtends,
  72767. mipLevelCount: 1,
  72768. sampleCount: this._mainPassSampleCount,
  72769. dimension: mu.E2d,
  72770. format: this._mainRenderPassWrapper.depthTextureFormat,
  72771. usage: gu.RenderAttachment
  72772. };
  72773. this._depthTexture && this._depthTexture.destroy(),
  72774. this._depthTexture = this._device.createTexture(r);
  72775. var o = {
  72776. view: this._depthTexture.createView(),
  72777. depthClearValue: this._clearDepthValue,
  72778. depthLoadOp: zu.Clear,
  72779. depthStoreOp: Wu.Store,
  72780. stencilClearValue: this._clearStencilValue,
  72781. stencilLoadOp: zu.Clear,
  72782. stencilStoreOp: Wu.Store
  72783. };
  72784. this._mainRenderPassWrapper.renderPassDescriptor = {
  72785. colorAttachments: t,
  72786. depthStencilAttachment: o
  72787. },
  72788. null !== this._mainRenderPassWrapper.renderPass && this._endMainRenderPass()
  72789. }
  72790. ,
  72791. t.prototype._configureContext = function(e, t) {
  72792. this._context.configure({
  72793. device: this._device,
  72794. format: this._options.swapChainFormat,
  72795. usage: gu.RenderAttachment | gu.CopySrc,
  72796. compositingAlphaMode: this.premultipliedAlpha ? Xu.Premultiplied : Xu.Opaque,
  72797. size: {
  72798. width: e,
  72799. height: t,
  72800. depthOrArrayLayers: 1
  72801. }
  72802. })
  72803. }
  72804. ,
  72805. t.prototype.setSize = function(t, i, n) {
  72806. return void 0 === n && (n = !1),
  72807. !!e.prototype.setSize.call(this, t, i, n) && (this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  72808. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize called -", t, i)),
  72809. this._configureContext(t, i),
  72810. this._initializeMainAttachments(),
  72811. this.snapshotRendering && this.snapshotRenderingReset(),
  72812. !0)
  72813. }
  72814. ,
  72815. t.prototype._getShaderProcessor = function(e) {
  72816. return e === st.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor
  72817. }
  72818. ,
  72819. t.prototype._getShaderProcessingContext = function(e) {
  72820. return new Ju(e)
  72821. }
  72822. ,
  72823. t.prototype.applyStates = function() {
  72824. this._stencilStateComposer.apply(),
  72825. this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)
  72826. }
  72827. ,
  72828. t.prototype.wipeCaches = function(e) {
  72829. this.preventCacheWipeBetweenFrames && !e || (this._forceEnableEffect = !0,
  72830. this._currentIndexBuffer = null,
  72831. this._currentOverrideVertexBuffers = null,
  72832. this._cacheRenderPipeline.setBuffers(null, null, null),
  72833. e && (this._stencilStateComposer.reset(),
  72834. this._depthCullingState.reset(),
  72835. this._depthCullingState.depthFunc = a.LEQUAL,
  72836. this._alphaState.reset(),
  72837. this._alphaMode = a.ALPHA_ADD,
  72838. this._alphaEquation = a.ALPHA_DISABLE,
  72839. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters),
  72840. this._cacheRenderPipeline.setAlphaBlendEnabled(!1),
  72841. this.setColorWrite(!0)),
  72842. this._cachedVertexBuffers = null,
  72843. this._cachedIndexBuffer = null,
  72844. this._cachedEffectForVertexBuffers = null)
  72845. }
  72846. ,
  72847. t.prototype.setColorWrite = function(e) {
  72848. this._colorWriteLocal = e,
  72849. this._cacheRenderPipeline.setWriteMask(e ? 15 : 0)
  72850. }
  72851. ,
  72852. t.prototype.getColorWrite = function() {
  72853. return this._colorWriteLocal
  72854. }
  72855. ,
  72856. t.prototype._resetCurrentViewport = function(e) {
  72857. this._viewportsCurrent[e].x = 0,
  72858. this._viewportsCurrent[e].y = 0,
  72859. this._viewportsCurrent[e].w = 0,
  72860. this._viewportsCurrent[e].h = 0,
  72861. 1 === e && (this._viewportCached.x = 0,
  72862. this._viewportCached.y = 0,
  72863. this._viewportCached.z = 0,
  72864. this._viewportCached.w = 0)
  72865. }
  72866. ,
  72867. t.prototype._mustUpdateViewport = function(e) {
  72868. var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
  72869. , i = this._viewportCached.x
  72870. , n = this._viewportCached.y
  72871. , r = this._viewportCached.z
  72872. , o = this._viewportCached.w
  72873. , a = this._viewportsCurrent[t].x !== i || this._viewportsCurrent[t].y !== n || this._viewportsCurrent[t].w !== r || this._viewportsCurrent[t].h !== o;
  72874. return a && (this._viewportsCurrent[t].x = this._viewportCached.x,
  72875. this._viewportsCurrent[t].y = this._viewportCached.y,
  72876. this._viewportsCurrent[t].w = this._viewportCached.z,
  72877. this._viewportsCurrent[t].h = this._viewportCached.w),
  72878. a
  72879. }
  72880. ,
  72881. t.prototype._applyViewport = function(e) {
  72882. var t = Math.floor(this._viewportCached.y)
  72883. , i = Math.floor(this._viewportCached.w);
  72884. this._currentRenderTarget || (t = this.getRenderHeight() - t - i),
  72885. e.setViewport(Math.floor(this._viewportCached.x), t, Math.floor(this._viewportCached.z), i, 0, 1),
  72886. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  72887. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - viewport applied - (", this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w, ") current pass is main pass=" + (e === this._mainRenderPassWrapper.renderPass)))
  72888. }
  72889. ,
  72890. t.prototype._viewport = function(e, t, i, n) {
  72891. this._viewportCached.x = e,
  72892. this._viewportCached.y = t,
  72893. this._viewportCached.z = i,
  72894. this._viewportCached.w = n
  72895. }
  72896. ,
  72897. t.prototype._resetCurrentScissor = function(e) {
  72898. this._scissorsCurrent[e].x = 0,
  72899. this._scissorsCurrent[e].y = 0,
  72900. this._scissorsCurrent[e].w = 0,
  72901. this._scissorsCurrent[e].h = 0
  72902. }
  72903. ,
  72904. t.prototype._mustUpdateScissor = function(e) {
  72905. var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
  72906. , i = this._scissorCached.x
  72907. , n = this._scissorCached.y
  72908. , r = this._scissorCached.z
  72909. , o = this._scissorCached.w
  72910. , a = this._scissorsCurrent[t].x !== i || this._scissorsCurrent[t].y !== n || this._scissorsCurrent[t].w !== r || this._scissorsCurrent[t].h !== o;
  72911. return a && (this._scissorsCurrent[t].x = this._scissorCached.x,
  72912. this._scissorsCurrent[t].y = this._scissorCached.y,
  72913. this._scissorsCurrent[t].w = this._scissorCached.z,
  72914. this._scissorsCurrent[t].h = this._scissorCached.w),
  72915. a
  72916. }
  72917. ,
  72918. t.prototype._applyScissor = function(e) {
  72919. e.setScissorRect(this._scissorCached.x, this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y, this._scissorCached.z, this._scissorCached.w),
  72920. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  72921. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - scissor applied - (", this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w, ") current pass is main pass=" + (e === this._mainRenderPassWrapper.renderPass)))
  72922. }
  72923. ,
  72924. t.prototype._scissorIsActive = function() {
  72925. return 0 !== this._scissorCached.x || 0 !== this._scissorCached.y || 0 !== this._scissorCached.z || 0 !== this._scissorCached.w
  72926. }
  72927. ,
  72928. t.prototype.enableScissor = function(e, t, i, n) {
  72929. this._scissorCached.x = e,
  72930. this._scissorCached.y = t,
  72931. this._scissorCached.z = i,
  72932. this._scissorCached.w = n
  72933. }
  72934. ,
  72935. t.prototype.disableScissor = function() {
  72936. this._scissorCached.x = 0,
  72937. this._scissorCached.y = 0,
  72938. this._scissorCached.z = 0,
  72939. this._scissorCached.w = 0,
  72940. this._resetCurrentScissor(0),
  72941. this._resetCurrentScissor(1)
  72942. }
  72943. ,
  72944. t.prototype._resetCurrentStencilRef = function(e) {
  72945. this._stencilRefsCurrent[e] = -1
  72946. }
  72947. ,
  72948. t.prototype._mustUpdateStencilRef = function(e) {
  72949. var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
  72950. , i = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent[t];
  72951. return i && (this._stencilRefsCurrent[t] = this._stencilStateComposer.funcRef),
  72952. i
  72953. }
  72954. ,
  72955. t.prototype._applyStencilRef = function(e) {
  72956. var t;
  72957. e.setStencilReference(null !== (t = this._stencilStateComposer.funcRef) && void 0 !== t ? t : 0)
  72958. }
  72959. ,
  72960. t.prototype._resetCurrentColorBlend = function(e) {
  72961. this._blendColorsCurrent[e][0] = this._blendColorsCurrent[e][1] = this._blendColorsCurrent[e][2] = this._blendColorsCurrent[e][3] = null
  72962. }
  72963. ,
  72964. t.prototype._mustUpdateBlendColor = function(e) {
  72965. var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
  72966. , i = this._alphaState._blendConstants
  72967. , n = i[0] !== this._blendColorsCurrent[t][0] || i[1] !== this._blendColorsCurrent[t][1] || i[2] !== this._blendColorsCurrent[t][2] || i[3] !== this._blendColorsCurrent[t][3];
  72968. return n && (this._blendColorsCurrent[t][0] = i[0],
  72969. this._blendColorsCurrent[t][1] = i[1],
  72970. this._blendColorsCurrent[t][2] = i[2],
  72971. this._blendColorsCurrent[t][3] = i[3]),
  72972. n
  72973. }
  72974. ,
  72975. t.prototype._applyBlendColor = function(e) {
  72976. e.setBlendConstant(this._alphaState._blendConstants)
  72977. }
  72978. ,
  72979. t.prototype.clear = function(e, t, i, n) {
  72980. void 0 === n && (n = !1),
  72981. e && void 0 === e.a && (e.a = 1);
  72982. var r = this._scissorIsActive();
  72983. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  72984. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear called - backBuffer=", t, " depth=", i, " stencil=", n, " scissor is active=", r)),
  72985. this._currentRenderTarget ? r ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, t ? e : null, i, n),
  72986. this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  72987. this._clearFullQuad(t ? e : null, i, n)) : (this._currentRenderPass && this._endRenderTargetRenderPass(),
  72988. this._startRenderTargetRenderPass(this._currentRenderTarget, !0, t ? e : null, i, n)) : (this._mainRenderPassWrapper.renderPass && r || this._startMainRenderPass(!r, t ? e : null, i, n),
  72989. r && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  72990. this._clearFullQuad(t ? e : null, i, n)))
  72991. }
  72992. ,
  72993. t.prototype._clearFullQuad = function(e, t, i) {
  72994. var n, r, o, a = this.compatibilityMode ? this._getCurrentRenderPass() : null, s = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget;
  72995. this._clearQuad.setColorFormat(this._colorFormat),
  72996. this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),
  72997. this._clearQuad.setMRTAttachments(null !== (n = this._cacheRenderPipeline.mrtAttachments) && void 0 !== n ? n : [], null !== (r = this._cacheRenderPipeline.mrtTextureArray) && void 0 !== r ? r : [], this._cacheRenderPipeline.mrtTextureCount),
  72998. this.compatibilityMode ? a.setStencilReference(this._clearStencilValue) : s.addItem(new Bh(this._clearStencilValue));
  72999. var l = this._clearQuad.clear(a, e, t, i, this.currentSampleCount);
  73000. this.compatibilityMode ? this._applyStencilRef(a) : (s.addBundle(l),
  73001. s.addItem(new Bh(null !== (o = this._stencilStateComposer.funcRef) && void 0 !== o ? o : 0)),
  73002. this._reportDrawCall())
  73003. }
  73004. ,
  73005. t.prototype.createVertexBuffer = function(e) {
  73006. var t;
  73007. return t = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e,
  73008. this._bufferManager.createBuffer(t, fu.Vertex | fu.CopyDst)
  73009. }
  73010. ,
  73011. t.prototype.createDynamicVertexBuffer = function(e) {
  73012. return this.createVertexBuffer(e)
  73013. }
  73014. ,
  73015. t.prototype.createIndexBuffer = function(e) {
  73016. var t, i = !0;
  73017. e instanceof Uint32Array || e instanceof Int32Array ? t = e : e instanceof Uint16Array ? (t = e,
  73018. i = !1) : e.length > 65535 ? t = new Uint32Array(e) : (t = new Uint16Array(e),
  73019. i = !1);
  73020. var n = this._bufferManager.createBuffer(t, fu.Index | fu.CopyDst);
  73021. return n.is32Bits = i,
  73022. n
  73023. }
  73024. ,
  73025. t.prototype._createBuffer = function(e, t) {
  73026. var i;
  73027. i = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e;
  73028. var n = 0;
  73029. return t & a.BUFFER_CREATIONFLAG_READ && (n |= fu.CopySrc),
  73030. t & a.BUFFER_CREATIONFLAG_WRITE && (n |= fu.CopyDst),
  73031. t & a.BUFFER_CREATIONFLAG_UNIFORM && (n |= fu.Uniform),
  73032. t & a.BUFFER_CREATIONFLAG_VERTEX && (n |= fu.Vertex),
  73033. t & a.BUFFER_CREATIONFLAG_INDEX && (n |= fu.Index),
  73034. t & a.BUFFER_CREATIONFLAG_STORAGE && (n |= fu.Storage),
  73035. this._bufferManager.createBuffer(i, n)
  73036. }
  73037. ,
  73038. t.prototype.bindBuffersDirectly = function() {
  73039. throw "Not implemented on WebGPU"
  73040. }
  73041. ,
  73042. t.prototype.updateAndBindInstancesBuffer = function() {
  73043. throw "Not implemented on WebGPU"
  73044. }
  73045. ,
  73046. t.prototype.bindBuffers = function(e, t, i, n) {
  73047. this._currentIndexBuffer = t,
  73048. this._currentOverrideVertexBuffers = null != n ? n : null,
  73049. this._cacheRenderPipeline.setBuffers(e, t, this._currentOverrideVertexBuffers)
  73050. }
  73051. ,
  73052. t.prototype._releaseBuffer = function(e) {
  73053. return this._bufferManager.releaseBuffer(e)
  73054. }
  73055. ,
  73056. t.prototype.createEffect = function(e, t, i, n, r, o, a, s, l, c) {
  73057. var u;
  73058. void 0 === c && (c = st.GLSL);
  73059. var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
  73060. , d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
  73061. , p = this._getGlobalDefines()
  73062. , f = null !== (u = null != r ? r : t.defines) && void 0 !== u ? u : "";
  73063. p && (f += "\n" + p);
  73064. var _ = h + "+" + d + "@" + f;
  73065. if (this._compiledEffects[_]) {
  73066. var m = this._compiledEffects[_];
  73067. return a && m.isReady() && a(m),
  73068. m
  73069. }
  73070. var g = new Mt(e,t,i,n,this,r,o,a,s,l,_,c);
  73071. return this._compiledEffects[_] = g,
  73072. g
  73073. }
  73074. ,
  73075. t.prototype._compileRawShaderToSpirV = function(e, t) {
  73076. return this._glslang.compileGLSL(e, t)
  73077. }
  73078. ,
  73079. t.prototype._compileShaderToSpirV = function(e, t, i, n) {
  73080. return this._compileRawShaderToSpirV(n + (i ? i + "\n" : "") + e, t)
  73081. }
  73082. ,
  73083. t.prototype._getWGSLShader = function(e, t, i) {
  73084. return (i = i ? "//" + i.split("\n").join("\n//") + "\n" : "") + e
  73085. }
  73086. ,
  73087. t.prototype._createPipelineStageDescriptor = function(e, t, i) {
  73088. return this._tintWASM && i === st.GLSL && (e = this._tintWASM.convertSpirV2WGSL(e),
  73089. t = this._tintWASM.convertSpirV2WGSL(t)),
  73090. {
  73091. vertexStage: {
  73092. module: this._device.createShaderModule({
  73093. code: e
  73094. }),
  73095. entryPoint: "main"
  73096. },
  73097. fragmentStage: {
  73098. module: this._device.createShaderModule({
  73099. code: t
  73100. }),
  73101. entryPoint: "main"
  73102. }
  73103. }
  73104. }
  73105. ,
  73106. t.prototype._compileRawPipelineStageDescriptor = function(e, t, i) {
  73107. var n = i === st.GLSL ? this._compileRawShaderToSpirV(e, "vertex") : e
  73108. , r = i === st.GLSL ? this._compileRawShaderToSpirV(t, "fragment") : t;
  73109. return this._createPipelineStageDescriptor(n, r, i)
  73110. }
  73111. ,
  73112. t.prototype._compilePipelineStageDescriptor = function(e, t, i, n) {
  73113. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  73114. var r = "#version 450\n"
  73115. , o = n === st.GLSL ? this._compileShaderToSpirV(e, "vertex", i, r) : this._getWGSLShader(e, "vertex", i)
  73116. , a = n === st.GLSL ? this._compileShaderToSpirV(t, "fragment", i, r) : this._getWGSLShader(t, "fragment", i)
  73117. , s = this._createPipelineStageDescriptor(o, a, n);
  73118. return this.onAfterShaderCompilationObservable.notifyObservers(this),
  73119. s
  73120. }
  73121. ,
  73122. t.prototype.createRawShaderProgram = function() {
  73123. throw "Not available on WebGPU"
  73124. }
  73125. ,
  73126. t.prototype.createShaderProgram = function() {
  73127. throw "Not available on WebGPU"
  73128. }
  73129. ,
  73130. t.prototype.inlineShaderCode = function(e) {
  73131. var t = new iu(e);
  73132. return t.debug = !1,
  73133. t.processCode(),
  73134. t.code
  73135. }
  73136. ,
  73137. t.prototype.createPipelineContext = function(e) {
  73138. return new qu(e,this)
  73139. }
  73140. ,
  73141. t.prototype.createMaterialContext = function() {
  73142. return new Ih
  73143. }
  73144. ,
  73145. t.prototype.createDrawContext = function() {
  73146. return new Oh(this._bufferManager)
  73147. }
  73148. ,
  73149. t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s) {
  73150. var l = e
  73151. , c = l.shaderProcessingContext.shaderLanguage;
  73152. this.dbgShowShaderCode && (console.log(s),
  73153. console.log(t),
  73154. console.log(i)),
  73155. l.sources = {
  73156. fragment: i,
  73157. vertex: t,
  73158. rawVertex: r,
  73159. rawFragment: o
  73160. },
  73161. l.stages = n ? this._compileRawPipelineStageDescriptor(t, i, c) : this._compilePipelineStageDescriptor(t, i, s, c)
  73162. }
  73163. ,
  73164. t.prototype.getAttributes = function(e, t) {
  73165. for (var i = new Array(t.length), n = e, r = 0; r < t.length; r++) {
  73166. var o = t[r]
  73167. , a = n.shaderProcessingContext.availableAttributes[o];
  73168. void 0 !== a && (i[r] = a)
  73169. }
  73170. return i
  73171. }
  73172. ,
  73173. t.prototype.enableEffect = function(e) {
  73174. if (e) {
  73175. var t = !0;
  73176. if (Gt.IsWrapper(e)) {
  73177. if (!e.effect || e.effect === this._currentEffect && e.materialContext === this._currentMaterialContext && e.drawContext === this._currentDrawContext && !this._forceEnableEffect) {
  73178. if (!e.effect && this.dbgShowEmptyEnableEffectCalls)
  73179. throw console.error("drawWrapper=", e),
  73180. "Invalid call to enableEffect: the effect property is empty!";
  73181. return
  73182. }
  73183. if (t = e.effect !== this._currentEffect,
  73184. this._currentEffect = e.effect,
  73185. this._currentMaterialContext = e.materialContext,
  73186. this._currentDrawContext = e.drawContext,
  73187. this._counters.numEnableDrawWrapper++,
  73188. !this._currentMaterialContext)
  73189. throw console.error("drawWrapper=", e),
  73190. "Invalid call to enableEffect: the materialContext property is empty!"
  73191. } else
  73192. t = e !== this._currentEffect,
  73193. this._currentEffect = e,
  73194. this._currentMaterialContext = this._defaultMaterialContext,
  73195. this._currentDrawContext = this._defaultDrawContext,
  73196. this._counters.numEnableEffects++,
  73197. this.dbgLogIfNotDrawWrapper && K.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId, ", effect.name=").concat(e.name, ", effect.name.vertex=").concat(e.name.vertex, ", effect.name.fragment=").concat(e.name.fragment), 10);
  73198. this._stencilStateComposer.stencilMaterial = void 0,
  73199. this._forceEnableEffect = !t && !this._forceEnableEffect && this._forceEnableEffect,
  73200. t && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect),
  73201. this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect))
  73202. }
  73203. }
  73204. ,
  73205. t.prototype._releaseEffect = function(e) {
  73206. this._compiledEffects[e._key] && (delete this._compiledEffects[e._key],
  73207. this._deletePipelineContext(e.getPipelineContext()))
  73208. }
  73209. ,
  73210. t.prototype.releaseEffects = function() {
  73211. for (var e in this._compiledEffects) {
  73212. var t = this._compiledEffects[e].getPipelineContext();
  73213. this._deletePipelineContext(t)
  73214. }
  73215. this._compiledEffects = {}
  73216. }
  73217. ,
  73218. t.prototype._deletePipelineContext = function(e) {
  73219. e && e.dispose()
  73220. }
  73221. ,
  73222. Object.defineProperty(t.prototype, "needPOTTextures", {
  73223. get: function() {
  73224. return !1
  73225. },
  73226. enumerable: !1,
  73227. configurable: !0
  73228. }),
  73229. t.prototype._createHardwareTexture = function() {
  73230. return new uh
  73231. }
  73232. ,
  73233. t.prototype._releaseTexture = function(e) {
  73234. var t = this._internalTexturesCache.indexOf(e);
  73235. -1 !== t && this._internalTexturesCache.splice(t, 1),
  73236. this._textureHelper.releaseTexture(e)
  73237. }
  73238. ,
  73239. t.prototype._getRGBABufferInternalSizedFormat = function() {
  73240. return a.TEXTUREFORMAT_RGBA
  73241. }
  73242. ,
  73243. t.prototype.updateTextureComparisonFunction = function(e, t) {
  73244. e._comparisonFunction = t
  73245. }
  73246. ,
  73247. t.prototype._createInternalTexture = function(e, t, i, n) {
  73248. var r, o;
  73249. void 0 === i && (i = !0),
  73250. void 0 === n && (n = At.Unknown);
  73251. var s = {};
  73252. void 0 !== t && "object" == typeof t ? (s.generateMipMaps = t.generateMipMaps,
  73253. s.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
  73254. s.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
  73255. s.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format,
  73256. s.samples = null !== (r = t.samples) && void 0 !== r ? r : 1,
  73257. s.creationFlags = null !== (o = t.creationFlags) && void 0 !== o ? o : 0) : (s.generateMipMaps = t,
  73258. s.type = a.TEXTURETYPE_UNSIGNED_INT,
  73259. s.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  73260. s.format = a.TEXTUREFORMAT_RGBA,
  73261. s.samples = 1,
  73262. s.creationFlags = 0),
  73263. (s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (s.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (s.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
  73264. s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (s.type = a.TEXTURETYPE_UNSIGNED_INT,
  73265. K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
  73266. var l = new Lt(this,n)
  73267. , c = e.width || e
  73268. , u = e.height || e
  73269. , h = e.layers || 0;
  73270. return l.baseWidth = c,
  73271. l.baseHeight = u,
  73272. l.width = c,
  73273. l.height = u,
  73274. l.depth = h,
  73275. l.isReady = !0,
  73276. l.samples = s.samples,
  73277. l.generateMipMaps = !!s.generateMipMaps,
  73278. l.samplingMode = s.samplingMode,
  73279. l.type = s.type,
  73280. l.format = s.format,
  73281. l.is2DArray = h > 0,
  73282. l._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  73283. l._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  73284. this._internalTexturesCache.push(l),
  73285. i || this._textureHelper.createGPUTextureForInternalTexture(l, c, u, h || 1, s.creationFlags),
  73286. l
  73287. }
  73288. ,
  73289. t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
  73290. var m = this;
  73291. return void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  73292. void 0 === o && (o = null),
  73293. void 0 === s && (s = null),
  73294. void 0 === l && (l = null),
  73295. void 0 === c && (c = null),
  73296. void 0 === u && (u = null),
  73297. void 0 === h && (h = null),
  73298. this._createTextureBase(e, t, i, n, r, o, s, (function(e, t, i, n, r, o, a, s) {
  73299. var l, c = n;
  73300. if (e.baseWidth = c.width,
  73301. e.baseHeight = c.height,
  73302. e.width = c.width,
  73303. e.height = c.height,
  73304. e.format = null != u ? u : -1,
  73305. s(e.width, e.height, c, t, e, (function() {}
  73306. )),
  73307. null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource)
  73308. o || a || m._generateMipmaps(e, m._uploadEncoder);
  73309. else {
  73310. var h = m._textureHelper.createGPUTextureForInternalTexture(e, c.width, c.height, void 0, f);
  73311. fh.IsImageBitmap(c) && (m._textureHelper.updateTexture(c, e, c.width, c.height, e.depth, h.format, 0, 0, r, !1, 0, 0),
  73312. o || a || m._generateMipmaps(e, m._uploadEncoder))
  73313. }
  73314. i && i._removePendingData(e),
  73315. e.isReady = !0,
  73316. e.onLoadedObservable.notifyObservers(e),
  73317. e.onLoadedObservable.clear()
  73318. }
  73319. ), (function() {
  73320. return !1
  73321. }
  73322. ), l, c, u, h, d, p, _)
  73323. }
  73324. ,
  73325. t.prototype.generateMipMapsForCubemap = function(e) {
  73326. var t;
  73327. e.generateMipMaps && ((null === (t = e._hardwareTexture) || void 0 === t ? void 0 : t.underlyingResource) || this._textureHelper.createGPUTextureForInternalTexture(e),
  73328. this._generateMipmaps(e, e.source === At.RenderTarget || e.source === At.MultiRenderTarget ? this._renderTargetEncoder : void 0))
  73329. }
  73330. ,
  73331. t.prototype.updateTextureSamplingMode = function(e, t, i) {
  73332. void 0 === i && (i = !1),
  73333. i && (t.generateMipMaps = !0,
  73334. this._generateMipmaps(t)),
  73335. t.samplingMode = e
  73336. }
  73337. ,
  73338. t.prototype.updateTextureWrappingMode = function(e, t, i, n) {
  73339. void 0 === i && (i = null),
  73340. void 0 === n && (n = null),
  73341. null !== t && (e._cachedWrapU = t),
  73342. null !== i && (e._cachedWrapV = i),
  73343. (e.is2DArray || e.is3D) && null !== n && (e._cachedWrapR = n)
  73344. }
  73345. ,
  73346. t.prototype.updateTextureDimensions = function(e, t, i, n) {
  73347. if (void 0 === n && (n = 1),
  73348. e._hardwareTexture && (e.width !== t || e.height !== i || e.depth !== n)) {
  73349. var r = e._hardwareTexture.textureAdditionalUsages;
  73350. e._hardwareTexture.release(),
  73351. this._textureHelper.createGPUTextureForInternalTexture(e, t, i, n, r)
  73352. }
  73353. }
  73354. ,
  73355. t.prototype._setInternalTexture = function(e, t, i) {
  73356. if (i = null != i ? i : e,
  73357. this._currentEffect) {
  73358. var n = this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];
  73359. if (this._currentMaterialContext.setTexture(e, t),
  73360. n && n.autoBindSampler) {
  73361. var r = i + Qu.AutoSamplerSuffix;
  73362. this._currentMaterialContext.setSampler(r, t)
  73363. }
  73364. }
  73365. }
  73366. ,
  73367. t.prototype.setTexture = function(e, t, i, n) {
  73368. this._setTexture(e, i, !1, !1, n, n)
  73369. }
  73370. ,
  73371. t.prototype.setTextureArray = function(e, t, i, n) {
  73372. for (var r = 0; r < i.length; r++)
  73373. this._setTexture(-1, i[r], !0, !1, n + r.toString(), n)
  73374. }
  73375. ,
  73376. t.prototype._setTexture = function(e, t, i, n, r, o) {
  73377. if (void 0 === i && (i = !1),
  73378. void 0 === n && (n = !1),
  73379. void 0 === r && (r = ""),
  73380. o = null != o ? o : r,
  73381. this._currentEffect) {
  73382. if (!t)
  73383. return this._currentMaterialContext.setTexture(r, null),
  73384. !1;
  73385. if (t.video)
  73386. t.update();
  73387. else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
  73388. return t.delayLoad(),
  73389. !1;
  73390. var s = null;
  73391. if ((s = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture) && !s.isMultiview) {
  73392. if (s.isCube && s._cachedCoordinatesMode !== t.coordinatesMode) {
  73393. s._cachedCoordinatesMode = t.coordinatesMode;
  73394. var l = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE;
  73395. t.wrapU = l,
  73396. t.wrapV = l
  73397. }
  73398. s._cachedWrapU = t.wrapU,
  73399. s._cachedWrapV = t.wrapV,
  73400. s.is3D && (s._cachedWrapR = t.wrapR),
  73401. this._setAnisotropicLevel(0, s, t.anisotropicFilteringLevel)
  73402. }
  73403. this._setInternalTexture(r, s, o)
  73404. } else
  73405. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73406. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", t));
  73407. return !0
  73408. }
  73409. ,
  73410. t.prototype._setAnisotropicLevel = function(e, t, i) {
  73411. t._cachedAnisotropicFilteringLevel !== i && (t._cachedAnisotropicFilteringLevel = Math.min(i, this._caps.maxAnisotropy))
  73412. }
  73413. ,
  73414. t.prototype._bindTexture = function(e, t, i) {
  73415. void 0 !== e && this._setInternalTexture(i, t)
  73416. }
  73417. ,
  73418. t.prototype.generateMipmaps = function(e) {
  73419. this._generateMipmaps(e, this._renderTargetEncoder)
  73420. }
  73421. ,
  73422. t.prototype._generateMipmaps = function(e, t) {
  73423. var i = e._hardwareTexture;
  73424. if (i) {
  73425. t = null != t ? t : this._currentRenderTarget && !this._currentRenderPass ? this._renderTargetEncoder : this._currentRenderPass ? this._uploadEncoder : this._renderEncoder;
  73426. var n = e._hardwareTexture.format
  73427. , r = fh.ComputeNumMipmapLevels(e.width, e.height);
  73428. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73429. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps called - width=", e.width, "height=", e.height, "isCube=", e.isCube)),
  73430. e.isCube ? this._textureHelper.generateCubeMipmaps(i, n, r, t) : this._textureHelper.generateMipmaps(i, n, r, 0, t)
  73431. }
  73432. }
  73433. ,
  73434. t.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
  73435. var l;
  73436. void 0 === a && (a = 0),
  73437. void 0 === s && (s = 0);
  73438. var c = e._hardwareTexture;
  73439. (null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource) || (c = this._textureHelper.createGPUTextureForInternalTexture(e));
  73440. var u = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
  73441. this._textureHelper.updateTexture(u, e, r, o, e.depth, c.format, a, s, e.invertY, !1, i, n)
  73442. }
  73443. ,
  73444. t.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
  73445. var s;
  73446. void 0 === o && (o = 0),
  73447. void 0 === a && (a = 0);
  73448. var l = e._hardwareTexture;
  73449. (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (e.format = t,
  73450. l = this._textureHelper.createGPUTextureForInternalTexture(e, i, n));
  73451. var c = new Uint8Array(r.buffer,r.byteOffset,r.byteLength);
  73452. this._textureHelper.updateTexture(c, e, i, n, e.depth, l.format, o, a, !1, !1, 0, 0)
  73453. }
  73454. ,
  73455. t.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
  73456. var a;
  73457. void 0 === i && (i = 0),
  73458. void 0 === n && (n = 0),
  73459. void 0 === o && (o = !1);
  73460. var s = Math.round(Math.log(e.width) * Math.LOG2E)
  73461. , l = Math.round(Math.log(e.height) * Math.LOG2E)
  73462. , c = o ? e.width : Math.pow(2, Math.max(s - n, 0))
  73463. , u = o ? e.height : Math.pow(2, Math.max(l - n, 0))
  73464. , h = e._hardwareTexture;
  73465. (null === (a = e._hardwareTexture) || void 0 === a ? void 0 : a.underlyingResource) || (h = this._textureHelper.createGPUTextureForInternalTexture(e, c, u));
  73466. var d = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
  73467. this._textureHelper.updateTexture(d, e, c, u, e.depth, h.format, i, n, e.invertY, !1, 0, 0)
  73468. }
  73469. ,
  73470. t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
  73471. void 0 === i && (i = 0),
  73472. void 0 === n && (n = 0),
  73473. this._uploadDataToTextureDirectly(e, t, i, n)
  73474. }
  73475. ,
  73476. t.prototype._uploadImageToTexture = function(e, t, i, n) {
  73477. var r;
  73478. void 0 === i && (i = 0),
  73479. void 0 === n && (n = 0);
  73480. var o = e._hardwareTexture;
  73481. (null === (r = e._hardwareTexture) || void 0 === r ? void 0 : r.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e));
  73482. var a = t
  73483. , s = Math.ceil(e.width / (1 << n))
  73484. , l = Math.ceil(e.height / (1 << n));
  73485. this._textureHelper.updateTexture(a, e, s, l, e.depth, o.format, i, n, e.invertY, !1, 0, 0)
  73486. }
  73487. ,
  73488. t.prototype.readPixels = function(e, t, i, n, r, o) {
  73489. void 0 === r && (r = !0),
  73490. void 0 === o && (o = !0);
  73491. var a = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper
  73492. , s = a.colorAttachmentGPUTextures[0].underlyingResource
  73493. , l = a.colorAttachmentGPUTextures[0].format;
  73494. return s ? (o && this.flushFramebuffer(),
  73495. this._textureHelper.readPixels(s, e, t, i, n, l)) : Promise.resolve(new Uint8Array(0))
  73496. }
  73497. ,
  73498. t.prototype.beginFrame = function() {
  73499. e.prototype.beginFrame.call(this)
  73500. }
  73501. ,
  73502. t.prototype.endFrame = function() {
  73503. if (this._snapshotRendering.endFrame(this._mainRenderPassWrapper.renderPass),
  73504. this._endMainRenderPass(),
  73505. this._timestampQuery.endFrame(this._renderEncoder),
  73506. this.flushFramebuffer(!1),
  73507. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73508. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - counters")),
  73509. this._textureHelper.destroyDeferredTextures(),
  73510. this._bufferManager.destroyDeferredBuffers(),
  73511. this._features._collectUbosUpdatedInFrame) {
  73512. if (this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73513. !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
  73514. var t = [];
  73515. for (var i in Fi._UpdatedUbosInFrame)
  73516. t.push(i + ":" + Fi._UpdatedUbosInFrame[i]);
  73517. console.log("frame #" + this._count + " - updated ubos -", t.join(", "))
  73518. }
  73519. Fi._UpdatedUbosInFrame = {}
  73520. }
  73521. this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects,
  73522. this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper,
  73523. this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode,
  73524. this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode,
  73525. this._counters.numEnableEffects = 0,
  73526. this._counters.numEnableDrawWrapper = 0,
  73527. this._counters.numBundleCreationNonCompatMode = 0,
  73528. this._counters.numBundleReuseNonCompatMode = 0,
  73529. this._cacheRenderPipeline.endFrame(),
  73530. this._cacheBindGroups.endFrame(),
  73531. this._pendingDebugCommands.length = 0,
  73532. e.prototype.endFrame.call(this),
  73533. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73534. this._count < this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - end", "background: #ffff00"),
  73535. this._count < this.dbgVerboseLogsNumFrames && (this._count++,
  73536. this._count !== this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - begin", "background: #ffff00")))
  73537. }
  73538. ,
  73539. t.prototype.flushFramebuffer = function(e) {
  73540. void 0 === e && (e = !0);
  73541. var t = !this._currentRenderPass
  73542. , i = 0;
  73543. this._currentRenderPass && this._currentRenderTarget && (i |= 1,
  73544. this._endRenderTargetRenderPass()),
  73545. this._mainRenderPassWrapper.renderPass && (i |= 2,
  73546. this._endMainRenderPass()),
  73547. this._commandBuffers[0] = this._uploadEncoder.finish(),
  73548. this._commandBuffers[1] = this._renderTargetEncoder.finish(),
  73549. this._commandBuffers[2] = this._renderEncoder.finish(),
  73550. this._device.queue.submit(this._commandBuffers),
  73551. this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor),
  73552. this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor),
  73553. this._renderTargetEncoder = this._device.createCommandEncoder(this._renderTargetEncoderDescriptor),
  73554. this._timestampQuery.startFrame(this._uploadEncoder),
  73555. this._textureHelper.setCommandEncoder(this._uploadEncoder),
  73556. this._bundleList.reset(),
  73557. this._bundleListRenderTarget.reset(),
  73558. e && (2 & i && this._startMainRenderPass(!1),
  73559. 1 & i && this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1),
  73560. t && this._currentRenderTarget && (this._currentRenderPass = null))
  73561. }
  73562. ,
  73563. t.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
  73564. return null === this._currentRenderTarget
  73565. }
  73566. ,
  73567. t.prototype._startRenderTargetRenderPass = function(e, t, i, n, r) {
  73568. var o, a, s, l = e, c = l._depthStencilTexture, u = null == c ? void 0 : c._hardwareTexture, h = null == u ? void 0 : u.underlyingResource, d = null == u ? void 0 : u.msaaTexture, p = null == h ? void 0 : h.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), f = null == d ? void 0 : d.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), _ = [];
  73569. this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
  73570. var m = t && i
  73571. , g = t && n
  73572. , v = t && r;
  73573. if (l._attachments && l.isMulti) {
  73574. this._mrtAttachments && 0 !== this._mrtAttachments.length || (this._mrtAttachments = l._defaultAttachments);
  73575. for (var y = 0; y < this._mrtAttachments.length; ++y) {
  73576. var b = this._mrtAttachments[y]
  73577. , T = l.textures[y]
  73578. , E = null == T ? void 0 : T._hardwareTexture
  73579. , S = null == E ? void 0 : E.underlyingResource;
  73580. if (E && S) {
  73581. var A = V(V({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), {
  73582. format: E.format
  73583. })
  73584. , x = E.msaaTexture
  73585. , R = S.createView(A)
  73586. , C = null == x ? void 0 : x.createView(A);
  73587. _.push({
  73588. view: C || R,
  73589. resolveTarget: x ? R : void 0,
  73590. clearValue: 0 !== b && m ? i : void 0,
  73591. loadOp: 0 !== b && m ? zu.Clear : zu.Load,
  73592. storeOp: Wu.Store
  73593. })
  73594. }
  73595. }
  73596. this._cacheRenderPipeline.setMRT(l.textures, this._mrtAttachments.length),
  73597. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)
  73598. } else {
  73599. var P = (I = l.texture)._hardwareTexture
  73600. , M = P.underlyingResource;
  73601. x = P.msaaTexture,
  73602. R = M.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
  73603. C = null == x ? void 0 : x.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
  73604. _.push({
  73605. view: C || R,
  73606. resolveTarget: x ? R : void 0,
  73607. clearValue: m ? i : void 0,
  73608. loadOp: m ? zu.Clear : zu.Load,
  73609. storeOp: Wu.Store
  73610. })
  73611. }
  73612. if (null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "render target pass", 1),
  73613. this._rttRenderPassWrapper.renderPassDescriptor = {
  73614. colorAttachments: _,
  73615. depthStencilAttachment: c && h ? {
  73616. view: f || p,
  73617. depthClearValue: g ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
  73618. depthLoadOp: g ? zu.Clear : zu.Load,
  73619. depthStoreOp: Wu.Store,
  73620. stencilClearValue: l._depthStencilTextureWithStencil && v ? this._clearStencilValue : void 0,
  73621. stencilLoadOp: l._depthStencilTextureWithStencil && v ? zu.Clear : zu.Load,
  73622. stencilStoreOp: Wu.Store
  73623. } : void 0,
  73624. occlusionQuerySet: (null === (a = this._occlusionQuery) || void 0 === a ? void 0 : a.hasQueries) ? this._occlusionQuery.querySet : void 0
  73625. },
  73626. this._rttRenderPassWrapper.renderPass = this._renderTargetEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),
  73627. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73628. !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
  73629. var I = l.texture;
  73630. console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", I.uniqueId, "width=", I.width, "height=", I.height, this._rttRenderPassWrapper.renderPassDescriptor)
  73631. }
  73632. this._currentRenderPass = this._rttRenderPassWrapper.renderPass,
  73633. null === (s = this._debugFlushPendingCommands) || void 0 === s || s.call(this),
  73634. this._resetCurrentViewport(1),
  73635. this._resetCurrentScissor(1),
  73636. this._resetCurrentStencilRef(1),
  73637. this._resetCurrentColorBlend(1),
  73638. u && fh.HasStencilAspect(u.format) || (this._stencilStateComposer.enabled = !1)
  73639. }
  73640. ,
  73641. t.prototype._endRenderTargetRenderPass = function() {
  73642. var e, t, i;
  73643. if (this._currentRenderPass) {
  73644. var n = this._currentRenderTarget.texture._hardwareTexture;
  73645. this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, n) || this.compatibilityMode || (this._bundleListRenderTarget.run(this._currentRenderPass),
  73646. this._bundleListRenderTarget.reset()),
  73647. this._currentRenderPass.end(),
  73648. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73649. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", null === (t = null === (e = this._currentRenderTarget) || void 0 === e ? void 0 : e.texture) || void 0 === t ? void 0 : t.uniqueId)),
  73650. null === (i = this._debugPopGroup) || void 0 === i || i.call(this, 1),
  73651. this._resetCurrentViewport(1),
  73652. this._resetCurrentScissor(1),
  73653. this._resetCurrentStencilRef(1),
  73654. this._resetCurrentColorBlend(1),
  73655. this._currentRenderPass = null,
  73656. this._rttRenderPassWrapper.reset()
  73657. }
  73658. }
  73659. ,
  73660. t.prototype._getCurrentRenderPass = function() {
  73661. return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1),
  73662. this._currentRenderPass
  73663. }
  73664. ,
  73665. t.prototype._getCurrentRenderPassIndex = function() {
  73666. return null === this._currentRenderPass ? -1 : this._currentRenderPass === this._mainRenderPassWrapper.renderPass ? 0 : 1
  73667. }
  73668. ,
  73669. t.prototype._startMainRenderPass = function(e, t, i, n) {
  73670. var r, o, a;
  73671. this._mainRenderPassWrapper.renderPass && this._endMainRenderPass(),
  73672. this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
  73673. var s = e && t
  73674. , l = e && i
  73675. , c = e && n;
  73676. this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = s ? t : void 0,
  73677. this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = s ? zu.Clear : zu.Load,
  73678. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = l ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
  73679. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = l ? zu.Clear : zu.Load,
  73680. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = c ? this._clearStencilValue : void 0,
  73681. this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = c ? zu.Clear : zu.Load,
  73682. this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = (null === (r = this._occlusionQuery) || void 0 === r ? void 0 : r.hasQueries) ? this._occlusionQuery.querySet : void 0,
  73683. this._swapChainTexture = this._context.getCurrentTexture(),
  73684. this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(this._swapChainTexture),
  73685. this._options.antialiasing ? this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = this._swapChainTexture.createView() : this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = this._swapChainTexture.createView(),
  73686. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73687. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main begin pass - texture width=" + this._mainTextureExtends.width, " height=" + this._mainTextureExtends.height, this._mainRenderPassWrapper.renderPassDescriptor)),
  73688. null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "main pass", 0),
  73689. this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),
  73690. this._mainRenderPassWrapper.renderPass = this._currentRenderPass,
  73691. null === (a = this._debugFlushPendingCommands) || void 0 === a || a.call(this),
  73692. this._resetCurrentViewport(0),
  73693. this._resetCurrentScissor(0),
  73694. this._resetCurrentStencilRef(0),
  73695. this._resetCurrentColorBlend(0),
  73696. this._isStencilEnable || (this._stencilStateComposer.enabled = !1)
  73697. }
  73698. ,
  73699. t.prototype._endMainRenderPass = function() {
  73700. var e;
  73701. null !== this._mainRenderPassWrapper.renderPass && (this._snapshotRendering.endMainRenderPass(),
  73702. this.compatibilityMode || this._snapshotRendering.play || (this._bundleList.run(this._mainRenderPassWrapper.renderPass),
  73703. this._bundleList.reset()),
  73704. this._mainRenderPassWrapper.renderPass.end(),
  73705. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73706. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main end pass")),
  73707. null === (e = this._debugPopGroup) || void 0 === e || e.call(this, 0),
  73708. this._resetCurrentViewport(0),
  73709. this._resetCurrentScissor(0),
  73710. this._resetCurrentStencilRef(0),
  73711. this._resetCurrentColorBlend(0),
  73712. this._mainRenderPassWrapper.renderPass === this._currentRenderPass && (this._currentRenderPass = null),
  73713. this._mainRenderPassWrapper.reset(!1))
  73714. }
  73715. ,
  73716. t.prototype.bindFramebuffer = function(e, t, i, n, r, o, s) {
  73717. var l, c;
  73718. void 0 === t && (t = 0),
  73719. void 0 === o && (o = 0),
  73720. void 0 === s && (s = 0);
  73721. var u = null === (l = e.texture) || void 0 === l ? void 0 : l._hardwareTexture;
  73722. u ? (this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
  73723. this._currentRenderTarget = e,
  73724. u._currentLayer = e.isCube ? 6 * s + t : s,
  73725. this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = u,
  73726. this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? fh.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0,
  73727. this._setDepthTextureFormat(this._rttRenderPassWrapper),
  73728. this._setColorFormat(this._rttRenderPassWrapper),
  73729. this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
  73730. format: this._colorFormat,
  73731. dimension: vu.E2d,
  73732. mipLevelCount: 1,
  73733. baseArrayLayer: e.isCube ? 6 * s + t : s,
  73734. baseMipLevel: o,
  73735. arrayLayerCount: 1,
  73736. aspect: yu.All
  73737. },
  73738. this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
  73739. format: this._depthTextureFormat,
  73740. dimension: vu.E2d,
  73741. mipLevelCount: 1,
  73742. baseArrayLayer: e.isCube ? 6 * s + t : s,
  73743. baseMipLevel: 0,
  73744. arrayLayerCount: 1,
  73745. aspect: yu.All
  73746. },
  73747. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73748. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - bindFramebuffer called - internalTexture.uniqueId=", null === (c = e.texture) || void 0 === c ? void 0 : c.uniqueId, "face=", t, "lodLevel=", o, "layer=", s, this._rttRenderPassWrapper.colorAttachmentViewDescriptor, this._rttRenderPassWrapper.depthAttachmentViewDescriptor)),
  73749. this._currentRenderPass = null,
  73750. this.snapshotRendering && this.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this._getCurrentRenderPass(),
  73751. this._cachedViewport && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
  73752. o && (i /= Math.pow(2, o))),
  73753. n || (n = e.height,
  73754. o && (n /= Math.pow(2, o))),
  73755. this._viewport(0, 0, i, n)),
  73756. this.wipeCaches()) : this.dbgSanityChecks && console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", e, u)
  73757. }
  73758. ,
  73759. t.prototype.unBindFramebuffer = function(e, t, i) {
  73760. var n, r;
  73761. void 0 === t && (t = !1);
  73762. var o = this._currentRenderTarget;
  73763. this._currentRenderTarget = null,
  73764. i && i(),
  73765. this._currentRenderTarget = o,
  73766. this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(),
  73767. !(null === (n = e.texture) || void 0 === n ? void 0 : n.generateMipMaps) || t || e.isCube || this._generateMipmaps(e.texture),
  73768. this._currentRenderTarget = null,
  73769. this._onAfterUnbindFrameBufferObservable.notifyObservers(this),
  73770. this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
  73771. (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - unBindFramebuffer called - internalTexture.uniqueId=", null === (r = e.texture) || void 0 === r ? void 0 : r.uniqueId)),
  73772. this._mrtAttachments = [],
  73773. this._cacheRenderPipeline.setMRT([]),
  73774. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments),
  73775. this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  73776. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  73777. this._setColorFormat(this._mainRenderPassWrapper)
  73778. }
  73779. ,
  73780. t.prototype.restoreDefaultFramebuffer = function() {
  73781. this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : (this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  73782. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  73783. this._setColorFormat(this._mainRenderPassWrapper)),
  73784. this._currentRenderPass && this._cachedViewport && this.setViewport(this._cachedViewport),
  73785. this.wipeCaches()
  73786. }
  73787. ,
  73788. t.prototype._setColorFormat = function(e) {
  73789. var t = e.colorAttachmentGPUTextures[0].format;
  73790. this._cacheRenderPipeline.setColorFormat(t),
  73791. this._colorFormat !== t && (this._colorFormat = t)
  73792. }
  73793. ,
  73794. t.prototype._setDepthTextureFormat = function(e) {
  73795. this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat),
  73796. this._depthTextureFormat !== e.depthTextureFormat && (this._depthTextureFormat = e.depthTextureFormat)
  73797. }
  73798. ,
  73799. t.prototype.setDitheringState = function() {}
  73800. ,
  73801. t.prototype.setRasterizerState = function() {}
  73802. ,
  73803. t.prototype.setState = function(e, t, i, n, r, o, a) {
  73804. var s, l;
  73805. void 0 === t && (t = 0),
  73806. void 0 === n && (n = !1),
  73807. void 0 === a && (a = 0),
  73808. (this._depthCullingState.cull !== e || i) && (this._depthCullingState.cull = e);
  73809. var c = null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? 1 : 2;
  73810. (this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c),
  73811. this.setZOffset(t),
  73812. this.setZOffsetUnits(a);
  73813. var u = n ? this._currentRenderTarget ? 1 : 2 : this._currentRenderTarget ? 2 : 1;
  73814. (this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u),
  73815. this._stencilStateComposer.stencilMaterial = o
  73816. }
  73817. ,
  73818. t.prototype._applyRenderPassChanges = function(e, t) {
  73819. var i, n = this._mustUpdateViewport(e), r = this._mustUpdateScissor(e), o = !!this._stencilStateComposer.enabled && this._mustUpdateStencilRef(e), a = !!this._alphaState.alphaBlend && this._mustUpdateBlendColor(e);
  73820. t ? (n && t.addItem(new Fh(this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w)),
  73821. r && t.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
  73822. o && t.addItem(new Bh(null !== (i = this._stencilStateComposer.funcRef) && void 0 !== i ? i : 0)),
  73823. a && t.addItem(new Uh(this._alphaState._blendConstants.slice()))) : (n && this._applyViewport(e),
  73824. r && this._applyScissor(e),
  73825. o && this._applyStencilRef(e),
  73826. a && this._applyBlendColor(e))
  73827. }
  73828. ,
  73829. t.prototype._draw = function(e, t, i, n, r) {
  73830. var o, s = this._getCurrentRenderPass(), l = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget;
  73831. this.applyStates();
  73832. var c = this._currentEffect._pipelineContext;
  73833. if (this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, Qu.InternalsUBOName),
  73834. c.uniformBuffer && (c.uniformBuffer.update(),
  73835. this.bindUniformBufferBase(c.uniformBuffer.getBuffer(), 0, Qu.LeftOvertUBOName)),
  73836. this._snapshotRendering.play)
  73837. this._reportDrawCall();
  73838. else {
  73839. !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0);
  73840. var u = s;
  73841. if (!this.compatibilityMode && this._currentDrawContext.fastBundle || this._snapshotRendering.record) {
  73842. if (this._applyRenderPassChanges(s, l),
  73843. !this._snapshotRendering.record)
  73844. return this._counters.numBundleReuseNonCompatMode++,
  73845. this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(n, r || 1, i),
  73846. l.addBundle(this._currentDrawContext.fastBundle),
  73847. void this._reportDrawCall();
  73848. u = l.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount),
  73849. l.numDrawCalls++
  73850. }
  73851. var h = 0;
  73852. if (!this._caps.textureFloatLinearFiltering && this._currentMaterialContext.hasFloatTextures)
  73853. for (var d = 1, p = 0; p < c.shaderProcessingContext.textureNames.length; ++p) {
  73854. var f = c.shaderProcessingContext.textureNames[p]
  73855. , _ = null === (o = this._currentMaterialContext.textures[f]) || void 0 === o ? void 0 : o.texture;
  73856. (null == _ ? void 0 : _.type) === a.TEXTURETYPE_FLOAT && (h |= d),
  73857. d <<= 1
  73858. }
  73859. var m = this._cacheRenderPipeline.getRenderPipeline(t, this._currentEffect, this.currentSampleCount, h)
  73860. , g = this._cacheBindGroups.getBindGroups(c, this._currentDrawContext, this._currentMaterialContext);
  73861. this._snapshotRendering.record || (this._applyRenderPassChanges(s, this.compatibilityMode ? null : l),
  73862. this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++,
  73863. u = this._device.createRenderBundleEncoder({
  73864. colorFormats: this._cacheRenderPipeline.colorFormats,
  73865. depthStencilFormat: this._depthTextureFormat,
  73866. sampleCount: this.currentSampleCount
  73867. }))),
  73868. u.setPipeline(m),
  73869. this._currentIndexBuffer && u.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? Bu.Uint32 : Bu.Uint16, 0);
  73870. for (var v = this._cacheRenderPipeline.vertexBuffers, y = 0; y < v.length; y++) {
  73871. var b = v[y]
  73872. , T = b.getBuffer();
  73873. T && u.setVertexBuffer(y, T.underlyingResource, b._validOffsetRange ? 0 : b.byteOffset)
  73874. }
  73875. for (p = 0; p < g.length; p++)
  73876. u.setBindGroup(p, g[p]);
  73877. var E = !this.compatibilityMode && !this._snapshotRendering.record;
  73878. E && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(n, r || 1, i),
  73879. 0 === e ? u.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : u.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : 0 === e ? u.drawIndexed(n, r || 1, i, 0, 0) : u.draw(n, r || 1, i, 0),
  73880. E && (this._currentDrawContext.fastBundle = u.finish(),
  73881. l.addBundle(this._currentDrawContext.fastBundle)),
  73882. this._reportDrawCall()
  73883. }
  73884. }
  73885. ,
  73886. t.prototype.drawElementsType = function(e, t, i, n) {
  73887. void 0 === n && (n = 1),
  73888. this._draw(0, e, t, i, n)
  73889. }
  73890. ,
  73891. t.prototype.drawArraysType = function(e, t, i, n) {
  73892. void 0 === n && (n = 1),
  73893. this._currentIndexBuffer = null,
  73894. this._draw(1, e, t, i, n)
  73895. }
  73896. ,
  73897. t.prototype.dispose = function() {
  73898. var t, i, n;
  73899. null === (t = this._mainTexture) || void 0 === t || t.destroy(),
  73900. null === (i = this._mainTextureLastCopy) || void 0 === i || i.destroy(),
  73901. null === (n = this._depthTexture) || void 0 === n || n.destroy(),
  73902. e.prototype.dispose.call(this)
  73903. }
  73904. ,
  73905. t.prototype.getRenderWidth = function(e) {
  73906. return void 0 === e && (e = !1),
  73907. !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._canvas.width
  73908. }
  73909. ,
  73910. t.prototype.getRenderHeight = function(e) {
  73911. return void 0 === e && (e = !1),
  73912. !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._canvas.height
  73913. }
  73914. ,
  73915. t.prototype.getRenderingCanvas = function() {
  73916. return this._canvas
  73917. }
  73918. ,
  73919. t.prototype.getError = function() {
  73920. return 0
  73921. }
  73922. ,
  73923. t.prototype.bindSamplers = function() {}
  73924. ,
  73925. t.prototype._bindTextureDirectly = function() {
  73926. return !1
  73927. }
  73928. ,
  73929. t.prototype.areAllEffectsReady = function() {
  73930. return !0
  73931. }
  73932. ,
  73933. t.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
  73934. t()
  73935. }
  73936. ,
  73937. t.prototype._isRenderingStateCompiled = function() {
  73938. return !0
  73939. }
  73940. ,
  73941. t.prototype._getUnpackAlignement = function() {
  73942. return 1
  73943. }
  73944. ,
  73945. t.prototype._unpackFlipY = function() {}
  73946. ,
  73947. t.prototype._bindUnboundFramebuffer = function() {
  73948. throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead"
  73949. }
  73950. ,
  73951. t.prototype._getSamplingParameters = function() {
  73952. throw "_getSamplingParameters is not available in WebGPU"
  73953. }
  73954. ,
  73955. t.prototype.getUniforms = function() {
  73956. return []
  73957. }
  73958. ,
  73959. t.prototype.setIntArray = function() {
  73960. return !1
  73961. }
  73962. ,
  73963. t.prototype.setIntArray2 = function() {
  73964. return !1
  73965. }
  73966. ,
  73967. t.prototype.setIntArray3 = function() {
  73968. return !1
  73969. }
  73970. ,
  73971. t.prototype.setIntArray4 = function() {
  73972. return !1
  73973. }
  73974. ,
  73975. t.prototype.setArray = function() {
  73976. return !1
  73977. }
  73978. ,
  73979. t.prototype.setArray2 = function() {
  73980. return !1
  73981. }
  73982. ,
  73983. t.prototype.setArray3 = function() {
  73984. return !1
  73985. }
  73986. ,
  73987. t.prototype.setArray4 = function() {
  73988. return !1
  73989. }
  73990. ,
  73991. t.prototype.setMatrices = function() {
  73992. return !1
  73993. }
  73994. ,
  73995. t.prototype.setMatrix3x3 = function() {
  73996. return !1
  73997. }
  73998. ,
  73999. t.prototype.setMatrix2x2 = function() {
  74000. return !1
  74001. }
  74002. ,
  74003. t.prototype.setFloat = function() {
  74004. return !1
  74005. }
  74006. ,
  74007. t.prototype.setFloat2 = function() {
  74008. return !1
  74009. }
  74010. ,
  74011. t.prototype.setFloat3 = function() {
  74012. return !1
  74013. }
  74014. ,
  74015. t.prototype.setFloat4 = function() {
  74016. return !1
  74017. }
  74018. ,
  74019. t._GLSLslangDefaultOptions = {
  74020. jsPath: "https://preview.babylonjs.com/glslang/glslang.js",
  74021. wasmPath: "https://preview.babylonjs.com/glslang/glslang.wasm"
  74022. },
  74023. t.UseTWGSL = !0,
  74024. t
  74025. }(vr);
  74026. Qh.prototype.setAlphaMode = function(e, t) {
  74027. if (void 0 === t && (t = !1),
  74028. this._alphaMode !== e || !(e === a.ALPHA_DISABLE && !this._alphaState.alphaBlend || e !== a.ALPHA_DISABLE && this._alphaState.alphaBlend)) {
  74029. switch (e) {
  74030. case a.ALPHA_DISABLE:
  74031. this._alphaState.alphaBlend = !1;
  74032. break;
  74033. case a.ALPHA_PREMULTIPLIED:
  74034. this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1),
  74035. this._alphaState.alphaBlend = !0;
  74036. break;
  74037. case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
  74038. this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
  74039. this._alphaState.alphaBlend = !0;
  74040. break;
  74041. case a.ALPHA_COMBINE:
  74042. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1),
  74043. this._alphaState.alphaBlend = !0;
  74044. break;
  74045. case a.ALPHA_ONEONE:
  74046. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1),
  74047. this._alphaState.alphaBlend = !0;
  74048. break;
  74049. case a.ALPHA_ADD:
  74050. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, 1, 0, 1),
  74051. this._alphaState.alphaBlend = !0;
  74052. break;
  74053. case a.ALPHA_SUBTRACT:
  74054. this._alphaState.setAlphaBlendFunctionParameters(0, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1),
  74055. this._alphaState.alphaBlend = !0;
  74056. break;
  74057. case a.ALPHA_MULTIPLY:
  74058. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_COLOR, 0, 1, 1),
  74059. this._alphaState.alphaBlend = !0;
  74060. break;
  74061. case a.ALPHA_MAXIMIZED:
  74062. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1),
  74063. this._alphaState.alphaBlend = !0;
  74064. break;
  74065. case a.ALPHA_INTERPOLATE:
  74066. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA),
  74067. this._alphaState.alphaBlend = !0;
  74068. break;
  74069. case a.ALPHA_SCREENMODE:
  74070. this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
  74071. this._alphaState.alphaBlend = !0;
  74072. break;
  74073. case a.ALPHA_ONEONE_ONEONE:
  74074. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1),
  74075. this._alphaState.alphaBlend = !0;
  74076. break;
  74077. case a.ALPHA_ALPHATOCOLOR:
  74078. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_ALPHA, 1, 0, 0),
  74079. this._alphaState.alphaBlend = !0;
  74080. break;
  74081. case a.ALPHA_REVERSEONEMINUS:
  74082. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
  74083. this._alphaState.alphaBlend = !0;
  74084. break;
  74085. case a.ALPHA_SRC_DSTONEMINUSSRCALPHA:
  74086. this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
  74087. this._alphaState.alphaBlend = !0;
  74088. break;
  74089. case a.ALPHA_ONEONE_ONEZERO:
  74090. this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0),
  74091. this._alphaState.alphaBlend = !0;
  74092. break;
  74093. case a.ALPHA_EXCLUSION:
  74094. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 0, 1),
  74095. this._alphaState.alphaBlend = !0;
  74096. break;
  74097. case a.ALPHA_LAYER_ACCUMULATE:
  74098. this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
  74099. this._alphaState.alphaBlend = !0
  74100. }
  74101. t || (this.setDepthWrite(e === vr.ALPHA_DISABLE),
  74102. this._cacheRenderPipeline.setDepthWriteEnabled(e === vr.ALPHA_DISABLE)),
  74103. this._alphaMode = e,
  74104. this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),
  74105. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
  74106. }
  74107. }
  74108. ,
  74109. Qh.prototype.setAlphaEquation = function(e) {
  74110. vr.prototype.setAlphaEquation.call(this, e),
  74111. this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
  74112. }
  74113. ;
  74114. var qh = function() {
  74115. function e(t, i) {
  74116. this._device = t,
  74117. this._cacheSampler = i,
  74118. this.uniqueId = e._Counter++,
  74119. this._bindGroupEntries = [],
  74120. this.clear()
  74121. }
  74122. return e.prototype.getBindGroups = function(e, t, i) {
  74123. if (!i)
  74124. throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");
  74125. if (0 === this._bindGroups.length) {
  74126. var n = this._bindGroupEntries.length > 0;
  74127. for (var r in e) {
  74128. var o = e[r]
  74129. , a = i[r]
  74130. , s = a.group
  74131. , l = a.binding
  74132. , c = o.type
  74133. , u = o.object
  74134. , h = o.indexInGroupEntries;
  74135. switch ((v = this._bindGroupEntries[s]) || (v = this._bindGroupEntries[s] = []),
  74136. c) {
  74137. case _l.Sampler:
  74138. var d = u;
  74139. void 0 !== h && n ? v[h].resource = this._cacheSampler.getSampler(d) : (o.indexInGroupEntries = v.length,
  74140. v.push({
  74141. binding: l,
  74142. resource: this._cacheSampler.getSampler(d)
  74143. }));
  74144. break;
  74145. case _l.Texture:
  74146. case _l.TextureWithoutSampler:
  74147. var p = (f = u)._texture._hardwareTexture;
  74148. void 0 !== h && n ? (c === _l.Texture && (v[h++].resource = this._cacheSampler.getSampler(f._texture)),
  74149. v[h].resource = p.view) : (o.indexInGroupEntries = v.length,
  74150. c === _l.Texture && v.push({
  74151. binding: l - 1,
  74152. resource: this._cacheSampler.getSampler(f._texture)
  74153. }),
  74154. v.push({
  74155. binding: l,
  74156. resource: p.view
  74157. }));
  74158. break;
  74159. case _l.StorageTexture:
  74160. var f;
  74161. 0 == ((p = (f = u)._texture._hardwareTexture).textureAdditionalUsages & gu.StorageBinding) && K.Error("computeDispatch: The texture (name=".concat(f.name, ", uniqueId=").concat(f.uniqueId, ") is not a storage texture!"), 50),
  74162. void 0 !== h && n ? v[h].resource = p.viewForWriting : (o.indexInGroupEntries = v.length,
  74163. v.push({
  74164. binding: l,
  74165. resource: p.viewForWriting
  74166. }));
  74167. break;
  74168. case _l.UniformBuffer:
  74169. case _l.StorageBuffer:
  74170. var _ = (_l.UniformBuffer,
  74171. u).getBuffer()
  74172. , m = _.underlyingResource;
  74173. void 0 !== h && n ? (v[h].resource.buffer = m,
  74174. v[h].resource.size = _.capacity) : (o.indexInGroupEntries = v.length,
  74175. v.push({
  74176. binding: l,
  74177. resource: {
  74178. buffer: m,
  74179. offset: 0,
  74180. size: _.capacity
  74181. }
  74182. }))
  74183. }
  74184. }
  74185. for (var g = 0; g < this._bindGroupEntries.length; ++g) {
  74186. var v;
  74187. (v = this._bindGroupEntries[g]) ? this._bindGroups[g] = this._device.createBindGroup({
  74188. layout: t.getBindGroupLayout(g),
  74189. entries: v
  74190. }) : this._bindGroups[g] = void 0
  74191. }
  74192. this._bindGroups.length = this._bindGroupEntries.length
  74193. }
  74194. return this._bindGroups
  74195. }
  74196. ,
  74197. e.prototype.clear = function() {
  74198. this._bindGroups = []
  74199. }
  74200. ,
  74201. e._Counter = 0,
  74202. e
  74203. }()
  74204. , Zh = function() {
  74205. function e(e) {
  74206. this._name = "unnamed",
  74207. this.engine = e
  74208. }
  74209. return Object.defineProperty(e.prototype, "isAsync", {
  74210. get: function() {
  74211. return !1
  74212. },
  74213. enumerable: !1,
  74214. configurable: !0
  74215. }),
  74216. Object.defineProperty(e.prototype, "isReady", {
  74217. get: function() {
  74218. return !!this.stage
  74219. },
  74220. enumerable: !1,
  74221. configurable: !0
  74222. }),
  74223. e.prototype._getComputeShaderCode = function() {
  74224. var e;
  74225. return null === (e = this.sources) || void 0 === e ? void 0 : e.compute
  74226. }
  74227. ,
  74228. e.prototype.dispose = function() {}
  74229. ,
  74230. e
  74231. }();
  74232. Qh.prototype.createComputeContext = function() {
  74233. return new qh(this._device,this._cacheSampler)
  74234. }
  74235. ,
  74236. Qh.prototype.createComputeEffect = function(e, t) {
  74237. var i = (e.computeElement || e.compute || e.computeToken || e.computeSource || e) + "@" + t.defines;
  74238. if (this._compiledComputeEffects[i]) {
  74239. var n = this._compiledComputeEffects[i];
  74240. return t.onCompiled && n.isReady() && t.onCompiled(n),
  74241. n
  74242. }
  74243. var r = new ml(e,t,this,i);
  74244. return this._compiledComputeEffects[i] = r,
  74245. r
  74246. }
  74247. ,
  74248. Qh.prototype.createComputePipelineContext = function() {
  74249. return new Zh(this)
  74250. }
  74251. ,
  74252. Qh.prototype.areAllComputeEffectsReady = function() {
  74253. for (var e in this._compiledComputeEffects)
  74254. if (!this._compiledComputeEffects[e].isReady())
  74255. return !1;
  74256. return !0
  74257. }
  74258. ,
  74259. Qh.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
  74260. var s = this;
  74261. if (this._currentRenderTarget)
  74262. this._onAfterUnbindFrameBufferObservable.addOnce((function() {
  74263. s.computeDispatch(e, t, i, n, r, o, a)
  74264. }
  74265. ));
  74266. else {
  74267. var l = e._pipelineContext
  74268. , c = t;
  74269. l.computePipeline || (l.computePipeline = this._device.createComputePipeline({
  74270. compute: l.stage
  74271. }));
  74272. var u = this._renderTargetEncoder.beginComputePass();
  74273. u.setPipeline(l.computePipeline);
  74274. for (var h = c.getBindGroups(i, l.computePipeline, a), d = 0; d < h.length; ++d) {
  74275. var p = h[d];
  74276. p && u.setBindGroup(d, p)
  74277. }
  74278. u.dispatch(n, r, o),
  74279. u.end()
  74280. }
  74281. }
  74282. ,
  74283. Qh.prototype.releaseComputeEffects = function() {
  74284. for (var e in this._compiledComputeEffects) {
  74285. var t = this._compiledComputeEffects[e].getPipelineContext();
  74286. this._deleteComputePipelineContext(t)
  74287. }
  74288. this._compiledComputeEffects = {}
  74289. }
  74290. ,
  74291. Qh.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {
  74292. var o = e;
  74293. this.dbgShowShaderCode && (console.log(n),
  74294. console.log(t)),
  74295. o.sources = {
  74296. compute: t,
  74297. rawCompute: i
  74298. },
  74299. o.stage = this._createComputePipelineStageDescriptor(t, n, r)
  74300. }
  74301. ,
  74302. Qh.prototype._releaseComputeEffect = function(e) {
  74303. this._compiledComputeEffects[e._key] && (delete this._compiledComputeEffects[e._key],
  74304. this._deleteComputePipelineContext(e.getPipelineContext()))
  74305. }
  74306. ,
  74307. Qh.prototype._rebuildComputeEffects = function() {
  74308. for (var e in this._compiledComputeEffects) {
  74309. var t = this._compiledComputeEffects[e];
  74310. t._pipelineContext = null,
  74311. t._wasPreviouslyReady = !1,
  74312. t._prepareEffect()
  74313. }
  74314. }
  74315. ,
  74316. Qh.prototype._deleteComputePipelineContext = function(e) {
  74317. e && e.dispose()
  74318. }
  74319. ,
  74320. Qh.prototype._createComputePipelineStageDescriptor = function(e, t, i) {
  74321. return t = t ? "//" + t.split("\n").join("\n//") + "\n" : "",
  74322. {
  74323. module: this._device.createShaderModule({
  74324. code: t + e
  74325. }),
  74326. entryPoint: i
  74327. }
  74328. }
  74329. ,
  74330. Qh.prototype._createDepthStencilCubeTexture = function(e, t) {
  74331. var i = new Lt(this,At.DepthStencil);
  74332. i.isCube = !0;
  74333. var n = V({
  74334. bilinearFiltering: !1,
  74335. comparisonFunction: 0,
  74336. generateStencil: !1,
  74337. samples: 1
  74338. }, t);
  74339. return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT,
  74340. this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
  74341. this._textureHelper.createGPUTextureForInternalTexture(i),
  74342. this._internalTexturesCache.push(i),
  74343. i
  74344. }
  74345. ,
  74346. Qh.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d) {
  74347. var p = this;
  74348. return void 0 === r && (r = null),
  74349. void 0 === o && (o = null),
  74350. void 0 === s && (s = null),
  74351. void 0 === l && (l = !1),
  74352. void 0 === c && (c = 0),
  74353. void 0 === u && (u = 0),
  74354. void 0 === h && (h = null),
  74355. void 0 === d && (d = !1),
  74356. this.createCubeTextureBase(e, t, i, !!n, r, o, a, s, l, c, u, h, null, (function(e, t) {
  74357. var i = t
  74358. , o = i[0].width
  74359. , s = o;
  74360. p._setCubeMapTextureParams(e, !n),
  74361. e.format = null != a ? a : -1;
  74362. var l = p._textureHelper.createGPUTextureForInternalTexture(e, o, s);
  74363. p._textureHelper.updateCubeTextures(i, l.underlyingResource, o, s, l.format, !1, !1, 0, 0),
  74364. n || p._generateMipmaps(e, p._uploadEncoder),
  74365. e.isReady = !0,
  74366. e.onLoadedObservable.notifyObservers(e),
  74367. e.onLoadedObservable.clear(),
  74368. r && r()
  74369. }
  74370. ), !!d)
  74371. }
  74372. ,
  74373. Qh.prototype._setCubeMapTextureParams = function(e, t, i) {
  74374. e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_BILINEAR_SAMPLINGMODE,
  74375. e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  74376. e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  74377. i && (e._maxLodLevel = i)
  74378. }
  74379. ,
  74380. Qh.prototype._debugPushGroup = function(e, t) {
  74381. this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).pushDebugGroup(e) : this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(e) : this._pendingDebugCommands.push(["push", e]))
  74382. }
  74383. ,
  74384. Qh.prototype._debugPopGroup = function(e) {
  74385. this._options.enableGPUDebugMarkers && (0 === e || 1 === e ? (0 === e ? this._renderEncoder : this._renderTargetEncoder).popDebugGroup() : this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null]))
  74386. }
  74387. ,
  74388. Qh.prototype._debugInsertMarker = function(e, t) {
  74389. this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).insertDebugMarker(e) : this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(e) : this._pendingDebugCommands.push(["insert", e]))
  74390. }
  74391. ,
  74392. Qh.prototype._debugFlushPendingCommands = function() {
  74393. for (var e = 0; e < this._pendingDebugCommands.length; ++e) {
  74394. var t = this._pendingDebugCommands[e]
  74395. , i = t[0]
  74396. , n = t[1];
  74397. switch (i) {
  74398. case "push":
  74399. this._debugPushGroup(n);
  74400. break;
  74401. case "pop":
  74402. this._debugPopGroup();
  74403. break;
  74404. case "insert":
  74405. this._debugInsertMarker(n)
  74406. }
  74407. }
  74408. this._pendingDebugCommands.length = 0
  74409. }
  74410. ,
  74411. Qh.prototype.updateDynamicIndexBuffer = function(e, t, i) {
  74412. void 0 === i && (i = 0);
  74413. var n, r = e;
  74414. n = t instanceof Uint16Array ? e.is32Bits ? Uint32Array.from(t) : t : t instanceof Uint32Array ? e.is32Bits ? t : Uint16Array.from(t) : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
  74415. this._bufferManager.setSubData(r, i, n)
  74416. }
  74417. ,
  74418. Qh.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
  74419. var r, o = e;
  74420. void 0 === i && (i = 0),
  74421. void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
  74422. this._bufferManager.setSubData(o, i, r, 0, n)
  74423. }
  74424. ,
  74425. Qh.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
  74426. var s;
  74427. if (void 0 === n && (n = !1),
  74428. e) {
  74429. var l = t.width
  74430. , c = t.height
  74431. , u = e._hardwareTexture;
  74432. (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (u = this._textureHelper.createGPUTextureForInternalTexture(e, l, c)),
  74433. this._textureHelper.updateTexture(t, e, l, c, e.depth, u.format, 0, 0, i, n, 0, 0, a),
  74434. e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
  74435. e.isReady = !0
  74436. }
  74437. }
  74438. ;
  74439. var Jh = function(e) {
  74440. function t(t) {
  74441. return e.call(this, t) || this
  74442. }
  74443. return U(t, e),
  74444. t
  74445. }(Mh);
  74446. function $h(e, t, i, n) {
  74447. var r, o = 1;
  74448. n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
  74449. o = 15360) : r = n === a.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * i * 4) : new Uint8Array(t * i * 4);
  74450. for (var s = 0; s < t; s++)
  74451. for (var l = 0; l < i; l++) {
  74452. var c = 3 * (l * t + s)
  74453. , u = 4 * (l * t + s);
  74454. r[u + 0] = e[c + 0],
  74455. r[u + 1] = e[c + 1],
  74456. r[u + 2] = e[c + 2],
  74457. r[u + 3] = o
  74458. }
  74459. return r
  74460. }
  74461. Mt.prototype.setExternalTexture = function(e, t) {
  74462. this._engine.setExternalTexture(e, t)
  74463. }
  74464. ,
  74465. Qh.prototype.createExternalTexture = function(e) {
  74466. return new Jh(e)
  74467. }
  74468. ,
  74469. Qh.prototype.setExternalTexture = function(e, t) {
  74470. t ? this._setInternalTexture(e, t) : this._currentMaterialContext.setTexture(e, null)
  74471. }
  74472. ,
  74473. Qh.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
  74474. void 0 === t && (t = !1),
  74475. i && i();
  74476. var n = e._attachments.length;
  74477. this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass();
  74478. for (var r = 0; r < n; r++) {
  74479. var o = e.textures[r];
  74480. !o.generateMipMaps || t || o.isCube || this._generateMipmaps(o)
  74481. }
  74482. this._currentRenderTarget = null,
  74483. this._mrtAttachments = [],
  74484. this._cacheRenderPipeline.setMRT([]),
  74485. this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments),
  74486. this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
  74487. this._setDepthTextureFormat(this._mainRenderPassWrapper),
  74488. this._setColorFormat(this._mainRenderPassWrapper)
  74489. }
  74490. ,
  74491. Qh.prototype.createMultipleRenderTarget = function(e, t, i) {
  74492. var n, r = !1, o = !0, s = !1, l = !1, c = a.TEXTUREFORMAT_DEPTH16, u = 1, h = a.TEXTURETYPE_UNSIGNED_INT, d = a.TEXTURE_TRILINEAR_SAMPLINGMODE, p = new Array, f = new Array, _ = this._createHardwareRenderTargetWrapper(!0, !1, e);
  74493. void 0 !== t && (r = void 0 !== t.generateMipMaps && t.generateMipMaps,
  74494. o = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
  74495. s = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer,
  74496. l = void 0 !== t.generateDepthTexture && t.generateDepthTexture,
  74497. u = t.textureCount || 1,
  74498. c = null !== (n = t.depthTextureFormat) && void 0 !== n ? n : a.TEXTUREFORMAT_DEPTH16,
  74499. t.types && (p = t.types),
  74500. t.samplingModes && (f = t.samplingModes));
  74501. var m = e.width || e
  74502. , g = e.height || e
  74503. , v = null;
  74504. (o || s || l) && (v = _.createDepthStencilTexture(0, !1, s, 1, c));
  74505. var y = []
  74506. , b = []
  74507. , T = [];
  74508. _._generateDepthBuffer = o,
  74509. _._generateStencilBuffer = s,
  74510. _._attachments = b,
  74511. _._defaultAttachments = T;
  74512. for (var E = 0; E < u; E++) {
  74513. var S = f[E] || d
  74514. , A = p[E] || h;
  74515. (A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (A !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (S = a.TEXTURE_NEAREST_SAMPLINGMODE),
  74516. A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (A = a.TEXTURETYPE_UNSIGNED_INT,
  74517. K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
  74518. var x = new Lt(this,At.MultiRenderTarget);
  74519. y.push(x),
  74520. b.push(E + 1),
  74521. T.push(i ? E + 1 : 0 === E ? 1 : 0),
  74522. x.baseWidth = m,
  74523. x.baseHeight = g,
  74524. x.width = m,
  74525. x.height = g,
  74526. x.isReady = !0,
  74527. x.samples = 1,
  74528. x.generateMipMaps = r,
  74529. x.samplingMode = S,
  74530. x.type = A,
  74531. x._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  74532. x._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  74533. this._internalTexturesCache.push(x),
  74534. this._textureHelper.createGPUTextureForInternalTexture(x)
  74535. }
  74536. return v && (v.incrementReferences(),
  74537. y.push(v),
  74538. this._internalTexturesCache.push(v)),
  74539. _.setTextures(y),
  74540. _
  74541. }
  74542. ,
  74543. Qh.prototype.updateMultipleRenderTargetTextureSampleCount = function(e, t) {
  74544. if (!e || !e.textures || e.textures[0].samples === t)
  74545. return t;
  74546. var i = e.textures.length;
  74547. if (0 === i)
  74548. return 1;
  74549. t = Math.min(t, this.getCaps().maxMSAASamples);
  74550. for (var n = 0; n < i; ++n) {
  74551. var r = e.textures[n];
  74552. this._textureHelper.createMSAATexture(r, t),
  74553. r.samples = t
  74554. }
  74555. return e._depthStencilTexture && e._depthStencilTexture !== e.textures[e.textures.length - 1] && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t),
  74556. e._depthStencilTexture.samples = t),
  74557. t
  74558. }
  74559. ,
  74560. Qh.prototype.bindAttachments = function(e) {
  74561. 0 !== e.length && this._currentRenderTarget && (this._mrtAttachments = e,
  74562. this._currentRenderPass && this._cacheRenderPipeline.setMRTAttachments(e))
  74563. }
  74564. ,
  74565. Qh.prototype.buildTextureLayout = function(e) {
  74566. for (var t = [], i = 0; i < e.length; i++)
  74567. e[i] ? t.push(i + 1) : t.push(0);
  74568. return t
  74569. }
  74570. ,
  74571. Qh.prototype.restoreSingleAttachment = function() {}
  74572. ,
  74573. Qh.prototype.restoreSingleAttachmentForRenderTarget = function() {}
  74574. ,
  74575. Qh.prototype.getGPUFrameTimeCounter = function() {
  74576. return this._timestampQuery.gpuFrameTimeCounter
  74577. }
  74578. ,
  74579. Qh.prototype.captureGPUFrameTime = function(e) {
  74580. this._timestampQuery.enable = e && !!this._caps.timerQuery
  74581. }
  74582. ,
  74583. Qh.prototype.createQuery = function() {
  74584. return this._occlusionQuery.createQuery()
  74585. }
  74586. ,
  74587. Qh.prototype.deleteQuery = function(e) {
  74588. return this._occlusionQuery.deleteQuery(e),
  74589. this
  74590. }
  74591. ,
  74592. Qh.prototype.isQueryResultAvailable = function(e) {
  74593. return this._occlusionQuery.isQueryResultAvailable(e)
  74594. }
  74595. ,
  74596. Qh.prototype.getQueryResult = function(e) {
  74597. return this._occlusionQuery.getQueryResult(e)
  74598. }
  74599. ,
  74600. Qh.prototype.beginOcclusionQuery = function(e, t) {
  74601. var i;
  74602. return this.compatibilityMode ? !!this._occlusionQuery.canBeginQuery && (null === (i = this._currentRenderPass) || void 0 === i || i.beginOcclusionQuery(t),
  74603. !0) : ((0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new Vh(t)),
  74604. !0)
  74605. }
  74606. ,
  74607. Qh.prototype.endOcclusionQuery = function() {
  74608. var e;
  74609. return this.compatibilityMode ? null === (e = this._currentRenderPass) || void 0 === e || e.endOcclusionQuery() : (0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new kh),
  74610. this
  74611. }
  74612. ,
  74613. Qh.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
  74614. void 0 === l && (l = null),
  74615. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  74616. void 0 === u && (u = 0);
  74617. var h = new Lt(this,At.Raw);
  74618. return h.baseWidth = t,
  74619. h.baseHeight = i,
  74620. h.width = t,
  74621. h.height = i,
  74622. h.format = n,
  74623. h.generateMipMaps = r,
  74624. h.samplingMode = s,
  74625. h.invertY = o,
  74626. h._compression = l,
  74627. h.type = c,
  74628. this._doNotHandleContextLost || (h._bufferView = e),
  74629. this._textureHelper.createGPUTextureForInternalTexture(h, t, i, void 0, u),
  74630. this.updateRawTexture(h, e, n, o, l, c),
  74631. this._internalTexturesCache.push(h),
  74632. h
  74633. }
  74634. ,
  74635. Qh.prototype.updateRawTexture = function(e, t, i, n, r, o) {
  74636. if (void 0 === r && (r = null),
  74637. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  74638. e) {
  74639. if (this._doNotHandleContextLost || (e._bufferView = t,
  74640. e.invertY = n,
  74641. e._compression = r),
  74642. t) {
  74643. var s = e._hardwareTexture;
  74644. i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
  74645. var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
  74646. this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
  74647. e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
  74648. }
  74649. e.isReady = !0
  74650. }
  74651. }
  74652. ,
  74653. Qh.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
  74654. void 0 === l && (l = null);
  74655. var c = new Lt(this,At.CubeRaw);
  74656. return n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering ? n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatRender ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.colorBufferFloat || (r = !1,
  74657. K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
  74658. K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
  74659. s = a.TEXTURE_NEAREST_SAMPLINGMODE,
  74660. K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
  74661. s = a.TEXTURE_NEAREST_SAMPLINGMODE,
  74662. K.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")),
  74663. c.isCube = !0,
  74664. c.format = i === a.TEXTUREFORMAT_RGB ? a.TEXTUREFORMAT_RGBA : i,
  74665. c.type = n,
  74666. c.generateMipMaps = r,
  74667. c.width = t,
  74668. c.height = t,
  74669. c.samplingMode = s,
  74670. this._doNotHandleContextLost || (c._bufferViewArray = e),
  74671. c._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  74672. c._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  74673. this._textureHelper.createGPUTextureForInternalTexture(c),
  74674. e && this.updateRawCubeTexture(c, e, i, n, o, l),
  74675. c
  74676. }
  74677. ,
  74678. Qh.prototype.updateRawCubeTexture = function(e, t, i, n, r, o) {
  74679. void 0 === o && (o = null),
  74680. e._bufferViewArray = t,
  74681. e.invertY = r,
  74682. e._compression = o;
  74683. for (var s = e._hardwareTexture, l = i === a.TEXTUREFORMAT_RGB, c = [], u = 0; u < t.length; ++u) {
  74684. var h = t[u];
  74685. l && (h = $h(t[u], e.width, e.height, n)),
  74686. c.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength))
  74687. }
  74688. this._textureHelper.updateCubeTextures(c, s.underlyingResource, e.width, e.height, s.format, r, !1, 0, 0),
  74689. e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
  74690. e.isReady = !0
  74691. }
  74692. ,
  74693. Qh.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, o, s, l, c, u, h, d) {
  74694. var p = this;
  74695. void 0 === c && (c = null),
  74696. void 0 === u && (u = null),
  74697. void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  74698. void 0 === d && (d = !1);
  74699. var f = this.createRawCubeTexture(null, i, n, r, !o, d, h, null);
  74700. return null == t || t._addPendingData(f),
  74701. f.url = e,
  74702. this._internalTexturesCache.push(f),
  74703. this._loadFile(e, (function(e) {
  74704. !function(e) {
  74705. var i = f.width
  74706. , o = s(e);
  74707. if (o) {
  74708. var u = [0, 2, 4, 1, 3, 5];
  74709. if (l)
  74710. for (var h = n === a.TEXTUREFORMAT_RGB, _ = l(o), m = f._hardwareTexture, g = [0, 1, 2, 3, 4, 5], v = 0; v < _.length; v++) {
  74711. for (var y = i >> v, b = [], T = 0; T < 6; T++) {
  74712. var E = _[v][g[T]];
  74713. h && (E = $h(E, y, y, r)),
  74714. b.push(new Uint8Array(E.buffer,E.byteOffset,E.byteLength))
  74715. }
  74716. p._textureHelper.updateCubeTextures(b, m.underlyingResource, y, y, m.format, d, !1, 0, 0)
  74717. }
  74718. else {
  74719. for (b = [],
  74720. T = 0; T < 6; T++)
  74721. b.push(o[u[T]]);
  74722. p.updateRawCubeTexture(f, b, n, r, d)
  74723. }
  74724. f.isReady = !0,
  74725. null == t || t._removePendingData(f),
  74726. c && c()
  74727. }
  74728. }(e)
  74729. }
  74730. ), void 0, null == t ? void 0 : t.offlineProvider, !0, (function(e, i) {
  74731. null == t || t._removePendingData(f),
  74732. u && e && u(e.status + " " + e.statusText, i)
  74733. }
  74734. )),
  74735. f
  74736. }
  74737. ,
  74738. Qh.prototype.createRawTexture3D = function(e, t, i, n, r, o, s, l, c, u, h) {
  74739. void 0 === c && (c = null),
  74740. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  74741. void 0 === h && (h = 0);
  74742. var d = At.Raw3D
  74743. , p = new Lt(this,d);
  74744. return p.baseWidth = t,
  74745. p.baseHeight = i,
  74746. p.baseDepth = n,
  74747. p.width = t,
  74748. p.height = i,
  74749. p.depth = n,
  74750. p.format = r,
  74751. p.type = u,
  74752. p.generateMipMaps = o,
  74753. p.samplingMode = l,
  74754. p.is3D = !0,
  74755. this._doNotHandleContextLost || (p._bufferView = e),
  74756. this._textureHelper.createGPUTextureForInternalTexture(p, t, i, void 0, h),
  74757. this.updateRawTexture3D(p, e, r, s, c, u),
  74758. this._internalTexturesCache.push(p),
  74759. p
  74760. }
  74761. ,
  74762. Qh.prototype.updateRawTexture3D = function(e, t, i, n, r, o) {
  74763. if (void 0 === r && (r = null),
  74764. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  74765. this._doNotHandleContextLost || (e._bufferView = t,
  74766. e.format = i,
  74767. e.invertY = n,
  74768. e._compression = r),
  74769. t) {
  74770. var s = e._hardwareTexture;
  74771. i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
  74772. var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
  74773. this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
  74774. e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
  74775. }
  74776. e.isReady = !0
  74777. }
  74778. ,
  74779. Qh.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u, h) {
  74780. void 0 === c && (c = null),
  74781. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  74782. void 0 === h && (h = 0);
  74783. var d = At.Raw2DArray
  74784. , p = new Lt(this,d);
  74785. return p.baseWidth = t,
  74786. p.baseHeight = i,
  74787. p.baseDepth = n,
  74788. p.width = t,
  74789. p.height = i,
  74790. p.depth = n,
  74791. p.format = r,
  74792. p.type = u,
  74793. p.generateMipMaps = o,
  74794. p.samplingMode = l,
  74795. p.is2DArray = !0,
  74796. this._doNotHandleContextLost || (p._bufferView = e),
  74797. this._textureHelper.createGPUTextureForInternalTexture(p, t, i, n, h),
  74798. this.updateRawTexture2DArray(p, e, r, s, c, u),
  74799. this._internalTexturesCache.push(p),
  74800. p
  74801. }
  74802. ,
  74803. Qh.prototype.updateRawTexture2DArray = function(e, t, i, n, r, o) {
  74804. if (void 0 === r && (r = null),
  74805. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  74806. this._doNotHandleContextLost || (e._bufferView = t,
  74807. e.format = i,
  74808. e.invertY = n,
  74809. e._compression = r),
  74810. t) {
  74811. var s = e._hardwareTexture;
  74812. i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
  74813. var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
  74814. this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
  74815. e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
  74816. }
  74817. e.isReady = !0
  74818. }
  74819. ,
  74820. Qh.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
  74821. void 0 === n && (n = -1),
  74822. void 0 === r && (r = 0),
  74823. void 0 === o && (o = null),
  74824. void 0 === a && (a = !0),
  74825. void 0 === s && (s = !1);
  74826. var l = e._hardwareTexture;
  74827. return a && this.flushFramebuffer(),
  74828. this._textureHelper.readPixels(l.underlyingResource, 0, 0, t, i, l.format, n, r, o, s)
  74829. }
  74830. ,
  74831. Qh.prototype._readTexturePixelsSync = function() {
  74832. throw "_readTexturePixelsSync is unsupported in WebGPU!"
  74833. }
  74834. ;
  74835. var ed = function(e) {
  74836. function t() {
  74837. return null !== e && e.apply(this, arguments) || this
  74838. }
  74839. return U(t, e),
  74840. t
  74841. }(Fa);
  74842. Qh.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
  74843. var n = new ed(e,t,i,this);
  74844. return this._renderTargetWrapperCache.push(n),
  74845. n
  74846. }
  74847. ,
  74848. Qh.prototype.createRenderTargetTexture = function(e, t) {
  74849. var i, n = this._createHardwareRenderTargetWrapper(!1, !1, e), r = {};
  74850. void 0 !== t && "object" == typeof t ? (r.generateMipMaps = t.generateMipMaps,
  74851. r.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
  74852. r.generateStencilBuffer = r.generateDepthBuffer && t.generateStencilBuffer,
  74853. r.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
  74854. r.creationFlags = null !== (i = t.creationFlags) && void 0 !== i ? i : 0) : (r.generateMipMaps = t,
  74855. r.generateDepthBuffer = !0,
  74856. r.generateStencilBuffer = !1,
  74857. r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  74858. r.creationFlags = 0);
  74859. var o = this._createInternalTexture(e, t, !0, At.RenderTarget);
  74860. return n._generateDepthBuffer = r.generateDepthBuffer,
  74861. n._generateStencilBuffer = !!r.generateStencilBuffer,
  74862. n.setTextures(o),
  74863. (n._generateDepthBuffer || n._generateStencilBuffer) && n.createDepthStencilTexture(0, void 0 === r.samplingMode || r.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR || r.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, n._generateStencilBuffer, n.samples),
  74864. void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !0),
  74865. this._textureHelper.createGPUTextureForInternalTexture(o, void 0, void 0, void 0, r.creationFlags),
  74866. void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !1),
  74867. n
  74868. }
  74869. ,
  74870. Qh.prototype._createDepthStencilTexture = function(e, t) {
  74871. var i = new Lt(this,At.DepthStencil)
  74872. , n = V({
  74873. bilinearFiltering: !1,
  74874. comparisonFunction: 0,
  74875. generateStencil: !1,
  74876. samples: 1,
  74877. depthTextureFormat: a.TEXTUREFORMAT_DEPTH32_FLOAT
  74878. }, t);
  74879. return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : n.depthTextureFormat,
  74880. this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
  74881. this._textureHelper.createGPUTextureForInternalTexture(i),
  74882. this._internalTexturesCache.push(i),
  74883. i
  74884. }
  74885. ,
  74886. Qh.prototype._setupDepthStencilTexture = function(e, t, i, n, r, o) {
  74887. void 0 === o && (o = 1);
  74888. var s = t.width || t
  74889. , l = t.height || t
  74890. , c = t.layers || 0;
  74891. e.baseWidth = s,
  74892. e.baseHeight = l,
  74893. e.width = s,
  74894. e.height = l,
  74895. e.is2DArray = c > 0,
  74896. e.depth = c,
  74897. e.isReady = !0,
  74898. e.samples = o,
  74899. e.generateMipMaps = !1,
  74900. e.samplingMode = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
  74901. e.type = a.TEXTURETYPE_FLOAT,
  74902. e._comparisonFunction = r,
  74903. e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  74904. e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE
  74905. }
  74906. ,
  74907. Qh.prototype.updateRenderTargetTextureSampleCount = function(e, t) {
  74908. return e && e.texture && e.samples !== t ? (t = Math.min(t, this.getCaps().maxMSAASamples),
  74909. this._textureHelper.createMSAATexture(e.texture, t),
  74910. e._depthStencilTexture && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t),
  74911. e._depthStencilTexture.samples = t),
  74912. e.texture.samples = t,
  74913. t) : t
  74914. }
  74915. ,
  74916. Qh.prototype.createRenderTargetCubeTexture = function(e, t) {
  74917. var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
  74918. , n = V({
  74919. generateMipMaps: !0,
  74920. generateDepthBuffer: !0,
  74921. generateStencilBuffer: !1,
  74922. type: a.TEXTURETYPE_UNSIGNED_INT,
  74923. samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
  74924. format: a.TEXTUREFORMAT_RGBA,
  74925. samples: 1
  74926. }, t);
  74927. n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
  74928. i._generateDepthBuffer = n.generateDepthBuffer,
  74929. i._generateStencilBuffer = n.generateStencilBuffer;
  74930. var r = new Lt(this,At.RenderTarget);
  74931. return r.width = e,
  74932. r.height = e,
  74933. r.depth = 0,
  74934. r.isReady = !0,
  74935. r.isCube = !0,
  74936. r.samples = n.samples,
  74937. r.generateMipMaps = n.generateMipMaps,
  74938. r.samplingMode = n.samplingMode,
  74939. r.type = n.type,
  74940. r.format = n.format,
  74941. this._internalTexturesCache.push(r),
  74942. i.setTextures(r),
  74943. (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, void 0 === n.samplingMode || n.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR || n.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, i._generateStencilBuffer, i.samples),
  74944. t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !0),
  74945. this._textureHelper.createGPUTextureForInternalTexture(r),
  74946. t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !1),
  74947. i
  74948. }
  74949. ,
  74950. Mt.prototype.setTextureSampler = function(e, t) {
  74951. this._engine.setTextureSampler(e, t)
  74952. }
  74953. ,
  74954. Qh.prototype.setTextureSampler = function(e, t) {
  74955. var i;
  74956. null === (i = this._currentMaterialContext) || void 0 === i || i.setSampler(e, t)
  74957. }
  74958. ,
  74959. Mt.prototype.setStorageBuffer = function(e, t) {
  74960. this._engine.setStorageBuffer(e, t)
  74961. }
  74962. ,
  74963. Qh.prototype.createStorageBuffer = function(e, t) {
  74964. return this._createBuffer(e, t | a.BUFFER_CREATIONFLAG_STORAGE)
  74965. }
  74966. ,
  74967. Qh.prototype.updateStorageBuffer = function(e, t, i, n) {
  74968. var r, o = e;
  74969. void 0 === i && (i = 0),
  74970. void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
  74971. this._bufferManager.setSubData(o, i, r, 0, n)
  74972. }
  74973. ,
  74974. Qh.prototype.readFromStorageBuffer = function(e, t, i, n) {
  74975. var r = this;
  74976. i = i || e.capacity;
  74977. var o = this._bufferManager.createRawBuffer(i, fu.MapRead | fu.CopyDst);
  74978. return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource, null != t ? t : 0, o, 0, i),
  74979. new Promise((function(e, t) {
  74980. r.onEndFrameObservable.addOnce((function() {
  74981. o.mapAsync(_u.Read, 0, i).then((function() {
  74982. var t = o.getMappedRange(0, i)
  74983. , a = n;
  74984. if (void 0 === a)
  74985. (a = new Uint8Array(i)).set(new Uint8Array(t));
  74986. else {
  74987. var s = a.constructor;
  74988. (a = new s(a.buffer)).set(new s(t))
  74989. }
  74990. o.unmap(),
  74991. r._bufferManager.releaseBuffer(o),
  74992. e(a)
  74993. }
  74994. ), (function(e) {
  74995. return t(e)
  74996. }
  74997. ))
  74998. }
  74999. ))
  75000. }
  75001. ))
  75002. }
  75003. ,
  75004. Qh.prototype.setStorageBuffer = function(e, t) {
  75005. var i, n;
  75006. null === (i = this._currentDrawContext) || void 0 === i || i.setBuffer(e, null !== (n = null == t ? void 0 : t.getBuffer()) && void 0 !== n ? n : null)
  75007. }
  75008. ,
  75009. Qh.prototype.createUniformBuffer = function(e) {
  75010. var t;
  75011. return t = e instanceof Array ? new Float32Array(e) : e,
  75012. this._bufferManager.createBuffer(t, fu.Uniform | fu.CopyDst)
  75013. }
  75014. ,
  75015. Qh.prototype.createDynamicUniformBuffer = function(e) {
  75016. return this.createUniformBuffer(e)
  75017. }
  75018. ,
  75019. Qh.prototype.updateUniformBuffer = function(e, t, i, n) {
  75020. void 0 === i && (i = 0);
  75021. var r, o = e;
  75022. void 0 === n ? n = (r = t instanceof Float32Array ? t : new Float32Array(t)).byteLength : r = t instanceof Float32Array ? t : new Float32Array(t),
  75023. this._bufferManager.setSubData(o, i, r, 0, n)
  75024. }
  75025. ,
  75026. Qh.prototype.bindUniformBufferBase = function(e, t, i) {
  75027. this._currentDrawContext.setBuffer(i, e)
  75028. }
  75029. ,
  75030. Qh.prototype.bindUniformBlock = function() {}
  75031. ,
  75032. Qh.prototype.updateVideoTexture = function(e, t, i) {
  75033. var n, r = this;
  75034. if (e && !e._isDisabled) {
  75035. void 0 === this._videoTextureSupported && (this._videoTextureSupported = !0);
  75036. var o = e._hardwareTexture;
  75037. (null === (n = e._hardwareTexture) || void 0 === n ? void 0 : n.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e)),
  75038. this.createImageBitmap(t).then((function(t) {
  75039. r._textureHelper.updateTexture(t, e, e.width, e.height, e.depth, o.format, 0, 0, !i, !1, 0, 0),
  75040. e.generateMipMaps && r._generateMipmaps(e, r._uploadEncoder),
  75041. e.isReady = !0
  75042. }
  75043. )).catch((function() {
  75044. e.isReady = !0
  75045. }
  75046. ))
  75047. }
  75048. }
  75049. ;
  75050. var td, id = function() {
  75051. function e() {}
  75052. return e.CreateAsync = function(e, t) {
  75053. return Qh.IsSupportedAsync.then((function(i) {
  75054. return i ? Qh.CreateAsync(e, t) : vr.IsSupported ? new Promise((function(i) {
  75055. i(new vr(e,void 0,t))
  75056. }
  75057. )) : new Promise((function(e) {
  75058. e(new dc(t))
  75059. }
  75060. ))
  75061. }
  75062. ))
  75063. }
  75064. ,
  75065. e
  75066. }(), nd = function() {
  75067. function e() {}
  75068. return e.COPY = 1,
  75069. e.CUT = 2,
  75070. e.PASTE = 3,
  75071. e
  75072. }(), rd = function() {
  75073. function e(e, t) {
  75074. this.type = e,
  75075. this.event = t
  75076. }
  75077. return e.GetTypeFromCharacter = function(e) {
  75078. switch (e) {
  75079. case 67:
  75080. return nd.COPY;
  75081. case 86:
  75082. return nd.PASTE;
  75083. case 88:
  75084. return nd.CUT;
  75085. default:
  75086. return -1
  75087. }
  75088. }
  75089. ,
  75090. e
  75091. }();
  75092. !function(e) {
  75093. e[e.Clean = 0] = "Clean",
  75094. e[e.Stop = 1] = "Stop",
  75095. e[e.Sync = 2] = "Sync",
  75096. e[e.NoSync = 3] = "NoSync"
  75097. }(td || (td = {}));
  75098. var od = function() {
  75099. function e() {}
  75100. return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", {
  75101. get: function() {
  75102. return dr.ForceFullSceneLoadingForIncremental
  75103. },
  75104. set: function(e) {
  75105. dr.ForceFullSceneLoadingForIncremental = e
  75106. },
  75107. enumerable: !1,
  75108. configurable: !0
  75109. }),
  75110. Object.defineProperty(e, "ShowLoadingScreen", {
  75111. get: function() {
  75112. return dr.ShowLoadingScreen
  75113. },
  75114. set: function(e) {
  75115. dr.ShowLoadingScreen = e
  75116. },
  75117. enumerable: !1,
  75118. configurable: !0
  75119. }),
  75120. Object.defineProperty(e, "loggingLevel", {
  75121. get: function() {
  75122. return dr.loggingLevel
  75123. },
  75124. set: function(e) {
  75125. dr.loggingLevel = e
  75126. },
  75127. enumerable: !1,
  75128. configurable: !0
  75129. }),
  75130. Object.defineProperty(e, "CleanBoneMatrixWeights", {
  75131. get: function() {
  75132. return dr.CleanBoneMatrixWeights
  75133. },
  75134. set: function(e) {
  75135. dr.CleanBoneMatrixWeights = e
  75136. },
  75137. enumerable: !1,
  75138. configurable: !0
  75139. }),
  75140. e.GetDefaultPlugin = function() {
  75141. return e._RegisteredPlugins[".babylon"]
  75142. }
  75143. ,
  75144. e._GetPluginForExtension = function(t) {
  75145. return e._RegisteredPlugins[t] || (K.Warn("Unable to find a plugin to load " + t + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type"),
  75146. e.GetDefaultPlugin())
  75147. }
  75148. ,
  75149. e._GetPluginForDirectLoad = function(t) {
  75150. for (var i in e._RegisteredPlugins) {
  75151. var n = e._RegisteredPlugins[i].plugin;
  75152. if (n.canDirectLoad && n.canDirectLoad(t))
  75153. return e._RegisteredPlugins[i]
  75154. }
  75155. return e.GetDefaultPlugin()
  75156. }
  75157. ,
  75158. e._GetPluginForFilename = function(t) {
  75159. var i = t.indexOf("?");
  75160. -1 !== i && (t = t.substring(0, i));
  75161. var n = t.lastIndexOf(".")
  75162. , r = t.substring(n, t.length).toLowerCase();
  75163. return e._GetPluginForExtension(r)
  75164. }
  75165. ,
  75166. e._GetDirectLoad = function(e) {
  75167. return "data:" === e.substr(0, 5) ? e.substr(5) : null
  75168. }
  75169. ,
  75170. e._FormatErrorMessage = function(e, t, i) {
  75171. var n = "Unable to load from " + e.url;
  75172. return t ? n += ": ".concat(t) : i && (n += ": ".concat(i)),
  75173. n
  75174. }
  75175. ,
  75176. e._LoadData = function(t, i, n, r, o, a, s) {
  75177. var l, c = e._GetDirectLoad(t.url), u = s ? e._GetPluginForExtension(s) : c ? e._GetPluginForDirectLoad(t.url) : e._GetPluginForFilename(t.url);
  75178. if (!(l = void 0 !== u.plugin.createPlugin ? u.plugin.createPlugin() : u.plugin))
  75179. throw "The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";
  75180. if (e.OnPluginActivatedObservable.notifyObservers(l),
  75181. c && (l.canDirectLoad && l.canDirectLoad(t.url) || !ri(t.url))) {
  75182. if (l.directLoad) {
  75183. var h = l.directLoad(i, c);
  75184. h.then ? h.then((function(e) {
  75185. n(l, e)
  75186. }
  75187. )).catch((function(e) {
  75188. o("Error in directLoad of _loadData: " + e, e)
  75189. }
  75190. )) : n(l, h)
  75191. } else
  75192. n(l, c);
  75193. return l
  75194. }
  75195. var d = u.isBinary
  75196. , p = function(e, t) {
  75197. i.isDisposed ? o("Scene has been disposed") : n(l, e, t)
  75198. }
  75199. , f = null
  75200. , _ = !1
  75201. , m = l.onDisposeObservable;
  75202. m && m.add((function() {
  75203. _ = !0,
  75204. f && (f.abort(),
  75205. f = null),
  75206. a()
  75207. }
  75208. ));
  75209. var g = function() {
  75210. if (!_) {
  75211. var e = function(e, t) {
  75212. o(null == e ? void 0 : e.statusText, t)
  75213. }
  75214. , n = t.file || t.url;
  75215. f = l.loadFile ? l.loadFile(i, n, p, r, d, e) : i._loadFile(n, p, r, !0, d, e)
  75216. }
  75217. }
  75218. , v = i.getEngine()
  75219. , y = v.enableOfflineSupport;
  75220. if (y) {
  75221. for (var b = !1, T = 0, E = i.disableOfflineSupportExceptionRules; T < E.length; T++)
  75222. if (E[T].test(t.url)) {
  75223. b = !0;
  75224. break
  75225. }
  75226. y = !b
  75227. }
  75228. return y && vr.OfflineProviderFactory ? i.offlineProvider = vr.OfflineProviderFactory(t.url, g, v.disableManifestCheck) : g(),
  75229. l
  75230. }
  75231. ,
  75232. e._GetFileInfo = function(e, t) {
  75233. var i, n, r = null;
  75234. if (t)
  75235. if (t.name) {
  75236. var o = t;
  75237. i = "file:".concat(o.name),
  75238. n = o.name,
  75239. r = o
  75240. } else if ("string" == typeof t && ae(t, "data:"))
  75241. i = t,
  75242. n = "";
  75243. else {
  75244. var a = t;
  75245. if ("/" === a.substr(0, 1))
  75246. return gi.Error("Wrong sceneFilename parameter"),
  75247. null;
  75248. i = e + a,
  75249. n = a
  75250. }
  75251. else
  75252. i = e,
  75253. n = gi.GetFilename(e),
  75254. e = gi.GetFolderPath(e);
  75255. return {
  75256. url: i,
  75257. rootUrl: e,
  75258. name: n,
  75259. file: r
  75260. }
  75261. }
  75262. ,
  75263. e.GetPluginForExtension = function(t) {
  75264. return e._GetPluginForExtension(t).plugin
  75265. }
  75266. ,
  75267. e.IsPluginForExtensionAvailable = function(t) {
  75268. return !!e._RegisteredPlugins[t]
  75269. }
  75270. ,
  75271. e.RegisterPlugin = function(t) {
  75272. if ("string" == typeof t.extensions) {
  75273. var i = t.extensions;
  75274. e._RegisteredPlugins[i.toLowerCase()] = {
  75275. plugin: t,
  75276. isBinary: !1
  75277. }
  75278. } else {
  75279. var n = t.extensions;
  75280. Object.keys(n).forEach((function(i) {
  75281. e._RegisteredPlugins[i.toLowerCase()] = {
  75282. plugin: t,
  75283. isBinary: n[i].isBinary
  75284. }
  75285. }
  75286. ))
  75287. }
  75288. }
  75289. ,
  75290. e.ImportMesh = function(t, i, n, r, o, a, s, l) {
  75291. if (void 0 === n && (n = ""),
  75292. void 0 === r && (r = E.LastCreatedScene),
  75293. void 0 === o && (o = null),
  75294. void 0 === a && (a = null),
  75295. void 0 === s && (s = null),
  75296. void 0 === l && (l = null),
  75297. !r)
  75298. return K.Error("No scene available to import mesh to"),
  75299. null;
  75300. var c = e._GetFileInfo(i, n);
  75301. if (!c)
  75302. return null;
  75303. var u = {};
  75304. r._addPendingData(u);
  75305. var h = function() {
  75306. r._removePendingData(u)
  75307. }
  75308. , d = function(t, i) {
  75309. var n = e._FormatErrorMessage(c, t, i);
  75310. s ? s(r, n, new ft(n,pt.SceneLoaderError,i)) : K.Error(n),
  75311. h()
  75312. }
  75313. , p = a ? function(e) {
  75314. try {
  75315. a(e)
  75316. } catch (e) {
  75317. d("Error in onProgress callback: " + e, e)
  75318. }
  75319. }
  75320. : void 0
  75321. , f = function(e, t, i, n, a, s, l) {
  75322. if (r.importedMeshesFiles.push(c.url),
  75323. o)
  75324. try {
  75325. o(e, t, i, n, a, s, l)
  75326. } catch (e) {
  75327. d("Error in onSuccess callback: " + e, e)
  75328. }
  75329. r._removePendingData(u)
  75330. };
  75331. return e._LoadData(c, r, (function(e, i, n) {
  75332. if (e.rewriteRootURL && (c.rootUrl = e.rewriteRootURL(c.rootUrl, n)),
  75333. e.importMesh) {
  75334. var o = e
  75335. , a = new Array
  75336. , s = new Array
  75337. , l = new Array;
  75338. if (!o.importMesh(t, r, i, c.rootUrl, a, s, l, d))
  75339. return;
  75340. r.loadingPluginName = e.name,
  75341. f(a, s, l, [], [], [], [])
  75342. } else
  75343. e.importMeshAsync(t, r, i, c.rootUrl, p, c.name).then((function(t) {
  75344. r.loadingPluginName = e.name,
  75345. f(t.meshes, t.particleSystems, t.skeletons, t.animationGroups, t.transformNodes, t.geometries, t.lights)
  75346. }
  75347. )).catch((function(e) {
  75348. d(e.message, e)
  75349. }
  75350. ))
  75351. }
  75352. ), p, d, h, l)
  75353. }
  75354. ,
  75355. e.ImportMeshAsync = function(t, i, n, r, o, a) {
  75356. return void 0 === n && (n = ""),
  75357. void 0 === r && (r = E.LastCreatedScene),
  75358. void 0 === o && (o = null),
  75359. void 0 === a && (a = null),
  75360. new Promise((function(s, l) {
  75361. e.ImportMesh(t, i, n, r, (function(e, t, i, n, r, o, a) {
  75362. s({
  75363. meshes: e,
  75364. particleSystems: t,
  75365. skeletons: i,
  75366. animationGroups: n,
  75367. transformNodes: r,
  75368. geometries: o,
  75369. lights: a
  75370. })
  75371. }
  75372. ), o, (function(e, t, i) {
  75373. l(i || new Error(t))
  75374. }
  75375. ), a)
  75376. }
  75377. ))
  75378. }
  75379. ,
  75380. e.Load = function(t, i, n, r, o, a, s) {
  75381. return void 0 === i && (i = ""),
  75382. void 0 === n && (n = E.LastCreatedEngine),
  75383. void 0 === r && (r = null),
  75384. void 0 === o && (o = null),
  75385. void 0 === a && (a = null),
  75386. void 0 === s && (s = null),
  75387. n ? e.Append(t, i, new mn(n), r, o, a, s) : (gi.Error("No engine available"),
  75388. null)
  75389. }
  75390. ,
  75391. e.LoadAsync = function(t, i, n, r, o) {
  75392. return void 0 === i && (i = ""),
  75393. void 0 === n && (n = E.LastCreatedEngine),
  75394. void 0 === r && (r = null),
  75395. void 0 === o && (o = null),
  75396. new Promise((function(a, s) {
  75397. e.Load(t, i, n, (function(e) {
  75398. a(e)
  75399. }
  75400. ), r, (function(e, t, i) {
  75401. s(i || new Error(t))
  75402. }
  75403. ), o)
  75404. }
  75405. ))
  75406. }
  75407. ,
  75408. e.Append = function(t, i, n, r, o, a, s) {
  75409. var l = this;
  75410. if (void 0 === i && (i = ""),
  75411. void 0 === n && (n = E.LastCreatedScene),
  75412. void 0 === r && (r = null),
  75413. void 0 === o && (o = null),
  75414. void 0 === a && (a = null),
  75415. void 0 === s && (s = null),
  75416. !n)
  75417. return K.Error("No scene available to append to"),
  75418. null;
  75419. var c = e._GetFileInfo(t, i);
  75420. if (!c)
  75421. return null;
  75422. e.ShowLoadingScreen && !this._ShowingLoadingScreen && (this._ShowingLoadingScreen = !0,
  75423. n.getEngine().displayLoadingUI(),
  75424. n.executeWhenReady((function() {
  75425. n.getEngine().hideLoadingUI(),
  75426. l._ShowingLoadingScreen = !1
  75427. }
  75428. )));
  75429. var u = {};
  75430. n._addPendingData(u);
  75431. var h = function() {
  75432. n._removePendingData(u)
  75433. }
  75434. , d = function(t, i) {
  75435. var r = e._FormatErrorMessage(c, t, i);
  75436. a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
  75437. h()
  75438. }
  75439. , p = o ? function(e) {
  75440. try {
  75441. o(e)
  75442. } catch (e) {
  75443. d("Error in onProgress callback", e)
  75444. }
  75445. }
  75446. : void 0
  75447. , f = function() {
  75448. if (r)
  75449. try {
  75450. r(n)
  75451. } catch (e) {
  75452. d("Error in onSuccess callback", e)
  75453. }
  75454. n._removePendingData(u)
  75455. };
  75456. return e._LoadData(c, n, (function(e, t) {
  75457. if (e.load) {
  75458. if (!e.load(n, t, c.rootUrl, d))
  75459. return;
  75460. n.loadingPluginName = e.name,
  75461. f()
  75462. } else
  75463. e.loadAsync(n, t, c.rootUrl, p, c.name).then((function() {
  75464. n.loadingPluginName = e.name,
  75465. f()
  75466. }
  75467. )).catch((function(e) {
  75468. d(e.message, e)
  75469. }
  75470. ))
  75471. }
  75472. ), p, d, h, s)
  75473. }
  75474. ,
  75475. e.AppendAsync = function(t, i, n, r, o) {
  75476. return void 0 === i && (i = ""),
  75477. void 0 === n && (n = E.LastCreatedScene),
  75478. void 0 === r && (r = null),
  75479. void 0 === o && (o = null),
  75480. new Promise((function(a, s) {
  75481. e.Append(t, i, n, (function(e) {
  75482. a(e)
  75483. }
  75484. ), r, (function(e, t, i) {
  75485. s(i || new Error(t))
  75486. }
  75487. ), o)
  75488. }
  75489. ))
  75490. }
  75491. ,
  75492. e.LoadAssetContainer = function(t, i, n, r, o, a, s) {
  75493. if (void 0 === i && (i = ""),
  75494. void 0 === n && (n = E.LastCreatedScene),
  75495. void 0 === r && (r = null),
  75496. void 0 === o && (o = null),
  75497. void 0 === a && (a = null),
  75498. void 0 === s && (s = null),
  75499. !n)
  75500. return K.Error("No scene available to load asset container to"),
  75501. null;
  75502. var l = e._GetFileInfo(t, i);
  75503. if (!l)
  75504. return null;
  75505. var c = {};
  75506. n._addPendingData(c);
  75507. var u = function() {
  75508. n._removePendingData(c)
  75509. }
  75510. , h = function(t, i) {
  75511. var r = e._FormatErrorMessage(l, t, i);
  75512. a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
  75513. u()
  75514. }
  75515. , d = o ? function(e) {
  75516. try {
  75517. o(e)
  75518. } catch (e) {
  75519. h("Error in onProgress callback", e)
  75520. }
  75521. }
  75522. : void 0
  75523. , p = function(e) {
  75524. if (r)
  75525. try {
  75526. r(e)
  75527. } catch (e) {
  75528. h("Error in onSuccess callback", e)
  75529. }
  75530. n._removePendingData(c)
  75531. };
  75532. return e._LoadData(l, n, (function(e, t) {
  75533. if (e.loadAssetContainer) {
  75534. var i = e.loadAssetContainer(n, t, l.rootUrl, h);
  75535. if (!i)
  75536. return;
  75537. n.loadingPluginName = e.name,
  75538. p(i)
  75539. } else
  75540. e.loadAssetContainerAsync ? e.loadAssetContainerAsync(n, t, l.rootUrl, d, l.name).then((function(t) {
  75541. n.loadingPluginName = e.name,
  75542. p(t)
  75543. }
  75544. )).catch((function(e) {
  75545. h(e.message, e)
  75546. }
  75547. )) : h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
  75548. }
  75549. ), d, h, u, s)
  75550. }
  75551. ,
  75552. e.LoadAssetContainerAsync = function(t, i, n, r, o) {
  75553. return void 0 === i && (i = ""),
  75554. void 0 === n && (n = E.LastCreatedScene),
  75555. void 0 === r && (r = null),
  75556. void 0 === o && (o = null),
  75557. new Promise((function(a, s) {
  75558. e.LoadAssetContainer(t, i, n, (function(e) {
  75559. a(e)
  75560. }
  75561. ), r, (function(e, t, i) {
  75562. s(i || new Error(t))
  75563. }
  75564. ), o)
  75565. }
  75566. ))
  75567. }
  75568. ,
  75569. e.ImportAnimations = function(e, t, i, n, r, o, a, s, l, c) {
  75570. if (void 0 === t && (t = ""),
  75571. void 0 === i && (i = E.LastCreatedScene),
  75572. void 0 === n && (n = !0),
  75573. void 0 === r && (r = td.Clean),
  75574. void 0 === o && (o = null),
  75575. void 0 === a && (a = null),
  75576. void 0 === s && (s = null),
  75577. void 0 === l && (l = null),
  75578. void 0 === c && (c = null),
  75579. i) {
  75580. if (n) {
  75581. for (var u = 0, h = i.animatables; u < h.length; u++)
  75582. h[u].reset();
  75583. i.stopAllAnimations(),
  75584. i.animationGroups.slice().forEach((function(e) {
  75585. e.dispose()
  75586. }
  75587. )),
  75588. i.getNodes().forEach((function(e) {
  75589. e.animations && (e.animations = [])
  75590. }
  75591. ))
  75592. } else
  75593. switch (r) {
  75594. case td.Clean:
  75595. i.animationGroups.slice().forEach((function(e) {
  75596. e.dispose()
  75597. }
  75598. ));
  75599. break;
  75600. case td.Stop:
  75601. i.animationGroups.forEach((function(e) {
  75602. e.stop()
  75603. }
  75604. ));
  75605. break;
  75606. case td.Sync:
  75607. i.animationGroups.forEach((function(e) {
  75608. e.reset(),
  75609. e.restart()
  75610. }
  75611. ));
  75612. break;
  75613. case td.NoSync:
  75614. break;
  75615. default:
  75616. return void K.Error("Unknown animation group loading mode value '" + r + "'")
  75617. }
  75618. var d = i.animatables.length;
  75619. this.LoadAssetContainer(e, t, i, (function(e) {
  75620. e.mergeAnimationsTo(i, i.animatables.slice(d), o),
  75621. e.dispose(),
  75622. i.onAnimationFileImportedObservable.notifyObservers(i),
  75623. a && a(i)
  75624. }
  75625. ), s, l, c)
  75626. } else
  75627. K.Error("No scene available to load animations to")
  75628. }
  75629. ,
  75630. e.ImportAnimationsAsync = function(t, i, n, r, o, a, s, l, c, u) {
  75631. return void 0 === i && (i = ""),
  75632. void 0 === n && (n = E.LastCreatedScene),
  75633. void 0 === r && (r = !0),
  75634. void 0 === o && (o = td.Clean),
  75635. void 0 === a && (a = null),
  75636. void 0 === s && (s = null),
  75637. void 0 === l && (l = null),
  75638. void 0 === c && (c = null),
  75639. void 0 === u && (u = null),
  75640. new Promise((function(s, c) {
  75641. e.ImportAnimations(t, i, n, r, o, a, (function(e) {
  75642. s(e)
  75643. }
  75644. ), l, (function(e, t, i) {
  75645. c(i || new Error(t))
  75646. }
  75647. ), u)
  75648. }
  75649. ))
  75650. }
  75651. ,
  75652. e.NO_LOGGING = a.SCENELOADER_NO_LOGGING,
  75653. e.MINIMAL_LOGGING = a.SCENELOADER_MINIMAL_LOGGING,
  75654. e.SUMMARY_LOGGING = a.SCENELOADER_SUMMARY_LOGGING,
  75655. e.DETAILED_LOGGING = a.SCENELOADER_DETAILED_LOGGING,
  75656. e.OnPluginActivatedObservable = new h,
  75657. e._RegisteredPlugins = {},
  75658. e._ShowingLoadingScreen = !1,
  75659. e
  75660. }()
  75661. , ad = function(e) {
  75662. function t(t) {
  75663. var i = e.call(this, t) || this;
  75664. return i.controllerType = ba.DAYDREAM,
  75665. i
  75666. }
  75667. return U(t, e),
  75668. t.prototype.initControllerMesh = function(e, i) {
  75669. var n = this;
  75670. od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
  75671. n._defaultModel = e[1],
  75672. n.attachToMesh(n._defaultModel),
  75673. i && i(n._defaultModel)
  75674. }
  75675. ))
  75676. }
  75677. ,
  75678. t.prototype._handleButtonChange = function(e, t) {
  75679. if (0 === e) {
  75680. var i = this.onTriggerStateChangedObservable;
  75681. i && i.notifyObservers(t)
  75682. } else
  75683. K.Warn("Unrecognized Daydream button index: ".concat(e))
  75684. }
  75685. ,
  75686. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
  75687. t.MODEL_FILENAME = "generic.babylon",
  75688. t.GAMEPAD_ID_PREFIX = "Daydream",
  75689. t
  75690. }(_s);
  75691. xa._ControllerFactories.push({
  75692. canCreate: function(e) {
  75693. return 0 === e.id.indexOf(ad.GAMEPAD_ID_PREFIX)
  75694. },
  75695. create: function(e) {
  75696. return new ad(e)
  75697. }
  75698. });
  75699. var sd = function(e) {
  75700. function t(t) {
  75701. var i = e.call(this, t) || this;
  75702. return i._buttonIndexToObservableNameMap = ["onPadStateChangedObservable", "onTriggerStateChangedObservable"],
  75703. i.controllerType = ba.GEAR_VR,
  75704. i._calculatedPosition = new x("left" == i.hand ? -.15 : .15,-.5,.25),
  75705. i._disableTrackPosition(i._calculatedPosition),
  75706. i
  75707. }
  75708. return U(t, e),
  75709. t.prototype.initControllerMesh = function(e, i) {
  75710. var n = this;
  75711. od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(t) {
  75712. var r = new Vr("",e);
  75713. t[1].parent = r,
  75714. t[1].position.z = -.15,
  75715. n._defaultModel = r,
  75716. n.attachToMesh(n._defaultModel),
  75717. i && i(n._defaultModel)
  75718. }
  75719. ))
  75720. }
  75721. ,
  75722. t.prototype._handleButtonChange = function(e, t) {
  75723. if (e < this._buttonIndexToObservableNameMap.length) {
  75724. var i = this[this._buttonIndexToObservableNameMap[e]];
  75725. i && i.notifyObservers(t)
  75726. }
  75727. }
  75728. ,
  75729. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
  75730. t.MODEL_FILENAME = "generic.babylon",
  75731. t.GAMEPAD_ID_PREFIX = "Gear VR",
  75732. t
  75733. }(_s);
  75734. xa._ControllerFactories.push({
  75735. canCreate: function(e) {
  75736. return 0 === e.id.indexOf(sd.GAMEPAD_ID_PREFIX) || -1 !== e.id.indexOf("Oculus Go") || -1 !== e.id.indexOf("Vive Focus")
  75737. },
  75738. create: function(e) {
  75739. return new sd(e)
  75740. }
  75741. });
  75742. var ld = function(e) {
  75743. function t(t) {
  75744. return e.call(this, t) || this
  75745. }
  75746. return U(t, e),
  75747. t.prototype.initControllerMesh = function(e, i) {
  75748. var n = this;
  75749. od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
  75750. n._defaultModel = e[1],
  75751. n.attachToMesh(n._defaultModel),
  75752. i && i(n._defaultModel)
  75753. }
  75754. ))
  75755. }
  75756. ,
  75757. t.prototype._handleButtonChange = function(e, t) {
  75758. console.log("Button id: " + e + "state: "),
  75759. console.dir(t)
  75760. }
  75761. ,
  75762. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
  75763. t.MODEL_FILENAME = "generic.babylon",
  75764. t
  75765. }(_s);
  75766. xa._DefaultControllerFactory = function(e) {
  75767. return new ld(e)
  75768. }
  75769. ;
  75770. var cd = function(e) {
  75771. function t(t) {
  75772. var i = e.call(this, t) || this;
  75773. return i.onSecondaryTriggerStateChangedObservable = new h,
  75774. i.onThumbRestChangedObservable = new h,
  75775. i.controllerType = ba.OCULUS,
  75776. i
  75777. }
  75778. return U(t, e),
  75779. t.prototype.initControllerMesh = function(e, i) {
  75780. var n, r = this;
  75781. n = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
  75782. od.ImportMesh("", t._IsQuest ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL, n, e, (function(e) {
  75783. r._defaultModel = t._IsQuest ? e[0] : e[1],
  75784. r.attachToMesh(r._defaultModel),
  75785. i && i(r._defaultModel)
  75786. }
  75787. ))
  75788. }
  75789. ,
  75790. Object.defineProperty(t.prototype, "onAButtonStateChangedObservable", {
  75791. get: function() {
  75792. if ("right" === this.hand)
  75793. return this.onMainButtonStateChangedObservable;
  75794. throw new Error("No A button on left hand")
  75795. },
  75796. enumerable: !1,
  75797. configurable: !0
  75798. }),
  75799. Object.defineProperty(t.prototype, "onBButtonStateChangedObservable", {
  75800. get: function() {
  75801. if ("right" === this.hand)
  75802. return this.onSecondaryButtonStateChangedObservable;
  75803. throw new Error("No B button on left hand")
  75804. },
  75805. enumerable: !1,
  75806. configurable: !0
  75807. }),
  75808. Object.defineProperty(t.prototype, "onXButtonStateChangedObservable", {
  75809. get: function() {
  75810. if ("left" === this.hand)
  75811. return this.onMainButtonStateChangedObservable;
  75812. throw new Error("No X button on right hand")
  75813. },
  75814. enumerable: !1,
  75815. configurable: !0
  75816. }),
  75817. Object.defineProperty(t.prototype, "onYButtonStateChangedObservable", {
  75818. get: function() {
  75819. if ("left" === this.hand)
  75820. return this.onSecondaryButtonStateChangedObservable;
  75821. throw new Error("No Y button on right hand")
  75822. },
  75823. enumerable: !1,
  75824. configurable: !0
  75825. }),
  75826. t.prototype._handleButtonChange = function(e, i) {
  75827. var n = i
  75828. , r = "right" === this.hand ? -1 : 1;
  75829. switch (e) {
  75830. case 0:
  75831. return void this.onPadStateChangedObservable.notifyObservers(n);
  75832. case 1:
  75833. return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[3].rotation.x = .2 * -n.value,
  75834. this._defaultModel.getChildren()[3].position.y = .005 * -n.value,
  75835. this._defaultModel.getChildren()[3].position.z = .005 * -n.value),
  75836. void this.onTriggerStateChangedObservable.notifyObservers(n);
  75837. case 2:
  75838. return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[4].position.x = r * n.value * .0035),
  75839. void this.onSecondaryTriggerStateChangedObservable.notifyObservers(n);
  75840. case 3:
  75841. return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[1].position.y = -.001 : this._defaultModel.getChildren()[1].position.y = 0),
  75842. void this.onMainButtonStateChangedObservable.notifyObservers(n);
  75843. case 4:
  75844. return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0),
  75845. void this.onSecondaryButtonStateChangedObservable.notifyObservers(n);
  75846. case 5:
  75847. return void this.onThumbRestChangedObservable.notifyObservers(n)
  75848. }
  75849. }
  75850. ,
  75851. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/",
  75852. t.MODEL_LEFT_FILENAME = "left.babylon",
  75853. t.MODEL_RIGHT_FILENAME = "right.babylon",
  75854. t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/",
  75855. t._IsQuest = !1,
  75856. t
  75857. }(_s);
  75858. xa._ControllerFactories.push({
  75859. canCreate: function(e) {
  75860. return E.LastCreatedEngine && E.LastCreatedEngine._vrDisplay && "Oculus Quest" === E.LastCreatedEngine._vrDisplay.displayName && (cd._IsQuest = !0),
  75861. -1 !== e.id.indexOf("Oculus Touch")
  75862. },
  75863. create: function(e) {
  75864. return new cd(e)
  75865. }
  75866. });
  75867. var ud = function(e) {
  75868. function t(t) {
  75869. var i = e.call(this, t) || this;
  75870. return i.controllerType = ba.VIVE,
  75871. i._invertLeftStickY = !0,
  75872. i
  75873. }
  75874. return U(t, e),
  75875. t.prototype.initControllerMesh = function(e, i) {
  75876. var n = this;
  75877. od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
  75878. n._defaultModel = e[1],
  75879. n.attachToMesh(n._defaultModel),
  75880. i && i(n._defaultModel)
  75881. }
  75882. ))
  75883. }
  75884. ,
  75885. Object.defineProperty(t.prototype, "onLeftButtonStateChangedObservable", {
  75886. get: function() {
  75887. return this.onMainButtonStateChangedObservable
  75888. },
  75889. enumerable: !1,
  75890. configurable: !0
  75891. }),
  75892. Object.defineProperty(t.prototype, "onRightButtonStateChangedObservable", {
  75893. get: function() {
  75894. return this.onMainButtonStateChangedObservable
  75895. },
  75896. enumerable: !1,
  75897. configurable: !0
  75898. }),
  75899. Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", {
  75900. get: function() {
  75901. return this.onSecondaryButtonStateChangedObservable
  75902. },
  75903. enumerable: !1,
  75904. configurable: !0
  75905. }),
  75906. t.prototype._handleButtonChange = function(e, t) {
  75907. var i = t;
  75908. switch (e) {
  75909. case 0:
  75910. return void this.onPadStateChangedObservable.notifyObservers(i);
  75911. case 1:
  75912. return this._defaultModel && (this._defaultModel.getChildren()[6].rotation.x = .15 * -i.value),
  75913. void this.onTriggerStateChangedObservable.notifyObservers(i);
  75914. case 2:
  75915. return void this.onMainButtonStateChangedObservable.notifyObservers(i);
  75916. case 3:
  75917. return this._defaultModel && (i.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0),
  75918. void this.onSecondaryButtonStateChangedObservable.notifyObservers(i)
  75919. }
  75920. }
  75921. ,
  75922. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/",
  75923. t.MODEL_FILENAME = "wand.babylon",
  75924. t
  75925. }(_s);
  75926. xa._ControllerFactories.push({
  75927. canCreate: function(e) {
  75928. return -1 !== e.id.toLowerCase().indexOf("openvr")
  75929. },
  75930. create: function(e) {
  75931. return new ud(e)
  75932. }
  75933. });
  75934. var hd = function() {
  75935. this.buttonMeshes = {},
  75936. this.axisMeshes = {}
  75937. }
  75938. , dd = function(e) {
  75939. function t(t) {
  75940. var i = e.call(this, t) || this;
  75941. return i._mapping = {
  75942. buttons: ["thumbstick", "trigger", "grip", "menu", "trackpad"],
  75943. buttonMeshNames: {
  75944. trigger: "SELECT",
  75945. menu: "MENU",
  75946. grip: "GRASP",
  75947. thumbstick: "THUMBSTICK_PRESS",
  75948. trackpad: "TOUCHPAD_PRESS"
  75949. },
  75950. buttonObservableNames: {
  75951. trigger: "onTriggerStateChangedObservable",
  75952. menu: "onSecondaryButtonStateChangedObservable",
  75953. grip: "onMainButtonStateChangedObservable",
  75954. thumbstick: "onPadStateChangedObservable",
  75955. trackpad: "onTrackpadChangedObservable"
  75956. },
  75957. axisMeshNames: ["THUMBSTICK_X", "THUMBSTICK_Y", "TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y"],
  75958. pointingPoseMeshName: Ra.POINTING_POSE
  75959. },
  75960. i.onTrackpadChangedObservable = new h,
  75961. i.onTrackpadValuesChangedObservable = new h,
  75962. i.trackpad = {
  75963. x: 0,
  75964. y: 0
  75965. },
  75966. i.controllerType = ba.WINDOWS,
  75967. i._loadedMeshInfo = null,
  75968. i
  75969. }
  75970. return U(t, e),
  75971. Object.defineProperty(t.prototype, "onTriggerButtonStateChangedObservable", {
  75972. get: function() {
  75973. return this.onTriggerStateChangedObservable
  75974. },
  75975. enumerable: !1,
  75976. configurable: !0
  75977. }),
  75978. Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", {
  75979. get: function() {
  75980. return this.onSecondaryButtonStateChangedObservable
  75981. },
  75982. enumerable: !1,
  75983. configurable: !0
  75984. }),
  75985. Object.defineProperty(t.prototype, "onGripButtonStateChangedObservable", {
  75986. get: function() {
  75987. return this.onMainButtonStateChangedObservable
  75988. },
  75989. enumerable: !1,
  75990. configurable: !0
  75991. }),
  75992. Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", {
  75993. get: function() {
  75994. return this.onPadStateChangedObservable
  75995. },
  75996. enumerable: !1,
  75997. configurable: !0
  75998. }),
  75999. Object.defineProperty(t.prototype, "onTouchpadButtonStateChangedObservable", {
  76000. get: function() {
  76001. return this.onTrackpadChangedObservable
  76002. },
  76003. enumerable: !1,
  76004. configurable: !0
  76005. }),
  76006. Object.defineProperty(t.prototype, "onTouchpadValuesChangedObservable", {
  76007. get: function() {
  76008. return this.onTrackpadValuesChangedObservable
  76009. },
  76010. enumerable: !1,
  76011. configurable: !0
  76012. }),
  76013. t.prototype._updateTrackpad = function() {
  76014. !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.trackpad.x && this.browserGamepad.axes[3] == this.trackpad.y || (this.trackpad.x = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")],
  76015. this.trackpad.y = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")],
  76016. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))
  76017. }
  76018. ,
  76019. t.prototype.update = function() {
  76020. if (e.prototype.update.call(this),
  76021. this.browserGamepad.axes && (this._updateTrackpad(),
  76022. this._loadedMeshInfo))
  76023. for (var t = 0; t < this._mapping.axisMeshNames.length; t++)
  76024. this._lerpAxisTransform(t, this.browserGamepad.axes[t])
  76025. }
  76026. ,
  76027. t.prototype._handleButtonChange = function(e, t) {
  76028. var i = this._mapping.buttons[e];
  76029. if (i) {
  76030. this._updateTrackpad();
  76031. var n = this[this._mapping.buttonObservableNames[i]];
  76032. n && n.notifyObservers(t),
  76033. this._lerpButtonTransform(i, t.value)
  76034. }
  76035. }
  76036. ,
  76037. t.prototype._lerpButtonTransform = function(e, t) {
  76038. if (this._loadedMeshInfo) {
  76039. var i = this._loadedMeshInfo.buttonMeshes[e];
  76040. i && i.unpressed.rotationQuaternion && i.pressed.rotationQuaternion && i.value.rotationQuaternion && (C.SlerpToRef(i.unpressed.rotationQuaternion, i.pressed.rotationQuaternion, t, i.value.rotationQuaternion),
  76041. x.LerpToRef(i.unpressed.position, i.pressed.position, t, i.value.position))
  76042. }
  76043. }
  76044. ,
  76045. t.prototype._lerpAxisTransform = function(e, t) {
  76046. if (this._loadedMeshInfo) {
  76047. var i = this._loadedMeshInfo.axisMeshes[e];
  76048. if (i && i.min.rotationQuaternion && i.max.rotationQuaternion && i.value.rotationQuaternion) {
  76049. var n = .5 * t + .5;
  76050. C.SlerpToRef(i.min.rotationQuaternion, i.max.rotationQuaternion, n, i.value.rotationQuaternion),
  76051. x.LerpToRef(i.min.position, i.max.position, n, i.value.position)
  76052. }
  76053. }
  76054. }
  76055. ,
  76056. t.prototype.initControllerMesh = function(e, i, n) {
  76057. var r, o, a = this;
  76058. if (void 0 === n && (n = !1),
  76059. od.IsPluginForExtensionAvailable(".glb")) {
  76060. var s = "default";
  76061. if (this.id && !n) {
  76062. var l = this.id.match(t.GAMEPAD_ID_PATTERN);
  76063. s = l && l[0] || s
  76064. }
  76065. o = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
  76066. r = t.MODEL_BASE_URL + s + "/"
  76067. } else
  76068. K.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),
  76069. r = ld.MODEL_BASE_URL,
  76070. o = ld.MODEL_FILENAME;
  76071. od.ImportMesh("", r, o, e, (function(t) {
  76072. a._loadedMeshInfo = a._processModel(e, t),
  76073. a._loadedMeshInfo && (a._defaultModel = a._loadedMeshInfo.rootNode,
  76074. a.attachToMesh(a._defaultModel),
  76075. i && i(a._defaultModel))
  76076. }
  76077. ), null, (function(e, t) {
  76078. K.Log(t),
  76079. K.Warn("Failed to retrieve controller model from the remote server: " + r + o),
  76080. n || a.initControllerMesh(e, i, !0)
  76081. }
  76082. ))
  76083. }
  76084. ,
  76085. t.prototype._processModel = function(e, t) {
  76086. for (var i = null, n = new Vr(this.id + " " + this.hand,e), r = null, o = 0; o < t.length; o++) {
  76087. var a = t[o];
  76088. if (!a.parent) {
  76089. a.isPickable = !1,
  76090. r = a;
  76091. break
  76092. }
  76093. }
  76094. return r ? (r.setParent(n),
  76095. i = this._createMeshInfo(n)) : K.Warn("Could not find root node in model file."),
  76096. i
  76097. }
  76098. ,
  76099. t.prototype._createMeshInfo = function(e) {
  76100. var t, i = new hd;
  76101. for (i.rootNode = e,
  76102. i.buttonMeshes = {},
  76103. i.axisMeshes = {},
  76104. t = 0; t < this._mapping.buttons.length; t++) {
  76105. var n = this._mapping.buttonMeshNames[this._mapping.buttons[t]];
  76106. if (n) {
  76107. var r = c(e, n);
  76108. if (r) {
  76109. var o = {
  76110. index: t,
  76111. value: u(r, "VALUE"),
  76112. pressed: u(r, "PRESSED"),
  76113. unpressed: u(r, "UNPRESSED")
  76114. };
  76115. o.value && o.pressed && o.unpressed ? i.buttonMeshes[this._mapping.buttons[t]] = o : K.Warn("Missing button submesh under mesh with name: " + n + "(VALUE: " + !!o.value + ", PRESSED: " + !!o.pressed + ", UNPRESSED:" + !!o.unpressed + ")")
  76116. } else
  76117. K.Warn("Missing button mesh with name: " + n)
  76118. } else
  76119. K.Log("Skipping unknown button at index: " + t + " with mapped name: " + this._mapping.buttons[t])
  76120. }
  76121. for (t = 0; t < this._mapping.axisMeshNames.length; t++) {
  76122. var a = this._mapping.axisMeshNames[t];
  76123. if (a) {
  76124. var s = c(e, a);
  76125. if (s) {
  76126. var l = {
  76127. index: t,
  76128. value: u(s, "VALUE"),
  76129. min: u(s, "MIN"),
  76130. max: u(s, "MAX")
  76131. };
  76132. l.value && l.min && l.max ? i.axisMeshes[t] = l : K.Warn("Missing axis submesh under mesh with name: " + a + "(VALUE: " + !!l.value + ", MIN: " + !!l.min + ", MAX:" + !!l.max + ")")
  76133. } else
  76134. K.Warn("Missing axis mesh with name: " + a)
  76135. } else
  76136. K.Log("Skipping unknown axis at index: " + t)
  76137. }
  76138. return i.pointingPoseNode = c(e, this._mapping.pointingPoseMeshName),
  76139. i.pointingPoseNode ? this._pointingPoseNode = i.pointingPoseNode : K.Warn("Missing pointing pose mesh with name: " + this._mapping.pointingPoseMeshName),
  76140. i;
  76141. function c(e, t) {
  76142. return e.getChildren((function(e) {
  76143. return e.name === t
  76144. }
  76145. ), !1)[0]
  76146. }
  76147. function u(e, t) {
  76148. return e.getChildren((function(e) {
  76149. return e.name == t
  76150. }
  76151. ), !0)[0]
  76152. }
  76153. }
  76154. ,
  76155. t.prototype.getForwardRay = function(t) {
  76156. if (void 0 === t && (t = 100),
  76157. !this._loadedMeshInfo || !this._loadedMeshInfo.pointingPoseNode)
  76158. return e.prototype.getForwardRay.call(this, t);
  76159. var i = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix()
  76160. , n = i.getTranslation()
  76161. , r = new x(0,0,-1)
  76162. , o = x.TransformNormal(r, i)
  76163. , a = x.Normalize(o);
  76164. return new _o(n,a,t)
  76165. }
  76166. ,
  76167. t.prototype.dispose = function() {
  76168. e.prototype.dispose.call(this),
  76169. this.onTrackpadChangedObservable.clear(),
  76170. this.onTrackpadValuesChangedObservable.clear()
  76171. }
  76172. ,
  76173. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/",
  76174. t.MODEL_LEFT_FILENAME = "left.glb",
  76175. t.MODEL_RIGHT_FILENAME = "right.glb",
  76176. t.GAMEPAD_ID_PREFIX = "Spatial Controller (Spatial Interaction Source) ",
  76177. t.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,
  76178. t
  76179. }(_s)
  76180. , pd = function(e) {
  76181. function t(t) {
  76182. var i = e.call(this, t) || this;
  76183. return i._mapping = {
  76184. buttons: ["trigger", "grip", "trackpad", "thumbstick", "menu"],
  76185. buttonMeshNames: {
  76186. trigger: "SELECT",
  76187. menu: "MENU",
  76188. grip: "GRASP",
  76189. thumbstick: "THUMBSTICK_PRESS",
  76190. trackpad: "TOUCHPAD_PRESS"
  76191. },
  76192. buttonObservableNames: {
  76193. trigger: "onTriggerStateChangedObservable",
  76194. menu: "onSecondaryButtonStateChangedObservable",
  76195. grip: "onMainButtonStateChangedObservable",
  76196. thumbstick: "onThumbstickStateChangedObservable",
  76197. trackpad: "onTrackpadChangedObservable"
  76198. },
  76199. axisMeshNames: ["TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y", "THUMBSTICK_X", "THUMBSTICK_Y"],
  76200. pointingPoseMeshName: Ra.POINTING_POSE
  76201. },
  76202. i.thumbstickValues = {
  76203. x: 0,
  76204. y: 0
  76205. },
  76206. i.onThumbstickStateChangedObservable = new h,
  76207. i.onThumbstickValuesChangedObservable = new h,
  76208. i.onTrackpadChangedObservable = i.onPadStateChangedObservable,
  76209. i.onTrackpadValuesChangedObservable = i.onPadValuesChangedObservable,
  76210. i
  76211. }
  76212. return U(t, e),
  76213. Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", {
  76214. get: function() {
  76215. return this.onThumbstickStateChangedObservable
  76216. },
  76217. enumerable: !1,
  76218. configurable: !0
  76219. }),
  76220. t.prototype._updateTrackpad = function() {
  76221. !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.thumbstickValues.x && this.browserGamepad.axes[3] == this.thumbstickValues.y || (this.trackpad.x = this.browserGamepad.axes[2],
  76222. this.trackpad.y = this.browserGamepad.axes[3],
  76223. this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad))
  76224. }
  76225. ,
  76226. t.prototype.dispose = function() {
  76227. e.prototype.dispose.call(this),
  76228. this.onThumbstickStateChangedObservable.clear(),
  76229. this.onThumbstickValuesChangedObservable.clear()
  76230. }
  76231. ,
  76232. t
  76233. }(dd);
  76234. xa._ControllerFactories.push({
  76235. canCreate: function(e) {
  76236. return 0 === e.id.indexOf(dd.GAMEPAD_ID_PREFIX)
  76237. },
  76238. create: function(e) {
  76239. return new dd(e)
  76240. }
  76241. });
  76242. var fd = function(e) {
  76243. function t(t, i, n, r, o) {
  76244. void 0 === i && (i = D.Gray()),
  76245. void 0 === n && (n = El.DefaultUtilityLayer),
  76246. void 0 === r && (r = null),
  76247. void 0 === o && (o = 1);
  76248. var a, s, l, c, u, d, p, f = this;
  76249. (f = e.call(this, n) || this)._pointerObserver = null,
  76250. f.snapDistance = 0,
  76251. f.onSnapObservable = new h,
  76252. f.uniformScaling = !1,
  76253. f.sensitivity = 1,
  76254. f.dragScale = 1,
  76255. f._isEnabled = !0,
  76256. f._parent = null,
  76257. f._dragging = !1,
  76258. f._tmpVector = new x,
  76259. f._tmpMatrix = new P,
  76260. f._tmpMatrix2 = new P,
  76261. f._parent = r,
  76262. f._coloredMaterial = new Os("",n.utilityLayerScene),
  76263. f._coloredMaterial.diffuseColor = i,
  76264. f._coloredMaterial.specularColor = i.subtract(new D(.1,.1,.1)),
  76265. f._hoverMaterial = new Os("",n.utilityLayerScene),
  76266. f._hoverMaterial.diffuseColor = D.Yellow(),
  76267. f._disableMaterial = new Os("",n.utilityLayerScene),
  76268. f._disableMaterial.diffuseColor = D.Gray(),
  76269. f._disableMaterial.alpha = .4,
  76270. f._gizmoMesh = new Vr("axis",n.utilityLayerScene);
  76271. var _ = f._createGizmoMesh(f._gizmoMesh, o)
  76272. , m = _.arrowMesh
  76273. , g = _.arrowTail
  76274. , v = f._createGizmoMesh(f._gizmoMesh, o + 4, !0);
  76275. f._gizmoMesh.lookAt(f._rootMesh.position.add(t)),
  76276. f._rootMesh.addChild(f._gizmoMesh),
  76277. f._gizmoMesh.scaling.scaleInPlace(1 / 3);
  76278. var y = m.position.clone()
  76279. , b = g.position.clone()
  76280. , T = g.scaling.clone()
  76281. , E = function(e) {
  76282. var t = e * (3 / f._rootMesh.scaling.length()) * 6;
  76283. m.position.z += t / 3.5,
  76284. g.scaling.y += t,
  76285. f.dragScale = g.scaling.y,
  76286. g.position.z = m.position.z / 2
  76287. }
  76288. , S = function() {
  76289. m.position.set(y.x, y.y, y.z),
  76290. g.position.set(b.x, b.y, b.z),
  76291. g.scaling.set(T.x, T.y, T.z),
  76292. f.dragScale = g.scaling.y,
  76293. f._dragging = !1
  76294. };
  76295. f.dragBehavior = new Ao({
  76296. dragAxis: t
  76297. }),
  76298. f.dragBehavior.moveAttached = !1,
  76299. f._rootMesh.addBehavior(f.dragBehavior);
  76300. var A = 0
  76301. , R = new x
  76302. , C = {
  76303. snapDistance: 0
  76304. };
  76305. f.dragBehavior.onDragObservable.add((function(e) {
  76306. if (f.attachedNode) {
  76307. f._handlePivot();
  76308. var i = f.sensitivity * e.dragDistance * (3 * f.scaleRatio / f._rootMesh.scaling.length())
  76309. , n = !1
  76310. , r = 0;
  76311. f.uniformScaling ? R.setAll(.57735) : R.copyFrom(t),
  76312. 0 == f.snapDistance ? R.scaleToRef(i, R) : (A += i,
  76313. Math.abs(A) > f.snapDistance ? (r = Math.floor(Math.abs(A) / f.snapDistance),
  76314. A < 0 && (r *= -1),
  76315. A %= f.snapDistance,
  76316. R.scaleToRef(f.snapDistance * r, R),
  76317. n = !0) : R.scaleInPlace(0)),
  76318. P.ScalingToRef(1 + R.x, 1 + R.y, 1 + R.z, f._tmpMatrix2),
  76319. f._tmpMatrix2.multiplyToRef(f.attachedNode.getWorldMatrix(), f._tmpMatrix),
  76320. f._tmpMatrix.decompose(f._tmpVector);
  76321. var o = 1e5;
  76322. Math.abs(f._tmpVector.x) < o && Math.abs(f._tmpVector.y) < o && Math.abs(f._tmpVector.z) < o && f.attachedNode.getWorldMatrix().copyFrom(f._tmpMatrix),
  76323. n && (C.snapDistance = f.snapDistance * r,
  76324. f.onSnapObservable.notifyObservers(C)),
  76325. f._matrixChanged()
  76326. }
  76327. }
  76328. )),
  76329. f.dragBehavior.onDragStartObservable.add((function() {
  76330. f._dragging = !0
  76331. }
  76332. )),
  76333. f.dragBehavior.onDragObservable.add((function(e) {
  76334. return E(e.dragDistance)
  76335. }
  76336. )),
  76337. f.dragBehavior.onDragEndObservable.add(S),
  76338. null === (l = null === (s = null === (a = null == r ? void 0 : r.uniformScaleGizmo) || void 0 === a ? void 0 : a.dragBehavior) || void 0 === s ? void 0 : s.onDragObservable) || void 0 === l || l.add((function(e) {
  76339. return E(e.delta.y)
  76340. }
  76341. )),
  76342. null === (d = null === (u = null === (c = null == r ? void 0 : r.uniformScaleGizmo) || void 0 === c ? void 0 : c.dragBehavior) || void 0 === u ? void 0 : u.onDragEndObservable) || void 0 === d || d.add(S);
  76343. var M = {
  76344. gizmoMeshes: [m, g],
  76345. colliderMeshes: [v.arrowMesh, v.arrowTail],
  76346. material: f._coloredMaterial,
  76347. hoverMaterial: f._hoverMaterial,
  76348. disableMaterial: f._disableMaterial,
  76349. active: !1,
  76350. dragBehavior: f.dragBehavior
  76351. };
  76352. null === (p = f._parent) || void 0 === p || p.addToAxisCache(f._gizmoMesh, M),
  76353. f._pointerObserver = n.utilityLayerScene.onPointerObservable.add((function(e) {
  76354. var t;
  76355. if (!f._customMeshSet && (f._isHovered = !(-1 == M.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
  76356. !f._parent)) {
  76357. var i = f.dragBehavior.enabled ? f._isHovered || f._dragging ? f._hoverMaterial : f._coloredMaterial : f._disableMaterial;
  76358. f._setGizmoMeshMaterial(M.gizmoMeshes, i)
  76359. }
  76360. }
  76361. )),
  76362. f.dragBehavior.onEnabledObservable.add((function(e) {
  76363. f._setGizmoMeshMaterial(M.gizmoMeshes, e ? f._coloredMaterial : f._disableMaterial)
  76364. }
  76365. ));
  76366. var I = n._getSharedGizmoLight();
  76367. return I.includedOnlyMeshes = I.includedOnlyMeshes.concat(f._rootMesh.getChildMeshes()),
  76368. f
  76369. }
  76370. return U(t, e),
  76371. t.prototype._createGizmoMesh = function(e, t, i) {
  76372. void 0 === i && (i = !1);
  76373. var n = Ml("yPosMesh", {
  76374. size: .4 * (1 + (t - 1) / 4)
  76375. }, this.gizmoLayer.utilityLayerScene)
  76376. , r = Ys("cylinder", {
  76377. diameterTop: .005 * t,
  76378. height: .275,
  76379. diameterBottom: .005 * t,
  76380. tessellation: 96
  76381. }, this.gizmoLayer.utilityLayerScene);
  76382. return n.scaling.scaleInPlace(.1),
  76383. n.material = this._coloredMaterial,
  76384. n.rotation.x = Math.PI / 2,
  76385. n.position.z += .3,
  76386. r.material = this._coloredMaterial,
  76387. r.position.z += .1375,
  76388. r.rotation.x = Math.PI / 2,
  76389. i && (n.visibility = 0,
  76390. r.visibility = 0),
  76391. e.addChild(n),
  76392. e.addChild(r),
  76393. {
  76394. arrowMesh: n,
  76395. arrowTail: r
  76396. }
  76397. }
  76398. ,
  76399. t.prototype._attachedNodeChanged = function(e) {
  76400. this.dragBehavior && (this.dragBehavior.enabled = !!e)
  76401. }
  76402. ,
  76403. Object.defineProperty(t.prototype, "isEnabled", {
  76404. get: function() {
  76405. return this._isEnabled
  76406. },
  76407. set: function(e) {
  76408. this._isEnabled = e,
  76409. e ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
  76410. this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
  76411. this.attachedNode = null)
  76412. },
  76413. enumerable: !1,
  76414. configurable: !0
  76415. }),
  76416. t.prototype.dispose = function() {
  76417. this.onSnapObservable.clear(),
  76418. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  76419. this.dragBehavior.detach(),
  76420. this._gizmoMesh && this._gizmoMesh.dispose(),
  76421. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
  76422. e && e.dispose()
  76423. }
  76424. )),
  76425. e.prototype.dispose.call(this)
  76426. }
  76427. ,
  76428. t.prototype.setCustomMesh = function(t, i) {
  76429. var n = this;
  76430. void 0 === i && (i = !1),
  76431. e.prototype.setCustomMesh.call(this, t),
  76432. i && (this._rootMesh.getChildMeshes().forEach((function(e) {
  76433. e.material = n._coloredMaterial,
  76434. e.color && (e.color = n._coloredMaterial.diffuseColor)
  76435. }
  76436. )),
  76437. this._customMeshSet = !1)
  76438. }
  76439. ,
  76440. t
  76441. }(Sl)
  76442. , _d = function(e) {
  76443. function t(t, i) {
  76444. void 0 === t && (t = D.Gray()),
  76445. void 0 === i && (i = El.DefaultKeepDepthUtilityLayer);
  76446. var n = e.call(this, i) || this;
  76447. n._boundingDimensions = new x(1,1,1),
  76448. n._renderObserver = null,
  76449. n._pointerObserver = null,
  76450. n._scaleDragSpeed = .2,
  76451. n._tmpQuaternion = new C,
  76452. n._tmpVector = new x(0,0,0),
  76453. n._tmpRotationMatrix = new P,
  76454. n.ignoreChildren = !1,
  76455. n.includeChildPredicate = null,
  76456. n.rotationSphereSize = .1,
  76457. n.scaleBoxSize = .1,
  76458. n.fixedDragMeshScreenSize = !1,
  76459. n.fixedDragMeshBoundsSize = !1,
  76460. n.fixedDragMeshScreenSizeDistanceFactor = 10,
  76461. n.onDragStartObservable = new h,
  76462. n.onScaleBoxDragObservable = new h,
  76463. n.onScaleBoxDragEndObservable = new h,
  76464. n.onRotationSphereDragObservable = new h,
  76465. n.onRotationSphereDragEndObservable = new h,
  76466. n.scalePivot = null,
  76467. n._axisFactor = new x(1,1,1),
  76468. n._existingMeshScale = new x,
  76469. n._dragMesh = null,
  76470. n._pointerDragBehavior = new Ao,
  76471. n.updateScale = !1,
  76472. n._anchorMesh = new Sr("anchor",i.utilityLayerScene),
  76473. n._coloredMaterial = new Os("",i.utilityLayerScene),
  76474. n._coloredMaterial.disableLighting = !0,
  76475. n._hoverColoredMaterial = new Os("",i.utilityLayerScene),
  76476. n._hoverColoredMaterial.disableLighting = !0,
  76477. n._lineBoundingBox = new Sr("",i.utilityLayerScene),
  76478. n._lineBoundingBox.rotationQuaternion = new C;
  76479. var r = [];
  76480. r.push(Jl("lines", {
  76481. points: [new x(0,0,0), new x(n._boundingDimensions.x,0,0)]
  76482. }, i.utilityLayerScene)),
  76483. r.push(Jl("lines", {
  76484. points: [new x(0,0,0), new x(0,n._boundingDimensions.y,0)]
  76485. }, i.utilityLayerScene)),
  76486. r.push(Jl("lines", {
  76487. points: [new x(0,0,0), new x(0,0,n._boundingDimensions.z)]
  76488. }, i.utilityLayerScene)),
  76489. r.push(Jl("lines", {
  76490. points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
  76491. }, i.utilityLayerScene)),
  76492. r.push(Jl("lines", {
  76493. points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
  76494. }, i.utilityLayerScene)),
  76495. r.push(Jl("lines", {
  76496. points: [new x(0,n._boundingDimensions.y,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
  76497. }, i.utilityLayerScene)),
  76498. r.push(Jl("lines", {
  76499. points: [new x(0,n._boundingDimensions.y,0), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
  76500. }, i.utilityLayerScene)),
  76501. r.push(Jl("lines", {
  76502. points: [new x(0,0,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
  76503. }, i.utilityLayerScene)),
  76504. r.push(Jl("lines", {
  76505. points: [new x(0,0,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
  76506. }, i.utilityLayerScene)),
  76507. r.push(Jl("lines", {
  76508. points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
  76509. }, i.utilityLayerScene)),
  76510. r.push(Jl("lines", {
  76511. points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
  76512. }, i.utilityLayerScene)),
  76513. r.push(Jl("lines", {
  76514. points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
  76515. }, i.utilityLayerScene)),
  76516. r.forEach((function(e) {
  76517. e.color = t,
  76518. e.position.addInPlace(new x(-n._boundingDimensions.x / 2,-n._boundingDimensions.y / 2,-n._boundingDimensions.z / 2)),
  76519. e.isPickable = !1,
  76520. n._lineBoundingBox.addChild(e)
  76521. }
  76522. )),
  76523. n._rootMesh.addChild(n._lineBoundingBox),
  76524. n.setColor(t),
  76525. n._rotateSpheresParent = new Sr("",i.utilityLayerScene),
  76526. n._rotateSpheresParent.rotationQuaternion = new C;
  76527. for (var o = function(e) {
  76528. var t = Dl("", {
  76529. diameter: 1
  76530. }, i.utilityLayerScene);
  76531. t.rotationQuaternion = new C,
  76532. t.material = a._coloredMaterial,
  76533. t.isNearGrabbable = !0;
  76534. var r = new Ao({});
  76535. r.moveAttached = !1,
  76536. r.updateDragPlane = !1,
  76537. t.addBehavior(r);
  76538. var o = new x(1,0,0)
  76539. , s = 0;
  76540. r.onDragStartObservable.add((function() {
  76541. o.copyFrom(t.forward),
  76542. s = 0
  76543. }
  76544. )),
  76545. r.onDragObservable.add((function(t) {
  76546. if (n.onRotationSphereDragObservable.notifyObservers({}),
  76547. n.attachedMesh) {
  76548. var i = n.attachedMesh.parent;
  76549. if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
  76550. return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  76551. mo._RemoveAndStorePivotPoint(n.attachedMesh);
  76552. var r = o
  76553. , a = t.dragPlaneNormal.scale(x.Dot(t.dragPlaneNormal, r))
  76554. , l = r.subtract(a).normalizeToNew()
  76555. , c = x.Dot(l, t.delta) < 0 ? Math.abs(t.delta.length()) : -Math.abs(t.delta.length());
  76556. c = c / n._boundingDimensions.length() * n._anchorMesh.scaling.length(),
  76557. n.attachedMesh.rotationQuaternion || (n.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(n.attachedMesh.rotation.y, n.attachedMesh.rotation.x, n.attachedMesh.rotation.z)),
  76558. n._anchorMesh.rotationQuaternion || (n._anchorMesh.rotationQuaternion = C.RotationYawPitchRoll(n._anchorMesh.rotation.y, n._anchorMesh.rotation.x, n._anchorMesh.rotation.z)),
  76559. s += c,
  76560. Math.abs(s) <= 2 * Math.PI && (e >= 8 ? C.RotationYawPitchRollToRef(0, 0, c, n._tmpQuaternion) : e >= 4 ? C.RotationYawPitchRollToRef(c, 0, 0, n._tmpQuaternion) : C.RotationYawPitchRollToRef(0, c, 0, n._tmpQuaternion),
  76561. n._anchorMesh.addChild(n.attachedMesh),
  76562. n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion, n._anchorMesh.rotationQuaternion),
  76563. n._anchorMesh.removeChild(n.attachedMesh),
  76564. n.attachedMesh.setParent(i)),
  76565. n.updateBoundingBox(),
  76566. mo._RestorePivotPoint(n.attachedMesh)
  76567. }
  76568. n._updateDummy()
  76569. }
  76570. )),
  76571. r.onDragStartObservable.add((function() {
  76572. n.onDragStartObservable.notifyObservers({}),
  76573. n._selectNode(t)
  76574. }
  76575. )),
  76576. r.onDragEndObservable.add((function() {
  76577. n.onRotationSphereDragEndObservable.notifyObservers({}),
  76578. n._selectNode(null),
  76579. n._updateDummy()
  76580. }
  76581. )),
  76582. a._rotateSpheresParent.addChild(t)
  76583. }, a = this, s = 0; s < 12; s++)
  76584. o(s);
  76585. for (n._rootMesh.addChild(n._rotateSpheresParent),
  76586. n._scaleBoxesParent = new Sr("",i.utilityLayerScene),
  76587. n._scaleBoxesParent.rotationQuaternion = new C,
  76588. s = 0; s < 3; s++)
  76589. for (var l = 0; l < 3; l++)
  76590. for (var c = function(e) {
  76591. var t = (1 === s ? 1 : 0) + (1 === l ? 1 : 0) + (1 === e ? 1 : 0);
  76592. if (1 === t || 3 === t)
  76593. return "continue";
  76594. var r = Ml("", {
  76595. size: 1
  76596. }, i.utilityLayerScene);
  76597. r.material = u._coloredMaterial,
  76598. r.metadata = 2 === t,
  76599. r.isNearGrabbable = !0;
  76600. var o = new x(s - 1,l - 1,e - 1).normalize()
  76601. , a = new Ao({
  76602. dragAxis: o
  76603. });
  76604. a.updateDragPlane = !1,
  76605. a.moveAttached = !1,
  76606. r.addBehavior(a),
  76607. a.onDragObservable.add((function(e) {
  76608. if (n.onScaleBoxDragObservable.notifyObservers({}),
  76609. n.attachedMesh) {
  76610. var i = n.attachedMesh.parent;
  76611. if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
  76612. return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  76613. mo._RemoveAndStorePivotPoint(n.attachedMesh);
  76614. var a = e.dragDistance / n._boundingDimensions.length() * n._anchorMesh.scaling.length()
  76615. , s = new x(a,a,a);
  76616. 2 === t && (s.x *= Math.abs(o.x),
  76617. s.y *= Math.abs(o.y),
  76618. s.z *= Math.abs(o.z)),
  76619. s.scaleInPlace(n._scaleDragSpeed),
  76620. s.multiplyInPlace(n._axisFactor),
  76621. n.updateBoundingBox(),
  76622. n.scalePivot ? (n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),
  76623. n._boundingDimensions.scaleToRef(.5, n._tmpVector),
  76624. x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
  76625. n._anchorMesh.position.subtractInPlace(n._tmpVector),
  76626. n._boundingDimensions.multiplyToRef(n.scalePivot, n._tmpVector),
  76627. x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
  76628. n._anchorMesh.position.addInPlace(n._tmpVector)) : (r.absolutePosition.subtractToRef(n._anchorMesh.position, n._tmpVector),
  76629. n._anchorMesh.position.subtractInPlace(n._tmpVector)),
  76630. n._anchorMesh.addChild(n.attachedMesh),
  76631. n._anchorMesh.scaling.addInPlace(s),
  76632. (n._anchorMesh.scaling.x < 0 || n._anchorMesh.scaling.y < 0 || n._anchorMesh.scaling.z < 0) && n._anchorMesh.scaling.subtractInPlace(s),
  76633. n._anchorMesh.removeChild(n.attachedMesh),
  76634. n.attachedMesh.setParent(i),
  76635. mo._RestorePivotPoint(n.attachedMesh)
  76636. }
  76637. n._updateDummy()
  76638. }
  76639. )),
  76640. a.onDragStartObservable.add((function() {
  76641. n.onDragStartObservable.notifyObservers({}),
  76642. n._selectNode(r)
  76643. }
  76644. )),
  76645. a.onDragEndObservable.add((function() {
  76646. n.onScaleBoxDragEndObservable.notifyObservers({}),
  76647. n._selectNode(null),
  76648. n._updateDummy()
  76649. }
  76650. )),
  76651. u._scaleBoxesParent.addChild(r)
  76652. }, u = this, d = 0; d < 3; d++)
  76653. c(d);
  76654. n._rootMesh.addChild(n._scaleBoxesParent);
  76655. var p = new Array;
  76656. return n._pointerObserver = i.utilityLayerScene.onPointerObservable.add((function(e) {
  76657. p[e.event.pointerId] ? e.pickInfo && e.pickInfo.pickedMesh != p[e.event.pointerId] && (p[e.event.pointerId].material = n._coloredMaterial,
  76658. delete p[e.event.pointerId]) : n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t) {
  76659. e.pickInfo && e.pickInfo.pickedMesh == t && (p[e.event.pointerId] = t,
  76660. t.material = n._hoverColoredMaterial)
  76661. }
  76662. ))
  76663. }
  76664. )),
  76665. n._renderObserver = n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function() {
  76666. n.attachedMesh && !n._existingMeshScale.equals(n.attachedMesh.scaling) ? n.updateBoundingBox() : (n.fixedDragMeshScreenSize || n.fixedDragMeshBoundsSize) && (n._updateRotationSpheres(),
  76667. n._updateScaleBoxes()),
  76668. n._dragMesh && n.attachedMesh && n._pointerDragBehavior.dragging && (n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion, n._tmpVector),
  76669. n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))
  76670. }
  76671. )),
  76672. n.updateBoundingBox(),
  76673. n
  76674. }
  76675. return U(t, e),
  76676. Object.defineProperty(t.prototype, "axisFactor", {
  76677. get: function() {
  76678. return this._axisFactor
  76679. },
  76680. set: function(e) {
  76681. this._axisFactor = e;
  76682. for (var t = this._scaleBoxesParent.getChildMeshes(), i = 0, n = 0; n < 3; n++)
  76683. for (var r = 0; r < 3; r++)
  76684. for (var o = 0; o < 3; o++) {
  76685. var a = (1 === n ? 1 : 0) + (1 === r ? 1 : 0) + (1 === o ? 1 : 0);
  76686. if (1 !== a && 3 !== a) {
  76687. if (t[i]) {
  76688. var s = new x(n - 1,r - 1,o - 1);
  76689. s.multiplyInPlace(this._axisFactor),
  76690. t[i].setEnabled(s.lengthSquared() > m)
  76691. }
  76692. i++
  76693. }
  76694. }
  76695. },
  76696. enumerable: !1,
  76697. configurable: !0
  76698. }),
  76699. Object.defineProperty(t.prototype, "scaleDragSpeed", {
  76700. get: function() {
  76701. return this._scaleDragSpeed
  76702. },
  76703. set: function(e) {
  76704. this._scaleDragSpeed = e
  76705. },
  76706. enumerable: !1,
  76707. configurable: !0
  76708. }),
  76709. t.prototype.setColor = function(e) {
  76710. this._coloredMaterial.emissiveColor = e,
  76711. this._hoverColoredMaterial.emissiveColor = e.clone().add(new D(.3,.3,.3)),
  76712. this._lineBoundingBox.getChildren().forEach((function(t) {
  76713. t.color && (t.color = e)
  76714. }
  76715. ))
  76716. }
  76717. ,
  76718. t.prototype._attachedNodeChanged = function(e) {
  76719. var t = this;
  76720. if (e) {
  76721. this._anchorMesh.scaling.setAll(1),
  76722. mo._RemoveAndStorePivotPoint(e);
  76723. var i = e.parent;
  76724. this._anchorMesh.addChild(e),
  76725. this._anchorMesh.removeChild(e),
  76726. e.setParent(i),
  76727. mo._RestorePivotPoint(e),
  76728. this.updateBoundingBox(),
  76729. e.getChildMeshes(!1).forEach((function(e) {
  76730. e.markAsDirty("scaling")
  76731. }
  76732. )),
  76733. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function() {
  76734. t._updateDummy()
  76735. }
  76736. ))
  76737. }
  76738. }
  76739. ,
  76740. t.prototype._selectNode = function(e) {
  76741. this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t) {
  76742. t.isVisible = !e || t == e
  76743. }
  76744. ))
  76745. }
  76746. ,
  76747. t.prototype.updateBoundingBox = function() {
  76748. if (this.attachedMesh) {
  76749. mo._RemoveAndStorePivotPoint(this.attachedMesh);
  76750. var e = this.attachedMesh.parent;
  76751. this.attachedMesh.setParent(null),
  76752. this._update(),
  76753. this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)),
  76754. this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = C.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)),
  76755. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
  76756. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
  76757. this._tmpVector.copyFrom(this.attachedMesh.position),
  76758. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1),
  76759. this.attachedMesh.position.set(0, 0, 0);
  76760. var t = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  76761. t.max.subtractToRef(t.min, this._boundingDimensions),
  76762. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),
  76763. this._lineBoundingBox.position.set((t.max.x + t.min.x) / 2, (t.max.y + t.min.y) / 2, (t.max.z + t.min.z) / 2),
  76764. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),
  76765. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),
  76766. this._lineBoundingBox.computeWorldMatrix(),
  76767. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),
  76768. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),
  76769. this.attachedMesh.position.copyFrom(this._tmpVector),
  76770. this.attachedMesh.setParent(e)
  76771. }
  76772. this._updateRotationSpheres(),
  76773. this._updateScaleBoxes(),
  76774. this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling),
  76775. mo._RestorePivotPoint(this.attachedMesh))
  76776. }
  76777. ,
  76778. t.prototype._updateRotationSpheres = function() {
  76779. for (var e = this._rotateSpheresParent.getChildMeshes(), t = 0; t < 3; t++)
  76780. for (var i = 0; i < 2; i++)
  76781. for (var n = 0; n < 2; n++) {
  76782. var r = 4 * t + 2 * i + n;
  76783. if (0 == t && (e[r].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * i, this._boundingDimensions.z * n),
  76784. e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  76785. e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Right()).normalizeToNew().add(e[r].position))),
  76786. 1 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y / 2, this._boundingDimensions.z * n),
  76787. e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  76788. e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Up()).normalizeToNew().add(e[r].position))),
  76789. 2 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * n, this._boundingDimensions.z / 2),
  76790. e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  76791. e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Forward()).normalizeToNew().add(e[r].position))),
  76792. this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  76793. e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  76794. var o = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  76795. e[r].scaling.set(o, o, o)
  76796. } else
  76797. this.fixedDragMeshBoundsSize ? e[r].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : e[r].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize)
  76798. }
  76799. }
  76800. ,
  76801. t.prototype._updateScaleBoxes = function() {
  76802. for (var e = this._scaleBoxesParent.getChildMeshes(), t = 0, i = 0; i < 3; i++)
  76803. for (var n = 0; n < 3; n++)
  76804. for (var r = 0; r < 3; r++) {
  76805. var o = (1 === i ? 1 : 0) + (1 === n ? 1 : 0) + (1 === r ? 1 : 0);
  76806. if (1 !== o && 3 !== o) {
  76807. if (e[t])
  76808. if (e[t].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (n / 2), this._boundingDimensions.z * (r / 2)),
  76809. e[t].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
  76810. this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  76811. e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  76812. var a = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  76813. e[t].scaling.set(a, a, a)
  76814. } else
  76815. this.fixedDragMeshBoundsSize ? e[t].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z) : e[t].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  76816. t++
  76817. }
  76818. }
  76819. }
  76820. ,
  76821. t.prototype.setEnabledRotationAxis = function(e) {
  76822. this._rotateSpheresParent.getChildMeshes().forEach((function(t, i) {
  76823. i < 4 ? t.setEnabled(-1 != e.indexOf("x")) : i < 8 ? t.setEnabled(-1 != e.indexOf("y")) : t.setEnabled(-1 != e.indexOf("z"))
  76824. }
  76825. ))
  76826. }
  76827. ,
  76828. t.prototype.setEnabledScaling = function(e, t) {
  76829. void 0 === t && (t = !1),
  76830. this._scaleBoxesParent.getChildMeshes().forEach((function(i) {
  76831. var n = e;
  76832. t && !0 === i.metadata && (n = !1),
  76833. i.setEnabled(n)
  76834. }
  76835. ))
  76836. }
  76837. ,
  76838. t.prototype._updateDummy = function() {
  76839. this._dragMesh && (this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),
  76840. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),
  76841. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))
  76842. }
  76843. ,
  76844. t.prototype.enableDragBehavior = function() {
  76845. this._dragMesh = Ml("dummy", {
  76846. size: 1
  76847. }, this.gizmoLayer.utilityLayerScene),
  76848. this._dragMesh.visibility = 0,
  76849. this._dragMesh.rotationQuaternion = new C,
  76850. this._pointerDragBehavior.useObjectOrientationForDragging = !1,
  76851. this._dragMesh.addBehavior(this._pointerDragBehavior)
  76852. }
  76853. ,
  76854. t.prototype.dispose = function() {
  76855. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  76856. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),
  76857. this._lineBoundingBox.dispose(),
  76858. this._rotateSpheresParent.dispose(),
  76859. this._scaleBoxesParent.dispose(),
  76860. this._dragMesh && this._dragMesh.dispose(),
  76861. e.prototype.dispose.call(this)
  76862. }
  76863. ,
  76864. t.MakeNotPickableAndWrapInBoundingBox = function(e) {
  76865. var t = function(e) {
  76866. e.isPickable = !1,
  76867. e.getChildMeshes().forEach((function(e) {
  76868. t(e)
  76869. }
  76870. ))
  76871. };
  76872. t(e),
  76873. e.rotationQuaternion || (e.rotationQuaternion = C.RotationYawPitchRoll(e.rotation.y, e.rotation.x, e.rotation.z));
  76874. var i = e.position.clone()
  76875. , n = e.rotationQuaternion.clone();
  76876. e.rotationQuaternion.set(0, 0, 0, 1),
  76877. e.position.set(0, 0, 0);
  76878. var r = Ml("box", {
  76879. size: 1
  76880. }, e.getScene())
  76881. , o = e.getHierarchyBoundingVectors();
  76882. return o.max.subtractToRef(o.min, r.scaling),
  76883. 0 === r.scaling.y && (r.scaling.y = m),
  76884. 0 === r.scaling.x && (r.scaling.x = m),
  76885. 0 === r.scaling.z && (r.scaling.z = m),
  76886. r.position.set((o.max.x + o.min.x) / 2, (o.max.y + o.min.y) / 2, (o.max.z + o.min.z) / 2),
  76887. e.addChild(r),
  76888. e.rotationQuaternion.copyFrom(n),
  76889. e.position.copyFrom(i),
  76890. e.removeChild(r),
  76891. r.addChild(e),
  76892. r.visibility = 0,
  76893. r
  76894. }
  76895. ,
  76896. t.prototype.setCustomMesh = function() {
  76897. K.Error("Custom meshes are not supported on this gizmo")
  76898. }
  76899. ,
  76900. t
  76901. }(Sl)
  76902. , md = function(e) {
  76903. function t(i, n, r, o, a, s, l) {
  76904. void 0 === n && (n = D.Gray()),
  76905. void 0 === r && (r = El.DefaultUtilityLayer),
  76906. void 0 === o && (o = 32),
  76907. void 0 === a && (a = null),
  76908. void 0 === s && (s = !1),
  76909. void 0 === l && (l = 1);
  76910. var c, u = this;
  76911. (u = e.call(this, r) || this)._pointerObserver = null,
  76912. u.snapDistance = 0,
  76913. u.onSnapObservable = new h,
  76914. u.angle = 0,
  76915. u._isEnabled = !0,
  76916. u._parent = null,
  76917. u._dragging = !1,
  76918. u._angles = new x,
  76919. u._parent = a,
  76920. u._coloredMaterial = new Os("",r.utilityLayerScene),
  76921. u._coloredMaterial.diffuseColor = n,
  76922. u._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
  76923. u._hoverMaterial = new Os("",r.utilityLayerScene),
  76924. u._hoverMaterial.diffuseColor = D.Yellow(),
  76925. u._disableMaterial = new Os("",r.utilityLayerScene),
  76926. u._disableMaterial.diffuseColor = D.Gray(),
  76927. u._disableMaterial.alpha = .4,
  76928. u._gizmoMesh = new Vr("",r.utilityLayerScene);
  76929. var d = u._createGizmoMesh(u._gizmoMesh, l, o)
  76930. , p = d.rotationMesh
  76931. , f = d.collider;
  76932. u._rotationDisplayPlane = vo("rotationDisplay", {
  76933. size: .6,
  76934. updatable: !1
  76935. }, u.gizmoLayer.utilityLayerScene),
  76936. u._rotationDisplayPlane.rotation.z = .5 * Math.PI,
  76937. u._rotationDisplayPlane.parent = u._gizmoMesh,
  76938. u._rotationDisplayPlane.setEnabled(!1),
  76939. Mt.ShadersStore.rotationGizmoVertexShader = t._RotationGizmoVertexShader,
  76940. Mt.ShadersStore.rotationGizmoFragmentShader = t._RotationGizmoFragmentShader,
  76941. u._rotationShaderMaterial = new jl("shader",u.gizmoLayer.utilityLayerScene,{
  76942. vertex: "rotationGizmo",
  76943. fragment: "rotationGizmo"
  76944. },{
  76945. attributes: ["position", "uv"],
  76946. uniforms: ["worldViewProjection", "angles"]
  76947. }),
  76948. u._rotationShaderMaterial.backFaceCulling = !1,
  76949. u._rotationDisplayPlane.material = u._rotationShaderMaterial,
  76950. u._rotationDisplayPlane.visibility = .999,
  76951. u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),
  76952. u._rootMesh.addChild(u._gizmoMesh),
  76953. u._gizmoMesh.scaling.scaleInPlace(1 / 3),
  76954. u.dragBehavior = new Ao({
  76955. dragPlaneNormal: i
  76956. }),
  76957. u.dragBehavior.moveAttached = !1,
  76958. u.dragBehavior.maxDragAngle = t.MaxDragAngle,
  76959. u.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0,
  76960. u._rootMesh.addBehavior(u.dragBehavior);
  76961. var _ = new x
  76962. , m = new P
  76963. , g = new x
  76964. , v = new x;
  76965. u.dragBehavior.onDragStartObservable.add((function(e) {
  76966. u.attachedNode && (_.copyFrom(e.dragPlanePoint),
  76967. u._rotationDisplayPlane.setEnabled(!0),
  76968. u._rotationDisplayPlane.getWorldMatrix().invertToRef(m),
  76969. x.TransformCoordinatesToRef(e.dragPlanePoint, m, _),
  76970. u._angles.x = Math.atan2(_.y, _.x) + Math.PI,
  76971. u._angles.y = 0,
  76972. u._angles.z = u.updateGizmoRotationToMatchAttachedMesh ? 1 : 0,
  76973. u._dragging = !0,
  76974. _.copyFrom(e.dragPlanePoint),
  76975. u._rotationShaderMaterial.setVector3("angles", u._angles),
  76976. u.angle = 0)
  76977. }
  76978. )),
  76979. u.dragBehavior.onDragEndObservable.add((function() {
  76980. u._dragging = !1,
  76981. u._rotationDisplayPlane.setEnabled(!1)
  76982. }
  76983. ));
  76984. var y = {
  76985. snapDistance: 0
  76986. }
  76987. , b = 0
  76988. , T = new P
  76989. , E = new C;
  76990. u.dragBehavior.onDragObservable.add((function(e) {
  76991. if (u.attachedNode) {
  76992. var t = new x(1,1,1)
  76993. , n = new C(0,0,0,1)
  76994. , o = new x(0,0,0);
  76995. u._handlePivot(),
  76996. u.attachedNode.getWorldMatrix().decompose(t, n, o);
  76997. var a = e.dragPlanePoint.subtract(o).normalize()
  76998. , s = _.subtract(o).normalize()
  76999. , l = x.Cross(a, s)
  77000. , c = x.Dot(a, s)
  77001. , h = Math.atan2(l.length(), c);
  77002. g.copyFrom(i),
  77003. v.copyFrom(i),
  77004. u.updateGizmoRotationToMatchAttachedMesh && (n.toRotationMatrix(m),
  77005. v = x.TransformCoordinates(g, m));
  77006. var d = !1;
  77007. if (r.utilityLayerScene.activeCamera) {
  77008. var p = r.utilityLayerScene.activeCamera.position.subtract(o).normalize();
  77009. x.Dot(p, v) > 0 && (g.scaleInPlace(-1),
  77010. v.scaleInPlace(-1),
  77011. d = !0)
  77012. }
  77013. x.Dot(v, l) > 0 && (h = -h);
  77014. var f = !1;
  77015. if (0 != u.snapDistance)
  77016. if (b += h,
  77017. Math.abs(b) > u.snapDistance) {
  77018. var S = Math.floor(Math.abs(b) / u.snapDistance);
  77019. b < 0 && (S *= -1),
  77020. b %= u.snapDistance,
  77021. h = u.snapDistance * S,
  77022. f = !0
  77023. } else
  77024. h = 0;
  77025. var A = Math.sin(h / 2);
  77026. if (E.set(g.x * A, g.y * A, g.z * A, Math.cos(h / 2)),
  77027. T.determinant() > 0) {
  77028. var R = new x;
  77029. E.toEulerAnglesToRef(R),
  77030. C.RotationYawPitchRollToRef(R.y, -R.x, -R.z, E)
  77031. }
  77032. u.updateGizmoRotationToMatchAttachedMesh ? n.multiplyToRef(E, n) : E.multiplyToRef(n, n),
  77033. u.attachedNode.getWorldMatrix().copyFrom(P.Compose(t, n, o)),
  77034. _.copyFrom(e.dragPlanePoint),
  77035. f && (y.snapDistance = h,
  77036. u.onSnapObservable.notifyObservers(y)),
  77037. u._angles.y += h,
  77038. u.angle += d ? -h : h,
  77039. u._rotationShaderMaterial.setVector3("angles", u._angles),
  77040. u._matrixChanged()
  77041. }
  77042. }
  77043. ));
  77044. var S = r._getSharedGizmoLight();
  77045. S.includedOnlyMeshes = S.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));
  77046. var A = {
  77047. colliderMeshes: [f],
  77048. gizmoMeshes: [p],
  77049. material: u._coloredMaterial,
  77050. hoverMaterial: u._hoverMaterial,
  77051. disableMaterial: u._disableMaterial,
  77052. active: !1,
  77053. dragBehavior: u.dragBehavior
  77054. };
  77055. return null === (c = u._parent) || void 0 === c || c.addToAxisCache(u._gizmoMesh, A),
  77056. u._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
  77057. var i;
  77058. if (!u._customMeshSet && (u.dragBehavior.maxDragAngle = t.MaxDragAngle,
  77059. u._isHovered = !(-1 == A.colliderMeshes.indexOf(null === (i = null == e ? void 0 : e.pickInfo) || void 0 === i ? void 0 : i.pickedMesh)),
  77060. !u._parent)) {
  77061. var n = A.dragBehavior.enabled ? u._isHovered || u._dragging ? u._hoverMaterial : u._coloredMaterial : u._disableMaterial;
  77062. u._setGizmoMeshMaterial(A.gizmoMeshes, n)
  77063. }
  77064. }
  77065. )),
  77066. u.dragBehavior.onEnabledObservable.add((function(e) {
  77067. u._setGizmoMeshMaterial(A.gizmoMeshes, e ? u._coloredMaterial : u._disableMaterial)
  77068. }
  77069. )),
  77070. u
  77071. }
  77072. return U(t, e),
  77073. t.prototype._createGizmoMesh = function(e, t, i) {
  77074. var n = qs("ignore", {
  77075. diameter: .6,
  77076. thickness: .03 * t,
  77077. tessellation: i
  77078. }, this.gizmoLayer.utilityLayerScene);
  77079. n.visibility = 0;
  77080. var r = qs("", {
  77081. diameter: .6,
  77082. thickness: .005 * t,
  77083. tessellation: i
  77084. }, this.gizmoLayer.utilityLayerScene);
  77085. return r.material = this._coloredMaterial,
  77086. r.rotation.x = Math.PI / 2,
  77087. n.rotation.x = Math.PI / 2,
  77088. e.addChild(r),
  77089. e.addChild(n),
  77090. {
  77091. rotationMesh: r,
  77092. collider: n
  77093. }
  77094. }
  77095. ,
  77096. t.prototype._attachedNodeChanged = function(e) {
  77097. this.dragBehavior && (this.dragBehavior.enabled = !!e)
  77098. }
  77099. ,
  77100. Object.defineProperty(t.prototype, "isEnabled", {
  77101. get: function() {
  77102. return this._isEnabled
  77103. },
  77104. set: function(e) {
  77105. this._isEnabled = e,
  77106. e ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null
  77107. },
  77108. enumerable: !1,
  77109. configurable: !0
  77110. }),
  77111. t.prototype.dispose = function() {
  77112. this.onSnapObservable.clear(),
  77113. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  77114. this.dragBehavior.detach(),
  77115. this._gizmoMesh && this._gizmoMesh.dispose(),
  77116. this._rotationDisplayPlane && this._rotationDisplayPlane.dispose(),
  77117. this._rotationShaderMaterial && this._rotationShaderMaterial.dispose(),
  77118. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
  77119. e && e.dispose()
  77120. }
  77121. )),
  77122. e.prototype.dispose.call(this)
  77123. }
  77124. ,
  77125. t.MaxDragAngle = 9 * Math.PI / 20,
  77126. t._RotationGizmoVertexShader = "\n precision highp float;\n attribute vec3 position;\n attribute vec2 uv;\n uniform mat4 worldViewProjection;\n varying vec3 vPosition;\n varying vec2 vUV;\n void main(void) {\n gl_Position = worldViewProjection * vec4(position, 1.0);\n vUV = uv;\n }",
  77127. t._RotationGizmoFragmentShader = "\n precision highp float;\n varying vec2 vUV;\n varying vec3 vPosition;\n uniform vec3 angles;\n #define twopi 6.283185307\n void main(void) {\n vec2 uv = vUV - vec2(0.5);\n float angle = atan(uv.y, uv.x) + 3.141592;\n float delta = gl_FrontFacing ? angles.y : -angles.y;\n float begin = angles.x - delta * angles.z;\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\n float len = sqrt(dot(uv,uv));\n float opacity = 1. - step(0.5, len);\n\n float base = abs(floor(start / twopi)) * twopi;\n start += base;\n end += base;\n\n float intensity = 0.;\n for (int i = 0; i < 5; i++)\n {\n intensity += max(step(start, angle) - step(end, angle), 0.);\n angle += twopi;\n }\n gl_FragColor = vec4(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;\n }",
  77128. t
  77129. }(Sl)
  77130. , gd = function(e) {
  77131. function t(t, i, n, r, o, a) {
  77132. void 0 === t && (t = El.DefaultUtilityLayer),
  77133. void 0 === i && (i = 32),
  77134. void 0 === n && (n = !1),
  77135. void 0 === r && (r = 1);
  77136. var s = e.call(this, t) || this;
  77137. s.onDragStartObservable = new h,
  77138. s.onDragEndObservable = new h,
  77139. s._observables = [],
  77140. s._gizmoAxisCache = new Map;
  77141. var l = a && a.xOptions && a.xOptions.color ? a.xOptions.color : D.Red().scale(.5)
  77142. , c = a && a.yOptions && a.yOptions.color ? a.yOptions.color : D.Green().scale(.5)
  77143. , u = a && a.zOptions && a.zOptions.color ? a.zOptions.color : D.Blue().scale(.5);
  77144. return s.xGizmo = new md(new x(1,0,0),l,t,i,s,n,r),
  77145. s.yGizmo = new md(new x(0,1,0),c,t,i,s,n,r),
  77146. s.zGizmo = new md(new x(0,0,1),u,t,i,s,n,r),
  77147. [s.xGizmo, s.yGizmo, s.zGizmo].forEach((function(e) {
  77148. a && null != a.updateScale && (e.updateScale = a.updateScale),
  77149. e.dragBehavior.onDragStartObservable.add((function() {
  77150. s.onDragStartObservable.notifyObservers({})
  77151. }
  77152. )),
  77153. e.dragBehavior.onDragEndObservable.add((function() {
  77154. s.onDragEndObservable.notifyObservers({})
  77155. }
  77156. ))
  77157. }
  77158. )),
  77159. s.attachedMesh = null,
  77160. s.attachedNode = null,
  77161. o ? o.addToAxisCache(s._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, s._gizmoAxisCache),
  77162. s
  77163. }
  77164. return U(t, e),
  77165. Object.defineProperty(t.prototype, "attachedMesh", {
  77166. get: function() {
  77167. return this._meshAttached
  77168. },
  77169. set: function(e) {
  77170. this._meshAttached = e,
  77171. this._nodeAttached = e,
  77172. this._checkBillboardTransform(),
  77173. [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
  77174. t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
  77175. }
  77176. ))
  77177. },
  77178. enumerable: !1,
  77179. configurable: !0
  77180. }),
  77181. Object.defineProperty(t.prototype, "attachedNode", {
  77182. get: function() {
  77183. return this._nodeAttached
  77184. },
  77185. set: function(e) {
  77186. this._meshAttached = null,
  77187. this._nodeAttached = e,
  77188. this._checkBillboardTransform(),
  77189. [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
  77190. t.isEnabled ? t.attachedNode = e : t.attachedNode = null
  77191. }
  77192. ))
  77193. },
  77194. enumerable: !1,
  77195. configurable: !0
  77196. }),
  77197. t.prototype._checkBillboardTransform = function() {
  77198. this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.")
  77199. }
  77200. ,
  77201. Object.defineProperty(t.prototype, "isHovered", {
  77202. get: function() {
  77203. var e = !1;
  77204. return [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
  77205. e = e || t.isHovered
  77206. }
  77207. )),
  77208. e
  77209. },
  77210. enumerable: !1,
  77211. configurable: !0
  77212. }),
  77213. Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  77214. get: function() {
  77215. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh
  77216. },
  77217. set: function(e) {
  77218. this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = e,
  77219. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = e,
  77220. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = e)
  77221. },
  77222. enumerable: !1,
  77223. configurable: !0
  77224. }),
  77225. Object.defineProperty(t.prototype, "snapDistance", {
  77226. get: function() {
  77227. return this.xGizmo.snapDistance
  77228. },
  77229. set: function(e) {
  77230. this.xGizmo && (this.xGizmo.snapDistance = e,
  77231. this.yGizmo.snapDistance = e,
  77232. this.zGizmo.snapDistance = e)
  77233. },
  77234. enumerable: !1,
  77235. configurable: !0
  77236. }),
  77237. Object.defineProperty(t.prototype, "scaleRatio", {
  77238. get: function() {
  77239. return this.xGizmo.scaleRatio
  77240. },
  77241. set: function(e) {
  77242. this.xGizmo && (this.xGizmo.scaleRatio = e,
  77243. this.yGizmo.scaleRatio = e,
  77244. this.zGizmo.scaleRatio = e)
  77245. },
  77246. enumerable: !1,
  77247. configurable: !0
  77248. }),
  77249. t.prototype.addToAxisCache = function(e, t) {
  77250. this._gizmoAxisCache.set(e, t)
  77251. }
  77252. ,
  77253. t.prototype.dispose = function() {
  77254. var e = this;
  77255. this.xGizmo.dispose(),
  77256. this.yGizmo.dispose(),
  77257. this.zGizmo.dispose(),
  77258. this.onDragStartObservable.clear(),
  77259. this.onDragEndObservable.clear(),
  77260. this._observables.forEach((function(t) {
  77261. e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
  77262. }
  77263. ))
  77264. }
  77265. ,
  77266. t.prototype.setCustomMesh = function() {
  77267. K.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")
  77268. }
  77269. ,
  77270. t
  77271. }(Sl)
  77272. , vd = function(e) {
  77273. function t(i, n, r, o) {
  77274. void 0 === n && (n = D.Gray()),
  77275. void 0 === r && (r = El.DefaultUtilityLayer),
  77276. void 0 === o && (o = null);
  77277. var a, s = this;
  77278. (s = e.call(this, r) || this)._pointerObserver = null,
  77279. s.snapDistance = 0,
  77280. s.onSnapObservable = new h,
  77281. s._isEnabled = !1,
  77282. s._parent = null,
  77283. s._dragging = !1,
  77284. s._parent = o,
  77285. s._coloredMaterial = new Os("",r.utilityLayerScene),
  77286. s._coloredMaterial.diffuseColor = n,
  77287. s._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
  77288. s._hoverMaterial = new Os("",r.utilityLayerScene),
  77289. s._hoverMaterial.diffuseColor = D.Yellow(),
  77290. s._disableMaterial = new Os("",r.utilityLayerScene),
  77291. s._disableMaterial.diffuseColor = D.Gray(),
  77292. s._disableMaterial.alpha = .4,
  77293. s._gizmoMesh = t._CreatePlane(r.utilityLayerScene, s._coloredMaterial),
  77294. s._gizmoMesh.lookAt(s._rootMesh.position.add(i)),
  77295. s._gizmoMesh.scaling.scaleInPlace(1 / 3),
  77296. s._gizmoMesh.parent = s._rootMesh;
  77297. var l = 0
  77298. , c = new x
  77299. , u = {
  77300. snapDistance: 0
  77301. };
  77302. s.dragBehavior = new Ao({
  77303. dragPlaneNormal: i
  77304. }),
  77305. s.dragBehavior.moveAttached = !1,
  77306. s._rootMesh.addBehavior(s.dragBehavior),
  77307. s.dragBehavior.onDragObservable.add((function(e) {
  77308. if (s.attachedNode) {
  77309. if (s._handlePivot(),
  77310. 0 == s.snapDistance)
  77311. s.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x, e.delta.y, e.delta.z);
  77312. else if (l += e.dragDistance,
  77313. Math.abs(l) > s.snapDistance) {
  77314. var t = Math.floor(Math.abs(l) / s.snapDistance);
  77315. l %= s.snapDistance,
  77316. e.delta.normalizeToRef(c),
  77317. c.scaleInPlace(s.snapDistance * t),
  77318. s.attachedNode.getWorldMatrix().addTranslationFromFloats(c.x, c.y, c.z),
  77319. u.snapDistance = s.snapDistance * t,
  77320. s.onSnapObservable.notifyObservers(u)
  77321. }
  77322. s._matrixChanged()
  77323. }
  77324. }
  77325. )),
  77326. s.dragBehavior.onDragStartObservable.add((function() {
  77327. s._dragging = !0
  77328. }
  77329. )),
  77330. s.dragBehavior.onDragEndObservable.add((function() {
  77331. s._dragging = !1
  77332. }
  77333. ));
  77334. var d = r._getSharedGizmoLight();
  77335. d.includedOnlyMeshes = d.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1));
  77336. var p = {
  77337. gizmoMeshes: s._gizmoMesh.getChildMeshes(),
  77338. colliderMeshes: s._gizmoMesh.getChildMeshes(),
  77339. material: s._coloredMaterial,
  77340. hoverMaterial: s._hoverMaterial,
  77341. disableMaterial: s._disableMaterial,
  77342. active: !1,
  77343. dragBehavior: s.dragBehavior
  77344. };
  77345. return null === (a = s._parent) || void 0 === a || a.addToAxisCache(s._gizmoMesh, p),
  77346. s._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
  77347. var t;
  77348. if (!s._customMeshSet && (s._isHovered = !(-1 == p.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
  77349. !s._parent)) {
  77350. var i = p.dragBehavior.enabled ? s._isHovered || s._dragging ? s._hoverMaterial : s._coloredMaterial : s._disableMaterial;
  77351. s._setGizmoMeshMaterial(p.gizmoMeshes, i)
  77352. }
  77353. }
  77354. )),
  77355. s.dragBehavior.onEnabledObservable.add((function(e) {
  77356. s._setGizmoMeshMaterial(p.gizmoMeshes, e ? s._coloredMaterial : s._disableMaterial)
  77357. }
  77358. )),
  77359. s
  77360. }
  77361. return U(t, e),
  77362. t._CreatePlane = function(e, t) {
  77363. var i = new yr("plane",e)
  77364. , n = vo("dragPlane", {
  77365. width: .1375,
  77366. height: .1375,
  77367. sideOrientation: 2
  77368. }, e);
  77369. return n.material = t,
  77370. n.parent = i,
  77371. i
  77372. }
  77373. ,
  77374. t.prototype._attachedNodeChanged = function(e) {
  77375. this.dragBehavior && (this.dragBehavior.enabled = !!e)
  77376. }
  77377. ,
  77378. Object.defineProperty(t.prototype, "isEnabled", {
  77379. get: function() {
  77380. return this._isEnabled
  77381. },
  77382. set: function(e) {
  77383. this._isEnabled = e,
  77384. e ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null
  77385. },
  77386. enumerable: !1,
  77387. configurable: !0
  77388. }),
  77389. t.prototype.dispose = function() {
  77390. this.onSnapObservable.clear(),
  77391. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  77392. this.dragBehavior.detach(),
  77393. e.prototype.dispose.call(this),
  77394. this._gizmoMesh && this._gizmoMesh.dispose(),
  77395. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
  77396. e && e.dispose()
  77397. }
  77398. ))
  77399. }
  77400. ,
  77401. t
  77402. }(Sl)
  77403. , yd = function(e) {
  77404. function t(t, i, n) {
  77405. void 0 === t && (t = El.DefaultUtilityLayer),
  77406. void 0 === i && (i = 1);
  77407. var r = e.call(this, t) || this;
  77408. return r._meshAttached = null,
  77409. r._nodeAttached = null,
  77410. r._observables = [],
  77411. r._gizmoAxisCache = new Map,
  77412. r.onDragStartObservable = new h,
  77413. r.onDragEndObservable = new h,
  77414. r._planarGizmoEnabled = !1,
  77415. r.xGizmo = new Al(new x(1,0,0),D.Red().scale(.5),t,r,i),
  77416. r.yGizmo = new Al(new x(0,1,0),D.Green().scale(.5),t,r,i),
  77417. r.zGizmo = new Al(new x(0,0,1),D.Blue().scale(.5),t,r,i),
  77418. r.xPlaneGizmo = new vd(new x(1,0,0),D.Red().scale(.5),r.gizmoLayer,r),
  77419. r.yPlaneGizmo = new vd(new x(0,1,0),D.Green().scale(.5),r.gizmoLayer,r),
  77420. r.zPlaneGizmo = new vd(new x(0,0,1),D.Blue().scale(.5),r.gizmoLayer,r),
  77421. [r.xGizmo, r.yGizmo, r.zGizmo, r.xPlaneGizmo, r.yPlaneGizmo, r.zPlaneGizmo].forEach((function(e) {
  77422. e.dragBehavior.onDragStartObservable.add((function() {
  77423. r.onDragStartObservable.notifyObservers({})
  77424. }
  77425. )),
  77426. e.dragBehavior.onDragEndObservable.add((function() {
  77427. r.onDragEndObservable.notifyObservers({})
  77428. }
  77429. ))
  77430. }
  77431. )),
  77432. r.attachedMesh = null,
  77433. n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
  77434. r
  77435. }
  77436. return U(t, e),
  77437. Object.defineProperty(t.prototype, "attachedMesh", {
  77438. get: function() {
  77439. return this._meshAttached
  77440. },
  77441. set: function(e) {
  77442. this._meshAttached = e,
  77443. this._nodeAttached = e,
  77444. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77445. t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
  77446. }
  77447. ))
  77448. },
  77449. enumerable: !1,
  77450. configurable: !0
  77451. }),
  77452. Object.defineProperty(t.prototype, "attachedNode", {
  77453. get: function() {
  77454. return this._nodeAttached
  77455. },
  77456. set: function(e) {
  77457. this._meshAttached = null,
  77458. this._nodeAttached = e,
  77459. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77460. t.isEnabled ? t.attachedNode = e : t.attachedNode = null
  77461. }
  77462. ))
  77463. },
  77464. enumerable: !1,
  77465. configurable: !0
  77466. }),
  77467. Object.defineProperty(t.prototype, "isHovered", {
  77468. get: function() {
  77469. var e = !1;
  77470. return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77471. e = e || t.isHovered
  77472. }
  77473. )),
  77474. e
  77475. },
  77476. enumerable: !1,
  77477. configurable: !0
  77478. }),
  77479. Object.defineProperty(t.prototype, "planarGizmoEnabled", {
  77480. get: function() {
  77481. return this._planarGizmoEnabled
  77482. },
  77483. set: function(e) {
  77484. var t = this;
  77485. this._planarGizmoEnabled = e,
  77486. [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(i) {
  77487. i && (i.isEnabled = e,
  77488. e && (i.attachedMesh ? i.attachedMesh = t.attachedMesh : i.attachedNode = t.attachedNode))
  77489. }
  77490. ), this)
  77491. },
  77492. enumerable: !1,
  77493. configurable: !0
  77494. }),
  77495. Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  77496. get: function() {
  77497. return this._updateGizmoRotationToMatchAttachedMesh
  77498. },
  77499. set: function(e) {
  77500. this._updateGizmoRotationToMatchAttachedMesh = e,
  77501. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77502. t && (t.updateGizmoRotationToMatchAttachedMesh = e)
  77503. }
  77504. ))
  77505. },
  77506. enumerable: !1,
  77507. configurable: !0
  77508. }),
  77509. Object.defineProperty(t.prototype, "snapDistance", {
  77510. get: function() {
  77511. return this._snapDistance
  77512. },
  77513. set: function(e) {
  77514. this._snapDistance = e,
  77515. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77516. t && (t.snapDistance = e)
  77517. }
  77518. ))
  77519. },
  77520. enumerable: !1,
  77521. configurable: !0
  77522. }),
  77523. Object.defineProperty(t.prototype, "scaleRatio", {
  77524. get: function() {
  77525. return this._scaleRatio
  77526. },
  77527. set: function(e) {
  77528. this._scaleRatio = e,
  77529. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
  77530. t && (t.scaleRatio = e)
  77531. }
  77532. ))
  77533. },
  77534. enumerable: !1,
  77535. configurable: !0
  77536. }),
  77537. t.prototype.addToAxisCache = function(e, t) {
  77538. this._gizmoAxisCache.set(e, t)
  77539. }
  77540. ,
  77541. t.prototype.dispose = function() {
  77542. var e = this;
  77543. [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(e) {
  77544. e && e.dispose()
  77545. }
  77546. )),
  77547. this._observables.forEach((function(t) {
  77548. e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
  77549. }
  77550. )),
  77551. this.onDragStartObservable.clear(),
  77552. this.onDragEndObservable.clear()
  77553. }
  77554. ,
  77555. t.prototype.setCustomMesh = function() {
  77556. K.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")
  77557. }
  77558. ,
  77559. t
  77560. }(Sl);
  77561. function bd(e) {
  77562. var t = [];
  77563. t[0] = {
  77564. vertex: [[0, 0, 1.732051], [1.632993, 0, -.5773503], [-.8164966, 1.414214, -.5773503], [-.8164966, -1.414214, -.5773503]],
  77565. face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]]
  77566. },
  77567. t[1] = {
  77568. vertex: [[0, 0, 1.414214], [1.414214, 0, 0], [0, 1.414214, 0], [-1.414214, 0, 0], [0, -1.414214, 0], [0, 0, -1.414214]],
  77569. face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [1, 4, 5], [1, 5, 2], [2, 5, 3], [3, 5, 4]]
  77570. },
  77571. t[2] = {
  77572. vertex: [[0, 0, 1.070466], [.7136442, 0, .7978784], [-.3568221, .618034, .7978784], [-.3568221, -.618034, .7978784], [.7978784, .618034, .3568221], [.7978784, -.618034, .3568221], [-.9341724, .381966, .3568221], [.1362939, 1, .3568221], [.1362939, -1, .3568221], [-.9341724, -.381966, .3568221], [.9341724, .381966, -.3568221], [.9341724, -.381966, -.3568221], [-.7978784, .618034, -.3568221], [-.1362939, 1, -.3568221], [-.1362939, -1, -.3568221], [-.7978784, -.618034, -.3568221], [.3568221, .618034, -.7978784], [.3568221, -.618034, -.7978784], [-.7136442, 0, -.7978784], [0, 0, -1.070466]],
  77573. face: [[0, 1, 4, 7, 2], [0, 2, 6, 9, 3], [0, 3, 8, 5, 1], [1, 5, 11, 10, 4], [2, 7, 13, 12, 6], [3, 9, 15, 14, 8], [4, 10, 16, 13, 7], [5, 8, 14, 17, 11], [6, 12, 18, 15, 9], [10, 11, 17, 19, 16], [12, 13, 16, 19, 18], [14, 15, 18, 19, 17]]
  77574. },
  77575. t[3] = {
  77576. vertex: [[0, 0, 1.175571], [1.051462, 0, .5257311], [.3249197, 1, .5257311], [-.8506508, .618034, .5257311], [-.8506508, -.618034, .5257311], [.3249197, -1, .5257311], [.8506508, .618034, -.5257311], [.8506508, -.618034, -.5257311], [-.3249197, 1, -.5257311], [-1.051462, 0, -.5257311], [-.3249197, -1, -.5257311], [0, 0, -1.175571]],
  77577. face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 1], [1, 5, 7], [1, 7, 6], [1, 6, 2], [2, 6, 8], [2, 8, 3], [3, 8, 9], [3, 9, 4], [4, 9, 10], [4, 10, 5], [5, 10, 7], [6, 7, 11], [6, 11, 8], [7, 10, 11], [8, 11, 9], [9, 11, 10]]
  77578. },
  77579. t[4] = {
  77580. vertex: [[0, 0, 1.070722], [.7148135, 0, .7971752], [-.104682, .7071068, .7971752], [-.6841528, .2071068, .7971752], [-.104682, -.7071068, .7971752], [.6101315, .7071068, .5236279], [1.04156, .2071068, .1367736], [.6101315, -.7071068, .5236279], [-.3574067, 1, .1367736], [-.7888348, -.5, .5236279], [-.9368776, .5, .1367736], [-.3574067, -1, .1367736], [.3574067, 1, -.1367736], [.9368776, -.5, -.1367736], [.7888348, .5, -.5236279], [.3574067, -1, -.1367736], [-.6101315, .7071068, -.5236279], [-1.04156, -.2071068, -.1367736], [-.6101315, -.7071068, -.5236279], [.104682, .7071068, -.7971752], [.6841528, -.2071068, -.7971752], [.104682, -.7071068, -.7971752], [-.7148135, 0, -.7971752], [0, 0, -1.070722]],
  77581. face: [[0, 2, 3], [1, 6, 5], [4, 9, 11], [7, 15, 13], [8, 16, 10], [12, 14, 19], [17, 22, 18], [20, 21, 23], [0, 1, 5, 2], [0, 3, 9, 4], [0, 4, 7, 1], [1, 7, 13, 6], [2, 5, 12, 8], [2, 8, 10, 3], [3, 10, 17, 9], [4, 11, 15, 7], [5, 6, 14, 12], [6, 13, 20, 14], [8, 12, 19, 16], [9, 17, 18, 11], [10, 16, 22, 17], [11, 18, 21, 15], [13, 15, 21, 20], [14, 20, 23, 19], [16, 19, 23, 22], [18, 22, 23, 21]]
  77582. },
  77583. t[5] = {
  77584. vertex: [[0, 0, 1.322876], [1.309307, 0, .1889822], [-.9819805, .8660254, .1889822], [.1636634, -1.299038, .1889822], [.3273268, .8660254, -.9449112], [-.8183171, -.4330127, -.9449112]],
  77585. face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]]
  77586. },
  77587. t[6] = {
  77588. vertex: [[0, 0, 1.159953], [1.013464, 0, .5642542], [-.3501431, .9510565, .5642542], [-.7715208, -.6571639, .5642542], [.6633206, .9510565, -.03144481], [.8682979, -.6571639, -.3996071], [-1.121664, .2938926, -.03144481], [-.2348831, -1.063314, -.3996071], [.5181548, .2938926, -.9953061], [-.5850262, -.112257, -.9953061]],
  77589. face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 9, 7], [5, 7, 9, 8], [0, 3, 7, 5, 1], [2, 4, 8, 9, 6]]
  77590. },
  77591. t[7] = {
  77592. vertex: [[0, 0, 1.118034], [.8944272, 0, .6708204], [-.2236068, .8660254, .6708204], [-.7826238, -.4330127, .6708204], [.6708204, .8660254, .2236068], [1.006231, -.4330127, -.2236068], [-1.006231, .4330127, .2236068], [-.6708204, -.8660254, -.2236068], [.7826238, .4330127, -.6708204], [.2236068, -.8660254, -.6708204], [-.8944272, 0, -.6708204], [0, 0, -1.118034]],
  77593. face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 10, 7], [5, 9, 11, 8], [7, 10, 11, 9], [0, 3, 7, 9, 5, 1], [2, 4, 8, 11, 10, 6]]
  77594. },
  77595. t[8] = {
  77596. vertex: [[-.729665, .670121, .319155], [-.655235, -.29213, -.754096], [-.093922, -.607123, .537818], [.702196, .595691, .485187], [.776626, -.36656, -.588064]],
  77597. face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]]
  77598. },
  77599. t[9] = {
  77600. vertex: [[-.868849, -.100041, .61257], [-.329458, .976099, .28078], [-.26629, -.013796, -.477654], [-.13392, -1.034115, .229829], [.738834, .707117, -.307018], [.859683, -.535264, -.338508]],
  77601. face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]]
  77602. },
  77603. t[10] = {
  77604. vertex: [[-.610389, .243975, .531213], [-.187812, -.48795, -.664016], [-.187812, .9759, -.664016], [.187812, -.9759, .664016], [.798201, .243975, .132803]],
  77605. face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]]
  77606. },
  77607. t[11] = {
  77608. vertex: [[-1.028778, .392027, -.048786], [-.640503, -.646161, .621837], [-.125162, -.395663, -.540059], [.004683, .888447, -.651988], [.125161, .395663, .540059], [.632925, -.791376, .433102], [1.031672, .157063, -.354165]],
  77609. face: [[3, 2, 0], [2, 1, 0], [2, 5, 1], [0, 4, 3], [0, 1, 4], [4, 1, 5], [2, 3, 6], [3, 4, 6], [5, 2, 6], [4, 5, 6]]
  77610. },
  77611. t[12] = {
  77612. vertex: [[-.669867, .334933, -.529576], [-.669867, .334933, .529577], [-.4043, 1.212901, 0], [-.334933, -.669867, -.529576], [-.334933, -.669867, .529577], [.334933, .669867, -.529576], [.334933, .669867, .529577], [.4043, -1.212901, 0], [.669867, -.334933, -.529576], [.669867, -.334933, .529577]],
  77613. face: [[8, 9, 7], [6, 5, 2], [3, 8, 7], [5, 0, 2], [4, 3, 7], [0, 1, 2], [9, 4, 7], [1, 6, 2], [9, 8, 5, 6], [8, 3, 0, 5], [3, 4, 1, 0], [4, 9, 6, 1]]
  77614. },
  77615. t[13] = {
  77616. vertex: [[-.931836, .219976, -.264632], [-.636706, .318353, .692816], [-.613483, -.735083, -.264632], [-.326545, .979634, 0], [-.318353, -.636706, .692816], [-.159176, .477529, -.856368], [.159176, -.477529, -.856368], [.318353, .636706, .692816], [.326545, -.979634, 0], [.613482, .735082, -.264632], [.636706, -.318353, .692816], [.931835, -.219977, -.264632]],
  77617. face: [[11, 10, 8], [7, 9, 3], [6, 11, 8], [9, 5, 3], [2, 6, 8], [5, 0, 3], [4, 2, 8], [0, 1, 3], [10, 4, 8], [1, 7, 3], [10, 11, 9, 7], [11, 6, 5, 9], [6, 2, 0, 5], [2, 4, 1, 0], [4, 10, 7, 1]]
  77618. },
  77619. t[14] = {
  77620. vertex: [[-.93465, .300459, -.271185], [-.838689, -.260219, -.516017], [-.711319, .717591, .128359], [-.710334, -.156922, .080946], [-.599799, .556003, -.725148], [-.503838, -.004675, -.969981], [-.487004, .26021, .48049], [-.460089, -.750282, -.512622], [-.376468, .973135, -.325605], [-.331735, -.646985, .084342], [-.254001, .831847, .530001], [-.125239, -.494738, -.966586], [.029622, .027949, .730817], [.056536, -.982543, -.262295], [.08085, 1.087391, .076037], [.125583, -.532729, .485984], [.262625, .599586, .780328], [.391387, -.726999, -.716259], [.513854, -.868287, .139347], [.597475, .85513, .326364], [.641224, .109523, .783723], [.737185, -.451155, .538891], [.848705, -.612742, -.314616], [.976075, .365067, .32976], [1.072036, -.19561, .084927]],
  77621. face: [[15, 18, 21], [12, 20, 16], [6, 10, 2], [3, 0, 1], [9, 7, 13], [2, 8, 4, 0], [0, 4, 5, 1], [1, 5, 11, 7], [7, 11, 17, 13], [13, 17, 22, 18], [18, 22, 24, 21], [21, 24, 23, 20], [20, 23, 19, 16], [16, 19, 14, 10], [10, 14, 8, 2], [15, 9, 13, 18], [12, 15, 21, 20], [6, 12, 16, 10], [3, 6, 2, 0], [9, 3, 1, 7], [9, 15, 12, 6, 3], [22, 17, 11, 5, 4, 8, 14, 19, 23, 24]]
  77622. };
  77623. var i, n, r, o, a, s, l = e.type && (e.type < 0 || e.type >= t.length) ? 0 : e.type || 0, c = e.size, u = e.sizeX || c || 1, h = e.sizeY || c || 1, d = e.sizeZ || c || 1, p = e.custom || t[l], f = p.face.length, _ = e.faceUV || new Array(f), m = e.faceColors, g = void 0 === e.flat || e.flat, v = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, y = new Array, b = new Array, T = new Array, E = new Array, S = new Array, A = 0, x = 0, C = new Array, P = 0, M = 0;
  77624. if (g)
  77625. for (M = 0; M < f; M++)
  77626. m && void 0 === m[M] && (m[M] = new N(1,1,1,1)),
  77627. _ && void 0 === _[M] && (_[M] = new R(0,0,1,1));
  77628. if (g)
  77629. for (M = 0; M < f; M++) {
  77630. var I = p.face[M].length;
  77631. for (r = 2 * Math.PI / I,
  77632. o = .5 * Math.tan(r / 2),
  77633. a = .5,
  77634. P = 0; P < I; P++)
  77635. y.push(p.vertex[p.face[M][P]][0] * u, p.vertex[p.face[M][P]][1] * h, p.vertex[p.face[M][P]][2] * d),
  77636. C.push(A),
  77637. A++,
  77638. i = _[M].x + (_[M].z - _[M].x) * (.5 + o),
  77639. n = _[M].y + (_[M].w - _[M].y) * (a - .5),
  77640. E.push(i, pr.UseOpenGLOrientationForUV ? 1 - n : n),
  77641. s = o * Math.cos(r) - a * Math.sin(r),
  77642. a = o * Math.sin(r) + a * Math.cos(r),
  77643. o = s,
  77644. m && S.push(m[M].r, m[M].g, m[M].b, m[M].a);
  77645. for (P = 0; P < I - 2; P++)
  77646. b.push(C[0 + x], C[P + 2 + x], C[P + 1 + x]);
  77647. x += I
  77648. }
  77649. else {
  77650. for (P = 0; P < p.vertex.length; P++)
  77651. y.push(p.vertex[P][0] * u, p.vertex[P][1] * h, p.vertex[P][2] * d),
  77652. E.push(0, pr.UseOpenGLOrientationForUV ? 1 : 0);
  77653. for (M = 0; M < f; M++)
  77654. for (P = 0; P < p.face[M].length - 2; P++)
  77655. b.push(p.face[M][0], p.face[M][P + 2], p.face[M][P + 1])
  77656. }
  77657. $n.ComputeNormals(y, b, T),
  77658. $n._ComputeSides(v, y, b, T, E, e.frontUVs, e.backUVs);
  77659. var O = new $n;
  77660. return O.positions = y,
  77661. O.indices = b,
  77662. O.normals = T,
  77663. O.uvs = E,
  77664. m && g && (O.colors = S),
  77665. O
  77666. }
  77667. function Td(e, t, i) {
  77668. void 0 === t && (t = {}),
  77669. void 0 === i && (i = null);
  77670. var n = new Vr(e,i);
  77671. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  77672. n._originalBuilderSideOrientation = t.sideOrientation,
  77673. bd(t).applyToMesh(n, t.updatable),
  77674. n
  77675. }
  77676. var Ed = {
  77677. CreatePolyhedron: Td
  77678. };
  77679. $n.CreatePolyhedron = bd,
  77680. Vr.CreatePolyhedron = function(e, t, i) {
  77681. return Td(e, t, i)
  77682. }
  77683. ;
  77684. var Sd = function(e) {
  77685. function t(t, i, n) {
  77686. void 0 === t && (t = El.DefaultUtilityLayer),
  77687. void 0 === i && (i = 1);
  77688. var r = e.call(this, t) || this;
  77689. return r._meshAttached = null,
  77690. r._nodeAttached = null,
  77691. r._sensitivity = 1,
  77692. r._observables = [],
  77693. r._gizmoAxisCache = new Map,
  77694. r.onDragStartObservable = new h,
  77695. r.onDragEndObservable = new h,
  77696. r.uniformScaleGizmo = r._createUniformScaleMesh(),
  77697. r.xGizmo = new fd(new x(1,0,0),D.Red().scale(.5),t,r,i),
  77698. r.yGizmo = new fd(new x(0,1,0),D.Green().scale(.5),t,r,i),
  77699. r.zGizmo = new fd(new x(0,0,1),D.Blue().scale(.5),t,r,i),
  77700. [r.xGizmo, r.yGizmo, r.zGizmo, r.uniformScaleGizmo].forEach((function(e) {
  77701. e.dragBehavior.onDragStartObservable.add((function() {
  77702. r.onDragStartObservable.notifyObservers({})
  77703. }
  77704. )),
  77705. e.dragBehavior.onDragEndObservable.add((function() {
  77706. r.onDragEndObservable.notifyObservers({})
  77707. }
  77708. ))
  77709. }
  77710. )),
  77711. r.attachedMesh = null,
  77712. r.attachedNode = null,
  77713. n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
  77714. r
  77715. }
  77716. return U(t, e),
  77717. Object.defineProperty(t.prototype, "attachedMesh", {
  77718. get: function() {
  77719. return this._meshAttached
  77720. },
  77721. set: function(e) {
  77722. this._meshAttached = e,
  77723. this._nodeAttached = e,
  77724. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77725. t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
  77726. }
  77727. ))
  77728. },
  77729. enumerable: !1,
  77730. configurable: !0
  77731. }),
  77732. Object.defineProperty(t.prototype, "attachedNode", {
  77733. get: function() {
  77734. return this._nodeAttached
  77735. },
  77736. set: function(e) {
  77737. this._meshAttached = null,
  77738. this._nodeAttached = e,
  77739. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77740. t.isEnabled ? t.attachedNode = e : t.attachedNode = null
  77741. }
  77742. ))
  77743. },
  77744. enumerable: !1,
  77745. configurable: !0
  77746. }),
  77747. Object.defineProperty(t.prototype, "isHovered", {
  77748. get: function() {
  77749. var e = !1;
  77750. return [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
  77751. e = e || t.isHovered
  77752. }
  77753. )),
  77754. e
  77755. },
  77756. enumerable: !1,
  77757. configurable: !0
  77758. }),
  77759. t.prototype._createUniformScaleMesh = function() {
  77760. this._coloredMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
  77761. this._coloredMaterial.diffuseColor = D.Gray(),
  77762. this._hoverMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
  77763. this._hoverMaterial.diffuseColor = D.Yellow(),
  77764. this._disableMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
  77765. this._disableMaterial.diffuseColor = D.Gray(),
  77766. this._disableMaterial.alpha = .4;
  77767. var e = new fd(new x(0,1,0),D.Gray().scale(.5),this.gizmoLayer,this);
  77768. e.updateGizmoRotationToMatchAttachedMesh = !1,
  77769. e.uniformScaling = !0,
  77770. this._uniformScalingMesh = Td("uniform", {
  77771. type: 1
  77772. }, e.gizmoLayer.utilityLayerScene),
  77773. this._uniformScalingMesh.scaling.scaleInPlace(.01),
  77774. this._uniformScalingMesh.visibility = 0,
  77775. this._octahedron = Td("", {
  77776. type: 1
  77777. }, e.gizmoLayer.utilityLayerScene),
  77778. this._octahedron.scaling.scaleInPlace(.007),
  77779. this._uniformScalingMesh.addChild(this._octahedron),
  77780. e.setCustomMesh(this._uniformScalingMesh, !0);
  77781. var t = this.gizmoLayer._getSharedGizmoLight();
  77782. t.includedOnlyMeshes = t.includedOnlyMeshes.concat(this._octahedron);
  77783. var i = {
  77784. gizmoMeshes: [this._octahedron, this._uniformScalingMesh],
  77785. colliderMeshes: [this._uniformScalingMesh],
  77786. material: this._coloredMaterial,
  77787. hoverMaterial: this._hoverMaterial,
  77788. disableMaterial: this._disableMaterial,
  77789. active: !1,
  77790. dragBehavior: e.dragBehavior
  77791. };
  77792. return this.addToAxisCache(e._rootMesh, i),
  77793. e
  77794. }
  77795. ,
  77796. Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  77797. get: function() {
  77798. return this._updateGizmoRotationToMatchAttachedMesh
  77799. },
  77800. set: function(e) {
  77801. e ? (this._updateGizmoRotationToMatchAttachedMesh = e,
  77802. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77803. t && (t.updateGizmoRotationToMatchAttachedMesh = e)
  77804. }
  77805. ))) : K.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")
  77806. },
  77807. enumerable: !1,
  77808. configurable: !0
  77809. }),
  77810. Object.defineProperty(t.prototype, "snapDistance", {
  77811. get: function() {
  77812. return this._snapDistance
  77813. },
  77814. set: function(e) {
  77815. this._snapDistance = e,
  77816. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77817. t && (t.snapDistance = e)
  77818. }
  77819. ))
  77820. },
  77821. enumerable: !1,
  77822. configurable: !0
  77823. }),
  77824. Object.defineProperty(t.prototype, "scaleRatio", {
  77825. get: function() {
  77826. return this._scaleRatio
  77827. },
  77828. set: function(e) {
  77829. this._scaleRatio = e,
  77830. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77831. t && (t.scaleRatio = e)
  77832. }
  77833. ))
  77834. },
  77835. enumerable: !1,
  77836. configurable: !0
  77837. }),
  77838. Object.defineProperty(t.prototype, "sensitivity", {
  77839. get: function() {
  77840. return this._sensitivity
  77841. },
  77842. set: function(e) {
  77843. this._sensitivity = e,
  77844. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
  77845. t && (t.sensitivity = e)
  77846. }
  77847. ))
  77848. },
  77849. enumerable: !1,
  77850. configurable: !0
  77851. }),
  77852. t.prototype.addToAxisCache = function(e, t) {
  77853. this._gizmoAxisCache.set(e, t)
  77854. }
  77855. ,
  77856. t.prototype.dispose = function() {
  77857. var e = this;
  77858. [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(e) {
  77859. e && e.dispose()
  77860. }
  77861. )),
  77862. this._observables.forEach((function(t) {
  77863. e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
  77864. }
  77865. )),
  77866. this.onDragStartObservable.clear(),
  77867. this.onDragEndObservable.clear(),
  77868. [this._uniformScalingMesh, this._octahedron].forEach((function(e) {
  77869. e && e.dispose()
  77870. }
  77871. )),
  77872. [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
  77873. e && e.dispose()
  77874. }
  77875. ))
  77876. }
  77877. ,
  77878. t
  77879. }(Sl)
  77880. , Ad = function() {
  77881. function e(e, t, i, n) {
  77882. void 0 === t && (t = 1),
  77883. void 0 === i && (i = El.DefaultUtilityLayer),
  77884. void 0 === n && (n = El.DefaultKeepDepthUtilityLayer),
  77885. this._scene = e,
  77886. this.clearGizmoOnEmptyPointerEvent = !1,
  77887. this.enableAutoPicking = !0,
  77888. this.onAttachedToMeshObservable = new h,
  77889. this.onAttachedToNodeObservable = new h,
  77890. this._gizmosEnabled = {
  77891. positionGizmo: !1,
  77892. rotationGizmo: !1,
  77893. scaleGizmo: !1,
  77894. boundingBoxGizmo: !1
  77895. },
  77896. this._pointerObservers = [],
  77897. this._attachedMesh = null,
  77898. this._attachedNode = null,
  77899. this._boundingBoxColor = D.FromHexString("#0984e3"),
  77900. this._thickness = 1,
  77901. this._scaleRatio = 1,
  77902. this._gizmoAxisCache = new Map,
  77903. this.boundingBoxDragBehavior = new Co,
  77904. this.attachableMeshes = null,
  77905. this.attachableNodes = null,
  77906. this.usePointerToAttachGizmos = !0,
  77907. this._defaultUtilityLayer = i,
  77908. this._defaultKeepDepthUtilityLayer = n,
  77909. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
  77910. this._thickness = t,
  77911. this.gizmos = {
  77912. positionGizmo: null,
  77913. rotationGizmo: null,
  77914. scaleGizmo: null,
  77915. boundingBoxGizmo: null
  77916. };
  77917. var r = this._attachToMeshPointerObserver(e)
  77918. , o = Sl.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
  77919. this._pointerObservers = [r, o]
  77920. }
  77921. return Object.defineProperty(e.prototype, "keepDepthUtilityLayer", {
  77922. get: function() {
  77923. return this._defaultKeepDepthUtilityLayer
  77924. },
  77925. enumerable: !1,
  77926. configurable: !0
  77927. }),
  77928. Object.defineProperty(e.prototype, "utilityLayer", {
  77929. get: function() {
  77930. return this._defaultUtilityLayer
  77931. },
  77932. enumerable: !1,
  77933. configurable: !0
  77934. }),
  77935. Object.defineProperty(e.prototype, "isHovered", {
  77936. get: function() {
  77937. var e = !1;
  77938. for (var t in this.gizmos) {
  77939. var i = this.gizmos[t];
  77940. if (i && i.isHovered) {
  77941. e = !0;
  77942. break
  77943. }
  77944. }
  77945. return e
  77946. },
  77947. enumerable: !1,
  77948. configurable: !0
  77949. }),
  77950. Object.defineProperty(e.prototype, "scaleRatio", {
  77951. get: function() {
  77952. return this._scaleRatio
  77953. },
  77954. set: function(e) {
  77955. this._scaleRatio = e,
  77956. [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((function(t) {
  77957. t && (t.scaleRatio = e)
  77958. }
  77959. ))
  77960. },
  77961. enumerable: !1,
  77962. configurable: !0
  77963. }),
  77964. e.prototype._attachToMeshPointerObserver = function(e) {
  77965. var t = this;
  77966. return e.onPointerObservable.add((function(e) {
  77967. if (t.usePointerToAttachGizmos && e.type == Xi.POINTERDOWN)
  77968. if (e.pickInfo && e.pickInfo.pickedMesh) {
  77969. if (t.enableAutoPicking) {
  77970. var i = e.pickInfo.pickedMesh;
  77971. if (null == t.attachableMeshes)
  77972. for (; i && null != i.parent; )
  77973. i = i.parent;
  77974. else {
  77975. var n = !1;
  77976. t.attachableMeshes.forEach((function(e) {
  77977. i && (i == e || i.isDescendantOf(e)) && (i = e,
  77978. n = !0)
  77979. }
  77980. )),
  77981. n || (i = null)
  77982. }
  77983. i instanceof Sr ? t._attachedMesh != i && t.attachToMesh(i) : t.clearGizmoOnEmptyPointerEvent && t.attachToMesh(null)
  77984. }
  77985. } else
  77986. t.clearGizmoOnEmptyPointerEvent && t.attachToMesh(null)
  77987. }
  77988. ))
  77989. }
  77990. ,
  77991. e.prototype.attachToMesh = function(e) {
  77992. for (var t in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  77993. this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  77994. this._attachedMesh = e,
  77995. this._attachedNode = null,
  77996. this.gizmos) {
  77997. var i = this.gizmos[t];
  77998. i && this._gizmosEnabled[t] && (i.attachedMesh = e)
  77999. }
  78000. this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),
  78001. this.onAttachedToMeshObservable.notifyObservers(e)
  78002. }
  78003. ,
  78004. e.prototype.attachToNode = function(e) {
  78005. for (var t in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  78006. this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  78007. this._attachedMesh = null,
  78008. this._attachedNode = e,
  78009. this.gizmos) {
  78010. var i = this.gizmos[t];
  78011. i && this._gizmosEnabled[t] && (i.attachedNode = e)
  78012. }
  78013. this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior),
  78014. this.onAttachedToNodeObservable.notifyObservers(e)
  78015. }
  78016. ,
  78017. Object.defineProperty(e.prototype, "positionGizmoEnabled", {
  78018. get: function() {
  78019. return this._gizmosEnabled.positionGizmo
  78020. },
  78021. set: function(e) {
  78022. e ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new yd(this._defaultUtilityLayer,this._thickness,this)),
  78023. this._attachedNode ? this.gizmos.positionGizmo.attachedNode = this._attachedNode : this.gizmos.positionGizmo.attachedMesh = this._attachedMesh) : this.gizmos.positionGizmo && (this.gizmos.positionGizmo.attachedNode = null),
  78024. this._gizmosEnabled.positionGizmo = e
  78025. },
  78026. enumerable: !1,
  78027. configurable: !0
  78028. }),
  78029. Object.defineProperty(e.prototype, "rotationGizmoEnabled", {
  78030. get: function() {
  78031. return this._gizmosEnabled.rotationGizmo
  78032. },
  78033. set: function(e) {
  78034. e ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new gd(this._defaultUtilityLayer,32,!1,this._thickness,this)),
  78035. this._attachedNode ? this.gizmos.rotationGizmo.attachedNode = this._attachedNode : this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh) : this.gizmos.rotationGizmo && (this.gizmos.rotationGizmo.attachedNode = null),
  78036. this._gizmosEnabled.rotationGizmo = e
  78037. },
  78038. enumerable: !1,
  78039. configurable: !0
  78040. }),
  78041. Object.defineProperty(e.prototype, "scaleGizmoEnabled", {
  78042. get: function() {
  78043. return this._gizmosEnabled.scaleGizmo
  78044. },
  78045. set: function(e) {
  78046. e ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new Sd(this._defaultUtilityLayer,this._thickness,this),
  78047. this._attachedNode ? this.gizmos.scaleGizmo.attachedNode = this._attachedNode : this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh) : this.gizmos.scaleGizmo && (this.gizmos.scaleGizmo.attachedNode = null),
  78048. this._gizmosEnabled.scaleGizmo = e
  78049. },
  78050. enumerable: !1,
  78051. configurable: !0
  78052. }),
  78053. Object.defineProperty(e.prototype, "boundingBoxGizmoEnabled", {
  78054. get: function() {
  78055. return this._gizmosEnabled.boundingBoxGizmo
  78056. },
  78057. set: function(e) {
  78058. e ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _d(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),
  78059. this._attachedMesh ? this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh : this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode,
  78060. this._attachedMesh ? (this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
  78061. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)) : this._attachedNode && (this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  78062. this._attachedNode.addBehavior(this.boundingBoxDragBehavior))) : this.gizmos.boundingBoxGizmo && (this._attachedMesh ? this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior) : this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
  78063. this.gizmos.boundingBoxGizmo.attachedNode = null),
  78064. this._gizmosEnabled.boundingBoxGizmo = e
  78065. },
  78066. enumerable: !1,
  78067. configurable: !0
  78068. }),
  78069. e.prototype.addToAxisCache = function(e) {
  78070. var t = this;
  78071. e.size > 0 && e.forEach((function(e, i) {
  78072. t._gizmoAxisCache.set(i, e)
  78073. }
  78074. ))
  78075. }
  78076. ,
  78077. e.prototype.dispose = function() {
  78078. var e, t, i = this;
  78079. for (var n in this._pointerObservers.forEach((function(e) {
  78080. i._scene.onPointerObservable.remove(e)
  78081. }
  78082. )),
  78083. this.gizmos) {
  78084. var r = this.gizmos[n];
  78085. r && r.dispose()
  78086. }
  78087. this._defaultKeepDepthUtilityLayer !== El._DefaultKeepDepthUtilityLayer && (null === (e = this._defaultKeepDepthUtilityLayer) || void 0 === e || e.dispose()),
  78088. this._defaultUtilityLayer !== El._DefaultUtilityLayer && (null === (t = this._defaultUtilityLayer) || void 0 === t || t.dispose()),
  78089. this.boundingBoxDragBehavior.detach(),
  78090. this.onAttachedToMeshObservable.clear()
  78091. }
  78092. ,
  78093. e
  78094. }()
  78095. , xd = function(e) {
  78096. function t() {
  78097. var t = null !== e && e.apply(this, arguments) || this;
  78098. return t._needProjectionMatrixCompute = !0,
  78099. t
  78100. }
  78101. return U(t, e),
  78102. t.prototype._setPosition = function(e) {
  78103. this._position = e
  78104. }
  78105. ,
  78106. Object.defineProperty(t.prototype, "position", {
  78107. get: function() {
  78108. return this._position
  78109. },
  78110. set: function(e) {
  78111. this._setPosition(e)
  78112. },
  78113. enumerable: !1,
  78114. configurable: !0
  78115. }),
  78116. t.prototype._setDirection = function(e) {
  78117. this._direction = e
  78118. }
  78119. ,
  78120. Object.defineProperty(t.prototype, "direction", {
  78121. get: function() {
  78122. return this._direction
  78123. },
  78124. set: function(e) {
  78125. this._setDirection(e)
  78126. },
  78127. enumerable: !1,
  78128. configurable: !0
  78129. }),
  78130. Object.defineProperty(t.prototype, "shadowMinZ", {
  78131. get: function() {
  78132. return this._shadowMinZ
  78133. },
  78134. set: function(e) {
  78135. this._shadowMinZ = e,
  78136. this.forceProjectionMatrixCompute()
  78137. },
  78138. enumerable: !1,
  78139. configurable: !0
  78140. }),
  78141. Object.defineProperty(t.prototype, "shadowMaxZ", {
  78142. get: function() {
  78143. return this._shadowMaxZ
  78144. },
  78145. set: function(e) {
  78146. this._shadowMaxZ = e,
  78147. this.forceProjectionMatrixCompute()
  78148. },
  78149. enumerable: !1,
  78150. configurable: !0
  78151. }),
  78152. t.prototype.computeTransformedInformation = function() {
  78153. return !(!this.parent || !this.parent.getWorldMatrix || (this.transformedPosition || (this.transformedPosition = x.Zero()),
  78154. x.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
  78155. this.direction && (this.transformedDirection || (this.transformedDirection = x.Zero()),
  78156. x.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)),
  78157. 0))
  78158. }
  78159. ,
  78160. t.prototype.getDepthScale = function() {
  78161. return 50
  78162. }
  78163. ,
  78164. t.prototype.getShadowDirection = function(e) {
  78165. return this.transformedDirection ? this.transformedDirection : this.direction
  78166. }
  78167. ,
  78168. t.prototype.getAbsolutePosition = function() {
  78169. return this.transformedPosition ? this.transformedPosition : this.position
  78170. }
  78171. ,
  78172. t.prototype.setDirectionToTarget = function(e) {
  78173. return this.direction = x.Normalize(e.subtract(this.position)),
  78174. this.direction
  78175. }
  78176. ,
  78177. t.prototype.getRotation = function() {
  78178. this.direction.normalize();
  78179. var e = x.Cross(this.direction, vn.Y)
  78180. , t = x.Cross(e, this.direction);
  78181. return x.RotationFromAxis(e, t, this.direction)
  78182. }
  78183. ,
  78184. t.prototype.needCube = function() {
  78185. return !1
  78186. }
  78187. ,
  78188. t.prototype.needProjectionMatrixCompute = function() {
  78189. return this._needProjectionMatrixCompute
  78190. }
  78191. ,
  78192. t.prototype.forceProjectionMatrixCompute = function() {
  78193. this._needProjectionMatrixCompute = !0
  78194. }
  78195. ,
  78196. t.prototype._initCache = function() {
  78197. e.prototype._initCache.call(this),
  78198. this._cache.position = x.Zero()
  78199. }
  78200. ,
  78201. t.prototype._isSynchronized = function() {
  78202. return !!this._cache.position.equals(this.position)
  78203. }
  78204. ,
  78205. t.prototype.computeWorldMatrix = function(e) {
  78206. return !e && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(),
  78207. this._worldMatrix) : (this._updateCache(),
  78208. this._cache.position.copyFrom(this.position),
  78209. this._worldMatrix || (this._worldMatrix = P.Identity()),
  78210. P.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix),
  78211. this.parent && this.parent.getWorldMatrix && (this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix),
  78212. this._markSyncedWithParent()),
  78213. this._worldMatrixDeterminantIsDirty = !0,
  78214. this._worldMatrix)
  78215. }
  78216. ,
  78217. t.prototype.getDepthMinZ = function(e) {
  78218. return void 0 !== this.shadowMinZ ? this.shadowMinZ : e.minZ
  78219. }
  78220. ,
  78221. t.prototype.getDepthMaxZ = function(e) {
  78222. return void 0 !== this.shadowMaxZ ? this.shadowMaxZ : e.maxZ
  78223. }
  78224. ,
  78225. t.prototype.setShadowProjectionMatrix = function(e, t, i) {
  78226. return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(t, i, e) : this._setDefaultShadowProjectionMatrix(e, t, i),
  78227. this
  78228. }
  78229. ,
  78230. k([De()], t.prototype, "position", null),
  78231. k([De()], t.prototype, "direction", null),
  78232. k([Ce()], t.prototype, "shadowMinZ", null),
  78233. k([Ce()], t.prototype, "shadowMaxZ", null),
  78234. t
  78235. }(Cr);
  78236. Xe.AddNodeConstructor("Light_Type_1", (function(e, t) {
  78237. return function() {
  78238. return new Rd(e,x.Zero(),t)
  78239. }
  78240. }
  78241. ));
  78242. var Rd = function(e) {
  78243. function t(t, i, n) {
  78244. var r = e.call(this, t, n) || this;
  78245. return r._shadowFrustumSize = 0,
  78246. r._shadowOrthoScale = .1,
  78247. r.autoUpdateExtends = !0,
  78248. r.autoCalcShadowZBounds = !1,
  78249. r._orthoLeft = Number.MAX_VALUE,
  78250. r._orthoRight = Number.MIN_VALUE,
  78251. r._orthoTop = Number.MIN_VALUE,
  78252. r._orthoBottom = Number.MAX_VALUE,
  78253. r.position = i.scale(-1),
  78254. r.direction = i,
  78255. r
  78256. }
  78257. return U(t, e),
  78258. Object.defineProperty(t.prototype, "shadowFrustumSize", {
  78259. get: function() {
  78260. return this._shadowFrustumSize
  78261. },
  78262. set: function(e) {
  78263. this._shadowFrustumSize = e,
  78264. this.forceProjectionMatrixCompute()
  78265. },
  78266. enumerable: !1,
  78267. configurable: !0
  78268. }),
  78269. Object.defineProperty(t.prototype, "shadowOrthoScale", {
  78270. get: function() {
  78271. return this._shadowOrthoScale
  78272. },
  78273. set: function(e) {
  78274. this._shadowOrthoScale = e,
  78275. this.forceProjectionMatrixCompute()
  78276. },
  78277. enumerable: !1,
  78278. configurable: !0
  78279. }),
  78280. Object.defineProperty(t.prototype, "orthoLeft", {
  78281. get: function() {
  78282. return this._orthoLeft
  78283. },
  78284. set: function(e) {
  78285. this._orthoLeft = e
  78286. },
  78287. enumerable: !1,
  78288. configurable: !0
  78289. }),
  78290. Object.defineProperty(t.prototype, "orthoRight", {
  78291. get: function() {
  78292. return this._orthoRight
  78293. },
  78294. set: function(e) {
  78295. this._orthoRight = e
  78296. },
  78297. enumerable: !1,
  78298. configurable: !0
  78299. }),
  78300. Object.defineProperty(t.prototype, "orthoTop", {
  78301. get: function() {
  78302. return this._orthoTop
  78303. },
  78304. set: function(e) {
  78305. this._orthoTop = e
  78306. },
  78307. enumerable: !1,
  78308. configurable: !0
  78309. }),
  78310. Object.defineProperty(t.prototype, "orthoBottom", {
  78311. get: function() {
  78312. return this._orthoBottom
  78313. },
  78314. set: function(e) {
  78315. this._orthoBottom = e
  78316. },
  78317. enumerable: !1,
  78318. configurable: !0
  78319. }),
  78320. t.prototype.getClassName = function() {
  78321. return "DirectionalLight"
  78322. }
  78323. ,
  78324. t.prototype.getTypeID = function() {
  78325. return Cr.LIGHTTYPEID_DIRECTIONALLIGHT
  78326. }
  78327. ,
  78328. t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
  78329. this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(e) : this._setDefaultAutoExtendShadowProjectionMatrix(e, t, i)
  78330. }
  78331. ,
  78332. t.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(e) {
  78333. var t = this.getScene().activeCamera;
  78334. t && P.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, void 0 !== this.shadowMinZ ? this.shadowMinZ : t.minZ, void 0 !== this.shadowMaxZ ? this.shadowMaxZ : t.maxZ, e, this.getScene().getEngine().isNDCHalfZRange)
  78335. }
  78336. ,
  78337. t.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(e, t, i) {
  78338. var n = this.getScene().activeCamera;
  78339. if (n) {
  78340. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  78341. var r = x.Zero();
  78342. this._orthoLeft = Number.MAX_VALUE,
  78343. this._orthoRight = Number.MIN_VALUE,
  78344. this._orthoTop = Number.MIN_VALUE,
  78345. this._orthoBottom = Number.MAX_VALUE;
  78346. for (var o = Number.MAX_VALUE, a = Number.MIN_VALUE, s = 0; s < i.length; s++) {
  78347. var l = i[s];
  78348. if (l)
  78349. for (var c = l.getBoundingInfo().boundingBox, u = 0; u < c.vectorsWorld.length; u++)
  78350. x.TransformCoordinatesToRef(c.vectorsWorld[u], t, r),
  78351. r.x < this._orthoLeft && (this._orthoLeft = r.x),
  78352. r.y < this._orthoBottom && (this._orthoBottom = r.y),
  78353. r.x > this._orthoRight && (this._orthoRight = r.x),
  78354. r.y > this._orthoTop && (this._orthoTop = r.y),
  78355. this.autoCalcShadowZBounds && (r.z < o && (o = r.z),
  78356. r.z > a && (a = r.z))
  78357. }
  78358. this.autoCalcShadowZBounds && (this._shadowMinZ = o,
  78359. this._shadowMaxZ = a)
  78360. }
  78361. var h = this._orthoRight - this._orthoLeft
  78362. , d = this._orthoTop - this._orthoBottom
  78363. , p = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
  78364. , f = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
  78365. , _ = this.getScene().getEngine().useReverseDepthBuffer;
  78366. P.OrthoOffCenterLHToRef(this._orthoLeft - h * this.shadowOrthoScale, this._orthoRight + h * this.shadowOrthoScale, this._orthoBottom - d * this.shadowOrthoScale, this._orthoTop + d * this.shadowOrthoScale, _ ? f : p, _ ? p : f, e, this.getScene().getEngine().isNDCHalfZRange)
  78367. }
  78368. }
  78369. ,
  78370. t.prototype._buildUniformLayout = function() {
  78371. this._uniformBuffer.addUniform("vLightData", 4),
  78372. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  78373. this._uniformBuffer.addUniform("vLightSpecular", 4),
  78374. this._uniformBuffer.addUniform("shadowsInfo", 3),
  78375. this._uniformBuffer.addUniform("depthValues", 2),
  78376. this._uniformBuffer.create()
  78377. }
  78378. ,
  78379. t.prototype.transferToEffect = function(e, t) {
  78380. return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, t),
  78381. this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, t),
  78382. this)
  78383. }
  78384. ,
  78385. t.prototype.transferToNodeMaterialEffect = function(e, t) {
  78386. return this.computeTransformedInformation() ? (e.setFloat3(t, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z),
  78387. this) : (e.setFloat3(t, this.direction.x, this.direction.y, this.direction.z),
  78388. this)
  78389. }
  78390. ,
  78391. t.prototype.getDepthMinZ = function(e) {
  78392. var t = this._scene.getEngine();
  78393. return !t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : 1
  78394. }
  78395. ,
  78396. t.prototype.getDepthMaxZ = function(e) {
  78397. var t = this._scene.getEngine();
  78398. return t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : 1
  78399. }
  78400. ,
  78401. t.prototype.prepareLightSpecificDefines = function(e, t) {
  78402. e["DIRLIGHT" + t] = !0
  78403. }
  78404. ,
  78405. k([Ce()], t.prototype, "shadowFrustumSize", null),
  78406. k([Ce()], t.prototype, "shadowOrthoScale", null),
  78407. k([Ce()], t.prototype, "autoUpdateExtends", void 0),
  78408. k([Ce()], t.prototype, "autoCalcShadowZBounds", void 0),
  78409. k([Ce("orthoLeft")], t.prototype, "_orthoLeft", void 0),
  78410. k([Ce("orthoRight")], t.prototype, "_orthoRight", void 0),
  78411. k([Ce("orthoTop")], t.prototype, "_orthoTop", void 0),
  78412. k([Ce("orthoBottom")], t.prototype, "_orthoBottom", void 0),
  78413. t
  78414. }(xd);
  78415. function Cd(e) {
  78416. var t = new Array
  78417. , i = new Array
  78418. , n = new Array
  78419. , r = new Array
  78420. , o = e.radius || .5
  78421. , a = e.tessellation || 64
  78422. , s = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1
  78423. , l = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE;
  78424. t.push(0, 0, 0),
  78425. r.push(.5, .5);
  78426. for (var c = 2 * Math.PI * s, u = 1 === s ? c / a : c / (a - 1), h = 0, d = 0; d < a; d++) {
  78427. var p = Math.cos(h)
  78428. , f = Math.sin(h)
  78429. , _ = (p + 1) / 2
  78430. , m = (1 - f) / 2;
  78431. t.push(o * p, o * f, 0),
  78432. r.push(_, pr.UseOpenGLOrientationForUV ? 1 - m : m),
  78433. h += u
  78434. }
  78435. 1 === s && (t.push(t[3], t[4], t[5]),
  78436. r.push(r[2], pr.UseOpenGLOrientationForUV ? 1 - r[3] : r[3]));
  78437. for (var g = t.length / 3, v = 1; v < g - 1; v++)
  78438. i.push(v + 1, 0, v);
  78439. $n.ComputeNormals(t, i, n),
  78440. $n._ComputeSides(l, t, i, n, r, e.frontUVs, e.backUVs);
  78441. var y = new $n;
  78442. return y.indices = i,
  78443. y.positions = t,
  78444. y.normals = n,
  78445. y.uvs = r,
  78446. y
  78447. }
  78448. function Pd(e, t, i) {
  78449. void 0 === t && (t = {}),
  78450. void 0 === i && (i = null);
  78451. var n = new Vr(e,i);
  78452. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  78453. n._originalBuilderSideOrientation = t.sideOrientation,
  78454. Cd(t).applyToMesh(n, t.updatable),
  78455. n
  78456. }
  78457. var Md = {
  78458. CreateDisc: Pd
  78459. };
  78460. function Id(e, t, i) {
  78461. void 0 === t && (t = {}),
  78462. t.diameter || (t.diameter = 1),
  78463. t.segments || (t.segments = 16);
  78464. var n = Dl("", {
  78465. slice: .5,
  78466. diameter: t.diameter,
  78467. segments: t.segments
  78468. }, i)
  78469. , r = Pd("", {
  78470. radius: t.diameter / 2,
  78471. tessellation: 3 * t.segments + (4 - t.segments)
  78472. }, i);
  78473. r.rotation.x = -Math.PI / 2,
  78474. r.parent = n;
  78475. var o = Vr.MergeMeshes([r, n], !0);
  78476. return o.name = e,
  78477. o
  78478. }
  78479. $n.CreateDisc = Cd,
  78480. Vr.CreateDisc = function(e, t, i, n, r, o) {
  78481. return void 0 === n && (n = null),
  78482. Pd(e, {
  78483. radius: t,
  78484. tessellation: i,
  78485. sideOrientation: o,
  78486. updatable: r
  78487. }, n)
  78488. }
  78489. ;
  78490. var Od = {
  78491. CreateHemisphere: Id
  78492. };
  78493. Vr.CreateHemisphere = function(e, t, i, n) {
  78494. return Id(e, {
  78495. segments: t,
  78496. diameter: i
  78497. }, n)
  78498. }
  78499. ,
  78500. Xe.AddNodeConstructor("Light_Type_2", (function(e, t) {
  78501. return function() {
  78502. return new Dd(e,x.Zero(),x.Zero(),0,0,t)
  78503. }
  78504. }
  78505. ));
  78506. var Dd = function(e) {
  78507. function t(t, i, n, r, o, a) {
  78508. var s = e.call(this, t, a) || this;
  78509. return s._innerAngle = 0,
  78510. s._projectionTextureMatrix = P.Zero(),
  78511. s._projectionTextureLightNear = 1e-6,
  78512. s._projectionTextureLightFar = 1e3,
  78513. s._projectionTextureUpDirection = x.Up(),
  78514. s._projectionTextureViewLightDirty = !0,
  78515. s._projectionTextureProjectionLightDirty = !0,
  78516. s._projectionTextureDirty = !0,
  78517. s._projectionTextureViewTargetVector = x.Zero(),
  78518. s._projectionTextureViewLightMatrix = P.Zero(),
  78519. s._projectionTextureProjectionLightMatrix = P.Zero(),
  78520. s._projectionTextureScalingMatrix = P.FromValues(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1),
  78521. s.position = i,
  78522. s.direction = n,
  78523. s.angle = r,
  78524. s.exponent = o,
  78525. s
  78526. }
  78527. return U(t, e),
  78528. Object.defineProperty(t.prototype, "angle", {
  78529. get: function() {
  78530. return this._angle
  78531. },
  78532. set: function(e) {
  78533. this._angle = e,
  78534. this._cosHalfAngle = Math.cos(.5 * e),
  78535. this._projectionTextureProjectionLightDirty = !0,
  78536. this.forceProjectionMatrixCompute(),
  78537. this._computeAngleValues()
  78538. },
  78539. enumerable: !1,
  78540. configurable: !0
  78541. }),
  78542. Object.defineProperty(t.prototype, "innerAngle", {
  78543. get: function() {
  78544. return this._innerAngle
  78545. },
  78546. set: function(e) {
  78547. this._innerAngle = e,
  78548. this._computeAngleValues()
  78549. },
  78550. enumerable: !1,
  78551. configurable: !0
  78552. }),
  78553. Object.defineProperty(t.prototype, "shadowAngleScale", {
  78554. get: function() {
  78555. return this._shadowAngleScale
  78556. },
  78557. set: function(e) {
  78558. this._shadowAngleScale = e,
  78559. this.forceProjectionMatrixCompute()
  78560. },
  78561. enumerable: !1,
  78562. configurable: !0
  78563. }),
  78564. Object.defineProperty(t.prototype, "projectionTextureMatrix", {
  78565. get: function() {
  78566. return this._projectionTextureMatrix
  78567. },
  78568. enumerable: !1,
  78569. configurable: !0
  78570. }),
  78571. Object.defineProperty(t.prototype, "projectionTextureLightNear", {
  78572. get: function() {
  78573. return this._projectionTextureLightNear
  78574. },
  78575. set: function(e) {
  78576. this._projectionTextureLightNear = e,
  78577. this._projectionTextureProjectionLightDirty = !0
  78578. },
  78579. enumerable: !1,
  78580. configurable: !0
  78581. }),
  78582. Object.defineProperty(t.prototype, "projectionTextureLightFar", {
  78583. get: function() {
  78584. return this._projectionTextureLightFar
  78585. },
  78586. set: function(e) {
  78587. this._projectionTextureLightFar = e,
  78588. this._projectionTextureProjectionLightDirty = !0
  78589. },
  78590. enumerable: !1,
  78591. configurable: !0
  78592. }),
  78593. Object.defineProperty(t.prototype, "projectionTextureUpDirection", {
  78594. get: function() {
  78595. return this._projectionTextureUpDirection
  78596. },
  78597. set: function(e) {
  78598. this._projectionTextureUpDirection = e,
  78599. this._projectionTextureProjectionLightDirty = !0
  78600. },
  78601. enumerable: !1,
  78602. configurable: !0
  78603. }),
  78604. Object.defineProperty(t.prototype, "projectionTexture", {
  78605. get: function() {
  78606. return this._projectionTexture
  78607. },
  78608. set: function(e) {
  78609. var i = this;
  78610. this._projectionTexture !== e && (this._projectionTexture = e,
  78611. this._projectionTextureDirty = !0,
  78612. this._projectionTexture && !this._projectionTexture.isReady() && (t._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled((function() {
  78613. i._markMeshesAsLightDirty()
  78614. }
  78615. )) : t._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce((function() {
  78616. i._markMeshesAsLightDirty()
  78617. }
  78618. ))))
  78619. },
  78620. enumerable: !1,
  78621. configurable: !0
  78622. }),
  78623. t._IsProceduralTexture = function(e) {
  78624. return void 0 !== e.onGeneratedObservable
  78625. }
  78626. ,
  78627. t._IsTexture = function(e) {
  78628. return void 0 !== e.onLoadObservable
  78629. }
  78630. ,
  78631. Object.defineProperty(t.prototype, "projectionTextureProjectionLightMatrix", {
  78632. get: function() {
  78633. return this._projectionTextureProjectionLightMatrix
  78634. },
  78635. set: function(e) {
  78636. this._projectionTextureProjectionLightMatrix = e,
  78637. this._projectionTextureProjectionLightDirty = !1,
  78638. this._projectionTextureDirty = !0
  78639. },
  78640. enumerable: !1,
  78641. configurable: !0
  78642. }),
  78643. t.prototype.getClassName = function() {
  78644. return "SpotLight"
  78645. }
  78646. ,
  78647. t.prototype.getTypeID = function() {
  78648. return Cr.LIGHTTYPEID_SPOTLIGHT
  78649. }
  78650. ,
  78651. t.prototype._setDirection = function(t) {
  78652. e.prototype._setDirection.call(this, t),
  78653. this._projectionTextureViewLightDirty = !0
  78654. }
  78655. ,
  78656. t.prototype._setPosition = function(t) {
  78657. e.prototype._setPosition.call(this, t),
  78658. this._projectionTextureViewLightDirty = !0
  78659. }
  78660. ,
  78661. t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
  78662. var n = this.getScene().activeCamera;
  78663. if (n) {
  78664. this._shadowAngleScale = this._shadowAngleScale || 1;
  78665. var r = this._shadowAngleScale * this._angle
  78666. , o = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
  78667. , a = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
  78668. , s = this.getScene().getEngine().useReverseDepthBuffer;
  78669. P.PerspectiveFovLHToRef(r, 1, s ? a : o, s ? o : a, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, s)
  78670. }
  78671. }
  78672. ,
  78673. t.prototype._computeProjectionTextureViewLightMatrix = function() {
  78674. this._projectionTextureViewLightDirty = !1,
  78675. this._projectionTextureDirty = !0,
  78676. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector),
  78677. P.LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix)
  78678. }
  78679. ,
  78680. t.prototype._computeProjectionTextureProjectionLightMatrix = function() {
  78681. this._projectionTextureProjectionLightDirty = !1,
  78682. this._projectionTextureDirty = !0;
  78683. var e = this.projectionTextureLightFar
  78684. , t = this.projectionTextureLightNear
  78685. , i = e / (e - t)
  78686. , n = -i * t
  78687. , r = 1 / Math.tan(this._angle / 2);
  78688. P.FromValuesToRef(r / 1, 0, 0, 0, 0, r, 0, 0, 0, 0, i, 1, 0, 0, n, 0, this._projectionTextureProjectionLightMatrix)
  78689. }
  78690. ,
  78691. t.prototype._computeProjectionTextureMatrix = function() {
  78692. if (this._projectionTextureDirty = !1,
  78693. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix),
  78694. this._projectionTexture instanceof io) {
  78695. var e = this._projectionTexture.uScale / 2
  78696. , t = this._projectionTexture.vScale / 2;
  78697. P.FromValuesToRef(e, 0, 0, 0, 0, t, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1, this._projectionTextureScalingMatrix)
  78698. }
  78699. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix)
  78700. }
  78701. ,
  78702. t.prototype._buildUniformLayout = function() {
  78703. this._uniformBuffer.addUniform("vLightData", 4),
  78704. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  78705. this._uniformBuffer.addUniform("vLightSpecular", 4),
  78706. this._uniformBuffer.addUniform("vLightDirection", 3),
  78707. this._uniformBuffer.addUniform("vLightFalloff", 4),
  78708. this._uniformBuffer.addUniform("shadowsInfo", 3),
  78709. this._uniformBuffer.addUniform("depthValues", 2),
  78710. this._uniformBuffer.create()
  78711. }
  78712. ,
  78713. t.prototype._computeAngleValues = function() {
  78714. this._lightAngleScale = 1 / Math.max(.001, Math.cos(.5 * this._innerAngle) - this._cosHalfAngle),
  78715. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale
  78716. }
  78717. ,
  78718. t.prototype.transferTexturesToEffect = function(e, t) {
  78719. return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(),
  78720. this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(),
  78721. this._projectionTextureDirty && this._computeProjectionTextureMatrix(),
  78722. e.setMatrix("textureProjectionMatrix" + t, this._projectionTextureMatrix),
  78723. e.setTexture("projectionLightSampler" + t, this.projectionTexture)),
  78724. this
  78725. }
  78726. ,
  78727. t.prototype.transferToEffect = function(e, t) {
  78728. var i;
  78729. return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, t),
  78730. i = x.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, t),
  78731. i = x.Normalize(this.direction)),
  78732. this._uniformBuffer.updateFloat4("vLightDirection", i.x, i.y, i.z, this._cosHalfAngle, t),
  78733. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, t),
  78734. this
  78735. }
  78736. ,
  78737. t.prototype.transferToNodeMaterialEffect = function(e, t) {
  78738. var i;
  78739. return i = this.computeTransformedInformation() ? x.Normalize(this.transformedDirection) : x.Normalize(this.direction),
  78740. this.getScene().useRightHandedSystem ? e.setFloat3(t, -i.x, -i.y, -i.z) : e.setFloat3(t, i.x, i.y, i.z),
  78741. this
  78742. }
  78743. ,
  78744. t.prototype.dispose = function() {
  78745. e.prototype.dispose.call(this),
  78746. this._projectionTexture && this._projectionTexture.dispose()
  78747. }
  78748. ,
  78749. t.prototype.getDepthMinZ = function(e) {
  78750. var t = this._scene.getEngine()
  78751. , i = void 0 !== this.shadowMinZ ? this.shadowMinZ : e.minZ;
  78752. return t.useReverseDepthBuffer && t.isNDCHalfZRange ? i : this._scene.getEngine().isNDCHalfZRange ? 0 : i
  78753. }
  78754. ,
  78755. t.prototype.getDepthMaxZ = function(e) {
  78756. var t = this._scene.getEngine()
  78757. , i = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : e.maxZ;
  78758. return t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : i
  78759. }
  78760. ,
  78761. t.prototype.prepareLightSpecificDefines = function(e, t) {
  78762. e["SPOTLIGHT" + t] = !0,
  78763. e["PROJECTEDLIGHTTEXTURE" + t] = !(!this.projectionTexture || !this.projectionTexture.isReady())
  78764. }
  78765. ,
  78766. k([Ce()], t.prototype, "angle", null),
  78767. k([Ce()], t.prototype, "innerAngle", null),
  78768. k([Ce()], t.prototype, "shadowAngleScale", null),
  78769. k([Ce()], t.prototype, "exponent", void 0),
  78770. k([Ce()], t.prototype, "projectionTextureLightNear", null),
  78771. k([Ce()], t.prototype, "projectionTextureLightFar", null),
  78772. k([Ce()], t.prototype, "projectionTextureUpDirection", null),
  78773. k([Pe("projectedLightTexture")], t.prototype, "_projectionTexture", void 0),
  78774. t
  78775. }(xd)
  78776. , Nd = function(e) {
  78777. function t(t) {
  78778. void 0 === t && (t = El.DefaultUtilityLayer);
  78779. var i = e.call(this, t) || this;
  78780. return i._cachedPosition = new x,
  78781. i._cachedForward = new x(0,0,1),
  78782. i._pointerObserver = null,
  78783. i.onClickedObservable = new h,
  78784. i._light = null,
  78785. i.attachedMesh = new Sr("",i.gizmoLayer.utilityLayerScene),
  78786. i._attachedMeshParent = new yr("parent",i.gizmoLayer.utilityLayerScene),
  78787. i.attachedMesh.parent = i._attachedMeshParent,
  78788. i._material = new Os("light",i.gizmoLayer.utilityLayerScene),
  78789. i._material.diffuseColor = new D(.5,.5,.5),
  78790. i._material.specularColor = new D(.1,.1,.1),
  78791. i._pointerObserver = t.utilityLayerScene.onPointerObservable.add((function(e) {
  78792. i._light && (i._isHovered = !(!e.pickInfo || -1 == i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),
  78793. i._isHovered && 0 === e.event.button && i.onClickedObservable.notifyObservers(i._light))
  78794. }
  78795. ), Xi.POINTERDOWN),
  78796. i
  78797. }
  78798. return U(t, e),
  78799. Object.defineProperty(t.prototype, "attachedNode", {
  78800. get: function() {
  78801. return this.attachedMesh
  78802. },
  78803. set: function(e) {
  78804. console.warn("Nodes cannot be attached to LightGizmo. Attach to a mesh instead.")
  78805. },
  78806. enumerable: !1,
  78807. configurable: !0
  78808. }),
  78809. Object.defineProperty(t.prototype, "light", {
  78810. get: function() {
  78811. return this._light
  78812. },
  78813. set: function(e) {
  78814. var i = this;
  78815. if (this._light = e,
  78816. e) {
  78817. this._lightMesh && this._lightMesh.dispose(),
  78818. this._lightMesh = e instanceof ds ? t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Rd ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Dd ? t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene) : t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),
  78819. this._lightMesh.getChildMeshes(!1).forEach((function(e) {
  78820. e.material = i._material
  78821. }
  78822. )),
  78823. this._lightMesh.parent = this._rootMesh;
  78824. var n = this.gizmoLayer._getSharedGizmoLight();
  78825. n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),
  78826. this._lightMesh.rotationQuaternion = new C,
  78827. this.attachedMesh.reservedDataStore || (this.attachedMesh.reservedDataStore = {}),
  78828. this.attachedMesh.reservedDataStore.lightGizmo = this,
  78829. e.parent && this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),
  78830. e.position && (this.attachedMesh.position.copyFrom(e.position),
  78831. this.attachedMesh.computeWorldMatrix(!0),
  78832. this._cachedPosition.copyFrom(this.attachedMesh.position)),
  78833. e.direction && (this.attachedMesh.setDirection(e.direction),
  78834. this.attachedMesh.computeWorldMatrix(!0),
  78835. this._cachedForward.copyFrom(this.attachedMesh.forward)),
  78836. this._update()
  78837. }
  78838. },
  78839. enumerable: !1,
  78840. configurable: !0
  78841. }),
  78842. Object.defineProperty(t.prototype, "material", {
  78843. get: function() {
  78844. return this._material
  78845. },
  78846. enumerable: !1,
  78847. configurable: !0
  78848. }),
  78849. t.prototype._update = function() {
  78850. if (e.prototype._update.call(this),
  78851. this._light) {
  78852. if (this._light.parent && this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),
  78853. this._light.position)
  78854. if (this.attachedMesh.position.equals(this._cachedPosition))
  78855. this.attachedMesh.position.copyFrom(this._light.position),
  78856. this.attachedMesh.computeWorldMatrix(!0),
  78857. this._cachedPosition.copyFrom(this.attachedMesh.position);
  78858. else {
  78859. var t = this.attachedMesh.position;
  78860. this._light.position = new x(t.x,t.y,t.z),
  78861. this._cachedPosition.copyFrom(this.attachedMesh.position)
  78862. }
  78863. if (this._light.direction)
  78864. if (x.DistanceSquared(this.attachedMesh.forward, this._cachedForward) > 1e-4) {
  78865. var i = this.attachedMesh.forward;
  78866. this._light.direction = new x(i.x,i.y,i.z),
  78867. this._cachedForward.copyFrom(this.attachedMesh.forward)
  78868. } else
  78869. x.DistanceSquared(this.attachedMesh.forward, this._light.direction) > 1e-4 && (this.attachedMesh.setDirection(this._light.direction),
  78870. this.attachedMesh.computeWorldMatrix(!0),
  78871. this._cachedForward.copyFrom(this.attachedMesh.forward))
  78872. }
  78873. }
  78874. ,
  78875. t.prototype.dispose = function() {
  78876. this.onClickedObservable.clear(),
  78877. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  78878. this._material.dispose(),
  78879. e.prototype.dispose.call(this),
  78880. this._attachedMeshParent.dispose()
  78881. }
  78882. ,
  78883. t._CreateHemisphericLightMesh = function(e) {
  78884. var i = new Vr("hemisphereLight",e)
  78885. , n = Id(i.name, {
  78886. segments: 10,
  78887. diameter: 1
  78888. }, e);
  78889. return n.position.z = -.15,
  78890. n.rotation.x = Math.PI / 2,
  78891. n.parent = i,
  78892. this._CreateLightLines(3, e).parent = i,
  78893. i.scaling.scaleInPlace(t._Scale),
  78894. i.rotation.x = Math.PI / 2,
  78895. i
  78896. }
  78897. ,
  78898. t._CreatePointLightMesh = function(e) {
  78899. var i = new Vr("pointLight",e)
  78900. , n = Dl(i.name, {
  78901. segments: 10,
  78902. diameter: 1
  78903. }, e);
  78904. return n.rotation.x = Math.PI / 2,
  78905. n.parent = i,
  78906. this._CreateLightLines(5, e).parent = i,
  78907. i.scaling.scaleInPlace(t._Scale),
  78908. i.rotation.x = Math.PI / 2,
  78909. i
  78910. }
  78911. ,
  78912. t._CreateSpotLightMesh = function(e) {
  78913. var i = new Vr("spotLight",e);
  78914. Dl(i.name, {
  78915. segments: 10,
  78916. diameter: 1
  78917. }, e).parent = i;
  78918. var n = Id(i.name, {
  78919. segments: 10,
  78920. diameter: 2
  78921. }, e);
  78922. return n.parent = i,
  78923. n.rotation.x = -Math.PI / 2,
  78924. this._CreateLightLines(2, e).parent = i,
  78925. i.scaling.scaleInPlace(t._Scale),
  78926. i.rotation.x = Math.PI / 2,
  78927. i
  78928. }
  78929. ,
  78930. t._CreateDirectionalLightMesh = function(e) {
  78931. var i = new Vr("directionalLight",e)
  78932. , n = new Vr(i.name,e);
  78933. n.parent = i,
  78934. Dl(i.name, {
  78935. diameter: 1.2,
  78936. segments: 10
  78937. }, e).parent = n;
  78938. var r = Ys(i.name, {
  78939. updatable: !1,
  78940. height: 6,
  78941. diameterTop: .3,
  78942. diameterBottom: .3,
  78943. tessellation: 6,
  78944. subdivisions: 1
  78945. }, e);
  78946. r.parent = n;
  78947. var o = r.clone(i.name);
  78948. o.scaling.y = .5,
  78949. o.position.x += 1.25;
  78950. var a = r.clone(i.name);
  78951. a.scaling.y = .5,
  78952. a.position.x += -1.25;
  78953. var s = Ys(i.name, {
  78954. updatable: !1,
  78955. height: 1,
  78956. diameterTop: 0,
  78957. diameterBottom: .6,
  78958. tessellation: 6,
  78959. subdivisions: 1
  78960. }, e);
  78961. return s.position.y += 3,
  78962. s.parent = n,
  78963. (o = s.clone(i.name)).position.y = 1.5,
  78964. o.position.x += 1.25,
  78965. (a = s.clone(i.name)).position.y = 1.5,
  78966. a.position.x += -1.25,
  78967. n.scaling.scaleInPlace(t._Scale),
  78968. n.rotation.z = Math.PI / 2,
  78969. n.rotation.y = Math.PI / 2,
  78970. i
  78971. }
  78972. ,
  78973. t._Scale = .007,
  78974. t._CreateLightLines = function(e, t) {
  78975. var i = new Vr("root",t);
  78976. i.rotation.x = Math.PI / 2;
  78977. var n = new Vr("linePivot",t);
  78978. n.parent = i;
  78979. var r = Ys("line", {
  78980. updatable: !1,
  78981. height: 2,
  78982. diameterTop: .2,
  78983. diameterBottom: .3,
  78984. tessellation: 6,
  78985. subdivisions: 1
  78986. }, t);
  78987. if (r.position.y = r.scaling.y / 2 + 1.2,
  78988. r.parent = n,
  78989. e < 2)
  78990. return n;
  78991. for (var o = 0; o < 4; o++) {
  78992. var a = n.clone("lineParentClone");
  78993. a.rotation.z = Math.PI / 4,
  78994. a.rotation.y = Math.PI / 2 + Math.PI / 2 * o,
  78995. a.getChildMeshes()[0].scaling.y = .5,
  78996. a.getChildMeshes()[0].scaling.x = a.getChildMeshes()[0].scaling.z = .8,
  78997. a.getChildMeshes()[0].position.y = a.getChildMeshes()[0].scaling.y / 2 + 1.2
  78998. }
  78999. if (e < 3)
  79000. return i;
  79001. for (o = 0; o < 4; o++) {
  79002. var s = n.clone("linePivotClone");
  79003. s.rotation.z = Math.PI / 2,
  79004. s.rotation.y = Math.PI / 2 * o
  79005. }
  79006. if (e < 4)
  79007. return i;
  79008. for (o = 0; o < 4; o++) {
  79009. var l = n.clone("linePivotClone");
  79010. l.rotation.z = Math.PI + Math.PI / 4,
  79011. l.rotation.y = Math.PI / 2 + Math.PI / 2 * o,
  79012. l.getChildMeshes()[0].scaling.y = .5,
  79013. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = .8,
  79014. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + 1.2
  79015. }
  79016. return e < 5 || (n.clone("linePivotClone").rotation.z = Math.PI),
  79017. i
  79018. }
  79019. ,
  79020. t
  79021. }(Sl)
  79022. , Ld = function(e) {
  79023. function t(t) {
  79024. void 0 === t && (t = El.DefaultUtilityLayer);
  79025. var i = e.call(this, t) || this;
  79026. return i._pointerObserver = null,
  79027. i.onClickedObservable = new h,
  79028. i._camera = null,
  79029. i._invProjection = new P,
  79030. i._material = new Os("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),
  79031. i._material.diffuseColor = new D(.5,.5,.5),
  79032. i._material.specularColor = new D(.1,.1,.1),
  79033. i._pointerObserver = t.utilityLayerScene.onPointerObservable.add((function(e) {
  79034. i._camera && (i._isHovered = !(!e.pickInfo || -1 == i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),
  79035. i._isHovered && 0 === e.event.button && i.onClickedObservable.notifyObservers(i._camera))
  79036. }
  79037. ), Xi.POINTERDOWN),
  79038. i
  79039. }
  79040. return U(t, e),
  79041. Object.defineProperty(t.prototype, "displayFrustum", {
  79042. get: function() {
  79043. return this._cameraLinesMesh.isEnabled()
  79044. },
  79045. set: function(e) {
  79046. this._cameraLinesMesh.setEnabled(e)
  79047. },
  79048. enumerable: !1,
  79049. configurable: !0
  79050. }),
  79051. Object.defineProperty(t.prototype, "camera", {
  79052. get: function() {
  79053. return this._camera
  79054. },
  79055. set: function(e) {
  79056. var i = this;
  79057. if (this._camera = e,
  79058. this.attachedNode = e,
  79059. e) {
  79060. this._cameraMesh && this._cameraMesh.dispose(),
  79061. this._cameraLinesMesh && this._cameraLinesMesh.dispose(),
  79062. this._cameraMesh = t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),
  79063. this._cameraLinesMesh = t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),
  79064. this._cameraMesh.getChildMeshes(!1).forEach((function(e) {
  79065. e.material = i._material
  79066. }
  79067. )),
  79068. this._cameraMesh.parent = this._rootMesh,
  79069. this._cameraLinesMesh.parent = this._rootMesh,
  79070. this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < 1.5 * e.maxZ && (this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = 1.5 * e.maxZ),
  79071. this.attachedNode.reservedDataStore || (this.attachedNode.reservedDataStore = {}),
  79072. this.attachedNode.reservedDataStore.cameraGizmo = this;
  79073. var n = this.gizmoLayer._getSharedGizmoLight();
  79074. n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),
  79075. this._update()
  79076. }
  79077. },
  79078. enumerable: !1,
  79079. configurable: !0
  79080. }),
  79081. Object.defineProperty(t.prototype, "material", {
  79082. get: function() {
  79083. return this._material
  79084. },
  79085. enumerable: !1,
  79086. configurable: !0
  79087. }),
  79088. t.prototype._update = function() {
  79089. e.prototype._update.call(this),
  79090. this._camera && (this._camera.getProjectionMatrix().invertToRef(this._invProjection),
  79091. this._cameraLinesMesh.setPivotMatrix(this._invProjection, !1),
  79092. this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x,
  79093. this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y,
  79094. this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z,
  79095. this._cameraMesh.parent = null,
  79096. this._cameraMesh.rotation.y = .5 * Math.PI * (this._camera.getScene().useRightHandedSystem ? 1 : -1),
  79097. this._cameraMesh.parent = this._rootMesh)
  79098. }
  79099. ,
  79100. t.prototype.dispose = function() {
  79101. this.onClickedObservable.clear(),
  79102. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
  79103. this._cameraMesh && this._cameraMesh.dispose(),
  79104. this._cameraLinesMesh && this._cameraLinesMesh.dispose(),
  79105. this._material.dispose(),
  79106. e.prototype.dispose.call(this)
  79107. }
  79108. ,
  79109. t._CreateCameraMesh = function(e) {
  79110. var i = new Vr("rootCameraGizmo",e)
  79111. , n = new Vr(i.name,e);
  79112. n.parent = i,
  79113. Ml(i.name, {
  79114. width: 1,
  79115. height: .8,
  79116. depth: .5
  79117. }, e).parent = n;
  79118. var r = Ys(i.name, {
  79119. height: .5,
  79120. diameterTop: .8,
  79121. diameterBottom: .8
  79122. }, e);
  79123. r.parent = n,
  79124. r.position.y = .3,
  79125. r.position.x = -.6,
  79126. r.rotation.x = .5 * Math.PI;
  79127. var o = Ys(i.name, {
  79128. height: .5,
  79129. diameterTop: .6,
  79130. diameterBottom: .6
  79131. }, e);
  79132. o.parent = n,
  79133. o.position.y = .5,
  79134. o.position.x = .4,
  79135. o.rotation.x = .5 * Math.PI;
  79136. var a = Ys(i.name, {
  79137. height: .5,
  79138. diameterTop: .5,
  79139. diameterBottom: .5
  79140. }, e);
  79141. return a.parent = n,
  79142. a.position.y = 0,
  79143. a.position.x = .6,
  79144. a.rotation.z = .5 * Math.PI,
  79145. i.scaling.scaleInPlace(t._Scale),
  79146. n.position.x = -.9,
  79147. i
  79148. }
  79149. ,
  79150. t._CreateCameraFrustum = function(e) {
  79151. var t = new Vr("rootCameraGizmo",e)
  79152. , i = new Vr(t.name,e);
  79153. i.parent = t;
  79154. for (var n = 0; n < 4; n += 2)
  79155. for (var r = 0; r < 4; r += 2) {
  79156. var o = Jl("lines", {
  79157. points: [new x(-1 + r,-1 + n,-1), new x(-1 + r,-1 + n,1)]
  79158. }, e);
  79159. o.parent = i,
  79160. o.alwaysSelectAsActiveMesh = !0,
  79161. o.isPickable = !1,
  79162. (o = Jl("lines", {
  79163. points: [new x(-1,-1 + r,-1 + n), new x(1,-1 + r,-1 + n)]
  79164. }, e)).parent = i,
  79165. o.alwaysSelectAsActiveMesh = !0,
  79166. o.isPickable = !1,
  79167. (o = Jl("lines", {
  79168. points: [new x(-1 + r,-1,-1 + n), new x(-1 + r,1,-1 + n)]
  79169. }, e)).parent = i,
  79170. o.alwaysSelectAsActiveMesh = !0,
  79171. o.isPickable = !1
  79172. }
  79173. return t
  79174. }
  79175. ,
  79176. t._Scale = .05,
  79177. t
  79178. }(Sl);
  79179. Pt.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};";
  79180. Pt.IncludesShadersStore.packingFunctions = "vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}";
  79181. Pt.IncludesShadersStore.kernelBlurFragment = "#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif\n";
  79182. Pt.IncludesShadersStore.kernelBlurFragment2 = "#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif\n";
  79183. Pt.ShadersStore.kernelBlurPixelShader = "uniform sampler2D textureSampler;\nuniform vec2 delta;\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g; \nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; \n}\nfloat sampleCoC(in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r; \nreturn coc; \n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include<packingFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";
  79184. Pt.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  79185. Pt.ShadersStore.kernelBlurVertexShader = "attribute vec2 position;\nuniform vec2 delta;\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  79186. var Fd = function(e) {
  79187. function t(t, i, n, r, o, s, l, c, u, h, d) {
  79188. void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
  79189. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  79190. void 0 === h && (h = ""),
  79191. void 0 === d && (d = !1);
  79192. var p = e.call(this, t, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], r, o, s, l, c, null, u, "kernelBlur", {
  79193. varyingCount: 0,
  79194. depCount: 0
  79195. }, !0) || this;
  79196. return p._blockCompilation = d,
  79197. p._packedFloat = !1,
  79198. p._staticDefines = "",
  79199. p._staticDefines = h,
  79200. p.direction = i,
  79201. p.onApplyObservable.add((function(e) {
  79202. p._outputTexture ? e.setFloat2("delta", 1 / p._outputTexture.width * p.direction.x, 1 / p._outputTexture.height * p.direction.y) : e.setFloat2("delta", 1 / p.width * p.direction.x, 1 / p.height * p.direction.y)
  79203. }
  79204. )),
  79205. p.kernel = n,
  79206. p
  79207. }
  79208. return U(t, e),
  79209. Object.defineProperty(t.prototype, "kernel", {
  79210. get: function() {
  79211. return this._idealKernel
  79212. },
  79213. set: function(e) {
  79214. this._idealKernel !== e && (e = Math.max(e, 1),
  79215. this._idealKernel = e,
  79216. this._kernel = this._nearestBestKernel(e),
  79217. this._blockCompilation || this._updateParameters())
  79218. },
  79219. enumerable: !1,
  79220. configurable: !0
  79221. }),
  79222. Object.defineProperty(t.prototype, "packedFloat", {
  79223. get: function() {
  79224. return this._packedFloat
  79225. },
  79226. set: function(e) {
  79227. this._packedFloat !== e && (this._packedFloat = e,
  79228. this._blockCompilation || this._updateParameters())
  79229. },
  79230. enumerable: !1,
  79231. configurable: !0
  79232. }),
  79233. t.prototype.getClassName = function() {
  79234. return "BlurPostProcess"
  79235. }
  79236. ,
  79237. t.prototype.updateEffect = function(e, t, i, n, r, o) {
  79238. void 0 === e && (e = null),
  79239. void 0 === t && (t = null),
  79240. void 0 === i && (i = null),
  79241. this._updateParameters(r, o)
  79242. }
  79243. ,
  79244. t.prototype._updateParameters = function(t, i) {
  79245. for (var n = this._kernel, r = (n - 1) / 2, o = [], a = [], s = 0, l = 0; l < n; l++) {
  79246. var c = l / (n - 1)
  79247. , u = this._gaussianWeight(2 * c - 1);
  79248. o[l] = l - r,
  79249. a[l] = u,
  79250. s += u
  79251. }
  79252. for (l = 0; l < a.length; l++)
  79253. a[l] /= s;
  79254. var h = []
  79255. , d = []
  79256. , p = [];
  79257. for (l = 0; l <= r; l += 2) {
  79258. var f = Math.min(l + 1, Math.floor(r));
  79259. if (l === f)
  79260. p.push({
  79261. o: o[l],
  79262. w: a[l]
  79263. });
  79264. else {
  79265. var _ = f === r
  79266. , m = a[l] + a[f] * (_ ? .5 : 1)
  79267. , g = o[l] + 1 / (1 + a[l] / a[f]);
  79268. 0 === g ? (p.push({
  79269. o: o[l],
  79270. w: a[l]
  79271. }),
  79272. p.push({
  79273. o: o[l + 1],
  79274. w: a[l + 1]
  79275. })) : (p.push({
  79276. o: g,
  79277. w: m
  79278. }),
  79279. p.push({
  79280. o: -g,
  79281. w: m
  79282. }))
  79283. }
  79284. }
  79285. for (l = 0; l < p.length; l++)
  79286. d[l] = p[l].o,
  79287. h[l] = p[l].w;
  79288. o = d,
  79289. a = h;
  79290. var v = this.getEngine().getCaps().maxVaryingVectors
  79291. , y = Math.max(v, 0) - 1
  79292. , b = Math.min(o.length, y)
  79293. , T = "";
  79294. for (T += this._staticDefines,
  79295. -1 != this._staticDefines.indexOf("DOF") && (T += "#define CENTER_WEIGHT ".concat(this._glslFloat(a[b - 1]), "\r\n"),
  79296. b--),
  79297. l = 0; l < b; l++)
  79298. T += "#define KERNEL_OFFSET".concat(l, " ").concat(this._glslFloat(o[l]), "\r\n"),
  79299. T += "#define KERNEL_WEIGHT".concat(l, " ").concat(this._glslFloat(a[l]), "\r\n");
  79300. var E = 0;
  79301. for (l = y; l < o.length; l++)
  79302. T += "#define KERNEL_DEP_OFFSET".concat(E, " ").concat(this._glslFloat(o[l]), "\r\n"),
  79303. T += "#define KERNEL_DEP_WEIGHT".concat(E, " ").concat(this._glslFloat(a[l]), "\r\n"),
  79304. E++;
  79305. this.packedFloat && (T += "#define PACKEDFLOAT 1"),
  79306. this._blockCompilation = !1,
  79307. e.prototype.updateEffect.call(this, T, null, null, {
  79308. varyingCount: b,
  79309. depCount: E
  79310. }, t, i)
  79311. }
  79312. ,
  79313. t.prototype._nearestBestKernel = function(e) {
  79314. for (var t = Math.round(e), i = 0, n = [t, t - 1, t + 1, t - 2, t + 2]; i < n.length; i++) {
  79315. var r = n[i];
  79316. if (r % 2 != 0 && Math.floor(r / 2) % 2 == 0 && r > 0)
  79317. return Math.max(r, 3)
  79318. }
  79319. return Math.max(t, 3)
  79320. }
  79321. ,
  79322. t.prototype._gaussianWeight = function(e) {
  79323. var t = 1 / 3
  79324. , i = -e * e / (2 * t * t);
  79325. return 1 / (Math.sqrt(2 * Math.PI) * t) * Math.exp(i)
  79326. }
  79327. ,
  79328. t.prototype._glslFloat = function(e, t) {
  79329. return void 0 === t && (t = 8),
  79330. e.toFixed(t).replace(/0+$/, "")
  79331. }
  79332. ,
  79333. t._Parse = function(e, i, n, r) {
  79334. return Ge.Parse((function() {
  79335. return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)
  79336. }
  79337. ), e, n, r)
  79338. }
  79339. ,
  79340. k([Ce("kernel")], t.prototype, "_kernel", void 0),
  79341. k([Ce("packedFloat")], t.prototype, "_packedFloat", void 0),
  79342. k([Oe()], t.prototype, "direction", void 0),
  79343. t
  79344. }(Ba);
  79345. y("BABYLON.BlurPostProcess", Fd);
  79346. var wd = function(e) {
  79347. function t(t, i, n, r, o, s, l) {
  79348. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  79349. void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
  79350. void 0 === l && (l = !0);
  79351. var c = e.call(this, t, i, n, r, !0, o, !1, s, l) || this;
  79352. if (c.mirrorPlane = new hn(0,1,0,1),
  79353. c._transformMatrix = P.Zero(),
  79354. c._mirrorMatrix = P.Zero(),
  79355. c._adaptiveBlurKernel = 0,
  79356. c._blurKernelX = 0,
  79357. c._blurKernelY = 0,
  79358. c._blurRatio = 1,
  79359. !(n = c.getScene()))
  79360. return c;
  79361. c.ignoreCameraViewport = !0,
  79362. c._updateGammaSpace(),
  79363. c._imageProcessingConfigChangeObserver = n.imageProcessingConfiguration.onUpdateParameters.add((function() {
  79364. c._updateGammaSpace()
  79365. }
  79366. ));
  79367. var u, h = n.getEngine();
  79368. return h.supportsUniformBuffers && (c._sceneUBO = n.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(t, '")'))),
  79369. c.onBeforeBindObservable.add((function() {
  79370. var e;
  79371. null === (e = h._debugPushGroup) || void 0 === e || e.call(h, "mirror generation for ".concat(t), 1)
  79372. }
  79373. )),
  79374. c.onAfterUnbindObservable.add((function() {
  79375. var e;
  79376. null === (e = h._debugPopGroup) || void 0 === e || e.call(h, 1)
  79377. }
  79378. )),
  79379. c.onBeforeRenderObservable.add((function() {
  79380. c._sceneUBO && (c._currentSceneUBO = n.getSceneUniformBuffer(),
  79381. n.setSceneUniformBuffer(c._sceneUBO),
  79382. n.getSceneUniformBuffer().unbindEffect()),
  79383. P.ReflectionToRef(c.mirrorPlane, c._mirrorMatrix),
  79384. c._mirrorMatrix.multiplyToRef(n.getViewMatrix(), c._transformMatrix),
  79385. n.setTransformMatrix(c._transformMatrix, n.getProjectionMatrix()),
  79386. u = n.clipPlane,
  79387. n.clipPlane = c.mirrorPlane,
  79388. n.getEngine().cullBackFaces = !1,
  79389. n._mirroredCameraPosition = x.TransformCoordinates(n.activeCamera.globalPosition, c._mirrorMatrix)
  79390. }
  79391. )),
  79392. c.onAfterRenderObservable.add((function() {
  79393. c._sceneUBO && n.setSceneUniformBuffer(c._currentSceneUBO),
  79394. n.updateTransformMatrix(),
  79395. n.getEngine().cullBackFaces = null,
  79396. n._mirroredCameraPosition = null,
  79397. n.clipPlane = u
  79398. }
  79399. )),
  79400. c
  79401. }
  79402. return U(t, e),
  79403. Object.defineProperty(t.prototype, "blurRatio", {
  79404. get: function() {
  79405. return this._blurRatio
  79406. },
  79407. set: function(e) {
  79408. this._blurRatio !== e && (this._blurRatio = e,
  79409. this._preparePostProcesses())
  79410. },
  79411. enumerable: !1,
  79412. configurable: !0
  79413. }),
  79414. Object.defineProperty(t.prototype, "adaptiveBlurKernel", {
  79415. set: function(e) {
  79416. this._adaptiveBlurKernel = e,
  79417. this._autoComputeBlurKernel()
  79418. },
  79419. enumerable: !1,
  79420. configurable: !0
  79421. }),
  79422. Object.defineProperty(t.prototype, "blurKernel", {
  79423. set: function(e) {
  79424. this.blurKernelX = e,
  79425. this.blurKernelY = e
  79426. },
  79427. enumerable: !1,
  79428. configurable: !0
  79429. }),
  79430. Object.defineProperty(t.prototype, "blurKernelX", {
  79431. get: function() {
  79432. return this._blurKernelX
  79433. },
  79434. set: function(e) {
  79435. this._blurKernelX !== e && (this._blurKernelX = e,
  79436. this._preparePostProcesses())
  79437. },
  79438. enumerable: !1,
  79439. configurable: !0
  79440. }),
  79441. Object.defineProperty(t.prototype, "blurKernelY", {
  79442. get: function() {
  79443. return this._blurKernelY
  79444. },
  79445. set: function(e) {
  79446. this._blurKernelY !== e && (this._blurKernelY = e,
  79447. this._preparePostProcesses())
  79448. },
  79449. enumerable: !1,
  79450. configurable: !0
  79451. }),
  79452. t.prototype._autoComputeBlurKernel = function() {
  79453. var e = this.getScene().getEngine()
  79454. , t = this.getRenderWidth() / e.getRenderWidth()
  79455. , i = this.getRenderHeight() / e.getRenderHeight();
  79456. this.blurKernelX = this._adaptiveBlurKernel * t,
  79457. this.blurKernelY = this._adaptiveBlurKernel * i
  79458. }
  79459. ,
  79460. t.prototype._onRatioRescale = function() {
  79461. this._sizeRatio && (this.resize(this._initialSizeParameter),
  79462. this._adaptiveBlurKernel || this._preparePostProcesses()),
  79463. this._adaptiveBlurKernel && this._autoComputeBlurKernel()
  79464. }
  79465. ,
  79466. t.prototype._updateGammaSpace = function() {
  79467. var e = this.getScene();
  79468. e && (this.gammaSpace = !e.imageProcessingConfiguration.isEnabled || !e.imageProcessingConfiguration.applyByPostProcess)
  79469. }
  79470. ,
  79471. t.prototype._preparePostProcesses = function() {
  79472. if (this.clearPostProcesses(!0),
  79473. this._blurKernelX && this._blurKernelY) {
  79474. var e = this.getScene().getEngine()
  79475. , t = e.getCaps().textureFloatRender && e.getCaps().textureFloatLinearFiltering ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT;
  79476. this._blurX = new Fd("horizontal blur",new A(1,0),this._blurKernelX,this._blurRatio,null,io.BILINEAR_SAMPLINGMODE,e,!1,t),
  79477. this._blurX.autoClear = !1,
  79478. 1 === this._blurRatio && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._renderTarget : this._blurX.alwaysForcePOT = !0,
  79479. this._blurY = new Fd("vertical blur",new A(0,1),this._blurKernelY,this._blurRatio,null,io.BILINEAR_SAMPLINGMODE,e,!1,t),
  79480. this._blurY.autoClear = !1,
  79481. this._blurY.alwaysForcePOT = 1 !== this._blurRatio,
  79482. this.addPostProcess(this._blurX),
  79483. this.addPostProcess(this._blurY)
  79484. } else
  79485. this._blurY && (this.removePostProcess(this._blurY),
  79486. this._blurY.dispose(),
  79487. this._blurY = null),
  79488. this._blurX && (this.removePostProcess(this._blurX),
  79489. this._blurX.dispose(),
  79490. this._blurX = null)
  79491. }
  79492. ,
  79493. t.prototype.clone = function() {
  79494. var e = this.getScene();
  79495. if (!e)
  79496. return this;
  79497. var i = this.getSize()
  79498. , n = new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);
  79499. return n.hasAlpha = this.hasAlpha,
  79500. n.level = this.level,
  79501. n.mirrorPlane = this.mirrorPlane.clone(),
  79502. this.renderList && (n.renderList = this.renderList.slice(0)),
  79503. n
  79504. }
  79505. ,
  79506. t.prototype.serialize = function() {
  79507. if (!this.name)
  79508. return null;
  79509. var t = e.prototype.serialize.call(this);
  79510. return t.mirrorPlane = this.mirrorPlane.asArray(),
  79511. t
  79512. }
  79513. ,
  79514. t.prototype.dispose = function() {
  79515. var t;
  79516. e.prototype.dispose.call(this);
  79517. var i = this.getScene();
  79518. i && i.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),
  79519. null === (t = this._sceneUBO) || void 0 === t || t.dispose()
  79520. }
  79521. ,
  79522. t
  79523. }(ns);
  79524. io._CreateMirror = function(e, t, i, n) {
  79525. return new wd(e,t,i,n)
  79526. }
  79527. ;
  79528. var Bd = function(e) {
  79529. function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
  79530. void 0 === n && (n = null),
  79531. void 0 === r && (r = !1),
  79532. void 0 === o && (o = null),
  79533. void 0 === s && (s = null),
  79534. void 0 === l && (l = null),
  79535. void 0 === c && (c = a.TEXTUREFORMAT_RGBA),
  79536. void 0 === u && (u = !1),
  79537. void 0 === d && (d = null),
  79538. void 0 === p && (p = !1),
  79539. void 0 === f && (f = .8),
  79540. void 0 === _ && (_ = 0);
  79541. var v, y = this;
  79542. return (y = e.call(this, i) || this)._lodScale = .8,
  79543. y._lodOffset = 0,
  79544. y.onLoadObservable = new h,
  79545. y.boundingBoxPosition = x.Zero(),
  79546. y._rotationY = 0,
  79547. y._files = null,
  79548. y._forcedExtension = null,
  79549. y._extensions = null,
  79550. y.name = t,
  79551. y.url = t,
  79552. y._noMipmap = r,
  79553. y.hasAlpha = !1,
  79554. y._format = c,
  79555. y.isCube = !0,
  79556. y._textureMatrix = P.Identity(),
  79557. y._createPolynomials = p,
  79558. y.coordinatesMode = io.CUBIC_MODE,
  79559. y._extensions = n,
  79560. y._files = o,
  79561. y._forcedExtension = d,
  79562. y._loaderOptions = m,
  79563. y._useSRGBBuffer = g,
  79564. y._lodScale = f,
  79565. y._lodOffset = _,
  79566. t || o ? (y.updateURL(t, d, s, u, l, n, null === (v = y.getScene()) || void 0 === v ? void 0 : v.useDelayedTextureLoading, o),
  79567. y) : y
  79568. }
  79569. return U(t, e),
  79570. Object.defineProperty(t.prototype, "boundingBoxSize", {
  79571. get: function() {
  79572. return this._boundingBoxSize
  79573. },
  79574. set: function(e) {
  79575. if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
  79576. this._boundingBoxSize = e;
  79577. var t = this.getScene();
  79578. t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
  79579. }
  79580. },
  79581. enumerable: !1,
  79582. configurable: !0
  79583. }),
  79584. Object.defineProperty(t.prototype, "rotationY", {
  79585. get: function() {
  79586. return this._rotationY
  79587. },
  79588. set: function(e) {
  79589. this._rotationY = e,
  79590. this.setReflectionTextureMatrix(P.RotationY(this._rotationY))
  79591. },
  79592. enumerable: !1,
  79593. configurable: !0
  79594. }),
  79595. Object.defineProperty(t.prototype, "noMipmap", {
  79596. get: function() {
  79597. return this._noMipmap
  79598. },
  79599. enumerable: !1,
  79600. configurable: !0
  79601. }),
  79602. Object.defineProperty(t.prototype, "forcedExtension", {
  79603. get: function() {
  79604. return this._forcedExtension
  79605. },
  79606. enumerable: !1,
  79607. configurable: !0
  79608. }),
  79609. t.CreateFromImages = function(e, i, n) {
  79610. var r = "";
  79611. return e.forEach((function(e) {
  79612. return r += e
  79613. }
  79614. )),
  79615. new t(r,i,null,n,e)
  79616. }
  79617. ,
  79618. t.CreateFromPrefilteredData = function(e, i, n, r) {
  79619. void 0 === n && (n = null),
  79620. void 0 === r && (r = !0);
  79621. var o = i.useDelayedTextureLoading;
  79622. i.useDelayedTextureLoading = !1;
  79623. var a = new t(e,i,null,!1,null,null,null,void 0,!0,n,r);
  79624. return i.useDelayedTextureLoading = o,
  79625. a
  79626. }
  79627. ,
  79628. t.prototype.getClassName = function() {
  79629. return "CubeTexture"
  79630. }
  79631. ,
  79632. t.prototype.updateURL = function(e, t, i, n, r, o, s, l) {
  79633. void 0 === i && (i = null),
  79634. void 0 === n && (n = !1),
  79635. void 0 === r && (r = null),
  79636. void 0 === o && (o = null),
  79637. void 0 === s && (s = !1),
  79638. void 0 === l && (l = null),
  79639. this.name && !ae(this.name, "data:") || (this.name = e),
  79640. this.url = e;
  79641. var c = e.lastIndexOf(".")
  79642. , u = t || (c > -1 ? e.substring(c).toLowerCase() : "")
  79643. , h = 0 === u.indexOf(".dds")
  79644. , d = 0 === u.indexOf(".env");
  79645. if (d ? (this.gammaSpace = !1,
  79646. this._prefiltered = !1,
  79647. this.anisotropicFilteringLevel = 1) : (this._prefiltered = n,
  79648. n && (this.gammaSpace = !1,
  79649. this.anisotropicFilteringLevel = 1)),
  79650. l)
  79651. this._files = l;
  79652. else if (d || h || o || (o = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]),
  79653. this._files = this._files || [],
  79654. this._files.length = 0,
  79655. o) {
  79656. for (var p = 0; p < o.length; p++)
  79657. this._files.push(e + o[p]);
  79658. this._extensions = o
  79659. }
  79660. s ? (this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
  79661. this._delayedOnLoad = i,
  79662. this._delayedOnError = r) : this._loadTexture(i, r)
  79663. }
  79664. ,
  79665. t.prototype.delayLoad = function(e) {
  79666. this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (e && (this._forcedExtension = e),
  79667. this.delayLoadState = a.DELAYLOADSTATE_LOADED,
  79668. this._loadTexture(this._delayedOnLoad, this._delayedOnError))
  79669. }
  79670. ,
  79671. t.prototype.getReflectionTextureMatrix = function() {
  79672. return this._textureMatrix
  79673. }
  79674. ,
  79675. t.prototype.setReflectionTextureMatrix = function(e) {
  79676. var t, i = this;
  79677. e.updateFlag !== this._textureMatrix.updateFlag && (e.isIdentity() !== this._textureMatrix.isIdentity() && (null === (t = this.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  79678. return -1 !== e.getActiveTextures().indexOf(i)
  79679. }
  79680. ))),
  79681. this._textureMatrix = e)
  79682. }
  79683. ,
  79684. t.prototype._loadTexture = function(e, t) {
  79685. var i, n = this;
  79686. void 0 === e && (e = null),
  79687. void 0 === t && (t = null);
  79688. var r = this.getScene()
  79689. , o = this._texture;
  79690. this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
  79691. var s = function() {
  79692. var t;
  79693. n.onLoadObservable.notifyObservers(n),
  79694. o && (o.dispose(),
  79695. null === (t = n.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
  79696. e && e()
  79697. }
  79698. , l = function(e, i) {
  79699. n._loadingError = !0,
  79700. n._errorObject = {
  79701. message: e,
  79702. exception: i
  79703. },
  79704. t && t(e, i),
  79705. io.OnTextureLoadErrorObservable.notifyObservers(n)
  79706. };
  79707. this._texture ? this._texture.isReady ? gi.SetImmediate((function() {
  79708. return s()
  79709. }
  79710. )) : this._texture.onLoadedObservable.add((function() {
  79711. return s()
  79712. }
  79713. )) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, r, this._lodScale, this._lodOffset, e, l, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, r, this._files, this._noMipmap, e, l, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer),
  79714. null === (i = this._texture) || void 0 === i || i.onLoadedObservable.add((function() {
  79715. return n.onLoadObservable.notifyObservers(n)
  79716. }
  79717. )))
  79718. }
  79719. ,
  79720. t.Parse = function(e, i, n) {
  79721. var r = Ge.Parse((function() {
  79722. var r = !1;
  79723. return e.prefiltered && (r = e.prefiltered),
  79724. new t(n + e.name,i,e.extensions,!1,e.files || null,null,null,void 0,r,e.forcedExtension)
  79725. }
  79726. ), e, i);
  79727. if (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
  79728. e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
  79729. e.animations)
  79730. for (var o = 0; o < e.animations.length; o++) {
  79731. var a = e.animations[o]
  79732. , s = b("BABYLON.Animation");
  79733. s && r.animations.push(s.Parse(a))
  79734. }
  79735. return r
  79736. }
  79737. ,
  79738. t.prototype.clone = function() {
  79739. var e = this
  79740. , i = 0
  79741. , n = Ge.Clone((function() {
  79742. var n = new t(e.url,e.getScene() || e._getEngine(),e._extensions,e._noMipmap,e._files);
  79743. return i = n.uniqueId,
  79744. n
  79745. }
  79746. ), this);
  79747. return n.uniqueId = i,
  79748. n
  79749. }
  79750. ,
  79751. k([Ce()], t.prototype, "url", void 0),
  79752. k([Ce("rotationY")], t.prototype, "rotationY", null),
  79753. k([Ce("files")], t.prototype, "_files", void 0),
  79754. k([Ce("forcedExtension")], t.prototype, "_forcedExtension", void 0),
  79755. k([Ce("extensions")], t.prototype, "_extensions", void 0),
  79756. k([Ue("textureMatrix")], t.prototype, "_textureMatrix", void 0),
  79757. t
  79758. }(Zr);
  79759. io._CubeTextureParser = Bd.Parse,
  79760. y("BABYLON.CubeTexture", Bd);
  79761. Pt.IncludesShadersStore.backgroundFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n";
  79762. Pt.IncludesShadersStore.backgroundUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\n#include<sceneUboDeclaration>\n";
  79763. Pt.ShadersStore.backgroundPixelShader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#include<helperFunctions>\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV==1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV==2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n#ifndef BACKMAT_SHADOWONLY\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition.xyz),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\nvec4 color=vec4(finalColor,finalAlpha);\n#else\nvec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);\n#endif\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n#if !defined(SKIPFINALCOLORCLAMP)\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#endif\n#else\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
  79764. Pt.IncludesShadersStore.backgroundVertexDeclaration = "uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
  79765. Pt.ShadersStore.backgroundVertexShader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nif (vDiffuseInfos.x==0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  79766. var Ud = function(e) {
  79767. function t() {
  79768. var t = e.call(this) || this;
  79769. return t.DIFFUSE = !1,
  79770. t.DIFFUSEDIRECTUV = 0,
  79771. t.GAMMADIFFUSE = !1,
  79772. t.DIFFUSEHASALPHA = !1,
  79773. t.OPACITYFRESNEL = !1,
  79774. t.REFLECTIONBLUR = !1,
  79775. t.REFLECTIONFRESNEL = !1,
  79776. t.REFLECTIONFALLOFF = !1,
  79777. t.TEXTURELODSUPPORT = !1,
  79778. t.PREMULTIPLYALPHA = !1,
  79779. t.USERGBCOLOR = !1,
  79780. t.USEHIGHLIGHTANDSHADOWCOLORS = !1,
  79781. t.BACKMAT_SHADOWONLY = !1,
  79782. t.NOISE = !1,
  79783. t.REFLECTIONBGR = !1,
  79784. t.IMAGEPROCESSING = !1,
  79785. t.VIGNETTE = !1,
  79786. t.VIGNETTEBLENDMODEMULTIPLY = !1,
  79787. t.VIGNETTEBLENDMODEOPAQUE = !1,
  79788. t.TONEMAPPING = !1,
  79789. t.TONEMAPPING_ACES = !1,
  79790. t.CONTRAST = !1,
  79791. t.COLORCURVES = !1,
  79792. t.COLORGRADING = !1,
  79793. t.COLORGRADING3D = !1,
  79794. t.SAMPLER3DGREENDEPTH = !1,
  79795. t.SAMPLER3DBGRMAP = !1,
  79796. t.IMAGEPROCESSINGPOSTPROCESS = !1,
  79797. t.SKIPFINALCOLORCLAMP = !1,
  79798. t.EXPOSURE = !1,
  79799. t.MULTIVIEW = !1,
  79800. t.REFLECTION = !1,
  79801. t.REFLECTIONMAP_3D = !1,
  79802. t.REFLECTIONMAP_SPHERICAL = !1,
  79803. t.REFLECTIONMAP_PLANAR = !1,
  79804. t.REFLECTIONMAP_CUBIC = !1,
  79805. t.REFLECTIONMAP_PROJECTION = !1,
  79806. t.REFLECTIONMAP_SKYBOX = !1,
  79807. t.REFLECTIONMAP_EXPLICIT = !1,
  79808. t.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  79809. t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  79810. t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  79811. t.INVERTCUBICMAP = !1,
  79812. t.REFLECTIONMAP_OPPOSITEZ = !1,
  79813. t.LODINREFLECTIONALPHA = !1,
  79814. t.GAMMAREFLECTION = !1,
  79815. t.RGBDREFLECTION = !1,
  79816. t.EQUIRECTANGULAR_RELFECTION_FOV = !1,
  79817. t.MAINUV1 = !1,
  79818. t.MAINUV2 = !1,
  79819. t.UV1 = !1,
  79820. t.UV2 = !1,
  79821. t.CLIPPLANE = !1,
  79822. t.CLIPPLANE2 = !1,
  79823. t.CLIPPLANE3 = !1,
  79824. t.CLIPPLANE4 = !1,
  79825. t.CLIPPLANE5 = !1,
  79826. t.CLIPPLANE6 = !1,
  79827. t.POINTSIZE = !1,
  79828. t.FOG = !1,
  79829. t.NORMAL = !1,
  79830. t.NUM_BONE_INFLUENCERS = 0,
  79831. t.BonesPerMesh = 0,
  79832. t.INSTANCES = !1,
  79833. t.SHADOWFLOAT = !1,
  79834. t.LOGARITHMICDEPTH = !1,
  79835. t.NONUNIFORMSCALING = !1,
  79836. t.ALPHATEST = !1,
  79837. t.rebuild(),
  79838. t
  79839. }
  79840. return U(t, e),
  79841. t
  79842. }(Si)
  79843. , Vd = function(e) {
  79844. function t(t, i) {
  79845. var n = e.call(this, t, i) || this;
  79846. return n.primaryColor = D.White(),
  79847. n._primaryColorShadowLevel = 0,
  79848. n._primaryColorHighlightLevel = 0,
  79849. n.reflectionTexture = null,
  79850. n.reflectionBlur = 0,
  79851. n.diffuseTexture = null,
  79852. n._shadowLights = null,
  79853. n.shadowLights = null,
  79854. n.shadowLevel = 0,
  79855. n.sceneCenter = x.Zero(),
  79856. n.opacityFresnel = !0,
  79857. n.reflectionFresnel = !1,
  79858. n.reflectionFalloffDistance = 0,
  79859. n.reflectionAmount = 1,
  79860. n.reflectionReflectance0 = .05,
  79861. n.reflectionReflectance90 = .5,
  79862. n.useRGBColor = !0,
  79863. n.enableNoise = !1,
  79864. n._fovMultiplier = 1,
  79865. n.useEquirectangularFOV = !1,
  79866. n._maxSimultaneousLights = 4,
  79867. n.maxSimultaneousLights = 4,
  79868. n._shadowOnly = !1,
  79869. n.shadowOnly = !1,
  79870. n._imageProcessingObserver = null,
  79871. n.switchToBGR = !1,
  79872. n._renderTargets = new bi(16),
  79873. n._reflectionControls = R.Zero(),
  79874. n._white = D.White(),
  79875. n._primaryShadowColor = D.Black(),
  79876. n._primaryHighlightColor = D.Black(),
  79877. n._attachImageProcessingConfiguration(null),
  79878. n.getRenderTargetTextures = function() {
  79879. return n._renderTargets.reset(),
  79880. n._diffuseTexture && n._diffuseTexture.isRenderTarget && n._renderTargets.push(n._diffuseTexture),
  79881. n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture),
  79882. n._renderTargets
  79883. }
  79884. ,
  79885. n
  79886. }
  79887. return U(t, e),
  79888. Object.defineProperty(t.prototype, "_perceptualColor", {
  79889. get: function() {
  79890. return this.__perceptualColor
  79891. },
  79892. set: function(e) {
  79893. this.__perceptualColor = e,
  79894. this._computePrimaryColorFromPerceptualColor(),
  79895. this._markAllSubMeshesAsLightsDirty()
  79896. },
  79897. enumerable: !1,
  79898. configurable: !0
  79899. }),
  79900. Object.defineProperty(t.prototype, "primaryColorShadowLevel", {
  79901. get: function() {
  79902. return this._primaryColorShadowLevel
  79903. },
  79904. set: function(e) {
  79905. this._primaryColorShadowLevel = e,
  79906. this._computePrimaryColors(),
  79907. this._markAllSubMeshesAsLightsDirty()
  79908. },
  79909. enumerable: !1,
  79910. configurable: !0
  79911. }),
  79912. Object.defineProperty(t.prototype, "primaryColorHighlightLevel", {
  79913. get: function() {
  79914. return this._primaryColorHighlightLevel
  79915. },
  79916. set: function(e) {
  79917. this._primaryColorHighlightLevel = e,
  79918. this._computePrimaryColors(),
  79919. this._markAllSubMeshesAsLightsDirty()
  79920. },
  79921. enumerable: !1,
  79922. configurable: !0
  79923. }),
  79924. Object.defineProperty(t.prototype, "reflectionStandardFresnelWeight", {
  79925. set: function(e) {
  79926. var i = e;
  79927. i < .5 ? (i *= 2,
  79928. this.reflectionReflectance0 = t.StandardReflectance0 * i,
  79929. this.reflectionReflectance90 = t.StandardReflectance90 * i) : (i = 2 * i - 1,
  79930. this.reflectionReflectance0 = t.StandardReflectance0 + (1 - t.StandardReflectance0) * i,
  79931. this.reflectionReflectance90 = t.StandardReflectance90 + (1 - t.StandardReflectance90) * i)
  79932. },
  79933. enumerable: !1,
  79934. configurable: !0
  79935. }),
  79936. Object.defineProperty(t.prototype, "fovMultiplier", {
  79937. get: function() {
  79938. return this._fovMultiplier
  79939. },
  79940. set: function(e) {
  79941. isNaN(e) && (e = 1),
  79942. this._fovMultiplier = Math.max(0, Math.min(2, e))
  79943. },
  79944. enumerable: !1,
  79945. configurable: !0
  79946. }),
  79947. t.prototype._attachImageProcessingConfiguration = function(e) {
  79948. var t = this;
  79949. e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  79950. this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
  79951. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
  79952. t._computePrimaryColorFromPerceptualColor(),
  79953. t._markAllSubMeshesAsImageProcessingDirty()
  79954. }
  79955. ))))
  79956. }
  79957. ,
  79958. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  79959. get: function() {
  79960. return this._imageProcessingConfiguration
  79961. },
  79962. set: function(e) {
  79963. this._attachImageProcessingConfiguration(e),
  79964. this._markAllSubMeshesAsTexturesDirty()
  79965. },
  79966. enumerable: !1,
  79967. configurable: !0
  79968. }),
  79969. Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
  79970. get: function() {
  79971. return this.imageProcessingConfiguration.colorCurvesEnabled
  79972. },
  79973. set: function(e) {
  79974. this.imageProcessingConfiguration.colorCurvesEnabled = e
  79975. },
  79976. enumerable: !1,
  79977. configurable: !0
  79978. }),
  79979. Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
  79980. get: function() {
  79981. return this.imageProcessingConfiguration.colorGradingEnabled
  79982. },
  79983. set: function(e) {
  79984. this.imageProcessingConfiguration.colorGradingEnabled = e
  79985. },
  79986. enumerable: !1,
  79987. configurable: !0
  79988. }),
  79989. Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
  79990. get: function() {
  79991. return this._imageProcessingConfiguration.toneMappingEnabled
  79992. },
  79993. set: function(e) {
  79994. this._imageProcessingConfiguration.toneMappingEnabled = e
  79995. },
  79996. enumerable: !1,
  79997. configurable: !0
  79998. }),
  79999. Object.defineProperty(t.prototype, "cameraExposure", {
  80000. get: function() {
  80001. return this._imageProcessingConfiguration.exposure
  80002. },
  80003. set: function(e) {
  80004. this._imageProcessingConfiguration.exposure = e
  80005. },
  80006. enumerable: !1,
  80007. configurable: !0
  80008. }),
  80009. Object.defineProperty(t.prototype, "cameraContrast", {
  80010. get: function() {
  80011. return this._imageProcessingConfiguration.contrast
  80012. },
  80013. set: function(e) {
  80014. this._imageProcessingConfiguration.contrast = e
  80015. },
  80016. enumerable: !1,
  80017. configurable: !0
  80018. }),
  80019. Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
  80020. get: function() {
  80021. return this._imageProcessingConfiguration.colorGradingTexture
  80022. },
  80023. set: function(e) {
  80024. this.imageProcessingConfiguration.colorGradingTexture = e
  80025. },
  80026. enumerable: !1,
  80027. configurable: !0
  80028. }),
  80029. Object.defineProperty(t.prototype, "cameraColorCurves", {
  80030. get: function() {
  80031. return this.imageProcessingConfiguration.colorCurves
  80032. },
  80033. set: function(e) {
  80034. this.imageProcessingConfiguration.colorCurves = e
  80035. },
  80036. enumerable: !1,
  80037. configurable: !0
  80038. }),
  80039. Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
  80040. get: function() {
  80041. return !(!this._diffuseTexture || !this._diffuseTexture.isRenderTarget) || !(!this._reflectionTexture || !this._reflectionTexture.isRenderTarget)
  80042. },
  80043. enumerable: !1,
  80044. configurable: !0
  80045. }),
  80046. t.prototype.needAlphaTesting = function() {
  80047. return !0
  80048. }
  80049. ,
  80050. t.prototype.needAlphaBlending = function() {
  80051. return this.alpha < 1 || null != this._diffuseTexture && this._diffuseTexture.hasAlpha || this._shadowOnly
  80052. }
  80053. ,
  80054. t.prototype.isReadyForSubMesh = function(e, t, i) {
  80055. if (void 0 === i && (i = !1),
  80056. t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
  80057. return !0;
  80058. t.materialDefines || (t.materialDefines = new Ud);
  80059. var n = this.getScene()
  80060. , r = t.materialDefines;
  80061. if (this._isReadyForSubMesh(t))
  80062. return !0;
  80063. var o = n.getEngine();
  80064. if (Mr.PrepareDefinesForLights(n, e, r, !1, this._maxSimultaneousLights),
  80065. r._needNormals = !0,
  80066. Mr.PrepareDefinesForMultiview(n, r),
  80067. r._areTexturesDirty) {
  80068. if (r._needUVs = !1,
  80069. n.texturesEnabled) {
  80070. if (n.getEngine().getCaps().textureLOD && (r.TEXTURELODSUPPORT = !0),
  80071. this._diffuseTexture && vs.DiffuseTextureEnabled) {
  80072. if (!this._diffuseTexture.isReadyOrNotBlocking())
  80073. return !1;
  80074. Mr.PrepareDefinesForMergedUV(this._diffuseTexture, r, "DIFFUSE"),
  80075. r.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha,
  80076. r.GAMMADIFFUSE = this._diffuseTexture.gammaSpace,
  80077. r.OPACITYFRESNEL = this._opacityFresnel
  80078. } else
  80079. r.DIFFUSE = !1,
  80080. r.DIFFUSEHASALPHA = !1,
  80081. r.GAMMADIFFUSE = !1,
  80082. r.OPACITYFRESNEL = !1;
  80083. var s = this._reflectionTexture;
  80084. if (s && vs.ReflectionTextureEnabled) {
  80085. if (!s.isReadyOrNotBlocking())
  80086. return !1;
  80087. switch (r.REFLECTION = !0,
  80088. r.GAMMAREFLECTION = s.gammaSpace,
  80089. r.RGBDREFLECTION = s.isRGBD,
  80090. r.REFLECTIONBLUR = this._reflectionBlur > 0,
  80091. r.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !s.invertZ : s.invertZ,
  80092. r.LODINREFLECTIONALPHA = s.lodLevelInAlpha,
  80093. r.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV,
  80094. r.REFLECTIONBGR = this.switchToBGR,
  80095. s.coordinatesMode === io.INVCUBIC_MODE && (r.INVERTCUBICMAP = !0),
  80096. r.REFLECTIONMAP_3D = s.isCube,
  80097. s.coordinatesMode) {
  80098. case io.EXPLICIT_MODE:
  80099. r.REFLECTIONMAP_EXPLICIT = !0;
  80100. break;
  80101. case io.PLANAR_MODE:
  80102. r.REFLECTIONMAP_PLANAR = !0;
  80103. break;
  80104. case io.PROJECTION_MODE:
  80105. r.REFLECTIONMAP_PROJECTION = !0;
  80106. break;
  80107. case io.SKYBOX_MODE:
  80108. r.REFLECTIONMAP_SKYBOX = !0;
  80109. break;
  80110. case io.SPHERICAL_MODE:
  80111. r.REFLECTIONMAP_SPHERICAL = !0;
  80112. break;
  80113. case io.EQUIRECTANGULAR_MODE:
  80114. r.REFLECTIONMAP_EQUIRECTANGULAR = !0;
  80115. break;
  80116. case io.FIXED_EQUIRECTANGULAR_MODE:
  80117. r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
  80118. break;
  80119. case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  80120. r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
  80121. break;
  80122. case io.CUBIC_MODE:
  80123. case io.INVCUBIC_MODE:
  80124. default:
  80125. r.REFLECTIONMAP_CUBIC = !0
  80126. }
  80127. this.reflectionFresnel ? (r.REFLECTIONFRESNEL = !0,
  80128. r.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0,
  80129. this._reflectionControls.x = this.reflectionAmount,
  80130. this._reflectionControls.y = this.reflectionReflectance0,
  80131. this._reflectionControls.z = this.reflectionReflectance90,
  80132. this._reflectionControls.w = 1 / this.reflectionFalloffDistance) : (r.REFLECTIONFRESNEL = !1,
  80133. r.REFLECTIONFALLOFF = !1)
  80134. } else
  80135. r.REFLECTION = !1,
  80136. r.REFLECTIONFRESNEL = !1,
  80137. r.REFLECTIONFALLOFF = !1,
  80138. r.REFLECTIONBLUR = !1,
  80139. r.REFLECTIONMAP_3D = !1,
  80140. r.REFLECTIONMAP_SPHERICAL = !1,
  80141. r.REFLECTIONMAP_PLANAR = !1,
  80142. r.REFLECTIONMAP_CUBIC = !1,
  80143. r.REFLECTIONMAP_PROJECTION = !1,
  80144. r.REFLECTIONMAP_SKYBOX = !1,
  80145. r.REFLECTIONMAP_EXPLICIT = !1,
  80146. r.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  80147. r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  80148. r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  80149. r.INVERTCUBICMAP = !1,
  80150. r.REFLECTIONMAP_OPPOSITEZ = !1,
  80151. r.LODINREFLECTIONALPHA = !1,
  80152. r.GAMMAREFLECTION = !1,
  80153. r.RGBDREFLECTION = !1
  80154. }
  80155. r.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
  80156. r.USERGBCOLOR = this._useRGBColor,
  80157. r.NOISE = this._enableNoise
  80158. }
  80159. if (r._areLightsDirty && (r.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (0 !== this._primaryColorShadowLevel || 0 !== this._primaryColorHighlightLevel),
  80160. r.BACKMAT_SHADOWONLY = this._shadowOnly),
  80161. r._areImageProcessingDirty && this._imageProcessingConfiguration) {
  80162. if (!this._imageProcessingConfiguration.isReady())
  80163. return !1;
  80164. this._imageProcessingConfiguration.prepareDefines(r)
  80165. }
  80166. if (Mr.PrepareDefinesForMisc(e, n, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), r),
  80167. Mr.PrepareDefinesForFrameBoundValues(n, o, r, i, null, t.getRenderingMesh().hasThinInstances),
  80168. Mr.PrepareDefinesForAttributes(e, r, !1, !0, !1) && e && (n.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
  80169. K.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))),
  80170. r.isDirty) {
  80171. r.markAsProcessed(),
  80172. n.resetCachedMaterial();
  80173. var l = new ys;
  80174. r.FOG && l.addFallback(0, "FOG"),
  80175. r.POINTSIZE && l.addFallback(1, "POINTSIZE"),
  80176. r.MULTIVIEW && l.addFallback(0, "MULTIVIEW"),
  80177. Mr.HandleFallbacksForShadows(r, l, this._maxSimultaneousLights);
  80178. var c = [Bi.PositionKind];
  80179. r.NORMAL && c.push(Bi.NormalKind),
  80180. r.UV1 && c.push(Bi.UVKind),
  80181. r.UV2 && c.push(Bi.UV2Kind),
  80182. Mr.PrepareAttributesForBones(c, e, r, l),
  80183. Mr.PrepareAttributesForInstances(c, r);
  80184. var u = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "mBones", "vPrimaryColor", "vPrimaryColorShadow", "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier", "shadowLevel", "alpha", "vBackgroundCenter", "vReflectionControl", "vDiffuseInfos", "diffuseMatrix"]
  80185. , h = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"]
  80186. , d = ["Material", "Scene"];
  80187. Ri && (Ri.PrepareUniforms(u, r),
  80188. Ri.PrepareSamplers(h, r)),
  80189. Mr.PrepareUniformsAndSamplersList({
  80190. uniformsNames: u,
  80191. uniformBuffersNames: d,
  80192. samplers: h,
  80193. defines: r,
  80194. maxSimultaneousLights: this._maxSimultaneousLights
  80195. });
  80196. var p = r.toString()
  80197. , f = n.getEngine().createEffect("background", {
  80198. attributes: c,
  80199. uniformsNames: u,
  80200. uniformBuffersNames: d,
  80201. samplers: h,
  80202. defines: p,
  80203. fallbacks: l,
  80204. onCompiled: this.onCompiled,
  80205. onError: this.onError,
  80206. indexParameters: {
  80207. maxSimultaneousLights: this._maxSimultaneousLights
  80208. }
  80209. }, o);
  80210. t.setEffect(f, r, this._materialContext),
  80211. this.buildUniformLayout()
  80212. }
  80213. return !(!t.effect || !t.effect.isReady() || (r._renderId = n.getRenderId(),
  80214. t.effect._wasPreviouslyReady = !0,
  80215. 0))
  80216. }
  80217. ,
  80218. t.prototype._computePrimaryColorFromPerceptualColor = function() {
  80219. this.__perceptualColor && (this._primaryColor.copyFrom(this.__perceptualColor),
  80220. this._primaryColor.toLinearSpaceToRef(this._primaryColor),
  80221. this._imageProcessingConfiguration && this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor),
  80222. this._computePrimaryColors())
  80223. }
  80224. ,
  80225. t.prototype._computePrimaryColors = function() {
  80226. 0 === this._primaryColorShadowLevel && 0 === this._primaryColorHighlightLevel || (this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor),
  80227. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor),
  80228. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor),
  80229. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor),
  80230. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor))
  80231. }
  80232. ,
  80233. t.prototype.buildUniformLayout = function() {
  80234. this._uniformBuffer.addUniform("vPrimaryColor", 4),
  80235. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4),
  80236. this._uniformBuffer.addUniform("vDiffuseInfos", 2),
  80237. this._uniformBuffer.addUniform("vReflectionInfos", 2),
  80238. this._uniformBuffer.addUniform("diffuseMatrix", 16),
  80239. this._uniformBuffer.addUniform("reflectionMatrix", 16),
  80240. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3),
  80241. this._uniformBuffer.addUniform("fFovMultiplier", 1),
  80242. this._uniformBuffer.addUniform("pointSize", 1),
  80243. this._uniformBuffer.addUniform("shadowLevel", 1),
  80244. this._uniformBuffer.addUniform("alpha", 1),
  80245. this._uniformBuffer.addUniform("vBackgroundCenter", 3),
  80246. this._uniformBuffer.addUniform("vReflectionControl", 4),
  80247. this._uniformBuffer.create()
  80248. }
  80249. ,
  80250. t.prototype.unbind = function() {
  80251. this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null),
  80252. this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null),
  80253. e.prototype.unbind.call(this)
  80254. }
  80255. ,
  80256. t.prototype.bindOnlyWorldMatrix = function(e) {
  80257. this._activeEffect.setMatrix("world", e)
  80258. }
  80259. ,
  80260. t.prototype.bindForSubMesh = function(e, t, i) {
  80261. var n = this.getScene()
  80262. , r = i.materialDefines;
  80263. if (r) {
  80264. var o = i.effect;
  80265. if (o) {
  80266. this._activeEffect = o,
  80267. this.bindOnlyWorldMatrix(e),
  80268. Mr.BindBonesParameters(t, this._activeEffect);
  80269. var a = this._mustRebind(n, o, t.visibility);
  80270. if (a) {
  80271. this._uniformBuffer.bindToEffect(o, "Material"),
  80272. this.bindViewProjection(o);
  80273. var s = this._reflectionTexture;
  80274. this._uniformBuffer.useUbo && this.isFrozen && this._uniformBuffer.isSync || (n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
  80275. Mr.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")),
  80276. s && vs.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", s.getReflectionTextureMatrix()),
  80277. this._uniformBuffer.updateFloat2("vReflectionInfos", s.level, this._reflectionBlur),
  80278. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", s.getSize().width, s.lodGenerationScale, s.lodGenerationOffset))),
  80279. this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel),
  80280. this._uniformBuffer.updateFloat("alpha", this.alpha),
  80281. this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize),
  80282. r.USEHIGHLIGHTANDSHADOWCOLORS ? (this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1),
  80283. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1)) : this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1)),
  80284. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier),
  80285. n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture),
  80286. s && vs.ReflectionTextureEnabled && (r.REFLECTIONBLUR && r.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", s) : r.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", s._lodTextureMid || s),
  80287. this._uniformBuffer.setTexture("reflectionSamplerLow", s._lodTextureLow || s),
  80288. this._uniformBuffer.setTexture("reflectionSamplerHigh", s._lodTextureHigh || s)) : this._uniformBuffer.setTexture("reflectionSampler", s),
  80289. r.REFLECTIONFRESNEL && (this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z),
  80290. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w)))),
  80291. Mr.BindClipPlane(this._activeEffect, n),
  80292. n.bindEyePosition(o)
  80293. } else
  80294. n.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(o, "Material"),
  80295. this._needToBindSceneUbo = !0);
  80296. !a && this.isFrozen || (n.lightsEnabled && Mr.BindLights(n, t, this._activeEffect, r, this._maxSimultaneousLights),
  80297. this.bindView(o),
  80298. Mr.BindFogParameters(n, t, this._activeEffect, !0),
  80299. this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)),
  80300. this._afterBind(t, this._activeEffect),
  80301. this._uniformBuffer.update()
  80302. }
  80303. }
  80304. }
  80305. ,
  80306. t.prototype.hasTexture = function(t) {
  80307. return !!e.prototype.hasTexture.call(this, t) || this._reflectionTexture === t || this._diffuseTexture === t
  80308. }
  80309. ,
  80310. t.prototype.dispose = function(t, i) {
  80311. void 0 === t && (t = !1),
  80312. void 0 === i && (i = !1),
  80313. i && (this.diffuseTexture && this.diffuseTexture.dispose(),
  80314. this.reflectionTexture && this.reflectionTexture.dispose()),
  80315. this._renderTargets.dispose(),
  80316. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  80317. e.prototype.dispose.call(this, t)
  80318. }
  80319. ,
  80320. t.prototype.clone = function(e) {
  80321. var i = this;
  80322. return Ge.Clone((function() {
  80323. return new t(e,i.getScene())
  80324. }
  80325. ), this)
  80326. }
  80327. ,
  80328. t.prototype.serialize = function() {
  80329. var e = Ge.Serialize(this);
  80330. return e.customType = "BABYLON.BackgroundMaterial",
  80331. e
  80332. }
  80333. ,
  80334. t.prototype.getClassName = function() {
  80335. return "BackgroundMaterial"
  80336. }
  80337. ,
  80338. t.Parse = function(e, i, n) {
  80339. return Ge.Parse((function() {
  80340. return new t(e.name,i)
  80341. }
  80342. ), e, i, n)
  80343. }
  80344. ,
  80345. t.StandardReflectance0 = .05,
  80346. t.StandardReflectance90 = .5,
  80347. k([Me()], t.prototype, "_primaryColor", void 0),
  80348. k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0),
  80349. k([Me()], t.prototype, "__perceptualColor", void 0),
  80350. k([Ce()], t.prototype, "_primaryColorShadowLevel", void 0),
  80351. k([Ce()], t.prototype, "_primaryColorHighlightLevel", void 0),
  80352. k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null),
  80353. k([Pe()], t.prototype, "_reflectionTexture", void 0),
  80354. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
  80355. k([Ce()], t.prototype, "_reflectionBlur", void 0),
  80356. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0),
  80357. k([Pe()], t.prototype, "_diffuseTexture", void 0),
  80358. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0),
  80359. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0),
  80360. k([Ce()], t.prototype, "_shadowLevel", void 0),
  80361. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0),
  80362. k([De()], t.prototype, "_sceneCenter", void 0),
  80363. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0),
  80364. k([Ce()], t.prototype, "_opacityFresnel", void 0),
  80365. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0),
  80366. k([Ce()], t.prototype, "_reflectionFresnel", void 0),
  80367. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0),
  80368. k([Ce()], t.prototype, "_reflectionFalloffDistance", void 0),
  80369. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0),
  80370. k([Ce()], t.prototype, "_reflectionAmount", void 0),
  80371. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0),
  80372. k([Ce()], t.prototype, "_reflectionReflectance0", void 0),
  80373. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0),
  80374. k([Ce()], t.prototype, "_reflectionReflectance90", void 0),
  80375. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0),
  80376. k([Ce()], t.prototype, "_useRGBColor", void 0),
  80377. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0),
  80378. k([Ce()], t.prototype, "_enableNoise", void 0),
  80379. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0),
  80380. k([Ce()], t.prototype, "_maxSimultaneousLights", void 0),
  80381. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0),
  80382. k([Ce()], t.prototype, "_shadowOnly", void 0),
  80383. k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0),
  80384. k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
  80385. t
  80386. }(gs);
  80387. y("BABYLON.BackgroundMaterial", Vd);
  80388. var kd = function() {
  80389. function e(t, i) {
  80390. var n = this;
  80391. this._errorHandler = function(e, t) {
  80392. n.onErrorObservable.notifyObservers({
  80393. message: e,
  80394. exception: t
  80395. })
  80396. }
  80397. ,
  80398. this._options = V(V({}, e._GetDefaultOptions()), t),
  80399. this._scene = i,
  80400. this.onErrorObservable = new h,
  80401. this._setupBackground(),
  80402. this._setupImageProcessing()
  80403. }
  80404. return e._GetDefaultOptions = function() {
  80405. return {
  80406. createGround: !0,
  80407. groundSize: 15,
  80408. groundTexture: this._GroundTextureCDNUrl,
  80409. groundColor: new D(.2,.2,.3).toLinearSpace().scale(3),
  80410. groundOpacity: .9,
  80411. enableGroundShadow: !0,
  80412. groundShadowLevel: .5,
  80413. enableGroundMirror: !1,
  80414. groundMirrorSizeRatio: .3,
  80415. groundMirrorBlurKernel: 64,
  80416. groundMirrorAmount: 1,
  80417. groundMirrorFresnelWeight: 1,
  80418. groundMirrorFallOffDistance: 0,
  80419. groundMirrorTextureType: a.TEXTURETYPE_UNSIGNED_INT,
  80420. groundYBias: 1e-5,
  80421. createSkybox: !0,
  80422. skyboxSize: 20,
  80423. skyboxTexture: this._SkyboxTextureCDNUrl,
  80424. skyboxColor: new D(.2,.2,.3).toLinearSpace().scale(3),
  80425. backgroundYRotation: 0,
  80426. sizeAuto: !0,
  80427. rootPosition: x.Zero(),
  80428. setupImageProcessing: !0,
  80429. environmentTexture: this._EnvironmentTextureCDNUrl,
  80430. cameraExposure: .8,
  80431. cameraContrast: 1.2,
  80432. toneMappingEnabled: !0
  80433. }
  80434. }
  80435. ,
  80436. Object.defineProperty(e.prototype, "rootMesh", {
  80437. get: function() {
  80438. return this._rootMesh
  80439. },
  80440. enumerable: !1,
  80441. configurable: !0
  80442. }),
  80443. Object.defineProperty(e.prototype, "skybox", {
  80444. get: function() {
  80445. return this._skybox
  80446. },
  80447. enumerable: !1,
  80448. configurable: !0
  80449. }),
  80450. Object.defineProperty(e.prototype, "skyboxTexture", {
  80451. get: function() {
  80452. return this._skyboxTexture
  80453. },
  80454. enumerable: !1,
  80455. configurable: !0
  80456. }),
  80457. Object.defineProperty(e.prototype, "skyboxMaterial", {
  80458. get: function() {
  80459. return this._skyboxMaterial
  80460. },
  80461. enumerable: !1,
  80462. configurable: !0
  80463. }),
  80464. Object.defineProperty(e.prototype, "ground", {
  80465. get: function() {
  80466. return this._ground
  80467. },
  80468. enumerable: !1,
  80469. configurable: !0
  80470. }),
  80471. Object.defineProperty(e.prototype, "groundTexture", {
  80472. get: function() {
  80473. return this._groundTexture
  80474. },
  80475. enumerable: !1,
  80476. configurable: !0
  80477. }),
  80478. Object.defineProperty(e.prototype, "groundMirror", {
  80479. get: function() {
  80480. return this._groundMirror
  80481. },
  80482. enumerable: !1,
  80483. configurable: !0
  80484. }),
  80485. Object.defineProperty(e.prototype, "groundMirrorRenderList", {
  80486. get: function() {
  80487. return this._groundMirror ? this._groundMirror.renderList : null
  80488. },
  80489. enumerable: !1,
  80490. configurable: !0
  80491. }),
  80492. Object.defineProperty(e.prototype, "groundMaterial", {
  80493. get: function() {
  80494. return this._groundMaterial
  80495. },
  80496. enumerable: !1,
  80497. configurable: !0
  80498. }),
  80499. e.prototype.updateOptions = function(e) {
  80500. var t = V(V({}, this._options), e);
  80501. this._ground && !t.createGround && (this._ground.dispose(),
  80502. this._ground = null),
  80503. this._groundMaterial && !t.createGround && (this._groundMaterial.dispose(),
  80504. this._groundMaterial = null),
  80505. this._groundTexture && this._options.groundTexture != t.groundTexture && (this._groundTexture.dispose(),
  80506. this._groundTexture = null),
  80507. this._skybox && !t.createSkybox && (this._skybox.dispose(),
  80508. this._skybox = null),
  80509. this._skyboxMaterial && !t.createSkybox && (this._skyboxMaterial.dispose(),
  80510. this._skyboxMaterial = null),
  80511. this._skyboxTexture && this._options.skyboxTexture != t.skyboxTexture && (this._skyboxTexture.dispose(),
  80512. this._skyboxTexture = null),
  80513. this._groundMirror && !t.enableGroundMirror && (this._groundMirror.dispose(),
  80514. this._groundMirror = null),
  80515. this._scene.environmentTexture && this._options.environmentTexture != t.environmentTexture && this._scene.environmentTexture.dispose(),
  80516. this._options = t,
  80517. this._setupBackground(),
  80518. this._setupImageProcessing()
  80519. }
  80520. ,
  80521. e.prototype.setMainColor = function(e) {
  80522. this.groundMaterial && (this.groundMaterial.primaryColor = e),
  80523. this.skyboxMaterial && (this.skyboxMaterial.primaryColor = e),
  80524. this.groundMirror && (this.groundMirror.clearColor = new N(e.r,e.g,e.b,1))
  80525. }
  80526. ,
  80527. e.prototype._setupImageProcessing = function() {
  80528. this._options.setupImageProcessing && (this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast,
  80529. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure,
  80530. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled,
  80531. this._setupEnvironmentTexture())
  80532. }
  80533. ,
  80534. e.prototype._setupEnvironmentTexture = function() {
  80535. if (!this._scene.environmentTexture)
  80536. if (this._options.environmentTexture instanceof Zr)
  80537. this._scene.environmentTexture = this._options.environmentTexture;
  80538. else {
  80539. var e = Bd.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  80540. this._scene.environmentTexture = e
  80541. }
  80542. }
  80543. ,
  80544. e.prototype._setupBackground = function() {
  80545. this._rootMesh || (this._rootMesh = new Vr("BackgroundHelper",this._scene)),
  80546. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  80547. var e = this._getSceneSize();
  80548. this._options.createGround && (this._setupGround(e),
  80549. this._setupGroundMaterial(),
  80550. this._setupGroundDiffuseTexture(),
  80551. this._options.enableGroundMirror && this._setupGroundMirrorTexture(e),
  80552. this._setupMirrorInGroundMaterial()),
  80553. this._options.createSkybox && (this._setupSkybox(e),
  80554. this._setupSkyboxMaterial(),
  80555. this._setupSkyboxReflectionTexture()),
  80556. this._rootMesh.position.x = e.rootPosition.x,
  80557. this._rootMesh.position.z = e.rootPosition.z,
  80558. this._rootMesh.position.y = e.rootPosition.y
  80559. }
  80560. ,
  80561. e.prototype._getSceneSize = function() {
  80562. var e = this
  80563. , t = this._options.groundSize
  80564. , i = this._options.skyboxSize
  80565. , n = this._options.rootPosition;
  80566. if (!this._scene.meshes || 1 === this._scene.meshes.length)
  80567. return {
  80568. groundSize: t,
  80569. skyboxSize: i,
  80570. rootPosition: n
  80571. };
  80572. var r = this._scene.getWorldExtends((function(t) {
  80573. return t !== e._ground && t !== e._rootMesh && t !== e._skybox
  80574. }
  80575. ))
  80576. , o = r.max.subtract(r.min);
  80577. if (this._options.sizeAuto) {
  80578. this._scene.activeCamera instanceof _a && this._scene.activeCamera.upperRadiusLimit && (i = t = 2 * this._scene.activeCamera.upperRadiusLimit);
  80579. var a = o.length();
  80580. a > t && (i = t = 2 * a),
  80581. t *= 1.1,
  80582. i *= 1.5,
  80583. (n = r.min.add(o.scale(.5))).y = r.min.y - this._options.groundYBias
  80584. }
  80585. return {
  80586. groundSize: t,
  80587. skyboxSize: i,
  80588. rootPosition: n
  80589. }
  80590. }
  80591. ,
  80592. e.prototype._setupGround = function(e) {
  80593. var t = this;
  80594. this._ground && !this._ground.isDisposed() || (this._ground = vo("BackgroundPlane", {
  80595. size: e.groundSize
  80596. }, this._scene),
  80597. this._ground.rotation.x = Math.PI / 2,
  80598. this._ground.parent = this._rootMesh,
  80599. this._ground.onDisposeObservable.add((function() {
  80600. t._ground = null
  80601. }
  80602. ))),
  80603. this._ground.receiveShadows = this._options.enableGroundShadow
  80604. }
  80605. ,
  80606. e.prototype._setupGroundMaterial = function() {
  80607. this._groundMaterial || (this._groundMaterial = new Vd("BackgroundPlaneMaterial",this._scene)),
  80608. this._groundMaterial.alpha = this._options.groundOpacity,
  80609. this._groundMaterial.alphaMode = a.ALPHA_PREMULTIPLIED_PORTERDUFF,
  80610. this._groundMaterial.shadowLevel = this._options.groundShadowLevel,
  80611. this._groundMaterial.primaryColor = this._options.groundColor,
  80612. this._groundMaterial.useRGBColor = !1,
  80613. this._groundMaterial.enableNoise = !0,
  80614. this._ground && (this._ground.material = this._groundMaterial)
  80615. }
  80616. ,
  80617. e.prototype._setupGroundDiffuseTexture = function() {
  80618. this._groundMaterial && (this._groundTexture || (this._options.groundTexture instanceof Zr ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new io(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
  80619. this._groundTexture.gammaSpace = !1,
  80620. this._groundTexture.hasAlpha = !0,
  80621. this._groundMaterial.diffuseTexture = this._groundTexture)))
  80622. }
  80623. ,
  80624. e.prototype._setupGroundMirrorTexture = function(e) {
  80625. var t = io.CLAMP_ADDRESSMODE;
  80626. if (!this._groundMirror && (this._groundMirror = new wd("BackgroundPlaneMirrorTexture",{
  80627. ratio: this._options.groundMirrorSizeRatio
  80628. },this._scene,!1,this._options.groundMirrorTextureType,io.BILINEAR_SAMPLINGMODE,!0),
  80629. this._groundMirror.mirrorPlane = new hn(0,-1,0,e.rootPosition.y),
  80630. this._groundMirror.anisotropicFilteringLevel = 1,
  80631. this._groundMirror.wrapU = t,
  80632. this._groundMirror.wrapV = t,
  80633. this._groundMirror.renderList))
  80634. for (var i = 0; i < this._scene.meshes.length; i++) {
  80635. var n = this._scene.meshes[i];
  80636. n !== this._ground && n !== this._skybox && n !== this._rootMesh && this._groundMirror.renderList.push(n)
  80637. }
  80638. var r = this._options.groundColor.toGammaSpace();
  80639. this._groundMirror.clearColor = new N(r.r,r.g,r.b,1),
  80640. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel
  80641. }
  80642. ,
  80643. e.prototype._setupMirrorInGroundMaterial = function() {
  80644. this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror,
  80645. this._groundMaterial.reflectionFresnel = !0,
  80646. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount,
  80647. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight,
  80648. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance)
  80649. }
  80650. ,
  80651. e.prototype._setupSkybox = function(e) {
  80652. var t = this;
  80653. this._skybox && !this._skybox.isDisposed() || (this._skybox = Ml("BackgroundSkybox", {
  80654. size: e.skyboxSize,
  80655. sideOrientation: Vr.BACKSIDE
  80656. }, this._scene),
  80657. this._skybox.onDisposeObservable.add((function() {
  80658. t._skybox = null
  80659. }
  80660. ))),
  80661. this._skybox.parent = this._rootMesh
  80662. }
  80663. ,
  80664. e.prototype._setupSkyboxMaterial = function() {
  80665. this._skybox && (this._skyboxMaterial || (this._skyboxMaterial = new Vd("BackgroundSkyboxMaterial",this._scene)),
  80666. this._skyboxMaterial.useRGBColor = !1,
  80667. this._skyboxMaterial.primaryColor = this._options.skyboxColor,
  80668. this._skyboxMaterial.enableNoise = !0,
  80669. this._skybox.material = this._skyboxMaterial)
  80670. }
  80671. ,
  80672. e.prototype._setupSkyboxReflectionTexture = function() {
  80673. this._skyboxMaterial && (this._skyboxTexture || (this._options.skyboxTexture instanceof Zr ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new Bd(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
  80674. this._skyboxTexture.coordinatesMode = io.SKYBOX_MODE,
  80675. this._skyboxTexture.gammaSpace = !1,
  80676. this._skyboxMaterial.reflectionTexture = this._skyboxTexture)))
  80677. }
  80678. ,
  80679. e.prototype.dispose = function() {
  80680. this._groundMaterial && this._groundMaterial.dispose(!0, !0),
  80681. this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0),
  80682. this._rootMesh.dispose(!1)
  80683. }
  80684. ,
  80685. e._GroundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png",
  80686. e._SkyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds",
  80687. e._EnvironmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env",
  80688. e
  80689. }()
  80690. , Gd = function(e) {
  80691. function t(i, n, r, o, a) {
  80692. void 0 === a && (a = null);
  80693. var s = e.call(this, i, o) || this;
  80694. s.onError = a,
  80695. s._halfDome = !1,
  80696. s._crossEye = !1,
  80697. s._useDirectMapping = !1,
  80698. s._textureMode = t.MODE_MONOSCOPIC,
  80699. s._onBeforeCameraRenderObserver = null,
  80700. s.onLoadErrorObservable = new h,
  80701. s.onLoadObservable = new h,
  80702. o = s.getScene(),
  80703. i = i || "textureDome",
  80704. r.resolution = 0 | Math.abs(r.resolution) || 32,
  80705. r.clickToPlay = Boolean(r.clickToPlay),
  80706. r.autoPlay = void 0 === r.autoPlay || Boolean(r.autoPlay),
  80707. r.loop = void 0 === r.loop || Boolean(r.loop),
  80708. r.size = Math.abs(r.size) || (o.activeCamera ? .48 * o.activeCamera.maxZ : 1e3),
  80709. void 0 === r.useDirectMapping ? s._useDirectMapping = !0 : s._useDirectMapping = r.useDirectMapping,
  80710. void 0 === r.faceForward && (r.faceForward = !0),
  80711. s._setReady(!1),
  80712. r.mesh ? s._mesh = r.mesh : s._mesh = Dl(i + "_mesh", {
  80713. segments: r.resolution,
  80714. diameter: r.size,
  80715. updatable: !1,
  80716. sideOrientation: Vr.BACKSIDE
  80717. }, o);
  80718. var l = s._material = new Vd(i + "_material",o);
  80719. l.useEquirectangularFOV = !0,
  80720. l.fovMultiplier = 1,
  80721. l.opacityFresnel = !1;
  80722. var c = s._initTexture(n, o, r);
  80723. if (s.texture = c,
  80724. s._mesh.material = l,
  80725. s._mesh.parent = s,
  80726. s._halfDomeMask = Dl("", {
  80727. slice: .5,
  80728. diameter: .98 * r.size,
  80729. segments: 2 * r.resolution,
  80730. sideOrientation: Vr.BACKSIDE
  80731. }, o),
  80732. s._halfDomeMask.rotate(vn.X, -Math.PI / 2),
  80733. s._halfDomeMask.parent = s._mesh,
  80734. s._halfDome = !!r.halfDomeMode,
  80735. s._halfDomeMask.setEnabled(s._halfDome),
  80736. s._crossEye = !!r.crossEyeMode,
  80737. s._texture.anisotropicFilteringLevel = 1,
  80738. s._texture.onLoadObservable.addOnce((function() {
  80739. s._setReady(!0)
  80740. }
  80741. )),
  80742. r.faceForward && o.activeCamera) {
  80743. var u = o.activeCamera
  80744. , d = x.Forward()
  80745. , p = x.TransformNormal(d, u.getViewMatrix());
  80746. p.normalize(),
  80747. s.rotation.y = Math.acos(x.Dot(d, p))
  80748. }
  80749. return s._changeTextureMode(s._textureMode),
  80750. s
  80751. }
  80752. return U(t, e),
  80753. Object.defineProperty(t.prototype, "texture", {
  80754. get: function() {
  80755. return this._texture
  80756. },
  80757. set: function(e) {
  80758. this._texture !== e && (this._texture = e,
  80759. this._useDirectMapping ? (this._texture.wrapU = io.CLAMP_ADDRESSMODE,
  80760. this._texture.wrapV = io.CLAMP_ADDRESSMODE,
  80761. this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
  80762. this._texture.wrapV = io.CLAMP_ADDRESSMODE,
  80763. this._material.reflectionTexture = this._texture),
  80764. this._changeTextureMode(this._textureMode))
  80765. },
  80766. enumerable: !1,
  80767. configurable: !0
  80768. }),
  80769. Object.defineProperty(t.prototype, "mesh", {
  80770. get: function() {
  80771. return this._mesh
  80772. },
  80773. enumerable: !1,
  80774. configurable: !0
  80775. }),
  80776. Object.defineProperty(t.prototype, "fovMultiplier", {
  80777. get: function() {
  80778. return this._material.fovMultiplier
  80779. },
  80780. set: function(e) {
  80781. this._material.fovMultiplier = e
  80782. },
  80783. enumerable: !1,
  80784. configurable: !0
  80785. }),
  80786. Object.defineProperty(t.prototype, "textureMode", {
  80787. get: function() {
  80788. return this._textureMode
  80789. },
  80790. set: function(e) {
  80791. this._textureMode !== e && this._changeTextureMode(e)
  80792. },
  80793. enumerable: !1,
  80794. configurable: !0
  80795. }),
  80796. Object.defineProperty(t.prototype, "halfDome", {
  80797. get: function() {
  80798. return this._halfDome
  80799. },
  80800. set: function(e) {
  80801. this._halfDome = e,
  80802. this._halfDomeMask.setEnabled(e),
  80803. this._changeTextureMode(this._textureMode)
  80804. },
  80805. enumerable: !1,
  80806. configurable: !0
  80807. }),
  80808. Object.defineProperty(t.prototype, "crossEye", {
  80809. get: function() {
  80810. return this._crossEye
  80811. },
  80812. set: function(e) {
  80813. this._crossEye = e,
  80814. this._changeTextureMode(this._textureMode)
  80815. },
  80816. enumerable: !1,
  80817. configurable: !0
  80818. }),
  80819. Object.defineProperty(t.prototype, "material", {
  80820. get: function() {
  80821. return this._material
  80822. },
  80823. enumerable: !1,
  80824. configurable: !0
  80825. }),
  80826. t.prototype._changeTextureMode = function(e) {
  80827. var i = this;
  80828. switch (this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  80829. this._textureMode = e,
  80830. this._texture.uScale = 1,
  80831. this._texture.vScale = 1,
  80832. this._texture.uOffset = 0,
  80833. this._texture.vOffset = 0,
  80834. this._texture.vAng = 0,
  80835. e) {
  80836. case t.MODE_MONOSCOPIC:
  80837. this._halfDome && (this._texture.uScale = 2,
  80838. this._texture.uOffset = -1);
  80839. break;
  80840. case t.MODE_SIDEBYSIDE:
  80841. this._texture.uScale = this._halfDome ? .99999 : .5;
  80842. var n = this._halfDome ? 0 : .5
  80843. , r = this._halfDome ? -.5 : 0;
  80844. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function(e) {
  80845. var t = e.isRightCamera;
  80846. i._crossEye && (t = !t),
  80847. i._texture.uOffset = t ? n : r
  80848. }
  80849. ));
  80850. break;
  80851. case t.MODE_TOPBOTTOM:
  80852. this._texture.vScale = this._halfDome ? .99999 : .5,
  80853. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function(e) {
  80854. var t = e.isRightCamera;
  80855. i._crossEye && (t = !t),
  80856. i._texture.vOffset = t ? .5 : 0
  80857. }
  80858. ))
  80859. }
  80860. }
  80861. ,
  80862. t.prototype.dispose = function(t, i) {
  80863. void 0 === i && (i = !1),
  80864. this._texture.dispose(),
  80865. this._mesh.dispose(),
  80866. this._material.dispose(),
  80867. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  80868. this.onLoadErrorObservable.clear(),
  80869. this.onLoadObservable.clear(),
  80870. e.prototype.dispose.call(this, t, i)
  80871. }
  80872. ,
  80873. t.MODE_MONOSCOPIC = 0,
  80874. t.MODE_TOPBOTTOM = 1,
  80875. t.MODE_SIDEBYSIDE = 2,
  80876. t
  80877. }(yr)
  80878. , zd = function(e) {
  80879. function t() {
  80880. return null !== e && e.apply(this, arguments) || this
  80881. }
  80882. return U(t, e),
  80883. Object.defineProperty(t.prototype, "photoTexture", {
  80884. get: function() {
  80885. return this.texture
  80886. },
  80887. set: function(e) {
  80888. this.texture = e
  80889. },
  80890. enumerable: !1,
  80891. configurable: !0
  80892. }),
  80893. Object.defineProperty(t.prototype, "imageMode", {
  80894. get: function() {
  80895. return this.textureMode
  80896. },
  80897. set: function(e) {
  80898. this.textureMode = e
  80899. },
  80900. enumerable: !1,
  80901. configurable: !0
  80902. }),
  80903. t.prototype._initTexture = function(e, t, i) {
  80904. var n = this;
  80905. return new io(e,t,!i.generateMipMaps,!this._useDirectMapping,void 0,(function() {
  80906. n.onLoadObservable.notifyObservers()
  80907. }
  80908. ),(function(e, t) {
  80909. n.onLoadErrorObservable.notifyObservers(e || "Unknown error occured"),
  80910. n.onError && n.onError(e, t)
  80911. }
  80912. ))
  80913. }
  80914. ,
  80915. t.MODE_MONOSCOPIC = Gd.MODE_MONOSCOPIC,
  80916. t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
  80917. t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
  80918. t
  80919. }(Gd)
  80920. , Wd = 0
  80921. , Hd = function(e) {
  80922. if (!e.environmentBRDFTexture) {
  80923. var t = e.useDelayedTextureLoading;
  80924. e.useDelayedTextureLoading = !1;
  80925. var i = e._blockEntityCollection;
  80926. e._blockEntityCollection = !1;
  80927. var n = io.CreateFromBase64String("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==", "EnvironmentBRDFTexture" + Wd++, e, !0, !1, io.BILINEAR_SAMPLINGMODE);
  80928. e._blockEntityCollection = i;
  80929. var r = e.getEngine().getLoadedTexturesCache()
  80930. , o = r.indexOf(n.getInternalTexture());
  80931. -1 !== o && r.splice(o, 1),
  80932. n.isRGBD = !0,
  80933. n.wrapU = io.CLAMP_ADDRESSMODE,
  80934. n.wrapV = io.CLAMP_ADDRESSMODE,
  80935. e.environmentBRDFTexture = n,
  80936. e.useDelayedTextureLoading = t,
  80937. Lc.ExpandRGBDTexture(n);
  80938. var a = e.getEngine().onContextRestoredObservable.add((function() {
  80939. n.isRGBD = !0;
  80940. var e = function() {
  80941. n.isReady() ? Lc.ExpandRGBDTexture(n) : gi.SetImmediate(e)
  80942. };
  80943. e()
  80944. }
  80945. ));
  80946. e.onDisposeObservable.add((function() {
  80947. e.getEngine().onContextRestoredObservable.remove(a)
  80948. }
  80949. ))
  80950. }
  80951. return e.environmentBRDFTexture
  80952. }
  80953. , Xd = {
  80954. GetEnvironmentBRDFTexture: Hd
  80955. }
  80956. , jd = function(e) {
  80957. function t() {
  80958. var t = null !== e && e.apply(this, arguments) || this;
  80959. return t.BRDF_V_HEIGHT_CORRELATED = !1,
  80960. t.MS_BRDF_ENERGY_CONSERVATION = !1,
  80961. t.SPHERICAL_HARMONICS = !1,
  80962. t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1,
  80963. t
  80964. }
  80965. return U(t, e),
  80966. t
  80967. }(Si)
  80968. , Yd = function(e) {
  80969. function t(i, n) {
  80970. void 0 === n && (n = !0);
  80971. var r = e.call(this, i, "PBRBRDF", 90, new jd, n) || this;
  80972. return r._useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
  80973. r.useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
  80974. r._useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
  80975. r.useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
  80976. r._useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
  80977. r.useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
  80978. r._useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
  80979. r.useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
  80980. r._internalMarkAllSubMeshesAsMiscDirty = i._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag],
  80981. r._enable(!0),
  80982. r
  80983. }
  80984. return U(t, e),
  80985. t.prototype._markAllSubMeshesAsMiscDirty = function() {
  80986. this._internalMarkAllSubMeshesAsMiscDirty()
  80987. }
  80988. ,
  80989. t.prototype.prepareDefines = function(e) {
  80990. e.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated,
  80991. e.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated,
  80992. e.SPHERICAL_HARMONICS = this._useSphericalHarmonics,
  80993. e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation
  80994. }
  80995. ,
  80996. t.prototype.getClassName = function() {
  80997. return "PBRBRDFConfiguration"
  80998. }
  80999. ,
  81000. t.DEFAULT_USE_ENERGY_CONSERVATION = !0,
  81001. t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0,
  81002. t.DEFAULT_USE_SPHERICAL_HARMONICS = !0,
  81003. t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0,
  81004. k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useEnergyConservation", void 0),
  81005. k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSmithVisibilityHeightCorrelated", void 0),
  81006. k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSphericalHarmonics", void 0),
  81007. k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
  81008. t
  81009. }(Rs);
  81010. Pt.IncludesShadersStore.pbrFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec4 vMetallicReflectanceFactors;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec3 vAmbientColor;\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_ROUGHNESS\nuniform float vSheenRoughness;\n#endif\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;\nuniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;\nuniform mat4 translucencyIntensityMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif\n#ifdef PREPASS\n#ifdef SS_SCATTERING\nuniform float scatteringDiffusionProfile;\n#endif\n#endif\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
  81011. Pt.IncludesShadersStore.pbrUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material {\nvec2 vAlbedoInfos;\nvec4 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec3 vReflectivityInfos;\nvec2 vMicroSurfaceSamplerInfos;\nvec2 vReflectionInfos;\nvec2 vReflectionFilteringInfo;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec3 vBumpInfos;\nmat4 albedoMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 reflectivityMatrix;\nmat4 microSurfaceSamplerMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 reflectionMatrix;\nvec3 vReflectionColor;\nvec4 vAlbedoColor;\nvec4 vLightingIntensity;\nvec3 vReflectionMicrosurfaceInfos;\nfloat pointSize;\nvec4 vReflectivityColor;\nvec3 vEmissiveColor;\nvec3 vAmbientColor;\nvec2 vDebugMode;\nvec4 vMetallicReflectanceFactors;\nvec2 vMetallicReflectanceInfos;\nmat4 metallicReflectanceMatrix;\nvec2 vReflectanceInfos;\nmat4 reflectanceMatrix;\nvec3 vSphericalL00;\nvec3 vSphericalL1_1;\nvec3 vSphericalL10;\nvec3 vSphericalL11;\nvec3 vSphericalL2_2;\nvec3 vSphericalL2_1;\nvec3 vSphericalL20;\nvec3 vSphericalL21;\nvec3 vSphericalL22;\nvec3 vSphericalX;\nvec3 vSphericalY;\nvec3 vSphericalZ;\nvec3 vSphericalXX_ZZ;\nvec3 vSphericalYY_ZZ;\nvec3 vSphericalZZ;\nvec3 vSphericalXY;\nvec3 vSphericalYZ;\nvec3 vSphericalZX;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
  81012. Pt.IncludesShadersStore.pbrFragmentExtraDeclaration = "varying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n";
  81013. Pt.IncludesShadersStore.samplerFragmentAlternateDeclaration = "#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV==1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV==2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV==3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV==4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV==5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV==6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n#endif\n";
  81014. Pt.IncludesShadersStore.pbrFragmentSamplersDeclaration = "#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)\n#ifdef CLEARCOAT\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)\n#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\n#endif\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)\n#endif\n#ifdef SHEEN\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)\n#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D sheenRoughnessSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D refractionSamplerLow;\nuniform sampler2D refractionSamplerHigh;\n#endif\n#endif\n#endif\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)\n#endif\n";
  81015. Pt.IncludesShadersStore.subSurfaceScatteringFunctions = "bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";
  81016. Pt.IncludesShadersStore.importanceSampling = "vec3 hemisphereCosSample(vec2 u) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=1.-u.y;\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { \nfloat phi=2.*PI*u.x;\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}";
  81017. Pt.IncludesShadersStore.pbrHelperFunctions = "#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif\n";
  81018. Pt.IncludesShadersStore.harmonicsFunctions = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+ vSphericalL1_1*(normal.y)\n+ vSphericalL10*(normal.z)\n+ vSphericalL11*(normal.x)\n+ vSphericalL2_2*(normal.y*normal.x)\n+ vSphericalL2_1*(normal.y*normal.z)\n+ vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+ vSphericalL21*(normal.z*normal.x)\n+ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz *Nz+C1;\nvec3 t2=a2 *Ny+t1;\nvec3 t3=b3 *Nx+t2;\nreturn t3;\n}\n#endif\n#endif\n";
  81019. Pt.IncludesShadersStore.pbrDirectLightingSetupFunctions = "struct preLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\nfloat attenuation;\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nresult.lightDistance=sqrt(result.lightDistanceSquared);\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightDistance=length(-lightData.xyz);\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  81020. Pt.IncludesShadersStore.pbrDirectLightingFalloffFunctions = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  81021. Pt.IncludesShadersStore.pbrBRDFFunctions = "#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\nvec2 UV=vec2(NdotV,perceptualRoughness);\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\n#endif\nreturn reflectance;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n/* NOT USED\n#if defined(SHEEN) && defined(SHEEN_SOFTER)\nfloat getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)\n{\nfloat c=1.0-NdotV;\nfloat c3=c*c*c;\nreturn 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));\n}\n#endif\n*/\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\n/**\n* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.\n* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table\n*/\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\nreturn 0.25/(VdotH*VdotH); \n}\n#endif\n#ifdef SHEEN\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n/* NOT USED\n#ifdef SHEEN_SOFTER\nfloat l(float x,float alphaG)\n{\nfloat oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);\nfloat a=mix(21.5473,25.3245,oneMinusAlphaSq);\nfloat b=mix(3.82987,3.32435,oneMinusAlphaSq);\nfloat c=mix(0.19823,0.16801,oneMinusAlphaSq);\nfloat d=mix(-1.97760,-1.27393,oneMinusAlphaSq);\nfloat e=mix(-4.32054,-4.85967,oneMinusAlphaSq);\nreturn a/(1.0+b*pow(x,c))+d*x+e;\n}\nfloat lambdaSheen(float cosTheta,float alphaG)\n{\nreturn abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));\n}\nfloat visibility_CharlieSheen(float NdotL,float NdotV,float alphaG)\n{\nfloat G=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));\nreturn G/(4.0*NdotV*NdotL);\n}\n#endif\n*/\n#endif\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";
  81022. Pt.IncludesShadersStore.hdrFilteringFunctions = "#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU)\nfloat radicalInverse_VdC(uint bits) \n{\nbits=(bits<<16u) | (bits>>16u);\nbits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);\nbits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);\nbits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);\nbits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);\nreturn float(bits)*2.3283064365386963e-10; \n}\nvec2 hammersley(uint i,uint N)\n{\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\n}\n#else\nfloat vanDerCorpus(int n,int base)\n{\nfloat invBase=1.0/float(base);\nfloat denom =1.0;\nfloat result =0.0;\nfor(int i=0; i<32; ++i)\n{\nif(n>0)\n{\ndenom =mod(float(n),2.0);\nresult+=denom*invBase;\ninvBase=invBase/2.0;\nn =int(float(n)/2.0);\n}\n}\nreturn result;\n}\nvec2 hammersley(int i,int N)\n{\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\n}\n#endif\nfloat log4(float x) {\nreturn log2(x)/2.;\n}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\nconst float K=4.;\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nvec3 result=vec3(0.0);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 Ls=hemisphereCosSample(Xi);\nLs=normalize(Ls);\nvec3 Ns=vec3(0.,0.,1.);\nfloat NoL=dot(Ns,Ls);\nif (NoL>0.) {\nfloat pdf_inversed=PI/NoL;\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(l,0.0,maxLevel);\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c;\n}\n}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\nreturn result;\n}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nif (alphaG==0.) {\nvec3 c=textureCube(inputTexture,n).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;\n} else {\nvec3 result=vec3(0.);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\nfloat weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);\nfloat NoV=1.;\nfloat NoH=H.z;\nfloat NoH2=H.z*H.z;\nfloat NoL=2.*NoH2-1.;\nvec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);\nL=normalize(L);\nif (NoL>0.) {\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\nweight+=NoL;\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;\n}\n}\nresult=result/weight;\nreturn result;\n}\n}\n#endif\n#endif\n";
  81023. Pt.IncludesShadersStore.pbrDirectLightingFunctions = "#define CLEARCOATREFLECTANCE90 1.0\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\nfloat lightRoughness=lightRadius/lightDistance;\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\n/*#ifdef SHEEN_SOFTER\nfloat visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);\n#else */\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\n/* #endif */\nfloat sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  81024. Pt.IncludesShadersStore.pbrIBLFunctions = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\nreturn square(temp);\n}\n#endif\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif\n";
  81025. Pt.IncludesShadersStore.pbrBlockAlbedoOpacity = "struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nin vec4 vAlbedoColor,\n#ifdef ALBEDO\nin vec4 albedoTexture,\nin vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nin vec4 opacityMap,\nin vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin vec4 vDetailInfos,\n#endif\nout albedoOpacityOutParams outParams\n)\n{\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\n#ifdef GAMMAALBEDO\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\n#else\nsurfaceAlbedo*=albedoTexture.rgb;\n#endif\nsurfaceAlbedo*=albedoInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#ifdef DETAIL\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; \n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n#ifdef OPACITY\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\n#endif\noutParams.surfaceAlbedo=surfaceAlbedo;\noutParams.alpha=alpha;\n}\n";
  81026. Pt.IncludesShadersStore.pbrBlockReflectivity = "struct reflectivityOutParams\n{\nfloat microSurface;\nfloat roughness;\nvec3 surfaceReflectivityColor;\n#ifdef METALLICWORKFLOW\nvec3 surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nvec3 ambientOcclusionColor;\n#endif\n#if DEBUGMODE>0\nvec4 surfaceMetallicColorMap;\nvec4 surfaceReflectivityColorMap;\nvec2 metallicRoughness;\nvec3 metallicF0;\n#endif\n};\n#define pbr_inline\nvoid reflectivityBlock(\nin vec4 vReflectivityColor,\n#ifdef METALLICWORKFLOW\nin vec3 surfaceAlbedo,\nin vec4 metallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nin vec3 reflectivityInfos,\nin vec4 surfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nin vec3 ambientOcclusionColorIn,\n#endif\n#ifdef MICROSURFACEMAP\nin vec4 microSurfaceTexel,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin vec4 vDetailInfos,\n#endif\nout reflectivityOutParams outParams\n)\n{\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\n#if DEBUGMODE>0\noutParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);\noutParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;\n#endif\n#endif\n#endif\n#ifdef DETAIL\nfloat detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);\nfloat loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);\nfloat hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);\nmetallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));\n#endif\n#ifdef MICROSURFACEMAP\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n#if DEBUGMODE>0\noutParams.metallicRoughness=metallicRoughness;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\nmicroSurface=1.0-metallicRoughness.g;\nvec3 baseColor=surfaceAlbedo;\n#ifdef FROSTBITE_REFLECTANCE\noutParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\nvec3 metallicF0=metallicReflectanceFactors.rgb;\n#if DEBUGMODE>0\noutParams.metallicF0=metallicF0;\n#endif\noutParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);\nsurfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nsurfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;\n#if DEBUGMODE>0\noutParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceMetallicOrReflectivityColorMap.a;\nmicroSurface*=reflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\n#endif\n#endif\n#endif\nmicroSurface=saturate(microSurface);\nfloat roughness=1.-microSurface;\noutParams.microSurface=microSurface;\noutParams.roughness=roughness;\noutParams.surfaceReflectivityColor=surfaceReflectivityColor;\n}\n";
  81027. Pt.IncludesShadersStore.pbrBlockAmbientOcclusion = "struct ambientOcclusionOutParams\n{\nvec3 ambientOcclusionColor;\n#if DEBUGMODE>0\nvec3 ambientOcclusionColorMap;\n#endif\n};\n#define pbr_inline\nvoid ambientOcclusionBlock(\n#ifdef AMBIENT\nin vec3 ambientOcclusionColorMap_,\nin vec4 vAmbientInfos,\n#endif\nout ambientOcclusionOutParams outParams\n)\n{\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#if DEBUGMODE>0\noutParams.ambientOcclusionColorMap=ambientOcclusionColorMap;\n#endif\n#endif\noutParams.ambientOcclusionColor=ambientOcclusionColor;\n}\n";
  81028. Pt.IncludesShadersStore.pbrBlockAlphaFresnel = "#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nstruct alphaFresnelOutParams\n{\nfloat alpha;\n};\n#define pbr_inline\nvoid alphaFresnelBlock(\nin vec3 normalW,\nin vec3 viewDirectionW,\nin float alpha,\nin float microSurface,\nout alphaFresnelOutParams outParams\n)\n{\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\noutParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (outParams.alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\noutParams.alpha=1.0;\n#endif\n#endif\n}\n#endif\n#endif\n";
  81029. Pt.IncludesShadersStore.pbrBlockAnisotropic = "#ifdef ANISOTROPIC\nstruct anisotropicOutParams\n{\nfloat anisotropy;\nvec3 anisotropicTangent;\nvec3 anisotropicBitangent;\nvec3 anisotropicNormal;\n#if DEBUGMODE>0\nvec3 anisotropyMapData;\n#endif\n};\n#define pbr_inline\nvoid anisotropicBlock(\nin vec3 vAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nin vec3 anisotropyMapData,\n#endif\nin mat3 TBN,\nin vec3 normalW,\nin vec3 viewDirectionW,\nout anisotropicOutParams outParams\n)\n{\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#if DEBUGMODE>0\noutParams.anisotropyMapData=anisotropyMapData;\n#endif\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\noutParams.anisotropy=anisotropy;\noutParams.anisotropicTangent=anisotropicTangent;\noutParams.anisotropicBitangent=anisotropicBitangent;\noutParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n}\n#endif\n";
  81030. Pt.IncludesShadersStore.pbrBlockReflection = "#ifdef REFLECTION\nstruct reflectionOutParams\n{\nvec4 environmentRadiance;\nvec3 environmentIrradiance;\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords;\n#else\nvec2 reflectionCoords;\n#endif\n#ifdef SS_TRANSLUCENCY\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nvec3 irradianceVector;\n#endif\n#endif\n#endif\n};\n#define pbr_inline\nvoid createReflectionCoords(\nin vec3 vPositionW,\nin vec3 normalW,\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REFLECTIONMAP_3D\nout vec3 reflectionCoords\n#else\nout vec2 reflectionCoords\n#endif\n)\n{\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionCoords=reflectionVector;\n#else\nreflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n}\n#define pbr_inline\n#define inline\nvoid sampleReflectionTexture(\nin float alphaG,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nin float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nin float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\nconst vec3 reflectionCoords,\n#else\nin sampler2D reflectionSampler,\nconst vec2 reflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\nout vec4 environmentRadiance\n)\n{\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);\nif (lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nenvironmentRadiance=mix(\nenvironmentMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\n}\n#define pbr_inline\n#define inline\nvoid reflectionBlock(\nin vec3 vPositionW,\nin vec3 normalW,\nin float alphaG,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nin float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nin float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\n#else\nin sampler2D reflectionSampler,\n#endif\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nin vec3 vEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nin mat4 reflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nin samplerCube irradianceSampler,\n#else\nin sampler2D irradianceSampler,\n#endif\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\nout reflectionOutParams outParams\n)\n{\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.);\n#else\nvec2 reflectionCoords=vec2(0.);\n#endif\ncreateReflectionCoords(\nvPositionW,\nnormalW,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\nreflectionCoords\n);\nsampleReflectionTexture(\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionSampler,\nreflectionCoords,\n#else\nreflectionSampler,\nreflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentRadiance\n);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#ifdef SS_TRANSLUCENCY\noutParams.irradianceVector=irradianceVector;\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\nvec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);\nenvironmentIrradiance=environmentIrradiance4.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance4);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\nenvironmentIrradiance*=vReflectionColor.rgb;\noutParams.environmentRadiance=environmentRadiance;\noutParams.environmentIrradiance=environmentIrradiance;\noutParams.reflectionCoords=reflectionCoords;\n}\n#endif\n";
  81031. Pt.IncludesShadersStore.pbrBlockSheen = "#ifdef SHEEN\nstruct sheenOutParams\n{\nfloat sheenIntensity;\nvec3 sheenColor;\nfloat sheenRoughness;\n#ifdef SHEEN_LINKWITHALBEDO\nvec3 surfaceAlbedo;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfloat sheenAlbedoScaling;\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nvec3 finalSheenRadianceScaled;\n#endif\n#if DEBUGMODE>0\nvec4 sheenMapData;\nvec3 sheenEnvironmentReflectance;\n#endif\n};\n#define pbr_inline\n#define inline\nvoid sheenBlock(\nin vec4 vSheenColor,\n#ifdef SHEEN_ROUGHNESS\nin float vSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nin vec4 sheenMapRoughnessData,\n#endif\n#endif\nin float roughness,\n#ifdef SHEEN_TEXTURE\nin vec4 sheenMapData,\nin float sheenMapLevel,\n#endif\nin float reflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nin vec3 baseColor,\nin vec3 surfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nin float NdotV,\nin vec3 environmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nin vec2 AARoughnessFactors,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\nin vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\nin vec3 reflectionCoords,\n#else\nin sampler2D reflectionSampler,\nin vec2 reflectionCoords,\n#endif\nin float NdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nin float seo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nin float eho,\n#endif\n#endif\nout sheenOutParams outParams\n)\n{\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\n#if DEBUGMODE>0\noutParams.sheenMapData=sheenMapData;\n#endif\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\noutParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\n#ifdef SHEEN_GAMMATEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#else\nsheenColor.rgb*=sheenMapData.rgb;\n#endif\nsheenColor.rgb*=sheenMapLevel;\n#endif\n#ifdef SHEEN_ROUGHNESS\nfloat sheenRoughness=vSheenRoughness;\n#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE\n#if defined(SHEEN_TEXTURE)\nsheenRoughness*=sheenMapData.a;\n#endif\n#elif defined(SHEEN_TEXTURE_ROUGHNESS)\n#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL\nsheenRoughness*=sheenMapData.a;\n#else\nsheenRoughness*=sheenMapRoughnessData.a;\n#endif\n#endif\n#else\nfloat sheenRoughness=roughness;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#endif\n#if !defined(SHEEN_ALBEDOSCALING)\nsheenIntensity*=(1.-reflectance);\n#endif\nsheenColor*=sheenIntensity;\n#endif\n#ifdef ENVIRONMENTBRDF\n/*#ifdef SHEEN_SOFTER\nvec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));\n#else*/\n#ifdef SHEEN_ROUGHNESS\nvec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);\n#else\nvec3 environmentSheenBrdf=environmentBrdf;\n#endif\n/*#endif*/\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\nsampleReflectionTexture(\nsheenAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nsheenRoughness,\n#endif\nreflectionSampler,\nreflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentSheenRadiance\n);\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nsheenEnvironmentReflectance*=seo;\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nsheenEnvironmentReflectance*=eho;\n#endif\n#if DEBUGMODE>0\noutParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;\n#endif\noutParams.finalSheenRadianceScaled=\nenvironmentSheenRadiance.rgb *\nsheenEnvironmentReflectance *\nvLightingIntensity.z;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\noutParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;\n#endif\noutParams.sheenIntensity=sheenIntensity;\noutParams.sheenColor=sheenColor;\noutParams.sheenRoughness=sheenRoughness;\n}\n#endif\n";
  81032. Pt.IncludesShadersStore.pbrBlockClearcoat = "struct clearcoatOutParams\n{\nvec3 specularEnvironmentR0;\nfloat conservationFactor;\nvec3 clearCoatNormalW;\nvec2 clearCoatAARoughnessFactors;\nfloat clearCoatIntensity;\nfloat clearCoatRoughness;\n#ifdef REFLECTION\nvec3 finalClearCoatRadianceScaled;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 absorption;\nfloat clearCoatNdotVRefract;\nvec3 clearCoatColor;\nfloat clearCoatThickness;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nvec3 energyConservationFactorClearCoat;\n#endif\n#if DEBUGMODE>0\nmat3 TBNClearCoat;\nvec2 clearCoatMapData;\nvec4 clearCoatTintMapData;\nvec4 environmentClearCoatRadiance;\nfloat clearCoatNdotV;\nvec3 clearCoatEnvironmentReflectance;\n#endif\n};\n#ifdef CLEARCOAT\n#define pbr_inline\n#define inline\nvoid clearcoatBlock(\nin vec3 vPositionW,\nin vec3 geometricNormalW,\nin vec3 viewDirectionW,\nin vec2 vClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nin vec4 clearCoatMapRoughnessData,\n#endif\nin vec3 specularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nin vec2 clearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nin vec4 vClearCoatTintParams,\nin float clearCoatColorAtDistance,\nin vec4 vClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nin vec4 clearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nin vec2 vClearCoatBumpInfos,\nin vec4 clearCoatBumpMapData,\nin vec2 vClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nin mat3 vTBN,\n#else\nin vec2 vClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nin mat4 normalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nin vec3 faceNormal,\n#endif\n#ifdef REFLECTION\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\nin vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\n#else\nin sampler2D reflectionSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nin float ambientMonochrome,\n#endif\n#endif\n#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\nin float frontFacingMultiplier,\n#endif\nout clearcoatOutParams outParams\n)\n{\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nclearCoatIntensity*=clearCoatMapData.x;\n#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#if DEBUGMODE>0\noutParams.clearCoatMapData=clearCoatMapData;\n#endif\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL\nclearCoatRoughness*=clearCoatMapData.y;\n#else\nclearCoatRoughness*=clearCoatMapRoughnessData.y;\n#endif\n#endif\noutParams.clearCoatIntensity=clearCoatIntensity;\noutParams.clearCoatRoughness=clearCoatRoughness;\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\n#ifdef CLEARCOAT_TINT_GAMMATEXTURE\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\n#else\nclearCoatColor*=clearCoatTintMapData.rgb;\n#endif\nclearCoatThickness*=clearCoatTintMapData.a;\n#if DEBUGMODE>0\noutParams.clearCoatTintMapData=clearCoatTintMapData;\n#endif\n#endif\noutParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\noutParams.clearCoatThickness=clearCoatThickness;\n#endif\n#ifdef CLEARCOAT_REMAP_F0\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\n#else\nvec3 specularEnvironmentR0Updated=specularEnvironmentR0;\n#endif\noutParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\nvec3 clearCoatNormalW=geometricNormalW;\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nvec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);\n#endif\n#if DEBUGMODE>0\noutParams.TBNClearCoat=TBNClearCoat;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;\n#endif\noutParams.clearCoatNormalW=clearCoatNormalW;\noutParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n#if DEBUGMODE>0\noutParams.clearCoatNdotV=clearCoatNdotV;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\noutParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\n#endif\n#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);\n#endif\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\nclearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\nsampleReflectionTexture(\nclearCoatAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nclearCoatNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nclearCoatRoughness,\n#endif\nreflectionSampler,\nclearCoatReflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentClearCoatRadiance\n);\n#if DEBUGMODE>0\noutParams.environmentClearCoatRadiance=environmentClearCoatRadiance;\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#if DEBUGMODE>0\noutParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;\n#endif\noutParams.finalClearCoatRadianceScaled=\nenvironmentClearCoatRadiance.rgb *\nclearCoatEnvironmentReflectance *\nvLightingIntensity.z;\n#endif\n#if defined(CLEARCOAT_TINT)\noutParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#endif\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\noutParams.conservationFactor=(1.-fresnelIBLClearCoat);\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\noutParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);\n#endif\n}\n#endif\n";
  81033. Pt.IncludesShadersStore.pbrBlockSubSurface = "struct subSurfaceOutParams\n{\nvec3 specularEnvironmentReflectance;\n#ifdef SS_REFRACTION\nvec3 finalRefraction;\nvec3 surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nfloat alpha;\n#endif\n#ifdef REFLECTION\nfloat refractionFactorForIrradiance;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvec3 transmittance;\nfloat translucencyIntensity;\n#ifdef REFLECTION\nvec3 refractionIrradiance;\n#endif\n#endif\n#if DEBUGMODE>0\nvec4 thicknessMap;\nvec4 environmentRefraction;\nvec3 refractionTransmittance;\n#endif\n};\n#ifdef SUBSURFACE\n#define pbr_inline\n#define inline\nvoid subSurfaceBlock(\nin vec3 vSubSurfaceIntensity,\nin vec2 vThicknessParam,\nin vec4 vTintColor,\nin vec3 normalW,\nin vec3 specularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nin vec4 thicknessMap,\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nin vec4 refractionIntensityMap,\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nin vec4 translucencyIntensityMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nin mat4 reflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nin vec3 irradianceVector_,\n#endif\n#if defined(REALTIME_FILTERING)\nin samplerCube reflectionSampler,\nin vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nin samplerCube irradianceSampler,\n#else\nin sampler2D irradianceSampler,\n#endif\n#endif\n#endif\n#endif\n#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\nin vec3 surfaceAlbedo,\n#endif\n#ifdef SS_REFRACTION\nin vec3 vPositionW,\nin vec3 viewDirectionW,\nin mat4 view,\nin vec4 vRefractionInfos,\nin mat4 refractionMatrix,\nin vec4 vRefractionMicrosurfaceInfos,\nin vec4 vLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nin float alpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nin float NdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nin float roughness,\n#endif\nin float alphaG,\n#ifdef SS_REFRACTIONMAP_3D\nin samplerCube refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nin samplerCube refractionSamplerLow,\nin samplerCube refractionSamplerHigh,\n#endif\n#else\nin sampler2D refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nin sampler2D refractionSamplerLow,\nin sampler2D refractionSamplerHigh,\n#endif\n#endif\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vRefractionFilteringInfo,\n#endif\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nin vec3 refractionPosition,\nin vec3 refractionSize,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nin vec3 vDiffusionDistance,\n#endif\nout subSurfaceOutParams outParams\n)\n{\noutParams.specularEnvironmentReflectance=specularEnvironmentReflectance;\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\noutParams.alpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if defined(SS_USE_GLTF_TEXTURES)\nfloat thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;\n#else\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#endif\n#if DEBUGMODE>0\noutParams.thicknessMap=thicknessMap;\n#endif\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)\n#if defined(SS_USE_GLTF_TEXTURES)\nrefractionIntensity*=thicknessMap.r;\n#else\nrefractionIntensity*=thicknessMap.g;\n#endif\n#endif\n#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\n#ifdef SS_USE_GLTF_TEXTURES\nrefractionIntensity*=refractionIntensityMap.r;\n#else\nrefractionIntensity*=refractionIntensityMap.g;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\ntranslucencyIntensity*=translucencyIntensityMap.b;\n#endif\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\noutParams.transmittance=transmittance;\noutParams.translucencyIntensity=translucencyIntensity;\n#endif\n#ifdef SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n#ifdef SS_REFRACTIONMAP_3D\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\n#ifdef SS_USE_THICKNESS_AS_DEPTH\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\n#endif\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef SS_HAS_THICKNESS\nfloat ior=vRefractionInfos.y;\n#else\nfloat ior=vRefractionMicrosurfaceInfos.w;\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nfloat refractionAlphaG=alphaG;\nrefractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);\n#elif defined(SS_LINEARSPECULARREFRACTION)\nfloat refractionRoughness=alphaG;\nrefractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);\n#else\nfloat refractionAlphaG=alphaG;\nrefractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_LODINREFRACTIONALPHA\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\n#ifdef REALTIME_FILTERING\nenvironmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);\n#else\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#endif\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif (lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n} else {\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef SS_RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef SS_GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\n#endif\n#ifdef SS_ALBEDOFORREFRACTIONTINT\nenvironmentRefraction.rgb*=surfaceAlbedo.rgb;\n#endif\noutParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);\n#ifdef REFLECTION\noutParams.refractionFactorForIrradiance=(1.-refractionIntensity);\n#endif\n#ifdef UNUSED_MULTIPLEBOUNCES\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\noutParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n#endif\nrefractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;\n#if DEBUGMODE>0\noutParams.refractionTransmittance=refractionTransmittance;\n#endif\noutParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;\n#if DEBUGMODE>0\noutParams.environmentRefraction=environmentRefraction;\n#endif\n#endif\n#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#else\nvec3 irradianceVector=irradianceVector_;\n#endif\n#if defined(USESPHERICALFROMREFLECTIONMAP)\n#if defined(REALTIME_FILTERING)\nvec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);\n#else\nvec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nvec3 irradianceCoords=irradianceVector;\n#else\nvec2 irradianceCoords=irradianceVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nirradianceCoords/=irradianceVector.z;\n#endif\nirradianceCoords.y=1.0-irradianceCoords.y;\n#endif\nvec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);\n#ifdef RGBDREFLECTION\nrefractionIrradiance.rgb=fromRGBD(refractionIrradiance);\n#endif\n#ifdef GAMMAREFLECTION\nrefractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);\n#endif\n#else\nvec4 refractionIrradiance=vec4(0.);\n#endif\nrefractionIrradiance.rgb*=transmittance;\n#ifdef SS_ALBEDOFORTRANSLUCENCYTINT\nrefractionIrradiance.rgb*=surfaceAlbedo.rgb;\n#endif\noutParams.refractionIrradiance=refractionIrradiance.rgb;\n#endif\n}\n#endif\n";
  81034. Pt.IncludesShadersStore.pbrBlockNormalGeometric = "vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\nvec3 geometricNormalW=normalW;\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\ngeometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;\n#endif\n";
  81035. Pt.IncludesShadersStore.pbrBlockNormalFinal = "#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n";
  81036. Pt.IncludesShadersStore.pbrBlockLightmapInit = "#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\n#ifdef GAMMALIGHTMAP\nlightmapColor.rgb=toLinearSpace(lightmapColor.rgb);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n";
  81037. Pt.IncludesShadersStore.pbrBlockGeometryInfo = "float NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\nalphaG+=AARoughnessFactors.y;\n#endif\n#if defined(ENVIRONMENTBRDF)\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness);\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=aoOut.ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\n#endif\n#endif\n#endif\n#endif\n";
  81038. Pt.IncludesShadersStore.pbrBlockReflectance0 = "float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);\nvec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);\n#else \nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);\n#endif\n#ifdef ALPHAFRESNEL\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nspecularEnvironmentR90=specularEnvironmentR90*reflectance90;\n#endif\n";
  81039. Pt.IncludesShadersStore.pbrBlockReflectance = "#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n#ifdef CLEARCOAT\nspecularEnvironmentReflectance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nspecularEnvironmentReflectance*=clearcoatOut.absorption;\n#endif\n#endif\n";
  81040. Pt.IncludesShadersStore.pbrBlockDirectLighting = "vec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.; \n#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\nvec3 absorption=vec3(0.);\n#endif\n";
  81041. Pt.IncludesShadersStore.pbrBlockFinalLitComponents = "#if defined(ENVIRONMENTBRDF)\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n#ifndef METALLICWORKFLOW\n#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n#endif\n#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)\nsurfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;\n#endif\n#ifdef REFLECTION\nvec3 finalIrradiance=reflectionOut.environmentIrradiance;\n#if defined(CLEARCOAT)\nfinalIrradiance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nfinalIrradiance*=clearcoatOut.absorption;\n#endif\n#endif\n#if defined(SS_REFRACTION)\nfinalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;\n#endif\n#if defined(SS_TRANSLUCENCY)\nfinalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);\nfinalIrradiance+=subSurfaceOut.refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\nfinalIrradiance*=vLightingIntensity.z;\nfinalIrradiance*=aoOut.ambientOcclusionColor;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalSpecularScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n#ifdef REFLECTION\nvec3 finalRadiance=reflectionOut.environmentRadiance.rgb;\nfinalRadiance*=subSurfaceOut.specularEnvironmentReflectance;\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalRadianceScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenOut.sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;\n#ifdef CLEARCOAT_TINT\nsubSurfaceOut.finalRefraction*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n";
  81042. Pt.IncludesShadersStore.pbrBlockFinalUnlitComponents = "vec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\nfinalDiffuse*=vLightingIntensity.x;\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\n#ifdef GAMMAEMISSIVE\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\n#else\nfinalEmissive*=emissiveColorTex.rgb;\n#endif\nfinalEmissive*= vEmissiveInfos.y;\n#endif\nfinalEmissive*=vLightingIntensity.y;\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;\n#endif\nfinalAmbient*=aoOut.ambientOcclusionColor;\nfinalDiffuse*=ambientOcclusionForDirectDiffuse;\n";
  81043. Pt.IncludesShadersStore.pbrBlockFinalColorComposition = "vec4 finalColor=vec4(\nfinalAmbient +\nfinalDiffuse +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance +\n#endif\n#ifdef SPECULARTERM\nfinalSpecularScaled +\n#endif\n#ifdef SHEEN\nfinalSheenScaled +\n#endif\n#ifdef CLEARCOAT\nfinalClearCoatScaled +\n#endif\n#ifdef REFLECTION\nfinalRadianceScaled +\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled +\n#endif\n#ifdef CLEARCOAT\nclearcoatOut.finalClearCoatRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction +\n#endif\n#endif\nfinalEmissive,\nalpha);\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor.rgb;\n#else\nfinalColor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\nfinalColor=max(finalColor,0.0);\n";
  81044. Pt.IncludesShadersStore.pbrBlockImageProcessing = "#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)\n#if !defined(SKIPFINALCOLORCLAMP)\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#endif\n#else\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\nfinalColor.rgb*=finalColor.a;\n#endif\n";
  81045. Pt.IncludesShadersStore.pbrDebug = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {\n#if DEBUGMODE==1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==5\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE==7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==10 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearcoatOut.clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE==21 && defined(AMBIENT)\ngl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE==22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE==23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);\n#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;\n#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenOut.sheenMapData.rgb;\n#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;\n#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;\n#elif DEBUGMODE==40 && defined(SS_REFRACTION)\ngl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==41 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==54 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==61\ngl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);\n#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.metallicF0;\n#elif DEBUGMODE==63\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE==64\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE==65\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);\n#elif DEBUGMODE==68 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);\n#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=subSurfaceOut.transmittance;\n#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=subSurfaceOut.refractionTransmittance;\n#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==86 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE==87\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#ifdef PREPASS\ngl_FragData[0]=toLinearSpace(gl_FragColor); \ngl_FragData[1]=vec4(0.,0.,0.,0.); \n#endif\nreturn;\n}\n#endif\n";
  81046. Pt.ShadersStore.pbrPixelShader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n#include<oitDeclaration>\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<pbrBlockAlbedoOpacity>\n#include<pbrBlockReflectivity>\n#include<pbrBlockAmbientOcclusion>\n#include<pbrBlockAlphaFresnel>\n#include<pbrBlockAnisotropic>\n#include<pbrBlockReflection>\n#include<pbrBlockSheen>\n#include<pbrBlockClearcoat>\n#include<pbrBlockSubSurface>\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<oitFragment>\n#include<clipPlaneFragment>\n#include<pbrBlockNormalGeometric>\n#include<bumpFragment>\n#include<pbrBlockNormalFinal>\nalbedoOpacityOutParams albedoOpacityOut;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#endif\nalbedoOpacityBlock(\nvAlbedoColor,\n#ifdef ALBEDO\nalbedoTexture,\nvAlbedoInfos,\n#endif\n#ifdef OPACITY\nopacityMap,\nvOpacityInfos,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nalbedoOpacityOut\n);\nvec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;\nfloat alpha=albedoOpacityOut.alpha;\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\nambientOcclusionOutParams aoOut;\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;\n#endif\nambientOcclusionBlock(\n#ifdef AMBIENT\nambientOcclusionColorMap,\nvAmbientInfos,\n#endif\naoOut\n);\n#include<pbrBlockLightmapInit>\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\nvec3 baseColor=surfaceAlbedo;\nreflectivityOutParams reflectivityOut;\n#if defined(REFLECTIVITY)\nvec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nvec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;\n#ifndef METALLICWORKFLOW\n#ifdef REFLECTIVITY_GAMMA\nsurfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);\n#endif\nsurfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;\n#endif\n#endif\n#if defined(MICROSURFACEMAP)\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\n#endif\n#ifdef METALLICWORKFLOW\nvec4 metallicReflectanceFactors=vMetallicReflectanceFactors;\n#ifdef REFLECTANCE\nvec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);\n#ifdef REFLECTANCE_GAMMA\nreflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);\n#endif\nmetallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;\n#endif\n#ifdef METALLIC_REFLECTANCE\nvec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);\n#ifdef METALLIC_REFLECTANCE_GAMMA\nmetallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);\n#endif\n#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY\nmetallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;\n#endif\nmetallicReflectanceFactors*=metallicReflectanceFactorsMap.a;\n#endif\n#endif\nreflectivityBlock(\nvReflectivityColor,\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo,\nmetallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nvReflectivityInfos,\nsurfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor,\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurfaceTexel,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nreflectivityOut\n);\nfloat microSurface=reflectivityOut.microSurface;\nfloat roughness=reflectivityOut.roughness;\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo=reflectivityOut.surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;\n#endif\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nalphaFresnelOutParams alphaFresnelOut;\nalphaFresnelBlock(\nnormalW,\nviewDirectionW,\nalpha,\nmicroSurface,\nalphaFresnelOut\n);\nalpha=alphaFresnelOut.alpha;\n#endif\n#endif\n#include<pbrBlockGeometryInfo>\n#ifdef ANISOTROPIC\nanisotropicOutParams anisotropicOut;\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\n#endif\nanisotropicBlock(\nvAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nanisotropyMapData,\n#endif\nTBN,\nnormalW,\nviewDirectionW,\nanisotropicOut\n);\n#endif\n#ifdef REFLECTION\nreflectionOutParams reflectionOut;\n#ifndef USE_CUSTOM_REFLECTION\nreflectionBlock(\nvPositionW,\nnormalW,\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\nreflectionSampler,\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nvEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nreflectionOut\n);\n#else\n#define CUSTOM_REFLECTION\n#endif\n#endif\n#include<pbrBlockReflectance0>\n#ifdef SHEEN\nsheenOutParams sheenOut;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);\n#endif\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;\n#endif\nsheenBlock(\nvSheenColor,\n#ifdef SHEEN_ROUGHNESS\nvSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nsheenMapRoughnessData,\n#endif\n#endif\nroughness,\n#ifdef SHEEN_TEXTURE\nsheenMapData,\nvSheenInfos.y,\n#endif\nreflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nbaseColor,\nsurfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nNdotV,\nenvironmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nAARoughnessFactors,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\nreflectionOut.reflectionCoords,\nNdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nseo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\neho,\n#endif\n#endif\nsheenOut\n);\n#ifdef SHEEN_LINKWITHALBEDO\nsurfaceAlbedo=sheenOut.surfaceAlbedo;\n#endif\n#endif\nclearcoatOutParams clearcoatOut;\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;\n#endif\n#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\n#endif\n#ifdef CLEARCOAT_BUMP\nvec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);\n#endif\nclearcoatBlock(\nvPositionW,\ngeometricNormalW,\nviewDirectionW,\nvClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nclearCoatMapRoughnessData,\n#endif\nspecularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nclearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nvClearCoatTintParams,\nclearCoatColorAtDistance,\nvClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nclearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nvClearCoatBumpInfos,\nclearCoatBumpMapData,\nvClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nvTBN,\n#else\nvClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nnormalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nfaceNormal,\n#endif\n#ifdef REFLECTION\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nambientMonochrome,\n#endif\n#endif\n#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\n(gl_FrontFacing ? 1. : -1.),\n#endif\nclearcoatOut\n);\n#else\nclearcoatOut.specularEnvironmentR0=specularEnvironmentR0;\n#endif\n#include<pbrBlockReflectance>\nsubSurfaceOutParams subSurfaceOut;\n#ifdef SUBSURFACE\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nvec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nvec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);\n#endif\nsubSurfaceBlock(\nvSubSurfaceIntensity,\nvThicknessParam,\nvTintColor,\nnormalW,\nspecularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nthicknessMap,\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nrefractionIntensityMap,\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\ntranslucencyIntensityMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nreflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionOut.irradianceVector,\n#endif\n#if defined(REALTIME_FILTERING)\nreflectionSampler,\nvReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#endif\n#endif\n#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\nsurfaceAlbedo,\n#endif\n#ifdef SS_REFRACTION\nvPositionW,\nviewDirectionW,\nview,\nvRefractionInfos,\nrefractionMatrix,\nvRefractionMicrosurfaceInfos,\nvLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nNdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nroughness,\n#endif\nalphaG,\nrefractionSampler,\n#ifndef LODBASEDMICROSFURACE\nrefractionSamplerLow,\nrefractionSamplerHigh,\n#endif\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nvRefractionFilteringInfo,\n#endif\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nvRefractionPosition,\nvRefractionSize,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvDiffusionDistance,\n#endif\nsubSurfaceOut\n);\n#ifdef SS_REFRACTION\nsurfaceAlbedo=subSurfaceOut.surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha=subSurfaceOut.alpha;\n#endif\n#endif\n#else\nsubSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;\n#endif\n#include<pbrBlockDirectLighting>\n#include<lightFragment>[0..maxSimultaneousLights]\n#include<pbrBlockFinalLitComponents>\n#endif \n#include<pbrBlockFinalUnlitComponents>\n#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\n#include<pbrBlockFinalColorComposition>\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_ALBEDO_SQRT\nvec3 sqAlbedo=sqrt(surfaceAlbedo); \n#endif\n#ifdef PREPASS_IRRADIANCE\nvec3 irradiance=finalDiffuse;\n#ifndef UNLIT\n#ifdef REFLECTION\nirradiance+=finalIrradiance;\n#endif\n#endif\n#ifdef SS_SCATTERING\ngl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a); \nirradiance/=sqAlbedo;\n#else\ngl_FragData[0]=finalColor; \nfloat scatteringDiffusionProfile=255.;\n#endif\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.); \n#else\ngl_FragData[0]=vec4(finalColor.rgb,finalColor.a);\n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(REFLECTIVITY)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,baseReflectivity.a*writeGeometryInfo);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {\nfrontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;\nfrontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);\n} else {\nbackColor+=finalColor;\n}\n#endif\n#include<pbrDebug>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
  81047. Pt.IncludesShadersStore.pbrVertexDeclaration = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef METALLIC_REFLECTANCE\nuniform vec2 vMetallicReflectanceInfos;\nuniform mat4 metallicReflectanceMatrix;\n#endif\n#ifdef REFLECTANCE\nuniform vec2 vReflectanceInfos;\nuniform mat4 reflectanceMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;\nuniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;\nuniform mat4 translucencyIntensityMatrix;\n#endif\n#endif\n#ifdef NORMAL\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n#endif\n#endif\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n#endif\n#define ADDITIONAL_VERTEX_DECLARATION\n";
  81048. Pt.ShadersStore.pbrVertexShader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#include<uvAttributeDeclaration>[2..7]\n#include<mainUVVaryingDeclaration>[1..7]\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\n#include<prePassVertexDeclaration>\n#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)\n#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)\n#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)\n#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)\n#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)\n#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)\n#include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)\n#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)\n#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)\n#ifdef CLEARCOAT\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)\n#endif\n#ifdef SHEEN\n#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\n#endif\n#ifdef ANISOTROPIC\n#include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)\n#endif\n#ifdef SUBSURFACE\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)\n#endif\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n#ifndef UV1\nvec2 uvUpdated=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#include<uvVariableDeclaration>[2..7]\n#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)\n#ifdef CLEARCOAT\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)\n#endif\n#ifdef SHEEN\n#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.z)\n#endif\n#ifdef ANISOTROPIC\n#include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)\n#endif\n#ifdef SUBSURFACE\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  81049. var Kd = function(e) {
  81050. function t() {
  81051. var t = null !== e && e.apply(this, arguments) || this;
  81052. return t.CLEARCOAT = !1,
  81053. t.CLEARCOAT_DEFAULTIOR = !1,
  81054. t.CLEARCOAT_TEXTURE = !1,
  81055. t.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  81056. t.CLEARCOAT_TEXTUREDIRECTUV = 0,
  81057. t.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0,
  81058. t.CLEARCOAT_BUMP = !1,
  81059. t.CLEARCOAT_BUMPDIRECTUV = 0,
  81060. t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  81061. t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1,
  81062. t.CLEARCOAT_REMAP_F0 = !1,
  81063. t.CLEARCOAT_TINT = !1,
  81064. t.CLEARCOAT_TINT_TEXTURE = !1,
  81065. t.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0,
  81066. t.CLEARCOAT_TINT_GAMMATEXTURE = !1,
  81067. t
  81068. }
  81069. return U(t, e),
  81070. t
  81071. }(Si)
  81072. , Qd = function(e) {
  81073. function t(i, n) {
  81074. void 0 === n && (n = !0);
  81075. var r = e.call(this, i, "PBRClearCoat", 100, new Kd, n) || this;
  81076. return r._isEnabled = !1,
  81077. r.isEnabled = !1,
  81078. r.intensity = 1,
  81079. r.roughness = 0,
  81080. r._indexOfRefraction = t._DefaultIndexOfRefraction,
  81081. r.indexOfRefraction = t._DefaultIndexOfRefraction,
  81082. r._texture = null,
  81083. r.texture = null,
  81084. r._useRoughnessFromMainTexture = !0,
  81085. r.useRoughnessFromMainTexture = !0,
  81086. r._textureRoughness = null,
  81087. r.textureRoughness = null,
  81088. r._remapF0OnInterfaceChange = !0,
  81089. r.remapF0OnInterfaceChange = !0,
  81090. r._bumpTexture = null,
  81091. r.bumpTexture = null,
  81092. r._isTintEnabled = !1,
  81093. r.isTintEnabled = !1,
  81094. r.tintColor = D.White(),
  81095. r.tintColorAtDistance = 1,
  81096. r.tintThickness = 1,
  81097. r._tintTexture = null,
  81098. r.tintTexture = null,
  81099. r._internalMarkAllSubMeshesAsTexturesDirty = i._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
  81100. r
  81101. }
  81102. return U(t, e),
  81103. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  81104. this._enable(this._isEnabled),
  81105. this._internalMarkAllSubMeshesAsTexturesDirty()
  81106. }
  81107. ,
  81108. t.prototype.isReadyForSubMesh = function(e, t, i) {
  81109. if (!this._isEnabled)
  81110. return !0;
  81111. var n = this._material._disableBumpMap;
  81112. if (e._areTexturesDirty && t.texturesEnabled) {
  81113. if (this._texture && vs.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking())
  81114. return !1;
  81115. if (this._textureRoughness && vs.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())
  81116. return !1;
  81117. if (i.getCaps().standardDerivatives && this._bumpTexture && vs.ClearCoatBumpTextureEnabled && !n && !this._bumpTexture.isReady())
  81118. return !1;
  81119. if (this._isTintEnabled && this._tintTexture && vs.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking())
  81120. return !1
  81121. }
  81122. return !0
  81123. }
  81124. ,
  81125. t.prototype.prepareDefines = function(e, i) {
  81126. var n;
  81127. this._isEnabled ? (e.CLEARCOAT = !0,
  81128. e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
  81129. e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = null !== this._texture && this._texture._texture === (null === (n = this._textureRoughness) || void 0 === n ? void 0 : n._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
  81130. e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange,
  81131. e._areTexturesDirty && i.texturesEnabled && (this._texture && vs.ClearCoatTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1,
  81132. this._textureRoughness && vs.ClearCoatTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  81133. this._bumpTexture && vs.ClearCoatBumpTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1,
  81134. e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === t._DefaultIndexOfRefraction,
  81135. this._isTintEnabled ? (e.CLEARCOAT_TINT = !0,
  81136. this._tintTexture && vs.ClearCoatTintTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._tintTexture, e, "CLEARCOAT_TINT_TEXTURE"),
  81137. e.CLEARCOAT_TINT_GAMMATEXTURE = this._tintTexture.gammaSpace) : e.CLEARCOAT_TINT_TEXTURE = !1) : (e.CLEARCOAT_TINT = !1,
  81138. e.CLEARCOAT_TINT_TEXTURE = !1))) : (e.CLEARCOAT = !1,
  81139. e.CLEARCOAT_TEXTURE = !1,
  81140. e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
  81141. e.CLEARCOAT_BUMP = !1,
  81142. e.CLEARCOAT_TINT = !1,
  81143. e.CLEARCOAT_TINT_TEXTURE = !1,
  81144. e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  81145. e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1)
  81146. }
  81147. ,
  81148. t.prototype.bindForSubMesh = function(e, t, i, n) {
  81149. var r, o, a, s, l, c, u, h;
  81150. if (this._isEnabled) {
  81151. var d = n.materialDefines
  81152. , p = this._material.isFrozen
  81153. , f = this._material._disableBumpMap
  81154. , _ = this._material._invertNormalMapX
  81155. , m = this._material._invertNormalMapY
  81156. , g = d.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
  81157. if (!e.useUbo || !p || !e.isSync) {
  81158. g && vs.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
  81159. Mr.BindTextureMatrix(this._texture, e, "clearCoat")) : (this._texture || this._textureRoughness) && vs.ClearCoatTextureEnabled && (e.updateFloat4("vClearCoatInfos", null !== (o = null === (r = this._texture) || void 0 === r ? void 0 : r.coordinatesIndex) && void 0 !== o ? o : 0, null !== (s = null === (a = this._texture) || void 0 === a ? void 0 : a.level) && void 0 !== s ? s : 0, null !== (c = null === (l = this._textureRoughness) || void 0 === l ? void 0 : l.coordinatesIndex) && void 0 !== c ? c : 0, null !== (h = null === (u = this._textureRoughness) || void 0 === u ? void 0 : u.level) && void 0 !== h ? h : 0),
  81160. this._texture && Mr.BindTextureMatrix(this._texture, e, "clearCoat"),
  81161. !this._textureRoughness || g || d.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE || Mr.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")),
  81162. this._bumpTexture && i.getCaps().standardDerivatives && vs.ClearCoatTextureEnabled && !f && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level),
  81163. Mr.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"),
  81164. t._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", _ ? 1 : -1, m ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", _ ? -1 : 1, m ? -1 : 1)),
  81165. this._tintTexture && vs.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level),
  81166. Mr.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")),
  81167. e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  81168. var v = 1 - this._indexOfRefraction
  81169. , y = 1 + this._indexOfRefraction
  81170. , b = Math.pow(-v / y, 2)
  81171. , T = 1 / this._indexOfRefraction;
  81172. e.updateFloat4("vClearCoatRefractionParams", b, T, v, y),
  81173. this._isTintEnabled && (e.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)),
  81174. e.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)))
  81175. }
  81176. t.texturesEnabled && (this._texture && vs.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture),
  81177. this._textureRoughness && !g && !d.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && vs.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness),
  81178. this._bumpTexture && i.getCaps().standardDerivatives && vs.ClearCoatBumpTextureEnabled && !f && e.setTexture("clearCoatBumpSampler", this._bumpTexture),
  81179. this._isTintEnabled && this._tintTexture && vs.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture))
  81180. }
  81181. }
  81182. ,
  81183. t.prototype.hasTexture = function(e) {
  81184. return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e
  81185. }
  81186. ,
  81187. t.prototype.getActiveTextures = function(e) {
  81188. this._texture && e.push(this._texture),
  81189. this._textureRoughness && e.push(this._textureRoughness),
  81190. this._bumpTexture && e.push(this._bumpTexture),
  81191. this._tintTexture && e.push(this._tintTexture)
  81192. }
  81193. ,
  81194. t.prototype.getAnimatables = function(e) {
  81195. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
  81196. this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness),
  81197. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture),
  81198. this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0 && e.push(this._tintTexture)
  81199. }
  81200. ,
  81201. t.prototype.dispose = function(e) {
  81202. var t, i, n, r;
  81203. e && (null === (t = this._texture) || void 0 === t || t.dispose(),
  81204. null === (i = this._textureRoughness) || void 0 === i || i.dispose(),
  81205. null === (n = this._bumpTexture) || void 0 === n || n.dispose(),
  81206. null === (r = this._tintTexture) || void 0 === r || r.dispose())
  81207. }
  81208. ,
  81209. t.prototype.getClassName = function() {
  81210. return "PBRClearCoatConfiguration"
  81211. }
  81212. ,
  81213. t.prototype.addFallbacks = function(e, t, i) {
  81214. return e.CLEARCOAT_BUMP && t.addFallback(i++, "CLEARCOAT_BUMP"),
  81215. e.CLEARCOAT_TINT && t.addFallback(i++, "CLEARCOAT_TINT"),
  81216. e.CLEARCOAT && t.addFallback(i++, "CLEARCOAT"),
  81217. i
  81218. }
  81219. ,
  81220. t.prototype.getSamplers = function(e) {
  81221. e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler")
  81222. }
  81223. ,
  81224. t.prototype.getUniforms = function() {
  81225. return {
  81226. ubo: [{
  81227. name: "vClearCoatParams",
  81228. size: 2,
  81229. type: "vec2"
  81230. }, {
  81231. name: "vClearCoatRefractionParams",
  81232. size: 4,
  81233. type: "vec4"
  81234. }, {
  81235. name: "vClearCoatInfos",
  81236. size: 4,
  81237. type: "vec4"
  81238. }, {
  81239. name: "clearCoatMatrix",
  81240. size: 16,
  81241. type: "mat4"
  81242. }, {
  81243. name: "clearCoatRoughnessMatrix",
  81244. size: 16,
  81245. type: "mat4"
  81246. }, {
  81247. name: "vClearCoatBumpInfos",
  81248. size: 2,
  81249. type: "vec2"
  81250. }, {
  81251. name: "vClearCoatTangentSpaceParams",
  81252. size: 2,
  81253. type: "vec2"
  81254. }, {
  81255. name: "clearCoatBumpMatrix",
  81256. size: 16,
  81257. type: "mat4"
  81258. }, {
  81259. name: "vClearCoatTintParams",
  81260. size: 4,
  81261. type: "vec4"
  81262. }, {
  81263. name: "clearCoatColorAtDistance",
  81264. size: 1,
  81265. type: "float"
  81266. }, {
  81267. name: "vClearCoatTintInfos",
  81268. size: 2,
  81269. type: "vec2"
  81270. }, {
  81271. name: "clearCoatTintMatrix",
  81272. size: 16,
  81273. type: "mat4"
  81274. }]
  81275. }
  81276. }
  81277. ,
  81278. t._DefaultIndexOfRefraction = 1.5,
  81279. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
  81280. k([Ce()], t.prototype, "intensity", void 0),
  81281. k([Ce()], t.prototype, "roughness", void 0),
  81282. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
  81283. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
  81284. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
  81285. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
  81286. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "remapF0OnInterfaceChange", void 0),
  81287. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
  81288. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTintEnabled", void 0),
  81289. k([Me()], t.prototype, "tintColor", void 0),
  81290. k([Ce()], t.prototype, "tintColorAtDistance", void 0),
  81291. k([Ce()], t.prototype, "tintThickness", void 0),
  81292. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "tintTexture", void 0),
  81293. t
  81294. }(Rs)
  81295. , qd = function(e) {
  81296. function t() {
  81297. var t = null !== e && e.apply(this, arguments) || this;
  81298. return t.ANISOTROPIC = !1,
  81299. t.ANISOTROPIC_TEXTURE = !1,
  81300. t.ANISOTROPIC_TEXTUREDIRECTUV = 0,
  81301. t.MAINUV1 = !1,
  81302. t
  81303. }
  81304. return U(t, e),
  81305. t
  81306. }(Si)
  81307. , Zd = function(e) {
  81308. function t(t, i) {
  81309. void 0 === i && (i = !0);
  81310. var n = e.call(this, t, "PBRAnisotropic", 110, new qd, i) || this;
  81311. return n._isEnabled = !1,
  81312. n.isEnabled = !1,
  81313. n.intensity = 1,
  81314. n.direction = new A(1,0),
  81315. n._texture = null,
  81316. n.texture = null,
  81317. n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
  81318. n
  81319. }
  81320. return U(t, e),
  81321. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  81322. this._enable(this._isEnabled),
  81323. this._internalMarkAllSubMeshesAsTexturesDirty()
  81324. }
  81325. ,
  81326. t.prototype.isReadyForSubMesh = function(e, t) {
  81327. return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && this._texture && vs.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking())
  81328. }
  81329. ,
  81330. t.prototype.prepareDefines = function(e, t, i) {
  81331. this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
  81332. this._isEnabled && !i.isVerticesDataPresent(Bi.TangentKind) && (e._needUVs = !0,
  81333. e.MAINUV1 = !0),
  81334. e._areTexturesDirty && t.texturesEnabled && (this._texture && vs.AnisotropicTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
  81335. e.ANISOTROPIC_TEXTURE = !1)
  81336. }
  81337. ,
  81338. t.prototype.bindForSubMesh = function(e, t) {
  81339. if (this._isEnabled) {
  81340. var i = this._material.isFrozen;
  81341. e.useUbo && i && e.isSync || (this._texture && vs.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
  81342. Mr.BindTextureMatrix(this._texture, e, "anisotropy")),
  81343. e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
  81344. t.texturesEnabled && this._texture && vs.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture)
  81345. }
  81346. }
  81347. ,
  81348. t.prototype.hasTexture = function(e) {
  81349. return this._texture === e
  81350. }
  81351. ,
  81352. t.prototype.getActiveTextures = function(e) {
  81353. this._texture && e.push(this._texture)
  81354. }
  81355. ,
  81356. t.prototype.getAnimatables = function(e) {
  81357. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
  81358. }
  81359. ,
  81360. t.prototype.dispose = function(e) {
  81361. e && this._texture && this._texture.dispose()
  81362. }
  81363. ,
  81364. t.prototype.getClassName = function() {
  81365. return "PBRAnisotropicConfiguration"
  81366. }
  81367. ,
  81368. t.prototype.addFallbacks = function(e, t, i) {
  81369. return e.ANISOTROPIC && t.addFallback(i++, "ANISOTROPIC"),
  81370. i
  81371. }
  81372. ,
  81373. t.prototype.getSamplers = function(e) {
  81374. e.push("anisotropySampler")
  81375. }
  81376. ,
  81377. t.prototype.getUniforms = function() {
  81378. return {
  81379. ubo: [{
  81380. name: "vAnisotropy",
  81381. size: 3,
  81382. type: "vec3"
  81383. }, {
  81384. name: "vAnisotropyInfos",
  81385. size: 2,
  81386. type: "vec2"
  81387. }, {
  81388. name: "anisotropyMatrix",
  81389. size: 16,
  81390. type: "mat4"
  81391. }]
  81392. }
  81393. }
  81394. ,
  81395. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
  81396. k([Ce()], t.prototype, "intensity", void 0),
  81397. k([Oe()], t.prototype, "direction", void 0),
  81398. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
  81399. t
  81400. }(Rs)
  81401. , Jd = function(e) {
  81402. function t() {
  81403. var t = null !== e && e.apply(this, arguments) || this;
  81404. return t.SHEEN = !1,
  81405. t.SHEEN_TEXTURE = !1,
  81406. t.SHEEN_GAMMATEXTURE = !1,
  81407. t.SHEEN_TEXTURE_ROUGHNESS = !1,
  81408. t.SHEEN_TEXTUREDIRECTUV = 0,
  81409. t.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0,
  81410. t.SHEEN_LINKWITHALBEDO = !1,
  81411. t.SHEEN_ROUGHNESS = !1,
  81412. t.SHEEN_ALBEDOSCALING = !1,
  81413. t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  81414. t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1,
  81415. t
  81416. }
  81417. return U(t, e),
  81418. t
  81419. }(Si)
  81420. , $d = function(e) {
  81421. function t(t, i) {
  81422. void 0 === i && (i = !0);
  81423. var n = e.call(this, t, "Sheen", 120, new Jd, i) || this;
  81424. return n._isEnabled = !1,
  81425. n.isEnabled = !1,
  81426. n._linkSheenWithAlbedo = !1,
  81427. n.linkSheenWithAlbedo = !1,
  81428. n.intensity = 1,
  81429. n.color = D.White(),
  81430. n._texture = null,
  81431. n.texture = null,
  81432. n._useRoughnessFromMainTexture = !0,
  81433. n.useRoughnessFromMainTexture = !0,
  81434. n._roughness = null,
  81435. n.roughness = null,
  81436. n._textureRoughness = null,
  81437. n.textureRoughness = null,
  81438. n._albedoScaling = !1,
  81439. n.albedoScaling = !1,
  81440. n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
  81441. n
  81442. }
  81443. return U(t, e),
  81444. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  81445. this._enable(this._isEnabled),
  81446. this._internalMarkAllSubMeshesAsTexturesDirty()
  81447. }
  81448. ,
  81449. t.prototype.isReadyForSubMesh = function(e, t) {
  81450. if (!this._isEnabled)
  81451. return !0;
  81452. if (e._areTexturesDirty && t.texturesEnabled) {
  81453. if (this._texture && vs.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking())
  81454. return !1;
  81455. if (this._textureRoughness && vs.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())
  81456. return !1
  81457. }
  81458. return !0
  81459. }
  81460. ,
  81461. t.prototype.prepareDefines = function(e, t) {
  81462. var i;
  81463. this._isEnabled ? (e.SHEEN = !0,
  81464. e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo,
  81465. e.SHEEN_ROUGHNESS = null !== this._roughness,
  81466. e.SHEEN_ALBEDOSCALING = this._albedoScaling,
  81467. e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
  81468. e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = null !== this._texture && this._texture._texture === (null === (i = this._textureRoughness) || void 0 === i ? void 0 : i._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
  81469. e._areTexturesDirty && t.texturesEnabled && (this._texture && vs.SheenTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
  81470. e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
  81471. this._textureRoughness && vs.SheenTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._textureRoughness, e, "SHEEN_TEXTURE_ROUGHNESS") : e.SHEEN_TEXTURE_ROUGHNESS = !1)) : (e.SHEEN = !1,
  81472. e.SHEEN_TEXTURE = !1,
  81473. e.SHEEN_TEXTURE_ROUGHNESS = !1,
  81474. e.SHEEN_LINKWITHALBEDO = !1,
  81475. e.SHEEN_ROUGHNESS = !1,
  81476. e.SHEEN_ALBEDOSCALING = !1,
  81477. e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
  81478. e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1)
  81479. }
  81480. ,
  81481. t.prototype.bindForSubMesh = function(e, t, i, n) {
  81482. var r, o, a, s, l, c, u, h;
  81483. if (this._isEnabled) {
  81484. var d = n.materialDefines
  81485. , p = this._material.isFrozen
  81486. , f = d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
  81487. e.useUbo && p && e.isSync || (f && vs.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
  81488. Mr.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && vs.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", null !== (o = null === (r = this._texture) || void 0 === r ? void 0 : r.coordinatesIndex) && void 0 !== o ? o : 0, null !== (s = null === (a = this._texture) || void 0 === a ? void 0 : a.level) && void 0 !== s ? s : 0, null !== (c = null === (l = this._textureRoughness) || void 0 === l ? void 0 : l.coordinatesIndex) && void 0 !== c ? c : 0, null !== (h = null === (u = this._textureRoughness) || void 0 === u ? void 0 : u.level) && void 0 !== h ? h : 0),
  81489. this._texture && Mr.BindTextureMatrix(this._texture, e, "sheen"),
  81490. !this._textureRoughness || f || d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || Mr.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")),
  81491. e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity),
  81492. null !== this._roughness && e.updateFloat("vSheenRoughness", this._roughness)),
  81493. t.texturesEnabled && (this._texture && vs.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
  81494. this._textureRoughness && !f && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && vs.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness))
  81495. }
  81496. }
  81497. ,
  81498. t.prototype.hasTexture = function(e) {
  81499. return this._texture === e || this._textureRoughness === e
  81500. }
  81501. ,
  81502. t.prototype.getActiveTextures = function(e) {
  81503. this._texture && e.push(this._texture),
  81504. this._textureRoughness && e.push(this._textureRoughness)
  81505. }
  81506. ,
  81507. t.prototype.getAnimatables = function(e) {
  81508. this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
  81509. this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness)
  81510. }
  81511. ,
  81512. t.prototype.dispose = function(e) {
  81513. var t, i;
  81514. e && (null === (t = this._texture) || void 0 === t || t.dispose(),
  81515. null === (i = this._textureRoughness) || void 0 === i || i.dispose())
  81516. }
  81517. ,
  81518. t.prototype.getClassName = function() {
  81519. return "PBRSheenConfiguration"
  81520. }
  81521. ,
  81522. t.prototype.addFallbacks = function(e, t, i) {
  81523. return e.SHEEN && t.addFallback(i++, "SHEEN"),
  81524. i
  81525. }
  81526. ,
  81527. t.prototype.getSamplers = function(e) {
  81528. e.push("sheenSampler", "sheenRoughnessSampler")
  81529. }
  81530. ,
  81531. t.prototype.getUniforms = function() {
  81532. return {
  81533. ubo: [{
  81534. name: "vSheenColor",
  81535. size: 4,
  81536. type: "vec4"
  81537. }, {
  81538. name: "vSheenRoughness",
  81539. size: 1,
  81540. type: "float"
  81541. }, {
  81542. name: "vSheenInfos",
  81543. size: 4,
  81544. type: "vec4"
  81545. }, {
  81546. name: "sheenMatrix",
  81547. size: 16,
  81548. type: "mat4"
  81549. }, {
  81550. name: "sheenRoughnessMatrix",
  81551. size: 16,
  81552. type: "mat4"
  81553. }]
  81554. }
  81555. }
  81556. ,
  81557. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
  81558. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkSheenWithAlbedo", void 0),
  81559. k([Ce()], t.prototype, "intensity", void 0),
  81560. k([Me()], t.prototype, "color", void 0),
  81561. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
  81562. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
  81563. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
  81564. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
  81565. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoScaling", void 0),
  81566. t
  81567. }(Rs)
  81568. , ep = function(e) {
  81569. function t() {
  81570. var t = null !== e && e.apply(this, arguments) || this;
  81571. return t.SUBSURFACE = !1,
  81572. t.SS_REFRACTION = !1,
  81573. t.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
  81574. t.SS_TRANSLUCENCY = !1,
  81575. t.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
  81576. t.SS_SCATTERING = !1,
  81577. t.SS_THICKNESSANDMASK_TEXTURE = !1,
  81578. t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0,
  81579. t.SS_HAS_THICKNESS = !1,
  81580. t.SS_REFRACTIONINTENSITY_TEXTURE = !1,
  81581. t.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0,
  81582. t.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
  81583. t.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0,
  81584. t.SS_REFRACTIONMAP_3D = !1,
  81585. t.SS_REFRACTIONMAP_OPPOSITEZ = !1,
  81586. t.SS_LODINREFRACTIONALPHA = !1,
  81587. t.SS_GAMMAREFRACTION = !1,
  81588. t.SS_RGBDREFRACTION = !1,
  81589. t.SS_LINEARSPECULARREFRACTION = !1,
  81590. t.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
  81591. t.SS_ALBEDOFORREFRACTIONTINT = !1,
  81592. t.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
  81593. t.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  81594. t.SS_USE_THICKNESS_AS_DEPTH = !1,
  81595. t.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
  81596. t.SS_USE_GLTF_TEXTURES = !1,
  81597. t
  81598. }
  81599. return U(t, e),
  81600. t
  81601. }(Si)
  81602. , tp = function(e) {
  81603. function t(t, i) {
  81604. void 0 === i && (i = !0);
  81605. var n = e.call(this, t, "PBRSubSurface", 130, new ep, i) || this;
  81606. return n._isRefractionEnabled = !1,
  81607. n.isRefractionEnabled = !1,
  81608. n._isTranslucencyEnabled = !1,
  81609. n.isTranslucencyEnabled = !1,
  81610. n._isScatteringEnabled = !1,
  81611. n.isScatteringEnabled = !1,
  81612. n._scatteringDiffusionProfileIndex = 0,
  81613. n.refractionIntensity = 1,
  81614. n.translucencyIntensity = 1,
  81615. n.useAlbedoToTintRefraction = !1,
  81616. n.useAlbedoToTintTranslucency = !1,
  81617. n._thicknessTexture = null,
  81618. n.thicknessTexture = null,
  81619. n._refractionTexture = null,
  81620. n.refractionTexture = null,
  81621. n._indexOfRefraction = 1.5,
  81622. n.indexOfRefraction = 1.5,
  81623. n._volumeIndexOfRefraction = -1,
  81624. n._invertRefractionY = !1,
  81625. n.invertRefractionY = !1,
  81626. n._linkRefractionWithTransparency = !1,
  81627. n.linkRefractionWithTransparency = !1,
  81628. n.minimumThickness = 0,
  81629. n.maximumThickness = 1,
  81630. n.useThicknessAsDepth = !1,
  81631. n.tintColor = D.White(),
  81632. n.tintColorAtDistance = 1,
  81633. n.diffusionDistance = D.White(),
  81634. n._useMaskFromThicknessTexture = !1,
  81635. n.useMaskFromThicknessTexture = !1,
  81636. n._refractionIntensityTexture = null,
  81637. n.refractionIntensityTexture = null,
  81638. n._translucencyIntensityTexture = null,
  81639. n.translucencyIntensityTexture = null,
  81640. n._useGltfStyleTextures = !1,
  81641. n.useGltfStyleTextures = !1,
  81642. n._scene = t.getScene(),
  81643. n.registerForExtraEvents = !0,
  81644. n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
  81645. n._internalMarkScenePrePassDirty = t._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag],
  81646. n
  81647. }
  81648. return U(t, e),
  81649. Object.defineProperty(t.prototype, "scatteringDiffusionProfile", {
  81650. get: function() {
  81651. return this._scene.subSurfaceConfiguration ? this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex] : null
  81652. },
  81653. set: function(e) {
  81654. this._scene.enableSubSurfaceForPrePass() && e && (this._scatteringDiffusionProfileIndex = this._scene.subSurfaceConfiguration.addDiffusionProfile(e))
  81655. },
  81656. enumerable: !1,
  81657. configurable: !0
  81658. }),
  81659. Object.defineProperty(t.prototype, "volumeIndexOfRefraction", {
  81660. get: function() {
  81661. return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction
  81662. },
  81663. set: function(e) {
  81664. this._volumeIndexOfRefraction = e >= 1 ? e : -1
  81665. },
  81666. enumerable: !1,
  81667. configurable: !0
  81668. }),
  81669. t.prototype._markAllSubMeshesAsTexturesDirty = function() {
  81670. this._enable(this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled),
  81671. this._internalMarkAllSubMeshesAsTexturesDirty()
  81672. }
  81673. ,
  81674. t.prototype._markScenePrePassDirty = function() {
  81675. this._internalMarkAllSubMeshesAsTexturesDirty(),
  81676. this._internalMarkScenePrePassDirty()
  81677. }
  81678. ,
  81679. t.prototype.isReadyForSubMesh = function(e, t) {
  81680. if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
  81681. return !0;
  81682. if (e._areTexturesDirty && t.texturesEnabled) {
  81683. if (this._thicknessTexture && vs.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
  81684. return !1;
  81685. var i = this._getRefractionTexture(t);
  81686. if (i && vs.RefractionTextureEnabled && !i.isReadyOrNotBlocking())
  81687. return !1
  81688. }
  81689. return !0
  81690. }
  81691. ,
  81692. t.prototype.prepareDefines = function(e, t) {
  81693. if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
  81694. return e.SUBSURFACE = !1,
  81695. e.SS_TRANSLUCENCY = !1,
  81696. e.SS_SCATTERING = !1,
  81697. void (e.SS_REFRACTION = !1);
  81698. if (e._areTexturesDirty) {
  81699. e.SUBSURFACE = !0,
  81700. e.SS_TRANSLUCENCY = this._isTranslucencyEnabled,
  81701. e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
  81702. e.SS_SCATTERING = this._isScatteringEnabled,
  81703. e.SS_THICKNESSANDMASK_TEXTURE = !1,
  81704. e.SS_REFRACTIONINTENSITY_TEXTURE = !1,
  81705. e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
  81706. e.SS_HAS_THICKNESS = !1,
  81707. e.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
  81708. e.SS_USE_GLTF_TEXTURES = !1,
  81709. e.SS_REFRACTION = !1,
  81710. e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
  81711. e.SS_REFRACTIONMAP_3D = !1,
  81712. e.SS_GAMMAREFRACTION = !1,
  81713. e.SS_RGBDREFRACTION = !1,
  81714. e.SS_LINEARSPECULARREFRACTION = !1,
  81715. e.SS_REFRACTIONMAP_OPPOSITEZ = !1,
  81716. e.SS_LODINREFRACTIONALPHA = !1,
  81717. e.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
  81718. e.SS_ALBEDOFORREFRACTIONTINT = !1,
  81719. e.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
  81720. e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
  81721. e.SS_USE_THICKNESS_AS_DEPTH = !1;
  81722. var i = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture
  81723. , n = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
  81724. , r = (i || !this._refractionIntensityTexture) && (n || !this._translucencyIntensityTexture);
  81725. if (e._areTexturesDirty && t.texturesEnabled && (this._thicknessTexture && vs.ThicknessTextureEnabled && Mr.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
  81726. this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && !r && Mr.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
  81727. this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && !r && Mr.PrepareDefinesForMergedUV(this._translucencyIntensityTexture, e, "SS_TRANSLUCENCYINTENSITY_TEXTURE")),
  81728. e.SS_HAS_THICKNESS = this.maximumThickness - this.minimumThickness != 0,
  81729. e.SS_MASK_FROM_THICKNESS_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture || !!this._translucencyIntensityTexture) && r,
  81730. e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
  81731. e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && r,
  81732. e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && r,
  81733. this._isRefractionEnabled && t.texturesEnabled) {
  81734. var o = this._getRefractionTexture(t);
  81735. o && vs.RefractionTextureEnabled && (e.SS_REFRACTION = !0,
  81736. e.SS_REFRACTIONMAP_3D = o.isCube,
  81737. e.SS_GAMMAREFRACTION = o.gammaSpace,
  81738. e.SS_RGBDREFRACTION = o.isRGBD,
  81739. e.SS_LINEARSPECULARREFRACTION = o.linearSpecularLOD,
  81740. e.SS_REFRACTIONMAP_OPPOSITEZ = o.invertZ,
  81741. e.SS_LODINREFRACTIONALPHA = o.lodLevelInAlpha,
  81742. e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency,
  81743. e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction,
  81744. e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = o.isCube && o.boundingBoxSize,
  81745. e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth)
  81746. }
  81747. this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency)
  81748. }
  81749. }
  81750. ,
  81751. t.prototype.hardBindForSubMesh = function(e, t, i, n) {
  81752. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  81753. n.getRenderingMesh().getWorldMatrix().decompose(I.Vector3[0]);
  81754. var r = Math.max(Math.abs(I.Vector3[0].x), Math.abs(I.Vector3[0].y), Math.abs(I.Vector3[0].z));
  81755. e.updateFloat2("vThicknessParam", this.minimumThickness * r, (this.maximumThickness - this.minimumThickness) * r)
  81756. }
  81757. }
  81758. ,
  81759. t.prototype.bindForSubMesh = function(e, t, i, n) {
  81760. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  81761. var r = n.materialDefines
  81762. , o = this._material.isFrozen
  81763. , a = this._material.realTimeFiltering
  81764. , s = r.LODBASEDMICROSFURACE
  81765. , l = this._getRefractionTexture(t);
  81766. if (!e.useUbo || !o || !e.isSync) {
  81767. if (this._thicknessTexture && vs.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
  81768. Mr.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
  81769. this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
  81770. Mr.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
  81771. this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
  81772. Mr.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
  81773. l && vs.RefractionTextureEnabled) {
  81774. e.updateMatrix("refractionMatrix", l.getReflectionTextureMatrix());
  81775. var c = 1;
  81776. l.isCube || l.depth && (c = l.depth);
  81777. var u = l.getSize().width
  81778. , h = this.volumeIndexOfRefraction;
  81779. if (e.updateFloat4("vRefractionInfos", l.level, 1 / h, c, this._invertRefractionY ? -1 : 1),
  81780. e.updateFloat4("vRefractionMicrosurfaceInfos", u, l.lodGenerationScale, l.lodGenerationOffset, 1 / this.indexOfRefraction),
  81781. a && e.updateFloat2("vRefractionFilteringInfo", u, d.Log2(u)),
  81782. l.boundingBoxSize) {
  81783. var p = l;
  81784. e.updateVector3("vRefractionPosition", p.boundingBoxPosition),
  81785. e.updateVector3("vRefractionSize", p.boundingBoxSize)
  81786. }
  81787. }
  81788. this._isScatteringEnabled && e.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex),
  81789. e.updateColor3("vDiffusionDistance", this.diffusionDistance),
  81790. e.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintColorAtDistance)),
  81791. e.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0)
  81792. }
  81793. t.texturesEnabled && (this._thicknessTexture && vs.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
  81794. this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
  81795. this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
  81796. l && vs.RefractionTextureEnabled && (s ? e.setTexture("refractionSampler", l) : (e.setTexture("refractionSampler", l._lodTextureMid || l),
  81797. e.setTexture("refractionSamplerLow", l._lodTextureLow || l),
  81798. e.setTexture("refractionSamplerHigh", l._lodTextureHigh || l))))
  81799. }
  81800. }
  81801. ,
  81802. t.prototype._getRefractionTexture = function(e) {
  81803. return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null
  81804. }
  81805. ,
  81806. Object.defineProperty(t.prototype, "disableAlphaBlending", {
  81807. get: function() {
  81808. return this._isRefractionEnabled && this._linkRefractionWithTransparency
  81809. },
  81810. enumerable: !1,
  81811. configurable: !0
  81812. }),
  81813. t.prototype.fillRenderTargetTextures = function(e) {
  81814. vs.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture)
  81815. }
  81816. ,
  81817. t.prototype.hasTexture = function(e) {
  81818. return this._thicknessTexture === e || this._refractionTexture === e
  81819. }
  81820. ,
  81821. t.prototype.hasRenderTargetTextures = function() {
  81822. return !!(vs.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
  81823. }
  81824. ,
  81825. t.prototype.getActiveTextures = function(e) {
  81826. this._thicknessTexture && e.push(this._thicknessTexture),
  81827. this._refractionTexture && e.push(this._refractionTexture)
  81828. }
  81829. ,
  81830. t.prototype.getAnimatables = function(e) {
  81831. this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && e.push(this._thicknessTexture),
  81832. this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && e.push(this._refractionTexture)
  81833. }
  81834. ,
  81835. t.prototype.dispose = function(e) {
  81836. e && (this._thicknessTexture && this._thicknessTexture.dispose(),
  81837. this._refractionTexture && this._refractionTexture.dispose())
  81838. }
  81839. ,
  81840. t.prototype.getClassName = function() {
  81841. return "PBRSubSurfaceConfiguration"
  81842. }
  81843. ,
  81844. t.prototype.addFallbacks = function(e, t, i) {
  81845. return e.SS_SCATTERING && t.addFallback(i++, "SS_SCATTERING"),
  81846. e.SS_TRANSLUCENCY && t.addFallback(i++, "SS_TRANSLUCENCY"),
  81847. i
  81848. }
  81849. ,
  81850. t.prototype.getSamplers = function(e) {
  81851. e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh")
  81852. }
  81853. ,
  81854. t.prototype.getUniforms = function() {
  81855. return {
  81856. ubo: [{
  81857. name: "vRefractionMicrosurfaceInfos",
  81858. size: 4,
  81859. type: "vec4"
  81860. }, {
  81861. name: "vRefractionFilteringInfo",
  81862. size: 2,
  81863. type: "vec2"
  81864. }, {
  81865. name: "vTranslucencyIntensityInfos",
  81866. size: 2,
  81867. type: "vec2"
  81868. }, {
  81869. name: "vRefractionInfos",
  81870. size: 4,
  81871. type: "vec4"
  81872. }, {
  81873. name: "refractionMatrix",
  81874. size: 16,
  81875. type: "mat4"
  81876. }, {
  81877. name: "vThicknessInfos",
  81878. size: 2,
  81879. type: "vec2"
  81880. }, {
  81881. name: "vRefractionIntensityInfos",
  81882. size: 2,
  81883. type: "vec2"
  81884. }, {
  81885. name: "thicknessMatrix",
  81886. size: 16,
  81887. type: "mat4"
  81888. }, {
  81889. name: "refractionIntensityMatrix",
  81890. size: 16,
  81891. type: "mat4"
  81892. }, {
  81893. name: "translucencyIntensityMatrix",
  81894. size: 16,
  81895. type: "mat4"
  81896. }, {
  81897. name: "vThicknessParam",
  81898. size: 2,
  81899. type: "vec2"
  81900. }, {
  81901. name: "vDiffusionDistance",
  81902. size: 3,
  81903. type: "vec3"
  81904. }, {
  81905. name: "vTintColor",
  81906. size: 4,
  81907. type: "vec4"
  81908. }, {
  81909. name: "vSubSurfaceIntensity",
  81910. size: 3,
  81911. type: "vec3"
  81912. }, {
  81913. name: "vRefractionPosition",
  81914. size: 3,
  81915. type: "vec3"
  81916. }, {
  81917. name: "vRefractionSize",
  81918. size: 3,
  81919. type: "vec3"
  81920. }, {
  81921. name: "scatteringDiffusionProfile",
  81922. size: 1,
  81923. type: "float"
  81924. }]
  81925. }
  81926. }
  81927. ,
  81928. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isRefractionEnabled", void 0),
  81929. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTranslucencyEnabled", void 0),
  81930. k([Ce(), Re("_markScenePrePassDirty")], t.prototype, "isScatteringEnabled", void 0),
  81931. k([Ce()], t.prototype, "_scatteringDiffusionProfileIndex", void 0),
  81932. k([Ce()], t.prototype, "refractionIntensity", void 0),
  81933. k([Ce()], t.prototype, "translucencyIntensity", void 0),
  81934. k([Ce()], t.prototype, "useAlbedoToTintRefraction", void 0),
  81935. k([Ce()], t.prototype, "useAlbedoToTintTranslucency", void 0),
  81936. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0),
  81937. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
  81938. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
  81939. k([Ce()], t.prototype, "_volumeIndexOfRefraction", void 0),
  81940. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "volumeIndexOfRefraction", null),
  81941. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertRefractionY", void 0),
  81942. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkRefractionWithTransparency", void 0),
  81943. k([Ce()], t.prototype, "minimumThickness", void 0),
  81944. k([Ce()], t.prototype, "maximumThickness", void 0),
  81945. k([Ce()], t.prototype, "useThicknessAsDepth", void 0),
  81946. k([Me()], t.prototype, "tintColor", void 0),
  81947. k([Ce()], t.prototype, "tintColorAtDistance", void 0),
  81948. k([Me()], t.prototype, "diffusionDistance", void 0),
  81949. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMaskFromThicknessTexture", void 0),
  81950. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionIntensityTexture", void 0),
  81951. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "translucencyIntensityTexture", void 0),
  81952. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGltfStyleTextures", void 0),
  81953. t
  81954. }(Rs)
  81955. , ip = {
  81956. effect: null,
  81957. subMesh: null
  81958. }
  81959. , np = function(e) {
  81960. function t(t) {
  81961. var i = e.call(this, t) || this;
  81962. return i.PBR = !0,
  81963. i.NUM_SAMPLES = "0",
  81964. i.REALTIME_FILTERING = !1,
  81965. i.MAINUV1 = !1,
  81966. i.MAINUV2 = !1,
  81967. i.MAINUV3 = !1,
  81968. i.MAINUV4 = !1,
  81969. i.MAINUV5 = !1,
  81970. i.MAINUV6 = !1,
  81971. i.UV1 = !1,
  81972. i.UV2 = !1,
  81973. i.UV3 = !1,
  81974. i.UV4 = !1,
  81975. i.UV5 = !1,
  81976. i.UV6 = !1,
  81977. i.ALBEDO = !1,
  81978. i.GAMMAALBEDO = !1,
  81979. i.ALBEDODIRECTUV = 0,
  81980. i.VERTEXCOLOR = !1,
  81981. i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
  81982. i.AMBIENT = !1,
  81983. i.AMBIENTDIRECTUV = 0,
  81984. i.AMBIENTINGRAYSCALE = !1,
  81985. i.OPACITY = !1,
  81986. i.VERTEXALPHA = !1,
  81987. i.OPACITYDIRECTUV = 0,
  81988. i.OPACITYRGB = !1,
  81989. i.ALPHATEST = !1,
  81990. i.DEPTHPREPASS = !1,
  81991. i.ALPHABLEND = !1,
  81992. i.ALPHAFROMALBEDO = !1,
  81993. i.ALPHATESTVALUE = "0.5",
  81994. i.SPECULAROVERALPHA = !1,
  81995. i.RADIANCEOVERALPHA = !1,
  81996. i.ALPHAFRESNEL = !1,
  81997. i.LINEARALPHAFRESNEL = !1,
  81998. i.PREMULTIPLYALPHA = !1,
  81999. i.EMISSIVE = !1,
  82000. i.EMISSIVEDIRECTUV = 0,
  82001. i.GAMMAEMISSIVE = !1,
  82002. i.REFLECTIVITY = !1,
  82003. i.REFLECTIVITY_GAMMA = !1,
  82004. i.REFLECTIVITYDIRECTUV = 0,
  82005. i.SPECULARTERM = !1,
  82006. i.MICROSURFACEFROMREFLECTIVITYMAP = !1,
  82007. i.MICROSURFACEAUTOMATIC = !1,
  82008. i.LODBASEDMICROSFURACE = !1,
  82009. i.MICROSURFACEMAP = !1,
  82010. i.MICROSURFACEMAPDIRECTUV = 0,
  82011. i.METALLICWORKFLOW = !1,
  82012. i.ROUGHNESSSTOREINMETALMAPALPHA = !1,
  82013. i.ROUGHNESSSTOREINMETALMAPGREEN = !1,
  82014. i.METALLNESSSTOREINMETALMAPBLUE = !1,
  82015. i.AOSTOREINMETALMAPRED = !1,
  82016. i.METALLIC_REFLECTANCE = !1,
  82017. i.METALLIC_REFLECTANCE_GAMMA = !1,
  82018. i.METALLIC_REFLECTANCEDIRECTUV = 0,
  82019. i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = !1,
  82020. i.REFLECTANCE = !1,
  82021. i.REFLECTANCE_GAMMA = !1,
  82022. i.REFLECTANCEDIRECTUV = 0,
  82023. i.ENVIRONMENTBRDF = !1,
  82024. i.ENVIRONMENTBRDF_RGBD = !1,
  82025. i.NORMAL = !1,
  82026. i.TANGENT = !1,
  82027. i.BUMP = !1,
  82028. i.BUMPDIRECTUV = 0,
  82029. i.OBJECTSPACE_NORMALMAP = !1,
  82030. i.PARALLAX = !1,
  82031. i.PARALLAXOCCLUSION = !1,
  82032. i.NORMALXYSCALE = !0,
  82033. i.LIGHTMAP = !1,
  82034. i.LIGHTMAPDIRECTUV = 0,
  82035. i.USELIGHTMAPASSHADOWMAP = !1,
  82036. i.GAMMALIGHTMAP = !1,
  82037. i.RGBDLIGHTMAP = !1,
  82038. i.REFLECTION = !1,
  82039. i.REFLECTIONMAP_3D = !1,
  82040. i.REFLECTIONMAP_SPHERICAL = !1,
  82041. i.REFLECTIONMAP_PLANAR = !1,
  82042. i.REFLECTIONMAP_CUBIC = !1,
  82043. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  82044. i.REFLECTIONMAP_PROJECTION = !1,
  82045. i.REFLECTIONMAP_SKYBOX = !1,
  82046. i.REFLECTIONMAP_EXPLICIT = !1,
  82047. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  82048. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  82049. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  82050. i.INVERTCUBICMAP = !1,
  82051. i.USESPHERICALFROMREFLECTIONMAP = !1,
  82052. i.USEIRRADIANCEMAP = !1,
  82053. i.USESPHERICALINVERTEX = !1,
  82054. i.REFLECTIONMAP_OPPOSITEZ = !1,
  82055. i.LODINREFLECTIONALPHA = !1,
  82056. i.GAMMAREFLECTION = !1,
  82057. i.RGBDREFLECTION = !1,
  82058. i.LINEARSPECULARREFLECTION = !1,
  82059. i.RADIANCEOCCLUSION = !1,
  82060. i.HORIZONOCCLUSION = !1,
  82061. i.INSTANCES = !1,
  82062. i.THIN_INSTANCES = !1,
  82063. i.INSTANCESCOLOR = !1,
  82064. i.PREPASS = !1,
  82065. i.PREPASS_IRRADIANCE = !1,
  82066. i.PREPASS_IRRADIANCE_INDEX = -1,
  82067. i.PREPASS_ALBEDO_SQRT = !1,
  82068. i.PREPASS_ALBEDO_SQRT_INDEX = -1,
  82069. i.PREPASS_DEPTH = !1,
  82070. i.PREPASS_DEPTH_INDEX = -1,
  82071. i.PREPASS_NORMAL = !1,
  82072. i.PREPASS_NORMAL_INDEX = -1,
  82073. i.PREPASS_POSITION = !1,
  82074. i.PREPASS_POSITION_INDEX = -1,
  82075. i.PREPASS_VELOCITY = !1,
  82076. i.PREPASS_VELOCITY_INDEX = -1,
  82077. i.PREPASS_REFLECTIVITY = !1,
  82078. i.PREPASS_REFLECTIVITY_INDEX = -1,
  82079. i.SCENE_MRT_COUNT = 0,
  82080. i.NUM_BONE_INFLUENCERS = 0,
  82081. i.BonesPerMesh = 0,
  82082. i.BONETEXTURE = !1,
  82083. i.BONES_VELOCITY_ENABLED = !1,
  82084. i.NONUNIFORMSCALING = !1,
  82085. i.MORPHTARGETS = !1,
  82086. i.MORPHTARGETS_NORMAL = !1,
  82087. i.MORPHTARGETS_TANGENT = !1,
  82088. i.MORPHTARGETS_UV = !1,
  82089. i.NUM_MORPH_INFLUENCERS = 0,
  82090. i.MORPHTARGETS_TEXTURE = !1,
  82091. i.IMAGEPROCESSING = !1,
  82092. i.VIGNETTE = !1,
  82093. i.VIGNETTEBLENDMODEMULTIPLY = !1,
  82094. i.VIGNETTEBLENDMODEOPAQUE = !1,
  82095. i.TONEMAPPING = !1,
  82096. i.TONEMAPPING_ACES = !1,
  82097. i.CONTRAST = !1,
  82098. i.COLORCURVES = !1,
  82099. i.COLORGRADING = !1,
  82100. i.COLORGRADING3D = !1,
  82101. i.SAMPLER3DGREENDEPTH = !1,
  82102. i.SAMPLER3DBGRMAP = !1,
  82103. i.IMAGEPROCESSINGPOSTPROCESS = !1,
  82104. i.SKIPFINALCOLORCLAMP = !1,
  82105. i.EXPOSURE = !1,
  82106. i.MULTIVIEW = !1,
  82107. i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
  82108. i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
  82109. i.USEPHYSICALLIGHTFALLOFF = !1,
  82110. i.USEGLTFLIGHTFALLOFF = !1,
  82111. i.TWOSIDEDLIGHTING = !1,
  82112. i.SHADOWFLOAT = !1,
  82113. i.CLIPPLANE = !1,
  82114. i.CLIPPLANE2 = !1,
  82115. i.CLIPPLANE3 = !1,
  82116. i.CLIPPLANE4 = !1,
  82117. i.CLIPPLANE5 = !1,
  82118. i.CLIPPLANE6 = !1,
  82119. i.POINTSIZE = !1,
  82120. i.FOG = !1,
  82121. i.LOGARITHMICDEPTH = !1,
  82122. i.FORCENORMALFORWARD = !1,
  82123. i.SPECULARAA = !1,
  82124. i.UNLIT = !1,
  82125. i.DEBUGMODE = 0,
  82126. i.rebuild(),
  82127. i
  82128. }
  82129. return U(t, e),
  82130. t.prototype.reset = function() {
  82131. e.prototype.reset.call(this),
  82132. this.ALPHATESTVALUE = "0.5",
  82133. this.PBR = !0,
  82134. this.NORMALXYSCALE = !0
  82135. }
  82136. ,
  82137. t
  82138. }(Si)
  82139. , rp = function(e) {
  82140. function t(i, n) {
  82141. var r = e.call(this, i, n) || this;
  82142. return r._directIntensity = 1,
  82143. r._emissiveIntensity = 1,
  82144. r._environmentIntensity = 1,
  82145. r._specularIntensity = 1,
  82146. r._lightingInfos = new R(r._directIntensity,r._emissiveIntensity,r._environmentIntensity,r._specularIntensity),
  82147. r._disableBumpMap = !1,
  82148. r._albedoTexture = null,
  82149. r._ambientTexture = null,
  82150. r._ambientTextureStrength = 1,
  82151. r._ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  82152. r._opacityTexture = null,
  82153. r._reflectionTexture = null,
  82154. r._emissiveTexture = null,
  82155. r._reflectivityTexture = null,
  82156. r._metallicTexture = null,
  82157. r._metallic = null,
  82158. r._roughness = null,
  82159. r._metallicF0Factor = 1,
  82160. r._metallicReflectanceColor = D.White(),
  82161. r._useOnlyMetallicFromMetallicReflectanceTexture = !1,
  82162. r._metallicReflectanceTexture = null,
  82163. r._reflectanceTexture = null,
  82164. r._microSurfaceTexture = null,
  82165. r._bumpTexture = null,
  82166. r._lightmapTexture = null,
  82167. r._ambientColor = new D(0,0,0),
  82168. r._albedoColor = new D(1,1,1),
  82169. r._reflectivityColor = new D(1,1,1),
  82170. r._reflectionColor = new D(1,1,1),
  82171. r._emissiveColor = new D(0,0,0),
  82172. r._microSurface = .9,
  82173. r._useLightmapAsShadowmap = !1,
  82174. r._useHorizonOcclusion = !0,
  82175. r._useRadianceOcclusion = !0,
  82176. r._useAlphaFromAlbedoTexture = !1,
  82177. r._useSpecularOverAlpha = !0,
  82178. r._useMicroSurfaceFromReflectivityMapAlpha = !1,
  82179. r._useRoughnessFromMetallicTextureAlpha = !0,
  82180. r._useRoughnessFromMetallicTextureGreen = !1,
  82181. r._useMetallnessFromMetallicTextureBlue = !1,
  82182. r._useAmbientOcclusionFromMetallicTextureRed = !1,
  82183. r._useAmbientInGrayScale = !1,
  82184. r._useAutoMicroSurfaceFromReflectivityMap = !1,
  82185. r._lightFalloff = t.LIGHTFALLOFF_PHYSICAL,
  82186. r._useRadianceOverAlpha = !0,
  82187. r._useObjectSpaceNormalMap = !1,
  82188. r._useParallax = !1,
  82189. r._useParallaxOcclusion = !1,
  82190. r._parallaxScaleBias = .05,
  82191. r._disableLighting = !1,
  82192. r._maxSimultaneousLights = 4,
  82193. r._invertNormalMapX = !1,
  82194. r._invertNormalMapY = !1,
  82195. r._twoSidedLighting = !1,
  82196. r._alphaCutOff = .4,
  82197. r._forceAlphaTest = !1,
  82198. r._useAlphaFresnel = !1,
  82199. r._useLinearAlphaFresnel = !1,
  82200. r._environmentBRDFTexture = null,
  82201. r._forceIrradianceInFragment = !1,
  82202. r._realTimeFiltering = !1,
  82203. r._realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW,
  82204. r._forceNormalForward = !1,
  82205. r._enableSpecularAntiAliasing = !1,
  82206. r._imageProcessingObserver = null,
  82207. r._renderTargets = new bi(16),
  82208. r._globalAmbientColor = new D(0,0,0),
  82209. r._useLogarithmicDepth = !1,
  82210. r._unlit = !1,
  82211. r._debugMode = 0,
  82212. r.debugMode = 0,
  82213. r._debugLimit = -1,
  82214. r._debugFactor = 1,
  82215. r._cacheHasRenderTargetTextures = !1,
  82216. r.brdf = new Yd(r),
  82217. r.clearCoat = new Qd(r),
  82218. r.anisotropy = new Zd(r),
  82219. r.sheen = new $d(r),
  82220. r.subSurface = new tp(r),
  82221. r.detailMap = new Ps(r),
  82222. r._attachImageProcessingConfiguration(null),
  82223. r.getRenderTargetTextures = function() {
  82224. return r._renderTargets.reset(),
  82225. vs.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
  82226. r._eventInfo.renderTargets = r._renderTargets,
  82227. r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
  82228. r._renderTargets
  82229. }
  82230. ,
  82231. r._environmentBRDFTexture = Hd(r.getScene()),
  82232. r.prePassConfiguration = new ms,
  82233. r
  82234. }
  82235. return U(t, e),
  82236. Object.defineProperty(t.prototype, "realTimeFiltering", {
  82237. get: function() {
  82238. return this._realTimeFiltering
  82239. },
  82240. set: function(e) {
  82241. this._realTimeFiltering = e,
  82242. this.markAsDirty(a.MATERIAL_TextureDirtyFlag)
  82243. },
  82244. enumerable: !1,
  82245. configurable: !0
  82246. }),
  82247. Object.defineProperty(t.prototype, "realTimeFilteringQuality", {
  82248. get: function() {
  82249. return this._realTimeFilteringQuality
  82250. },
  82251. set: function(e) {
  82252. this._realTimeFilteringQuality = e,
  82253. this.markAsDirty(a.MATERIAL_TextureDirtyFlag)
  82254. },
  82255. enumerable: !1,
  82256. configurable: !0
  82257. }),
  82258. Object.defineProperty(t.prototype, "canRenderToMRT", {
  82259. get: function() {
  82260. return !0
  82261. },
  82262. enumerable: !1,
  82263. configurable: !0
  82264. }),
  82265. t.prototype._attachImageProcessingConfiguration = function(e) {
  82266. var t = this;
  82267. e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  82268. this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
  82269. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
  82270. t._markAllSubMeshesAsImageProcessingDirty()
  82271. }
  82272. ))))
  82273. }
  82274. ,
  82275. Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
  82276. get: function() {
  82277. return !!(vs.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures
  82278. },
  82279. enumerable: !1,
  82280. configurable: !0
  82281. }),
  82282. Object.defineProperty(t.prototype, "isPrePassCapable", {
  82283. get: function() {
  82284. return !this.disableDepthWrite
  82285. },
  82286. enumerable: !1,
  82287. configurable: !0
  82288. }),
  82289. t.prototype.getClassName = function() {
  82290. return "PBRBaseMaterial"
  82291. }
  82292. ,
  82293. Object.defineProperty(t.prototype, "useLogarithmicDepth", {
  82294. get: function() {
  82295. return this._useLogarithmicDepth
  82296. },
  82297. set: function(e) {
  82298. this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported
  82299. },
  82300. enumerable: !1,
  82301. configurable: !0
  82302. }),
  82303. Object.defineProperty(t.prototype, "_disableAlphaBlending", {
  82304. get: function() {
  82305. var e;
  82306. return this._transparencyMode === t.PBRMATERIAL_OPAQUE || this._transparencyMode === t.PBRMATERIAL_ALPHATEST || (null === (e = this.subSurface) || void 0 === e ? void 0 : e.disableAlphaBlending)
  82307. },
  82308. enumerable: !1,
  82309. configurable: !0
  82310. }),
  82311. t.prototype.needAlphaBlending = function() {
  82312. return !this._disableAlphaBlending && (this.alpha < 1 || null != this._opacityTexture || this._shouldUseAlphaFromAlbedoTexture())
  82313. }
  82314. ,
  82315. t.prototype.needAlphaTesting = function() {
  82316. var e;
  82317. return !!this._forceAlphaTest || !(null === (e = this.subSurface) || void 0 === e ? void 0 : e.disableAlphaBlending) && this._hasAlphaChannel() && (null == this._transparencyMode || this._transparencyMode === t.PBRMATERIAL_ALPHATEST)
  82318. }
  82319. ,
  82320. t.prototype._shouldUseAlphaFromAlbedoTexture = function() {
  82321. return null != this._albedoTexture && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== t.PBRMATERIAL_OPAQUE
  82322. }
  82323. ,
  82324. t.prototype._hasAlphaChannel = function() {
  82325. return null != this._albedoTexture && this._albedoTexture.hasAlpha || null != this._opacityTexture
  82326. }
  82327. ,
  82328. t.prototype.getAlphaTestTexture = function() {
  82329. return this._albedoTexture
  82330. }
  82331. ,
  82332. t.prototype.isReadyForSubMesh = function(e, t, i) {
  82333. if (this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
  82334. t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
  82335. return !0;
  82336. t.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
  82337. t.materialDefines = new np(this._eventInfo.defineNames));
  82338. var n = t.materialDefines;
  82339. if (this._isReadyForSubMesh(t))
  82340. return !0;
  82341. var r = this.getScene()
  82342. , o = r.getEngine();
  82343. if (n._areTexturesDirty && (this._eventInfo.hasRenderTargetTextures = !1,
  82344. this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
  82345. this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures,
  82346. r.texturesEnabled)) {
  82347. if (this._albedoTexture && vs.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking())
  82348. return !1;
  82349. if (this._ambientTexture && vs.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking())
  82350. return !1;
  82351. if (this._opacityTexture && vs.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
  82352. return !1;
  82353. var a = this._getReflectionTexture();
  82354. if (a && vs.ReflectionTextureEnabled) {
  82355. if (!a.isReadyOrNotBlocking())
  82356. return !1;
  82357. if (a.irradianceTexture && !a.irradianceTexture.isReadyOrNotBlocking())
  82358. return !1
  82359. }
  82360. if (this._lightmapTexture && vs.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking())
  82361. return !1;
  82362. if (this._emissiveTexture && vs.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
  82363. return !1;
  82364. if (vs.SpecularTextureEnabled) {
  82365. if (this._metallicTexture) {
  82366. if (!this._metallicTexture.isReadyOrNotBlocking())
  82367. return !1
  82368. } else if (this._reflectivityTexture && !this._reflectivityTexture.isReadyOrNotBlocking())
  82369. return !1;
  82370. if (this._metallicReflectanceTexture && !this._metallicReflectanceTexture.isReadyOrNotBlocking())
  82371. return !1;
  82372. if (this._reflectanceTexture && !this._reflectanceTexture.isReadyOrNotBlocking())
  82373. return !1;
  82374. if (this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
  82375. return !1
  82376. }
  82377. if (o.getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady())
  82378. return !1;
  82379. if (this._environmentBRDFTexture && vs.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
  82380. return !1
  82381. }
  82382. if (this._eventInfo.isReadyForSubMesh = !0,
  82383. this._eventInfo.defines = n,
  82384. this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
  82385. !this._eventInfo.isReadyForSubMesh)
  82386. return !1;
  82387. if (n._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
  82388. return !1;
  82389. o.getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
  82390. K.Warn("PBRMaterial: Normals have been created for the mesh: " + e.name));
  82391. var s = t.effect
  82392. , l = n._areLightsDisposed
  82393. , c = this._prepareEffect(e, n, this.onCompiled, this.onError, i, null, t.getRenderingMesh().hasThinInstances);
  82394. if (c)
  82395. if (this._onEffectCreatedObservable && (ip.effect = c,
  82396. ip.subMesh = t,
  82397. this._onEffectCreatedObservable.notifyObservers(ip)),
  82398. this.allowShaderHotSwapping && s && !c.isReady()) {
  82399. if (c = s,
  82400. n.markAsUnprocessed(),
  82401. l)
  82402. return n._areLightsDisposed = !0,
  82403. !1
  82404. } else
  82405. r.resetCachedMaterial(),
  82406. t.setEffect(c, n, this._materialContext);
  82407. return !(!t.effect || !t.effect.isReady() || (n._renderId = r.getRenderId(),
  82408. t.effect._wasPreviouslyReady = !0,
  82409. 0))
  82410. }
  82411. ,
  82412. t.prototype.isMetallicWorkflow = function() {
  82413. return !(null == this._metallic && null == this._roughness && !this._metallicTexture)
  82414. }
  82415. ,
  82416. t.prototype._prepareEffect = function(e, t, i, n, r, o, s) {
  82417. if (void 0 === i && (i = null),
  82418. void 0 === n && (n = null),
  82419. void 0 === r && (r = null),
  82420. void 0 === o && (o = null),
  82421. this._prepareDefines(e, t, r, o, s),
  82422. !t.isDirty)
  82423. return null;
  82424. t.markAsProcessed();
  82425. var l = this.getScene().getEngine()
  82426. , c = new ys
  82427. , u = 0;
  82428. t.USESPHERICALINVERTEX && c.addFallback(u++, "USESPHERICALINVERTEX"),
  82429. t.FOG && c.addFallback(u, "FOG"),
  82430. t.SPECULARAA && c.addFallback(u, "SPECULARAA"),
  82431. t.POINTSIZE && c.addFallback(u, "POINTSIZE"),
  82432. t.LOGARITHMICDEPTH && c.addFallback(u, "LOGARITHMICDEPTH"),
  82433. t.PARALLAX && c.addFallback(u, "PARALLAX"),
  82434. t.PARALLAXOCCLUSION && c.addFallback(u++, "PARALLAXOCCLUSION"),
  82435. t.ENVIRONMENTBRDF && c.addFallback(u++, "ENVIRONMENTBRDF"),
  82436. t.TANGENT && c.addFallback(u++, "TANGENT"),
  82437. t.BUMP && c.addFallback(u++, "BUMP"),
  82438. u = Mr.HandleFallbacksForShadows(t, c, this._maxSimultaneousLights, u++),
  82439. t.SPECULARTERM && c.addFallback(u++, "SPECULARTERM"),
  82440. t.USESPHERICALFROMREFLECTIONMAP && c.addFallback(u++, "USESPHERICALFROMREFLECTIONMAP"),
  82441. t.USEIRRADIANCEMAP && c.addFallback(u++, "USEIRRADIANCEMAP"),
  82442. t.LIGHTMAP && c.addFallback(u++, "LIGHTMAP"),
  82443. t.NORMAL && c.addFallback(u++, "NORMAL"),
  82444. t.AMBIENT && c.addFallback(u++, "AMBIENT"),
  82445. t.EMISSIVE && c.addFallback(u++, "EMISSIVE"),
  82446. t.VERTEXCOLOR && c.addFallback(u++, "VERTEXCOLOR"),
  82447. t.MORPHTARGETS && c.addFallback(u++, "MORPHTARGETS"),
  82448. t.MULTIVIEW && c.addFallback(0, "MULTIVIEW");
  82449. var h = [Bi.PositionKind];
  82450. t.NORMAL && h.push(Bi.NormalKind),
  82451. t.TANGENT && h.push(Bi.TangentKind);
  82452. for (var d = 1; d <= a.MAX_SUPPORTED_UV_SETS; ++d)
  82453. t["UV" + d] && h.push("uv".concat(1 === d ? "" : d));
  82454. t.VERTEXCOLOR && h.push(Bi.ColorKind),
  82455. Mr.PrepareAttributesForBones(h, e, t, c),
  82456. Mr.PrepareAttributesForInstances(h, t),
  82457. Mr.PrepareAttributesForMorphTargets(h, e, t),
  82458. Mr.PrepareAttributesForBakedVertexAnimation(h, e, t);
  82459. var p = "pbr"
  82460. , f = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vMetallicReflectanceFactors", "vEmissiveColor", "visibility", "vReflectionColor", "vFogInfos", "vFogColor", "pointSize", "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos", "vReflectionFilteringInfo", "vMetallicReflectanceInfos", "vReflectanceInfos", "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "metallicReflectanceMatrix", "reflectanceMatrix", "vLightingIntensity", "logarithmicDepthConstant", "vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vSphericalL00", "vSphericalL1_1", "vSphericalL10", "vSphericalL11", "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22", "vReflectionMicrosurfaceInfos", "vTangentSpaceParams", "boneTextureWidth", "vDebugMode", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  82461. , _ = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler", "reflectanceSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
  82462. , m = ["Material", "Scene", "Mesh"];
  82463. this._eventInfo.fallbacks = c,
  82464. this._eventInfo.fallbackRank = u,
  82465. this._eventInfo.defines = t,
  82466. this._eventInfo.uniforms = f,
  82467. this._eventInfo.samplers = _,
  82468. this._eventInfo.uniformBuffersNames = m,
  82469. this._eventInfo.customCode = void 0,
  82470. this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
  82471. ms.AddUniforms(f),
  82472. ms.AddSamplers(_),
  82473. Ri && (Ri.PrepareUniforms(f, t),
  82474. Ri.PrepareSamplers(_, t)),
  82475. Mr.PrepareUniformsAndSamplersList({
  82476. uniformsNames: f,
  82477. uniformBuffersNames: m,
  82478. samplers: _,
  82479. defines: t,
  82480. maxSimultaneousLights: this._maxSimultaneousLights
  82481. });
  82482. var g = {};
  82483. this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, t, h, g));
  82484. var v = t.toString();
  82485. return l.createEffect(p, {
  82486. attributes: h,
  82487. uniformsNames: f,
  82488. uniformBuffersNames: m,
  82489. samplers: _,
  82490. defines: v,
  82491. fallbacks: c,
  82492. onCompiled: i,
  82493. onError: n,
  82494. indexParameters: {
  82495. maxSimultaneousLights: this._maxSimultaneousLights,
  82496. maxSimultaneousMorphTargets: t.NUM_MORPH_INFLUENCERS
  82497. },
  82498. processFinalCode: g.processFinalCode,
  82499. processCodeAfterIncludes: this._eventInfo.customCode,
  82500. multiTarget: t.PREPASS
  82501. }, l)
  82502. }
  82503. ,
  82504. t.prototype._prepareDefines = function(e, i, n, r, o) {
  82505. var s;
  82506. void 0 === n && (n = null),
  82507. void 0 === r && (r = null),
  82508. void 0 === o && (o = !1);
  82509. var l = this.getScene()
  82510. , c = l.getEngine();
  82511. Mr.PrepareDefinesForLights(l, e, i, !0, this._maxSimultaneousLights, this._disableLighting),
  82512. i._needNormals = !0,
  82513. Mr.PrepareDefinesForMultiview(l, i);
  82514. var u = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
  82515. if (Mr.PrepareDefinesForPrePass(l, i, this.canRenderToMRT && !u),
  82516. Mr.PrepareDefinesForOIT(l, i, u),
  82517. i.METALLICWORKFLOW = this.isMetallicWorkflow(),
  82518. i._areTexturesDirty) {
  82519. if (i._needUVs = !1,
  82520. l.texturesEnabled) {
  82521. l.getEngine().getCaps().textureLOD && (i.LODBASEDMICROSFURACE = !0),
  82522. this._albedoTexture && vs.DiffuseTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._albedoTexture, i, "ALBEDO"),
  82523. i.GAMMAALBEDO = this._albedoTexture.gammaSpace) : i.ALBEDO = !1,
  82524. this._ambientTexture && vs.AmbientTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._ambientTexture, i, "AMBIENT"),
  82525. i.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : i.AMBIENT = !1,
  82526. this._opacityTexture && vs.OpacityTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._opacityTexture, i, "OPACITY"),
  82527. i.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : i.OPACITY = !1;
  82528. var h = this._getReflectionTexture();
  82529. if (h && vs.ReflectionTextureEnabled) {
  82530. switch (i.REFLECTION = !0,
  82531. i.GAMMAREFLECTION = h.gammaSpace,
  82532. i.RGBDREFLECTION = h.isRGBD,
  82533. i.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !h.invertZ : h.invertZ,
  82534. i.LODINREFLECTIONALPHA = h.lodLevelInAlpha,
  82535. i.LINEARSPECULARREFLECTION = h.linearSpecularLOD,
  82536. this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (i.NUM_SAMPLES = "" + this.realTimeFilteringQuality,
  82537. c._features.needTypeSuffixInShaderConstants && (i.NUM_SAMPLES = i.NUM_SAMPLES + "u"),
  82538. i.REALTIME_FILTERING = !0) : i.REALTIME_FILTERING = !1,
  82539. h.coordinatesMode === io.INVCUBIC_MODE && (i.INVERTCUBICMAP = !0),
  82540. i.REFLECTIONMAP_3D = h.isCube,
  82541. i.REFLECTIONMAP_CUBIC = !1,
  82542. i.REFLECTIONMAP_EXPLICIT = !1,
  82543. i.REFLECTIONMAP_PLANAR = !1,
  82544. i.REFLECTIONMAP_PROJECTION = !1,
  82545. i.REFLECTIONMAP_SKYBOX = !1,
  82546. i.REFLECTIONMAP_SPHERICAL = !1,
  82547. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  82548. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  82549. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  82550. h.coordinatesMode) {
  82551. case io.EXPLICIT_MODE:
  82552. i.REFLECTIONMAP_EXPLICIT = !0;
  82553. break;
  82554. case io.PLANAR_MODE:
  82555. i.REFLECTIONMAP_PLANAR = !0;
  82556. break;
  82557. case io.PROJECTION_MODE:
  82558. i.REFLECTIONMAP_PROJECTION = !0;
  82559. break;
  82560. case io.SKYBOX_MODE:
  82561. i.REFLECTIONMAP_SKYBOX = !0;
  82562. break;
  82563. case io.SPHERICAL_MODE:
  82564. i.REFLECTIONMAP_SPHERICAL = !0;
  82565. break;
  82566. case io.EQUIRECTANGULAR_MODE:
  82567. i.REFLECTIONMAP_EQUIRECTANGULAR = !0;
  82568. break;
  82569. case io.FIXED_EQUIRECTANGULAR_MODE:
  82570. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
  82571. break;
  82572. case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  82573. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
  82574. break;
  82575. case io.CUBIC_MODE:
  82576. case io.INVCUBIC_MODE:
  82577. default:
  82578. i.REFLECTIONMAP_CUBIC = !0,
  82579. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !!h.boundingBoxSize
  82580. }
  82581. h.coordinatesMode !== io.SKYBOX_MODE && (h.irradianceTexture ? (i.USEIRRADIANCEMAP = !0,
  82582. i.USESPHERICALFROMREFLECTIONMAP = !1) : h.isCube && (i.USESPHERICALFROMREFLECTIONMAP = !0,
  82583. i.USEIRRADIANCEMAP = !1,
  82584. this._forceIrradianceInFragment || this.realTimeFiltering || l.getEngine().getCaps().maxVaryingVectors <= 8 ? i.USESPHERICALINVERTEX = !1 : i.USESPHERICALINVERTEX = !0))
  82585. } else
  82586. i.REFLECTION = !1,
  82587. i.REFLECTIONMAP_3D = !1,
  82588. i.REFLECTIONMAP_SPHERICAL = !1,
  82589. i.REFLECTIONMAP_PLANAR = !1,
  82590. i.REFLECTIONMAP_CUBIC = !1,
  82591. i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
  82592. i.REFLECTIONMAP_PROJECTION = !1,
  82593. i.REFLECTIONMAP_SKYBOX = !1,
  82594. i.REFLECTIONMAP_EXPLICIT = !1,
  82595. i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
  82596. i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
  82597. i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
  82598. i.INVERTCUBICMAP = !1,
  82599. i.USESPHERICALFROMREFLECTIONMAP = !1,
  82600. i.USEIRRADIANCEMAP = !1,
  82601. i.USESPHERICALINVERTEX = !1,
  82602. i.REFLECTIONMAP_OPPOSITEZ = !1,
  82603. i.LODINREFLECTIONALPHA = !1,
  82604. i.GAMMAREFLECTION = !1,
  82605. i.RGBDREFLECTION = !1,
  82606. i.LINEARSPECULARREFLECTION = !1;
  82607. if (this._lightmapTexture && vs.LightmapTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._lightmapTexture, i, "LIGHTMAP"),
  82608. i.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
  82609. i.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace,
  82610. i.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : i.LIGHTMAP = !1,
  82611. this._emissiveTexture && vs.EmissiveTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._emissiveTexture, i, "EMISSIVE"),
  82612. i.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : i.EMISSIVE = !1,
  82613. vs.SpecularTextureEnabled) {
  82614. if (this._metallicTexture ? (Mr.PrepareDefinesForMergedUV(this._metallicTexture, i, "REFLECTIVITY"),
  82615. i.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha,
  82616. i.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen,
  82617. i.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue,
  82618. i.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed,
  82619. i.REFLECTIVITY_GAMMA = !1) : this._reflectivityTexture ? (Mr.PrepareDefinesForMergedUV(this._reflectivityTexture, i, "REFLECTIVITY"),
  82620. i.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha,
  82621. i.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap,
  82622. i.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace) : i.REFLECTIVITY = !1,
  82623. this._metallicReflectanceTexture || this._reflectanceTexture) {
  82624. var d = null !== this._metallicReflectanceTexture && this._metallicReflectanceTexture._texture === (null === (s = this._reflectanceTexture) || void 0 === s ? void 0 : s._texture) && this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);
  82625. i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture && !d,
  82626. this._metallicReflectanceTexture ? (Mr.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, i, "METALLIC_REFLECTANCE"),
  82627. i.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : i.METALLIC_REFLECTANCE = !1,
  82628. this._reflectanceTexture && !d && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (Mr.PrepareDefinesForMergedUV(this._reflectanceTexture, i, "REFLECTANCE"),
  82629. i.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : i.REFLECTANCE = !1
  82630. } else
  82631. i.METALLIC_REFLECTANCE = !1,
  82632. i.REFLECTANCE = !1;
  82633. this._microSurfaceTexture ? Mr.PrepareDefinesForMergedUV(this._microSurfaceTexture, i, "MICROSURFACEMAP") : i.MICROSURFACEMAP = !1
  82634. } else
  82635. i.REFLECTIVITY = !1,
  82636. i.MICROSURFACEMAP = !1;
  82637. l.getEngine().getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap ? (Mr.PrepareDefinesForMergedUV(this._bumpTexture, i, "BUMP"),
  82638. this._useParallax && this._albedoTexture && vs.DiffuseTextureEnabled ? (i.PARALLAX = !0,
  82639. i.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : i.PARALLAX = !1,
  82640. i.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : i.BUMP = !1,
  82641. this._environmentBRDFTexture && vs.ReflectionTextureEnabled ? (i.ENVIRONMENTBRDF = !0,
  82642. i.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (i.ENVIRONMENTBRDF = !1,
  82643. i.ENVIRONMENTBRDF_RGBD = !1),
  82644. this._shouldUseAlphaFromAlbedoTexture() ? i.ALPHAFROMALBEDO = !0 : i.ALPHAFROMALBEDO = !1
  82645. }
  82646. i.SPECULAROVERALPHA = this._useSpecularOverAlpha,
  82647. this._lightFalloff === t.LIGHTFALLOFF_STANDARD ? (i.USEPHYSICALLIGHTFALLOFF = !1,
  82648. i.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === t.LIGHTFALLOFF_GLTF ? (i.USEPHYSICALLIGHTFALLOFF = !1,
  82649. i.USEGLTFLIGHTFALLOFF = !0) : (i.USEPHYSICALLIGHTFALLOFF = !0,
  82650. i.USEGLTFLIGHTFALLOFF = !1),
  82651. i.RADIANCEOVERALPHA = this._useRadianceOverAlpha,
  82652. !this.backFaceCulling && this._twoSidedLighting ? i.TWOSIDEDLIGHTING = !0 : i.TWOSIDEDLIGHTING = !1,
  82653. i.SPECULARAA = l.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing
  82654. }
  82655. (i._areTexturesDirty || i._areMiscDirty) && (i.ALPHATESTVALUE = "".concat(this._alphaCutOff).concat(this._alphaCutOff % 1 == 0 ? "." : ""),
  82656. i.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
  82657. i.ALPHABLEND = this.needAlphaBlendingForMesh(e),
  82658. i.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel,
  82659. i.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel),
  82660. i._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(i),
  82661. i.FORCENORMALFORWARD = this._forceNormalForward,
  82662. i.RADIANCEOCCLUSION = this._useRadianceOcclusion,
  82663. i.HORIZONOCCLUSION = this._useHorizonOcclusion,
  82664. i._areMiscDirty && (Mr.PrepareDefinesForMisc(e, l, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, i),
  82665. i.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !e.isVerticesDataPresent(Bi.NormalKind),
  82666. i.DEBUGMODE = this._debugMode),
  82667. this._eventInfo.defines = i,
  82668. this._eventInfo.mesh = e,
  82669. this._callbackPluginEventPrepareDefines(this._eventInfo),
  82670. Mr.PrepareDefinesForFrameBoundValues(l, c, i, !!n, r, o),
  82671. Mr.PrepareDefinesForAttributes(e, i, !0, !0, !0, this._transparencyMode !== t.PBRMATERIAL_OPAQUE)
  82672. }
  82673. ,
  82674. t.prototype.forceCompilation = function(e, t, i) {
  82675. var n = this
  82676. , r = V({
  82677. clipPlane: !1,
  82678. useInstances: !1
  82679. }, i);
  82680. this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
  82681. this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo);
  82682. var o = new np(this._eventInfo.defineNames)
  82683. , a = this._prepareEffect(e, o, void 0, void 0, r.useInstances, r.clipPlane, e.hasThinInstances);
  82684. this._onEffectCreatedObservable && (ip.effect = a,
  82685. ip.subMesh = null,
  82686. this._onEffectCreatedObservable.notifyObservers(ip)),
  82687. a.isReady() ? t && t(this) : a.onCompileObservable.add((function() {
  82688. t && t(n)
  82689. }
  82690. ))
  82691. }
  82692. ,
  82693. t.prototype.buildUniformLayout = function() {
  82694. var t = this._uniformBuffer;
  82695. t.addUniform("vAlbedoInfos", 2),
  82696. t.addUniform("vAmbientInfos", 4),
  82697. t.addUniform("vOpacityInfos", 2),
  82698. t.addUniform("vEmissiveInfos", 2),
  82699. t.addUniform("vLightmapInfos", 2),
  82700. t.addUniform("vReflectivityInfos", 3),
  82701. t.addUniform("vMicroSurfaceSamplerInfos", 2),
  82702. t.addUniform("vReflectionInfos", 2),
  82703. t.addUniform("vReflectionFilteringInfo", 2),
  82704. t.addUniform("vReflectionPosition", 3),
  82705. t.addUniform("vReflectionSize", 3),
  82706. t.addUniform("vBumpInfos", 3),
  82707. t.addUniform("albedoMatrix", 16),
  82708. t.addUniform("ambientMatrix", 16),
  82709. t.addUniform("opacityMatrix", 16),
  82710. t.addUniform("emissiveMatrix", 16),
  82711. t.addUniform("lightmapMatrix", 16),
  82712. t.addUniform("reflectivityMatrix", 16),
  82713. t.addUniform("microSurfaceSamplerMatrix", 16),
  82714. t.addUniform("bumpMatrix", 16),
  82715. t.addUniform("vTangentSpaceParams", 2),
  82716. t.addUniform("reflectionMatrix", 16),
  82717. t.addUniform("vReflectionColor", 3),
  82718. t.addUniform("vAlbedoColor", 4),
  82719. t.addUniform("vLightingIntensity", 4),
  82720. t.addUniform("vReflectionMicrosurfaceInfos", 3),
  82721. t.addUniform("pointSize", 1),
  82722. t.addUniform("vReflectivityColor", 4),
  82723. t.addUniform("vEmissiveColor", 3),
  82724. t.addUniform("vAmbientColor", 3),
  82725. t.addUniform("vDebugMode", 2),
  82726. t.addUniform("vMetallicReflectanceFactors", 4),
  82727. t.addUniform("vMetallicReflectanceInfos", 2),
  82728. t.addUniform("metallicReflectanceMatrix", 16),
  82729. t.addUniform("vReflectanceInfos", 2),
  82730. t.addUniform("reflectanceMatrix", 16),
  82731. t.addUniform("vSphericalL00", 3),
  82732. t.addUniform("vSphericalL1_1", 3),
  82733. t.addUniform("vSphericalL10", 3),
  82734. t.addUniform("vSphericalL11", 3),
  82735. t.addUniform("vSphericalL2_2", 3),
  82736. t.addUniform("vSphericalL2_1", 3),
  82737. t.addUniform("vSphericalL20", 3),
  82738. t.addUniform("vSphericalL21", 3),
  82739. t.addUniform("vSphericalL22", 3),
  82740. t.addUniform("vSphericalX", 3),
  82741. t.addUniform("vSphericalY", 3),
  82742. t.addUniform("vSphericalZ", 3),
  82743. t.addUniform("vSphericalXX_ZZ", 3),
  82744. t.addUniform("vSphericalYY_ZZ", 3),
  82745. t.addUniform("vSphericalZZ", 3),
  82746. t.addUniform("vSphericalXY", 3),
  82747. t.addUniform("vSphericalYZ", 3),
  82748. t.addUniform("vSphericalZX", 3),
  82749. e.prototype.buildUniformLayout.call(this)
  82750. }
  82751. ,
  82752. t.prototype.bindForSubMesh = function(e, t, i) {
  82753. var n, r, o, a, s = this.getScene(), l = i.materialDefines;
  82754. if (l) {
  82755. var c = i.effect;
  82756. if (c) {
  82757. this._activeEffect = c,
  82758. t.getMeshUniformBuffer().bindToEffect(c, "Mesh"),
  82759. t.transferToEffect(e);
  82760. var u = s.getEngine();
  82761. this._uniformBuffer.bindToEffect(c, "Material"),
  82762. this.prePassConfiguration.bindForSubMesh(this._activeEffect, s, t, e, this.isFrozen),
  82763. this._eventInfo.subMesh = i,
  82764. this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
  82765. l.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
  82766. this.bindOnlyNormalMatrix(this._normalMatrix));
  82767. var h = this._mustRebind(s, c, t.visibility);
  82768. Mr.BindBonesParameters(t, this._activeEffect, this.prePassConfiguration);
  82769. var p = null
  82770. , f = this._uniformBuffer;
  82771. if (h) {
  82772. if (this.bindViewProjection(c),
  82773. p = this._getReflectionTexture(),
  82774. !f.useUbo || !this.isFrozen || !f.isSync) {
  82775. if (s.texturesEnabled) {
  82776. if (this._albedoTexture && vs.DiffuseTextureEnabled && (f.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level),
  82777. Mr.BindTextureMatrix(this._albedoTexture, f, "albedo")),
  82778. this._ambientTexture && vs.AmbientTextureEnabled && (f.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights),
  82779. Mr.BindTextureMatrix(this._ambientTexture, f, "ambient")),
  82780. this._opacityTexture && vs.OpacityTextureEnabled && (f.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
  82781. Mr.BindTextureMatrix(this._opacityTexture, f, "opacity")),
  82782. p && vs.ReflectionTextureEnabled) {
  82783. if (f.updateMatrix("reflectionMatrix", p.getReflectionTextureMatrix()),
  82784. f.updateFloat2("vReflectionInfos", p.level, 0),
  82785. p.boundingBoxSize) {
  82786. var _ = p;
  82787. f.updateVector3("vReflectionPosition", _.boundingBoxPosition),
  82788. f.updateVector3("vReflectionSize", _.boundingBoxSize)
  82789. }
  82790. if (this.realTimeFiltering) {
  82791. var m = p.getSize().width;
  82792. f.updateFloat2("vReflectionFilteringInfo", m, d.Log2(m))
  82793. }
  82794. if (!l.USEIRRADIANCEMAP) {
  82795. var g = p.sphericalPolynomial;
  82796. if (l.USESPHERICALFROMREFLECTIONMAP && g)
  82797. if (l.SPHERICAL_HARMONICS) {
  82798. var v = g.preScaledHarmonics;
  82799. f.updateVector3("vSphericalL00", v.l00),
  82800. f.updateVector3("vSphericalL1_1", v.l1_1),
  82801. f.updateVector3("vSphericalL10", v.l10),
  82802. f.updateVector3("vSphericalL11", v.l11),
  82803. f.updateVector3("vSphericalL2_2", v.l2_2),
  82804. f.updateVector3("vSphericalL2_1", v.l2_1),
  82805. f.updateVector3("vSphericalL20", v.l20),
  82806. f.updateVector3("vSphericalL21", v.l21),
  82807. f.updateVector3("vSphericalL22", v.l22)
  82808. } else
  82809. f.updateFloat3("vSphericalX", g.x.x, g.x.y, g.x.z),
  82810. f.updateFloat3("vSphericalY", g.y.x, g.y.y, g.y.z),
  82811. f.updateFloat3("vSphericalZ", g.z.x, g.z.y, g.z.z),
  82812. f.updateFloat3("vSphericalXX_ZZ", g.xx.x - g.zz.x, g.xx.y - g.zz.y, g.xx.z - g.zz.z),
  82813. f.updateFloat3("vSphericalYY_ZZ", g.yy.x - g.zz.x, g.yy.y - g.zz.y, g.yy.z - g.zz.z),
  82814. f.updateFloat3("vSphericalZZ", g.zz.x, g.zz.y, g.zz.z),
  82815. f.updateFloat3("vSphericalXY", g.xy.x, g.xy.y, g.xy.z),
  82816. f.updateFloat3("vSphericalYZ", g.yz.x, g.yz.y, g.yz.z),
  82817. f.updateFloat3("vSphericalZX", g.zx.x, g.zx.y, g.zx.z)
  82818. }
  82819. f.updateFloat3("vReflectionMicrosurfaceInfos", p.getSize().width, p.lodGenerationScale, p.lodGenerationOffset)
  82820. }
  82821. this._emissiveTexture && vs.EmissiveTextureEnabled && (f.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
  82822. Mr.BindTextureMatrix(this._emissiveTexture, f, "emissive")),
  82823. this._lightmapTexture && vs.LightmapTextureEnabled && (f.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
  82824. Mr.BindTextureMatrix(this._lightmapTexture, f, "lightmap")),
  82825. vs.SpecularTextureEnabled && (this._metallicTexture ? (f.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength),
  82826. Mr.BindTextureMatrix(this._metallicTexture, f, "reflectivity")) : this._reflectivityTexture && (f.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1),
  82827. Mr.BindTextureMatrix(this._reflectivityTexture, f, "reflectivity")),
  82828. this._metallicReflectanceTexture && (f.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level),
  82829. Mr.BindTextureMatrix(this._metallicReflectanceTexture, f, "metallicReflectance")),
  82830. this._reflectanceTexture && l.REFLECTANCE && (f.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level),
  82831. Mr.BindTextureMatrix(this._reflectanceTexture, f, "reflectance")),
  82832. this._microSurfaceTexture && (f.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level),
  82833. Mr.BindTextureMatrix(this._microSurfaceTexture, f, "microSurfaceSampler"))),
  82834. this._bumpTexture && u.getCaps().standardDerivatives && vs.BumpTextureEnabled && !this._disableBumpMap && (f.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias),
  82835. Mr.BindTextureMatrix(this._bumpTexture, f, "bump"),
  82836. s._mirroredCameraPosition ? f.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : f.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1))
  82837. }
  82838. if (this.pointsCloud && f.updateFloat("pointSize", this.pointSize),
  82839. l.METALLICWORKFLOW) {
  82840. L.Color3[0].r = void 0 === this._metallic || null === this._metallic ? 1 : this._metallic,
  82841. L.Color3[0].g = void 0 === this._roughness || null === this._roughness ? 1 : this._roughness,
  82842. f.updateColor4("vReflectivityColor", L.Color3[0], 1);
  82843. var y = null !== (r = null === (n = this.subSurface) || void 0 === n ? void 0 : n._indexOfRefraction) && void 0 !== r ? r : 1.5
  82844. , b = Math.pow((y - 1) / (y + 1), 2);
  82845. this._metallicReflectanceColor.scaleToRef(b * this._metallicF0Factor, L.Color3[0]);
  82846. var T = this._metallicF0Factor;
  82847. f.updateColor4("vMetallicReflectanceFactors", L.Color3[0], T)
  82848. } else
  82849. f.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  82850. f.updateColor3("vEmissiveColor", vs.EmissiveTextureEnabled ? this._emissiveColor : D.BlackReadOnly),
  82851. f.updateColor3("vReflectionColor", this._reflectionColor),
  82852. !l.SS_REFRACTION && (null === (o = this.subSurface) || void 0 === o ? void 0 : o._linkRefractionWithTransparency) ? f.updateColor4("vAlbedoColor", this._albedoColor, 1) : f.updateColor4("vAlbedoColor", this._albedoColor, this.alpha),
  82853. this._lightingInfos.x = this._directIntensity,
  82854. this._lightingInfos.y = this._emissiveIntensity,
  82855. this._lightingInfos.z = this._environmentIntensity * s.environmentIntensity,
  82856. this._lightingInfos.w = this._specularIntensity,
  82857. f.updateVector4("vLightingIntensity", this._lightingInfos),
  82858. s.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor),
  82859. f.updateColor3("vAmbientColor", this._globalAmbientColor),
  82860. f.updateFloat2("vDebugMode", this._debugLimit, this._debugFactor)
  82861. }
  82862. s.texturesEnabled && (this._albedoTexture && vs.DiffuseTextureEnabled && f.setTexture("albedoSampler", this._albedoTexture),
  82863. this._ambientTexture && vs.AmbientTextureEnabled && f.setTexture("ambientSampler", this._ambientTexture),
  82864. this._opacityTexture && vs.OpacityTextureEnabled && f.setTexture("opacitySampler", this._opacityTexture),
  82865. p && vs.ReflectionTextureEnabled && (l.LODBASEDMICROSFURACE ? f.setTexture("reflectionSampler", p) : (f.setTexture("reflectionSampler", p._lodTextureMid || p),
  82866. f.setTexture("reflectionSamplerLow", p._lodTextureLow || p),
  82867. f.setTexture("reflectionSamplerHigh", p._lodTextureHigh || p)),
  82868. l.USEIRRADIANCEMAP && f.setTexture("irradianceSampler", p.irradianceTexture)),
  82869. l.ENVIRONMENTBRDF && f.setTexture("environmentBrdfSampler", this._environmentBRDFTexture),
  82870. this._emissiveTexture && vs.EmissiveTextureEnabled && f.setTexture("emissiveSampler", this._emissiveTexture),
  82871. this._lightmapTexture && vs.LightmapTextureEnabled && f.setTexture("lightmapSampler", this._lightmapTexture),
  82872. vs.SpecularTextureEnabled && (this._metallicTexture ? f.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && f.setTexture("reflectivitySampler", this._reflectivityTexture),
  82873. this._metallicReflectanceTexture && f.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture),
  82874. this._reflectanceTexture && l.REFLECTANCE && f.setTexture("reflectanceSampler", this._reflectanceTexture),
  82875. this._microSurfaceTexture && f.setTexture("microSurfaceSampler", this._microSurfaceTexture)),
  82876. this._bumpTexture && u.getCaps().standardDerivatives && vs.BumpTextureEnabled && !this._disableBumpMap && f.setTexture("bumpSampler", this._bumpTexture)),
  82877. this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(t) && this.getScene().depthPeelingRenderer.bind(c),
  82878. this._eventInfo.subMesh = i,
  82879. this._callbackPluginEventBindForSubMesh(this._eventInfo),
  82880. Mr.BindClipPlane(this._activeEffect, s),
  82881. this.bindEyePosition(c)
  82882. } else
  82883. s.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
  82884. !h && this.isFrozen || (s.lightsEnabled && !this._disableLighting && Mr.BindLights(s, t, this._activeEffect, l, this._maxSimultaneousLights),
  82885. (s.fogEnabled && t.applyFog && s.fogMode !== mn.FOGMODE_NONE || p || t.receiveShadows) && this.bindView(c),
  82886. Mr.BindFogParameters(s, t, this._activeEffect, !0),
  82887. l.NUM_MORPH_INFLUENCERS && Mr.BindMorphTargetParameters(t, this._activeEffect),
  82888. l.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (a = t.bakedVertexAnimationManager) || void 0 === a || a.bind(c, l.INSTANCES)),
  82889. this._imageProcessingConfiguration.bind(this._activeEffect),
  82890. Mr.BindLogDepth(l, this._activeEffect, s)),
  82891. this._afterBind(t, this._activeEffect),
  82892. f.update()
  82893. }
  82894. }
  82895. }
  82896. ,
  82897. t.prototype.getAnimatables = function() {
  82898. var t = e.prototype.getAnimatables.call(this);
  82899. return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && t.push(this._albedoTexture),
  82900. this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && t.push(this._ambientTexture),
  82901. this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && t.push(this._opacityTexture),
  82902. this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && t.push(this._reflectionTexture),
  82903. this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && t.push(this._emissiveTexture),
  82904. this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0 ? t.push(this._metallicTexture) : this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0 && t.push(this._reflectivityTexture),
  82905. this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture),
  82906. this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && t.push(this._lightmapTexture),
  82907. t
  82908. }
  82909. ,
  82910. t.prototype._getReflectionTexture = function() {
  82911. return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture
  82912. }
  82913. ,
  82914. t.prototype.getActiveTextures = function() {
  82915. var t = e.prototype.getActiveTextures.call(this);
  82916. return this._albedoTexture && t.push(this._albedoTexture),
  82917. this._ambientTexture && t.push(this._ambientTexture),
  82918. this._opacityTexture && t.push(this._opacityTexture),
  82919. this._reflectionTexture && t.push(this._reflectionTexture),
  82920. this._emissiveTexture && t.push(this._emissiveTexture),
  82921. this._reflectivityTexture && t.push(this._reflectivityTexture),
  82922. this._metallicTexture && t.push(this._metallicTexture),
  82923. this._metallicReflectanceTexture && t.push(this._metallicReflectanceTexture),
  82924. this._reflectanceTexture && t.push(this._reflectanceTexture),
  82925. this._microSurfaceTexture && t.push(this._microSurfaceTexture),
  82926. this._bumpTexture && t.push(this._bumpTexture),
  82927. this._lightmapTexture && t.push(this._lightmapTexture),
  82928. t
  82929. }
  82930. ,
  82931. t.prototype.hasTexture = function(t) {
  82932. return !!e.prototype.hasTexture.call(this, t) || this._albedoTexture === t || this._ambientTexture === t || this._opacityTexture === t || this._reflectionTexture === t || this._reflectivityTexture === t || this._metallicTexture === t || this._metallicReflectanceTexture === t || this._reflectanceTexture === t || this._microSurfaceTexture === t || this._bumpTexture === t || this._lightmapTexture === t
  82933. }
  82934. ,
  82935. t.prototype.setPrePassRenderer = function() {
  82936. var e;
  82937. if (null === (e = this.subSurface) || void 0 === e ? void 0 : e.isScatteringEnabled) {
  82938. var t = this.getScene().enableSubSurfaceForPrePass();
  82939. return t && (t.enabled = !0),
  82940. !0
  82941. }
  82942. return !1
  82943. }
  82944. ,
  82945. t.prototype.dispose = function(t, i) {
  82946. var n, r, o, a, s, l, c, u, h, d, p, f;
  82947. i && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(),
  82948. null === (n = this._albedoTexture) || void 0 === n || n.dispose(),
  82949. null === (r = this._ambientTexture) || void 0 === r || r.dispose(),
  82950. null === (o = this._opacityTexture) || void 0 === o || o.dispose(),
  82951. null === (a = this._reflectionTexture) || void 0 === a || a.dispose(),
  82952. null === (s = this._emissiveTexture) || void 0 === s || s.dispose(),
  82953. null === (l = this._metallicTexture) || void 0 === l || l.dispose(),
  82954. null === (c = this._reflectivityTexture) || void 0 === c || c.dispose(),
  82955. null === (u = this._bumpTexture) || void 0 === u || u.dispose(),
  82956. null === (h = this._lightmapTexture) || void 0 === h || h.dispose(),
  82957. null === (d = this._metallicReflectanceTexture) || void 0 === d || d.dispose(),
  82958. null === (p = this._reflectanceTexture) || void 0 === p || p.dispose(),
  82959. null === (f = this._microSurfaceTexture) || void 0 === f || f.dispose()),
  82960. this._renderTargets.dispose(),
  82961. this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  82962. e.prototype.dispose.call(this, t, i)
  82963. }
  82964. ,
  82965. t.PBRMATERIAL_OPAQUE = Or.MATERIAL_OPAQUE,
  82966. t.PBRMATERIAL_ALPHATEST = Or.MATERIAL_ALPHATEST,
  82967. t.PBRMATERIAL_ALPHABLEND = Or.MATERIAL_ALPHABLEND,
  82968. t.PBRMATERIAL_ALPHATESTANDBLEND = Or.MATERIAL_ALPHATESTANDBLEND,
  82969. t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
  82970. t.LIGHTFALLOFF_PHYSICAL = 0,
  82971. t.LIGHTFALLOFF_GLTF = 1,
  82972. t.LIGHTFALLOFF_STANDARD = 2,
  82973. k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
  82974. k([Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0),
  82975. k([Ce()], t.prototype, "useLogarithmicDepth", null),
  82976. t
  82977. }(gs)
  82978. , op = function(e) {
  82979. function t(i, n) {
  82980. var r = e.call(this, i, n) || this;
  82981. return r.directIntensity = 1,
  82982. r.emissiveIntensity = 1,
  82983. r.environmentIntensity = 1,
  82984. r.specularIntensity = 1,
  82985. r.disableBumpMap = !1,
  82986. r.ambientTextureStrength = 1,
  82987. r.ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  82988. r.metallicF0Factor = 1,
  82989. r.metallicReflectanceColor = D.White(),
  82990. r.useOnlyMetallicFromMetallicReflectanceTexture = !1,
  82991. r.ambientColor = new D(0,0,0),
  82992. r.albedoColor = new D(1,1,1),
  82993. r.reflectivityColor = new D(1,1,1),
  82994. r.reflectionColor = new D(1,1,1),
  82995. r.emissiveColor = new D(0,0,0),
  82996. r.microSurface = 1,
  82997. r.useLightmapAsShadowmap = !1,
  82998. r.useAlphaFromAlbedoTexture = !1,
  82999. r.forceAlphaTest = !1,
  83000. r.alphaCutOff = .4,
  83001. r.useSpecularOverAlpha = !0,
  83002. r.useMicroSurfaceFromReflectivityMapAlpha = !1,
  83003. r.useRoughnessFromMetallicTextureAlpha = !0,
  83004. r.useRoughnessFromMetallicTextureGreen = !1,
  83005. r.useMetallnessFromMetallicTextureBlue = !1,
  83006. r.useAmbientOcclusionFromMetallicTextureRed = !1,
  83007. r.useAmbientInGrayScale = !1,
  83008. r.useAutoMicroSurfaceFromReflectivityMap = !1,
  83009. r.useRadianceOverAlpha = !0,
  83010. r.useObjectSpaceNormalMap = !1,
  83011. r.useParallax = !1,
  83012. r.useParallaxOcclusion = !1,
  83013. r.parallaxScaleBias = .05,
  83014. r.disableLighting = !1,
  83015. r.forceIrradianceInFragment = !1,
  83016. r.maxSimultaneousLights = 4,
  83017. r.invertNormalMapX = !1,
  83018. r.invertNormalMapY = !1,
  83019. r.twoSidedLighting = !1,
  83020. r.useAlphaFresnel = !1,
  83021. r.useLinearAlphaFresnel = !1,
  83022. r.environmentBRDFTexture = null,
  83023. r.forceNormalForward = !1,
  83024. r.enableSpecularAntiAliasing = !1,
  83025. r.useHorizonOcclusion = !0,
  83026. r.useRadianceOcclusion = !0,
  83027. r.unlit = !1,
  83028. r._environmentBRDFTexture = Hd(r.getScene()),
  83029. r
  83030. }
  83031. return U(t, e),
  83032. Object.defineProperty(t.prototype, "refractionTexture", {
  83033. get: function() {
  83034. return this.subSurface.refractionTexture
  83035. },
  83036. set: function(e) {
  83037. this.subSurface.refractionTexture = e,
  83038. e ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1)
  83039. },
  83040. enumerable: !1,
  83041. configurable: !0
  83042. }),
  83043. Object.defineProperty(t.prototype, "indexOfRefraction", {
  83044. get: function() {
  83045. return this.subSurface.indexOfRefraction
  83046. },
  83047. set: function(e) {
  83048. this.subSurface.indexOfRefraction = e
  83049. },
  83050. enumerable: !1,
  83051. configurable: !0
  83052. }),
  83053. Object.defineProperty(t.prototype, "invertRefractionY", {
  83054. get: function() {
  83055. return this.subSurface.invertRefractionY
  83056. },
  83057. set: function(e) {
  83058. this.subSurface.invertRefractionY = e
  83059. },
  83060. enumerable: !1,
  83061. configurable: !0
  83062. }),
  83063. Object.defineProperty(t.prototype, "linkRefractionWithTransparency", {
  83064. get: function() {
  83065. return this.subSurface.linkRefractionWithTransparency
  83066. },
  83067. set: function(e) {
  83068. this.subSurface.linkRefractionWithTransparency = e,
  83069. e && (this.subSurface.isRefractionEnabled = !0)
  83070. },
  83071. enumerable: !1,
  83072. configurable: !0
  83073. }),
  83074. Object.defineProperty(t.prototype, "usePhysicalLightFalloff", {
  83075. get: function() {
  83076. return this._lightFalloff === rp.LIGHTFALLOFF_PHYSICAL
  83077. },
  83078. set: function(e) {
  83079. e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
  83080. this._lightFalloff = e ? rp.LIGHTFALLOFF_PHYSICAL : rp.LIGHTFALLOFF_STANDARD)
  83081. },
  83082. enumerable: !1,
  83083. configurable: !0
  83084. }),
  83085. Object.defineProperty(t.prototype, "useGLTFLightFalloff", {
  83086. get: function() {
  83087. return this._lightFalloff === rp.LIGHTFALLOFF_GLTF
  83088. },
  83089. set: function(e) {
  83090. e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
  83091. this._lightFalloff = e ? rp.LIGHTFALLOFF_GLTF : rp.LIGHTFALLOFF_STANDARD)
  83092. },
  83093. enumerable: !1,
  83094. configurable: !0
  83095. }),
  83096. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  83097. get: function() {
  83098. return this._imageProcessingConfiguration
  83099. },
  83100. set: function(e) {
  83101. this._attachImageProcessingConfiguration(e),
  83102. this._markAllSubMeshesAsTexturesDirty()
  83103. },
  83104. enumerable: !1,
  83105. configurable: !0
  83106. }),
  83107. Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
  83108. get: function() {
  83109. return this.imageProcessingConfiguration.colorCurvesEnabled
  83110. },
  83111. set: function(e) {
  83112. this.imageProcessingConfiguration.colorCurvesEnabled = e
  83113. },
  83114. enumerable: !1,
  83115. configurable: !0
  83116. }),
  83117. Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
  83118. get: function() {
  83119. return this.imageProcessingConfiguration.colorGradingEnabled
  83120. },
  83121. set: function(e) {
  83122. this.imageProcessingConfiguration.colorGradingEnabled = e
  83123. },
  83124. enumerable: !1,
  83125. configurable: !0
  83126. }),
  83127. Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
  83128. get: function() {
  83129. return this._imageProcessingConfiguration.toneMappingEnabled
  83130. },
  83131. set: function(e) {
  83132. this._imageProcessingConfiguration.toneMappingEnabled = e
  83133. },
  83134. enumerable: !1,
  83135. configurable: !0
  83136. }),
  83137. Object.defineProperty(t.prototype, "cameraExposure", {
  83138. get: function() {
  83139. return this._imageProcessingConfiguration.exposure
  83140. },
  83141. set: function(e) {
  83142. this._imageProcessingConfiguration.exposure = e
  83143. },
  83144. enumerable: !1,
  83145. configurable: !0
  83146. }),
  83147. Object.defineProperty(t.prototype, "cameraContrast", {
  83148. get: function() {
  83149. return this._imageProcessingConfiguration.contrast
  83150. },
  83151. set: function(e) {
  83152. this._imageProcessingConfiguration.contrast = e
  83153. },
  83154. enumerable: !1,
  83155. configurable: !0
  83156. }),
  83157. Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
  83158. get: function() {
  83159. return this._imageProcessingConfiguration.colorGradingTexture
  83160. },
  83161. set: function(e) {
  83162. this._imageProcessingConfiguration.colorGradingTexture = e
  83163. },
  83164. enumerable: !1,
  83165. configurable: !0
  83166. }),
  83167. Object.defineProperty(t.prototype, "cameraColorCurves", {
  83168. get: function() {
  83169. return this._imageProcessingConfiguration.colorCurves
  83170. },
  83171. set: function(e) {
  83172. this._imageProcessingConfiguration.colorCurves = e
  83173. },
  83174. enumerable: !1,
  83175. configurable: !0
  83176. }),
  83177. t.prototype.getClassName = function() {
  83178. return "PBRMaterial"
  83179. }
  83180. ,
  83181. t.prototype.clone = function(e) {
  83182. var i = this
  83183. , n = Ge.Clone((function() {
  83184. return new t(e,i.getScene())
  83185. }
  83186. ), this);
  83187. return n.id = e,
  83188. n.name = e,
  83189. this.stencil.copyTo(n.stencil),
  83190. this.clearCoat.copyTo(n.clearCoat),
  83191. this.anisotropy.copyTo(n.anisotropy),
  83192. this.brdf.copyTo(n.brdf),
  83193. this.sheen.copyTo(n.sheen),
  83194. this.subSurface.copyTo(n.subSurface),
  83195. n
  83196. }
  83197. ,
  83198. t.prototype.serialize = function() {
  83199. var t = e.prototype.serialize.call(this);
  83200. return t.customType = "BABYLON.PBRMaterial",
  83201. t.clearCoat = this.clearCoat.serialize(),
  83202. t.anisotropy = this.anisotropy.serialize(),
  83203. t.brdf = this.brdf.serialize(),
  83204. t.sheen = this.sheen.serialize(),
  83205. t.subSurface = this.subSurface.serialize(),
  83206. t
  83207. }
  83208. ,
  83209. t.Parse = function(e, i, n) {
  83210. var r = Ge.Parse((function() {
  83211. return new t(e.name,i)
  83212. }
  83213. ), e, i, n);
  83214. return e.stencil && r.stencil.parse(e.stencil, i, n),
  83215. e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
  83216. e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
  83217. e.brdf && r.brdf.parse(e.brdf, i, n),
  83218. e.sheen && r.sheen.parse(e.sheen, i, n),
  83219. e.subSurface && r.subSurface.parse(e.subSurface, i, n),
  83220. r
  83221. }
  83222. ,
  83223. t.PBRMATERIAL_OPAQUE = rp.PBRMATERIAL_OPAQUE,
  83224. t.PBRMATERIAL_ALPHATEST = rp.PBRMATERIAL_ALPHATEST,
  83225. t.PBRMATERIAL_ALPHABLEND = rp.PBRMATERIAL_ALPHABLEND,
  83226. t.PBRMATERIAL_ALPHATESTANDBLEND = rp.PBRMATERIAL_ALPHATESTANDBLEND,
  83227. t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
  83228. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0),
  83229. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0),
  83230. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0),
  83231. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0),
  83232. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0),
  83233. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0),
  83234. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
  83235. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0),
  83236. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0),
  83237. k([Pe(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
  83238. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
  83239. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
  83240. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0),
  83241. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0),
  83242. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
  83243. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
  83244. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0),
  83245. k([Me(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0),
  83246. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0),
  83247. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0),
  83248. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectanceTexture", void 0),
  83249. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0),
  83250. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
  83251. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
  83252. k([Me("ambient"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0),
  83253. k([Me("albedo"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0),
  83254. k([Me("reflectivity"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0),
  83255. k([Me("reflection"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0),
  83256. k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
  83257. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0),
  83258. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
  83259. k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0),
  83260. k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0),
  83261. k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0),
  83262. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
  83263. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0),
  83264. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0),
  83265. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0),
  83266. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0),
  83267. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0),
  83268. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0),
  83269. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0),
  83270. k([Ce()], t.prototype, "usePhysicalLightFalloff", null),
  83271. k([Ce()], t.prototype, "useGLTFLightFalloff", null),
  83272. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0),
  83273. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
  83274. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
  83275. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
  83276. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0),
  83277. k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
  83278. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0),
  83279. k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
  83280. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
  83281. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
  83282. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
  83283. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0),
  83284. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0),
  83285. k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0),
  83286. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0),
  83287. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0),
  83288. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0),
  83289. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0),
  83290. k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0),
  83291. t
  83292. }(rp);
  83293. y("BABYLON.PBRMaterial", op);
  83294. var ap = 131072
  83295. , sp = 131072;
  83296. function lp(e) {
  83297. return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24)
  83298. }
  83299. var cp = lp("DXT1")
  83300. , up = lp("DXT3")
  83301. , hp = lp("DXT5")
  83302. , dp = lp("DX10")
  83303. , pp = function() {
  83304. function e() {}
  83305. return e.GetDDSInfo = function(e) {
  83306. var t = new Int32Array(e.buffer,e.byteOffset,31)
  83307. , i = new Int32Array(e.buffer,e.byteOffset,35)
  83308. , n = 1;
  83309. t[2] & ap && (n = Math.max(1, t[7]));
  83310. var r = t[21]
  83311. , o = r === dp ? i[32] : 0
  83312. , s = a.TEXTURETYPE_UNSIGNED_INT;
  83313. switch (r) {
  83314. case 113:
  83315. s = a.TEXTURETYPE_HALF_FLOAT;
  83316. break;
  83317. case 116:
  83318. s = a.TEXTURETYPE_FLOAT;
  83319. break;
  83320. case dp:
  83321. if (10 === o) {
  83322. s = a.TEXTURETYPE_HALF_FLOAT;
  83323. break
  83324. }
  83325. if (2 === o) {
  83326. s = a.TEXTURETYPE_FLOAT;
  83327. break
  83328. }
  83329. }
  83330. return {
  83331. width: t[4],
  83332. height: t[3],
  83333. mipmapCount: n,
  83334. isFourCC: 4 == (4 & t[20]),
  83335. isRGB: 64 == (64 & t[20]),
  83336. isLuminance: (t[20] & sp) === sp,
  83337. isCube: 512 == (512 & t[28]),
  83338. isCompressed: r === cp || r === up || r === hp,
  83339. dxgiFormat: o,
  83340. textureType: s
  83341. }
  83342. }
  83343. ,
  83344. e._GetHalfFloatAsFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83345. for (var s = new Float32Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
  83346. for (var h = 0; h < t; h++) {
  83347. var d = 4 * (h + u * t);
  83348. s[c] = Dc(l[d]),
  83349. s[c + 1] = Dc(l[d + 1]),
  83350. s[c + 2] = Dc(l[d + 2]),
  83351. e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = Dc(l[d + 3]),
  83352. c += 4
  83353. }
  83354. return s
  83355. }
  83356. ,
  83357. e._GetHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83358. if (e.StoreLODInAlphaChannel) {
  83359. for (var s = new Uint16Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
  83360. for (var h = 0; h < t; h++) {
  83361. var d = 4 * (h + u * t);
  83362. s[c] = l[d],
  83363. s[c + 1] = l[d + 1],
  83364. s[c + 2] = l[d + 2],
  83365. s[c + 3] = Oc(a),
  83366. c += 4
  83367. }
  83368. return s
  83369. }
  83370. return new Uint16Array(o,n,r)
  83371. }
  83372. ,
  83373. e._GetFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83374. if (e.StoreLODInAlphaChannel) {
  83375. for (var s = new Float32Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
  83376. for (var h = 0; h < t; h++) {
  83377. var d = 4 * (h + u * t);
  83378. s[c] = l[d],
  83379. s[c + 1] = l[d + 1],
  83380. s[c + 2] = l[d + 2],
  83381. s[c + 3] = a,
  83382. c += 4
  83383. }
  83384. return s
  83385. }
  83386. return new Float32Array(o,n,r)
  83387. }
  83388. ,
  83389. e._GetFloatAsHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83390. for (var s = new Uint16Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
  83391. for (var h = 0; h < t; h++)
  83392. s[c] = Oc(l[c]),
  83393. s[c + 1] = Oc(l[c + 1]),
  83394. s[c + 2] = Oc(l[c + 2]),
  83395. e.StoreLODInAlphaChannel ? s[c + 3] = Oc(a) : s[c + 3] = Oc(l[c + 3]),
  83396. c += 4;
  83397. return s
  83398. }
  83399. ,
  83400. e._GetFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83401. for (var s = new Uint8Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
  83402. for (var h = 0; h < t; h++) {
  83403. var p = 4 * (h + u * t);
  83404. s[c] = 255 * d.Clamp(l[p]),
  83405. s[c + 1] = 255 * d.Clamp(l[p + 1]),
  83406. s[c + 2] = 255 * d.Clamp(l[p + 2]),
  83407. e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(l[p + 3]),
  83408. c += 4
  83409. }
  83410. return s
  83411. }
  83412. ,
  83413. e._GetHalfFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
  83414. for (var s = new Uint8Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
  83415. for (var h = 0; h < t; h++) {
  83416. var p = 4 * (h + u * t);
  83417. s[c] = 255 * d.Clamp(Dc(l[p])),
  83418. s[c + 1] = 255 * d.Clamp(Dc(l[p + 1])),
  83419. s[c + 2] = 255 * d.Clamp(Dc(l[p + 2])),
  83420. e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(Dc(l[p + 3])),
  83421. c += 4
  83422. }
  83423. return s
  83424. }
  83425. ,
  83426. e._GetRGBAArrayBuffer = function(e, t, i, n, r, o, a, s, l) {
  83427. for (var c = new Uint8Array(n), u = new Uint8Array(r,i), h = 0, d = 0; d < t; d++)
  83428. for (var p = 0; p < e; p++) {
  83429. var f = 4 * (p + d * e);
  83430. c[h] = u[f + o],
  83431. c[h + 1] = u[f + a],
  83432. c[h + 2] = u[f + s],
  83433. c[h + 3] = u[f + l],
  83434. h += 4
  83435. }
  83436. return c
  83437. }
  83438. ,
  83439. e._ExtractLongWordOrder = function(t) {
  83440. return 0 === t || 255 === t || -16777216 === t ? 0 : 1 + e._ExtractLongWordOrder(t >> 8)
  83441. }
  83442. ,
  83443. e._GetRGBArrayBuffer = function(e, t, i, n, r, o, a, s) {
  83444. for (var l = new Uint8Array(n), c = new Uint8Array(r,i), u = 0, h = 0; h < t; h++)
  83445. for (var d = 0; d < e; d++) {
  83446. var p = 3 * (d + h * e);
  83447. l[u] = c[p + o],
  83448. l[u + 1] = c[p + a],
  83449. l[u + 2] = c[p + s],
  83450. u += 3
  83451. }
  83452. return l
  83453. }
  83454. ,
  83455. e._GetLuminanceArrayBuffer = function(e, t, i, n, r) {
  83456. for (var o = new Uint8Array(n), a = new Uint8Array(r,i), s = 0, l = 0; l < t; l++)
  83457. for (var c = 0; c < e; c++) {
  83458. var u = c + l * e;
  83459. o[s] = a[u],
  83460. s++
  83461. }
  83462. return o
  83463. }
  83464. ,
  83465. e.UploadDDSLevels = function(t, i, n, r, o, s, l, c, u) {
  83466. void 0 === l && (l = -1),
  83467. void 0 === u && (u = !0);
  83468. var h = null;
  83469. r.sphericalPolynomial && (h = new Array);
  83470. var d = !!t.getCaps().s3tc;
  83471. i.generateMipMaps = o;
  83472. var p, f, _, m, g, v, y, b = new Int32Array(n.buffer,n.byteOffset,31), T = 0, E = 0, S = 1;
  83473. if (542327876 === b[0])
  83474. if (r.isFourCC || r.isRGB || r.isLuminance)
  83475. if (!r.isCompressed || d) {
  83476. var A = b[22];
  83477. m = b[1] + 4;
  83478. var x, R = !1;
  83479. if (r.isFourCC)
  83480. switch (p = b[21]) {
  83481. case cp:
  83482. S = 8,
  83483. E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1;
  83484. break;
  83485. case up:
  83486. S = 16,
  83487. E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;
  83488. break;
  83489. case hp:
  83490. S = 16,
  83491. E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
  83492. break;
  83493. case 113:
  83494. R = !0,
  83495. A = 64;
  83496. break;
  83497. case 116:
  83498. R = !0,
  83499. A = 128;
  83500. break;
  83501. case dp:
  83502. m += 20;
  83503. var C = !1;
  83504. switch (r.dxgiFormat) {
  83505. case 10:
  83506. R = !0,
  83507. A = 64,
  83508. C = !0;
  83509. break;
  83510. case 2:
  83511. R = !0,
  83512. A = 128,
  83513. C = !0;
  83514. break;
  83515. case 88:
  83516. r.isRGB = !0,
  83517. r.isFourCC = !1,
  83518. A = 32,
  83519. C = !0
  83520. }
  83521. if (C)
  83522. break;
  83523. default:
  83524. return void console.error("Unsupported FourCC code:", (x = p,
  83525. String.fromCharCode(255 & x, x >> 8 & 255, x >> 16 & 255, x >> 24 & 255)))
  83526. }
  83527. var P = e._ExtractLongWordOrder(b[23])
  83528. , M = e._ExtractLongWordOrder(b[24])
  83529. , I = e._ExtractLongWordOrder(b[25])
  83530. , O = e._ExtractLongWordOrder(b[26]);
  83531. R && (E = t._getRGBABufferInternalSizedFormat(r.textureType)),
  83532. v = 1,
  83533. b[2] & ap && !1 !== o && (v = Math.max(1, b[7]));
  83534. for (var D = c || 0, N = t.getCaps(), L = D; L < s; L++) {
  83535. for (f = b[4],
  83536. _ = b[3],
  83537. y = 0; y < v; ++y) {
  83538. if (-1 === l || l === y) {
  83539. var F = -1 === l ? y : 0;
  83540. if (!r.isCompressed && r.isFourCC) {
  83541. i.format = a.TEXTUREFORMAT_RGBA,
  83542. T = f * _ * 4;
  83543. var w = null;
  83544. if (t._badOS || t._badDesktopOS || !N.textureHalfFloat && !N.textureFloat)
  83545. 128 === A ? (w = e._GetFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
  83546. h && 0 == F && h.push(e._GetFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))) : 64 === A && (w = e._GetHalfFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
  83547. h && 0 == F && h.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))),
  83548. i.type = a.TEXTURETYPE_UNSIGNED_INT;
  83549. else {
  83550. var B = N.textureFloat && (u && N.textureFloatLinearFiltering || !u)
  83551. , U = N.textureHalfFloat && (u && N.textureHalfFloatLinearFiltering || !u)
  83552. , V = (128 === A || 64 === A && !U) && B ? a.TEXTURETYPE_FLOAT : (64 === A || 128 === A && !B) && U ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE
  83553. , k = void 0
  83554. , G = null;
  83555. if (128 === A)
  83556. switch (V) {
  83557. case a.TEXTURETYPE_FLOAT:
  83558. k = e._GetFloatRGBAArrayBuffer,
  83559. G = null;
  83560. break;
  83561. case a.TEXTURETYPE_HALF_FLOAT:
  83562. k = e._GetFloatAsHalfFloatRGBAArrayBuffer,
  83563. G = e._GetFloatRGBAArrayBuffer;
  83564. break;
  83565. case a.TEXTURETYPE_UNSIGNED_BYTE:
  83566. k = e._GetFloatAsUIntRGBAArrayBuffer,
  83567. G = e._GetFloatRGBAArrayBuffer
  83568. }
  83569. else
  83570. switch (V) {
  83571. case a.TEXTURETYPE_FLOAT:
  83572. k = e._GetHalfFloatAsFloatRGBAArrayBuffer,
  83573. G = null;
  83574. break;
  83575. case a.TEXTURETYPE_HALF_FLOAT:
  83576. k = e._GetHalfFloatRGBAArrayBuffer,
  83577. G = e._GetHalfFloatAsFloatRGBAArrayBuffer;
  83578. break;
  83579. case a.TEXTURETYPE_UNSIGNED_BYTE:
  83580. k = e._GetHalfFloatAsUIntRGBAArrayBuffer,
  83581. G = e._GetHalfFloatAsFloatRGBAArrayBuffer
  83582. }
  83583. i.type = V,
  83584. w = k(f, _, n.byteOffset + m, T, n.buffer, F),
  83585. h && 0 == F && h.push(G ? G(f, _, n.byteOffset + m, T, n.buffer, F) : w)
  83586. }
  83587. w && t._uploadDataToTextureDirectly(i, w, L, F)
  83588. } else if (r.isRGB)
  83589. i.type = a.TEXTURETYPE_UNSIGNED_INT,
  83590. 24 === A ? (i.format = a.TEXTUREFORMAT_RGB,
  83591. T = f * _ * 3,
  83592. g = e._GetRGBArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I),
  83593. t._uploadDataToTextureDirectly(i, g, L, F)) : (i.format = a.TEXTUREFORMAT_RGBA,
  83594. T = f * _ * 4,
  83595. g = e._GetRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I, O),
  83596. t._uploadDataToTextureDirectly(i, g, L, F));
  83597. else if (r.isLuminance) {
  83598. var z = t._getUnpackAlignement()
  83599. , W = f;
  83600. T = Math.floor((f + z - 1) / z) * z * (_ - 1) + W,
  83601. g = e._GetLuminanceArrayBuffer(f, _, n.byteOffset + m, T, n.buffer),
  83602. i.format = a.TEXTUREFORMAT_LUMINANCE,
  83603. i.type = a.TEXTURETYPE_UNSIGNED_INT,
  83604. t._uploadDataToTextureDirectly(i, g, L, F)
  83605. } else
  83606. T = Math.max(4, f) / 4 * Math.max(4, _) / 4 * S,
  83607. g = new Uint8Array(n.buffer,n.byteOffset + m,T),
  83608. i.type = a.TEXTURETYPE_UNSIGNED_INT,
  83609. t._uploadCompressedDataToTextureDirectly(i, E, f, _, g, L, F)
  83610. }
  83611. m += A ? f * _ * (A / 8) : T,
  83612. f *= .5,
  83613. _ *= .5,
  83614. f = Math.max(1, f),
  83615. _ = Math.max(1, _)
  83616. }
  83617. if (void 0 !== c)
  83618. break
  83619. }
  83620. h && h.length > 0 ? r.sphericalPolynomial = wc.ConvertCubeMapToSphericalPolynomial({
  83621. size: b[4],
  83622. right: h[0],
  83623. left: h[1],
  83624. up: h[2],
  83625. down: h[3],
  83626. front: h[4],
  83627. back: h[5],
  83628. format: a.TEXTUREFORMAT_RGBA,
  83629. type: a.TEXTURETYPE_FLOAT,
  83630. gammaSpace: !1
  83631. }) : r.sphericalPolynomial = void 0
  83632. } else
  83633. K.Error("Compressed textures are not supported on this platform.");
  83634. else
  83635. K.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  83636. else
  83637. K.Error("Invalid magic number in DDS header")
  83638. }
  83639. ,
  83640. e.StoreLODInAlphaChannel = !1,
  83641. e
  83642. }();
  83643. Ht.prototype.createPrefilteredCubeTexture = function(e, t, i, n, r, o, s, l, c) {
  83644. var u = this;
  83645. return void 0 === r && (r = null),
  83646. void 0 === o && (o = null),
  83647. void 0 === l && (l = null),
  83648. void 0 === c && (c = !0),
  83649. this.createCubeTexture(e, t, null, !1, (function(e) {
  83650. if (e) {
  83651. var o = e.texture;
  83652. if (c ? e.info.sphericalPolynomial && (o._sphericalPolynomial = e.info.sphericalPolynomial) : o._sphericalPolynomial = new Pc,
  83653. o._source = At.CubePrefiltered,
  83654. u.getCaps().textureLOD)
  83655. r && r(o);
  83656. else {
  83657. var s = u._gl
  83658. , l = e.width;
  83659. if (l) {
  83660. for (var h = [], p = 0; p < 3; p++) {
  83661. var f = 1 - p / 2
  83662. , _ = n
  83663. , m = d.Log2(l) * i + n
  83664. , g = _ + (m - _) * f
  83665. , v = Math.round(Math.min(Math.max(g, 0), m))
  83666. , y = new Lt(u,At.Temp);
  83667. if (y.type = o.type,
  83668. y.format = o.format,
  83669. y.width = Math.pow(2, Math.max(d.Log2(l) - v, 0)),
  83670. y.height = y.width,
  83671. y.isCube = !0,
  83672. y._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  83673. y._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  83674. u._bindTextureDirectly(s.TEXTURE_CUBE_MAP, y, !0),
  83675. y.samplingMode = a.TEXTURE_LINEAR_LINEAR,
  83676. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MAG_FILTER, s.LINEAR),
  83677. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MIN_FILTER, s.LINEAR),
  83678. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE),
  83679. s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE),
  83680. e.isDDS) {
  83681. var b = e.info
  83682. , T = e.data;
  83683. u._unpackFlipY(b.isCompressed),
  83684. pp.UploadDDSLevels(u, y, T, b, !0, 6, v)
  83685. } else
  83686. K.Warn("DDS is the only prefiltered cube map supported so far.");
  83687. u._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null);
  83688. var E = new Zr(t);
  83689. E.isCube = !0,
  83690. E._texture = y,
  83691. y.isReady = !0,
  83692. h.push(E)
  83693. }
  83694. o._lodTextureHigh = h[2],
  83695. o._lodTextureMid = h[1],
  83696. o._lodTextureLow = h[0],
  83697. r && r(o)
  83698. }
  83699. }
  83700. } else
  83701. r && r(null)
  83702. }
  83703. ), o, s, l, c, i, n)
  83704. }
  83705. ;
  83706. var fp = function() {
  83707. function e() {
  83708. this.supportCascades = !0
  83709. }
  83710. return e.prototype.canLoad = function(e) {
  83711. return oe(e, ".dds")
  83712. }
  83713. ,
  83714. e.prototype.loadCubeData = function(e, t, i, n) {
  83715. var r, o = t.getEngine(), a = !1, s = 1e3;
  83716. if (Array.isArray(e))
  83717. for (var l = 0; l < e.length; l++) {
  83718. var c = e[l];
  83719. r = pp.GetDDSInfo(c),
  83720. t.width = r.width,
  83721. t.height = r.height,
  83722. a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
  83723. o._unpackFlipY(r.isCompressed),
  83724. pp.UploadDDSLevels(o, t, c, r, a, 6, -1, l),
  83725. r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t)
  83726. }
  83727. else
  83728. c = e,
  83729. r = pp.GetDDSInfo(c),
  83730. t.width = r.width,
  83731. t.height = r.height,
  83732. i && (r.sphericalPolynomial = new Pc),
  83733. a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
  83734. o._unpackFlipY(r.isCompressed),
  83735. pp.UploadDDSLevels(o, t, c, r, a, 6),
  83736. r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t, !1);
  83737. o._setCubeMapTextureParams(t, a, s),
  83738. t.isReady = !0,
  83739. t.onLoadedObservable.notifyObservers(t),
  83740. t.onLoadedObservable.clear(),
  83741. n && n({
  83742. isDDS: !0,
  83743. width: t.width,
  83744. info: r,
  83745. data: e,
  83746. texture: t
  83747. })
  83748. }
  83749. ,
  83750. e.prototype.loadData = function(e, t, i) {
  83751. var n = pp.GetDDSInfo(e)
  83752. , r = (n.isRGB || n.isLuminance || n.mipmapCount > 1) && t.generateMipMaps && n.width >> n.mipmapCount - 1 == 1;
  83753. i(n.width, n.height, r, n.isFourCC, (function() {
  83754. pp.UploadDDSLevels(t.getEngine(), t, e, n, r, 1)
  83755. }
  83756. ))
  83757. }
  83758. ,
  83759. e
  83760. }();
  83761. vr._TextureLoaders.push(new fp);
  83762. var _p = function() {
  83763. function e() {
  83764. this.supportCascades = !1
  83765. }
  83766. return e.prototype.canLoad = function(e) {
  83767. return oe(e, ".env")
  83768. }
  83769. ,
  83770. e.prototype.loadCubeData = function(e, t, i, n, r) {
  83771. if (!Array.isArray(e)) {
  83772. var o = Vc(e);
  83773. if (o) {
  83774. t.width = o.width,
  83775. t.height = o.width;
  83776. try {
  83777. Yc(t, o),
  83778. Hc(t, e, o).then((function() {
  83779. t.isReady = !0,
  83780. t.onLoadedObservable.notifyObservers(t),
  83781. t.onLoadedObservable.clear(),
  83782. n && n()
  83783. }
  83784. ), (function(e) {
  83785. null == r || r("Can not upload environment levels", e)
  83786. }
  83787. ))
  83788. } catch (e) {
  83789. null == r || r("Can not upload environment file", e)
  83790. }
  83791. } else
  83792. r && r("Can not parse the environment file", null)
  83793. }
  83794. }
  83795. ,
  83796. e.prototype.loadData = function() {
  83797. throw ".env not supported in 2d."
  83798. }
  83799. ,
  83800. e
  83801. }();
  83802. vr._TextureLoaders.push(new _p);
  83803. var mp = function() {
  83804. function e(t, i) {
  83805. if (this.data = t,
  83806. this.isInvalid = !1,
  83807. !e.IsValid(t))
  83808. return this.isInvalid = !0,
  83809. void K.Error("texture missing KTX identifier");
  83810. var n = Uint32Array.BYTES_PER_ELEMENT
  83811. , r = new DataView(this.data.buffer,this.data.byteOffset + 12,13 * n)
  83812. , o = 67305985 === r.getUint32(0, !0);
  83813. this.glType = r.getUint32(1 * n, o),
  83814. this.glTypeSize = r.getUint32(2 * n, o),
  83815. this.glFormat = r.getUint32(3 * n, o),
  83816. this.glInternalFormat = r.getUint32(4 * n, o),
  83817. this.glBaseInternalFormat = r.getUint32(5 * n, o),
  83818. this.pixelWidth = r.getUint32(6 * n, o),
  83819. this.pixelHeight = r.getUint32(7 * n, o),
  83820. this.pixelDepth = r.getUint32(8 * n, o),
  83821. this.numberOfArrayElements = r.getUint32(9 * n, o),
  83822. this.numberOfFaces = r.getUint32(10 * n, o),
  83823. this.numberOfMipmapLevels = r.getUint32(11 * n, o),
  83824. this.bytesOfKeyValueData = r.getUint32(12 * n, o),
  83825. 0 === this.glType ? (this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels),
  83826. 0 !== this.pixelHeight && 0 === this.pixelDepth ? 0 === this.numberOfArrayElements ? this.numberOfFaces === i ? this.loadType = e.COMPRESSED_2D : K.Error("number of faces expected" + i + ", but found " + this.numberOfFaces) : K.Error("texture arrays not currently supported") : K.Error("only 2D textures currently supported")) : K.Error("only compressed formats currently supported")
  83827. }
  83828. return e.prototype.uploadLevels = function(t, i) {
  83829. switch (this.loadType) {
  83830. case e.COMPRESSED_2D:
  83831. this._upload2DCompressedLevels(t, i);
  83832. case e.TEX_2D:
  83833. case e.COMPRESSED_3D:
  83834. case e.TEX_3D:
  83835. }
  83836. }
  83837. ,
  83838. e.prototype._upload2DCompressedLevels = function(t, i) {
  83839. for (var n = e.HEADER_LEN + this.bytesOfKeyValueData, r = this.pixelWidth, o = this.pixelHeight, a = i ? this.numberOfMipmapLevels : 1, s = 0; s < a; s++) {
  83840. var l = new Int32Array(this.data.buffer,this.data.byteOffset + n,1)[0];
  83841. n += 4;
  83842. for (var c = 0; c < this.numberOfFaces; c++) {
  83843. var u = new Uint8Array(this.data.buffer,this.data.byteOffset + n,l);
  83844. t.getEngine()._uploadCompressedDataToTextureDirectly(t, this.glInternalFormat, r, o, u, c, s),
  83845. n += l,
  83846. n += 3 - (l + 3) % 4
  83847. }
  83848. r = Math.max(1, .5 * r),
  83849. o = Math.max(1, .5 * o)
  83850. }
  83851. }
  83852. ,
  83853. e.IsValid = function(e) {
  83854. if (e.byteLength >= 12) {
  83855. var t = new Uint8Array(e.buffer,e.byteOffset,12);
  83856. if (171 === t[0] && 75 === t[1] && 84 === t[2] && 88 === t[3] && 32 === t[4] && 49 === t[5] && 49 === t[6] && 187 === t[7] && 13 === t[8] && 10 === t[9] && 26 === t[10] && 10 === t[11])
  83857. return !0
  83858. }
  83859. return !1
  83860. }
  83861. ,
  83862. e.HEADER_LEN = 64,
  83863. e.COMPRESSED_2D = 0,
  83864. e.COMPRESSED_3D = 1,
  83865. e.TEX_2D = 2,
  83866. e.TEX_3D = 3,
  83867. e
  83868. }()
  83869. , gp = function() {
  83870. function e(e) {
  83871. this._pendingActions = new Array,
  83872. this._workerInfos = e.map((function(e) {
  83873. return {
  83874. workerPromise: Promise.resolve(e),
  83875. idle: !0
  83876. }
  83877. }
  83878. ))
  83879. }
  83880. return e.prototype.dispose = function() {
  83881. for (var e = 0, t = this._workerInfos; e < t.length; e++)
  83882. t[e].workerPromise.then((function(e) {
  83883. e.terminate()
  83884. }
  83885. ));
  83886. this._workerInfos.length = 0,
  83887. this._pendingActions.length = 0
  83888. }
  83889. ,
  83890. e.prototype.push = function(e) {
  83891. this._executeOnIdleWorker(e) || this._pendingActions.push(e)
  83892. }
  83893. ,
  83894. e.prototype._executeOnIdleWorker = function(e) {
  83895. for (var t = 0, i = this._workerInfos; t < i.length; t++) {
  83896. var n = i[t];
  83897. if (n.idle)
  83898. return this._execute(n, e),
  83899. !0
  83900. }
  83901. return !1
  83902. }
  83903. ,
  83904. e.prototype._execute = function(e, t) {
  83905. var i = this;
  83906. e.idle = !1,
  83907. e.workerPromise.then((function(n) {
  83908. t(n, (function() {
  83909. var t = i._pendingActions.shift();
  83910. t ? i._execute(e, t) : e.idle = !0
  83911. }
  83912. ))
  83913. }
  83914. ))
  83915. }
  83916. ,
  83917. e
  83918. }()
  83919. , vp = function(e) {
  83920. function t(i, n, r) {
  83921. void 0 === r && (r = t.DefaultOptions);
  83922. var o = e.call(this, []) || this;
  83923. return o._maxWorkers = i,
  83924. o._createWorkerAsync = n,
  83925. o._options = r,
  83926. o
  83927. }
  83928. return U(t, e),
  83929. t.prototype.push = function(e) {
  83930. if (!this._executeOnIdleWorker(e))
  83931. if (this._workerInfos.length < this._maxWorkers) {
  83932. var t = {
  83933. workerPromise: this._createWorkerAsync(),
  83934. idle: !1
  83935. };
  83936. this._workerInfos.push(t),
  83937. this._execute(t, e)
  83938. } else
  83939. this._pendingActions.push(e)
  83940. }
  83941. ,
  83942. t.prototype._execute = function(t, i) {
  83943. var n = this;
  83944. t.timeoutId && (clearTimeout(t.timeoutId),
  83945. delete t.timeoutId),
  83946. e.prototype._execute.call(this, t, (function(e, r) {
  83947. i(e, (function() {
  83948. r(),
  83949. t.idle && (t.timeoutId = setTimeout((function() {
  83950. t.workerPromise.then((function(e) {
  83951. e.terminate()
  83952. }
  83953. ));
  83954. var e = n._workerInfos.indexOf(t);
  83955. -1 !== e && n._workerInfos.splice(e, 1)
  83956. }
  83957. ), n._options.idleTimeElapsedBeforeRelease))
  83958. }
  83959. ))
  83960. }
  83961. ))
  83962. }
  83963. ,
  83964. t.DefaultOptions = {
  83965. idleTimeElapsedBeforeRelease: 1e3
  83966. },
  83967. t
  83968. }(gp)
  83969. , yp = function() {
  83970. function e(t, i) {
  83971. void 0 === i && (i = e.DefaultNumWorkers),
  83972. this._engine = t,
  83973. e._Initialize(i)
  83974. }
  83975. return e.GetDefaultNumWorkers = function() {
  83976. return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1
  83977. }
  83978. ,
  83979. e._Initialize = function(t) {
  83980. e._WorkerPoolPromise || e._DecoderModulePromise || (t && "function" == typeof Worker ? e._WorkerPoolPromise = new Promise((function(i) {
  83981. var n = "(".concat(bp, ")()")
  83982. , r = URL.createObjectURL(new Blob([n],{
  83983. type: "application/javascript"
  83984. }));
  83985. i(new vp(t,(function() {
  83986. return new Promise((function(t, i) {
  83987. var n = new Worker(r)
  83988. , o = function(e) {
  83989. n.removeEventListener("error", o),
  83990. n.removeEventListener("message", a),
  83991. i(e)
  83992. }
  83993. , a = function(e) {
  83994. "init" === e.data.action && (n.removeEventListener("error", o),
  83995. n.removeEventListener("message", a),
  83996. t(n))
  83997. };
  83998. n.addEventListener("error", o),
  83999. n.addEventListener("message", a),
  84000. n.postMessage({
  84001. action: "init",
  84002. urls: e.URLConfig
  84003. })
  84004. }
  84005. ))
  84006. }
  84007. )))
  84008. }
  84009. )) : "undefined" == typeof KTX2DECODER ? e._DecoderModulePromise = gi.LoadScriptAsync(e.URLConfig.jsDecoderModule).then((function() {
  84010. KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
  84011. KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0;
  84012. var t = e.URLConfig;
  84013. return null !== t.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = t.wasmUASTCToASTC),
  84014. null !== t.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = t.wasmUASTCToBC7),
  84015. null !== t.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = t.wasmUASTCToRGBA_UNORM),
  84016. null !== t.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = t.wasmUASTCToRGBA_SRGB),
  84017. null !== t.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = t.jsMSCTranscoder),
  84018. null !== t.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = t.wasmMSCTranscoder),
  84019. null !== t.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = t.wasmZSTDDecoder),
  84020. new KTX2DECODER.KTX2Decoder
  84021. }
  84022. )) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
  84023. KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0,
  84024. e._DecoderModulePromise = Promise.resolve(new KTX2DECODER.KTX2Decoder)))
  84025. }
  84026. ,
  84027. e.prototype.uploadAsync = function(t, i, n) {
  84028. var r = this
  84029. , o = this._engine.getCaps()
  84030. , a = {
  84031. astc: !!o.astc,
  84032. bptc: !!o.bptc,
  84033. s3tc: !!o.s3tc,
  84034. pvrtc: !!o.pvrtc,
  84035. etc2: !!o.etc2,
  84036. etc1: !!o.etc1
  84037. };
  84038. if (e._WorkerPoolPromise)
  84039. return e._WorkerPoolPromise.then((function(e) {
  84040. return new Promise((function(o, s) {
  84041. e.push((function(e, l) {
  84042. var c = function(t) {
  84043. e.removeEventListener("error", c),
  84044. e.removeEventListener("message", u),
  84045. s(t),
  84046. l()
  84047. }
  84048. , u = function(t) {
  84049. if ("decoded" === t.data.action) {
  84050. if (e.removeEventListener("error", c),
  84051. e.removeEventListener("message", u),
  84052. t.data.success)
  84053. try {
  84054. r._createTexture(t.data.decodedData, i, n),
  84055. o()
  84056. } catch (e) {
  84057. s({
  84058. message: e
  84059. })
  84060. }
  84061. else
  84062. s({
  84063. message: t.data.msg
  84064. });
  84065. l()
  84066. }
  84067. };
  84068. e.addEventListener("error", c),
  84069. e.addEventListener("message", u);
  84070. var h = new Uint8Array(t.byteLength);
  84071. h.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),
  84072. e.postMessage({
  84073. action: "decode",
  84074. data: h,
  84075. caps: a,
  84076. options: n
  84077. }, [h.buffer])
  84078. }
  84079. ))
  84080. }
  84081. ))
  84082. }
  84083. ));
  84084. if (e._DecoderModulePromise)
  84085. return e._DecoderModulePromise.then((function(e) {
  84086. return new Promise((function(n, a) {
  84087. e.decode(t, o).then((function(e) {
  84088. r._createTexture(e, i),
  84089. n()
  84090. }
  84091. )).catch((function(e) {
  84092. a({
  84093. message: e
  84094. })
  84095. }
  84096. ))
  84097. }
  84098. ))
  84099. }
  84100. ));
  84101. throw new Error("KTX2 decoder module is not available")
  84102. }
  84103. ,
  84104. e.prototype._createTexture = function(e, t, i) {
  84105. if (this._engine._bindTextureDirectly(3553, t),
  84106. i && (i.transcodedFormat = e.transcodedFormat,
  84107. i.isInGammaSpace = e.isInGammaSpace,
  84108. i.hasAlpha = e.hasAlpha,
  84109. i.transcoderName = e.transcoderName),
  84110. 32856 === e.transcodedFormat ? (t.type = a.TEXTURETYPE_UNSIGNED_BYTE,
  84111. t.format = a.TEXTUREFORMAT_RGBA) : t.format = e.transcodedFormat,
  84112. t._gammaSpace = e.isInGammaSpace,
  84113. t.generateMipMaps = e.mipmaps.length > 1,
  84114. e.errors)
  84115. throw new Error("KTX2 container - could not transcode the data. " + e.errors);
  84116. for (var n = 0; n < e.mipmaps.length; ++n) {
  84117. var r = e.mipmaps[n];
  84118. if (!r || !r.data)
  84119. throw new Error("KTX2 container - could not transcode one of the image");
  84120. 32856 === e.transcodedFormat ? (t.width = r.width,
  84121. t.height = r.height,
  84122. this._engine._uploadDataToTextureDirectly(t, r.data, 0, n, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(t, e.transcodedFormat, r.width, r.height, r.data, 0, n)
  84123. }
  84124. t._extension = ".ktx2",
  84125. t.width = e.mipmaps[0].width,
  84126. t.height = e.mipmaps[0].height,
  84127. t.isReady = !0,
  84128. this._engine._bindTextureDirectly(3553, null)
  84129. }
  84130. ,
  84131. e.IsValid = function(e) {
  84132. if (e.byteLength >= 12) {
  84133. var t = new Uint8Array(e.buffer,e.byteOffset,12);
  84134. if (171 === t[0] && 75 === t[1] && 84 === t[2] && 88 === t[3] && 32 === t[4] && 50 === t[5] && 48 === t[6] && 187 === t[7] && 13 === t[8] && 10 === t[9] && 26 === t[10] && 10 === t[11])
  84135. return !0
  84136. }
  84137. return !1
  84138. }
  84139. ,
  84140. e.URLConfig = {
  84141. jsDecoderModule: "https://preview.babylonjs.com/babylon.ktx2Decoder.js",
  84142. wasmUASTCToASTC: null,
  84143. wasmUASTCToBC7: null,
  84144. wasmUASTCToRGBA_UNORM: null,
  84145. wasmUASTCToRGBA_SRGB: null,
  84146. jsMSCTranscoder: null,
  84147. wasmMSCTranscoder: null,
  84148. wasmZSTDDecoder: null
  84149. },
  84150. e.DefaultNumWorkers = e.GetDefaultNumWorkers(),
  84151. e
  84152. }();
  84153. function bp() {
  84154. var e;
  84155. onmessage = function(t) {
  84156. if (t.data)
  84157. switch (t.data.action) {
  84158. case "init":
  84159. var i = t.data.urls;
  84160. importScripts(i.jsDecoderModule),
  84161. null !== i.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
  84162. null !== i.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
  84163. null !== i.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
  84164. null !== i.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
  84165. null !== i.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
  84166. null !== i.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
  84167. null !== i.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder),
  84168. e = new KTX2DECODER.KTX2Decoder,
  84169. postMessage({
  84170. action: "init"
  84171. });
  84172. break;
  84173. case "decode":
  84174. e.decode(t.data.data, t.data.caps, t.data.options).then((function(e) {
  84175. for (var t = [], i = 0; i < e.mipmaps.length; ++i) {
  84176. var n = e.mipmaps[i];
  84177. n && n.data && t.push(n.data.buffer)
  84178. }
  84179. postMessage({
  84180. action: "decoded",
  84181. success: !0,
  84182. decodedData: e
  84183. }, t)
  84184. }
  84185. )).catch((function(e) {
  84186. postMessage({
  84187. action: "decoded",
  84188. success: !1,
  84189. msg: e
  84190. })
  84191. }
  84192. ))
  84193. }
  84194. }
  84195. }
  84196. var Tp = function() {
  84197. function e() {
  84198. this.supportCascades = !1
  84199. }
  84200. return e.prototype.canLoad = function(e, t) {
  84201. return oe(e, ".ktx") || oe(e, ".ktx2") || "image/ktx" === t || "image/ktx2" === t
  84202. }
  84203. ,
  84204. e.prototype.loadCubeData = function(e, t, i, n) {
  84205. if (!Array.isArray(e)) {
  84206. t._invertVScale = !t.invertY;
  84207. var r = t.getEngine()
  84208. , o = new mp(e,6)
  84209. , a = o.numberOfMipmapLevels > 1 && t.generateMipMaps;
  84210. r._unpackFlipY(!0),
  84211. o.uploadLevels(t, t.generateMipMaps),
  84212. t.width = o.pixelWidth,
  84213. t.height = o.pixelHeight,
  84214. r._setCubeMapTextureParams(t, a, o.numberOfMipmapLevels - 1),
  84215. t.isReady = !0,
  84216. t.onLoadedObservable.notifyObservers(t),
  84217. t.onLoadedObservable.clear(),
  84218. n && n()
  84219. }
  84220. }
  84221. ,
  84222. e.prototype.loadData = function(e, t, i, n) {
  84223. if (mp.IsValid(e)) {
  84224. t._invertVScale = !t.invertY;
  84225. var r = new mp(e,1);
  84226. i(r.pixelWidth, r.pixelHeight, t.generateMipMaps, !0, (function() {
  84227. r.uploadLevels(t, t.generateMipMaps)
  84228. }
  84229. ), r.isInvalid)
  84230. } else
  84231. yp.IsValid(e) ? new yp(t.getEngine()).uploadAsync(e, t, n).then((function() {
  84232. i(t.width, t.height, t.generateMipMaps, !0, (function() {}
  84233. ), !1)
  84234. }
  84235. ), (function(e) {
  84236. K.Warn("Failed to load KTX2 texture data: ".concat(e.message)),
  84237. i(0, 0, !1, !1, (function() {}
  84238. ), !0)
  84239. }
  84240. )) : (K.Error("texture missing KTX identifier"),
  84241. i(0, 0, !1, !1, (function() {}
  84242. ), !0))
  84243. }
  84244. ,
  84245. e
  84246. }();
  84247. vr._TextureLoaders.unshift(new Tp);
  84248. var Ep = function(e) {
  84249. function t(t, i, n) {
  84250. var r = e.call(this, t, x.Zero(), i) || this;
  84251. return r._xrSessionManager = n,
  84252. r._firstFrame = !1,
  84253. r._referenceQuaternion = C.Identity(),
  84254. r._referencedPosition = new x,
  84255. r._trackingState = Ls.NOT_TRACKING,
  84256. r.onBeforeCameraTeleport = new h,
  84257. r.onAfterCameraTeleport = new h,
  84258. r.onTrackingStateChanged = new h,
  84259. r.compensateOnFirstFrame = !0,
  84260. r._rotate180 = new C(0,1,0,0),
  84261. r.minZ = .1,
  84262. r.rotationQuaternion = new C,
  84263. r.cameraRigMode = Rr.RIG_MODE_CUSTOM,
  84264. r.updateUpVectorFromRotation = !0,
  84265. r._updateNumberOfRigCameras(1),
  84266. r.freezeProjectionMatrix(),
  84267. r._xrSessionManager.onXRSessionInit.add((function() {
  84268. r._referencedPosition.copyFromFloats(0, 0, 0),
  84269. r._referenceQuaternion.copyFromFloats(0, 0, 0, 1),
  84270. r._firstFrame = r.compensateOnFirstFrame
  84271. }
  84272. )),
  84273. r._xrSessionManager.onXRFrameObservable.add((function() {
  84274. r._firstFrame && r._updateFromXRSession(),
  84275. r._updateReferenceSpace(),
  84276. r._updateFromXRSession()
  84277. }
  84278. ), void 0, !0),
  84279. r
  84280. }
  84281. return U(t, e),
  84282. Object.defineProperty(t.prototype, "trackingState", {
  84283. get: function() {
  84284. return this._trackingState
  84285. },
  84286. enumerable: !1,
  84287. configurable: !0
  84288. }),
  84289. t.prototype._setTrackingState = function(e) {
  84290. this._trackingState !== e && (this._trackingState = e,
  84291. this.onTrackingStateChanged.notifyObservers(e))
  84292. }
  84293. ,
  84294. Object.defineProperty(t.prototype, "realWorldHeight", {
  84295. get: function() {
  84296. var e = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
  84297. return e && e.transform ? e.transform.position.y : 0
  84298. },
  84299. enumerable: !1,
  84300. configurable: !0
  84301. }),
  84302. t.prototype._updateForDualEyeDebugging = function() {
  84303. this._updateNumberOfRigCameras(2),
  84304. this.rigCameras[0].viewport = new xr(0,0,.5,1),
  84305. this.rigCameras[0].outputRenderTarget = null,
  84306. this.rigCameras[1].viewport = new xr(.5,0,.5,1),
  84307. this.rigCameras[1].outputRenderTarget = null
  84308. }
  84309. ,
  84310. t.prototype.setTransformationFromNonVRCamera = function(e, t) {
  84311. void 0 === e && (e = this.getScene().activeCamera),
  84312. void 0 === t && (t = !0),
  84313. e && e !== this && (e.computeWorldMatrix().decompose(void 0, this.rotationQuaternion, this.position),
  84314. this.position.y = 0,
  84315. C.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion),
  84316. this._firstFrame = !0,
  84317. t && this._xrSessionManager.resetReferenceSpace())
  84318. }
  84319. ,
  84320. t.prototype.getClassName = function() {
  84321. return "WebXRCamera"
  84322. }
  84323. ,
  84324. t.prototype.dispose = function() {
  84325. e.prototype.dispose.call(this),
  84326. this._lastXRViewerPose = void 0
  84327. }
  84328. ,
  84329. t.prototype._updateFromXRSession = function() {
  84330. var e = this
  84331. , t = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
  84332. if (this._lastXRViewerPose = t || void 0,
  84333. t) {
  84334. var i = t.emulatedPosition ? Ls.TRACKING_LOST : Ls.TRACKING;
  84335. if (this._setTrackingState(i),
  84336. t.transform) {
  84337. var n = t.transform.orientation;
  84338. if (void 0 === t.transform.orientation.x)
  84339. return;
  84340. var r = t.transform.position;
  84341. this._referencedPosition.set(r.x, r.y, r.z),
  84342. this._referenceQuaternion.set(n.x, n.y, n.z, n.w),
  84343. this._scene.useRightHandedSystem || (this._referencedPosition.z *= -1,
  84344. this._referenceQuaternion.z *= -1,
  84345. this._referenceQuaternion.w *= -1),
  84346. this._firstFrame ? (this._firstFrame = !1,
  84347. this.position.y += this._referencedPosition.y,
  84348. this._referenceQuaternion.copyFromFloats(0, 0, 0, 1)) : (this.rotationQuaternion.copyFrom(this._referenceQuaternion),
  84349. this.position.copyFrom(this._referencedPosition))
  84350. }
  84351. this.rigCameras.length !== t.views.length && this._updateNumberOfRigCameras(t.views.length),
  84352. t.views.forEach((function(t, i) {
  84353. var n, r = e.rigCameras[i];
  84354. r.isLeftCamera || r.isRightCamera || ("right" === t.eye ? r._isRightCamera = !0 : "left" === t.eye && (r._isLeftCamera = !0));
  84355. var o = t.transform.position
  84356. , a = t.transform.orientation;
  84357. r.parent = e.parent,
  84358. r.position.set(o.x, o.y, o.z),
  84359. r.rotationQuaternion.set(a.x, a.y, a.z, a.w),
  84360. e._scene.useRightHandedSystem ? r.rotationQuaternion.multiplyInPlace(e._rotate180) : (r.position.z *= -1,
  84361. r.rotationQuaternion.z *= -1,
  84362. r.rotationQuaternion.w *= -1),
  84363. P.FromFloat32ArrayToRefScaled(t.projectionMatrix, 0, 1, r._projectionMatrix),
  84364. e._scene.useRightHandedSystem || r._projectionMatrix.toggleProjectionMatrixHandInPlace(),
  84365. 0 === i && e._projectionMatrix.copyFrom(r._projectionMatrix);
  84366. var s = e._xrSessionManager.getRenderTargetTextureForView(t);
  84367. e._renderingMultiview = (null === (n = null == s ? void 0 : s._texture) || void 0 === n ? void 0 : n.isMultiview) || !1,
  84368. e._renderingMultiview ? 0 == i && (e._xrSessionManager.trySetViewportForView(e.viewport, t),
  84369. e.outputRenderTarget = s) : (e._xrSessionManager.trySetViewportForView(r.viewport, t),
  84370. r.outputRenderTarget = s || e._xrSessionManager.getRenderTargetTextureForView(t))
  84371. }
  84372. ))
  84373. } else
  84374. this._setTrackingState(Ls.NOT_TRACKING)
  84375. }
  84376. ,
  84377. t.prototype._updateNumberOfRigCameras = function(e) {
  84378. for (void 0 === e && (e = 1); this.rigCameras.length < e; ) {
  84379. var t = new da("XR-RigCamera: " + this.rigCameras.length,x.Zero(),this.getScene());
  84380. t.minZ = .1,
  84381. t.rotationQuaternion = new C,
  84382. t.updateUpVectorFromRotation = !0,
  84383. t.isRigCamera = !0,
  84384. t.rigParent = this,
  84385. t.freezeProjectionMatrix(),
  84386. this.rigCameras.push(t)
  84387. }
  84388. for (; this.rigCameras.length > e; ) {
  84389. var i = this.rigCameras.pop();
  84390. i && i.dispose()
  84391. }
  84392. }
  84393. ,
  84394. t.prototype._updateReferenceSpace = function() {
  84395. if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
  84396. var e = I.Matrix[0]
  84397. , i = I.Matrix[1]
  84398. , n = I.Matrix[2];
  84399. P.ComposeToRef(t._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, e),
  84400. P.ComposeToRef(t._ScaleReadOnly, this.rotationQuaternion, this.position, i),
  84401. e.invert().multiplyToRef(i, n),
  84402. n.invert(),
  84403. this._scene.useRightHandedSystem || n.toggleModelMatrixHandInPlace(),
  84404. n.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
  84405. var r = new XRRigidTransform({
  84406. x: this._referencedPosition.x,
  84407. y: this._referencedPosition.y,
  84408. z: this._referencedPosition.z
  84409. },{
  84410. x: this._referenceQuaternion.x,
  84411. y: this._referenceQuaternion.y,
  84412. z: this._referenceQuaternion.z,
  84413. w: this._referenceQuaternion.w
  84414. });
  84415. this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(r)
  84416. }
  84417. }
  84418. ,
  84419. t._ScaleReadOnly = x.One(),
  84420. t
  84421. }(pa)
  84422. , Sp = function() {
  84423. function e(e) {
  84424. var t = this;
  84425. this._scene = e,
  84426. this._nonVRCamera = null,
  84427. this._attachedToElement = !1,
  84428. this._spectatorCamera = null,
  84429. this._originalSceneAutoClear = !0,
  84430. this._supported = !1,
  84431. this._spectatorMode = !1,
  84432. this.onInitialXRPoseSetObservable = new h,
  84433. this.onStateChangedObservable = new h,
  84434. this.state = Ns.NOT_IN_XR,
  84435. this.sessionManager = new Xs(e),
  84436. this.camera = new Ep("webxr",e,this.sessionManager),
  84437. this.featuresManager = new Oo(this.sessionManager),
  84438. e.onDisposeObservable.addOnce((function() {
  84439. t.dispose()
  84440. }
  84441. ))
  84442. }
  84443. return e.CreateAsync = function(t) {
  84444. var i = new e(t);
  84445. return i.sessionManager.initializeAsync().then((function() {
  84446. return i._supported = !0,
  84447. i
  84448. }
  84449. )).catch((function(e) {
  84450. throw i._setState(Ns.NOT_IN_XR),
  84451. i.dispose(),
  84452. e
  84453. }
  84454. ))
  84455. }
  84456. ,
  84457. e.prototype.dispose = function() {
  84458. var e;
  84459. this.exitXRAsync(),
  84460. this.camera.dispose(),
  84461. this.onStateChangedObservable.clear(),
  84462. this.onInitialXRPoseSetObservable.clear(),
  84463. this.sessionManager.dispose(),
  84464. null === (e = this._spectatorCamera) || void 0 === e || e.dispose(),
  84465. this._nonVRCamera && (this._scene.activeCamera = this._nonVRCamera)
  84466. }
  84467. ,
  84468. e.prototype.enterXRAsync = function(e, t, i, n) {
  84469. var r, o;
  84470. return void 0 === i && (i = this.sessionManager.getWebXRRenderTarget()),
  84471. void 0 === n && (n = {}),
  84472. G(this, void 0, void 0, (function() {
  84473. var a, s, l, c = this;
  84474. return z(this, (function(u) {
  84475. switch (u.label) {
  84476. case 0:
  84477. if (!this._supported)
  84478. throw "WebXR not supported in this browser or environment";
  84479. return this._setState(Ns.ENTERING_XR),
  84480. "viewer" !== t && "local" !== t && (n.optionalFeatures = n.optionalFeatures || [],
  84481. n.optionalFeatures.push(t)),
  84482. [4, this.featuresManager._extendXRSessionInitObject(n)];
  84483. case 1:
  84484. n = u.sent(),
  84485. "immersive-ar" === e && "unbounded" !== t && K.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),
  84486. u.label = 2;
  84487. case 2:
  84488. return u.trys.push([2, 6, , 7]),
  84489. [4, this.sessionManager.initializeSessionAsync(e, n)];
  84490. case 3:
  84491. return u.sent(),
  84492. [4, this.sessionManager.setReferenceSpaceTypeAsync(t)];
  84493. case 4:
  84494. return u.sent(),
  84495. [4, i.initializeXRLayerAsync(this.sessionManager.session)];
  84496. case 5:
  84497. return a = u.sent(),
  84498. s = {
  84499. depthFar: this.camera.maxZ,
  84500. depthNear: this.camera.minZ
  84501. },
  84502. this.featuresManager.getEnabledFeature(Io.LAYERS) || (s.baseLayer = a),
  84503. this.sessionManager.updateRenderState(s),
  84504. this.sessionManager.runXRRenderLoop(),
  84505. this._originalSceneAutoClear = this._scene.autoClear,
  84506. this._nonVRCamera = this._scene.activeCamera,
  84507. this._attachedToElement = !!(null === (r = this._nonVRCamera) || void 0 === r ? void 0 : r.inputs.attachedToElement),
  84508. null === (o = this._nonVRCamera) || void 0 === o || o.detachControl(),
  84509. this._scene.activeCamera = this.camera,
  84510. "immersive-ar" !== e ? this._nonXRToXRCamera() : (this._scene.autoClear = !1,
  84511. this.camera.compensateOnFirstFrame = !1,
  84512. this.camera.position.set(0, 0, 0),
  84513. this.camera.rotationQuaternion.set(0, 0, 0, 1)),
  84514. this.sessionManager.onXRSessionEnded.addOnce((function() {
  84515. c.state !== Ns.EXITING_XR && c._setState(Ns.EXITING_XR),
  84516. c.camera.rigCameras.forEach((function(e) {
  84517. e.outputRenderTarget = null
  84518. }
  84519. )),
  84520. c._scene.autoClear = c._originalSceneAutoClear,
  84521. c._scene.activeCamera = c._nonVRCamera,
  84522. c._attachedToElement && c._nonVRCamera && c._nonVRCamera.attachControl(!!c._nonVRCamera.inputs.noPreventDefault),
  84523. "immersive-ar" !== e && c.camera.compensateOnFirstFrame && (c._nonVRCamera.setPosition ? c._nonVRCamera.setPosition(c.camera.position) : c._nonVRCamera.position.copyFrom(c.camera.position)),
  84524. c._setState(Ns.NOT_IN_XR)
  84525. }
  84526. )),
  84527. this.sessionManager.onXRFrameObservable.addOnce((function() {
  84528. c._setState(Ns.IN_XR)
  84529. }
  84530. )),
  84531. [2, this.sessionManager];
  84532. case 6:
  84533. throw l = u.sent(),
  84534. console.log(l),
  84535. console.log(l.message),
  84536. this._setState(Ns.NOT_IN_XR),
  84537. l;
  84538. case 7:
  84539. return [2]
  84540. }
  84541. }
  84542. ))
  84543. }
  84544. ))
  84545. }
  84546. ,
  84547. e.prototype.exitXRAsync = function() {
  84548. return this.state !== Ns.IN_XR ? Promise.resolve() : (this._setState(Ns.EXITING_XR),
  84549. this.sessionManager.exitXRAsync())
  84550. }
  84551. ,
  84552. e.prototype.enableSpectatorMode = function() {
  84553. var e = this;
  84554. if (!this._spectatorMode) {
  84555. var t = function() {
  84556. e._spectatorCamera && (e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),
  84557. e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))
  84558. }
  84559. , i = function() {
  84560. e.state === Ns.IN_XR ? (e._spectatorCamera = new Na("webxr-spectator",x.Zero(),e._scene),
  84561. e._spectatorCamera.rotationQuaternion = new C,
  84562. e._scene.activeCameras = [e.camera, e._spectatorCamera],
  84563. e.sessionManager.onXRFrameObservable.add(t),
  84564. e._scene.onAfterRenderCameraObservable.add((function(t) {
  84565. t === e.camera && (e._scene.getEngine().framebufferDimensionsObject = null)
  84566. }
  84567. ))) : e.state === Ns.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(t),
  84568. e._scene.activeCameras = null)
  84569. };
  84570. this._spectatorMode = !0,
  84571. this.onStateChangedObservable.add(i),
  84572. i()
  84573. }
  84574. }
  84575. ,
  84576. e.prototype._nonXRToXRCamera = function() {
  84577. this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),
  84578. this.onInitialXRPoseSetObservable.notifyObservers(this.camera)
  84579. }
  84580. ,
  84581. e.prototype._setState = function(e) {
  84582. this.state !== e && (this.state = e,
  84583. this.onStateChangedObservable.notifyObservers(this.state))
  84584. }
  84585. ,
  84586. e
  84587. }()
  84588. , Ap = function() {
  84589. function e(e, t, i, n) {
  84590. void 0 === i && (i = -1),
  84591. void 0 === n && (n = []),
  84592. this.id = e,
  84593. this.type = t,
  84594. this._buttonIndex = i,
  84595. this._axesIndices = n,
  84596. this._axes = {
  84597. x: 0,
  84598. y: 0
  84599. },
  84600. this._changes = {},
  84601. this._currentValue = 0,
  84602. this._hasChanges = !1,
  84603. this._pressed = !1,
  84604. this._touched = !1,
  84605. this.onAxisValueChangedObservable = new h,
  84606. this.onButtonStateChangedObservable = new h
  84607. }
  84608. return Object.defineProperty(e.prototype, "axes", {
  84609. get: function() {
  84610. return this._axes
  84611. },
  84612. enumerable: !1,
  84613. configurable: !0
  84614. }),
  84615. Object.defineProperty(e.prototype, "changes", {
  84616. get: function() {
  84617. return this._changes
  84618. },
  84619. enumerable: !1,
  84620. configurable: !0
  84621. }),
  84622. Object.defineProperty(e.prototype, "hasChanges", {
  84623. get: function() {
  84624. return this._hasChanges
  84625. },
  84626. enumerable: !1,
  84627. configurable: !0
  84628. }),
  84629. Object.defineProperty(e.prototype, "pressed", {
  84630. get: function() {
  84631. return this._pressed
  84632. },
  84633. enumerable: !1,
  84634. configurable: !0
  84635. }),
  84636. Object.defineProperty(e.prototype, "touched", {
  84637. get: function() {
  84638. return this._touched
  84639. },
  84640. enumerable: !1,
  84641. configurable: !0
  84642. }),
  84643. Object.defineProperty(e.prototype, "value", {
  84644. get: function() {
  84645. return this._currentValue
  84646. },
  84647. enumerable: !1,
  84648. configurable: !0
  84649. }),
  84650. e.prototype.dispose = function() {
  84651. this.onAxisValueChangedObservable.clear(),
  84652. this.onButtonStateChangedObservable.clear()
  84653. }
  84654. ,
  84655. e.prototype.isAxes = function() {
  84656. return 0 !== this._axesIndices.length
  84657. }
  84658. ,
  84659. e.prototype.isButton = function() {
  84660. return -1 !== this._buttonIndex
  84661. }
  84662. ,
  84663. e.prototype.update = function(e) {
  84664. var t = !1
  84665. , i = !1;
  84666. if (this._hasChanges = !1,
  84667. this._changes = {},
  84668. this.isButton()) {
  84669. var n = e.buttons[this._buttonIndex];
  84670. if (!n)
  84671. return;
  84672. this._currentValue !== n.value && (this.changes.value = {
  84673. current: n.value,
  84674. previous: this._currentValue
  84675. },
  84676. t = !0,
  84677. this._currentValue = n.value),
  84678. this._touched !== n.touched && (this.changes.touched = {
  84679. current: n.touched,
  84680. previous: this._touched
  84681. },
  84682. t = !0,
  84683. this._touched = n.touched),
  84684. this._pressed !== n.pressed && (this.changes.pressed = {
  84685. current: n.pressed,
  84686. previous: this._pressed
  84687. },
  84688. t = !0,
  84689. this._pressed = n.pressed)
  84690. }
  84691. this.isAxes() && (this._axes.x !== e.axes[this._axesIndices[0]] && (this.changes.axes = {
  84692. current: {
  84693. x: e.axes[this._axesIndices[0]],
  84694. y: this._axes.y
  84695. },
  84696. previous: {
  84697. x: this._axes.x,
  84698. y: this._axes.y
  84699. }
  84700. },
  84701. this._axes.x = e.axes[this._axesIndices[0]],
  84702. i = !0),
  84703. this._axes.y !== e.axes[this._axesIndices[1]] && (this.changes.axes ? this.changes.axes.current.y = e.axes[this._axesIndices[1]] : this.changes.axes = {
  84704. current: {
  84705. x: this._axes.x,
  84706. y: e.axes[this._axesIndices[1]]
  84707. },
  84708. previous: {
  84709. x: this._axes.x,
  84710. y: this._axes.y
  84711. }
  84712. },
  84713. this._axes.y = e.axes[this._axesIndices[1]],
  84714. i = !0)),
  84715. t && (this._hasChanges = !0,
  84716. this.onButtonStateChangedObservable.notifyObservers(this)),
  84717. i && (this._hasChanges = !0,
  84718. this.onAxisValueChangedObservable.notifyObservers(this._axes))
  84719. }
  84720. ,
  84721. e.BUTTON_TYPE = "button",
  84722. e.SQUEEZE_TYPE = "squeeze",
  84723. e.THUMBSTICK_TYPE = "thumbstick",
  84724. e.TOUCHPAD_TYPE = "touchpad",
  84725. e.TRIGGER_TYPE = "trigger",
  84726. e
  84727. }()
  84728. , xp = function() {
  84729. function e(e, t, i, n, r, o) {
  84730. void 0 === r && (r = !1);
  84731. var a = this;
  84732. this.scene = e,
  84733. this.layout = t,
  84734. this.gamepadObject = i,
  84735. this.handedness = n,
  84736. this._doNotLoadControllerMesh = r,
  84737. this._controllerCache = o,
  84738. this._initComponent = function(e) {
  84739. if (e) {
  84740. var t = a.layout.components[e]
  84741. , i = t.type
  84742. , n = t.gamepadIndices.button
  84743. , r = [];
  84744. void 0 !== t.gamepadIndices.xAxis && void 0 !== t.gamepadIndices.yAxis && r.push(t.gamepadIndices.xAxis, t.gamepadIndices.yAxis),
  84745. a.components[e] = new Ap(e,i,n,r)
  84746. }
  84747. }
  84748. ,
  84749. this._modelReady = !1,
  84750. this.components = {},
  84751. this.disableAnimation = !1,
  84752. this.onModelLoadedObservable = new h,
  84753. t.components && Object.keys(t.components).forEach(this._initComponent)
  84754. }
  84755. return e.prototype.dispose = function() {
  84756. var e = this;
  84757. this.getComponentIds().forEach((function(t) {
  84758. return e.getComponent(t).dispose()
  84759. }
  84760. )),
  84761. this.rootMesh && (this.rootMesh.getChildren(void 0, !0).forEach((function(e) {
  84762. e.setEnabled(!1)
  84763. }
  84764. )),
  84765. this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache))
  84766. }
  84767. ,
  84768. e.prototype.getAllComponentsOfType = function(e) {
  84769. var t = this;
  84770. return this.getComponentIds().map((function(e) {
  84771. return t.components[e]
  84772. }
  84773. )).filter((function(t) {
  84774. return t.type === e
  84775. }
  84776. ))
  84777. }
  84778. ,
  84779. e.prototype.getComponent = function(e) {
  84780. return this.components[e]
  84781. }
  84782. ,
  84783. e.prototype.getComponentIds = function() {
  84784. return Object.keys(this.components)
  84785. }
  84786. ,
  84787. e.prototype.getComponentOfType = function(e) {
  84788. return this.getAllComponentsOfType(e)[0] || null
  84789. }
  84790. ,
  84791. e.prototype.getMainComponent = function() {
  84792. return this.getComponent(this.layout.selectComponentId)
  84793. }
  84794. ,
  84795. e.prototype.loadModel = function() {
  84796. return G(this, void 0, void 0, (function() {
  84797. var e, t, i = this;
  84798. return z(this, (function(n) {
  84799. return e = !this._getModelLoadingConstraints(),
  84800. t = this._getGenericFilenameAndPath(),
  84801. e ? K.Warn("Falling back to generic models") : t = this._getFilenameAndPath(),
  84802. [2, new Promise((function(n, r) {
  84803. var o = function(t) {
  84804. e ? i._getGenericParentMesh(t) : i._setRootMesh(t),
  84805. i._processLoadedModel(t),
  84806. i._modelReady = !0,
  84807. i.onModelLoadedObservable.notifyObservers(i),
  84808. n(!0)
  84809. };
  84810. if (i._controllerCache) {
  84811. var a = i._controllerCache.filter((function(e) {
  84812. return e.filename === t.filename && e.path === t.path
  84813. }
  84814. ));
  84815. if (a[0])
  84816. return a[0].meshes.forEach((function(e) {
  84817. return e.setEnabled(!0)
  84818. }
  84819. )),
  84820. void o(a[0].meshes)
  84821. }
  84822. od.ImportMesh("", t.path, t.filename, i.scene, (function(e) {
  84823. i._controllerCache && i._controllerCache.push(V(V({}, t), {
  84824. meshes: e
  84825. })),
  84826. o(e)
  84827. }
  84828. ), null, (function(e, n) {
  84829. K.Log(n),
  84830. K.Warn("Failed to retrieve controller model of type ".concat(i.profileId, " from the remote server: ").concat(t.path).concat(t.filename)),
  84831. r(n)
  84832. }
  84833. ))
  84834. }
  84835. ))]
  84836. }
  84837. ))
  84838. }
  84839. ))
  84840. }
  84841. ,
  84842. e.prototype.updateFromXRFrame = function(e) {
  84843. var t = this;
  84844. this.getComponentIds().forEach((function(e) {
  84845. return t.getComponent(e).update(t.gamepadObject)
  84846. }
  84847. )),
  84848. this.updateModel(e)
  84849. }
  84850. ,
  84851. Object.defineProperty(e.prototype, "handness", {
  84852. get: function() {
  84853. return this.handedness
  84854. },
  84855. enumerable: !1,
  84856. configurable: !0
  84857. }),
  84858. e.prototype.pulse = function(e, t, i) {
  84859. return void 0 === i && (i = 0),
  84860. this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[i] ? this.gamepadObject.hapticActuators[i].pulse(e, t) : Promise.resolve(!1)
  84861. }
  84862. ,
  84863. e.prototype._getChildByName = function(e, t) {
  84864. return e.getChildren((function(e) {
  84865. return e.name === t
  84866. }
  84867. ), !1)[0]
  84868. }
  84869. ,
  84870. e.prototype._getImmediateChildByName = function(e, t) {
  84871. return e.getChildren((function(e) {
  84872. return e.name == t
  84873. }
  84874. ), !0)[0]
  84875. }
  84876. ,
  84877. e.prototype._lerpTransform = function(e, t, i) {
  84878. if (e.minMesh && e.maxMesh && e.valueMesh && e.minMesh.rotationQuaternion && e.maxMesh.rotationQuaternion && e.valueMesh.rotationQuaternion) {
  84879. var n = i ? .5 * t + .5 : t;
  84880. C.SlerpToRef(e.minMesh.rotationQuaternion, e.maxMesh.rotationQuaternion, n, e.valueMesh.rotationQuaternion),
  84881. x.LerpToRef(e.minMesh.position, e.maxMesh.position, n, e.valueMesh.position)
  84882. }
  84883. }
  84884. ,
  84885. e.prototype.updateModel = function(e) {
  84886. this._modelReady && this._updateModel(e)
  84887. }
  84888. ,
  84889. e.prototype._getGenericFilenameAndPath = function() {
  84890. return {
  84891. filename: "generic.babylon",
  84892. path: "https://controllers.babylonjs.com/generic/"
  84893. }
  84894. }
  84895. ,
  84896. e.prototype._getGenericParentMesh = function(e) {
  84897. var t = this;
  84898. this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
  84899. e.forEach((function(e) {
  84900. e.parent || (e.isPickable = !1,
  84901. e.setParent(t.rootMesh))
  84902. }
  84903. )),
  84904. this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
  84905. }
  84906. ,
  84907. e
  84908. }()
  84909. , Rp = function(e) {
  84910. function t(i, n, r) {
  84911. var o = e.call(this, i, Cp[r], n, r) || this;
  84912. return o.profileId = t.ProfileId,
  84913. o
  84914. }
  84915. return U(t, e),
  84916. t.prototype._getFilenameAndPath = function() {
  84917. return {
  84918. filename: "generic.babylon",
  84919. path: "https://controllers.babylonjs.com/generic/"
  84920. }
  84921. }
  84922. ,
  84923. t.prototype._getModelLoadingConstraints = function() {
  84924. return !0
  84925. }
  84926. ,
  84927. t.prototype._processLoadedModel = function(e) {}
  84928. ,
  84929. t.prototype._setRootMesh = function(e) {
  84930. var t = this;
  84931. this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
  84932. e.forEach((function(e) {
  84933. e.isPickable = !1,
  84934. e.parent || e.setParent(t.rootMesh)
  84935. }
  84936. )),
  84937. this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
  84938. }
  84939. ,
  84940. t.prototype._updateModel = function() {}
  84941. ,
  84942. t.ProfileId = "generic-trigger",
  84943. t
  84944. }(xp)
  84945. , Cp = {
  84946. left: {
  84947. selectComponentId: "xr-standard-trigger",
  84948. components: {
  84949. "xr-standard-trigger": {
  84950. type: "trigger",
  84951. gamepadIndices: {
  84952. button: 0
  84953. },
  84954. rootNodeName: "xr_standard_trigger",
  84955. visualResponses: {}
  84956. }
  84957. },
  84958. gamepadMapping: "xr-standard",
  84959. rootNodeName: "generic-trigger-left",
  84960. assetPath: "left.glb"
  84961. },
  84962. right: {
  84963. selectComponentId: "xr-standard-trigger",
  84964. components: {
  84965. "xr-standard-trigger": {
  84966. type: "trigger",
  84967. gamepadIndices: {
  84968. button: 0
  84969. },
  84970. rootNodeName: "xr_standard_trigger",
  84971. visualResponses: {}
  84972. }
  84973. },
  84974. gamepadMapping: "xr-standard",
  84975. rootNodeName: "generic-trigger-right",
  84976. assetPath: "right.glb"
  84977. },
  84978. none: {
  84979. selectComponentId: "xr-standard-trigger",
  84980. components: {
  84981. "xr-standard-trigger": {
  84982. type: "trigger",
  84983. gamepadIndices: {
  84984. button: 0
  84985. },
  84986. rootNodeName: "xr_standard_trigger",
  84987. visualResponses: {}
  84988. }
  84989. },
  84990. gamepadMapping: "xr-standard",
  84991. rootNodeName: "generic-trigger-none",
  84992. assetPath: "none.glb"
  84993. }
  84994. }
  84995. , Pp = function(e) {
  84996. function t(t, i, n, r, o) {
  84997. var a = e.call(this, t, n.layouts[i.handedness || "none"], i.gamepad, i.handedness, void 0, o) || this;
  84998. return a._repositoryUrl = r,
  84999. a.controllerCache = o,
  85000. a._buttonMeshMapping = {},
  85001. a._touchDots = {},
  85002. a.profileId = n.profileId,
  85003. a
  85004. }
  85005. return U(t, e),
  85006. t.prototype.dispose = function() {
  85007. var t = this;
  85008. e.prototype.dispose.call(this),
  85009. this.controllerCache || Object.keys(this._touchDots).forEach((function(e) {
  85010. t._touchDots[e].dispose()
  85011. }
  85012. ))
  85013. }
  85014. ,
  85015. t.prototype._getFilenameAndPath = function() {
  85016. return {
  85017. filename: this.layout.assetPath,
  85018. path: "".concat(this._repositoryUrl, "/profiles/").concat(this.profileId, "/")
  85019. }
  85020. }
  85021. ,
  85022. t.prototype._getModelLoadingConstraints = function() {
  85023. var e = od.IsPluginForExtensionAvailable(".glb");
  85024. return e || K.Warn("glTF / glb loader was not registered, using generic controller instead"),
  85025. e
  85026. }
  85027. ,
  85028. t.prototype._processLoadedModel = function(e) {
  85029. var t = this;
  85030. this.getComponentIds().forEach((function(e) {
  85031. var i = t.layout.components[e];
  85032. t._buttonMeshMapping[e] = {
  85033. mainMesh: t._getChildByName(t.rootMesh, i.rootNodeName),
  85034. states: {}
  85035. },
  85036. Object.keys(i.visualResponses).forEach((function(n) {
  85037. var r = i.visualResponses[n];
  85038. if ("transform" === r.valueNodeProperty)
  85039. t._buttonMeshMapping[e].states[n] = {
  85040. valueMesh: t._getChildByName(t.rootMesh, r.valueNodeName),
  85041. minMesh: t._getChildByName(t.rootMesh, r.minNodeName),
  85042. maxMesh: t._getChildByName(t.rootMesh, r.maxNodeName)
  85043. };
  85044. else {
  85045. var o = i.type === Ap.TOUCHPAD_TYPE && i.touchPointNodeName ? i.touchPointNodeName : r.valueNodeName;
  85046. if (t._buttonMeshMapping[e].states[n] = {
  85047. valueMesh: t._getChildByName(t.rootMesh, o)
  85048. },
  85049. i.type === Ap.TOUCHPAD_TYPE && !t._touchDots[n]) {
  85050. var a = Dl(n + "dot", {
  85051. diameter: .0015,
  85052. segments: 8
  85053. }, t.scene);
  85054. a.material = new Os(n + "mat",t.scene),
  85055. a.material.diffuseColor = D.Red(),
  85056. a.parent = t._buttonMeshMapping[e].states[n].valueMesh || null,
  85057. a.isVisible = !1,
  85058. t._touchDots[n] = a
  85059. }
  85060. }
  85061. }
  85062. ))
  85063. }
  85064. ))
  85065. }
  85066. ,
  85067. t.prototype._setRootMesh = function(e) {
  85068. var t;
  85069. this.rootMesh = new Vr(this.profileId + "-" + this.handedness,this.scene),
  85070. this.rootMesh.isPickable = !1;
  85071. for (var i = 0; i < e.length; i++) {
  85072. var n = e[i];
  85073. n.isPickable = !1,
  85074. n.parent || (t = n)
  85075. }
  85076. t && t.setParent(this.rootMesh),
  85077. this.scene.useRightHandedSystem || this.rootMesh.rotate(vn.Y, Math.PI, Ji.WORLD)
  85078. }
  85079. ,
  85080. t.prototype._updateModel = function(e) {
  85081. var t = this;
  85082. this.disableAnimation || this.getComponentIds().forEach((function(e) {
  85083. var i = t.getComponent(e);
  85084. if (i.hasChanges) {
  85085. var n = t._buttonMeshMapping[e]
  85086. , r = t.layout.components[e];
  85087. Object.keys(r.visualResponses).forEach((function(e) {
  85088. var o = r.visualResponses[e]
  85089. , a = i.value;
  85090. if ("xAxis" === o.componentProperty ? a = i.axes.x : "yAxis" === o.componentProperty && (a = i.axes.y),
  85091. "transform" === o.valueNodeProperty)
  85092. t._lerpTransform(n.states[e], a, "button" !== o.componentProperty);
  85093. else {
  85094. var s = n.states[e].valueMesh;
  85095. s && (s.isVisible = i.touched || i.pressed),
  85096. t._touchDots[e] && (t._touchDots[e].isVisible = i.touched || i.pressed)
  85097. }
  85098. }
  85099. ))
  85100. }
  85101. }
  85102. ))
  85103. }
  85104. ,
  85105. t
  85106. }(xp)
  85107. , Mp = []
  85108. , Ip = function() {
  85109. function e() {}
  85110. return e.ClearProfilesCache = function() {
  85111. this._ProfilesList = null,
  85112. this._ProfileLoadingPromises = {}
  85113. }
  85114. ,
  85115. e.DefaultFallbacks = function() {
  85116. this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]),
  85117. this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]),
  85118. this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]),
  85119. this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]),
  85120. this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]),
  85121. this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
  85122. this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]),
  85123. this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]),
  85124. this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]),
  85125. this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
  85126. this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]),
  85127. this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]),
  85128. this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"])
  85129. }
  85130. ,
  85131. e.FindFallbackWithProfileId = function(e) {
  85132. var t = this._Fallbacks[e] || [];
  85133. return t.unshift(e),
  85134. t
  85135. }
  85136. ,
  85137. e.GetMotionControllerWithXRInput = function(e, t, i) {
  85138. var n = this
  85139. , r = [];
  85140. i && r.push(i),
  85141. r.push.apply(r, e.profiles || []),
  85142. r.length && !r[0] && r.pop(),
  85143. e.gamepad && e.gamepad.id && e.gamepad.id === (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0) && r.push("oculus-touch-v2");
  85144. var o = r.indexOf("windows-mixed-reality");
  85145. if (-1 !== o && r.splice(o, 0, "microsoft-mixed-reality"),
  85146. r.length || r.push("generic-trigger"),
  85147. this.UseOnlineRepository) {
  85148. var a = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers
  85149. , s = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
  85150. return a.call(this, r, e, t).catch((function() {
  85151. return s.call(n, r, e, t)
  85152. }
  85153. ))
  85154. }
  85155. return this._LoadProfilesFromAvailableControllers(r, e, t)
  85156. }
  85157. ,
  85158. e.RegisterController = function(e, t) {
  85159. this._AvailableControllers[e] = t
  85160. }
  85161. ,
  85162. e.RegisterFallbacksForProfileId = function(e, t) {
  85163. var i;
  85164. this._Fallbacks[e] ? (i = this._Fallbacks[e]).push.apply(i, t) : this._Fallbacks[e] = t
  85165. }
  85166. ,
  85167. e.UpdateProfilesList = function() {
  85168. return this._ProfilesList = gi.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then((function(e) {
  85169. return JSON.parse(e.toString())
  85170. }
  85171. )),
  85172. this._ProfilesList
  85173. }
  85174. ,
  85175. e.ClearControllerCache = function() {
  85176. Mp.forEach((function(e) {
  85177. e.meshes.forEach((function(e) {
  85178. e.dispose(!1, !0)
  85179. }
  85180. ))
  85181. }
  85182. )),
  85183. Mp.length = 0
  85184. }
  85185. ,
  85186. e._LoadProfileFromRepository = function(e, t, i) {
  85187. var n = this;
  85188. return Promise.resolve().then((function() {
  85189. return n._ProfilesList ? n._ProfilesList : n.UpdateProfilesList()
  85190. }
  85191. )).then((function(t) {
  85192. for (var i = 0; i < e.length; ++i)
  85193. if (e[i] && t[e[i]])
  85194. return e[i];
  85195. throw new Error("neither controller ".concat(e[0], " nor all fallbacks were found in the repository,"))
  85196. }
  85197. )).then((function(e) {
  85198. return n._ProfileLoadingPromises[e] || (n._ProfileLoadingPromises[e] = gi.LoadFileAsync("".concat(n.BaseRepositoryUrl, "/profiles/").concat(e, "/profile.json"), !1).then((function(e) {
  85199. return JSON.parse(e)
  85200. }
  85201. ))),
  85202. n._ProfileLoadingPromises[e]
  85203. }
  85204. )).then((function(e) {
  85205. return new Pp(i,t,e,n.BaseRepositoryUrl,n.DisableControllerCache ? void 0 : Mp)
  85206. }
  85207. ))
  85208. }
  85209. ,
  85210. e._LoadProfilesFromAvailableControllers = function(e, t, i) {
  85211. for (var n = 0; n < e.length; ++n)
  85212. if (e[n])
  85213. for (var r = this.FindFallbackWithProfileId(e[n]), o = 0; o < r.length; ++o) {
  85214. var a = this._AvailableControllers[r[o]];
  85215. if (a)
  85216. return Promise.resolve(a(t, i))
  85217. }
  85218. throw new Error("no controller requested was found in the available controllers list")
  85219. }
  85220. ,
  85221. e._AvailableControllers = {},
  85222. e._Fallbacks = {},
  85223. e._ProfileLoadingPromises = {},
  85224. e.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",
  85225. e.PrioritizeOnlineRepository = !0,
  85226. e.UseOnlineRepository = !0,
  85227. e.DisableControllerCache = !0,
  85228. e
  85229. }();
  85230. Ip.RegisterController(Rp.ProfileId, (function(e, t) {
  85231. return new Rp(t,e.gamepad,e.handedness)
  85232. }
  85233. )),
  85234. Ip.DefaultFallbacks();
  85235. var Op, Dp, Np = 0, Lp = function() {
  85236. function e(e, t, i) {
  85237. void 0 === i && (i = {});
  85238. var n = this;
  85239. this._scene = e,
  85240. this.inputSource = t,
  85241. this._options = i,
  85242. this._tmpVector = new x,
  85243. this._disposed = !1,
  85244. this.onDisposeObservable = new h,
  85245. this.onMeshLoadedObservable = new h,
  85246. this.onMotionControllerInitObservable = new h,
  85247. this._uniqueId = "controller-".concat(Np++, "-").concat(t.targetRayMode, "-").concat(t.handedness),
  85248. this.pointer = new Sr("".concat(this._uniqueId, "-pointer"),e),
  85249. this.pointer.rotationQuaternion = new C,
  85250. this.inputSource.gripSpace && (this.grip = new Sr("".concat(this._uniqueId, "-grip"),this._scene),
  85251. this.grip.rotationQuaternion = new C),
  85252. this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
  85253. this.inputSource.gamepad && "tracked-pointer" === this.inputSource.targetRayMode && Ip.GetMotionControllerWithXRInput(t, e, this._options.forceControllerProfile).then((function(e) {
  85254. n.motionController = e,
  85255. n.onMotionControllerInitObservable.notifyObservers(e),
  85256. n._options.doNotLoadControllerMesh || n.motionController._doNotLoadControllerMesh || n.motionController.loadModel().then((function(e) {
  85257. var t;
  85258. e && n.motionController && n.motionController.rootMesh && (n._options.renderingGroupId && (n.motionController.rootMesh.renderingGroupId = n._options.renderingGroupId,
  85259. n.motionController.rootMesh.getChildMeshes(!1).forEach((function(e) {
  85260. return e.renderingGroupId = n._options.renderingGroupId
  85261. }
  85262. ))),
  85263. n.onMeshLoadedObservable.notifyObservers(n.motionController.rootMesh),
  85264. n.motionController.rootMesh.parent = n.grip || n.pointer,
  85265. n.motionController.disableAnimation = !!n._options.disableMotionControllerAnimation),
  85266. n._disposed && (null === (t = n.motionController) || void 0 === t || t.dispose())
  85267. }
  85268. ))
  85269. }
  85270. ), (function() {
  85271. gi.Warn("Could not find a matching motion controller for the registered input source")
  85272. }
  85273. ))
  85274. }
  85275. return Object.defineProperty(e.prototype, "uniqueId", {
  85276. get: function() {
  85277. return this._uniqueId
  85278. },
  85279. enumerable: !1,
  85280. configurable: !0
  85281. }),
  85282. e.prototype.dispose = function() {
  85283. this.grip && this.grip.dispose(!0),
  85284. this.motionController && this.motionController.dispose(),
  85285. this.pointer.dispose(!0),
  85286. this.onMotionControllerInitObservable.clear(),
  85287. this.onMeshLoadedObservable.clear(),
  85288. this.onDisposeObservable.notifyObservers(this),
  85289. this.onDisposeObservable.clear(),
  85290. this._disposed = !0
  85291. }
  85292. ,
  85293. e.prototype.getWorldPointerRayToRef = function(e, t) {
  85294. void 0 === t && (t = !1);
  85295. var i = t && this.grip ? this.grip : this.pointer;
  85296. x.TransformNormalToRef(this._tmpVector, i.getWorldMatrix(), e.direction),
  85297. e.direction.normalize(),
  85298. e.origin.copyFrom(i.absolutePosition),
  85299. e.length = 1e3
  85300. }
  85301. ,
  85302. e.prototype.updateFromXRFrame = function(e, t, i) {
  85303. var n = e.getPose(this.inputSource.targetRaySpace, t);
  85304. if (this._lastXRPose = n,
  85305. n) {
  85306. var r = n.transform.position;
  85307. this.pointer.position.set(r.x, r.y, r.z);
  85308. var o = n.transform.orientation;
  85309. this.pointer.rotationQuaternion.set(o.x, o.y, o.z, o.w),
  85310. this._scene.useRightHandedSystem || (this.pointer.position.z *= -1,
  85311. this.pointer.rotationQuaternion.z *= -1,
  85312. this.pointer.rotationQuaternion.w *= -1),
  85313. this.pointer.parent = i.parent
  85314. }
  85315. if (this.inputSource.gripSpace && this.grip) {
  85316. var a = e.getPose(this.inputSource.gripSpace, t);
  85317. if (a) {
  85318. r = a.transform.position;
  85319. var s = a.transform.orientation;
  85320. this.grip.position.set(r.x, r.y, r.z),
  85321. this.grip.rotationQuaternion.set(s.x, s.y, s.z, s.w),
  85322. this._scene.useRightHandedSystem || (this.grip.position.z *= -1,
  85323. this.grip.rotationQuaternion.z *= -1,
  85324. this.grip.rotationQuaternion.w *= -1)
  85325. }
  85326. this.grip.parent = i.parent
  85327. }
  85328. this.motionController && this.motionController.updateFromXRFrame(e)
  85329. }
  85330. ,
  85331. e
  85332. }(), Fp = function() {
  85333. function e(e, t, i) {
  85334. void 0 === i && (i = {});
  85335. var n = this;
  85336. if (this.xrSessionManager = e,
  85337. this.xrCamera = t,
  85338. this._options = i,
  85339. this.controllers = [],
  85340. this.onControllerAddedObservable = new h,
  85341. this.onControllerRemovedObservable = new h,
  85342. this._onInputSourcesChange = function(e) {
  85343. n._addAndRemoveControllers(e.added, e.removed)
  85344. }
  85345. ,
  85346. this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add((function() {
  85347. n._addAndRemoveControllers([], n.controllers.map((function(e) {
  85348. return e.inputSource
  85349. }
  85350. )))
  85351. }
  85352. )),
  85353. this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((function(e) {
  85354. e.addEventListener("inputsourceschange", n._onInputSourcesChange)
  85355. }
  85356. )),
  85357. this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((function(e) {
  85358. n.controllers.forEach((function(t) {
  85359. t.updateFromXRFrame(e, n.xrSessionManager.referenceSpace, n.xrCamera)
  85360. }
  85361. ))
  85362. }
  85363. )),
  85364. this._options.customControllersRepositoryURL && (Ip.BaseRepositoryUrl = this._options.customControllersRepositoryURL),
  85365. Ip.UseOnlineRepository = !this._options.disableOnlineControllerRepository,
  85366. Ip.UseOnlineRepository)
  85367. try {
  85368. Ip.UpdateProfilesList().catch((function() {
  85369. Ip.UseOnlineRepository = !1
  85370. }
  85371. ))
  85372. } catch (e) {
  85373. Ip.UseOnlineRepository = !1
  85374. }
  85375. }
  85376. return e.prototype._addAndRemoveControllers = function(e, t) {
  85377. for (var i = this, n = this.controllers.map((function(e) {
  85378. return e.inputSource
  85379. }
  85380. )), r = 0, o = e; r < o.length; r++) {
  85381. var a = o[r];
  85382. if (-1 === n.indexOf(a)) {
  85383. var s = new Lp(this.xrSessionManager.scene,a,V(V({}, this._options.controllerOptions || {}), {
  85384. forceControllerProfile: this._options.forceInputProfile,
  85385. doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes,
  85386. disableMotionControllerAnimation: this._options.disableControllerAnimation
  85387. }));
  85388. this.controllers.push(s),
  85389. this.onControllerAddedObservable.notifyObservers(s)
  85390. }
  85391. }
  85392. var l = []
  85393. , c = [];
  85394. this.controllers.forEach((function(e) {
  85395. -1 === t.indexOf(e.inputSource) ? l.push(e) : c.push(e)
  85396. }
  85397. )),
  85398. this.controllers = l,
  85399. c.forEach((function(e) {
  85400. i.onControllerRemovedObservable.notifyObservers(e),
  85401. e.dispose()
  85402. }
  85403. ))
  85404. }
  85405. ,
  85406. e.prototype.dispose = function() {
  85407. this.controllers.forEach((function(e) {
  85408. e.dispose()
  85409. }
  85410. )),
  85411. this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),
  85412. this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),
  85413. this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),
  85414. this.onControllerAddedObservable.clear(),
  85415. this.onControllerRemovedObservable.clear(),
  85416. Ip.ClearControllerCache()
  85417. }
  85418. ,
  85419. e
  85420. }(), wp = function() {
  85421. function e(e) {
  85422. this._xrSessionManager = e,
  85423. this._attached = !1,
  85424. this._removeOnDetach = [],
  85425. this.isDisposed = !1,
  85426. this.disableAutoAttach = !1,
  85427. this.xrNativeFeatureName = ""
  85428. }
  85429. return Object.defineProperty(e.prototype, "attached", {
  85430. get: function() {
  85431. return this._attached
  85432. },
  85433. enumerable: !1,
  85434. configurable: !0
  85435. }),
  85436. e.prototype.attach = function(e) {
  85437. var t = this;
  85438. if (this.isDisposed)
  85439. return !1;
  85440. if (e)
  85441. this.attached && this.detach();
  85442. else if (this.attached)
  85443. return !1;
  85444. return this._attached = !0,
  85445. this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, (function(e) {
  85446. return t._onXRFrame(e)
  85447. }
  85448. )),
  85449. !0
  85450. }
  85451. ,
  85452. e.prototype.detach = function() {
  85453. return this._attached ? (this._attached = !1,
  85454. this._removeOnDetach.forEach((function(e) {
  85455. e.observable.remove(e.observer)
  85456. }
  85457. )),
  85458. !0) : (this.disableAutoAttach = !0,
  85459. !1)
  85460. }
  85461. ,
  85462. e.prototype.dispose = function() {
  85463. this.detach(),
  85464. this.isDisposed = !0
  85465. }
  85466. ,
  85467. e.prototype.isCompatible = function() {
  85468. return !0
  85469. }
  85470. ,
  85471. e.prototype._addNewAttachObserver = function(e, t) {
  85472. this._removeOnDetach.push({
  85473. observable: e,
  85474. observer: e.add(t)
  85475. })
  85476. }
  85477. ,
  85478. e
  85479. }(), Bp = function(e) {
  85480. function t(i, n) {
  85481. var r = e.call(this, i) || this;
  85482. return r._options = n,
  85483. r._attachController = function(e) {
  85484. if (!r._controllers[e.uniqueId]) {
  85485. var i = r._generateNewMeshPair(e.pointer)
  85486. , n = i.laserPointer
  85487. , o = i.selectionMesh;
  85488. switch (r._controllers[e.uniqueId] = {
  85489. xrController: e,
  85490. laserPointer: n,
  85491. selectionMesh: o,
  85492. meshUnderPointer: null,
  85493. pick: null,
  85494. tmpRay: new _o(new x,new x),
  85495. disabledByNearInteraction: !1,
  85496. id: t._IdCounter++
  85497. },
  85498. r._attachedController ? !r._options.enablePointerSelectionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enablePointerSelectionOnAllControllers || (r._attachedController = e.uniqueId),
  85499. e.inputSource.targetRayMode) {
  85500. case "tracked-pointer":
  85501. return r._attachTrackedPointerRayMode(e);
  85502. case "gaze":
  85503. return r._attachGazeMode(e);
  85504. case "screen":
  85505. return r._attachScreenRayMode(e)
  85506. }
  85507. }
  85508. }
  85509. ,
  85510. r._controllers = {},
  85511. r._tmpVectorForPickCompare = new x,
  85512. r.disablePointerLighting = !0,
  85513. r.disableSelectionMeshLighting = !0,
  85514. r.displayLaserPointer = !0,
  85515. r.displaySelectionMesh = !0,
  85516. r.laserPointerPickedColor = new D(.9,.9,.9),
  85517. r.laserPointerDefaultColor = new D(.7,.7,.7),
  85518. r.selectionMeshDefaultColor = new D(.8,.8,.8),
  85519. r.selectionMeshPickedColor = new D(.3,.3,1),
  85520. r._identityMatrix = P.Identity(),
  85521. r._screenCoordinatesRef = x.Zero(),
  85522. r._viewportRef = new xr(0,0,0,0),
  85523. r._scene = r._xrSessionManager.scene,
  85524. r
  85525. }
  85526. return U(t, e),
  85527. t.prototype.attach = function() {
  85528. var i = this;
  85529. if (!e.prototype.attach.call(this))
  85530. return !1;
  85531. if (this._options.xrInput.controllers.forEach(this._attachController),
  85532. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  85533. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function(e) {
  85534. i._detachController(e.uniqueId)
  85535. }
  85536. )),
  85537. this._scene.constantlyUpdateMeshUnderPointer = !0,
  85538. this._options.gazeCamera) {
  85539. var n = this._options.gazeCamera
  85540. , r = this._generateNewMeshPair(n)
  85541. , o = r.laserPointer
  85542. , a = r.selectionMesh;
  85543. this._controllers.camera = {
  85544. webXRCamera: n,
  85545. laserPointer: o,
  85546. selectionMesh: a,
  85547. meshUnderPointer: null,
  85548. pick: null,
  85549. tmpRay: new _o(new x,new x),
  85550. disabledByNearInteraction: !1,
  85551. id: t._IdCounter++
  85552. },
  85553. this._attachGazeMode()
  85554. }
  85555. return !0
  85556. }
  85557. ,
  85558. t.prototype.detach = function() {
  85559. var t = this;
  85560. return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
  85561. t._detachController(e)
  85562. }
  85563. )),
  85564. !0)
  85565. }
  85566. ,
  85567. t.prototype.getMeshUnderPointer = function(e) {
  85568. return this._controllers[e] ? this._controllers[e].meshUnderPointer : null
  85569. }
  85570. ,
  85571. t.prototype.getXRControllerByPointerId = function(e) {
  85572. for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
  85573. if (this._controllers[t[i]].id === e)
  85574. return this._controllers[t[i]].xrController || null;
  85575. return null
  85576. }
  85577. ,
  85578. t.prototype._getPointerSelectionDisabledByPointerId = function(e) {
  85579. for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
  85580. if (this._controllers[t[i]].id === e)
  85581. return this._controllers[t[i]].disabledByNearInteraction;
  85582. return !0
  85583. }
  85584. ,
  85585. t.prototype._setPointerSelectionDisabledByPointerId = function(e, t) {
  85586. for (var i = Object.keys(this._controllers), n = 0; n < i.length; ++n)
  85587. if (this._controllers[i[n]].id === e)
  85588. return void (this._controllers[i[n]].disabledByNearInteraction = t)
  85589. }
  85590. ,
  85591. t.prototype._onXRFrame = function(e) {
  85592. var t = this;
  85593. Object.keys(this._controllers).forEach((function(e) {
  85594. var i, n = t._controllers[e];
  85595. if (!t._options.enablePointerSelectionOnAllControllers && e !== t._attachedController || n.disabledByNearInteraction)
  85596. return n.selectionMesh.isVisible = !1,
  85597. n.laserPointer.isVisible = !1,
  85598. void (n.pick = null);
  85599. if (n.laserPointer.isVisible = t.displayLaserPointer,
  85600. n.xrController)
  85601. i = n.xrController.pointer.position,
  85602. n.xrController.getWorldPointerRayToRef(n.tmpRay);
  85603. else {
  85604. if (!n.webXRCamera)
  85605. return;
  85606. i = n.webXRCamera.position,
  85607. n.webXRCamera.getForwardRayToRef(n.tmpRay)
  85608. }
  85609. if (t._options.maxPointerDistance && (n.tmpRay.length = t._options.maxPointerDistance),
  85610. !t._options.disableScenePointerVectorUpdate && i) {
  85611. var r = t._xrSessionManager.scene
  85612. , o = t._options.xrInput.xrCamera;
  85613. o && (o.viewport.toGlobalToRef(r.getEngine().getRenderWidth(), r.getEngine().getRenderHeight(), t._viewportRef),
  85614. x.ProjectToRef(i, t._identityMatrix, r.getTransformMatrix(), t._viewportRef, t._screenCoordinatesRef),
  85615. "number" != typeof t._screenCoordinatesRef.x || "number" != typeof t._screenCoordinatesRef.y || isNaN(t._screenCoordinatesRef.x) || isNaN(t._screenCoordinatesRef.y) || (r.pointerX = t._screenCoordinatesRef.x,
  85616. r.pointerY = t._screenCoordinatesRef.y,
  85617. n.screenCoordinates = {
  85618. x: t._screenCoordinatesRef.x,
  85619. y: t._screenCoordinatesRef.y
  85620. }))
  85621. }
  85622. var a = null;
  85623. t._utilityLayerScene && (a = t._utilityLayerScene.pickWithRay(n.tmpRay, t._utilityLayerScene.pointerMovePredicate || t.raySelectionPredicate));
  85624. var s = t._scene.pickWithRay(n.tmpRay, t._scene.pointerMovePredicate || t.raySelectionPredicate);
  85625. a && a.hit ? s && s.hit ? a.distance < s.distance ? n.pick = a : n.pick = s : n.pick = a : n.pick = s,
  85626. n.pick && n.xrController && (n.pick.aimTransform = n.xrController.pointer,
  85627. n.pick.gripTransform = n.xrController.grip || null);
  85628. var l = n.pick;
  85629. if (l && l.pickedPoint && l.hit) {
  85630. t._updatePointerDistance(n.laserPointer, l.distance),
  85631. n.selectionMesh.position.copyFrom(l.pickedPoint),
  85632. n.selectionMesh.scaling.x = Math.sqrt(l.distance),
  85633. n.selectionMesh.scaling.y = Math.sqrt(l.distance),
  85634. n.selectionMesh.scaling.z = Math.sqrt(l.distance);
  85635. var c = t._convertNormalToDirectionOfRay(l.getNormal(!0), n.tmpRay);
  85636. if (n.selectionMesh.position.copyFrom(l.pickedPoint),
  85637. c) {
  85638. var u = x.Cross(vn.Y, c)
  85639. , h = x.Cross(c, u);
  85640. x.RotationFromAxisToRef(h, c, u, n.selectionMesh.rotation),
  85641. n.selectionMesh.position.addInPlace(c.scale(.001))
  85642. }
  85643. n.selectionMesh.isVisible = t.displaySelectionMesh,
  85644. n.meshUnderPointer = l.pickedMesh
  85645. } else
  85646. n.selectionMesh.isVisible = !1,
  85647. t._updatePointerDistance(n.laserPointer, 1),
  85648. n.meshUnderPointer = null
  85649. }
  85650. ))
  85651. }
  85652. ,
  85653. Object.defineProperty(t.prototype, "_utilityLayerScene", {
  85654. get: function() {
  85655. return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
  85656. },
  85657. enumerable: !1,
  85658. configurable: !0
  85659. }),
  85660. t.prototype._attachGazeMode = function(e) {
  85661. var t = this
  85662. , i = this._controllers[e && e.uniqueId || "camera"]
  85663. , n = this._options.timeToSelect || 3e3
  85664. , r = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene
  85665. , o = new Ui
  85666. , a = qs("selection", {
  85667. diameter: .0525,
  85668. thickness: .015,
  85669. tessellation: 20
  85670. }, r);
  85671. a.isVisible = !1,
  85672. a.isPickable = !1,
  85673. a.parent = i.selectionMesh;
  85674. var s = 0
  85675. , l = !1
  85676. , c = {
  85677. pointerId: i.id,
  85678. pointerType: "xr"
  85679. };
  85680. i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
  85681. if (i.pick) {
  85682. if (t._augmentPointerInit(c, i.id, i.screenCoordinates),
  85683. i.laserPointer.material.alpha = 0,
  85684. a.isVisible = !1,
  85685. i.pick.hit)
  85686. if (t._pickingMoved(o, i.pick))
  85687. l && (t._options.disablePointerUpOnTouchOut || t._scene.simulatePointerUp(i.pick, c)),
  85688. l = !1,
  85689. s = 0;
  85690. else if (s > n / 10 && (a.isVisible = !0),
  85691. (s += t._scene.getEngine().getDeltaTime()) >= n)
  85692. t._scene.simulatePointerDown(i.pick, c),
  85693. l = !0,
  85694. t._options.disablePointerUpOnTouchOut && t._scene.simulatePointerUp(i.pick, c),
  85695. a.isVisible = !1;
  85696. else {
  85697. var e = 1 - s / n;
  85698. a.scaling.set(e, e, e)
  85699. }
  85700. else
  85701. l = !1,
  85702. s = 0;
  85703. t._scene.simulatePointerMove(i.pick, c),
  85704. o = i.pick
  85705. }
  85706. }
  85707. )),
  85708. void 0 !== this._options.renderingGroupId && (a.renderingGroupId = this._options.renderingGroupId),
  85709. e && e.onDisposeObservable.addOnce((function() {
  85710. i.pick && !t._options.disablePointerUpOnTouchOut && l && (t._scene.simulatePointerUp(i.pick, c),
  85711. i.finalPointerUpTriggered = !0),
  85712. a.dispose()
  85713. }
  85714. ))
  85715. }
  85716. ,
  85717. t.prototype._attachScreenRayMode = function(e) {
  85718. var t = this
  85719. , i = this._controllers[e.uniqueId]
  85720. , n = !1
  85721. , r = {
  85722. pointerId: i.id,
  85723. pointerType: "xr"
  85724. };
  85725. i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
  85726. t._augmentPointerInit(r, i.id, i.screenCoordinates),
  85727. !i.pick || t._options.disablePointerUpOnTouchOut && n || (n ? t._scene.simulatePointerMove(i.pick, r) : (t._scene.simulatePointerDown(i.pick, r),
  85728. i.pointerDownTriggered = !0,
  85729. n = !0,
  85730. t._options.disablePointerUpOnTouchOut && t._scene.simulatePointerUp(i.pick, r)))
  85731. }
  85732. )),
  85733. e.onDisposeObservable.addOnce((function() {
  85734. t._augmentPointerInit(r, i.id, i.screenCoordinates),
  85735. t._xrSessionManager.runInXRFrame((function() {
  85736. i.pick && !i.finalPointerUpTriggered && n && !t._options.disablePointerUpOnTouchOut && (t._scene.simulatePointerUp(i.pick, r),
  85737. i.finalPointerUpTriggered = !0)
  85738. }
  85739. ))
  85740. }
  85741. ))
  85742. }
  85743. ,
  85744. t.prototype._attachTrackedPointerRayMode = function(e) {
  85745. var t = this
  85746. , i = this._controllers[e.uniqueId];
  85747. if (this._options.forceGazeMode)
  85748. return this._attachGazeMode(e);
  85749. var n = {
  85750. pointerId: i.id,
  85751. pointerType: "xr"
  85752. };
  85753. if (i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
  85754. i.laserPointer.material.disableLighting = t.disablePointerLighting,
  85755. i.selectionMesh.material.disableLighting = t.disableSelectionMeshLighting,
  85756. i.pick && (t._augmentPointerInit(n, i.id, i.screenCoordinates),
  85757. t._scene.simulatePointerMove(i.pick, n))
  85758. }
  85759. )),
  85760. e.inputSource.gamepad) {
  85761. var r = function(r) {
  85762. t._options.overrideButtonId && (i.selectionComponent = r.getComponent(t._options.overrideButtonId)),
  85763. i.selectionComponent || (i.selectionComponent = r.getMainComponent()),
  85764. i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(r) {
  85765. if (r.changes.pressed) {
  85766. var o = r.changes.pressed.current;
  85767. i.pick ? (t._options.enablePointerSelectionOnAllControllers || e.uniqueId === t._attachedController) && (t._augmentPointerInit(n, i.id, i.screenCoordinates),
  85768. o ? (t._scene.simulatePointerDown(i.pick, n),
  85769. i.pointerDownTriggered = !0,
  85770. i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
  85771. i.laserPointer.material.emissiveColor = t.laserPointerPickedColor) : (t._scene.simulatePointerUp(i.pick, n),
  85772. i.selectionMesh.material.emissiveColor = t.selectionMeshDefaultColor,
  85773. i.laserPointer.material.emissiveColor = t.laserPointerDefaultColor)) : !o || t._options.enablePointerSelectionOnAllControllers || t._options.disableSwitchOnClick || (t._attachedController = e.uniqueId)
  85774. }
  85775. }
  85776. ))
  85777. };
  85778. e.motionController ? r(e.motionController) : e.onMotionControllerInitObservable.add(r)
  85779. } else {
  85780. var o = function(e) {
  85781. t._augmentPointerInit(n, i.id, i.screenCoordinates),
  85782. i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerDown(i.pick, n),
  85783. i.pointerDownTriggered = !0,
  85784. i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
  85785. i.laserPointer.material.emissiveColor = t.laserPointerPickedColor)
  85786. }
  85787. , a = function(e) {
  85788. t._augmentPointerInit(n, i.id, i.screenCoordinates),
  85789. i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerUp(i.pick, n),
  85790. i.selectionMesh.material.emissiveColor = t.selectionMeshDefaultColor,
  85791. i.laserPointer.material.emissiveColor = t.laserPointerDefaultColor)
  85792. };
  85793. i.eventListeners = {
  85794. selectend: a,
  85795. selectstart: o
  85796. },
  85797. this._xrSessionManager.session.addEventListener("selectstart", o),
  85798. this._xrSessionManager.session.addEventListener("selectend", a)
  85799. }
  85800. }
  85801. ,
  85802. t.prototype._convertNormalToDirectionOfRay = function(e, t) {
  85803. return e && Math.acos(x.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1),
  85804. e
  85805. }
  85806. ,
  85807. t.prototype._detachController = function(e) {
  85808. var t = this
  85809. , i = this._controllers[e];
  85810. if (i) {
  85811. if (i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),
  85812. i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),
  85813. i.eventListeners && Object.keys(i.eventListeners).forEach((function(e) {
  85814. var n = i.eventListeners && i.eventListeners[e];
  85815. n && t._xrSessionManager.session.removeEventListener(e, n)
  85816. }
  85817. )),
  85818. !i.finalPointerUpTriggered && i.pointerDownTriggered) {
  85819. var n = {
  85820. pointerId: i.id,
  85821. pointerType: "xr"
  85822. };
  85823. this._xrSessionManager.runInXRFrame((function() {
  85824. t._augmentPointerInit(n, i.id, i.screenCoordinates),
  85825. t._scene.simulatePointerUp(new Ui, n)
  85826. }
  85827. ))
  85828. }
  85829. this._xrSessionManager.scene.onBeforeRenderObservable.addOnce((function() {
  85830. try {
  85831. if (i.selectionMesh.dispose(),
  85832. i.laserPointer.dispose(),
  85833. delete t._controllers[e],
  85834. t._attachedController === e) {
  85835. var n = Object.keys(t._controllers);
  85836. n.length ? t._attachedController = n[0] : t._attachedController = ""
  85837. }
  85838. } catch (e) {
  85839. gi.Warn("controller already detached.")
  85840. }
  85841. }
  85842. ))
  85843. }
  85844. }
  85845. ,
  85846. t.prototype._generateNewMeshPair = function(e) {
  85847. var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
  85848. , i = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : Ys("laserPointer", {
  85849. height: 1,
  85850. diameterTop: 2e-4,
  85851. diameterBottom: .004,
  85852. tessellation: 20,
  85853. subdivisions: 1
  85854. }, t);
  85855. i.parent = e;
  85856. var n = new Os("laserPointerMat",t);
  85857. n.emissiveColor = this.laserPointerDefaultColor,
  85858. n.alpha = .7,
  85859. i.material = n,
  85860. i.rotation.x = Math.PI / 2,
  85861. this._updatePointerDistance(i, 1),
  85862. i.isPickable = !1,
  85863. i.isVisible = !1;
  85864. var r = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : qs("gazeTracker", {
  85865. diameter: .0105,
  85866. thickness: .0075,
  85867. tessellation: 20
  85868. }, t);
  85869. r.bakeCurrentTransformIntoVertices(),
  85870. r.isPickable = !1,
  85871. r.isVisible = !1;
  85872. var o = new Os("targetMat",t);
  85873. return o.specularColor = D.Black(),
  85874. o.emissiveColor = this.selectionMeshDefaultColor,
  85875. o.backFaceCulling = !1,
  85876. r.material = o,
  85877. void 0 !== this._options.renderingGroupId && (i.renderingGroupId = this._options.renderingGroupId,
  85878. r.renderingGroupId = this._options.renderingGroupId),
  85879. {
  85880. laserPointer: i,
  85881. selectionMesh: r
  85882. }
  85883. }
  85884. ,
  85885. t.prototype._pickingMoved = function(e, t) {
  85886. var i;
  85887. if (!e.hit || !t.hit)
  85888. return !0;
  85889. if (!(e.pickedMesh && e.pickedPoint && t.pickedMesh && t.pickedPoint))
  85890. return !0;
  85891. if (e.pickedMesh !== t.pickedMesh)
  85892. return !0;
  85893. null === (i = e.pickedPoint) || void 0 === i || i.subtractToRef(t.pickedPoint, this._tmpVectorForPickCompare),
  85894. this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
  85895. var n = .01 * (this._options.gazeModePointerMovedFactor || 1) * t.distance;
  85896. return this._tmpVectorForPickCompare.length() > n
  85897. }
  85898. ,
  85899. t.prototype._updatePointerDistance = function(e, t) {
  85900. void 0 === t && (t = 100),
  85901. e.scaling.y = t,
  85902. this._scene.useRightHandedSystem && (t *= -1),
  85903. e.position.z = t / 2 + .05
  85904. }
  85905. ,
  85906. t.prototype._augmentPointerInit = function(e, t, i) {
  85907. e.pointerId = t,
  85908. e.pointerType = "xr",
  85909. i && (e.screenX = i.x,
  85910. e.screenY = i.y)
  85911. }
  85912. ,
  85913. Object.defineProperty(t.prototype, "lasterPointerDefaultColor", {
  85914. get: function() {
  85915. return this.laserPointerDefaultColor
  85916. },
  85917. enumerable: !1,
  85918. configurable: !0
  85919. }),
  85920. t._IdCounter = 200,
  85921. t.Name = Io.POINTER_SELECTION,
  85922. t.Version = 1,
  85923. t
  85924. }(wp);
  85925. Oo.AddWebXRFeature(Bp.Name, (function(e, t) {
  85926. return function() {
  85927. return new Bp(e,t)
  85928. }
  85929. }
  85930. ), Bp.Version, !0),
  85931. function(e) {
  85932. e[e.Float = 1] = "Float",
  85933. e[e.Int = 2] = "Int",
  85934. e[e.Vector2 = 4] = "Vector2",
  85935. e[e.Vector3 = 8] = "Vector3",
  85936. e[e.Vector4 = 16] = "Vector4",
  85937. e[e.Color3 = 32] = "Color3",
  85938. e[e.Color4 = 64] = "Color4",
  85939. e[e.Matrix = 128] = "Matrix",
  85940. e[e.Object = 256] = "Object",
  85941. e[e.AutoDetect = 1024] = "AutoDetect",
  85942. e[e.BasedOnInput = 2048] = "BasedOnInput"
  85943. }(Op || (Op = {})),
  85944. function(e) {
  85945. e[e.Vertex = 1] = "Vertex",
  85946. e[e.Fragment = 2] = "Fragment",
  85947. e[e.Neutral = 4] = "Neutral",
  85948. e[e.VertexAndFragment = 3] = "VertexAndFragment"
  85949. }(Dp || (Dp = {}));
  85950. var Up, Vp, kp = function() {
  85951. function e() {
  85952. this.supportUniformBuffers = !1,
  85953. this.attributes = new Array,
  85954. this.uniforms = new Array,
  85955. this.constants = new Array,
  85956. this.samplers = new Array,
  85957. this.functions = {},
  85958. this.extensions = {},
  85959. this.counters = {},
  85960. this._attributeDeclaration = "",
  85961. this._uniformDeclaration = "",
  85962. this._constantDeclaration = "",
  85963. this._samplerDeclaration = "",
  85964. this._varyingTransfer = "",
  85965. this._injectAtEnd = "",
  85966. this._repeatableContentAnchorIndex = 0,
  85967. this._builtCompilationString = "",
  85968. this.compilationString = ""
  85969. }
  85970. return e.prototype.finalize = function(e) {
  85971. var t = e.sharedData.emitComments
  85972. , i = this.target === Dp.Fragment;
  85973. this.compilationString = "\r\n".concat(t ? "//Entry point\r\n" : "", "void main(void) {\r\n").concat(this.compilationString),
  85974. this._constantDeclaration && (this.compilationString = "\r\n".concat(t ? "//Constants\r\n" : "").concat(this._constantDeclaration, "\r\n").concat(this.compilationString));
  85975. var n = "";
  85976. for (var r in this.functions)
  85977. n += this.functions[r] + "\r\n";
  85978. for (var o in this.compilationString = "\r\n".concat(n, "\r\n").concat(this.compilationString),
  85979. !i && this._varyingTransfer && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._varyingTransfer)),
  85980. this._injectAtEnd && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._injectAtEnd)),
  85981. this.compilationString = "".concat(this.compilationString, "\r\n}"),
  85982. this.sharedData.varyingDeclaration && (this.compilationString = "\r\n".concat(t ? "//Varyings\r\n" : "").concat(this.sharedData.varyingDeclaration, "\r\n").concat(this.compilationString)),
  85983. this._samplerDeclaration && (this.compilationString = "\r\n".concat(t ? "//Samplers\r\n" : "").concat(this._samplerDeclaration, "\r\n").concat(this.compilationString)),
  85984. this._uniformDeclaration && (this.compilationString = "\r\n".concat(t ? "//Uniforms\r\n" : "").concat(this._uniformDeclaration, "\r\n").concat(this.compilationString)),
  85985. this._attributeDeclaration && !i && (this.compilationString = "\r\n".concat(t ? "//Attributes\r\n" : "").concat(this._attributeDeclaration, "\r\n").concat(this.compilationString)),
  85986. this.compilationString = "precision highp float;\r\n" + this.compilationString,
  85987. this.extensions) {
  85988. var a = this.extensions[o];
  85989. this.compilationString = "\r\n".concat(a, "\r\n").concat(this.compilationString)
  85990. }
  85991. this._builtCompilationString = this.compilationString
  85992. }
  85993. ,
  85994. Object.defineProperty(e.prototype, "_repeatableContentAnchor", {
  85995. get: function() {
  85996. return "###___ANCHOR".concat(this._repeatableContentAnchorIndex++, "___###")
  85997. },
  85998. enumerable: !1,
  85999. configurable: !0
  86000. }),
  86001. e.prototype._getFreeVariableName = function(e) {
  86002. return e = e.replace(/[^a-zA-Z_]+/g, ""),
  86003. void 0 === this.sharedData.variableNames[e] ? (this.sharedData.variableNames[e] = 0,
  86004. "output" === e || "texture" === e ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++,
  86005. e + this.sharedData.variableNames[e])
  86006. }
  86007. ,
  86008. e.prototype._getFreeDefineName = function(e) {
  86009. return void 0 === this.sharedData.defineNames[e] ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++,
  86010. e + this.sharedData.defineNames[e]
  86011. }
  86012. ,
  86013. e.prototype._excludeVariableName = function(e) {
  86014. this.sharedData.variableNames[e] = 0
  86015. }
  86016. ,
  86017. e.prototype._emit2DSampler = function(e) {
  86018. this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D ".concat(e, ";\r\n"),
  86019. this.samplers.push(e))
  86020. }
  86021. ,
  86022. e.prototype._getGLType = function(e) {
  86023. switch (e) {
  86024. case Op.Float:
  86025. return "float";
  86026. case Op.Int:
  86027. return "int";
  86028. case Op.Vector2:
  86029. return "vec2";
  86030. case Op.Color3:
  86031. case Op.Vector3:
  86032. return "vec3";
  86033. case Op.Color4:
  86034. case Op.Vector4:
  86035. return "vec4";
  86036. case Op.Matrix:
  86037. return "mat4"
  86038. }
  86039. return ""
  86040. }
  86041. ,
  86042. e.prototype._emitExtension = function(e, t, i) {
  86043. void 0 === i && (i = ""),
  86044. this.extensions[e] || (i && (t = "#if ".concat(i, "\r\n").concat(t, "\r\n#endif")),
  86045. this.extensions[e] = t)
  86046. }
  86047. ,
  86048. e.prototype._emitFunction = function(e, t, i) {
  86049. this.functions[e] || (this.sharedData.emitComments && (t = i + "\r\n" + t),
  86050. this.functions[e] = t)
  86051. }
  86052. ,
  86053. e.prototype._emitCodeFromInclude = function(e, t, i) {
  86054. if (i && i.repeatKey)
  86055. return "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n");
  86056. var n = Mt.IncludesShadersStore[e] + "\r\n";
  86057. if (this.sharedData.emitComments && (n = t + "\r\n" + n),
  86058. !i)
  86059. return n;
  86060. if (i.replaceStrings)
  86061. for (var r = 0; r < i.replaceStrings.length; r++) {
  86062. var o = i.replaceStrings[r];
  86063. n = n.replace(o.search, o.replace)
  86064. }
  86065. return n
  86066. }
  86067. ,
  86068. e.prototype._emitFunctionFromInclude = function(e, t, i, n) {
  86069. void 0 === n && (n = "");
  86070. var r = e + n;
  86071. if (!this.functions[r]) {
  86072. if (!i || !(i.removeAttributes || i.removeUniforms || i.removeVaryings || i.removeIfDef || i.replaceStrings))
  86073. return i && i.repeatKey ? this.functions[r] = "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n") : this.functions[r] = "#include<".concat(e, ">\r\n"),
  86074. void (this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]));
  86075. if (this.functions[r] = Mt.IncludesShadersStore[e],
  86076. this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]),
  86077. i.removeIfDef && (this.functions[r] = this.functions[r].replace(/^\s*?#ifdef.+$/gm, ""),
  86078. this.functions[r] = this.functions[r].replace(/^\s*?#endif.*$/gm, ""),
  86079. this.functions[r] = this.functions[r].replace(/^\s*?#else.*$/gm, ""),
  86080. this.functions[r] = this.functions[r].replace(/^\s*?#elif.*$/gm, "")),
  86081. i.removeAttributes && (this.functions[r] = this.functions[r].replace(/^\s*?attribute.+$/gm, "")),
  86082. i.removeUniforms && (this.functions[r] = this.functions[r].replace(/^\s*?uniform.+$/gm, "")),
  86083. i.removeVaryings && (this.functions[r] = this.functions[r].replace(/^\s*?varying.+$/gm, "")),
  86084. i.replaceStrings)
  86085. for (var o = 0; o < i.replaceStrings.length; o++) {
  86086. var a = i.replaceStrings[o];
  86087. this.functions[r] = this.functions[r].replace(a.search, a.replace)
  86088. }
  86089. }
  86090. }
  86091. ,
  86092. e.prototype._registerTempVariable = function(e) {
  86093. return -1 === this.sharedData.temps.indexOf(e) && (this.sharedData.temps.push(e),
  86094. !0)
  86095. }
  86096. ,
  86097. e.prototype._emitVaryingFromString = function(e, t, i, n) {
  86098. return void 0 === i && (i = ""),
  86099. void 0 === n && (n = !1),
  86100. -1 === this.sharedData.varyings.indexOf(e) && (this.sharedData.varyings.push(e),
  86101. i && (ae(i, "defined(") ? this.sharedData.varyingDeclaration += "#if ".concat(i, "\r\n") : this.sharedData.varyingDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
  86102. this.sharedData.varyingDeclaration += "varying ".concat(t, " ").concat(e, ";\r\n"),
  86103. i && (this.sharedData.varyingDeclaration += "#endif\r\n"),
  86104. !0)
  86105. }
  86106. ,
  86107. e.prototype._emitUniformFromString = function(e, t, i, n) {
  86108. void 0 === i && (i = ""),
  86109. void 0 === n && (n = !1),
  86110. -1 === this.uniforms.indexOf(e) && (this.uniforms.push(e),
  86111. i && (ae(i, "defined(") ? this._uniformDeclaration += "#if ".concat(i, "\r\n") : this._uniformDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
  86112. this._uniformDeclaration += "uniform ".concat(t, " ").concat(e, ";\r\n"),
  86113. i && (this._uniformDeclaration += "#endif\r\n"))
  86114. }
  86115. ,
  86116. e.prototype._emitFloat = function(e) {
  86117. return e.toString() === e.toFixed(0) ? "".concat(e, ".0") : e.toString()
  86118. }
  86119. ,
  86120. e
  86121. }(), Gp = function() {
  86122. function e() {
  86123. this.temps = new Array,
  86124. this.varyings = new Array,
  86125. this.varyingDeclaration = "",
  86126. this.inputBlocks = new Array,
  86127. this.textureBlocks = new Array,
  86128. this.bindableBlocks = new Array,
  86129. this.forcedBindableBlocks = new Array,
  86130. this.blocksWithFallbacks = new Array,
  86131. this.blocksWithDefines = new Array,
  86132. this.repeatableContentBlocks = new Array,
  86133. this.dynamicUniformBlocks = new Array,
  86134. this.blockingBlocks = new Array,
  86135. this.animatedInputs = new Array,
  86136. this.variableNames = {},
  86137. this.defineNames = {},
  86138. this.hints = {
  86139. needWorldViewMatrix: !1,
  86140. needWorldViewProjectionMatrix: !1,
  86141. needAlphaBlending: !1,
  86142. needAlphaTesting: !1
  86143. },
  86144. this.checks = {
  86145. emitVertex: !1,
  86146. emitFragment: !1,
  86147. notConnectedNonOptionalInputs: new Array
  86148. },
  86149. this.allowEmptyVertexProgram = !1,
  86150. this.variableNames.position = 0,
  86151. this.variableNames.normal = 0,
  86152. this.variableNames.tangent = 0,
  86153. this.variableNames.uv = 0,
  86154. this.variableNames.uv2 = 0,
  86155. this.variableNames.uv3 = 0,
  86156. this.variableNames.uv4 = 0,
  86157. this.variableNames.uv5 = 0,
  86158. this.variableNames.uv6 = 0,
  86159. this.variableNames.color = 0,
  86160. this.variableNames.matricesIndices = 0,
  86161. this.variableNames.matricesWeights = 0,
  86162. this.variableNames.matricesIndicesExtra = 0,
  86163. this.variableNames.matricesWeightsExtra = 0,
  86164. this.variableNames.diffuseBase = 0,
  86165. this.variableNames.specularBase = 0,
  86166. this.variableNames.worldPos = 0,
  86167. this.variableNames.shadow = 0,
  86168. this.variableNames.view = 0,
  86169. this.variableNames.vTBN = 0,
  86170. this.defineNames.MAINUV0 = 0,
  86171. this.defineNames.MAINUV1 = 0,
  86172. this.defineNames.MAINUV2 = 0,
  86173. this.defineNames.MAINUV3 = 0,
  86174. this.defineNames.MAINUV4 = 0,
  86175. this.defineNames.MAINUV5 = 0,
  86176. this.defineNames.MAINUV6 = 0,
  86177. this.defineNames.MAINUV7 = 0
  86178. }
  86179. return e.prototype.emitErrors = function() {
  86180. var e = "";
  86181. this.checks.emitVertex || this.allowEmptyVertexProgram || (e += "NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r\n"),
  86182. this.checks.emitFragment || (e += "NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r\n");
  86183. for (var t = 0, i = this.checks.notConnectedNonOptionalInputs; t < i.length; t++) {
  86184. var n = i[t];
  86185. e += "input ".concat(n.name, " from block ").concat(n.ownerBlock.name, "[").concat(n.ownerBlock.getClassName(), "] is not connected and is not optional.\r\n")
  86186. }
  86187. if (e)
  86188. throw "Build of NodeMaterial failed:\r\n" + e
  86189. }
  86190. ,
  86191. e
  86192. }();
  86193. !function(e) {
  86194. e[e.Compatible = 0] = "Compatible",
  86195. e[e.TypeIncompatible = 1] = "TypeIncompatible",
  86196. e[e.TargetIncompatible = 2] = "TargetIncompatible",
  86197. e[e.HierarchyIssue = 3] = "HierarchyIssue"
  86198. }(Up || (Up = {})),
  86199. function(e) {
  86200. e[e.Input = 0] = "Input",
  86201. e[e.Output = 1] = "Output"
  86202. }(Vp || (Vp = {}));
  86203. var zp = function() {
  86204. function e(e, t, i) {
  86205. this._connectedPoint = null,
  86206. this._endpoints = new Array,
  86207. this._typeConnectionSource = null,
  86208. this._defaultConnectionPointType = null,
  86209. this._linkedConnectionSource = null,
  86210. this._acceptedConnectionPointType = null,
  86211. this._type = Op.Float,
  86212. this._enforceAssociatedVariableName = !1,
  86213. this.needDualDirectionValidation = !1,
  86214. this.acceptedConnectionPointTypes = new Array,
  86215. this.excludedConnectionPointTypes = new Array,
  86216. this.onConnectionObservable = new h,
  86217. this.isExposedOnFrame = !1,
  86218. this.exposedPortPosition = -1,
  86219. this._prioritizeVertex = !1,
  86220. this._target = Dp.VertexAndFragment,
  86221. this._ownerBlock = t,
  86222. this.name = e,
  86223. this._direction = i
  86224. }
  86225. return e.AreEquivalentTypes = function(e, t) {
  86226. switch (e) {
  86227. case Op.Vector3:
  86228. if (t === Op.Color3)
  86229. return !0;
  86230. break;
  86231. case Op.Vector4:
  86232. if (t === Op.Color4)
  86233. return !0;
  86234. break;
  86235. case Op.Color3:
  86236. if (t === Op.Vector3)
  86237. return !0;
  86238. break;
  86239. case Op.Color4:
  86240. if (t === Op.Vector4)
  86241. return !0
  86242. }
  86243. return !1
  86244. }
  86245. ,
  86246. Object.defineProperty(e.prototype, "direction", {
  86247. get: function() {
  86248. return this._direction
  86249. },
  86250. enumerable: !1,
  86251. configurable: !0
  86252. }),
  86253. Object.defineProperty(e.prototype, "associatedVariableName", {
  86254. get: function() {
  86255. return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : this._enforceAssociatedVariableName && this._associatedVariableName || !this._connectedPoint ? this._associatedVariableName : this._connectedPoint.associatedVariableName
  86256. },
  86257. set: function(e) {
  86258. this._associatedVariableName = e
  86259. },
  86260. enumerable: !1,
  86261. configurable: !0
  86262. }),
  86263. Object.defineProperty(e.prototype, "innerType", {
  86264. get: function() {
  86265. return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type
  86266. },
  86267. enumerable: !1,
  86268. configurable: !0
  86269. }),
  86270. Object.defineProperty(e.prototype, "type", {
  86271. get: function() {
  86272. if (this._type === Op.AutoDetect) {
  86273. if (this._ownerBlock.isInput)
  86274. return this._ownerBlock.type;
  86275. if (this._connectedPoint)
  86276. return this._connectedPoint.type;
  86277. if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected)
  86278. return this._linkedConnectionSource.type
  86279. }
  86280. if (this._type === Op.BasedOnInput) {
  86281. if (this._typeConnectionSource)
  86282. return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type;
  86283. if (this._defaultConnectionPointType)
  86284. return this._defaultConnectionPointType
  86285. }
  86286. return this._type
  86287. },
  86288. set: function(e) {
  86289. this._type = e
  86290. },
  86291. enumerable: !1,
  86292. configurable: !0
  86293. }),
  86294. Object.defineProperty(e.prototype, "target", {
  86295. get: function() {
  86296. return this._prioritizeVertex && this._ownerBlock ? this._target !== Dp.VertexAndFragment ? this._target : this._ownerBlock.target === Dp.Fragment ? Dp.Fragment : Dp.Vertex : this._target
  86297. },
  86298. set: function(e) {
  86299. this._target = e
  86300. },
  86301. enumerable: !1,
  86302. configurable: !0
  86303. }),
  86304. Object.defineProperty(e.prototype, "isConnected", {
  86305. get: function() {
  86306. return null !== this.connectedPoint || this.hasEndpoints
  86307. },
  86308. enumerable: !1,
  86309. configurable: !0
  86310. }),
  86311. Object.defineProperty(e.prototype, "isConnectedToInputBlock", {
  86312. get: function() {
  86313. return null !== this.connectedPoint && this.connectedPoint.ownerBlock.isInput
  86314. },
  86315. enumerable: !1,
  86316. configurable: !0
  86317. }),
  86318. Object.defineProperty(e.prototype, "connectInputBlock", {
  86319. get: function() {
  86320. return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null
  86321. },
  86322. enumerable: !1,
  86323. configurable: !0
  86324. }),
  86325. Object.defineProperty(e.prototype, "connectedPoint", {
  86326. get: function() {
  86327. return this._connectedPoint
  86328. },
  86329. enumerable: !1,
  86330. configurable: !0
  86331. }),
  86332. Object.defineProperty(e.prototype, "ownerBlock", {
  86333. get: function() {
  86334. return this._ownerBlock
  86335. },
  86336. enumerable: !1,
  86337. configurable: !0
  86338. }),
  86339. Object.defineProperty(e.prototype, "sourceBlock", {
  86340. get: function() {
  86341. return this._connectedPoint ? this._connectedPoint.ownerBlock : null
  86342. },
  86343. enumerable: !1,
  86344. configurable: !0
  86345. }),
  86346. Object.defineProperty(e.prototype, "connectedBlocks", {
  86347. get: function() {
  86348. return 0 === this._endpoints.length ? [] : this._endpoints.map((function(e) {
  86349. return e.ownerBlock
  86350. }
  86351. ))
  86352. },
  86353. enumerable: !1,
  86354. configurable: !0
  86355. }),
  86356. Object.defineProperty(e.prototype, "endpoints", {
  86357. get: function() {
  86358. return this._endpoints
  86359. },
  86360. enumerable: !1,
  86361. configurable: !0
  86362. }),
  86363. Object.defineProperty(e.prototype, "hasEndpoints", {
  86364. get: function() {
  86365. return this._endpoints && this._endpoints.length > 0
  86366. },
  86367. enumerable: !1,
  86368. configurable: !0
  86369. }),
  86370. Object.defineProperty(e.prototype, "isDirectlyConnectedToVertexOutput", {
  86371. get: function() {
  86372. if (!this.hasEndpoints)
  86373. return !1;
  86374. for (var e = 0, t = this._endpoints; e < t.length; e++) {
  86375. var i = t[e];
  86376. if (i.ownerBlock.target === Dp.Vertex)
  86377. return !0;
  86378. if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
  86379. return e.isDirectlyConnectedToVertexOutput
  86380. }
  86381. )))
  86382. return !0
  86383. }
  86384. return !1
  86385. },
  86386. enumerable: !1,
  86387. configurable: !0
  86388. }),
  86389. Object.defineProperty(e.prototype, "isConnectedInVertexShader", {
  86390. get: function() {
  86391. if (this.target === Dp.Vertex)
  86392. return !0;
  86393. if (!this.hasEndpoints)
  86394. return !1;
  86395. for (var e = 0, t = this._endpoints; e < t.length; e++) {
  86396. var i = t[e];
  86397. if (i.ownerBlock.target === Dp.Vertex)
  86398. return !0;
  86399. if (i.target === Dp.Vertex)
  86400. return !0;
  86401. if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
  86402. return e.isConnectedInVertexShader
  86403. }
  86404. )))
  86405. return !0
  86406. }
  86407. return !1
  86408. },
  86409. enumerable: !1,
  86410. configurable: !0
  86411. }),
  86412. Object.defineProperty(e.prototype, "isConnectedInFragmentShader", {
  86413. get: function() {
  86414. if (this.target === Dp.Fragment)
  86415. return !0;
  86416. if (!this.hasEndpoints)
  86417. return !1;
  86418. for (var e = 0, t = this._endpoints; e < t.length; e++) {
  86419. var i = t[e];
  86420. if (i.ownerBlock.target === Dp.Fragment)
  86421. return !0;
  86422. if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
  86423. return e.isConnectedInFragmentShader
  86424. }
  86425. )))
  86426. return !0
  86427. }
  86428. return !1
  86429. },
  86430. enumerable: !1,
  86431. configurable: !0
  86432. }),
  86433. e.prototype.createCustomInputBlock = function() {
  86434. return null
  86435. }
  86436. ,
  86437. e.prototype.getClassName = function() {
  86438. return "NodeMaterialConnectionPoint"
  86439. }
  86440. ,
  86441. e.prototype.canConnectTo = function(e) {
  86442. return this.checkCompatibilityState(e) === Up.Compatible
  86443. }
  86444. ,
  86445. e.prototype.checkCompatibilityState = function(t) {
  86446. var i = this._ownerBlock
  86447. , n = t.ownerBlock;
  86448. if (i.target === Dp.Fragment) {
  86449. if (n.target === Dp.Vertex)
  86450. return Up.TargetIncompatible;
  86451. for (var r = 0, o = n.outputs; r < o.length; r++) {
  86452. var a = o[r];
  86453. if (a.ownerBlock.target != Dp.Neutral && a.isConnectedInVertexShader)
  86454. return Up.TargetIncompatible
  86455. }
  86456. }
  86457. if (this.type !== t.type && t.innerType !== Op.AutoDetect)
  86458. return e.AreEquivalentTypes(this.type, t.type) || t.acceptedConnectionPointTypes && -1 !== t.acceptedConnectionPointTypes.indexOf(this.type) || t._acceptedConnectionPointType && e.AreEquivalentTypes(t._acceptedConnectionPointType.type, this.type) ? Up.Compatible : Up.TypeIncompatible;
  86459. if (t.excludedConnectionPointTypes && -1 !== t.excludedConnectionPointTypes.indexOf(this.type))
  86460. return Up.TypeIncompatible;
  86461. var s = n
  86462. , l = i;
  86463. return this.direction === Vp.Input && (s = i,
  86464. l = n),
  86465. s.isAnAncestorOf(l) ? Up.HierarchyIssue : Up.Compatible
  86466. }
  86467. ,
  86468. e.prototype.connectTo = function(e, t) {
  86469. if (void 0 === t && (t = !1),
  86470. !t && !this.canConnectTo(e))
  86471. throw "Cannot connect these two connectors.";
  86472. return this._endpoints.push(e),
  86473. e._connectedPoint = this,
  86474. this._enforceAssociatedVariableName = !1,
  86475. this.onConnectionObservable.notifyObservers(e),
  86476. e.onConnectionObservable.notifyObservers(this),
  86477. this
  86478. }
  86479. ,
  86480. e.prototype.disconnectFrom = function(e) {
  86481. var t = this._endpoints.indexOf(e);
  86482. return -1 === t || (this._endpoints.splice(t, 1),
  86483. e._connectedPoint = null,
  86484. this._enforceAssociatedVariableName = !1,
  86485. e._enforceAssociatedVariableName = !1),
  86486. this
  86487. }
  86488. ,
  86489. e.prototype.serialize = function(e) {
  86490. void 0 === e && (e = !0);
  86491. var t = {};
  86492. return t.name = this.name,
  86493. t.displayName = this.displayName,
  86494. e && this.connectedPoint && (t.inputName = this.name,
  86495. t.targetBlockId = this.connectedPoint.ownerBlock.uniqueId,
  86496. t.targetConnectionName = this.connectedPoint.name,
  86497. t.isExposedOnFrame = !0,
  86498. t.exposedPortPosition = this.exposedPortPosition),
  86499. (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (t.isExposedOnFrame = !0,
  86500. t.exposedPortPosition = this.exposedPortPosition),
  86501. t
  86502. }
  86503. ,
  86504. e.prototype.dispose = function() {
  86505. this.onConnectionObservable.clear()
  86506. }
  86507. ,
  86508. e
  86509. }()
  86510. , Wp = function() {
  86511. function e(e, t, i, n) {
  86512. void 0 === t && (t = Dp.Vertex),
  86513. void 0 === i && (i = !1),
  86514. void 0 === n && (n = !1),
  86515. this._isFinalMerger = !1,
  86516. this._isInput = !1,
  86517. this._name = "",
  86518. this._isUnique = !1,
  86519. this.inputsAreExclusive = !1,
  86520. this._codeVariableName = "",
  86521. this._inputs = new Array,
  86522. this._outputs = new Array,
  86523. this.comments = "",
  86524. this.visibleInInspector = !1,
  86525. this.visibleOnFrame = !1,
  86526. this._target = t,
  86527. this._originalTargetIsNeutral = t === Dp.Neutral,
  86528. this._isFinalMerger = i,
  86529. this._isInput = n,
  86530. this._name = e,
  86531. this.uniqueId = pn.UniqueId
  86532. }
  86533. return Object.defineProperty(e.prototype, "name", {
  86534. get: function() {
  86535. return this._name
  86536. },
  86537. set: function(e) {
  86538. this.validateBlockName(e) && (this._name = e)
  86539. },
  86540. enumerable: !1,
  86541. configurable: !0
  86542. }),
  86543. Object.defineProperty(e.prototype, "isUnique", {
  86544. get: function() {
  86545. return this._isUnique
  86546. },
  86547. enumerable: !1,
  86548. configurable: !0
  86549. }),
  86550. Object.defineProperty(e.prototype, "isFinalMerger", {
  86551. get: function() {
  86552. return this._isFinalMerger
  86553. },
  86554. enumerable: !1,
  86555. configurable: !0
  86556. }),
  86557. Object.defineProperty(e.prototype, "isInput", {
  86558. get: function() {
  86559. return this._isInput
  86560. },
  86561. enumerable: !1,
  86562. configurable: !0
  86563. }),
  86564. Object.defineProperty(e.prototype, "buildId", {
  86565. get: function() {
  86566. return this._buildId
  86567. },
  86568. set: function(e) {
  86569. this._buildId = e
  86570. },
  86571. enumerable: !1,
  86572. configurable: !0
  86573. }),
  86574. Object.defineProperty(e.prototype, "target", {
  86575. get: function() {
  86576. return this._target
  86577. },
  86578. set: function(e) {
  86579. 0 == (this._target & e) && (this._target = e)
  86580. },
  86581. enumerable: !1,
  86582. configurable: !0
  86583. }),
  86584. Object.defineProperty(e.prototype, "inputs", {
  86585. get: function() {
  86586. return this._inputs
  86587. },
  86588. enumerable: !1,
  86589. configurable: !0
  86590. }),
  86591. Object.defineProperty(e.prototype, "outputs", {
  86592. get: function() {
  86593. return this._outputs
  86594. },
  86595. enumerable: !1,
  86596. configurable: !0
  86597. }),
  86598. e.prototype.getInputByName = function(e) {
  86599. var t = this._inputs.filter((function(t) {
  86600. return t.name === e
  86601. }
  86602. ));
  86603. return t.length ? t[0] : null
  86604. }
  86605. ,
  86606. e.prototype.getOutputByName = function(e) {
  86607. var t = this._outputs.filter((function(t) {
  86608. return t.name === e
  86609. }
  86610. ));
  86611. return t.length ? t[0] : null
  86612. }
  86613. ,
  86614. e.prototype.initialize = function(e) {}
  86615. ,
  86616. e.prototype.bind = function(e, t, i, n) {}
  86617. ,
  86618. e.prototype._declareOutput = function(e, t) {
  86619. return "".concat(t._getGLType(e.type), " ").concat(e.associatedVariableName)
  86620. }
  86621. ,
  86622. e.prototype._writeVariable = function(e) {
  86623. return e.connectedPoint ? "".concat(e.associatedVariableName) : "0."
  86624. }
  86625. ,
  86626. e.prototype._writeFloat = function(e) {
  86627. var t = e.toString();
  86628. return -1 === t.indexOf(".") && (t += ".0"),
  86629. "".concat(t)
  86630. }
  86631. ,
  86632. e.prototype.getClassName = function() {
  86633. return "NodeMaterialBlock"
  86634. }
  86635. ,
  86636. e.prototype.registerInput = function(e, t, i, n, r) {
  86637. return void 0 === i && (i = !1),
  86638. (r = null != r ? r : new zp(e,this,Vp.Input)).type = t,
  86639. r.isOptional = i,
  86640. n && (r.target = n),
  86641. this._inputs.push(r),
  86642. this
  86643. }
  86644. ,
  86645. e.prototype.registerOutput = function(e, t, i, n) {
  86646. return (n = null != n ? n : new zp(e,this,Vp.Output)).type = t,
  86647. i && (n.target = i),
  86648. this._outputs.push(n),
  86649. this
  86650. }
  86651. ,
  86652. e.prototype.getFirstAvailableInput = function(e) {
  86653. void 0 === e && (e = null);
  86654. for (var t = 0, i = this._inputs; t < i.length; t++) {
  86655. var n = i[t];
  86656. if (!(n.connectedPoint || e && e.type !== n.type && n.type !== Op.AutoDetect))
  86657. return n
  86658. }
  86659. return null
  86660. }
  86661. ,
  86662. e.prototype.getFirstAvailableOutput = function(e) {
  86663. void 0 === e && (e = null);
  86664. for (var t = 0, i = this._outputs; t < i.length; t++) {
  86665. var n = i[t];
  86666. if (!e || !e.target || e.target === Dp.Neutral || 0 != (e.target & n.target))
  86667. return n
  86668. }
  86669. return null
  86670. }
  86671. ,
  86672. e.prototype.getSiblingOutput = function(e) {
  86673. var t = this._outputs.indexOf(e);
  86674. return -1 === t || t >= this._outputs.length ? null : this._outputs[t + 1]
  86675. }
  86676. ,
  86677. e.prototype.isAnAncestorOf = function(e) {
  86678. for (var t = 0, i = this._outputs; t < i.length; t++) {
  86679. var n = i[t];
  86680. if (n.hasEndpoints)
  86681. for (var r = 0, o = n.endpoints; r < o.length; r++) {
  86682. var a = o[r];
  86683. if (a.ownerBlock === e)
  86684. return !0;
  86685. if (a.ownerBlock.isAnAncestorOf(e))
  86686. return !0
  86687. }
  86688. }
  86689. return !1
  86690. }
  86691. ,
  86692. e.prototype.connectTo = function(e, t) {
  86693. if (0 !== this._outputs.length) {
  86694. for (var i = t && t.output ? this.getOutputByName(t.output) : this.getFirstAvailableOutput(e), n = !0; n; ) {
  86695. var r = t && t.input ? e.getInputByName(t.input) : e.getFirstAvailableInput(i);
  86696. if (i && r && i.canConnectTo(r))
  86697. i.connectTo(r),
  86698. n = !1;
  86699. else {
  86700. if (!i)
  86701. throw "Unable to find a compatible match";
  86702. i = this.getSiblingOutput(i)
  86703. }
  86704. }
  86705. return this
  86706. }
  86707. }
  86708. ,
  86709. e.prototype._buildBlock = function(e) {}
  86710. ,
  86711. e.prototype.updateUniformsAndSamples = function(e, t, i, n) {}
  86712. ,
  86713. e.prototype.provideFallbacks = function(e, t) {}
  86714. ,
  86715. e.prototype.initializeDefines = function(e, t, i, n) {
  86716. void 0 === n && (n = !1)
  86717. }
  86718. ,
  86719. e.prototype.prepareDefines = function(e, t, i, n, r) {
  86720. void 0 === n && (n = !1)
  86721. }
  86722. ,
  86723. e.prototype.autoConfigure = function(e) {}
  86724. ,
  86725. e.prototype.replaceRepeatableContent = function(e, t, i, n) {}
  86726. ,
  86727. Object.defineProperty(e.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
  86728. get: function() {
  86729. return !(this.isInput || this.isFinalMerger || this._outputs.some((function(e) {
  86730. return e.isDirectlyConnectedToVertexOutput
  86731. }
  86732. )) || this.target === Dp.Vertex || this.target !== Dp.VertexAndFragment && this.target !== Dp.Neutral || !this._outputs.some((function(e) {
  86733. return e.isConnectedInVertexShader
  86734. }
  86735. )))
  86736. },
  86737. enumerable: !1,
  86738. configurable: !0
  86739. }),
  86740. e.prototype.isReady = function(e, t, i, n) {
  86741. return void 0 === n && (n = !1),
  86742. !0
  86743. }
  86744. ,
  86745. e.prototype._linkConnectionTypes = function(e, t, i) {
  86746. void 0 === i && (i = !1),
  86747. i ? this._inputs[t]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[t],
  86748. this._inputs[t]._linkedConnectionSource = this._inputs[e]
  86749. }
  86750. ,
  86751. e.prototype._processBuild = function(e, t, i, n) {
  86752. e.build(t, n);
  86753. var r = null != t._vertexState
  86754. , o = e._buildTarget === Dp.Vertex && e.target !== Dp.VertexAndFragment;
  86755. if (r && (0 == (e.target & e._buildTarget) || 0 == (e.target & i.target) || this.target !== Dp.VertexAndFragment && o) && (!e.isInput && t.target !== e._buildTarget || e.isInput && e.isAttribute && !e._noContextSwitch)) {
  86756. var a = i.connectedPoint;
  86757. t._vertexState._emitVaryingFromString("v_" + a.associatedVariableName, t._getGLType(a.type)) && (t._vertexState.compilationString += "".concat("v_" + a.associatedVariableName, " = ").concat(a.associatedVariableName, ";\r\n")),
  86758. i.associatedVariableName = "v_" + a.associatedVariableName,
  86759. i._enforceAssociatedVariableName = !0
  86760. }
  86761. }
  86762. ,
  86763. e.prototype.validateBlockName = function(e) {
  86764. for (var t = 0, i = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "uv3", "uv4", "uv5", "uv6", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"]; t < i.length; t++)
  86765. if (e === i[t])
  86766. return !1;
  86767. return !0
  86768. }
  86769. ,
  86770. e.prototype.build = function(e, t) {
  86771. if (this._buildId === e.sharedData.buildId)
  86772. return !0;
  86773. if (!this.isInput)
  86774. for (var i = 0, n = this._outputs; i < n.length; i++)
  86775. (c = n[i]).associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name));
  86776. for (var r = 0, o = this._inputs; r < o.length; r++) {
  86777. var a = o[r];
  86778. if (a.connectedPoint) {
  86779. if (this.target !== Dp.Neutral) {
  86780. if (0 == (a.target & this.target))
  86781. continue;
  86782. if (0 == (a.target & e.target))
  86783. continue
  86784. }
  86785. (d = a.connectedPoint.ownerBlock) && d !== this && this._processBuild(d, e, a, t)
  86786. } else
  86787. a.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(a)
  86788. }
  86789. if (this._buildId === e.sharedData.buildId)
  86790. return !0;
  86791. if (e.sharedData.verbose && console.log("".concat(e.target === Dp.Vertex ? "Vertex shader" : "Fragment shader", ": Building ").concat(this.name, " [").concat(this.getClassName(), "]")),
  86792. this.isFinalMerger)
  86793. switch (e.target) {
  86794. case Dp.Vertex:
  86795. e.sharedData.checks.emitVertex = !0;
  86796. break;
  86797. case Dp.Fragment:
  86798. e.sharedData.checks.emitFragment = !0
  86799. }
  86800. !this.isInput && e.sharedData.emitComments && (e.compilationString += "\r\n//".concat(this.name, "\r\n")),
  86801. this._buildBlock(e),
  86802. this._buildId = e.sharedData.buildId,
  86803. this._buildTarget = e.target;
  86804. for (var s = 0, l = this._outputs; s < l.length; s++) {
  86805. var c;
  86806. if (0 != ((c = l[s]).target & e.target))
  86807. for (var u = 0, h = c.endpoints; u < h.length; u++) {
  86808. var d, p = h[u];
  86809. (d = p.ownerBlock) && 0 != (d.target & e.target) && -1 !== t.indexOf(d) && this._processBuild(d, e, p, t)
  86810. }
  86811. }
  86812. return !1
  86813. }
  86814. ,
  86815. e.prototype._inputRename = function(e) {
  86816. return e
  86817. }
  86818. ,
  86819. e.prototype._outputRename = function(e) {
  86820. return e
  86821. }
  86822. ,
  86823. e.prototype._dumpPropertiesCode = function() {
  86824. var e = this._codeVariableName;
  86825. return "".concat(e, ".visibleInInspector = ").concat(this.visibleInInspector, ";\r\n").concat(e, ".visibleOnFrame = ").concat(this.visibleOnFrame, ";\r\n").concat(e, ".target = ").concat(this.target, ";\r\n")
  86826. }
  86827. ,
  86828. e.prototype._dumpCode = function(e, t) {
  86829. var i;
  86830. t.push(this);
  86831. var n = this.name.replace(/[^A-Za-z_]+/g, "");
  86832. if (this._codeVariableName = n || "".concat(this.getClassName(), "_").concat(this.uniqueId),
  86833. -1 !== e.indexOf(this._codeVariableName)) {
  86834. var r = 0;
  86835. do {
  86836. r++,
  86837. this._codeVariableName = n + r
  86838. } while (-1 !== e.indexOf(this._codeVariableName))
  86839. }
  86840. e.push(this._codeVariableName),
  86841. i = "\r\n// ".concat(this.getClassName(), "\r\n"),
  86842. this.comments && (i += "// ".concat(this.comments, "\r\n")),
  86843. i += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, '");\r\n'),
  86844. i += this._dumpPropertiesCode();
  86845. for (var o = 0, a = this.inputs; o < a.length; o++) {
  86846. var s = a[o];
  86847. if (s.isConnected) {
  86848. var l = s.connectedPoint.ownerBlock;
  86849. -1 === t.indexOf(l) && (i += l._dumpCode(e, t))
  86850. }
  86851. }
  86852. for (var c = 0, u = this.outputs; c < u.length; c++) {
  86853. var h = u[c];
  86854. if (h.hasEndpoints)
  86855. for (var d = 0, p = h.endpoints; d < p.length; d++)
  86856. (l = p[d].ownerBlock) && -1 === t.indexOf(l) && (i += l._dumpCode(e, t))
  86857. }
  86858. return i
  86859. }
  86860. ,
  86861. e.prototype._dumpCodeForOutputConnections = function(e) {
  86862. var t = "";
  86863. if (-1 !== e.indexOf(this))
  86864. return t;
  86865. e.push(this);
  86866. for (var i = 0, n = this.inputs; i < n.length; i++) {
  86867. var r = n[i];
  86868. if (r.isConnected) {
  86869. var o = r.connectedPoint
  86870. , a = o.ownerBlock;
  86871. t += a._dumpCodeForOutputConnections(e),
  86872. t += "".concat(a._codeVariableName, ".").concat(a._outputRename(o.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(r.name), ");\r\n")
  86873. }
  86874. }
  86875. return t
  86876. }
  86877. ,
  86878. e.prototype.clone = function(e, t) {
  86879. void 0 === t && (t = "");
  86880. var i = this.serialize()
  86881. , n = b(i.customType);
  86882. if (n) {
  86883. var r = new n;
  86884. return r._deserialize(i, e, t),
  86885. r
  86886. }
  86887. return null
  86888. }
  86889. ,
  86890. e.prototype.serialize = function() {
  86891. var e = {};
  86892. e.customType = "BABYLON." + this.getClassName(),
  86893. e.id = this.uniqueId,
  86894. e.name = this.name,
  86895. e.comments = this.comments,
  86896. e.visibleInInspector = this.visibleInInspector,
  86897. e.visibleOnFrame = this.visibleOnFrame,
  86898. e.target = this.target,
  86899. e.inputs = [],
  86900. e.outputs = [];
  86901. for (var t = 0, i = this.inputs; t < i.length; t++) {
  86902. var n = i[t];
  86903. e.inputs.push(n.serialize())
  86904. }
  86905. for (var r = 0, o = this.outputs; r < o.length; r++) {
  86906. var a = o[r];
  86907. e.outputs.push(a.serialize(!1))
  86908. }
  86909. return e
  86910. }
  86911. ,
  86912. e.prototype._deserialize = function(e, t, i) {
  86913. var n;
  86914. this.name = e.name,
  86915. this.comments = e.comments,
  86916. this.visibleInInspector = !!e.visibleInInspector,
  86917. this.visibleOnFrame = !!e.visibleOnFrame,
  86918. this._target = null !== (n = e.target) && void 0 !== n ? n : this.target,
  86919. this._deserializePortDisplayNamesAndExposedOnFrame(e)
  86920. }
  86921. ,
  86922. e.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
  86923. var t = this
  86924. , i = e.inputs
  86925. , n = e.outputs;
  86926. i && i.forEach((function(e, i) {
  86927. e.displayName && (t.inputs[i].displayName = e.displayName),
  86928. e.isExposedOnFrame && (t.inputs[i].isExposedOnFrame = e.isExposedOnFrame,
  86929. t.inputs[i].exposedPortPosition = e.exposedPortPosition)
  86930. }
  86931. )),
  86932. n && n.forEach((function(e, i) {
  86933. e.displayName && (t.outputs[i].displayName = e.displayName),
  86934. e.isExposedOnFrame && (t.outputs[i].isExposedOnFrame = e.isExposedOnFrame,
  86935. t.outputs[i].exposedPortPosition = e.exposedPortPosition)
  86936. }
  86937. ))
  86938. }
  86939. ,
  86940. e.prototype.dispose = function() {
  86941. for (var e = 0, t = this.inputs; e < t.length; e++)
  86942. t[e].dispose();
  86943. for (var i = 0, n = this.outputs; i < n.length; i++)
  86944. n[i].dispose()
  86945. }
  86946. ,
  86947. e
  86948. }()
  86949. , Hp = function(e) {
  86950. function t(t) {
  86951. var i = e.call(this, t, Dp.Neutral) || this;
  86952. return i.complementW = 1,
  86953. i.complementZ = 0,
  86954. i.target = Dp.Vertex,
  86955. i.registerInput("vector", Op.AutoDetect),
  86956. i.registerInput("transform", Op.Matrix),
  86957. i.registerOutput("output", Op.Vector4),
  86958. i.registerOutput("xyz", Op.Vector3),
  86959. i._inputs[0].onConnectionObservable.add((function(e) {
  86960. if (e.ownerBlock.isInput) {
  86961. var t = e.ownerBlock;
  86962. "normal" !== t.name && "tangent" !== t.name || (i.complementW = 0)
  86963. }
  86964. }
  86965. )),
  86966. i
  86967. }
  86968. return U(t, e),
  86969. t.prototype.getClassName = function() {
  86970. return "TransformBlock"
  86971. }
  86972. ,
  86973. Object.defineProperty(t.prototype, "vector", {
  86974. get: function() {
  86975. return this._inputs[0]
  86976. },
  86977. enumerable: !1,
  86978. configurable: !0
  86979. }),
  86980. Object.defineProperty(t.prototype, "output", {
  86981. get: function() {
  86982. return this._outputs[0]
  86983. },
  86984. enumerable: !1,
  86985. configurable: !0
  86986. }),
  86987. Object.defineProperty(t.prototype, "xyz", {
  86988. get: function() {
  86989. return this._outputs[1]
  86990. },
  86991. enumerable: !1,
  86992. configurable: !0
  86993. }),
  86994. Object.defineProperty(t.prototype, "transform", {
  86995. get: function() {
  86996. return this._inputs[1]
  86997. },
  86998. enumerable: !1,
  86999. configurable: !0
  87000. }),
  87001. t.prototype._buildBlock = function(t) {
  87002. e.prototype._buildBlock.call(this, t);
  87003. var i = this.vector
  87004. , n = this.transform;
  87005. if (i.connectedPoint) {
  87006. if (0 === this.complementW) {
  87007. var r = "//".concat(this.name);
  87008. t._emitFunctionFromInclude("helperFunctions", r),
  87009. t.sharedData.blocksWithDefines.push(this);
  87010. var o = t._getFreeVariableName("".concat(n.associatedVariableName, "_NUS"));
  87011. switch (t.compilationString += "mat3 ".concat(o, " = mat3(").concat(n.associatedVariableName, ");\r\n"),
  87012. t.compilationString += "#ifdef NONUNIFORMSCALING\r\n",
  87013. t.compilationString += "".concat(o, " = transposeMat3(inverseMat3(").concat(o, "));\r\n"),
  87014. t.compilationString += "#endif\r\n",
  87015. i.connectedPoint.type) {
  87016. case Op.Vector2:
  87017. t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * vec3(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), "), ").concat(this._writeFloat(this.complementW), ");\r\n");
  87018. break;
  87019. case Op.Vector3:
  87020. case Op.Color3:
  87021. t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
  87022. break;
  87023. default:
  87024. t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ".xyz, ").concat(this._writeFloat(this.complementW), ");\r\n")
  87025. }
  87026. } else
  87027. switch (o = n.associatedVariableName,
  87028. i.connectedPoint.type) {
  87029. case Op.Vector2:
  87030. t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), ", ").concat(this._writeFloat(this.complementW), ");\r\n");
  87031. break;
  87032. case Op.Vector3:
  87033. case Op.Color3:
  87034. t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
  87035. break;
  87036. default:
  87037. t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * ").concat(i.associatedVariableName, ";\r\n")
  87038. }
  87039. this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\r\n"))
  87040. }
  87041. return this
  87042. }
  87043. ,
  87044. t.prototype.prepareDefines = function(e, t, i) {
  87045. e.nonUniformScaling && i.setValue("NONUNIFORMSCALING", !0)
  87046. }
  87047. ,
  87048. t.prototype.serialize = function() {
  87049. var t = e.prototype.serialize.call(this);
  87050. return t.complementZ = this.complementZ,
  87051. t.complementW = this.complementW,
  87052. t
  87053. }
  87054. ,
  87055. t.prototype._deserialize = function(t, i, n) {
  87056. e.prototype._deserialize.call(this, t, i, n),
  87057. this.complementZ = void 0 !== t.complementZ ? t.complementZ : 0,
  87058. this.complementW = void 0 !== t.complementW ? t.complementW : 1
  87059. }
  87060. ,
  87061. t.prototype._dumpPropertiesCode = function() {
  87062. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".complementZ = ").concat(this.complementZ, ";\r\n") + "".concat(this._codeVariableName, ".complementW = ").concat(this.complementW, ";\r\n")
  87063. }
  87064. ,
  87065. t
  87066. }(Wp);
  87067. y("BABYLON.TransformBlock", Hp);
  87068. var Xp, jp = function(e) {
  87069. function t(t) {
  87070. var i = e.call(this, t, Dp.Vertex, !0) || this;
  87071. return i.registerInput("vector", Op.Vector4),
  87072. i
  87073. }
  87074. return U(t, e),
  87075. t.prototype.getClassName = function() {
  87076. return "VertexOutputBlock"
  87077. }
  87078. ,
  87079. Object.defineProperty(t.prototype, "vector", {
  87080. get: function() {
  87081. return this._inputs[0]
  87082. },
  87083. enumerable: !1,
  87084. configurable: !0
  87085. }),
  87086. t.prototype._isLogarithmicDepthEnabled = function(e) {
  87087. for (var t = 0, i = e; t < i.length; t++)
  87088. if (i[t].useLogarithmicDepth)
  87089. return !0;
  87090. return !1
  87091. }
  87092. ,
  87093. t.prototype._buildBlock = function(t) {
  87094. e.prototype._buildBlock.call(this, t);
  87095. var i = this.vector;
  87096. return t.compilationString += "gl_Position = ".concat(i.associatedVariableName, ";\r\n"),
  87097. this._isLogarithmicDepthEnabled(t.sharedData.fragmentOutputNodes) && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
  87098. t._emitVaryingFromString("vFragmentDepth", "float"),
  87099. t.compilationString += "vFragmentDepth = 1.0 + gl_Position.w;\r\n",
  87100. t.compilationString += "gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r\n"),
  87101. this
  87102. }
  87103. ,
  87104. t
  87105. }(Wp);
  87106. function Yp(e, t, i, n) {
  87107. return void 0 === t && (t = Xp.Boolean),
  87108. void 0 === i && (i = "PROPERTIES"),
  87109. function(r, o) {
  87110. var a = r._propStore;
  87111. a || (a = [],
  87112. r._propStore = a),
  87113. a.push({
  87114. propertyName: o,
  87115. displayName: e,
  87116. type: t,
  87117. groupName: i,
  87118. options: null != n ? n : {}
  87119. })
  87120. }
  87121. }
  87122. y("BABYLON.VertexOutputBlock", jp),
  87123. function(e) {
  87124. e[e.Boolean = 0] = "Boolean",
  87125. e[e.Float = 1] = "Float",
  87126. e[e.Int = 2] = "Int",
  87127. e[e.Vector2 = 3] = "Vector2",
  87128. e[e.List = 4] = "List"
  87129. }(Xp || (Xp = {}));
  87130. var Kp, Qp, qp, Zp = function(e) {
  87131. function t(t) {
  87132. var i = e.call(this, t, Dp.Fragment, !0) || this;
  87133. return i.convertToGammaSpace = !1,
  87134. i.convertToLinearSpace = !1,
  87135. i.useLogarithmicDepth = !1,
  87136. i.registerInput("rgba", Op.Color4, !0),
  87137. i.registerInput("rgb", Op.Color3, !0),
  87138. i.registerInput("a", Op.Float, !0),
  87139. i.rgb.acceptedConnectionPointTypes.push(Op.Float),
  87140. i
  87141. }
  87142. return U(t, e),
  87143. t.prototype.getClassName = function() {
  87144. return "FragmentOutputBlock"
  87145. }
  87146. ,
  87147. t.prototype.initialize = function(e) {
  87148. e._excludeVariableName("logarithmicDepthConstant"),
  87149. e._excludeVariableName("vFragmentDepth")
  87150. }
  87151. ,
  87152. Object.defineProperty(t.prototype, "rgba", {
  87153. get: function() {
  87154. return this._inputs[0]
  87155. },
  87156. enumerable: !1,
  87157. configurable: !0
  87158. }),
  87159. Object.defineProperty(t.prototype, "rgb", {
  87160. get: function() {
  87161. return this._inputs[1]
  87162. },
  87163. enumerable: !1,
  87164. configurable: !0
  87165. }),
  87166. Object.defineProperty(t.prototype, "a", {
  87167. get: function() {
  87168. return this._inputs[2]
  87169. },
  87170. enumerable: !1,
  87171. configurable: !0
  87172. }),
  87173. t.prototype.prepareDefines = function(e, t, i) {
  87174. i.setValue(this._linearDefineName, this.convertToLinearSpace, !0),
  87175. i.setValue(this._gammaDefineName, this.convertToGammaSpace, !0)
  87176. }
  87177. ,
  87178. t.prototype.bind = function(e, t, i) {
  87179. this.useLogarithmicDepth && i && Mr.BindLogDepth(void 0, e, i.getScene())
  87180. }
  87181. ,
  87182. t.prototype._buildBlock = function(t) {
  87183. e.prototype._buildBlock.call(this, t);
  87184. var i = this.rgba
  87185. , n = this.rgb
  87186. , r = this.a;
  87187. t.sharedData.hints.needAlphaBlending = i.isConnected || r.isConnected,
  87188. t.sharedData.blocksWithDefines.push(this),
  87189. this.useLogarithmicDepth && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
  87190. t._emitVaryingFromString("vFragmentDepth", "float"),
  87191. t.sharedData.bindableBlocks.push(this)),
  87192. this._linearDefineName = t._getFreeDefineName("CONVERTTOLINEAR"),
  87193. this._gammaDefineName = t._getFreeDefineName("CONVERTTOGAMMA");
  87194. var o = "//".concat(this.name);
  87195. if (t._emitFunctionFromInclude("helperFunctions", o),
  87196. i.connectedPoint)
  87197. r.isConnected ? t.compilationString += "gl_FragColor = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(r.associatedVariableName, ");\r\n") : t.compilationString += "gl_FragColor = ".concat(i.associatedVariableName, ";\r\n");
  87198. else if (n.connectedPoint) {
  87199. var a = "1.0";
  87200. r.connectedPoint && (a = r.associatedVariableName),
  87201. n.connectedPoint.type === Op.Float ? t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(a, ");\r\n") : t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(a, ");\r\n")
  87202. } else
  87203. t.sharedData.checks.notConnectedNonOptionalInputs.push(i);
  87204. return t.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
  87205. t.compilationString += "gl_FragColor = toLinearSpace(gl_FragColor);\r\n",
  87206. t.compilationString += "#endif\r\n",
  87207. t.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
  87208. t.compilationString += "gl_FragColor = toGammaSpace(gl_FragColor);\r\n",
  87209. t.compilationString += "#endif\r\n",
  87210. this.useLogarithmicDepth && (t.compilationString += "gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r\n"),
  87211. this
  87212. }
  87213. ,
  87214. t.prototype._dumpPropertiesCode = function() {
  87215. var t = e.prototype._dumpPropertiesCode.call(this);
  87216. return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\r\n"),
  87217. (t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n")) + "".concat(this._codeVariableName, ".useLogarithmicDepth = ").concat(this.useLogarithmicDepth, ";\r\n")
  87218. }
  87219. ,
  87220. t.prototype.serialize = function() {
  87221. var t = e.prototype.serialize.call(this);
  87222. return t.convertToGammaSpace = this.convertToGammaSpace,
  87223. t.convertToLinearSpace = this.convertToLinearSpace,
  87224. t.useLogarithmicDepth = this.useLogarithmicDepth,
  87225. t
  87226. }
  87227. ,
  87228. t.prototype._deserialize = function(t, i, n) {
  87229. var r;
  87230. e.prototype._deserialize.call(this, t, i, n),
  87231. this.convertToGammaSpace = t.convertToGammaSpace,
  87232. this.convertToLinearSpace = t.convertToLinearSpace,
  87233. this.useLogarithmicDepth = null !== (r = t.useLogarithmicDepth) && void 0 !== r && r
  87234. }
  87235. ,
  87236. k([Yp("Convert to gamma space", Xp.Boolean, "PROPERTIES", {
  87237. notifiers: {
  87238. update: !0
  87239. }
  87240. })], t.prototype, "convertToGammaSpace", void 0),
  87241. k([Yp("Convert to linear space", Xp.Boolean, "PROPERTIES", {
  87242. notifiers: {
  87243. update: !0
  87244. }
  87245. })], t.prototype, "convertToLinearSpace", void 0),
  87246. k([Yp("Use logarithmic depth", Xp.Boolean, "PROPERTIES")], t.prototype, "useLogarithmicDepth", void 0),
  87247. t
  87248. }(Wp);
  87249. y("BABYLON.FragmentOutputBlock", Zp),
  87250. function(e) {
  87251. e[e.Uniform = 0] = "Uniform",
  87252. e[e.Attribute = 1] = "Attribute",
  87253. e[e.Varying = 2] = "Varying",
  87254. e[e.Undefined = 3] = "Undefined"
  87255. }(Kp || (Kp = {})),
  87256. function(e) {
  87257. e[e.World = 1] = "World",
  87258. e[e.View = 2] = "View",
  87259. e[e.Projection = 3] = "Projection",
  87260. e[e.ViewProjection = 4] = "ViewProjection",
  87261. e[e.WorldView = 5] = "WorldView",
  87262. e[e.WorldViewProjection = 6] = "WorldViewProjection",
  87263. e[e.CameraPosition = 7] = "CameraPosition",
  87264. e[e.FogColor = 8] = "FogColor",
  87265. e[e.DeltaTime = 9] = "DeltaTime",
  87266. e[e.CameraParameters = 10] = "CameraParameters",
  87267. e[e.MaterialAlpha = 11] = "MaterialAlpha"
  87268. }(Qp || (Qp = {})),
  87269. function(e) {
  87270. e[e.None = 0] = "None",
  87271. e[e.Time = 1] = "Time"
  87272. }(qp || (qp = {}));
  87273. var Jp = {
  87274. position2d: "position",
  87275. particle_uv: "vUV",
  87276. particle_color: "vColor",
  87277. particle_texturemask: "textureMask",
  87278. particle_positionw: "vPositionW"
  87279. }
  87280. , $p = {
  87281. particle_uv: !0,
  87282. particle_color: !0,
  87283. particle_texturemask: !0,
  87284. particle_positionw: !0
  87285. }
  87286. , ef = {
  87287. particle_texturemask: !0
  87288. }
  87289. , tf = function(e) {
  87290. function t(t, i, n) {
  87291. void 0 === i && (i = Dp.Vertex),
  87292. void 0 === n && (n = Op.AutoDetect);
  87293. var r = e.call(this, t, i, !1, !0) || this;
  87294. return r._mode = Kp.Undefined,
  87295. r._animationType = qp.None,
  87296. r.min = 0,
  87297. r.max = 0,
  87298. r.isBoolean = !1,
  87299. r.matrixMode = 0,
  87300. r._systemValue = null,
  87301. r.isConstant = !1,
  87302. r.groupInInspector = "",
  87303. r.onValueChangedObservable = new h,
  87304. r.convertToGammaSpace = !1,
  87305. r.convertToLinearSpace = !1,
  87306. r._type = n,
  87307. r.setDefaultValue(),
  87308. r.registerOutput("output", n),
  87309. r
  87310. }
  87311. return U(t, e),
  87312. Object.defineProperty(t.prototype, "type", {
  87313. get: function() {
  87314. if (this._type === Op.AutoDetect) {
  87315. if (this.isUniform && null != this.value) {
  87316. if (!isNaN(this.value))
  87317. return this._type = Op.Float,
  87318. this._type;
  87319. switch (this.value.getClassName()) {
  87320. case "Vector2":
  87321. return this._type = Op.Vector2,
  87322. this._type;
  87323. case "Vector3":
  87324. return this._type = Op.Vector3,
  87325. this._type;
  87326. case "Vector4":
  87327. return this._type = Op.Vector4,
  87328. this._type;
  87329. case "Color3":
  87330. return this._type = Op.Color3,
  87331. this._type;
  87332. case "Color4":
  87333. return this._type = Op.Color4,
  87334. this._type;
  87335. case "Matrix":
  87336. return this._type = Op.Matrix,
  87337. this._type
  87338. }
  87339. }
  87340. if (this.isAttribute)
  87341. switch (this.name) {
  87342. case "position":
  87343. case "normal":
  87344. case "tangent":
  87345. case "particle_positionw":
  87346. return this._type = Op.Vector3,
  87347. this._type;
  87348. case "uv":
  87349. case "uv2":
  87350. case "uv3":
  87351. case "uv4":
  87352. case "uv5":
  87353. case "uv6":
  87354. case "position2d":
  87355. case "particle_uv":
  87356. return this._type = Op.Vector2,
  87357. this._type;
  87358. case "matricesIndices":
  87359. case "matricesWeights":
  87360. case "world0":
  87361. case "world1":
  87362. case "world2":
  87363. case "world3":
  87364. return this._type = Op.Vector4,
  87365. this._type;
  87366. case "color":
  87367. case "particle_color":
  87368. case "particle_texturemask":
  87369. return this._type = Op.Color4,
  87370. this._type
  87371. }
  87372. if (this.isSystemValue)
  87373. switch (this._systemValue) {
  87374. case Qp.World:
  87375. case Qp.WorldView:
  87376. case Qp.WorldViewProjection:
  87377. case Qp.View:
  87378. case Qp.ViewProjection:
  87379. case Qp.Projection:
  87380. return this._type = Op.Matrix,
  87381. this._type;
  87382. case Qp.CameraPosition:
  87383. return this._type = Op.Vector3,
  87384. this._type;
  87385. case Qp.FogColor:
  87386. return this._type = Op.Color3,
  87387. this._type;
  87388. case Qp.DeltaTime:
  87389. case Qp.MaterialAlpha:
  87390. return this._type = Op.Float,
  87391. this._type;
  87392. case Qp.CameraParameters:
  87393. return this._type = Op.Vector4,
  87394. this._type
  87395. }
  87396. }
  87397. return this._type
  87398. },
  87399. enumerable: !1,
  87400. configurable: !0
  87401. }),
  87402. t.prototype.validateBlockName = function(t) {
  87403. return !!this.isAttribute || e.prototype.validateBlockName.call(this, t)
  87404. }
  87405. ,
  87406. Object.defineProperty(t.prototype, "output", {
  87407. get: function() {
  87408. return this._outputs[0]
  87409. },
  87410. enumerable: !1,
  87411. configurable: !0
  87412. }),
  87413. t.prototype.setAsAttribute = function(e) {
  87414. return this._mode = Kp.Attribute,
  87415. e && (this.name = e),
  87416. this
  87417. }
  87418. ,
  87419. t.prototype.setAsSystemValue = function(e) {
  87420. return this.systemValue = e,
  87421. this
  87422. }
  87423. ,
  87424. Object.defineProperty(t.prototype, "value", {
  87425. get: function() {
  87426. return this._storedValue
  87427. },
  87428. set: function(e) {
  87429. this.type === Op.Float && (this.isBoolean ? e = e ? 1 : 0 : this.min !== this.max && (e = Math.max(this.min, e),
  87430. e = Math.min(this.max, e))),
  87431. this._storedValue = e,
  87432. this._mode = Kp.Uniform,
  87433. this.onValueChangedObservable.notifyObservers(this)
  87434. },
  87435. enumerable: !1,
  87436. configurable: !0
  87437. }),
  87438. Object.defineProperty(t.prototype, "valueCallback", {
  87439. get: function() {
  87440. return this._valueCallback
  87441. },
  87442. set: function(e) {
  87443. this._valueCallback = e,
  87444. this._mode = Kp.Uniform
  87445. },
  87446. enumerable: !1,
  87447. configurable: !0
  87448. }),
  87449. Object.defineProperty(t.prototype, "associatedVariableName", {
  87450. get: function() {
  87451. return this._associatedVariableName
  87452. },
  87453. set: function(e) {
  87454. this._associatedVariableName = e
  87455. },
  87456. enumerable: !1,
  87457. configurable: !0
  87458. }),
  87459. Object.defineProperty(t.prototype, "animationType", {
  87460. get: function() {
  87461. return this._animationType
  87462. },
  87463. set: function(e) {
  87464. this._animationType = e
  87465. },
  87466. enumerable: !1,
  87467. configurable: !0
  87468. }),
  87469. Object.defineProperty(t.prototype, "isUndefined", {
  87470. get: function() {
  87471. return this._mode === Kp.Undefined
  87472. },
  87473. enumerable: !1,
  87474. configurable: !0
  87475. }),
  87476. Object.defineProperty(t.prototype, "isUniform", {
  87477. get: function() {
  87478. return this._mode === Kp.Uniform
  87479. },
  87480. set: function(e) {
  87481. this._mode = e ? Kp.Uniform : Kp.Undefined,
  87482. this.associatedVariableName = ""
  87483. },
  87484. enumerable: !1,
  87485. configurable: !0
  87486. }),
  87487. Object.defineProperty(t.prototype, "isAttribute", {
  87488. get: function() {
  87489. return this._mode === Kp.Attribute
  87490. },
  87491. set: function(e) {
  87492. this._mode = e ? Kp.Attribute : Kp.Undefined,
  87493. this.associatedVariableName = ""
  87494. },
  87495. enumerable: !1,
  87496. configurable: !0
  87497. }),
  87498. Object.defineProperty(t.prototype, "isVarying", {
  87499. get: function() {
  87500. return this._mode === Kp.Varying
  87501. },
  87502. set: function(e) {
  87503. this._mode = e ? Kp.Varying : Kp.Undefined,
  87504. this.associatedVariableName = ""
  87505. },
  87506. enumerable: !1,
  87507. configurable: !0
  87508. }),
  87509. Object.defineProperty(t.prototype, "isSystemValue", {
  87510. get: function() {
  87511. return null != this._systemValue
  87512. },
  87513. enumerable: !1,
  87514. configurable: !0
  87515. }),
  87516. Object.defineProperty(t.prototype, "systemValue", {
  87517. get: function() {
  87518. return this._systemValue
  87519. },
  87520. set: function(e) {
  87521. this._mode = Kp.Uniform,
  87522. this.associatedVariableName = "",
  87523. this._systemValue = e
  87524. },
  87525. enumerable: !1,
  87526. configurable: !0
  87527. }),
  87528. t.prototype.getClassName = function() {
  87529. return "InputBlock"
  87530. }
  87531. ,
  87532. t.prototype.animate = function(e) {
  87533. this._animationType === qp.Time && this.type === Op.Float && (this.value += .01 * e.getAnimationRatio())
  87534. }
  87535. ,
  87536. t.prototype._emitDefine = function(e) {
  87537. return "!" === e[0] ? "#ifndef ".concat(e.substring(1), "\r\n") : "#ifdef ".concat(e, "\r\n")
  87538. }
  87539. ,
  87540. t.prototype.initialize = function() {
  87541. this.associatedVariableName = ""
  87542. }
  87543. ,
  87544. t.prototype.setDefaultValue = function() {
  87545. switch (this.type) {
  87546. case Op.Float:
  87547. this.value = 0;
  87548. break;
  87549. case Op.Vector2:
  87550. this.value = A.Zero();
  87551. break;
  87552. case Op.Vector3:
  87553. this.value = x.Zero();
  87554. break;
  87555. case Op.Vector4:
  87556. this.value = R.Zero();
  87557. break;
  87558. case Op.Color3:
  87559. this.value = D.White();
  87560. break;
  87561. case Op.Color4:
  87562. this.value = new N(1,1,1,1);
  87563. break;
  87564. case Op.Matrix:
  87565. this.value = P.Identity()
  87566. }
  87567. }
  87568. ,
  87569. t.prototype._emitConstant = function(e) {
  87570. switch (this.type) {
  87571. case Op.Float:
  87572. return "".concat(e._emitFloat(this.value));
  87573. case Op.Vector2:
  87574. return "vec2(".concat(this.value.x, ", ").concat(this.value.y, ")");
  87575. case Op.Vector3:
  87576. return "vec3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
  87577. case Op.Vector4:
  87578. return "vec4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
  87579. case Op.Color3:
  87580. return L.Color3[0].set(this.value.r, this.value.g, this.value.b),
  87581. this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
  87582. this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
  87583. "vec3(".concat(L.Color3[0].r, ", ").concat(L.Color3[0].g, ", ").concat(L.Color3[0].b, ")");
  87584. case Op.Color4:
  87585. return L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
  87586. this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
  87587. this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
  87588. "vec4(".concat(L.Color4[0].r, ", ").concat(L.Color4[0].g, ", ").concat(L.Color4[0].b, ", ").concat(L.Color4[0].a, ")")
  87589. }
  87590. return ""
  87591. }
  87592. ,
  87593. Object.defineProperty(t.prototype, "_noContextSwitch", {
  87594. get: function() {
  87595. return $p[this.name]
  87596. },
  87597. enumerable: !1,
  87598. configurable: !0
  87599. }),
  87600. t.prototype._emit = function(e, t) {
  87601. var i;
  87602. if (this.isUniform) {
  87603. if (this.associatedVariableName || (this.associatedVariableName = e._getFreeVariableName("u_" + this.name)),
  87604. this.isConstant) {
  87605. if (-1 !== e.constants.indexOf(this.associatedVariableName))
  87606. return;
  87607. return e.constants.push(this.associatedVariableName),
  87608. void (e._constantDeclaration += this._declareOutput(this.output, e) + " = ".concat(this._emitConstant(e), ";\r\n"))
  87609. }
  87610. if (-1 !== e.uniforms.indexOf(this.associatedVariableName))
  87611. return;
  87612. e.uniforms.push(this.associatedVariableName),
  87613. t && (e._uniformDeclaration += this._emitDefine(t)),
  87614. e._uniformDeclaration += "uniform ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\r\n"),
  87615. t && (e._uniformDeclaration += "#endif\r\n");
  87616. var n = e.sharedData.hints;
  87617. if (null !== this._systemValue && void 0 !== this._systemValue)
  87618. switch (this._systemValue) {
  87619. case Qp.WorldView:
  87620. n.needWorldViewMatrix = !0;
  87621. break;
  87622. case Qp.WorldViewProjection:
  87623. n.needWorldViewProjectionMatrix = !0
  87624. }
  87625. else
  87626. this._animationType !== qp.None && e.sharedData.animatedInputs.push(this)
  87627. } else if (this.isAttribute) {
  87628. if (this.associatedVariableName = null !== (i = Jp[this.name]) && void 0 !== i ? i : this.name,
  87629. this.target === Dp.Vertex && e._vertexState)
  87630. return void ($p[this.name] ? ef[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : this._emit(e._vertexState, t));
  87631. if (-1 !== e.attributes.indexOf(this.associatedVariableName))
  87632. return;
  87633. e.attributes.push(this.associatedVariableName),
  87634. $p[this.name] ? ef[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : (t && (e._attributeDeclaration += this._emitDefine(t)),
  87635. e._attributeDeclaration += "attribute ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\r\n"),
  87636. t && (e._attributeDeclaration += "#endif\r\n"))
  87637. }
  87638. }
  87639. ,
  87640. t.prototype._transmitWorld = function(e, t, i, n) {
  87641. if (this._systemValue) {
  87642. var r = this.associatedVariableName;
  87643. switch (this._systemValue) {
  87644. case Qp.World:
  87645. e.setMatrix(r, t);
  87646. break;
  87647. case Qp.WorldView:
  87648. e.setMatrix(r, i);
  87649. break;
  87650. case Qp.WorldViewProjection:
  87651. e.setMatrix(r, n)
  87652. }
  87653. }
  87654. }
  87655. ,
  87656. t.prototype._transmit = function(e, t, i) {
  87657. if (!this.isAttribute) {
  87658. var n = this.associatedVariableName;
  87659. if (this._systemValue)
  87660. switch (this._systemValue) {
  87661. case Qp.World:
  87662. case Qp.WorldView:
  87663. case Qp.WorldViewProjection:
  87664. return;
  87665. case Qp.View:
  87666. e.setMatrix(n, t.getViewMatrix());
  87667. break;
  87668. case Qp.Projection:
  87669. e.setMatrix(n, t.getProjectionMatrix());
  87670. break;
  87671. case Qp.ViewProjection:
  87672. e.setMatrix(n, t.getTransformMatrix());
  87673. break;
  87674. case Qp.CameraPosition:
  87675. t.bindEyePosition(e, n, !0);
  87676. break;
  87677. case Qp.FogColor:
  87678. e.setColor3(n, t.fogColor);
  87679. break;
  87680. case Qp.DeltaTime:
  87681. e.setFloat(n, t.deltaTime / 1e3);
  87682. break;
  87683. case Qp.CameraParameters:
  87684. t.activeCamera && e.setFloat4(n, t.getEngine().hasOriginBottomLeft ? -1 : 1, t.activeCamera.minZ, t.activeCamera.maxZ, 1 / t.activeCamera.maxZ);
  87685. break;
  87686. case Qp.MaterialAlpha:
  87687. e.setFloat(n, i.alpha)
  87688. }
  87689. else {
  87690. var r = this._valueCallback ? this._valueCallback() : this._storedValue;
  87691. if (null !== r)
  87692. switch (this.type) {
  87693. case Op.Float:
  87694. e.setFloat(n, r);
  87695. break;
  87696. case Op.Int:
  87697. e.setInt(n, r);
  87698. break;
  87699. case Op.Color3:
  87700. L.Color3[0].set(this.value.r, this.value.g, this.value.b),
  87701. this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
  87702. this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
  87703. e.setColor3(n, L.Color3[0]);
  87704. break;
  87705. case Op.Color4:
  87706. L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
  87707. this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
  87708. this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
  87709. e.setDirectColor4(n, L.Color4[0]);
  87710. break;
  87711. case Op.Vector2:
  87712. e.setVector2(n, r);
  87713. break;
  87714. case Op.Vector3:
  87715. e.setVector3(n, r);
  87716. break;
  87717. case Op.Vector4:
  87718. e.setVector4(n, r);
  87719. break;
  87720. case Op.Matrix:
  87721. e.setMatrix(n, r)
  87722. }
  87723. }
  87724. }
  87725. }
  87726. ,
  87727. t.prototype._buildBlock = function(t) {
  87728. e.prototype._buildBlock.call(this, t),
  87729. (this.isUniform || this.isSystemValue) && t.sharedData.inputBlocks.push(this),
  87730. this._emit(t)
  87731. }
  87732. ,
  87733. t.prototype._dumpPropertiesCode = function() {
  87734. var t = this._codeVariableName;
  87735. if (this.isAttribute)
  87736. return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, '.setAsAttribute("').concat(this.name, '");\r\n');
  87737. if (this.isSystemValue)
  87738. return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, ".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(Qp[this._systemValue], ");\r\n");
  87739. if (this.isUniform) {
  87740. var i = []
  87741. , n = "";
  87742. switch (this.type) {
  87743. case Op.Float:
  87744. n = "".concat(this.value);
  87745. break;
  87746. case Op.Vector2:
  87747. n = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")");
  87748. break;
  87749. case Op.Vector3:
  87750. n = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
  87751. break;
  87752. case Op.Vector4:
  87753. n = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
  87754. break;
  87755. case Op.Color3:
  87756. n = "new BABYLON.Color3(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ")"),
  87757. this.convertToGammaSpace && (n += ".toGammaSpace()"),
  87758. this.convertToLinearSpace && (n += ".toLinearSpace()");
  87759. break;
  87760. case Op.Color4:
  87761. n = "new BABYLON.Color4(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ", ").concat(this.value.a, ")"),
  87762. this.convertToGammaSpace && (n += ".toGammaSpace()"),
  87763. this.convertToLinearSpace && (n += ".toLinearSpace()");
  87764. break;
  87765. case Op.Matrix:
  87766. n = "BABYLON.Matrix.FromArray([".concat(this.value.m, "])")
  87767. }
  87768. return i.push("".concat(t, ".value = ").concat(n)),
  87769. this.type === Op.Float && i.push("".concat(t, ".min = ").concat(this.min), "".concat(t, ".max = ").concat(this.max), "".concat(t, ".isBoolean = ").concat(this.isBoolean), "".concat(t, ".matrixMode = ").concat(this.matrixMode), "".concat(t, ".animationType = BABYLON.AnimatedInputBlockTypes.").concat(qp[this.animationType])),
  87770. i.push("".concat(t, ".isConstant = ").concat(this.isConstant)),
  87771. i.push(""),
  87772. e.prototype._dumpPropertiesCode.call(this) + i.join(";\r\n")
  87773. }
  87774. return e.prototype._dumpPropertiesCode.call(this)
  87775. }
  87776. ,
  87777. t.prototype.dispose = function() {
  87778. this.onValueChangedObservable.clear(),
  87779. e.prototype.dispose.call(this)
  87780. }
  87781. ,
  87782. t.prototype.serialize = function() {
  87783. var t = e.prototype.serialize.call(this);
  87784. return t.type = this.type,
  87785. t.mode = this._mode,
  87786. t.systemValue = this._systemValue,
  87787. t.animationType = this._animationType,
  87788. t.min = this.min,
  87789. t.max = this.max,
  87790. t.isBoolean = this.isBoolean,
  87791. t.matrixMode = this.matrixMode,
  87792. t.isConstant = this.isConstant,
  87793. t.groupInInspector = this.groupInInspector,
  87794. t.convertToGammaSpace = this.convertToGammaSpace,
  87795. t.convertToLinearSpace = this.convertToLinearSpace,
  87796. null != this._storedValue && this._mode === Kp.Uniform && (this._storedValue.asArray ? (t.valueType = "BABYLON." + this._storedValue.getClassName(),
  87797. t.value = this._storedValue.asArray()) : (t.valueType = "number",
  87798. t.value = this._storedValue)),
  87799. t
  87800. }
  87801. ,
  87802. t.prototype._deserialize = function(t, i, n) {
  87803. if (this._mode = t.mode,
  87804. e.prototype._deserialize.call(this, t, i, n),
  87805. this._type = t.type,
  87806. this._systemValue = t.systemValue || t.wellKnownValue,
  87807. this._animationType = t.animationType,
  87808. this.min = t.min || 0,
  87809. this.max = t.max || 0,
  87810. this.isBoolean = !!t.isBoolean,
  87811. this.matrixMode = t.matrixMode || 0,
  87812. this.isConstant = !!t.isConstant,
  87813. this.groupInInspector = t.groupInInspector || "",
  87814. this.convertToGammaSpace = !!t.convertToGammaSpace,
  87815. this.convertToLinearSpace = !!t.convertToLinearSpace,
  87816. t.valueType)
  87817. if ("number" === t.valueType)
  87818. this._storedValue = t.value;
  87819. else {
  87820. var r = b(t.valueType);
  87821. r && (this._storedValue = r.FromArray(t.value))
  87822. }
  87823. }
  87824. ,
  87825. t
  87826. }(Wp);
  87827. y("BABYLON.InputBlock", tf);
  87828. var nf = function(e) {
  87829. function t(t) {
  87830. var i = e.call(this, t, Dp.VertexAndFragment) || this;
  87831. return i._samplerName = "textureSampler",
  87832. i.convertToGammaSpace = !1,
  87833. i.convertToLinearSpace = !1,
  87834. i._isUnique = !1,
  87835. i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
  87836. i.registerOutput("rgba", Op.Color4, Dp.Neutral),
  87837. i.registerOutput("rgb", Op.Color3, Dp.Neutral),
  87838. i.registerOutput("r", Op.Float, Dp.Neutral),
  87839. i.registerOutput("g", Op.Float, Dp.Neutral),
  87840. i.registerOutput("b", Op.Float, Dp.Neutral),
  87841. i.registerOutput("a", Op.Float, Dp.Neutral),
  87842. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  87843. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  87844. i._inputs[0]._prioritizeVertex = !1,
  87845. i
  87846. }
  87847. return U(t, e),
  87848. t.prototype.getClassName = function() {
  87849. return "CurrentScreenBlock"
  87850. }
  87851. ,
  87852. Object.defineProperty(t.prototype, "uv", {
  87853. get: function() {
  87854. return this._inputs[0]
  87855. },
  87856. enumerable: !1,
  87857. configurable: !0
  87858. }),
  87859. Object.defineProperty(t.prototype, "rgba", {
  87860. get: function() {
  87861. return this._outputs[0]
  87862. },
  87863. enumerable: !1,
  87864. configurable: !0
  87865. }),
  87866. Object.defineProperty(t.prototype, "rgb", {
  87867. get: function() {
  87868. return this._outputs[1]
  87869. },
  87870. enumerable: !1,
  87871. configurable: !0
  87872. }),
  87873. Object.defineProperty(t.prototype, "r", {
  87874. get: function() {
  87875. return this._outputs[2]
  87876. },
  87877. enumerable: !1,
  87878. configurable: !0
  87879. }),
  87880. Object.defineProperty(t.prototype, "g", {
  87881. get: function() {
  87882. return this._outputs[3]
  87883. },
  87884. enumerable: !1,
  87885. configurable: !0
  87886. }),
  87887. Object.defineProperty(t.prototype, "b", {
  87888. get: function() {
  87889. return this._outputs[4]
  87890. },
  87891. enumerable: !1,
  87892. configurable: !0
  87893. }),
  87894. Object.defineProperty(t.prototype, "a", {
  87895. get: function() {
  87896. return this._outputs[5]
  87897. },
  87898. enumerable: !1,
  87899. configurable: !0
  87900. }),
  87901. t.prototype.initialize = function(e) {
  87902. e._excludeVariableName("textureSampler")
  87903. }
  87904. ,
  87905. Object.defineProperty(t.prototype, "target", {
  87906. get: function() {
  87907. return this.uv.isConnected ? this.uv.sourceBlock.isInput ? Dp.VertexAndFragment : Dp.Fragment : Dp.VertexAndFragment
  87908. },
  87909. enumerable: !1,
  87910. configurable: !0
  87911. }),
  87912. t.prototype.prepareDefines = function(e, t, i) {
  87913. i.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
  87914. i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
  87915. }
  87916. ,
  87917. t.prototype.isReady = function() {
  87918. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  87919. }
  87920. ,
  87921. t.prototype._injectVertexCode = function(e) {
  87922. var t = this.uv;
  87923. if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec2")),
  87924. this._mainUVName = "vMain" + t.associatedVariableName,
  87925. e._emitVaryingFromString(this._mainUVName, "vec2"),
  87926. e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
  87927. this._outputs.some((function(e) {
  87928. return e.isConnectedInVertexShader
  87929. }
  87930. ))) {
  87931. this._writeTextureRead(e, !0);
  87932. for (var i = 0, n = this._outputs; i < n.length; i++) {
  87933. var r = n[i];
  87934. r.hasEndpoints && this._writeOutput(e, r, r.name, !0)
  87935. }
  87936. }
  87937. }
  87938. ,
  87939. t.prototype._writeTextureRead = function(e, t) {
  87940. void 0 === t && (t = !1);
  87941. var i = this.uv;
  87942. if (t) {
  87943. if (e.target === Dp.Fragment)
  87944. return;
  87945. e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
  87946. } else
  87947. this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
  87948. }
  87949. ,
  87950. t.prototype._writeOutput = function(e, t, i, n) {
  87951. if (void 0 === n && (n = !1),
  87952. n) {
  87953. if (e.target === Dp.Fragment)
  87954. return;
  87955. e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
  87956. } else
  87957. this.uv.ownerBlock.target !== Dp.Fragment ? (e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
  87958. e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
  87959. e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
  87960. e.compilationString += "#endif\r\n",
  87961. e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
  87962. e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
  87963. e.compilationString += "#endif\r\n") : e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
  87964. }
  87965. ,
  87966. t.prototype._buildBlock = function(t) {
  87967. if (e.prototype._buildBlock.call(this, t),
  87968. this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
  87969. t.sharedData.blockingBlocks.indexOf(this) < 0 && t.sharedData.blockingBlocks.push(this),
  87970. t.sharedData.textureBlocks.indexOf(this) < 0 && t.sharedData.textureBlocks.push(this),
  87971. t.sharedData.blocksWithDefines.indexOf(this) < 0 && t.sharedData.blocksWithDefines.push(this),
  87972. t.target !== Dp.Fragment)
  87973. return t._emit2DSampler(this._samplerName),
  87974. void this._injectVertexCode(t);
  87975. if (this._outputs.some((function(e) {
  87976. return e.isConnectedInFragmentShader
  87977. }
  87978. ))) {
  87979. t._emit2DSampler(this._samplerName),
  87980. this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
  87981. this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
  87982. var i = "//".concat(this.name);
  87983. t._emitFunctionFromInclude("helperFunctions", i),
  87984. this._writeTextureRead(t);
  87985. for (var n = 0, r = this._outputs; n < r.length; n++) {
  87986. var o = r[n];
  87987. o.hasEndpoints && this._writeOutput(t, o, o.name)
  87988. }
  87989. return this
  87990. }
  87991. }
  87992. ,
  87993. t.prototype.serialize = function() {
  87994. var t = e.prototype.serialize.call(this);
  87995. return t.convertToGammaSpace = this.convertToGammaSpace,
  87996. t.convertToLinearSpace = this.convertToLinearSpace,
  87997. this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
  87998. t
  87999. }
  88000. ,
  88001. t.prototype._deserialize = function(t, i, n) {
  88002. e.prototype._deserialize.call(this, t, i, n),
  88003. this.convertToGammaSpace = t.convertToGammaSpace,
  88004. this.convertToLinearSpace = !!t.convertToLinearSpace,
  88005. t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  88006. this.texture = io.Parse(t.texture, i, n))
  88007. }
  88008. ,
  88009. t
  88010. }(Wp);
  88011. y("BABYLON.CurrentScreenBlock", nf);
  88012. var rf = function(e) {
  88013. function t(t) {
  88014. var i = e.call(this, t, Dp.Fragment) || this;
  88015. return i._samplerName = "diffuseSampler",
  88016. i.convertToGammaSpace = !1,
  88017. i.convertToLinearSpace = !1,
  88018. i._isUnique = !1,
  88019. i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
  88020. i.registerOutput("rgba", Op.Color4, Dp.Neutral),
  88021. i.registerOutput("rgb", Op.Color3, Dp.Neutral),
  88022. i.registerOutput("r", Op.Float, Dp.Neutral),
  88023. i.registerOutput("g", Op.Float, Dp.Neutral),
  88024. i.registerOutput("b", Op.Float, Dp.Neutral),
  88025. i.registerOutput("a", Op.Float, Dp.Neutral),
  88026. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  88027. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  88028. i
  88029. }
  88030. return U(t, e),
  88031. t.prototype.getClassName = function() {
  88032. return "ParticleTextureBlock"
  88033. }
  88034. ,
  88035. Object.defineProperty(t.prototype, "uv", {
  88036. get: function() {
  88037. return this._inputs[0]
  88038. },
  88039. enumerable: !1,
  88040. configurable: !0
  88041. }),
  88042. Object.defineProperty(t.prototype, "rgba", {
  88043. get: function() {
  88044. return this._outputs[0]
  88045. },
  88046. enumerable: !1,
  88047. configurable: !0
  88048. }),
  88049. Object.defineProperty(t.prototype, "rgb", {
  88050. get: function() {
  88051. return this._outputs[1]
  88052. },
  88053. enumerable: !1,
  88054. configurable: !0
  88055. }),
  88056. Object.defineProperty(t.prototype, "r", {
  88057. get: function() {
  88058. return this._outputs[2]
  88059. },
  88060. enumerable: !1,
  88061. configurable: !0
  88062. }),
  88063. Object.defineProperty(t.prototype, "g", {
  88064. get: function() {
  88065. return this._outputs[3]
  88066. },
  88067. enumerable: !1,
  88068. configurable: !0
  88069. }),
  88070. Object.defineProperty(t.prototype, "b", {
  88071. get: function() {
  88072. return this._outputs[4]
  88073. },
  88074. enumerable: !1,
  88075. configurable: !0
  88076. }),
  88077. Object.defineProperty(t.prototype, "a", {
  88078. get: function() {
  88079. return this._outputs[5]
  88080. },
  88081. enumerable: !1,
  88082. configurable: !0
  88083. }),
  88084. t.prototype.initialize = function(e) {
  88085. e._excludeVariableName("diffuseSampler")
  88086. }
  88087. ,
  88088. t.prototype.autoConfigure = function(e) {
  88089. if (!this.uv.isConnected) {
  88090. var t = e.getInputBlockByPredicate((function(e) {
  88091. return e.isAttribute && "particle_uv" === e.name
  88092. }
  88093. ));
  88094. t || (t = new tf("uv")).setAsAttribute("particle_uv"),
  88095. t.output.connectTo(this.uv)
  88096. }
  88097. }
  88098. ,
  88099. t.prototype.prepareDefines = function(e, t, i) {
  88100. i.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
  88101. i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
  88102. }
  88103. ,
  88104. t.prototype.isReady = function() {
  88105. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  88106. }
  88107. ,
  88108. t.prototype._writeOutput = function(e, t, i) {
  88109. e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
  88110. e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
  88111. e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
  88112. e.compilationString += "#endif\r\n",
  88113. e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
  88114. e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
  88115. e.compilationString += "#endif\r\n"
  88116. }
  88117. ,
  88118. t.prototype._buildBlock = function(t) {
  88119. if (e.prototype._buildBlock.call(this, t),
  88120. t.target !== Dp.Vertex) {
  88121. this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
  88122. t._emit2DSampler(this._samplerName),
  88123. t.sharedData.blockingBlocks.push(this),
  88124. t.sharedData.textureBlocks.push(this),
  88125. t.sharedData.blocksWithDefines.push(this),
  88126. this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
  88127. this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
  88128. var i = "//".concat(this.name);
  88129. t._emitFunctionFromInclude("helperFunctions", i),
  88130. t.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this.uv.associatedVariableName, ");\r\n");
  88131. for (var n = 0, r = this._outputs; n < r.length; n++) {
  88132. var o = r[n];
  88133. o.hasEndpoints && this._writeOutput(t, o, o.name)
  88134. }
  88135. return this
  88136. }
  88137. }
  88138. ,
  88139. t.prototype.serialize = function() {
  88140. var t = e.prototype.serialize.call(this);
  88141. return t.convertToGammaSpace = this.convertToGammaSpace,
  88142. t.convertToLinearSpace = this.convertToLinearSpace,
  88143. this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
  88144. t
  88145. }
  88146. ,
  88147. t.prototype._deserialize = function(t, i, n) {
  88148. e.prototype._deserialize.call(this, t, i, n),
  88149. this.convertToGammaSpace = t.convertToGammaSpace,
  88150. this.convertToLinearSpace = !!t.convertToLinearSpace,
  88151. t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  88152. this.texture = io.Parse(t.texture, i, n))
  88153. }
  88154. ,
  88155. t
  88156. }(Wp);
  88157. y("BABYLON.ParticleTextureBlock", rf);
  88158. var of = function(e) {
  88159. function t(t) {
  88160. var i = e.call(this, t, Dp.Fragment) || this;
  88161. return i._isUnique = !0,
  88162. i.registerInput("color", Op.Color4, !1, Dp.Fragment),
  88163. i.registerOutput("rampColor", Op.Color4, Dp.Fragment),
  88164. i
  88165. }
  88166. return U(t, e),
  88167. t.prototype.getClassName = function() {
  88168. return "ParticleRampGradientBlock"
  88169. }
  88170. ,
  88171. Object.defineProperty(t.prototype, "color", {
  88172. get: function() {
  88173. return this._inputs[0]
  88174. },
  88175. enumerable: !1,
  88176. configurable: !0
  88177. }),
  88178. Object.defineProperty(t.prototype, "rampColor", {
  88179. get: function() {
  88180. return this._outputs[0]
  88181. },
  88182. enumerable: !1,
  88183. configurable: !0
  88184. }),
  88185. t.prototype.initialize = function(e) {
  88186. e._excludeVariableName("remapRanges"),
  88187. e._excludeVariableName("rampSampler"),
  88188. e._excludeVariableName("baseColor"),
  88189. e._excludeVariableName("alpha"),
  88190. e._excludeVariableName("remappedColorIndex"),
  88191. e._excludeVariableName("rampColor"),
  88192. e._excludeVariableName("finalAlpha")
  88193. }
  88194. ,
  88195. t.prototype._buildBlock = function(t) {
  88196. if (e.prototype._buildBlock.call(this, t),
  88197. t.target !== Dp.Vertex)
  88198. return t._emit2DSampler("rampSampler"),
  88199. t._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"),
  88200. t.compilationString += "\n #ifdef RAMPGRADIENT\n vec4 baseColor = ".concat(this.color.associatedVariableName, ";\n float alpha = ").concat(this.color.associatedVariableName, ".a;\n\n float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\n\n vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));\n baseColor.rgb *= rampColor.rgb;\n\n // Remapped alpha\n float finalAlpha = baseColor.a;\n baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);\n\n ").concat(this._declareOutput(this.rampColor, t), " = baseColor;\n #else\n ").concat(this._declareOutput(this.rampColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "),
  88201. this
  88202. }
  88203. ,
  88204. t
  88205. }(Wp);
  88206. y("BABYLON.ParticleRampGradientBlock", of);
  88207. var af = function(e) {
  88208. function t(t) {
  88209. var i = e.call(this, t, Dp.Fragment) || this;
  88210. return i._isUnique = !0,
  88211. i.registerInput("color", Op.Color4, !1, Dp.Fragment),
  88212. i.registerInput("alphaTexture", Op.Float, !1, Dp.Fragment),
  88213. i.registerInput("alphaColor", Op.Float, !1, Dp.Fragment),
  88214. i.registerOutput("blendColor", Op.Color4, Dp.Fragment),
  88215. i
  88216. }
  88217. return U(t, e),
  88218. t.prototype.getClassName = function() {
  88219. return "ParticleBlendMultiplyBlock"
  88220. }
  88221. ,
  88222. Object.defineProperty(t.prototype, "color", {
  88223. get: function() {
  88224. return this._inputs[0]
  88225. },
  88226. enumerable: !1,
  88227. configurable: !0
  88228. }),
  88229. Object.defineProperty(t.prototype, "alphaTexture", {
  88230. get: function() {
  88231. return this._inputs[1]
  88232. },
  88233. enumerable: !1,
  88234. configurable: !0
  88235. }),
  88236. Object.defineProperty(t.prototype, "alphaColor", {
  88237. get: function() {
  88238. return this._inputs[2]
  88239. },
  88240. enumerable: !1,
  88241. configurable: !0
  88242. }),
  88243. Object.defineProperty(t.prototype, "blendColor", {
  88244. get: function() {
  88245. return this._outputs[0]
  88246. },
  88247. enumerable: !1,
  88248. configurable: !0
  88249. }),
  88250. t.prototype.initialize = function(e) {
  88251. e._excludeVariableName("sourceAlpha")
  88252. }
  88253. ,
  88254. t.prototype._buildBlock = function(t) {
  88255. if (e.prototype._buildBlock.call(this, t),
  88256. t.target !== Dp.Vertex)
  88257. return t.compilationString += "\n #ifdef BLENDMULTIPLYMODE\n ".concat(this._declareOutput(this.blendColor, t), ";\n float sourceAlpha = ").concat(this.alphaColor.associatedVariableName, " * ").concat(this.alphaTexture.associatedVariableName, ";\n ").concat(this.blendColor.associatedVariableName, ".rgb = ").concat(this.color.associatedVariableName, ".rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);\n ").concat(this.blendColor.associatedVariableName, ".a = ").concat(this.color.associatedVariableName, ".a;\n #else\n ").concat(this._declareOutput(this.blendColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "),
  88258. this
  88259. }
  88260. ,
  88261. t
  88262. }(Wp);
  88263. y("BABYLON.ParticleBlendMultiplyBlock", af);
  88264. var sf = function(e) {
  88265. function t(t) {
  88266. var i = e.call(this, t, Dp.Neutral) || this;
  88267. return i.xSwizzle = "x",
  88268. i.ySwizzle = "y",
  88269. i.zSwizzle = "z",
  88270. i.wSwizzle = "w",
  88271. i.registerInput("xyzw ", Op.Vector4, !0),
  88272. i.registerInput("xyz ", Op.Vector3, !0),
  88273. i.registerInput("xy ", Op.Vector2, !0),
  88274. i.registerInput("zw ", Op.Vector2, !0),
  88275. i.registerInput("x", Op.Float, !0),
  88276. i.registerInput("y", Op.Float, !0),
  88277. i.registerInput("z", Op.Float, !0),
  88278. i.registerInput("w", Op.Float, !0),
  88279. i.registerOutput("xyzw", Op.Vector4),
  88280. i.registerOutput("xyz", Op.Vector3),
  88281. i.registerOutput("xy", Op.Vector2),
  88282. i.registerOutput("zw", Op.Vector2),
  88283. i
  88284. }
  88285. return U(t, e),
  88286. t.prototype.getClassName = function() {
  88287. return "VectorMergerBlock"
  88288. }
  88289. ,
  88290. Object.defineProperty(t.prototype, "xyzwIn", {
  88291. get: function() {
  88292. return this._inputs[0]
  88293. },
  88294. enumerable: !1,
  88295. configurable: !0
  88296. }),
  88297. Object.defineProperty(t.prototype, "xyzIn", {
  88298. get: function() {
  88299. return this._inputs[1]
  88300. },
  88301. enumerable: !1,
  88302. configurable: !0
  88303. }),
  88304. Object.defineProperty(t.prototype, "xyIn", {
  88305. get: function() {
  88306. return this._inputs[2]
  88307. },
  88308. enumerable: !1,
  88309. configurable: !0
  88310. }),
  88311. Object.defineProperty(t.prototype, "zwIn", {
  88312. get: function() {
  88313. return this._inputs[3]
  88314. },
  88315. enumerable: !1,
  88316. configurable: !0
  88317. }),
  88318. Object.defineProperty(t.prototype, "x", {
  88319. get: function() {
  88320. return this._inputs[4]
  88321. },
  88322. enumerable: !1,
  88323. configurable: !0
  88324. }),
  88325. Object.defineProperty(t.prototype, "y", {
  88326. get: function() {
  88327. return this._inputs[5]
  88328. },
  88329. enumerable: !1,
  88330. configurable: !0
  88331. }),
  88332. Object.defineProperty(t.prototype, "z", {
  88333. get: function() {
  88334. return this._inputs[6]
  88335. },
  88336. enumerable: !1,
  88337. configurable: !0
  88338. }),
  88339. Object.defineProperty(t.prototype, "w", {
  88340. get: function() {
  88341. return this._inputs[7]
  88342. },
  88343. enumerable: !1,
  88344. configurable: !0
  88345. }),
  88346. Object.defineProperty(t.prototype, "xyzw", {
  88347. get: function() {
  88348. return this._outputs[0]
  88349. },
  88350. enumerable: !1,
  88351. configurable: !0
  88352. }),
  88353. Object.defineProperty(t.prototype, "xyzOut", {
  88354. get: function() {
  88355. return this._outputs[1]
  88356. },
  88357. enumerable: !1,
  88358. configurable: !0
  88359. }),
  88360. Object.defineProperty(t.prototype, "xyOut", {
  88361. get: function() {
  88362. return this._outputs[2]
  88363. },
  88364. enumerable: !1,
  88365. configurable: !0
  88366. }),
  88367. Object.defineProperty(t.prototype, "zwOut", {
  88368. get: function() {
  88369. return this._outputs[3]
  88370. },
  88371. enumerable: !1,
  88372. configurable: !0
  88373. }),
  88374. Object.defineProperty(t.prototype, "xy", {
  88375. get: function() {
  88376. return this.xyOut
  88377. },
  88378. enumerable: !1,
  88379. configurable: !0
  88380. }),
  88381. Object.defineProperty(t.prototype, "xyz", {
  88382. get: function() {
  88383. return this.xyzOut
  88384. },
  88385. enumerable: !1,
  88386. configurable: !0
  88387. }),
  88388. t.prototype._inputRename = function(e) {
  88389. return "xyzw " === e ? "xyzwIn" : "xyz " === e ? "xyzIn" : "xy " === e ? "xyIn" : "zw " === e ? "zwIn" : e
  88390. }
  88391. ,
  88392. t.prototype._buildSwizzle = function(e) {
  88393. return "." + (this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle).substr(0, e)
  88394. }
  88395. ,
  88396. t.prototype._buildBlock = function(t) {
  88397. e.prototype._buildBlock.call(this, t);
  88398. var i = this.x
  88399. , n = this.y
  88400. , r = this.z
  88401. , o = this.w
  88402. , a = this.xyIn
  88403. , s = this.zwIn
  88404. , l = this.xyzIn
  88405. , c = this.xyzwIn
  88406. , u = this._outputs[0]
  88407. , h = this._outputs[1]
  88408. , d = this._outputs[2]
  88409. , p = this._outputs[3];
  88410. return c.isConnected ? (u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(4), ";\r\n")),
  88411. h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
  88412. d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n"))) : l.isConnected ? (u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(l.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
  88413. h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
  88414. d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n"))) : a.isConnected ? (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
  88415. h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
  88416. d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n")),
  88417. p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n"))) : (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
  88418. h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
  88419. d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = vec2(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n")),
  88420. p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n"))),
  88421. this
  88422. }
  88423. ,
  88424. t.prototype.serialize = function() {
  88425. var t = e.prototype.serialize.call(this);
  88426. return t.xSwizzle = this.xSwizzle,
  88427. t.ySwizzle = this.ySwizzle,
  88428. t.zSwizzle = this.zSwizzle,
  88429. t.wSwizzle = this.wSwizzle,
  88430. t
  88431. }
  88432. ,
  88433. t.prototype._deserialize = function(t, i, n) {
  88434. var r, o, a, s;
  88435. e.prototype._deserialize.call(this, t, i, n),
  88436. this.xSwizzle = null !== (r = t.xSwizzle) && void 0 !== r ? r : "x",
  88437. this.ySwizzle = null !== (o = t.ySwizzle) && void 0 !== o ? o : "y",
  88438. this.zSwizzle = null !== (a = t.zSwizzle) && void 0 !== a ? a : "z",
  88439. this.wSwizzle = null !== (s = t.wSwizzle) && void 0 !== s ? s : "w"
  88440. }
  88441. ,
  88442. t.prototype._dumpPropertiesCode = function() {
  88443. var t = e.prototype._dumpPropertiesCode.call(this);
  88444. return t += "".concat(this._codeVariableName, '.xSwizzle = "').concat(this.xSwizzle, '";\r\n'),
  88445. t += "".concat(this._codeVariableName, '.ySwizzle = "').concat(this.ySwizzle, '";\r\n'),
  88446. (t += "".concat(this._codeVariableName, '.zSwizzle = "').concat(this.zSwizzle, '";\r\n')) + "".concat(this._codeVariableName, '.wSwizzle = "').concat(this.wSwizzle, '";\r\n')
  88447. }
  88448. ,
  88449. t
  88450. }(Wp);
  88451. y("BABYLON.VectorMergerBlock", sf);
  88452. var lf = function(e) {
  88453. function t(t) {
  88454. var i = e.call(this, t, Dp.Neutral) || this;
  88455. return i.sourceRange = new A(-1,1),
  88456. i.targetRange = new A(0,1),
  88457. i.registerInput("input", Op.AutoDetect),
  88458. i.registerInput("sourceMin", Op.Float, !0),
  88459. i.registerInput("sourceMax", Op.Float, !0),
  88460. i.registerInput("targetMin", Op.Float, !0),
  88461. i.registerInput("targetMax", Op.Float, !0),
  88462. i.registerOutput("output", Op.BasedOnInput),
  88463. i._outputs[0]._typeConnectionSource = i._inputs[0],
  88464. i
  88465. }
  88466. return U(t, e),
  88467. t.prototype.getClassName = function() {
  88468. return "RemapBlock"
  88469. }
  88470. ,
  88471. Object.defineProperty(t.prototype, "input", {
  88472. get: function() {
  88473. return this._inputs[0]
  88474. },
  88475. enumerable: !1,
  88476. configurable: !0
  88477. }),
  88478. Object.defineProperty(t.prototype, "sourceMin", {
  88479. get: function() {
  88480. return this._inputs[1]
  88481. },
  88482. enumerable: !1,
  88483. configurable: !0
  88484. }),
  88485. Object.defineProperty(t.prototype, "sourceMax", {
  88486. get: function() {
  88487. return this._inputs[2]
  88488. },
  88489. enumerable: !1,
  88490. configurable: !0
  88491. }),
  88492. Object.defineProperty(t.prototype, "targetMin", {
  88493. get: function() {
  88494. return this._inputs[3]
  88495. },
  88496. enumerable: !1,
  88497. configurable: !0
  88498. }),
  88499. Object.defineProperty(t.prototype, "targetMax", {
  88500. get: function() {
  88501. return this._inputs[4]
  88502. },
  88503. enumerable: !1,
  88504. configurable: !0
  88505. }),
  88506. Object.defineProperty(t.prototype, "output", {
  88507. get: function() {
  88508. return this._outputs[0]
  88509. },
  88510. enumerable: !1,
  88511. configurable: !0
  88512. }),
  88513. t.prototype._buildBlock = function(t) {
  88514. e.prototype._buildBlock.call(this, t);
  88515. var i = this._outputs[0]
  88516. , n = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
  88517. , r = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y)
  88518. , o = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x)
  88519. , a = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
  88520. return t.compilationString += this._declareOutput(i, t) + " = ".concat(o, " + (").concat(this._inputs[0].associatedVariableName, " - ").concat(n, ") * (").concat(a, " - ").concat(o, ") / (").concat(r, " - ").concat(n, ");\r\n"),
  88521. this
  88522. }
  88523. ,
  88524. t.prototype._dumpPropertiesCode = function() {
  88525. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".sourceRange = new BABYLON.Vector2(").concat(this.sourceRange.x, ", ").concat(this.sourceRange.y, ");\r\n") + "".concat(this._codeVariableName, ".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x, ", ").concat(this.targetRange.y, ");\r\n")
  88526. }
  88527. ,
  88528. t.prototype.serialize = function() {
  88529. var t = e.prototype.serialize.call(this);
  88530. return t.sourceRange = this.sourceRange.asArray(),
  88531. t.targetRange = this.targetRange.asArray(),
  88532. t
  88533. }
  88534. ,
  88535. t.prototype._deserialize = function(t, i, n) {
  88536. e.prototype._deserialize.call(this, t, i, n),
  88537. this.sourceRange = A.FromArray(t.sourceRange),
  88538. this.targetRange = A.FromArray(t.targetRange)
  88539. }
  88540. ,
  88541. k([Yp("From", Xp.Vector2)], t.prototype, "sourceRange", void 0),
  88542. k([Yp("To", Xp.Vector2)], t.prototype, "targetRange", void 0),
  88543. t
  88544. }(Wp);
  88545. y("BABYLON.RemapBlock", lf);
  88546. var cf, uf = function(e) {
  88547. function t(t) {
  88548. var i = e.call(this, t, Dp.Neutral) || this;
  88549. return i.registerInput("left", Op.AutoDetect),
  88550. i.registerInput("right", Op.AutoDetect),
  88551. i.registerOutput("output", Op.BasedOnInput),
  88552. i._outputs[0]._typeConnectionSource = i._inputs[0],
  88553. i._linkConnectionTypes(0, 1),
  88554. i
  88555. }
  88556. return U(t, e),
  88557. t.prototype.getClassName = function() {
  88558. return "MultiplyBlock"
  88559. }
  88560. ,
  88561. Object.defineProperty(t.prototype, "left", {
  88562. get: function() {
  88563. return this._inputs[0]
  88564. },
  88565. enumerable: !1,
  88566. configurable: !0
  88567. }),
  88568. Object.defineProperty(t.prototype, "right", {
  88569. get: function() {
  88570. return this._inputs[1]
  88571. },
  88572. enumerable: !1,
  88573. configurable: !0
  88574. }),
  88575. Object.defineProperty(t.prototype, "output", {
  88576. get: function() {
  88577. return this._outputs[0]
  88578. },
  88579. enumerable: !1,
  88580. configurable: !0
  88581. }),
  88582. t.prototype._buildBlock = function(t) {
  88583. e.prototype._buildBlock.call(this, t);
  88584. var i = this._outputs[0];
  88585. return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " * ").concat(this.right.associatedVariableName, ";\r\n"),
  88586. this
  88587. }
  88588. ,
  88589. t
  88590. }(Wp);
  88591. y("BABYLON.MultiplyBlock", uf),
  88592. function(e) {
  88593. e[e.Material = 0] = "Material",
  88594. e[e.PostProcess = 1] = "PostProcess",
  88595. e[e.Particle = 2] = "Particle",
  88596. e[e.ProceduralTexture = 3] = "ProceduralTexture"
  88597. }(cf || (cf = {}));
  88598. var hf = function() {
  88599. function e() {
  88600. this.direction1 = new x(0,1,0),
  88601. this.direction2 = new x(0,1,0),
  88602. this.minEmitBox = new x(-.5,-.5,-.5),
  88603. this.maxEmitBox = new x(.5,.5,.5)
  88604. }
  88605. return e.prototype.startDirectionFunction = function(e, t, i, n) {
  88606. var r = d.RandomRange(this.direction1.x, this.direction2.x)
  88607. , o = d.RandomRange(this.direction1.y, this.direction2.y)
  88608. , a = d.RandomRange(this.direction1.z, this.direction2.z);
  88609. if (n)
  88610. return t.x = r,
  88611. t.y = o,
  88612. void (t.z = a);
  88613. x.TransformNormalFromFloatsToRef(r, o, a, e, t)
  88614. }
  88615. ,
  88616. e.prototype.startPositionFunction = function(e, t, i, n) {
  88617. var r = d.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
  88618. , o = d.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
  88619. , a = d.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  88620. if (n)
  88621. return t.x = r,
  88622. t.y = o,
  88623. void (t.z = a);
  88624. x.TransformCoordinatesFromFloatsToRef(r, o, a, e, t)
  88625. }
  88626. ,
  88627. e.prototype.clone = function() {
  88628. var t = new e;
  88629. return fe.DeepCopy(this, t),
  88630. t
  88631. }
  88632. ,
  88633. e.prototype.applyToShader = function(e) {
  88634. e.setVector3("direction1", this.direction1),
  88635. e.setVector3("direction2", this.direction2),
  88636. e.setVector3("minEmitBox", this.minEmitBox),
  88637. e.setVector3("maxEmitBox", this.maxEmitBox)
  88638. }
  88639. ,
  88640. e.prototype.buildUniformLayout = function(e) {
  88641. e.addUniform("direction1", 3),
  88642. e.addUniform("direction2", 3),
  88643. e.addUniform("minEmitBox", 3),
  88644. e.addUniform("maxEmitBox", 3)
  88645. }
  88646. ,
  88647. e.prototype.getEffectDefines = function() {
  88648. return "#define BOXEMITTER"
  88649. }
  88650. ,
  88651. e.prototype.getClassName = function() {
  88652. return "BoxParticleEmitter"
  88653. }
  88654. ,
  88655. e.prototype.serialize = function() {
  88656. var e = {};
  88657. return e.type = this.getClassName(),
  88658. e.direction1 = this.direction1.asArray(),
  88659. e.direction2 = this.direction2.asArray(),
  88660. e.minEmitBox = this.minEmitBox.asArray(),
  88661. e.maxEmitBox = this.maxEmitBox.asArray(),
  88662. e
  88663. }
  88664. ,
  88665. e.prototype.parse = function(e) {
  88666. x.FromArrayToRef(e.direction1, 0, this.direction1),
  88667. x.FromArrayToRef(e.direction2, 0, this.direction2),
  88668. x.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
  88669. x.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
  88670. }
  88671. ,
  88672. e
  88673. }()
  88674. , df = function() {
  88675. function e(e, t, i) {
  88676. void 0 === e && (e = 1),
  88677. void 0 === t && (t = Math.PI),
  88678. void 0 === i && (i = 0),
  88679. this.directionRandomizer = i,
  88680. this.radiusRange = 1,
  88681. this.heightRange = 1,
  88682. this.emitFromSpawnPointOnly = !1,
  88683. this.angle = t,
  88684. this.radius = e
  88685. }
  88686. return Object.defineProperty(e.prototype, "radius", {
  88687. get: function() {
  88688. return this._radius
  88689. },
  88690. set: function(e) {
  88691. this._radius = e,
  88692. this._buildHeight()
  88693. },
  88694. enumerable: !1,
  88695. configurable: !0
  88696. }),
  88697. Object.defineProperty(e.prototype, "angle", {
  88698. get: function() {
  88699. return this._angle
  88700. },
  88701. set: function(e) {
  88702. this._angle = e,
  88703. this._buildHeight()
  88704. },
  88705. enumerable: !1,
  88706. configurable: !0
  88707. }),
  88708. e.prototype._buildHeight = function() {
  88709. 0 !== this._angle ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1
  88710. }
  88711. ,
  88712. e.prototype.startDirectionFunction = function(e, t, i, n) {
  88713. n ? I.Vector3[0].copyFrom(i._localPosition).normalize() : i.position.subtractToRef(e.getTranslation(), I.Vector3[0]).normalize();
  88714. var r = d.RandomRange(0, this.directionRandomizer)
  88715. , o = d.RandomRange(0, this.directionRandomizer)
  88716. , a = d.RandomRange(0, this.directionRandomizer);
  88717. t.x = I.Vector3[0].x + r,
  88718. t.y = I.Vector3[0].y + o,
  88719. t.z = I.Vector3[0].z + a,
  88720. t.normalize()
  88721. }
  88722. ,
  88723. e.prototype.startPositionFunction = function(e, t, i, n) {
  88724. var r, o = d.RandomRange(0, 2 * Math.PI);
  88725. r = this.emitFromSpawnPointOnly ? 1e-4 : 1 - (r = d.RandomRange(0, this.heightRange)) * r;
  88726. var a = this._radius - d.RandomRange(0, this._radius * this.radiusRange)
  88727. , s = (a *= r) * Math.sin(o)
  88728. , l = a * Math.cos(o)
  88729. , c = r * this._height;
  88730. if (n)
  88731. return t.x = s,
  88732. t.y = c,
  88733. void (t.z = l);
  88734. x.TransformCoordinatesFromFloatsToRef(s, c, l, e, t)
  88735. }
  88736. ,
  88737. e.prototype.clone = function() {
  88738. var t = new e(this._radius,this._angle,this.directionRandomizer);
  88739. return fe.DeepCopy(this, t),
  88740. t
  88741. }
  88742. ,
  88743. e.prototype.applyToShader = function(e) {
  88744. e.setFloat2("radius", this._radius, this.radiusRange),
  88745. e.setFloat("coneAngle", this._angle),
  88746. e.setFloat2("height", this._height, this.heightRange),
  88747. e.setFloat("directionRandomizer", this.directionRandomizer)
  88748. }
  88749. ,
  88750. e.prototype.buildUniformLayout = function(e) {
  88751. e.addUniform("radius", 2),
  88752. e.addUniform("coneAngle", 1),
  88753. e.addUniform("height", 2),
  88754. e.addUniform("directionRandomizer", 1)
  88755. }
  88756. ,
  88757. e.prototype.getEffectDefines = function() {
  88758. var e = "#define CONEEMITTER";
  88759. return this.emitFromSpawnPointOnly && (e += "\n#define CONEEMITTERSPAWNPOINT"),
  88760. e
  88761. }
  88762. ,
  88763. e.prototype.getClassName = function() {
  88764. return "ConeParticleEmitter"
  88765. }
  88766. ,
  88767. e.prototype.serialize = function() {
  88768. var e = {};
  88769. return e.type = this.getClassName(),
  88770. e.radius = this._radius,
  88771. e.angle = this._angle,
  88772. e.directionRandomizer = this.directionRandomizer,
  88773. e.radiusRange = this.radiusRange,
  88774. e.heightRange = this.heightRange,
  88775. e.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly,
  88776. e
  88777. }
  88778. ,
  88779. e.prototype.parse = function(e) {
  88780. this.radius = e.radius,
  88781. this.angle = e.angle,
  88782. this.directionRandomizer = e.directionRandomizer,
  88783. this.radiusRange = void 0 !== e.radiusRange ? e.radiusRange : 1,
  88784. this.heightRange = void 0 !== e.radiusRange ? e.heightRange : 1,
  88785. this.emitFromSpawnPointOnly = void 0 !== e.emitFromSpawnPointOnly && e.emitFromSpawnPointOnly
  88786. }
  88787. ,
  88788. e
  88789. }()
  88790. , pf = function() {
  88791. function e(e, t, i, n) {
  88792. void 0 === e && (e = 1),
  88793. void 0 === t && (t = 1),
  88794. void 0 === i && (i = 1),
  88795. void 0 === n && (n = 0),
  88796. this.radius = e,
  88797. this.height = t,
  88798. this.radiusRange = i,
  88799. this.directionRandomizer = n,
  88800. this._tempVector = x.Zero()
  88801. }
  88802. return e.prototype.startDirectionFunction = function(e, t, i, n, r) {
  88803. i.position.subtractToRef(e.getTranslation(), this._tempVector),
  88804. this._tempVector.normalize(),
  88805. x.TransformNormalToRef(this._tempVector, r, this._tempVector);
  88806. var o = d.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
  88807. , a = Math.atan2(this._tempVector.x, this._tempVector.z);
  88808. a += d.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer,
  88809. this._tempVector.y = o,
  88810. this._tempVector.x = Math.sin(a),
  88811. this._tempVector.z = Math.cos(a),
  88812. this._tempVector.normalize(),
  88813. n ? t.copyFrom(this._tempVector) : x.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, t)
  88814. }
  88815. ,
  88816. e.prototype.startPositionFunction = function(e, t, i, n) {
  88817. var r = d.RandomRange(-this.height / 2, this.height / 2)
  88818. , o = d.RandomRange(0, 2 * Math.PI)
  88819. , a = d.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
  88820. , s = Math.sqrt(a) * this.radius
  88821. , l = s * Math.cos(o)
  88822. , c = s * Math.sin(o);
  88823. n ? t.copyFromFloats(l, r, c) : x.TransformCoordinatesFromFloatsToRef(l, r, c, e, t)
  88824. }
  88825. ,
  88826. e.prototype.clone = function() {
  88827. var t = new e(this.radius,this.directionRandomizer);
  88828. return fe.DeepCopy(this, t),
  88829. t
  88830. }
  88831. ,
  88832. e.prototype.applyToShader = function(e) {
  88833. e.setFloat("radius", this.radius),
  88834. e.setFloat("height", this.height),
  88835. e.setFloat("radiusRange", this.radiusRange),
  88836. e.setFloat("directionRandomizer", this.directionRandomizer)
  88837. }
  88838. ,
  88839. e.prototype.buildUniformLayout = function(e) {
  88840. e.addUniform("radius", 1),
  88841. e.addUniform("height", 1),
  88842. e.addUniform("radiusRange", 1),
  88843. e.addUniform("directionRandomizer", 1)
  88844. }
  88845. ,
  88846. e.prototype.getEffectDefines = function() {
  88847. return "#define CYLINDEREMITTER"
  88848. }
  88849. ,
  88850. e.prototype.getClassName = function() {
  88851. return "CylinderParticleEmitter"
  88852. }
  88853. ,
  88854. e.prototype.serialize = function() {
  88855. var e = {};
  88856. return e.type = this.getClassName(),
  88857. e.radius = this.radius,
  88858. e.height = this.height,
  88859. e.radiusRange = this.radiusRange,
  88860. e.directionRandomizer = this.directionRandomizer,
  88861. e
  88862. }
  88863. ,
  88864. e.prototype.parse = function(e) {
  88865. this.radius = e.radius,
  88866. this.height = e.height,
  88867. this.radiusRange = e.radiusRange,
  88868. this.directionRandomizer = e.directionRandomizer
  88869. }
  88870. ,
  88871. e
  88872. }()
  88873. , ff = function(e) {
  88874. function t(t, i, n, r, o) {
  88875. void 0 === t && (t = 1),
  88876. void 0 === i && (i = 1),
  88877. void 0 === n && (n = 1),
  88878. void 0 === r && (r = new x(0,1,0)),
  88879. void 0 === o && (o = new x(0,1,0));
  88880. var a = e.call(this, t, i, n) || this;
  88881. return a.direction1 = r,
  88882. a.direction2 = o,
  88883. a
  88884. }
  88885. return U(t, e),
  88886. t.prototype.startDirectionFunction = function(e, t) {
  88887. var i = d.RandomRange(this.direction1.x, this.direction2.x)
  88888. , n = d.RandomRange(this.direction1.y, this.direction2.y)
  88889. , r = d.RandomRange(this.direction1.z, this.direction2.z);
  88890. x.TransformNormalFromFloatsToRef(i, n, r, e, t)
  88891. }
  88892. ,
  88893. t.prototype.clone = function() {
  88894. var e = new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
  88895. return fe.DeepCopy(this, e),
  88896. e
  88897. }
  88898. ,
  88899. t.prototype.applyToShader = function(e) {
  88900. e.setFloat("radius", this.radius),
  88901. e.setFloat("height", this.height),
  88902. e.setFloat("radiusRange", this.radiusRange),
  88903. e.setVector3("direction1", this.direction1),
  88904. e.setVector3("direction2", this.direction2)
  88905. }
  88906. ,
  88907. t.prototype.buildUniformLayout = function(e) {
  88908. e.addUniform("radius", 1),
  88909. e.addUniform("height", 1),
  88910. e.addUniform("radiusRange", 1),
  88911. e.addUniform("direction1", 3),
  88912. e.addUniform("direction2", 3)
  88913. }
  88914. ,
  88915. t.prototype.getEffectDefines = function() {
  88916. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"
  88917. }
  88918. ,
  88919. t.prototype.getClassName = function() {
  88920. return "CylinderDirectedParticleEmitter"
  88921. }
  88922. ,
  88923. t.prototype.serialize = function() {
  88924. var t = e.prototype.serialize.call(this);
  88925. return t.direction1 = this.direction1.asArray(),
  88926. t.direction2 = this.direction2.asArray(),
  88927. t
  88928. }
  88929. ,
  88930. t.prototype.parse = function(t) {
  88931. e.prototype.parse.call(this, t),
  88932. this.direction1.copyFrom(t.direction1),
  88933. this.direction2.copyFrom(t.direction2)
  88934. }
  88935. ,
  88936. t
  88937. }(pf)
  88938. , _f = function() {
  88939. function e(e, t, i) {
  88940. void 0 === e && (e = 1),
  88941. void 0 === t && (t = 1),
  88942. void 0 === i && (i = 0),
  88943. this.radius = e,
  88944. this.radiusRange = t,
  88945. this.directionRandomizer = i
  88946. }
  88947. return e.prototype.startDirectionFunction = function(e, t, i, n) {
  88948. var r = i.position.subtract(e.getTranslation()).normalize()
  88949. , o = d.RandomRange(0, this.directionRandomizer)
  88950. , a = d.RandomRange(0, this.directionRandomizer)
  88951. , s = d.RandomRange(0, this.directionRandomizer);
  88952. r.x += o,
  88953. r.y += a,
  88954. r.z += s,
  88955. r.normalize(),
  88956. n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
  88957. }
  88958. ,
  88959. e.prototype.startPositionFunction = function(e, t, i, n) {
  88960. var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
  88961. , o = d.RandomRange(0, 1)
  88962. , a = d.RandomRange(0, 2 * Math.PI)
  88963. , s = Math.acos(2 * o - 1)
  88964. , l = r * Math.cos(a) * Math.sin(s)
  88965. , c = r * Math.cos(s)
  88966. , u = r * Math.sin(a) * Math.sin(s);
  88967. n ? t.copyFromFloats(l, Math.abs(c), u) : x.TransformCoordinatesFromFloatsToRef(l, Math.abs(c), u, e, t)
  88968. }
  88969. ,
  88970. e.prototype.clone = function() {
  88971. var t = new e(this.radius,this.directionRandomizer);
  88972. return fe.DeepCopy(this, t),
  88973. t
  88974. }
  88975. ,
  88976. e.prototype.applyToShader = function(e) {
  88977. e.setFloat("radius", this.radius),
  88978. e.setFloat("radiusRange", this.radiusRange),
  88979. e.setFloat("directionRandomizer", this.directionRandomizer)
  88980. }
  88981. ,
  88982. e.prototype.buildUniformLayout = function(e) {
  88983. e.addUniform("radius", 1),
  88984. e.addUniform("radiusRange", 1),
  88985. e.addUniform("directionRandomizer", 1)
  88986. }
  88987. ,
  88988. e.prototype.getEffectDefines = function() {
  88989. return "#define HEMISPHERICEMITTER"
  88990. }
  88991. ,
  88992. e.prototype.getClassName = function() {
  88993. return "HemisphericParticleEmitter"
  88994. }
  88995. ,
  88996. e.prototype.serialize = function() {
  88997. var e = {};
  88998. return e.type = this.getClassName(),
  88999. e.radius = this.radius,
  89000. e.radiusRange = this.radiusRange,
  89001. e.directionRandomizer = this.directionRandomizer,
  89002. e
  89003. }
  89004. ,
  89005. e.prototype.parse = function(e) {
  89006. this.radius = e.radius,
  89007. this.radiusRange = e.radiusRange,
  89008. this.directionRandomizer = e.directionRandomizer
  89009. }
  89010. ,
  89011. e
  89012. }()
  89013. , mf = function() {
  89014. function e() {
  89015. this.direction1 = new x(0,1,0),
  89016. this.direction2 = new x(0,1,0)
  89017. }
  89018. return e.prototype.startDirectionFunction = function(e, t, i, n) {
  89019. var r = d.RandomRange(this.direction1.x, this.direction2.x)
  89020. , o = d.RandomRange(this.direction1.y, this.direction2.y)
  89021. , a = d.RandomRange(this.direction1.z, this.direction2.z);
  89022. n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
  89023. }
  89024. ,
  89025. e.prototype.startPositionFunction = function(e, t, i, n) {
  89026. n ? t.copyFromFloats(0, 0, 0) : x.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, t)
  89027. }
  89028. ,
  89029. e.prototype.clone = function() {
  89030. var t = new e;
  89031. return fe.DeepCopy(this, t),
  89032. t
  89033. }
  89034. ,
  89035. e.prototype.applyToShader = function(e) {
  89036. e.setVector3("direction1", this.direction1),
  89037. e.setVector3("direction2", this.direction2)
  89038. }
  89039. ,
  89040. e.prototype.buildUniformLayout = function(e) {
  89041. e.addUniform("direction1", 3),
  89042. e.addUniform("direction2", 3)
  89043. }
  89044. ,
  89045. e.prototype.getEffectDefines = function() {
  89046. return "#define POINTEMITTER"
  89047. }
  89048. ,
  89049. e.prototype.getClassName = function() {
  89050. return "PointParticleEmitter"
  89051. }
  89052. ,
  89053. e.prototype.serialize = function() {
  89054. var e = {};
  89055. return e.type = this.getClassName(),
  89056. e.direction1 = this.direction1.asArray(),
  89057. e.direction2 = this.direction2.asArray(),
  89058. e
  89059. }
  89060. ,
  89061. e.prototype.parse = function(e) {
  89062. x.FromArrayToRef(e.direction1, 0, this.direction1),
  89063. x.FromArrayToRef(e.direction2, 0, this.direction2)
  89064. }
  89065. ,
  89066. e
  89067. }()
  89068. , gf = function() {
  89069. function e(e, t, i) {
  89070. void 0 === e && (e = 1),
  89071. void 0 === t && (t = 1),
  89072. void 0 === i && (i = 0),
  89073. this.radius = e,
  89074. this.radiusRange = t,
  89075. this.directionRandomizer = i
  89076. }
  89077. return e.prototype.startDirectionFunction = function(e, t, i, n) {
  89078. var r = i.position.subtract(e.getTranslation()).normalize()
  89079. , o = d.RandomRange(0, this.directionRandomizer)
  89080. , a = d.RandomRange(0, this.directionRandomizer)
  89081. , s = d.RandomRange(0, this.directionRandomizer);
  89082. r.x += o,
  89083. r.y += a,
  89084. r.z += s,
  89085. r.normalize(),
  89086. n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
  89087. }
  89088. ,
  89089. e.prototype.startPositionFunction = function(e, t, i, n) {
  89090. var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
  89091. , o = d.RandomRange(0, 1)
  89092. , a = d.RandomRange(0, 2 * Math.PI)
  89093. , s = Math.acos(2 * o - 1)
  89094. , l = r * Math.cos(a) * Math.sin(s)
  89095. , c = r * Math.cos(s)
  89096. , u = r * Math.sin(a) * Math.sin(s);
  89097. n ? t.copyFromFloats(l, c, u) : x.TransformCoordinatesFromFloatsToRef(l, c, u, e, t)
  89098. }
  89099. ,
  89100. e.prototype.clone = function() {
  89101. var t = new e(this.radius,this.directionRandomizer);
  89102. return fe.DeepCopy(this, t),
  89103. t
  89104. }
  89105. ,
  89106. e.prototype.applyToShader = function(e) {
  89107. e.setFloat("radius", this.radius),
  89108. e.setFloat("radiusRange", this.radiusRange),
  89109. e.setFloat("directionRandomizer", this.directionRandomizer)
  89110. }
  89111. ,
  89112. e.prototype.buildUniformLayout = function(e) {
  89113. e.addUniform("radius", 1),
  89114. e.addUniform("radiusRange", 1),
  89115. e.addUniform("directionRandomizer", 1)
  89116. }
  89117. ,
  89118. e.prototype.getEffectDefines = function() {
  89119. return "#define SPHEREEMITTER"
  89120. }
  89121. ,
  89122. e.prototype.getClassName = function() {
  89123. return "SphereParticleEmitter"
  89124. }
  89125. ,
  89126. e.prototype.serialize = function() {
  89127. var e = {};
  89128. return e.type = this.getClassName(),
  89129. e.radius = this.radius,
  89130. e.radiusRange = this.radiusRange,
  89131. e.directionRandomizer = this.directionRandomizer,
  89132. e
  89133. }
  89134. ,
  89135. e.prototype.parse = function(e) {
  89136. this.radius = e.radius,
  89137. this.radiusRange = e.radiusRange,
  89138. this.directionRandomizer = e.directionRandomizer
  89139. }
  89140. ,
  89141. e
  89142. }()
  89143. , vf = function(e) {
  89144. function t(t, i, n) {
  89145. void 0 === t && (t = 1),
  89146. void 0 === i && (i = new x(0,1,0)),
  89147. void 0 === n && (n = new x(0,1,0));
  89148. var r = e.call(this, t) || this;
  89149. return r.direction1 = i,
  89150. r.direction2 = n,
  89151. r
  89152. }
  89153. return U(t, e),
  89154. t.prototype.startDirectionFunction = function(e, t) {
  89155. var i = d.RandomRange(this.direction1.x, this.direction2.x)
  89156. , n = d.RandomRange(this.direction1.y, this.direction2.y)
  89157. , r = d.RandomRange(this.direction1.z, this.direction2.z);
  89158. x.TransformNormalFromFloatsToRef(i, n, r, e, t)
  89159. }
  89160. ,
  89161. t.prototype.clone = function() {
  89162. var e = new t(this.radius,this.direction1,this.direction2);
  89163. return fe.DeepCopy(this, e),
  89164. e
  89165. }
  89166. ,
  89167. t.prototype.applyToShader = function(e) {
  89168. e.setFloat("radius", this.radius),
  89169. e.setFloat("radiusRange", this.radiusRange),
  89170. e.setVector3("direction1", this.direction1),
  89171. e.setVector3("direction2", this.direction2)
  89172. }
  89173. ,
  89174. t.prototype.buildUniformLayout = function(e) {
  89175. e.addUniform("radius", 1),
  89176. e.addUniform("radiusRange", 1),
  89177. e.addUniform("direction1", 3),
  89178. e.addUniform("direction2", 3)
  89179. }
  89180. ,
  89181. t.prototype.getEffectDefines = function() {
  89182. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"
  89183. }
  89184. ,
  89185. t.prototype.getClassName = function() {
  89186. return "SphereDirectedParticleEmitter"
  89187. }
  89188. ,
  89189. t.prototype.serialize = function() {
  89190. var t = e.prototype.serialize.call(this);
  89191. return t.direction1 = this.direction1.asArray(),
  89192. t.direction2 = this.direction2.asArray(),
  89193. t
  89194. }
  89195. ,
  89196. t.prototype.parse = function(t) {
  89197. e.prototype.parse.call(this, t),
  89198. this.direction1.copyFrom(t.direction1),
  89199. this.direction2.copyFrom(t.direction2)
  89200. }
  89201. ,
  89202. t
  89203. }(gf)
  89204. , yf = function() {
  89205. function e() {
  89206. this.particlePositionGenerator = function() {}
  89207. ,
  89208. this.particleDestinationGenerator = function() {}
  89209. }
  89210. return e.prototype.startDirectionFunction = function(e, t, i, n) {
  89211. var r = I.Vector3[0];
  89212. if (this.particleDestinationGenerator) {
  89213. this.particleDestinationGenerator(-1, i, r);
  89214. var o = I.Vector3[1];
  89215. r.subtractToRef(i.position, o),
  89216. o.scaleToRef(1 / i.lifeTime, r)
  89217. } else
  89218. r.set(0, 0, 0);
  89219. n ? t.copyFrom(r) : x.TransformNormalToRef(r, e, t)
  89220. }
  89221. ,
  89222. e.prototype.startPositionFunction = function(e, t, i, n) {
  89223. var r = I.Vector3[0];
  89224. this.particlePositionGenerator ? this.particlePositionGenerator(-1, i, r) : r.set(0, 0, 0),
  89225. n ? t.copyFrom(r) : x.TransformCoordinatesToRef(r, e, t)
  89226. }
  89227. ,
  89228. e.prototype.clone = function() {
  89229. var t = new e;
  89230. return fe.DeepCopy(this, t),
  89231. t
  89232. }
  89233. ,
  89234. e.prototype.applyToShader = function(e) {}
  89235. ,
  89236. e.prototype.buildUniformLayout = function(e) {}
  89237. ,
  89238. e.prototype.getEffectDefines = function() {
  89239. return "#define CUSTOMEMITTER"
  89240. }
  89241. ,
  89242. e.prototype.getClassName = function() {
  89243. return "CustomParticleEmitter"
  89244. }
  89245. ,
  89246. e.prototype.serialize = function() {
  89247. var e = {};
  89248. return e.type = this.getClassName(),
  89249. e
  89250. }
  89251. ,
  89252. e.prototype.parse = function(e) {}
  89253. ,
  89254. e
  89255. }()
  89256. , bf = function() {
  89257. function e(e) {
  89258. void 0 === e && (e = null),
  89259. this._indices = null,
  89260. this._positions = null,
  89261. this._normals = null,
  89262. this._storedNormal = x.Zero(),
  89263. this._mesh = null,
  89264. this.direction1 = new x(0,1,0),
  89265. this.direction2 = new x(0,1,0),
  89266. this.useMeshNormalsForDirection = !0,
  89267. this.mesh = e
  89268. }
  89269. return Object.defineProperty(e.prototype, "mesh", {
  89270. get: function() {
  89271. return this._mesh
  89272. },
  89273. set: function(e) {
  89274. this._mesh !== e && (this._mesh = e,
  89275. e ? (this._indices = e.getIndices(),
  89276. this._positions = e.getVerticesData(Bi.PositionKind),
  89277. this._normals = e.getVerticesData(Bi.NormalKind)) : (this._indices = null,
  89278. this._positions = null,
  89279. this._normals = null))
  89280. },
  89281. enumerable: !1,
  89282. configurable: !0
  89283. }),
  89284. e.prototype.startDirectionFunction = function(e, t, i, n) {
  89285. if (this.useMeshNormalsForDirection && this._normals)
  89286. x.TransformNormalToRef(this._storedNormal, e, t);
  89287. else {
  89288. var r = d.RandomRange(this.direction1.x, this.direction2.x)
  89289. , o = d.RandomRange(this.direction1.y, this.direction2.y)
  89290. , a = d.RandomRange(this.direction1.z, this.direction2.z);
  89291. n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
  89292. }
  89293. }
  89294. ,
  89295. e.prototype.startPositionFunction = function(e, t, i, n) {
  89296. if (this._indices && this._positions) {
  89297. var r = 3 * Math.random() * (this._indices.length / 3) | 0
  89298. , o = Math.random()
  89299. , a = Math.random() * (1 - o)
  89300. , s = 1 - o - a
  89301. , l = this._indices[r]
  89302. , c = this._indices[r + 1]
  89303. , u = this._indices[r + 2]
  89304. , h = I.Vector3[0]
  89305. , d = I.Vector3[1]
  89306. , p = I.Vector3[2]
  89307. , f = I.Vector3[3];
  89308. x.FromArrayToRef(this._positions, 3 * l, h),
  89309. x.FromArrayToRef(this._positions, 3 * c, d),
  89310. x.FromArrayToRef(this._positions, 3 * u, p),
  89311. f.x = o * h.x + a * d.x + s * p.x,
  89312. f.y = o * h.y + a * d.y + s * p.y,
  89313. f.z = o * h.z + a * d.z + s * p.z,
  89314. n ? t.copyFromFloats(f.x, f.y, f.z) : x.TransformCoordinatesFromFloatsToRef(f.x, f.y, f.z, e, t),
  89315. this.useMeshNormalsForDirection && this._normals && (x.FromArrayToRef(this._normals, 3 * l, h),
  89316. x.FromArrayToRef(this._normals, 3 * c, d),
  89317. x.FromArrayToRef(this._normals, 3 * u, p),
  89318. this._storedNormal.x = o * h.x + a * d.x + s * p.x,
  89319. this._storedNormal.y = o * h.y + a * d.y + s * p.y,
  89320. this._storedNormal.z = o * h.z + a * d.z + s * p.z)
  89321. }
  89322. }
  89323. ,
  89324. e.prototype.clone = function() {
  89325. var t = new e(this.mesh);
  89326. return fe.DeepCopy(this, t),
  89327. t
  89328. }
  89329. ,
  89330. e.prototype.applyToShader = function(e) {
  89331. e.setVector3("direction1", this.direction1),
  89332. e.setVector3("direction2", this.direction2)
  89333. }
  89334. ,
  89335. e.prototype.buildUniformLayout = function(e) {
  89336. e.addUniform("direction1", 3),
  89337. e.addUniform("direction2", 3)
  89338. }
  89339. ,
  89340. e.prototype.getEffectDefines = function() {
  89341. return ""
  89342. }
  89343. ,
  89344. e.prototype.getClassName = function() {
  89345. return "MeshParticleEmitter"
  89346. }
  89347. ,
  89348. e.prototype.serialize = function() {
  89349. var e, t = {};
  89350. return t.type = this.getClassName(),
  89351. t.direction1 = this.direction1.asArray(),
  89352. t.direction2 = this.direction2.asArray(),
  89353. t.meshId = null === (e = this.mesh) || void 0 === e ? void 0 : e.id,
  89354. t.useMeshNormalsForDirection = this.useMeshNormalsForDirection,
  89355. t
  89356. }
  89357. ,
  89358. e.prototype.parse = function(e, t) {
  89359. x.FromArrayToRef(e.direction1, 0, this.direction1),
  89360. x.FromArrayToRef(e.direction2, 0, this.direction2),
  89361. e.meshId && t && (this.mesh = t.getLastMeshById(e.meshId)),
  89362. this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
  89363. }
  89364. ,
  89365. e
  89366. }()
  89367. , Tf = function() {
  89368. function e(t) {
  89369. this.animations = [],
  89370. this.renderingGroupId = 0,
  89371. this.emitter = x.Zero(),
  89372. this.emitRate = 10,
  89373. this.manualEmitCount = -1,
  89374. this.updateSpeed = .01,
  89375. this.targetStopDuration = 0,
  89376. this.disposeOnStop = !1,
  89377. this.minEmitPower = 1,
  89378. this.maxEmitPower = 1,
  89379. this.minLifeTime = 1,
  89380. this.maxLifeTime = 1,
  89381. this.minSize = 1,
  89382. this.maxSize = 1,
  89383. this.minScaleX = 1,
  89384. this.maxScaleX = 1,
  89385. this.minScaleY = 1,
  89386. this.maxScaleY = 1,
  89387. this.minInitialRotation = 0,
  89388. this.maxInitialRotation = 0,
  89389. this.minAngularSpeed = 0,
  89390. this.maxAngularSpeed = 0,
  89391. this.layerMask = 268435455,
  89392. this.customShader = null,
  89393. this.preventAutoStart = !1,
  89394. this._rootUrl = "",
  89395. this.noiseStrength = new x(10,10,10),
  89396. this.onAnimationEnd = null,
  89397. this.blendMode = e.BLENDMODE_ONEONE,
  89398. this.forceDepthWrite = !1,
  89399. this.preWarmCycles = 0,
  89400. this.preWarmStepOffset = 1,
  89401. this.spriteCellChangeSpeed = 1,
  89402. this.startSpriteCellID = 0,
  89403. this.endSpriteCellID = 0,
  89404. this.spriteCellWidth = 0,
  89405. this.spriteCellHeight = 0,
  89406. this.spriteCellLoop = !0,
  89407. this.spriteRandomStartCell = !1,
  89408. this.translationPivot = new A(0,0),
  89409. this.beginAnimationOnStart = !1,
  89410. this.beginAnimationFrom = 0,
  89411. this.beginAnimationTo = 60,
  89412. this.beginAnimationLoop = !1,
  89413. this.worldOffset = new x(0,0,0),
  89414. this.gravity = x.Zero(),
  89415. this._colorGradients = null,
  89416. this._sizeGradients = null,
  89417. this._lifeTimeGradients = null,
  89418. this._angularSpeedGradients = null,
  89419. this._velocityGradients = null,
  89420. this._limitVelocityGradients = null,
  89421. this._dragGradients = null,
  89422. this._emitRateGradients = null,
  89423. this._startSizeGradients = null,
  89424. this._rampGradients = null,
  89425. this._colorRemapGradients = null,
  89426. this._alphaRemapGradients = null,
  89427. this.startDelay = 0,
  89428. this.limitVelocityDamping = .4,
  89429. this.color1 = new N(1,1,1,1),
  89430. this.color2 = new N(1,1,1,1),
  89431. this.colorDead = new N(0,0,0,1),
  89432. this.textureMask = new N(1,1,1,1),
  89433. this._isSubEmitter = !1,
  89434. this._billboardMode = a.PARTICLES_BILLBOARDMODE_ALL,
  89435. this._isBillboardBased = !0,
  89436. this._imageProcessingConfigurationDefines = new xi,
  89437. this.id = t,
  89438. this.name = t
  89439. }
  89440. return Object.defineProperty(e.prototype, "noiseTexture", {
  89441. get: function() {
  89442. return this._noiseTexture
  89443. },
  89444. set: function(e) {
  89445. this._noiseTexture !== e && (this._noiseTexture = e,
  89446. this._reset())
  89447. },
  89448. enumerable: !1,
  89449. configurable: !0
  89450. }),
  89451. Object.defineProperty(e.prototype, "isAnimationSheetEnabled", {
  89452. get: function() {
  89453. return this._isAnimationSheetEnabled
  89454. },
  89455. set: function(e) {
  89456. this._isAnimationSheetEnabled != e && (this._isAnimationSheetEnabled = e,
  89457. this._reset())
  89458. },
  89459. enumerable: !1,
  89460. configurable: !0
  89461. }),
  89462. e.prototype.getScene = function() {
  89463. return this._scene
  89464. }
  89465. ,
  89466. e.prototype._hasTargetStopDurationDependantGradient = function() {
  89467. return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0
  89468. }
  89469. ,
  89470. e.prototype.getDragGradients = function() {
  89471. return this._dragGradients
  89472. }
  89473. ,
  89474. e.prototype.getLimitVelocityGradients = function() {
  89475. return this._limitVelocityGradients
  89476. }
  89477. ,
  89478. e.prototype.getColorGradients = function() {
  89479. return this._colorGradients
  89480. }
  89481. ,
  89482. e.prototype.getSizeGradients = function() {
  89483. return this._sizeGradients
  89484. }
  89485. ,
  89486. e.prototype.getColorRemapGradients = function() {
  89487. return this._colorRemapGradients
  89488. }
  89489. ,
  89490. e.prototype.getAlphaRemapGradients = function() {
  89491. return this._alphaRemapGradients
  89492. }
  89493. ,
  89494. e.prototype.getLifeTimeGradients = function() {
  89495. return this._lifeTimeGradients
  89496. }
  89497. ,
  89498. e.prototype.getAngularSpeedGradients = function() {
  89499. return this._angularSpeedGradients
  89500. }
  89501. ,
  89502. e.prototype.getVelocityGradients = function() {
  89503. return this._velocityGradients
  89504. }
  89505. ,
  89506. e.prototype.getStartSizeGradients = function() {
  89507. return this._startSizeGradients
  89508. }
  89509. ,
  89510. e.prototype.getEmitRateGradients = function() {
  89511. return this._emitRateGradients
  89512. }
  89513. ,
  89514. Object.defineProperty(e.prototype, "direction1", {
  89515. get: function() {
  89516. return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : x.Zero()
  89517. },
  89518. set: function(e) {
  89519. this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = e)
  89520. },
  89521. enumerable: !1,
  89522. configurable: !0
  89523. }),
  89524. Object.defineProperty(e.prototype, "direction2", {
  89525. get: function() {
  89526. return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : x.Zero()
  89527. },
  89528. set: function(e) {
  89529. this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = e)
  89530. },
  89531. enumerable: !1,
  89532. configurable: !0
  89533. }),
  89534. Object.defineProperty(e.prototype, "minEmitBox", {
  89535. get: function() {
  89536. return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : x.Zero()
  89537. },
  89538. set: function(e) {
  89539. this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = e)
  89540. },
  89541. enumerable: !1,
  89542. configurable: !0
  89543. }),
  89544. Object.defineProperty(e.prototype, "maxEmitBox", {
  89545. get: function() {
  89546. return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : x.Zero()
  89547. },
  89548. set: function(e) {
  89549. this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = e)
  89550. },
  89551. enumerable: !1,
  89552. configurable: !0
  89553. }),
  89554. Object.defineProperty(e.prototype, "billboardMode", {
  89555. get: function() {
  89556. return this._billboardMode
  89557. },
  89558. set: function(e) {
  89559. this._billboardMode !== e && (this._billboardMode = e,
  89560. this._reset())
  89561. },
  89562. enumerable: !1,
  89563. configurable: !0
  89564. }),
  89565. Object.defineProperty(e.prototype, "isBillboardBased", {
  89566. get: function() {
  89567. return this._isBillboardBased
  89568. },
  89569. set: function(e) {
  89570. this._isBillboardBased !== e && (this._isBillboardBased = e,
  89571. this._reset())
  89572. },
  89573. enumerable: !1,
  89574. configurable: !0
  89575. }),
  89576. Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
  89577. get: function() {
  89578. return this._imageProcessingConfiguration
  89579. },
  89580. set: function(e) {
  89581. this._attachImageProcessingConfiguration(e)
  89582. },
  89583. enumerable: !1,
  89584. configurable: !0
  89585. }),
  89586. e.prototype._attachImageProcessingConfiguration = function(e) {
  89587. e !== this._imageProcessingConfiguration && (!e && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = e)
  89588. }
  89589. ,
  89590. e.prototype._reset = function() {}
  89591. ,
  89592. e.prototype._removeGradientAndTexture = function(e, t, i) {
  89593. if (!t)
  89594. return this;
  89595. for (var n = 0, r = 0, o = t; r < o.length; r++) {
  89596. if (o[r].gradient === e) {
  89597. t.splice(n, 1);
  89598. break
  89599. }
  89600. n++
  89601. }
  89602. return i && i.dispose(),
  89603. this
  89604. }
  89605. ,
  89606. e.prototype.createPointEmitter = function(e, t) {
  89607. var i = new mf;
  89608. return i.direction1 = e,
  89609. i.direction2 = t,
  89610. this.particleEmitterType = i,
  89611. i
  89612. }
  89613. ,
  89614. e.prototype.createHemisphericEmitter = function(e, t) {
  89615. void 0 === e && (e = 1),
  89616. void 0 === t && (t = 1);
  89617. var i = new _f(e,t);
  89618. return this.particleEmitterType = i,
  89619. i
  89620. }
  89621. ,
  89622. e.prototype.createSphereEmitter = function(e, t) {
  89623. void 0 === e && (e = 1),
  89624. void 0 === t && (t = 1);
  89625. var i = new gf(e,t);
  89626. return this.particleEmitterType = i,
  89627. i
  89628. }
  89629. ,
  89630. e.prototype.createDirectedSphereEmitter = function(e, t, i) {
  89631. void 0 === e && (e = 1),
  89632. void 0 === t && (t = new x(0,1,0)),
  89633. void 0 === i && (i = new x(0,1,0));
  89634. var n = new vf(e,t,i);
  89635. return this.particleEmitterType = n,
  89636. n
  89637. }
  89638. ,
  89639. e.prototype.createCylinderEmitter = function(e, t, i, n) {
  89640. void 0 === e && (e = 1),
  89641. void 0 === t && (t = 1),
  89642. void 0 === i && (i = 1),
  89643. void 0 === n && (n = 0);
  89644. var r = new pf(e,t,i,n);
  89645. return this.particleEmitterType = r,
  89646. r
  89647. }
  89648. ,
  89649. e.prototype.createDirectedCylinderEmitter = function(e, t, i, n, r) {
  89650. void 0 === e && (e = 1),
  89651. void 0 === t && (t = 1),
  89652. void 0 === i && (i = 1),
  89653. void 0 === n && (n = new x(0,1,0)),
  89654. void 0 === r && (r = new x(0,1,0));
  89655. var o = new ff(e,t,i,n,r);
  89656. return this.particleEmitterType = o,
  89657. o
  89658. }
  89659. ,
  89660. e.prototype.createConeEmitter = function(e, t) {
  89661. void 0 === e && (e = 1),
  89662. void 0 === t && (t = Math.PI / 4);
  89663. var i = new df(e,t);
  89664. return this.particleEmitterType = i,
  89665. i
  89666. }
  89667. ,
  89668. e.prototype.createBoxEmitter = function(e, t, i, n) {
  89669. var r = new hf;
  89670. return this.particleEmitterType = r,
  89671. this.direction1 = e,
  89672. this.direction2 = t,
  89673. this.minEmitBox = i,
  89674. this.maxEmitBox = n,
  89675. r
  89676. }
  89677. ,
  89678. e.BLENDMODE_ONEONE = 0,
  89679. e.BLENDMODE_STANDARD = 1,
  89680. e.BLENDMODE_ADD = 2,
  89681. e.BLENDMODE_MULTIPLY = 3,
  89682. e.BLENDMODE_MULTIPLYADD = 4,
  89683. e
  89684. }()
  89685. , Ef = function(e) {
  89686. function t(t) {
  89687. var i = e.call(this, t, Dp.Neutral) || this;
  89688. return i.registerInput("rgba", Op.Color4, !0),
  89689. i.registerInput("rgb ", Op.Color3, !0),
  89690. i.registerOutput("rgb", Op.Color3),
  89691. i.registerOutput("r", Op.Float),
  89692. i.registerOutput("g", Op.Float),
  89693. i.registerOutput("b", Op.Float),
  89694. i.registerOutput("a", Op.Float),
  89695. i.inputsAreExclusive = !0,
  89696. i
  89697. }
  89698. return U(t, e),
  89699. t.prototype.getClassName = function() {
  89700. return "ColorSplitterBlock"
  89701. }
  89702. ,
  89703. Object.defineProperty(t.prototype, "rgba", {
  89704. get: function() {
  89705. return this._inputs[0]
  89706. },
  89707. enumerable: !1,
  89708. configurable: !0
  89709. }),
  89710. Object.defineProperty(t.prototype, "rgbIn", {
  89711. get: function() {
  89712. return this._inputs[1]
  89713. },
  89714. enumerable: !1,
  89715. configurable: !0
  89716. }),
  89717. Object.defineProperty(t.prototype, "rgbOut", {
  89718. get: function() {
  89719. return this._outputs[0]
  89720. },
  89721. enumerable: !1,
  89722. configurable: !0
  89723. }),
  89724. Object.defineProperty(t.prototype, "r", {
  89725. get: function() {
  89726. return this._outputs[1]
  89727. },
  89728. enumerable: !1,
  89729. configurable: !0
  89730. }),
  89731. Object.defineProperty(t.prototype, "g", {
  89732. get: function() {
  89733. return this._outputs[2]
  89734. },
  89735. enumerable: !1,
  89736. configurable: !0
  89737. }),
  89738. Object.defineProperty(t.prototype, "b", {
  89739. get: function() {
  89740. return this._outputs[3]
  89741. },
  89742. enumerable: !1,
  89743. configurable: !0
  89744. }),
  89745. Object.defineProperty(t.prototype, "a", {
  89746. get: function() {
  89747. return this._outputs[4]
  89748. },
  89749. enumerable: !1,
  89750. configurable: !0
  89751. }),
  89752. t.prototype._inputRename = function(e) {
  89753. return "rgb " === e ? "rgbIn" : e
  89754. }
  89755. ,
  89756. t.prototype._outputRename = function(e) {
  89757. return "rgb" === e ? "rgbOut" : e
  89758. }
  89759. ,
  89760. t.prototype._buildBlock = function(t) {
  89761. e.prototype._buildBlock.call(this, t);
  89762. var i = this.rgba.isConnected ? this.rgba : this.rgbIn;
  89763. if (i.isConnected) {
  89764. var n = this._outputs[0]
  89765. , r = this._outputs[1]
  89766. , o = this._outputs[2]
  89767. , a = this._outputs[3]
  89768. , s = this._outputs[4];
  89769. return n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".rgb;\r\n")),
  89770. r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".r;\r\n")),
  89771. o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = ".concat(i.associatedVariableName, ".g;\r\n")),
  89772. a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".b;\r\n")),
  89773. s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".a;\r\n")),
  89774. this
  89775. }
  89776. }
  89777. ,
  89778. t
  89779. }(Wp);
  89780. y("BABYLON.ColorSplitterBlock", Ef);
  89781. var Sf = function() {
  89782. function e(e) {
  89783. this.name = Wi.NAME_PROCEDURALTEXTURE,
  89784. this.scene = e,
  89785. this.scene.proceduralTextures = new Array
  89786. }
  89787. return e.prototype.register = function() {
  89788. this.scene._beforeClearStage.registerStep(Wi.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
  89789. }
  89790. ,
  89791. e.prototype.rebuild = function() {}
  89792. ,
  89793. e.prototype.dispose = function() {}
  89794. ,
  89795. e.prototype._beforeClear = function() {
  89796. if (this.scene.proceduralTexturesEnabled) {
  89797. gi.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  89798. for (var e = 0; e < this.scene.proceduralTextures.length; e++) {
  89799. var t = this.scene.proceduralTextures[e];
  89800. t._shouldRender() && t.render()
  89801. }
  89802. gi.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
  89803. }
  89804. }
  89805. ,
  89806. e
  89807. }();
  89808. Pt.ShadersStore.proceduralVertexShader = "attribute vec2 position;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  89809. var Af, xf = function(e) {
  89810. function t(t, i, n, r, o, s, l, c) {
  89811. void 0 === o && (o = null),
  89812. void 0 === s && (s = !0),
  89813. void 0 === l && (l = !1),
  89814. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
  89815. var u = e.call(this, null, r, !s) || this;
  89816. u.isEnabled = !0,
  89817. u.autoClear = !0,
  89818. u.onGeneratedObservable = new h,
  89819. u.onBeforeGenerationObservable = new h,
  89820. u.nodeMaterialSource = null,
  89821. u._textures = {},
  89822. u._currentRefreshId = -1,
  89823. u._frameId = -1,
  89824. u._refreshRate = 1,
  89825. u._vertexBuffers = {},
  89826. u._uniforms = new Array,
  89827. u._samplers = new Array,
  89828. u._floats = {},
  89829. u._ints = {},
  89830. u._floatsArrays = {},
  89831. u._colors3 = {},
  89832. u._colors4 = {},
  89833. u._vectors2 = {},
  89834. u._vectors3 = {},
  89835. u._matrices = {},
  89836. u._fallbackTextureUsed = !1,
  89837. u._cachedDefines = null,
  89838. u._contentUpdateId = -1,
  89839. u._rtWrapper = null;
  89840. var d = (r = u.getScene() || E.LastCreatedScene)._getComponent(Wi.NAME_PROCEDURALTEXTURE);
  89841. d || (d = new Sf(r),
  89842. r._addComponent(d)),
  89843. r.proceduralTextures.push(u),
  89844. u._fullEngine = r.getEngine(),
  89845. u.name = t,
  89846. u.isRenderTarget = !0,
  89847. u._size = i,
  89848. u._textureType = c,
  89849. u._generateMipMaps = s,
  89850. u._drawWrapper = new Gt(u._fullEngine),
  89851. u.setFragment(n),
  89852. u._fallbackTexture = o;
  89853. var p = u._createRtWrapper(l, i, s, c);
  89854. u._texture = p.texture;
  89855. var f = [];
  89856. return f.push(1, 1),
  89857. f.push(-1, 1),
  89858. f.push(-1, -1),
  89859. f.push(1, -1),
  89860. u._vertexBuffers[Bi.PositionKind] = new Bi(u._fullEngine,f,Bi.PositionKind,!1,!1,2),
  89861. u._createIndexBuffer(),
  89862. u
  89863. }
  89864. return U(t, e),
  89865. t.prototype._createRtWrapper = function(e, t, i, n) {
  89866. return e ? (this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(t, {
  89867. generateMipMaps: i,
  89868. generateDepthBuffer: !1,
  89869. generateStencilBuffer: !1,
  89870. type: n
  89871. }),
  89872. this.setFloat("face", 0)) : this._rtWrapper = this._fullEngine.createRenderTargetTexture(t, {
  89873. generateMipMaps: i,
  89874. generateDepthBuffer: !1,
  89875. generateStencilBuffer: !1,
  89876. type: n
  89877. }),
  89878. this._rtWrapper
  89879. }
  89880. ,
  89881. t.prototype.getEffect = function() {
  89882. return this._drawWrapper.effect
  89883. }
  89884. ,
  89885. t.prototype._setEffect = function(e) {
  89886. this._drawWrapper.effect = e
  89887. }
  89888. ,
  89889. t.prototype.getContent = function() {
  89890. var e = this;
  89891. return this._contentData && this._frameId === this._contentUpdateId || (this._contentData ? this._contentData.then((function(t) {
  89892. e._contentData = e.readPixels(0, 0, t),
  89893. e._contentUpdateId = e._frameId
  89894. }
  89895. )) : (this._contentData = this.readPixels(0, 0),
  89896. this._contentUpdateId = this._frameId)),
  89897. this._contentData
  89898. }
  89899. ,
  89900. t.prototype._createIndexBuffer = function() {
  89901. var e = this._fullEngine
  89902. , t = [];
  89903. t.push(0),
  89904. t.push(1),
  89905. t.push(2),
  89906. t.push(0),
  89907. t.push(2),
  89908. t.push(3),
  89909. this._indexBuffer = e.createIndexBuffer(t)
  89910. }
  89911. ,
  89912. t.prototype._rebuild = function() {
  89913. var e = this._vertexBuffers[Bi.PositionKind];
  89914. e && e._rebuild(),
  89915. this._createIndexBuffer(),
  89916. this.refreshRate === ns.REFRESHRATE_RENDER_ONCE && (this.refreshRate = ns.REFRESHRATE_RENDER_ONCE)
  89917. }
  89918. ,
  89919. t.prototype.reset = function() {
  89920. var e;
  89921. null === (e = this._drawWrapper.effect) || void 0 === e || e.dispose()
  89922. }
  89923. ,
  89924. t.prototype._getDefines = function() {
  89925. return ""
  89926. }
  89927. ,
  89928. t.prototype.isReady = function() {
  89929. var e, t = this, i = this._fullEngine;
  89930. if (this.nodeMaterialSource)
  89931. return this._drawWrapper.effect.isReady();
  89932. if (!this._fragment)
  89933. return !1;
  89934. if (this._fallbackTextureUsed)
  89935. return !0;
  89936. if (!this._texture)
  89937. return !1;
  89938. var n = this._getDefines();
  89939. return !(!this._drawWrapper.effect || n !== this._cachedDefines || !this._drawWrapper.effect.isReady()) || (e = void 0 !== this._fragment.fragmentElement ? {
  89940. vertex: "procedural",
  89941. fragmentElement: this._fragment.fragmentElement
  89942. } : {
  89943. vertex: "procedural",
  89944. fragment: this._fragment
  89945. },
  89946. this._cachedDefines !== n && (this._cachedDefines = n,
  89947. this._drawWrapper.effect = i.createEffect(e, [Bi.PositionKind], this._uniforms, this._samplers, n, void 0, void 0, (function() {
  89948. var e;
  89949. null === (e = t._rtWrapper) || void 0 === e || e.dispose(),
  89950. t._rtWrapper = t._texture = null,
  89951. t._fallbackTexture && (t._texture = t._fallbackTexture._texture,
  89952. t._texture && t._texture.incrementReferences()),
  89953. t._fallbackTextureUsed = !0
  89954. }
  89955. ))),
  89956. this._drawWrapper.effect.isReady())
  89957. }
  89958. ,
  89959. t.prototype.resetRefreshCounter = function() {
  89960. this._currentRefreshId = -1
  89961. }
  89962. ,
  89963. t.prototype.setFragment = function(e) {
  89964. this._fragment = e
  89965. }
  89966. ,
  89967. Object.defineProperty(t.prototype, "refreshRate", {
  89968. get: function() {
  89969. return this._refreshRate
  89970. },
  89971. set: function(e) {
  89972. this._refreshRate = e,
  89973. this.resetRefreshCounter()
  89974. },
  89975. enumerable: !1,
  89976. configurable: !0
  89977. }),
  89978. t.prototype._shouldRender = function() {
  89979. return this.isEnabled && this.isReady() && this._texture ? !this._fallbackTextureUsed && (-1 === this._currentRefreshId || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
  89980. this._frameId++,
  89981. !0) : (this._currentRefreshId++,
  89982. !1)) : (this._texture && (this._texture.isReady = !1),
  89983. !1)
  89984. }
  89985. ,
  89986. t.prototype.getRenderSize = function() {
  89987. return this._size
  89988. }
  89989. ,
  89990. t.prototype.resize = function(e, t) {
  89991. if (!this._fallbackTextureUsed && this._rtWrapper && this._texture) {
  89992. var i = this._texture.isCube;
  89993. this._rtWrapper.dispose();
  89994. var n = this._createRtWrapper(i, e, t, this._textureType);
  89995. this._texture = n.texture,
  89996. this._size = e,
  89997. this._generateMipMaps = t
  89998. }
  89999. }
  90000. ,
  90001. t.prototype._checkUniform = function(e) {
  90002. -1 === this._uniforms.indexOf(e) && this._uniforms.push(e)
  90003. }
  90004. ,
  90005. t.prototype.setTexture = function(e, t) {
  90006. return -1 === this._samplers.indexOf(e) && this._samplers.push(e),
  90007. this._textures[e] = t,
  90008. this
  90009. }
  90010. ,
  90011. t.prototype.setFloat = function(e, t) {
  90012. return this._checkUniform(e),
  90013. this._floats[e] = t,
  90014. this
  90015. }
  90016. ,
  90017. t.prototype.setInt = function(e, t) {
  90018. return this._checkUniform(e),
  90019. this._ints[e] = t,
  90020. this
  90021. }
  90022. ,
  90023. t.prototype.setFloats = function(e, t) {
  90024. return this._checkUniform(e),
  90025. this._floatsArrays[e] = t,
  90026. this
  90027. }
  90028. ,
  90029. t.prototype.setColor3 = function(e, t) {
  90030. return this._checkUniform(e),
  90031. this._colors3[e] = t,
  90032. this
  90033. }
  90034. ,
  90035. t.prototype.setColor4 = function(e, t) {
  90036. return this._checkUniform(e),
  90037. this._colors4[e] = t,
  90038. this
  90039. }
  90040. ,
  90041. t.prototype.setVector2 = function(e, t) {
  90042. return this._checkUniform(e),
  90043. this._vectors2[e] = t,
  90044. this
  90045. }
  90046. ,
  90047. t.prototype.setVector3 = function(e, t) {
  90048. return this._checkUniform(e),
  90049. this._vectors3[e] = t,
  90050. this
  90051. }
  90052. ,
  90053. t.prototype.setMatrix = function(e, t) {
  90054. return this._checkUniform(e),
  90055. this._matrices[e] = t,
  90056. this
  90057. }
  90058. ,
  90059. t.prototype.render = function(e) {
  90060. var t, i, n = this.getScene();
  90061. if (n) {
  90062. var r = this._fullEngine;
  90063. if (r.enableEffect(this._drawWrapper),
  90064. this.onBeforeGenerationObservable.notifyObservers(this),
  90065. r.setState(!1),
  90066. !this.nodeMaterialSource) {
  90067. for (var o in this._textures)
  90068. this._drawWrapper.effect.setTexture(o, this._textures[o]);
  90069. for (var a in this._ints)
  90070. this._drawWrapper.effect.setInt(a, this._ints[a]);
  90071. for (var s in this._floats)
  90072. this._drawWrapper.effect.setFloat(s, this._floats[s]);
  90073. for (var l in this._floatsArrays)
  90074. this._drawWrapper.effect.setArray(l, this._floatsArrays[l]);
  90075. for (var c in this._colors3)
  90076. this._drawWrapper.effect.setColor3(c, this._colors3[c]);
  90077. for (var u in this._colors4) {
  90078. var h = this._colors4[u];
  90079. this._drawWrapper.effect.setFloat4(u, h.r, h.g, h.b, h.a)
  90080. }
  90081. for (var d in this._vectors2)
  90082. this._drawWrapper.effect.setVector2(d, this._vectors2[d]);
  90083. for (var p in this._vectors3)
  90084. this._drawWrapper.effect.setVector3(p, this._vectors3[p]);
  90085. for (var f in this._matrices)
  90086. this._drawWrapper.effect.setMatrix(f, this._matrices[f])
  90087. }
  90088. if (this._texture && this._rtWrapper) {
  90089. if (null === (t = r._debugPushGroup) || void 0 === t || t.call(r, "procedural texture generation for ".concat(this.name), 1),
  90090. this.isCube)
  90091. for (var _ = 0; _ < 6; _++)
  90092. r.bindFramebuffer(this._rtWrapper, _, void 0, void 0, !0),
  90093. r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
  90094. this._drawWrapper.effect.setFloat("face", _),
  90095. this.autoClear && r.clear(n.clearColor, !0, !1, !1),
  90096. r.drawElementsType(Or.TriangleFillMode, 0, 6);
  90097. else
  90098. r.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
  90099. r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
  90100. this.autoClear && r.clear(n.clearColor, !0, !1, !1),
  90101. r.drawElementsType(Or.TriangleFillMode, 0, 6);
  90102. r.unBindFramebuffer(this._rtWrapper, this.isCube),
  90103. this.isCube && r.generateMipMapsForCubemap(this._texture),
  90104. null === (i = r._debugPopGroup) || void 0 === i || i.call(r, 1),
  90105. this.onGenerated && this.onGenerated(),
  90106. this.onGeneratedObservable.notifyObservers(this)
  90107. }
  90108. }
  90109. }
  90110. ,
  90111. t.prototype.clone = function() {
  90112. var e = this.getSize()
  90113. , i = new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);
  90114. return i.hasAlpha = this.hasAlpha,
  90115. i.level = this.level,
  90116. i.coordinatesMode = this.coordinatesMode,
  90117. i
  90118. }
  90119. ,
  90120. t.prototype.dispose = function() {
  90121. var t = this.getScene();
  90122. if (t) {
  90123. var i = t.proceduralTextures.indexOf(this);
  90124. i >= 0 && t.proceduralTextures.splice(i, 1);
  90125. var n = this._vertexBuffers[Bi.PositionKind];
  90126. n && (n.dispose(),
  90127. this._vertexBuffers[Bi.PositionKind] = null),
  90128. this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
  90129. this.onGeneratedObservable.clear(),
  90130. this.onBeforeGenerationObservable.clear(),
  90131. e.prototype.dispose.call(this)
  90132. }
  90133. }
  90134. ,
  90135. k([Ce()], t.prototype, "isEnabled", void 0),
  90136. k([Ce()], t.prototype, "autoClear", void 0),
  90137. k([Ce()], t.prototype, "_generateMipMaps", void 0),
  90138. k([Ce()], t.prototype, "_size", void 0),
  90139. k([Ce()], t.prototype, "refreshRate", null),
  90140. t
  90141. }(io);
  90142. y("BABYLON.ProceduralTexture", xf),
  90143. function(e) {
  90144. e[e.Cos = 0] = "Cos",
  90145. e[e.Sin = 1] = "Sin",
  90146. e[e.Abs = 2] = "Abs",
  90147. e[e.Exp = 3] = "Exp",
  90148. e[e.Exp2 = 4] = "Exp2",
  90149. e[e.Round = 5] = "Round",
  90150. e[e.Floor = 6] = "Floor",
  90151. e[e.Ceiling = 7] = "Ceiling",
  90152. e[e.Sqrt = 8] = "Sqrt",
  90153. e[e.Log = 9] = "Log",
  90154. e[e.Tan = 10] = "Tan",
  90155. e[e.ArcTan = 11] = "ArcTan",
  90156. e[e.ArcCos = 12] = "ArcCos",
  90157. e[e.ArcSin = 13] = "ArcSin",
  90158. e[e.Fract = 14] = "Fract",
  90159. e[e.Sign = 15] = "Sign",
  90160. e[e.Radians = 16] = "Radians",
  90161. e[e.Degrees = 17] = "Degrees"
  90162. }(Af || (Af = {}));
  90163. var Rf = function(e) {
  90164. function t(t) {
  90165. var i = e.call(this, t, Dp.Neutral) || this;
  90166. return i.operation = Af.Cos,
  90167. i.registerInput("input", Op.AutoDetect),
  90168. i.registerOutput("output", Op.BasedOnInput),
  90169. i._outputs[0]._typeConnectionSource = i._inputs[0],
  90170. i
  90171. }
  90172. return U(t, e),
  90173. t.prototype.getClassName = function() {
  90174. return "TrigonometryBlock"
  90175. }
  90176. ,
  90177. Object.defineProperty(t.prototype, "input", {
  90178. get: function() {
  90179. return this._inputs[0]
  90180. },
  90181. enumerable: !1,
  90182. configurable: !0
  90183. }),
  90184. Object.defineProperty(t.prototype, "output", {
  90185. get: function() {
  90186. return this._outputs[0]
  90187. },
  90188. enumerable: !1,
  90189. configurable: !0
  90190. }),
  90191. t.prototype._buildBlock = function(t) {
  90192. e.prototype._buildBlock.call(this, t);
  90193. var i = this._outputs[0]
  90194. , n = "";
  90195. switch (this.operation) {
  90196. case Af.Cos:
  90197. n = "cos";
  90198. break;
  90199. case Af.Sin:
  90200. n = "sin";
  90201. break;
  90202. case Af.Abs:
  90203. n = "abs";
  90204. break;
  90205. case Af.Exp:
  90206. n = "exp";
  90207. break;
  90208. case Af.Exp2:
  90209. n = "exp2";
  90210. break;
  90211. case Af.Round:
  90212. n = "round";
  90213. break;
  90214. case Af.Floor:
  90215. n = "floor";
  90216. break;
  90217. case Af.Ceiling:
  90218. n = "ceil";
  90219. break;
  90220. case Af.Sqrt:
  90221. n = "sqrt";
  90222. break;
  90223. case Af.Log:
  90224. n = "log";
  90225. break;
  90226. case Af.Tan:
  90227. n = "tan";
  90228. break;
  90229. case Af.ArcTan:
  90230. n = "atan";
  90231. break;
  90232. case Af.ArcCos:
  90233. n = "acos";
  90234. break;
  90235. case Af.ArcSin:
  90236. n = "asin";
  90237. break;
  90238. case Af.Fract:
  90239. n = "fract";
  90240. break;
  90241. case Af.Sign:
  90242. n = "sign";
  90243. break;
  90244. case Af.Radians:
  90245. n = "radians";
  90246. break;
  90247. case Af.Degrees:
  90248. n = "degrees"
  90249. }
  90250. return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, "(").concat(this.input.associatedVariableName, ");\r\n"),
  90251. this
  90252. }
  90253. ,
  90254. t.prototype.serialize = function() {
  90255. var t = e.prototype.serialize.call(this);
  90256. return t.operation = this.operation,
  90257. t
  90258. }
  90259. ,
  90260. t.prototype._deserialize = function(t, i, n) {
  90261. e.prototype._deserialize.call(this, t, i, n),
  90262. this.operation = t.operation
  90263. }
  90264. ,
  90265. t.prototype._dumpPropertiesCode = function() {
  90266. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.TrigonometryBlockOperations.").concat(Af[this.operation], ";\r\n")
  90267. }
  90268. ,
  90269. t
  90270. }(Wp);
  90271. y("BABYLON.TrigonometryBlock", Rf);
  90272. var Cf, Pf, Mf = {
  90273. effect: null,
  90274. subMesh: null
  90275. }, If = function(e) {
  90276. function t() {
  90277. var t = e.call(this) || this;
  90278. return t.NORMAL = !1,
  90279. t.TANGENT = !1,
  90280. t.UV1 = !1,
  90281. t.UV2 = !1,
  90282. t.UV3 = !1,
  90283. t.UV4 = !1,
  90284. t.UV5 = !1,
  90285. t.UV6 = !1,
  90286. t.NUM_BONE_INFLUENCERS = 0,
  90287. t.BonesPerMesh = 0,
  90288. t.BONETEXTURE = !1,
  90289. t.MORPHTARGETS = !1,
  90290. t.MORPHTARGETS_NORMAL = !1,
  90291. t.MORPHTARGETS_TANGENT = !1,
  90292. t.MORPHTARGETS_UV = !1,
  90293. t.NUM_MORPH_INFLUENCERS = 0,
  90294. t.MORPHTARGETS_TEXTURE = !1,
  90295. t.IMAGEPROCESSING = !1,
  90296. t.VIGNETTE = !1,
  90297. t.VIGNETTEBLENDMODEMULTIPLY = !1,
  90298. t.VIGNETTEBLENDMODEOPAQUE = !1,
  90299. t.TONEMAPPING = !1,
  90300. t.TONEMAPPING_ACES = !1,
  90301. t.CONTRAST = !1,
  90302. t.EXPOSURE = !1,
  90303. t.COLORCURVES = !1,
  90304. t.COLORGRADING = !1,
  90305. t.COLORGRADING3D = !1,
  90306. t.SAMPLER3DGREENDEPTH = !1,
  90307. t.SAMPLER3DBGRMAP = !1,
  90308. t.IMAGEPROCESSINGPOSTPROCESS = !1,
  90309. t.SKIPFINALCOLORCLAMP = !1,
  90310. t.BUMPDIRECTUV = 0,
  90311. t.rebuild(),
  90312. t
  90313. }
  90314. return U(t, e),
  90315. t.prototype.setValue = function(e, t, i) {
  90316. void 0 === i && (i = !1),
  90317. void 0 === this[e] && this._keys.push(e),
  90318. i && this[e] !== t && this.markAsUnprocessed(),
  90319. this[e] = t
  90320. }
  90321. ,
  90322. t
  90323. }(Si), Of = function(e) {
  90324. function t(i, n, r) {
  90325. void 0 === r && (r = {});
  90326. var o = e.call(this, i, n || E.LastCreatedScene) || this;
  90327. return o._buildId = t._BuildIdGenerator++,
  90328. o._buildWasSuccessful = !1,
  90329. o._cachedWorldViewMatrix = new P,
  90330. o._cachedWorldViewProjectionMatrix = new P,
  90331. o._optimizers = new Array,
  90332. o._animationFrame = -1,
  90333. o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(),
  90334. o.editorData = null,
  90335. o.ignoreAlpha = !1,
  90336. o.maxSimultaneousLights = 4,
  90337. o.onBuildObservable = new h,
  90338. o._vertexOutputNodes = new Array,
  90339. o._fragmentOutputNodes = new Array,
  90340. o.attachedBlocks = new Array,
  90341. o._mode = cf.Material,
  90342. o.forceAlphaBlending = !1,
  90343. o._options = V({
  90344. emitComments: !1
  90345. }, r),
  90346. o._attachImageProcessingConfiguration(null),
  90347. o
  90348. }
  90349. return U(t, e),
  90350. t.prototype._getGlobalNodeMaterialEditor = function() {
  90351. return "undefined" != typeof NODEEDITOR ? NODEEDITOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.NodeEditor ? BABYLON : void 0
  90352. }
  90353. ,
  90354. Object.defineProperty(t.prototype, "options", {
  90355. get: function() {
  90356. return this._options
  90357. },
  90358. set: function(e) {
  90359. this._options = e
  90360. },
  90361. enumerable: !1,
  90362. configurable: !0
  90363. }),
  90364. Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
  90365. get: function() {
  90366. return this._imageProcessingConfiguration
  90367. },
  90368. set: function(e) {
  90369. this._attachImageProcessingConfiguration(e),
  90370. this._markAllSubMeshesAsTexturesDirty()
  90371. },
  90372. enumerable: !1,
  90373. configurable: !0
  90374. }),
  90375. Object.defineProperty(t.prototype, "mode", {
  90376. get: function() {
  90377. return this._mode
  90378. },
  90379. set: function(e) {
  90380. this._mode = e
  90381. },
  90382. enumerable: !1,
  90383. configurable: !0
  90384. }),
  90385. Object.defineProperty(t.prototype, "buildId", {
  90386. get: function() {
  90387. return this._buildId
  90388. },
  90389. set: function(e) {
  90390. this._buildId = e
  90391. },
  90392. enumerable: !1,
  90393. configurable: !0
  90394. }),
  90395. t.prototype.getClassName = function() {
  90396. return "NodeMaterial"
  90397. }
  90398. ,
  90399. t.prototype._attachImageProcessingConfiguration = function(e) {
  90400. var t = this;
  90401. e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  90402. this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
  90403. this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
  90404. t._markAllSubMeshesAsImageProcessingDirty()
  90405. }
  90406. ))))
  90407. }
  90408. ,
  90409. t.prototype.getBlockByName = function(e) {
  90410. for (var t = null, i = 0, n = this.attachedBlocks; i < n.length; i++) {
  90411. var r = n[i];
  90412. if (r.name === e) {
  90413. if (t)
  90414. return gi.Warn("More than one block was found with the name `" + e + "`"),
  90415. t;
  90416. t = r
  90417. }
  90418. }
  90419. return t
  90420. }
  90421. ,
  90422. t.prototype.getBlockByPredicate = function(e) {
  90423. for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
  90424. var n = i[t];
  90425. if (e(n))
  90426. return n
  90427. }
  90428. return null
  90429. }
  90430. ,
  90431. t.prototype.getInputBlockByPredicate = function(e) {
  90432. for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
  90433. var n = i[t];
  90434. if (n.isInput && e(n))
  90435. return n
  90436. }
  90437. return null
  90438. }
  90439. ,
  90440. t.prototype.getInputBlocks = function() {
  90441. for (var e = [], t = 0, i = this.attachedBlocks; t < i.length; t++) {
  90442. var n = i[t];
  90443. n.isInput && e.push(n)
  90444. }
  90445. return e
  90446. }
  90447. ,
  90448. t.prototype.registerOptimizer = function(e) {
  90449. if (!(this._optimizers.indexOf(e) > -1))
  90450. return this._optimizers.push(e),
  90451. this
  90452. }
  90453. ,
  90454. t.prototype.unregisterOptimizer = function(e) {
  90455. var t = this._optimizers.indexOf(e);
  90456. if (-1 !== t)
  90457. return this._optimizers.splice(t, 1),
  90458. this
  90459. }
  90460. ,
  90461. t.prototype.addOutputNode = function(e) {
  90462. if (null === e.target)
  90463. throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
  90464. return 0 != (e.target & Dp.Vertex) && this._addVertexOutputNode(e),
  90465. 0 != (e.target & Dp.Fragment) && this._addFragmentOutputNode(e),
  90466. this
  90467. }
  90468. ,
  90469. t.prototype.removeOutputNode = function(e) {
  90470. return null === e.target || (0 != (e.target & Dp.Vertex) && this._removeVertexOutputNode(e),
  90471. 0 != (e.target & Dp.Fragment) && this._removeFragmentOutputNode(e)),
  90472. this
  90473. }
  90474. ,
  90475. t.prototype._addVertexOutputNode = function(e) {
  90476. if (-1 === this._vertexOutputNodes.indexOf(e))
  90477. return e.target = Dp.Vertex,
  90478. this._vertexOutputNodes.push(e),
  90479. this
  90480. }
  90481. ,
  90482. t.prototype._removeVertexOutputNode = function(e) {
  90483. var t = this._vertexOutputNodes.indexOf(e);
  90484. if (-1 !== t)
  90485. return this._vertexOutputNodes.splice(t, 1),
  90486. this
  90487. }
  90488. ,
  90489. t.prototype._addFragmentOutputNode = function(e) {
  90490. if (-1 === this._fragmentOutputNodes.indexOf(e))
  90491. return e.target = Dp.Fragment,
  90492. this._fragmentOutputNodes.push(e),
  90493. this
  90494. }
  90495. ,
  90496. t.prototype._removeFragmentOutputNode = function(e) {
  90497. var t = this._fragmentOutputNodes.indexOf(e);
  90498. if (-1 !== t)
  90499. return this._fragmentOutputNodes.splice(t, 1),
  90500. this
  90501. }
  90502. ,
  90503. t.prototype.needAlphaBlending = function() {
  90504. return !this.ignoreAlpha && (this.forceAlphaBlending || this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending)
  90505. }
  90506. ,
  90507. t.prototype.needAlphaTesting = function() {
  90508. return this._sharedData && this._sharedData.hints.needAlphaTesting
  90509. }
  90510. ,
  90511. t.prototype._initializeBlock = function(e, t, i, n) {
  90512. if (void 0 === n && (n = !0),
  90513. e.initialize(t),
  90514. n && e.autoConfigure(this),
  90515. e._preparationId = this._buildId,
  90516. -1 === this.attachedBlocks.indexOf(e)) {
  90517. if (e.isUnique)
  90518. for (var r = e.getClassName(), o = 0, a = this.attachedBlocks; o < a.length; o++)
  90519. if (a[o].getClassName() === r)
  90520. throw "Cannot have multiple blocks of type ".concat(r, " in the same NodeMaterial");
  90521. this.attachedBlocks.push(e)
  90522. }
  90523. for (var s = 0, l = e.inputs; s < l.length; s++) {
  90524. var c = l[s];
  90525. c.associatedVariableName = "";
  90526. var u = c.connectedPoint;
  90527. if (u) {
  90528. var h = u.ownerBlock;
  90529. h !== e && ((h.target === Dp.VertexAndFragment || t.target === Dp.Fragment && h.target === Dp.Vertex && h._preparationId !== this._buildId) && i.push(h),
  90530. this._initializeBlock(h, t, i, n))
  90531. }
  90532. }
  90533. for (var d = 0, p = e.outputs; d < p.length; d++)
  90534. p[d].associatedVariableName = ""
  90535. }
  90536. ,
  90537. t.prototype._resetDualBlocks = function(e, t) {
  90538. e.target === Dp.VertexAndFragment && (e.buildId = t);
  90539. for (var i = 0, n = e.inputs; i < n.length; i++) {
  90540. var r = n[i].connectedPoint;
  90541. if (r) {
  90542. var o = r.ownerBlock;
  90543. o !== e && this._resetDualBlocks(o, t)
  90544. }
  90545. }
  90546. }
  90547. ,
  90548. t.prototype.removeBlock = function(e) {
  90549. var t = this.attachedBlocks.indexOf(e);
  90550. t > -1 && this.attachedBlocks.splice(t, 1),
  90551. e.isFinalMerger && this.removeOutputNode(e)
  90552. }
  90553. ,
  90554. t.prototype.build = function(e, i, n) {
  90555. void 0 === e && (e = !1),
  90556. void 0 === i && (i = !0),
  90557. void 0 === n && (n = !0),
  90558. this._buildWasSuccessful = !1;
  90559. var r = this.getScene().getEngine()
  90560. , o = this._mode === cf.Particle;
  90561. if (0 === this._vertexOutputNodes.length && !o)
  90562. throw "You must define at least one vertexOutputNode";
  90563. if (0 === this._fragmentOutputNodes.length)
  90564. throw "You must define at least one fragmentOutputNode";
  90565. this._vertexCompilationState = new kp,
  90566. this._vertexCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
  90567. this._vertexCompilationState.target = Dp.Vertex,
  90568. this._fragmentCompilationState = new kp,
  90569. this._fragmentCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
  90570. this._fragmentCompilationState.target = Dp.Fragment,
  90571. this._sharedData = new Gp,
  90572. this._sharedData.fragmentOutputNodes = this._fragmentOutputNodes,
  90573. this._vertexCompilationState.sharedData = this._sharedData,
  90574. this._fragmentCompilationState.sharedData = this._sharedData,
  90575. this._sharedData.buildId = this._buildId,
  90576. this._sharedData.emitComments = this._options.emitComments,
  90577. this._sharedData.verbose = e,
  90578. this._sharedData.scene = this.getScene(),
  90579. this._sharedData.allowEmptyVertexProgram = o;
  90580. for (var a = [], s = [], l = 0, c = this._vertexOutputNodes; l < c.length; l++) {
  90581. var u = c[l];
  90582. a.push(u),
  90583. this._initializeBlock(u, this._vertexCompilationState, s, n)
  90584. }
  90585. for (var h = 0, d = this._fragmentOutputNodes; h < d.length; h++) {
  90586. var p = d[h];
  90587. s.push(p),
  90588. this._initializeBlock(p, this._fragmentCompilationState, a, n)
  90589. }
  90590. this.optimize();
  90591. for (var f = 0, _ = a; f < _.length; f++)
  90592. (u = _[f]).build(this._vertexCompilationState, a);
  90593. this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0),
  90594. this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration,
  90595. this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration,
  90596. this._fragmentCompilationState._vertexState = this._vertexCompilationState;
  90597. for (var m = 0, g = s; m < g.length; m++)
  90598. p = g[m],
  90599. this._resetDualBlocks(p, this._buildId - 1);
  90600. for (var v = 0, y = s; v < y.length; v++)
  90601. (p = y[v]).build(this._fragmentCompilationState, s);
  90602. this._vertexCompilationState.finalize(this._vertexCompilationState),
  90603. this._fragmentCompilationState.finalize(this._fragmentCompilationState),
  90604. i && (this._buildId = t._BuildIdGenerator++),
  90605. this._sharedData.emitErrors(),
  90606. e && (console.log("Vertex shader:"),
  90607. console.log(this._vertexCompilationState.compilationString),
  90608. console.log("Fragment shader:"),
  90609. console.log(this._fragmentCompilationState.compilationString)),
  90610. this._buildWasSuccessful = !0,
  90611. this.onBuildObservable.notifyObservers(this);
  90612. for (var b = 0, T = this.getScene().meshes; b < T.length; b++) {
  90613. var E = T[b];
  90614. if (E.subMeshes)
  90615. for (var S = 0, A = E.subMeshes; S < A.length; S++) {
  90616. var x = A[S];
  90617. if (x.getMaterial() === this && x.materialDefines) {
  90618. var R = x.materialDefines;
  90619. R.markAllAsDirty(),
  90620. R.reset()
  90621. }
  90622. }
  90623. }
  90624. }
  90625. ,
  90626. t.prototype.optimize = function() {
  90627. for (var e = 0, t = this._optimizers; e < t.length; e++)
  90628. t[e].optimize(this._vertexOutputNodes, this._fragmentOutputNodes)
  90629. }
  90630. ,
  90631. t.prototype._prepareDefinesForAttributes = function(e, t) {
  90632. var i = t.NORMAL
  90633. , n = t.TANGENT;
  90634. t.NORMAL = e.isVerticesDataPresent(Bi.NormalKind),
  90635. t.TANGENT = e.isVerticesDataPresent(Bi.TangentKind);
  90636. for (var r = !1, o = 1; o <= a.MAX_SUPPORTED_UV_SETS; ++o) {
  90637. var s = t["UV" + o];
  90638. t["UV" + o] = e.isVerticesDataPresent("uv".concat(1 === o ? "" : o)),
  90639. r = r || t["UV" + o] !== s
  90640. }
  90641. (i !== t.NORMAL || n !== t.TANGENT || r) && t.markAsAttributesDirty()
  90642. }
  90643. ,
  90644. t.prototype.createPostProcess = function(e, t, i, n, r, o, s) {
  90645. return void 0 === t && (t = 1),
  90646. void 0 === i && (i = a.TEXTURE_NEAREST_SAMPLINGMODE),
  90647. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  90648. void 0 === s && (s = a.TEXTUREFORMAT_RGBA),
  90649. this.mode !== cf.PostProcess ? (console.log("Incompatible material mode"),
  90650. null) : this._createEffectForPostProcess(null, e, t, i, n, r, o, s)
  90651. }
  90652. ,
  90653. t.prototype.createEffectForPostProcess = function(e) {
  90654. this._createEffectForPostProcess(e)
  90655. }
  90656. ,
  90657. t.prototype._createEffectForPostProcess = function(e, t, i, n, r, o, s, l) {
  90658. var c = this;
  90659. void 0 === i && (i = 1),
  90660. void 0 === n && (n = a.TEXTURE_NEAREST_SAMPLINGMODE),
  90661. void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT),
  90662. void 0 === l && (l = a.TEXTUREFORMAT_RGBA);
  90663. var u = this.name + this._buildId
  90664. , h = new If
  90665. , d = new Sr(u + "PostProcess",this.getScene())
  90666. , p = this._buildId;
  90667. return this._processDefines(d, h),
  90668. Mt.RegisterShader(u, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString),
  90669. e ? e.updateEffect(h.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, {
  90670. maxSimultaneousLights: this.maxSimultaneousLights
  90671. }, void 0, void 0, u, u) : e = new Ba(this.name + "PostProcess",u,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,n,r,o,h.toString(),s,u,{
  90672. maxSimultaneousLights: this.maxSimultaneousLights
  90673. },!1,l),
  90674. e.nodeMaterialSource = this,
  90675. e.onApplyObservable.add((function(t) {
  90676. p !== c._buildId && (delete Mt.ShadersStore[u + "VertexShader"],
  90677. delete Mt.ShadersStore[u + "PixelShader"],
  90678. u = c.name + c._buildId,
  90679. h.markAllAsDirty(),
  90680. p = c._buildId),
  90681. c._processDefines(d, h) && (Mt.RegisterShader(u, c._fragmentCompilationState._builtCompilationString, c._vertexCompilationState._builtCompilationString),
  90682. Xt.SetImmediate((function() {
  90683. return e.updateEffect(h.toString(), c._fragmentCompilationState.uniforms, c._fragmentCompilationState.samplers, {
  90684. maxSimultaneousLights: c.maxSimultaneousLights
  90685. }, void 0, void 0, u, u)
  90686. }
  90687. ))),
  90688. c._checkInternals(t)
  90689. }
  90690. )),
  90691. e
  90692. }
  90693. ,
  90694. t.prototype.createProceduralTexture = function(e, t) {
  90695. var i = this;
  90696. if (this.mode !== cf.ProceduralTexture)
  90697. return console.log("Incompatible material mode"),
  90698. null;
  90699. var n = this.name + this._buildId
  90700. , r = new xf(n,e,null,t)
  90701. , o = new Sr(n + "Procedural",this.getScene());
  90702. o.reservedDataStore = {
  90703. hidden: !0
  90704. };
  90705. var a = new If
  90706. , s = this._processDefines(o, a);
  90707. Mt.RegisterShader(n, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
  90708. var l = this.getScene().getEngine().createEffect({
  90709. vertexElement: n,
  90710. fragmentElement: n
  90711. }, [Bi.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, a.toString(), null == s ? void 0 : s.fallbacks, void 0);
  90712. r.nodeMaterialSource = this,
  90713. r._setEffect(l);
  90714. var c = this._buildId;
  90715. return r.onBeforeGenerationObservable.add((function() {
  90716. c !== i._buildId && (delete Mt.ShadersStore[n + "VertexShader"],
  90717. delete Mt.ShadersStore[n + "PixelShader"],
  90718. n = i.name + i._buildId,
  90719. a.markAllAsDirty(),
  90720. c = i._buildId);
  90721. var e = i._processDefines(o, a);
  90722. e && (Mt.RegisterShader(n, i._fragmentCompilationState._builtCompilationString, i._vertexCompilationState._builtCompilationString),
  90723. Xt.SetImmediate((function() {
  90724. l = i.getScene().getEngine().createEffect({
  90725. vertexElement: n,
  90726. fragmentElement: n
  90727. }, [Bi.PositionKind], i._fragmentCompilationState.uniforms, i._fragmentCompilationState.samplers, a.toString(), null == e ? void 0 : e.fallbacks, void 0),
  90728. r._setEffect(l)
  90729. }
  90730. ))),
  90731. i._checkInternals(l)
  90732. }
  90733. )),
  90734. r
  90735. }
  90736. ,
  90737. t.prototype._createEffectForParticles = function(e, t, i, n, r, o, a, s) {
  90738. var l = this;
  90739. void 0 === s && (s = "");
  90740. var c = this.name + this._buildId + "_" + t;
  90741. o || (o = new If),
  90742. a || (a = this.getScene().getMeshByName(this.name + "Particle")) || ((a = new Sr(this.name + "Particle",this.getScene())).reservedDataStore = {
  90743. hidden: !0
  90744. });
  90745. var u = this._buildId
  90746. , h = []
  90747. , d = s;
  90748. if (!r) {
  90749. var p = this._processDefines(a, o);
  90750. Mt.RegisterShader(c, this._fragmentCompilationState._builtCompilationString),
  90751. e.fillDefines(h, t),
  90752. d = h.join("\n"),
  90753. r = this.getScene().getEngine().createEffectForParticles(c, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == p ? void 0 : p.fallbacks, i, n, e),
  90754. e.setCustomEffect(r, t)
  90755. }
  90756. r.onBindObservable.add((function(r) {
  90757. u !== l._buildId && (delete Mt.ShadersStore[c + "PixelShader"],
  90758. c = l.name + l._buildId + "_" + t,
  90759. o.markAllAsDirty(),
  90760. u = l._buildId),
  90761. h.length = 0,
  90762. e.fillDefines(h, t);
  90763. var p = h.join("\n");
  90764. p !== d && (o.markAllAsDirty(),
  90765. d = p);
  90766. var f = l._processDefines(a, o);
  90767. if (f)
  90768. return Mt.RegisterShader(c, l._fragmentCompilationState._builtCompilationString),
  90769. r = l.getScene().getEngine().createEffectForParticles(c, l._fragmentCompilationState.uniforms, l._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == f ? void 0 : f.fallbacks, i, n, e),
  90770. e.setCustomEffect(r, t),
  90771. void l._createEffectForParticles(e, t, i, n, r, o, a, s);
  90772. l._checkInternals(r)
  90773. }
  90774. ))
  90775. }
  90776. ,
  90777. t.prototype._checkInternals = function(e) {
  90778. if (this._sharedData.animatedInputs) {
  90779. var t = this.getScene()
  90780. , i = t.getFrameId();
  90781. if (this._animationFrame !== i) {
  90782. for (var n = 0, r = this._sharedData.animatedInputs; n < r.length; n++)
  90783. r[n].animate(t);
  90784. this._animationFrame = i
  90785. }
  90786. }
  90787. for (var o = 0, a = this._sharedData.bindableBlocks; o < a.length; o++)
  90788. a[o].bind(e, this);
  90789. for (var s = 0, l = this._sharedData.inputBlocks; s < l.length; s++)
  90790. l[s]._transmit(e, this.getScene(), this)
  90791. }
  90792. ,
  90793. t.prototype.createEffectForParticles = function(e, t, i) {
  90794. this.mode === cf.Particle ? (this._createEffectForParticles(e, Tf.BLENDMODE_ONEONE, t, i),
  90795. this._createEffectForParticles(e, Tf.BLENDMODE_MULTIPLY, t, i)) : console.log("Incompatible material mode")
  90796. }
  90797. ,
  90798. t.prototype._processDefines = function(e, t, i, n) {
  90799. var r = this;
  90800. void 0 === i && (i = !1);
  90801. var o = null;
  90802. if (this._sharedData.blocksWithDefines.forEach((function(n) {
  90803. n.initializeDefines(e, r, t, i)
  90804. }
  90805. )),
  90806. this._sharedData.blocksWithDefines.forEach((function(o) {
  90807. o.prepareDefines(e, r, t, i, n)
  90808. }
  90809. )),
  90810. t.isDirty) {
  90811. var a = t._areLightsDisposed;
  90812. t.markAsProcessed(),
  90813. this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
  90814. this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
  90815. this._sharedData.repeatableContentBlocks.forEach((function(i) {
  90816. i.replaceRepeatableContent(r._vertexCompilationState, r._fragmentCompilationState, e, t)
  90817. }
  90818. ));
  90819. var s = [];
  90820. this._sharedData.dynamicUniformBlocks.forEach((function(e) {
  90821. e.updateUniformsAndSamples(r._vertexCompilationState, r, t, s)
  90822. }
  90823. ));
  90824. var l = this._vertexCompilationState.uniforms;
  90825. this._fragmentCompilationState.uniforms.forEach((function(e) {
  90826. -1 === l.indexOf(e) && l.push(e)
  90827. }
  90828. ));
  90829. var c = this._vertexCompilationState.samplers;
  90830. this._fragmentCompilationState.samplers.forEach((function(e) {
  90831. -1 === c.indexOf(e) && c.push(e)
  90832. }
  90833. ));
  90834. var u = new ys;
  90835. this._sharedData.blocksWithFallbacks.forEach((function(t) {
  90836. t.provideFallbacks(e, u)
  90837. }
  90838. )),
  90839. o = {
  90840. lightDisposed: a,
  90841. uniformBuffers: s,
  90842. mergedUniforms: l,
  90843. mergedSamplers: c,
  90844. fallbacks: u
  90845. }
  90846. }
  90847. return o
  90848. }
  90849. ,
  90850. t.prototype.isReadyForSubMesh = function(e, t, i) {
  90851. var n = this;
  90852. if (void 0 === i && (i = !1),
  90853. !this._buildWasSuccessful)
  90854. return !1;
  90855. var r = this.getScene();
  90856. if (this._sharedData.animatedInputs) {
  90857. var o = r.getFrameId();
  90858. if (this._animationFrame !== o) {
  90859. for (var a = 0, s = this._sharedData.animatedInputs; a < s.length; a++)
  90860. s[a].animate(r);
  90861. this._animationFrame = o
  90862. }
  90863. }
  90864. if (t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
  90865. return !0;
  90866. t.materialDefines || (t.materialDefines = new If);
  90867. var l = t.materialDefines;
  90868. if (this._isReadyForSubMesh(t))
  90869. return !0;
  90870. var c = r.getEngine();
  90871. if (this._prepareDefinesForAttributes(e, l),
  90872. this._sharedData.blockingBlocks.some((function(t) {
  90873. return !t.isReady(e, n, l, i)
  90874. }
  90875. )))
  90876. return !1;
  90877. var u = this._processDefines(e, l, i, t);
  90878. if (u) {
  90879. var h = t.effect
  90880. , d = l.toString()
  90881. , p = c.createEffect({
  90882. vertex: "nodeMaterial" + this._buildId,
  90883. fragment: "nodeMaterial" + this._buildId,
  90884. vertexSource: this._vertexCompilationState.compilationString,
  90885. fragmentSource: this._fragmentCompilationState.compilationString
  90886. }, {
  90887. attributes: this._vertexCompilationState.attributes,
  90888. uniformsNames: u.mergedUniforms,
  90889. uniformBuffersNames: u.uniformBuffers,
  90890. samplers: u.mergedSamplers,
  90891. defines: d,
  90892. fallbacks: u.fallbacks,
  90893. onCompiled: this.onCompiled,
  90894. onError: this.onError,
  90895. indexParameters: {
  90896. maxSimultaneousLights: this.maxSimultaneousLights,
  90897. maxSimultaneousMorphTargets: l.NUM_MORPH_INFLUENCERS
  90898. }
  90899. }, c);
  90900. if (p)
  90901. if (this._onEffectCreatedObservable && (Mf.effect = p,
  90902. Mf.subMesh = t,
  90903. this._onEffectCreatedObservable.notifyObservers(Mf)),
  90904. this.allowShaderHotSwapping && h && !p.isReady()) {
  90905. if (p = h,
  90906. l.markAsUnprocessed(),
  90907. u.lightDisposed)
  90908. return l._areLightsDisposed = !0,
  90909. !1
  90910. } else
  90911. r.resetCachedMaterial(),
  90912. t.setEffect(p, l, this._materialContext)
  90913. }
  90914. return !(!t.effect || !t.effect.isReady() || (l._renderId = r.getRenderId(),
  90915. t.effect._wasPreviouslyReady = !0,
  90916. 0))
  90917. }
  90918. ,
  90919. Object.defineProperty(t.prototype, "compiledShaders", {
  90920. get: function() {
  90921. return "// Vertex shader\r\n".concat(this._vertexCompilationState.compilationString, "\r\n\r\n// Fragment shader\r\n").concat(this._fragmentCompilationState.compilationString)
  90922. },
  90923. enumerable: !1,
  90924. configurable: !0
  90925. }),
  90926. t.prototype.bindOnlyWorldMatrix = function(e) {
  90927. var t = this.getScene();
  90928. if (this._activeEffect) {
  90929. var i = this._sharedData.hints;
  90930. i.needWorldViewMatrix && e.multiplyToRef(t.getViewMatrix(), this._cachedWorldViewMatrix),
  90931. i.needWorldViewProjectionMatrix && e.multiplyToRef(t.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
  90932. for (var n = 0, r = this._sharedData.inputBlocks; n < r.length; n++)
  90933. r[n]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
  90934. }
  90935. }
  90936. ,
  90937. t.prototype.bindForSubMesh = function(e, t, i) {
  90938. var n = this.getScene()
  90939. , r = i.effect;
  90940. if (r) {
  90941. this._activeEffect = r,
  90942. this.bindOnlyWorldMatrix(e);
  90943. var o = this._mustRebind(n, r, t.visibility)
  90944. , a = this._sharedData;
  90945. if (o) {
  90946. for (var s = 0, l = a.bindableBlocks; s < l.length; s++)
  90947. l[s].bind(r, this, t, i);
  90948. for (var c = 0, u = a.forcedBindableBlocks; c < u.length; c++)
  90949. u[c].bind(r, this, t, i);
  90950. for (var h = 0, d = a.inputBlocks; h < d.length; h++)
  90951. d[h]._transmit(r, n, this)
  90952. } else if (!this.isFrozen)
  90953. for (var p = 0, f = a.forcedBindableBlocks; p < f.length; p++)
  90954. f[p].bind(r, this, t, i);
  90955. this._afterBind(t, this._activeEffect)
  90956. }
  90957. }
  90958. ,
  90959. t.prototype.getActiveTextures = function() {
  90960. var t = e.prototype.getActiveTextures.call(this);
  90961. return this._sharedData && t.push.apply(t, this._sharedData.textureBlocks.filter((function(e) {
  90962. return e.texture
  90963. }
  90964. )).map((function(e) {
  90965. return e.texture
  90966. }
  90967. ))),
  90968. t
  90969. }
  90970. ,
  90971. t.prototype.getTextureBlocks = function() {
  90972. return this._sharedData ? this._sharedData.textureBlocks : []
  90973. }
  90974. ,
  90975. t.prototype.hasTexture = function(t) {
  90976. if (e.prototype.hasTexture.call(this, t))
  90977. return !0;
  90978. if (!this._sharedData)
  90979. return !1;
  90980. for (var i = 0, n = this._sharedData.textureBlocks; i < n.length; i++)
  90981. if (n[i].texture === t)
  90982. return !0;
  90983. return !1
  90984. }
  90985. ,
  90986. t.prototype.dispose = function(t, i, n) {
  90987. if (i)
  90988. for (var r = 0, o = this.getTextureBlocks().filter((function(e) {
  90989. return e.texture
  90990. }
  90991. )).map((function(e) {
  90992. return e.texture
  90993. }
  90994. )); r < o.length; r++)
  90995. o[r].dispose();
  90996. for (var a = 0, s = this.attachedBlocks; a < s.length; a++)
  90997. s[a].dispose();
  90998. this.attachedBlocks = [],
  90999. this._sharedData = null,
  91000. this._vertexCompilationState = null,
  91001. this._fragmentCompilationState = null,
  91002. this.onBuildObservable.clear(),
  91003. this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
  91004. this._imageProcessingObserver = null),
  91005. e.prototype.dispose.call(this, t, i, n)
  91006. }
  91007. ,
  91008. t.prototype._createNodeEditor = function() {
  91009. this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
  91010. nodeMaterial: this
  91011. })
  91012. }
  91013. ,
  91014. t.prototype.edit = function(e) {
  91015. var i = this;
  91016. return new Promise((function(n) {
  91017. if (i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
  91018. void 0 === i.BJSNODEMATERIALEDITOR) {
  91019. var r = e && e.editorURL ? e.editorURL : t.EditorURL;
  91020. gi.LoadScript(r, (function() {
  91021. i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
  91022. i._createNodeEditor(),
  91023. n()
  91024. }
  91025. ))
  91026. } else
  91027. i._createNodeEditor(),
  91028. n()
  91029. }
  91030. ))
  91031. }
  91032. ,
  91033. t.prototype.clear = function() {
  91034. this._vertexOutputNodes = [],
  91035. this._fragmentOutputNodes = [],
  91036. this.attachedBlocks = []
  91037. }
  91038. ,
  91039. t.prototype.setToDefault = function() {
  91040. this.clear(),
  91041. this.editorData = null;
  91042. var e = new tf("Position");
  91043. e.setAsAttribute("position");
  91044. var t = new tf("World");
  91045. t.setAsSystemValue(Qp.World);
  91046. var i = new Hp("WorldPos");
  91047. e.connectTo(i),
  91048. t.connectTo(i);
  91049. var n = new tf("ViewProjection");
  91050. n.setAsSystemValue(Qp.ViewProjection);
  91051. var r = new Hp("WorldPos * ViewProjectionTransform");
  91052. i.connectTo(r),
  91053. n.connectTo(r);
  91054. var o = new jp("VertexOutput");
  91055. r.connectTo(o);
  91056. var a = new tf("color");
  91057. a.value = new N(.8,.8,.8,1);
  91058. var s = new Zp("FragmentOutput");
  91059. a.connectTo(s),
  91060. this.addOutputNode(o),
  91061. this.addOutputNode(s),
  91062. this._mode = cf.Material
  91063. }
  91064. ,
  91065. t.prototype.setToDefaultPostProcess = function() {
  91066. this.clear(),
  91067. this.editorData = null;
  91068. var e = new tf("Position");
  91069. e.setAsAttribute("position2d");
  91070. var t = new tf("Constant1");
  91071. t.isConstant = !0,
  91072. t.value = 1;
  91073. var i = new sf("Position3D");
  91074. e.connectTo(i),
  91075. t.connectTo(i, {
  91076. input: "w"
  91077. });
  91078. var n = new jp("VertexOutput");
  91079. i.connectTo(n);
  91080. var r = new tf("Scale");
  91081. r.visibleInInspector = !0,
  91082. r.value = new A(1,1);
  91083. var o = new lf("uv0");
  91084. e.connectTo(o);
  91085. var a = new uf("UV scale");
  91086. o.connectTo(a),
  91087. r.connectTo(a);
  91088. var s = new nf("CurrentScreen");
  91089. a.connectTo(s),
  91090. s.texture = new io("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
  91091. var l = new Zp("FragmentOutput");
  91092. s.connectTo(l, {
  91093. output: "rgba"
  91094. }),
  91095. this.addOutputNode(n),
  91096. this.addOutputNode(l),
  91097. this._mode = cf.PostProcess
  91098. }
  91099. ,
  91100. t.prototype.setToDefaultProceduralTexture = function() {
  91101. this.clear(),
  91102. this.editorData = null;
  91103. var e = new tf("Position");
  91104. e.setAsAttribute("position2d");
  91105. var t = new tf("Constant1");
  91106. t.isConstant = !0,
  91107. t.value = 1;
  91108. var i = new sf("Position3D");
  91109. e.connectTo(i),
  91110. t.connectTo(i, {
  91111. input: "w"
  91112. });
  91113. var n = new jp("VertexOutput");
  91114. i.connectTo(n);
  91115. var r = new tf("Time");
  91116. r.value = 0,
  91117. r.min = 0,
  91118. r.max = 0,
  91119. r.isBoolean = !1,
  91120. r.matrixMode = 0,
  91121. r.animationType = qp.Time,
  91122. r.isConstant = !1;
  91123. var o = new tf("Color3");
  91124. o.value = new D(1,1,1),
  91125. o.isConstant = !1;
  91126. var a = new Zp("FragmentOutput")
  91127. , s = new sf("VectorMerger");
  91128. s.visibleInInspector = !1;
  91129. var l = new Rf("Cos");
  91130. l.operation = Af.Cos,
  91131. e.connectTo(s),
  91132. r.output.connectTo(l.input),
  91133. l.output.connectTo(s.z),
  91134. s.xyzOut.connectTo(a.rgb),
  91135. this.addOutputNode(n),
  91136. this.addOutputNode(a),
  91137. this._mode = cf.ProceduralTexture
  91138. }
  91139. ,
  91140. t.prototype.setToDefaultParticle = function() {
  91141. this.clear(),
  91142. this.editorData = null;
  91143. var e = new tf("uv");
  91144. e.setAsAttribute("particle_uv");
  91145. var t = new rf("ParticleTexture");
  91146. e.connectTo(t);
  91147. var i = new tf("Color");
  91148. i.setAsAttribute("particle_color");
  91149. var n = new uf("Texture * Color");
  91150. t.connectTo(n),
  91151. i.connectTo(n);
  91152. var r = new of("ParticleRampGradient");
  91153. n.connectTo(r);
  91154. var o = new Ef("ColorSplitter");
  91155. i.connectTo(o);
  91156. var a = new af("ParticleBlendMultiply");
  91157. r.connectTo(a),
  91158. t.connectTo(a, {
  91159. output: "a"
  91160. }),
  91161. o.connectTo(a, {
  91162. output: "a"
  91163. });
  91164. var s = new Zp("FragmentOutput");
  91165. a.connectTo(s),
  91166. this.addOutputNode(s),
  91167. this._mode = cf.Particle
  91168. }
  91169. ,
  91170. t.prototype.loadAsync = function(e, t) {
  91171. var i = this;
  91172. return void 0 === t && (t = ""),
  91173. this.getScene()._loadFileAsync(e).then((function(e) {
  91174. var n = JSON.parse(e);
  91175. i.loadFromSerialization(n, t)
  91176. }
  91177. ))
  91178. }
  91179. ,
  91180. t.prototype._gatherBlocks = function(e, t) {
  91181. if (-1 === t.indexOf(e)) {
  91182. t.push(e);
  91183. for (var i = 0, n = e.inputs; i < n.length; i++) {
  91184. var r = n[i].connectedPoint;
  91185. if (r) {
  91186. var o = r.ownerBlock;
  91187. o !== e && this._gatherBlocks(o, t)
  91188. }
  91189. }
  91190. }
  91191. }
  91192. ,
  91193. t.prototype.generateCode = function() {
  91194. for (var e = [], t = [], i = ["const", "var", "let"], n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
  91195. var o = r[n];
  91196. this._gatherBlocks(o, t)
  91197. }
  91198. for (var a = [], s = 0, l = this._fragmentOutputNodes; s < l.length; s++)
  91199. o = l[s],
  91200. this._gatherBlocks(o, a);
  91201. for (var c = 'var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name || "node material", '");\r\n'), u = 0, h = t; u < h.length; u++)
  91202. (b = h[u]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e));
  91203. for (var d = 0, p = a; d < p.length; d++)
  91204. (b = p[d]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e));
  91205. e = [],
  91206. c += "\r\n// Connections\r\n";
  91207. for (var f = 0, _ = this._vertexOutputNodes; f < _.length; f++)
  91208. c += (b = _[f])._dumpCodeForOutputConnections(e);
  91209. for (var m = 0, g = this._fragmentOutputNodes; m < g.length; m++)
  91210. c += (b = g[m])._dumpCodeForOutputConnections(e);
  91211. c += "\r\n// Output nodes\r\n";
  91212. for (var v = 0, y = this._vertexOutputNodes; v < y.length; v++) {
  91213. var b = y[v];
  91214. c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n")
  91215. }
  91216. for (var T = 0, E = this._fragmentOutputNodes; T < E.length; T++)
  91217. b = E[T],
  91218. c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n");
  91219. return c + "nodeMaterial.build();\r\n"
  91220. }
  91221. ,
  91222. t.prototype.serialize = function(e) {
  91223. var t = e ? {} : Ge.Serialize(this);
  91224. t.editorData = JSON.parse(JSON.stringify(this.editorData));
  91225. var i = [];
  91226. if (e)
  91227. i = e;
  91228. else {
  91229. t.customType = "BABYLON.NodeMaterial",
  91230. t.outputNodes = [];
  91231. for (var n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
  91232. var o = r[n];
  91233. this._gatherBlocks(o, i),
  91234. t.outputNodes.push(o.uniqueId)
  91235. }
  91236. for (var a = 0, s = this._fragmentOutputNodes; a < s.length; a++)
  91237. o = s[a],
  91238. this._gatherBlocks(o, i),
  91239. -1 === t.outputNodes.indexOf(o.uniqueId) && t.outputNodes.push(o.uniqueId)
  91240. }
  91241. t.blocks = [];
  91242. for (var l = 0, c = i; l < c.length; l++) {
  91243. var u = c[l];
  91244. t.blocks.push(u.serialize())
  91245. }
  91246. if (!e)
  91247. for (var h = 0, d = this.attachedBlocks; h < d.length; h++)
  91248. u = d[h],
  91249. -1 === i.indexOf(u) && t.blocks.push(u.serialize());
  91250. return t
  91251. }
  91252. ,
  91253. t.prototype._restoreConnections = function(e, t, i) {
  91254. for (var n = 0, r = e.outputs; n < r.length; n++)
  91255. for (var o = r[n], a = 0, s = t.blocks; a < s.length; a++) {
  91256. var l = s[a]
  91257. , c = i[l.id];
  91258. if (c)
  91259. for (var u = 0, h = l.inputs; u < h.length; u++) {
  91260. var d = h[u];
  91261. if (i[d.targetBlockId] !== e || d.targetConnectionName !== o.name)
  91262. ;
  91263. else {
  91264. var p = c.getInputByName(d.inputName);
  91265. if (!p || p.isConnected)
  91266. continue;
  91267. o.connectTo(p, !0),
  91268. this._restoreConnections(c, t, i)
  91269. }
  91270. }
  91271. }
  91272. }
  91273. ,
  91274. t.prototype.loadFromSerialization = function(e, t, i) {
  91275. var n;
  91276. void 0 === t && (t = ""),
  91277. void 0 === i && (i = !1),
  91278. i || this.clear();
  91279. for (var r = {}, o = 0, a = e.blocks; o < a.length; o++) {
  91280. var s = b((c = a[o]).customType);
  91281. s && ((u = new s)._deserialize(c, this.getScene(), t),
  91282. r[c.id] = u,
  91283. this.attachedBlocks.push(u))
  91284. }
  91285. for (var l = 0; l < e.blocks.length; l++) {
  91286. var c, u;
  91287. (u = r[(c = e.blocks[l]).id]) && (u.inputs.length && !i || this._restoreConnections(u, e, r))
  91288. }
  91289. if (e.outputNodes)
  91290. for (var h = 0, d = e.outputNodes; h < d.length; h++) {
  91291. var p = d[h];
  91292. this.addOutputNode(r[p])
  91293. }
  91294. if (e.locations || e.editorData && e.editorData.locations) {
  91295. for (var f = e.locations || e.editorData.locations, _ = 0, m = f; _ < m.length; _++) {
  91296. var g = m[_];
  91297. r[g.blockId] && (g.blockId = r[g.blockId].uniqueId)
  91298. }
  91299. i && this.editorData && this.editorData.locations && f.concat(this.editorData.locations),
  91300. e.locations ? this.editorData = {
  91301. locations: f
  91302. } : (this.editorData = e.editorData,
  91303. this.editorData.locations = f);
  91304. var v = [];
  91305. for (var y in r)
  91306. v[y] = r[y].uniqueId;
  91307. this.editorData.map = v
  91308. }
  91309. this.comment = e.comment,
  91310. void 0 !== e.forceAlphaBlending && (this.forceAlphaBlending = e.forceAlphaBlending),
  91311. i || (this._mode = null !== (n = e.mode) && void 0 !== n ? n : cf.Material)
  91312. }
  91313. ,
  91314. t.prototype.clone = function(e, i) {
  91315. var n = this;
  91316. void 0 === i && (i = !1);
  91317. var r = this.serialize()
  91318. , o = Ge.Clone((function() {
  91319. return new t(e,n.getScene(),n.options)
  91320. }
  91321. ), this);
  91322. return o.id = e,
  91323. o.name = e,
  91324. o.loadFromSerialization(r),
  91325. o._buildId = this._buildId,
  91326. o.build(!1, !i),
  91327. o
  91328. }
  91329. ,
  91330. t.Parse = function(e, i, n) {
  91331. void 0 === n && (n = "");
  91332. var r = Ge.Parse((function() {
  91333. return new t(e.name,i)
  91334. }
  91335. ), e, i, n);
  91336. return r.loadFromSerialization(e, n),
  91337. r.build(),
  91338. r
  91339. }
  91340. ,
  91341. t.ParseFromFileAsync = function(e, i, n, r) {
  91342. void 0 === r && (r = "");
  91343. var o = new t(e,n);
  91344. return new Promise((function(e, t) {
  91345. return o.loadAsync(i, r).then((function() {
  91346. o.build(),
  91347. e(o)
  91348. }
  91349. )).catch(t)
  91350. }
  91351. ))
  91352. }
  91353. ,
  91354. t.ParseFromSnippetAsync = function(e, i, n, r) {
  91355. var o = this;
  91356. return void 0 === n && (n = ""),
  91357. "_BLANK" === e ? Promise.resolve(this.CreateDefault("blank", i)) : new Promise((function(a, s) {
  91358. var l = new Ye;
  91359. l.addEventListener("readystatechange", (function() {
  91360. if (4 == l.readyState)
  91361. if (200 == l.status) {
  91362. var o = JSON.parse(JSON.parse(l.responseText).jsonPayload)
  91363. , c = JSON.parse(o.nodeMaterial);
  91364. r || ((r = Ge.Parse((function() {
  91365. return new t(e,i)
  91366. }
  91367. ), c, i, n)).uniqueId = i.getUniqueId()),
  91368. r.loadFromSerialization(c),
  91369. r.snippetId = e;
  91370. try {
  91371. r.build(),
  91372. a(r)
  91373. } catch (e) {
  91374. s(e)
  91375. }
  91376. } else
  91377. s("Unable to load the snippet " + e)
  91378. }
  91379. )),
  91380. l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")),
  91381. l.send()
  91382. }
  91383. ))
  91384. }
  91385. ,
  91386. t.CreateDefault = function(e, i) {
  91387. var n = new t(e,i);
  91388. return n.setToDefault(),
  91389. n.build(),
  91390. n
  91391. }
  91392. ,
  91393. t._BuildIdGenerator = 0,
  91394. t.EditorURL = "https://unpkg.com/babylonjs-node-editor@".concat(vr.Version, "/babylon.nodeEditor.js"),
  91395. t.SnippetUrl = "https://snippet.babylonjs.com",
  91396. t.IgnoreTexturesAtLoadTime = !1,
  91397. k([Ce()], t.prototype, "ignoreAlpha", void 0),
  91398. k([Ce()], t.prototype, "maxSimultaneousLights", void 0),
  91399. k([Ce("mode")], t.prototype, "_mode", void 0),
  91400. k([Ce("comment")], t.prototype, "comment", void 0),
  91401. k([Ce()], t.prototype, "forceAlphaBlending", void 0),
  91402. t
  91403. }(gs);
  91404. y("BABYLON.NodeMaterial", Of),
  91405. hr.prototype._projectOnTrianglesToRef = function(e, t, i, n, r, o) {
  91406. for (var a = I.Vector3[0], s = I.Vector3[1], l = 1 / 0, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
  91407. var u = i[c]
  91408. , h = i[c + 1]
  91409. , d = i[c + 2];
  91410. if (r && 4294967295 === d)
  91411. c += 2;
  91412. else {
  91413. var p = t[u]
  91414. , f = t[h]
  91415. , _ = t[d];
  91416. if (p && f && _) {
  91417. var m = x.ProjectOnTriangleToRef(e, p, f, _, s);
  91418. m < l && (a.copyFrom(s),
  91419. l = m)
  91420. }
  91421. }
  91422. }
  91423. return o.copyFrom(a),
  91424. l
  91425. }
  91426. ,
  91427. hr.prototype._projectOnUnIndexedTrianglesToRef = function(e, t, i, n) {
  91428. for (var r = I.Vector3[0], o = I.Vector3[1], a = 1 / 0, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) {
  91429. var l = t[s]
  91430. , c = t[s + 1]
  91431. , u = t[s + 2]
  91432. , h = x.ProjectOnTriangleToRef(e, l, c, u, o);
  91433. h < a && (r.copyFrom(o),
  91434. a = h)
  91435. }
  91436. return n.copyFrom(r),
  91437. a
  91438. }
  91439. ,
  91440. hr.prototype.projectToRef = function(e, t, i, n) {
  91441. var r = this.getMaterial();
  91442. if (!r)
  91443. return -1;
  91444. var o = 3
  91445. , s = !1;
  91446. switch (r.fillMode) {
  91447. case a.MATERIAL_PointListDrawMode:
  91448. case a.MATERIAL_LineLoopDrawMode:
  91449. case a.MATERIAL_LineStripDrawMode:
  91450. case a.MATERIAL_TriangleFanDrawMode:
  91451. return -1;
  91452. case a.MATERIAL_TriangleStripDrawMode:
  91453. o = 1,
  91454. s = !0
  91455. }
  91456. return r.fillMode === a.MATERIAL_LineListDrawMode ? -1 : !i.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(e, t, i, n) : this._projectOnTrianglesToRef(e, t, i, o, s, n)
  91457. }
  91458. ,
  91459. function(e) {
  91460. e[e.DEHYDRATED = 0] = "DEHYDRATED",
  91461. e[e.HOVER = 1] = "HOVER",
  91462. e[e.TOUCH = 2] = "TOUCH"
  91463. }(Cf || (Cf = {})),
  91464. function(e) {
  91465. e[e.DISABLED = 0] = "DISABLED",
  91466. e[e.CENTERED_ON_CONTROLLER = 1] = "CENTERED_ON_CONTROLLER",
  91467. e[e.CENTERED_IN_FRONT = 2] = "CENTERED_IN_FRONT"
  91468. }(Pf || (Pf = {}));
  91469. var Df = function(e) {
  91470. function t(i, n) {
  91471. var r = e.call(this, i) || this;
  91472. return r._options = n,
  91473. r._tmpRay = new _o(new x,new x),
  91474. r._attachController = function(e) {
  91475. if (!r._controllers[e.uniqueId]) {
  91476. var i = r._generateNewTouchPointMesh()
  91477. , n = i.touchCollisionMesh
  91478. , o = i.touchCollisionMeshFunction
  91479. , a = i.hydrateCollisionMeshFunction
  91480. , s = r._generateVisualCue();
  91481. switch (r._controllers[e.uniqueId] = {
  91482. xrController: e,
  91483. meshUnderPointer: null,
  91484. nearInteractionTargetMesh: null,
  91485. pick: null,
  91486. stalePick: null,
  91487. touchCollisionMesh: n,
  91488. touchCollisionMeshFunction: o,
  91489. hydrateCollisionMeshFunction: a,
  91490. currentAnimationState: Cf.DEHYDRATED,
  91491. grabRay: new _o(new x,new x),
  91492. hoverInteraction: !1,
  91493. nearInteraction: !1,
  91494. grabInteraction: !1,
  91495. id: t._IdCounter++,
  91496. pickedPointVisualCue: s
  91497. },
  91498. r._attachedController ? !r._options.enableNearInteractionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enableNearInteractionOnAllControllers || (r._attachedController = e.uniqueId),
  91499. e.inputSource.targetRayMode) {
  91500. case "tracked-pointer":
  91501. return r._attachNearInteractionMode(e);
  91502. case "gaze":
  91503. case "screen":
  91504. return null
  91505. }
  91506. }
  91507. }
  91508. ,
  91509. r._controllers = {},
  91510. r._farInteractionFeature = null,
  91511. r.selectionMeshDefaultColor = new D(.8,.8,.8),
  91512. r.selectionMeshPickedColor = new D(.3,.3,1),
  91513. r._hoverRadius = .1,
  91514. r._pickRadius = .02,
  91515. r._controllerPickRadius = .03,
  91516. r._nearGrabLengthScale = 5,
  91517. r._scene = r._xrSessionManager.scene,
  91518. void 0 === r._options.nearInteractionControllerMode && (r._options.nearInteractionControllerMode = Pf.CENTERED_IN_FRONT),
  91519. r._options.farInteractionFeature && (r._farInteractionFeature = r._options.farInteractionFeature),
  91520. r
  91521. }
  91522. return U(t, e),
  91523. t.prototype.attach = function() {
  91524. var t = this;
  91525. return !!e.prototype.attach.call(this) && (this._options.xrInput.controllers.forEach(this._attachController),
  91526. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  91527. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function(e) {
  91528. t._detachController(e.uniqueId)
  91529. }
  91530. )),
  91531. this._scene.constantlyUpdateMeshUnderPointer = !0,
  91532. !0)
  91533. }
  91534. ,
  91535. t.prototype.detach = function() {
  91536. var t = this;
  91537. return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
  91538. t._detachController(e)
  91539. }
  91540. )),
  91541. !0)
  91542. }
  91543. ,
  91544. t.prototype.getMeshUnderPointer = function(e) {
  91545. return this._controllers[e] ? this._controllers[e].meshUnderPointer : null
  91546. }
  91547. ,
  91548. t.prototype.getXRControllerByPointerId = function(e) {
  91549. for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
  91550. if (this._controllers[t[i]].id === e)
  91551. return this._controllers[t[i]].xrController || null;
  91552. return null
  91553. }
  91554. ,
  91555. t.prototype.setFarInteractionFeature = function(e) {
  91556. this._farInteractionFeature = e
  91557. }
  91558. ,
  91559. t.prototype._nearPickPredicate = function(e) {
  91560. return e.isEnabled() && e.isVisible && e.isPickable && e.isNearPickable
  91561. }
  91562. ,
  91563. t.prototype._nearGrabPredicate = function(e) {
  91564. return e.isEnabled() && e.isVisible && e.isPickable && e.isNearGrabbable
  91565. }
  91566. ,
  91567. t.prototype._nearInteractionPredicate = function(e) {
  91568. return e.isEnabled() && e.isVisible && e.isPickable && (e.isNearPickable || e.isNearGrabbable)
  91569. }
  91570. ,
  91571. t.prototype._controllerAvailablePredicate = function(e, t) {
  91572. for (var i = e; i; ) {
  91573. if (i.reservedDataStore && i.reservedDataStore.nearInteraction && i.reservedDataStore.nearInteraction.excludedControllerId === t)
  91574. return !1;
  91575. i = i.parent
  91576. }
  91577. return !0
  91578. }
  91579. ,
  91580. t.prototype._handleTransitionAnimation = function(e, t) {
  91581. var i;
  91582. if (e.currentAnimationState !== t && this._options.nearInteractionControllerMode === Pf.CENTERED_IN_FRONT && !(null === (i = e.xrController) || void 0 === i ? void 0 : i.inputSource.hand)) {
  91583. if (t > e.currentAnimationState)
  91584. switch (e.currentAnimationState) {
  91585. case Cf.DEHYDRATED:
  91586. if (e.hydrateCollisionMeshFunction(!0),
  91587. t === Cf.HOVER)
  91588. break;
  91589. case Cf.HOVER:
  91590. if (e.touchCollisionMeshFunction(!0),
  91591. t === Cf.TOUCH)
  91592. break
  91593. }
  91594. else
  91595. switch (e.currentAnimationState) {
  91596. case Cf.TOUCH:
  91597. if (e.touchCollisionMeshFunction(!1),
  91598. t === Cf.HOVER)
  91599. break;
  91600. case Cf.HOVER:
  91601. if (e.hydrateCollisionMeshFunction(!1),
  91602. t === Cf.DEHYDRATED)
  91603. break
  91604. }
  91605. e.currentAnimationState = t
  91606. }
  91607. }
  91608. ,
  91609. t.prototype._processTouchPoint = function(e, t, i) {
  91610. var n, r = this._controllers[e];
  91611. r.grabRay.origin.copyFrom(t),
  91612. i.toEulerAnglesToRef(I.Vector3[0]),
  91613. r.grabRay.direction.copyFrom(I.Vector3[0]),
  91614. this._options.nearInteractionControllerMode !== Pf.CENTERED_IN_FRONT || (null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand) || (r.xrController.getWorldPointerRayToRef(this._tmpRay),
  91615. r.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),
  91616. r.grabRay.length = this._nearGrabLengthScale * this._hoverRadius,
  91617. r.touchCollisionMesh.position.copyFrom(r.grabRay.origin)
  91618. }
  91619. ,
  91620. t.prototype._onXRFrame = function(e) {
  91621. var t = this;
  91622. Object.keys(this._controllers).forEach((function(i) {
  91623. var n, r = t._controllers[i], o = null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand;
  91624. if ((t._options.enableNearInteractionOnAllControllers || i === t._attachedController) && r.xrController && (o || t._options.nearInteractionControllerMode && r.xrController.inputSource.gamepad)) {
  91625. if (r.hoverInteraction = !1,
  91626. r.nearInteraction = !1,
  91627. r.xrController) {
  91628. if (o) {
  91629. var a = o.get("index-finger-tip");
  91630. if (a) {
  91631. var s = e.getJointPose(a, t._xrSessionManager.referenceSpace);
  91632. if (s && s.transform) {
  91633. var l = t._scene.useRightHandedSystem ? 1 : -1;
  91634. I.Vector3[0].set(s.transform.position.x, s.transform.position.y, s.transform.position.z * l),
  91635. I.Quaternion[0].set(s.transform.orientation.x, s.transform.orientation.y, s.transform.orientation.z * l, s.transform.orientation.w * l),
  91636. t._processTouchPoint(i, I.Vector3[0], I.Quaternion[0])
  91637. }
  91638. }
  91639. } else if (r.xrController.inputSource.gamepad && t._options.nearInteractionControllerMode !== Pf.DISABLED) {
  91640. var c = r.xrController.pointer;
  91641. r.xrController.grip && t._options.nearInteractionControllerMode === Pf.CENTERED_ON_CONTROLLER && (c = r.xrController.grip),
  91642. t._processTouchPoint(i, c.position, c.rotationQuaternion)
  91643. }
  91644. var u = function(e, t) {
  91645. return t && t.hit ? e && e.hit ? t.distance < e.distance ? t : e : t : e
  91646. }
  91647. , h = function(e) {
  91648. var t = new Ui
  91649. , i = !1
  91650. , n = e && e.pickedPoint && e.hit;
  91651. return (null == e ? void 0 : e.pickedPoint) && (i = 0 === e.pickedPoint.x && 0 === e.pickedPoint.y && 0 === e.pickedPoint.z),
  91652. n && !i && (t = e),
  91653. t
  91654. };
  91655. if (!r.grabInteraction) {
  91656. var d = null
  91657. , p = null;
  91658. t._options.useUtilityLayer && t._utilityLayerScene && (p = t._pickWithSphere(r, t._hoverRadius, t._utilityLayerScene, (function(e) {
  91659. return t._nearInteractionPredicate(e)
  91660. }
  91661. )));
  91662. var f = u(t._pickWithSphere(r, t._hoverRadius, t._scene, (function(e) {
  91663. return t._nearInteractionPredicate(e)
  91664. }
  91665. )), p);
  91666. if (f && f.hit && (d = h(f)).hit && (r.hoverInteraction = !0),
  91667. r.hoverInteraction) {
  91668. var _ = null
  91669. , m = o ? t._pickRadius : t._controllerPickRadius;
  91670. t._options.useUtilityLayer && t._utilityLayerScene && (_ = t._pickWithSphere(r, m, t._utilityLayerScene, (function(e) {
  91671. return t._nearPickPredicate(e)
  91672. }
  91673. )));
  91674. var g = h(u(t._pickWithSphere(r, m, t._scene, (function(e) {
  91675. return t._nearPickPredicate(e)
  91676. }
  91677. )), _));
  91678. g.hit && (d = g,
  91679. r.nearInteraction = !0)
  91680. }
  91681. r.stalePick = r.pick,
  91682. r.pick = d,
  91683. r.pick && r.pick.pickedPoint && r.pick.hit ? (r.meshUnderPointer = r.pick.pickedMesh,
  91684. r.pickedPointVisualCue.position.copyFrom(r.pick.pickedPoint),
  91685. r.pickedPointVisualCue.isVisible = !0,
  91686. t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !0)) : (r.meshUnderPointer = null,
  91687. r.pickedPointVisualCue.isVisible = !1,
  91688. t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !1))
  91689. }
  91690. var v = Cf.DEHYDRATED;
  91691. r.grabInteraction || r.nearInteraction ? v = Cf.TOUCH : r.hoverInteraction && (v = Cf.HOVER),
  91692. t._handleTransitionAnimation(r, v)
  91693. }
  91694. } else
  91695. r.pick = null
  91696. }
  91697. ))
  91698. }
  91699. ,
  91700. Object.defineProperty(t.prototype, "_utilityLayerScene", {
  91701. get: function() {
  91702. return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
  91703. },
  91704. enumerable: !1,
  91705. configurable: !0
  91706. }),
  91707. t.prototype._generateVisualCue = function() {
  91708. var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
  91709. , t = Dl("nearInteraction", {
  91710. diameter: .0105
  91711. }, e);
  91712. t.bakeCurrentTransformIntoVertices(),
  91713. t.isPickable = !1,
  91714. t.isVisible = !1,
  91715. t.rotationQuaternion = C.Identity();
  91716. var i = new Os("targetMat",e);
  91717. return i.specularColor = D.Black(),
  91718. i.emissiveColor = this.selectionMeshDefaultColor,
  91719. i.backFaceCulling = !1,
  91720. t.material = i,
  91721. t
  91722. }
  91723. ,
  91724. t.prototype._isControllerReadyForNearInteraction = function(e) {
  91725. return !this._farInteractionFeature || this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e)
  91726. }
  91727. ,
  91728. t.prototype._attachNearInteractionMode = function(e) {
  91729. var t = this
  91730. , i = this._controllers[e.uniqueId]
  91731. , n = {
  91732. pointerId: i.id,
  91733. pointerType: "xr"
  91734. };
  91735. i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
  91736. (t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController) && i.xrController && (i.xrController.inputSource.hand || t._options.nearInteractionControllerMode && i.xrController.inputSource.gamepad) && (i.pick && (i.pick.ray = i.grabRay),
  91737. i.pick && t._isControllerReadyForNearInteraction(i.id) && t._scene.simulatePointerMove(i.pick, n),
  91738. i.nearInteraction && i.pick && i.pick.hit ? i.nearInteractionTargetMesh || (t._scene.simulatePointerDown(i.pick, n),
  91739. i.nearInteractionTargetMesh = i.meshUnderPointer) : i.nearInteractionTargetMesh && i.stalePick && (t._scene.simulatePointerUp(i.stalePick, n),
  91740. i.nearInteractionTargetMesh = null))
  91741. }
  91742. ));
  91743. var r = function(r) {
  91744. t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController && t._isControllerReadyForNearInteraction(i.id) ? (i.pick && (i.pick.ray = i.grabRay),
  91745. r && i.pick && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) ? (i.grabInteraction = !0,
  91746. i.pickedPointVisualCue.isVisible = !1,
  91747. t._scene.simulatePointerDown(i.pick, n)) : !r && i.pick && i.grabInteraction && (t._scene.simulatePointerUp(i.pick, n),
  91748. i.grabInteraction = !1,
  91749. i.pickedPointVisualCue.isVisible = !0)) : !r || t._options.enableNearInteractionOnAllControllers || t._options.disableSwitchOnClick || (t._attachedController = e.uniqueId)
  91750. };
  91751. if (e.inputSource.gamepad) {
  91752. var o = function(e) {
  91753. i.squeezeComponent = e.getComponent("grasp"),
  91754. i.squeezeComponent ? i.onSqueezeButtonChangedObserver = i.squeezeComponent.onButtonStateChangedObservable.add((function(e) {
  91755. if (e.changes.pressed) {
  91756. var t = e.changes.pressed.current;
  91757. r(t)
  91758. }
  91759. }
  91760. )) : (i.selectionComponent = e.getMainComponent(),
  91761. i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(e) {
  91762. if (e.changes.pressed) {
  91763. var t = e.changes.pressed.current;
  91764. r(t)
  91765. }
  91766. }
  91767. )))
  91768. };
  91769. e.motionController ? o(e.motionController) : e.onMotionControllerInitObservable.add(o)
  91770. } else {
  91771. var a = function(e) {
  91772. i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) && (i.grabInteraction = !0,
  91773. i.pickedPointVisualCue.isVisible = !1,
  91774. t._scene.simulatePointerDown(i.pick, n))
  91775. }
  91776. , s = function(e) {
  91777. i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && (t._scene.simulatePointerUp(i.pick, n),
  91778. i.grabInteraction = !1,
  91779. i.pickedPointVisualCue.isVisible = !0)
  91780. };
  91781. i.eventListeners = {
  91782. selectend: s,
  91783. selectstart: a
  91784. },
  91785. this._xrSessionManager.session.addEventListener("selectstart", a),
  91786. this._xrSessionManager.session.addEventListener("selectend", s)
  91787. }
  91788. }
  91789. ,
  91790. t.prototype._detachController = function(e) {
  91791. var t = this
  91792. , i = this._controllers[e];
  91793. if (i && (i.squeezeComponent && i.onSqueezeButtonChangedObserver && i.squeezeComponent.onButtonStateChangedObservable.remove(i.onSqueezeButtonChangedObserver),
  91794. i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),
  91795. i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),
  91796. i.eventListeners && Object.keys(i.eventListeners).forEach((function(e) {
  91797. var n = i.eventListeners && i.eventListeners[e];
  91798. n && t._xrSessionManager.session.removeEventListener(e, n)
  91799. }
  91800. )),
  91801. i.touchCollisionMesh.dispose(),
  91802. i.pickedPointVisualCue.dispose(),
  91803. this._xrSessionManager.runInXRFrame((function() {
  91804. var e = {
  91805. pointerId: i.id,
  91806. pointerType: "xr"
  91807. };
  91808. t._scene.simulatePointerUp(new Ui, e)
  91809. }
  91810. )),
  91811. delete this._controllers[e],
  91812. this._attachedController === e)) {
  91813. var n = Object.keys(this._controllers);
  91814. n.length ? this._attachedController = n[0] : this._attachedController = ""
  91815. }
  91816. }
  91817. ,
  91818. t.prototype._generateNewTouchPointMesh = function() {
  91819. var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
  91820. , t = Dl("PickSphere", {
  91821. diameter: 1
  91822. }, e);
  91823. t.isVisible = !1,
  91824. this._options.motionControllerOrbMaterial ? t.material = this._options.motionControllerOrbMaterial : Of.ParseFromSnippetAsync("8RUNKL#3", e).then((function(e) {
  91825. t.material = e
  91826. }
  91827. ));
  91828. var i = new Bn;
  91829. i.setEasingMode(Mn.EASINGMODE_EASEINOUT);
  91830. var n = new x(this._controllerPickRadius,this._controllerPickRadius,this._controllerPickRadius)
  91831. , r = this._controllerPickRadius * (4 / 3)
  91832. , o = new x(r,r,r)
  91833. , a = this._controllerPickRadius * (7 / 6)
  91834. , s = new x(a,a,a)
  91835. , l = .8 * this._controllerPickRadius
  91836. , c = new x(l,l,l)
  91837. , u = 1.5 * this._controllerPickRadius
  91838. , h = [{
  91839. frame: 0,
  91840. value: n
  91841. }, {
  91842. frame: 10,
  91843. value: new x(u,u,u)
  91844. }, {
  91845. frame: 18,
  91846. value: o
  91847. }]
  91848. , d = [{
  91849. frame: 0,
  91850. value: o
  91851. }, {
  91852. frame: 10,
  91853. value: c
  91854. }, {
  91855. frame: 18,
  91856. value: n
  91857. }]
  91858. , p = [{
  91859. frame: 0,
  91860. value: x.ZeroReadOnly
  91861. }, {
  91862. frame: 12,
  91863. value: s
  91864. }, {
  91865. frame: 15,
  91866. value: n
  91867. }]
  91868. , f = [{
  91869. frame: 0,
  91870. value: n
  91871. }, {
  91872. frame: 10,
  91873. value: x.ZeroReadOnly
  91874. }, {
  91875. frame: 15,
  91876. value: x.ZeroReadOnly
  91877. }]
  91878. , _ = new Qe("touch","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
  91879. , m = new Qe("release","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
  91880. , g = new Qe("hydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
  91881. , v = new Qe("dehydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT);
  91882. return _.setEasingFunction(i),
  91883. m.setEasingFunction(i),
  91884. g.setEasingFunction(i),
  91885. v.setEasingFunction(i),
  91886. _.setKeys(h),
  91887. m.setKeys(d),
  91888. g.setKeys(p),
  91889. v.setKeys(f),
  91890. {
  91891. touchCollisionMesh: t,
  91892. touchCollisionMeshFunction: function(i) {
  91893. var n = i ? _ : m;
  91894. e.beginDirectAnimation(t, [n], 0, 18, !1, 1)
  91895. },
  91896. hydrateCollisionMeshFunction: function(i) {
  91897. var n = i ? g : v;
  91898. i && (t.isVisible = !0),
  91899. e.beginDirectAnimation(t, [n], 0, 15, !1, 1, (function() {
  91900. i || (t.isVisible = !1)
  91901. }
  91902. ))
  91903. }
  91904. }
  91905. }
  91906. ,
  91907. t.prototype._pickWithSphere = function(e, i, n, r) {
  91908. var o = new Ui;
  91909. if (o.distance = 1 / 0,
  91910. e.touchCollisionMesh && e.xrController)
  91911. for (var a = e.touchCollisionMesh.position, s = ir.CreateFromCenterAndRadius(a, i), l = 0; l < n.meshes.length; l++) {
  91912. var c = n.meshes[l];
  91913. if (r(c) && this._controllerAvailablePredicate(c, e.xrController.uniqueId)) {
  91914. var u = t.PickMeshWithSphere(c, s);
  91915. u && u.hit && u.distance < o.distance && (o.hit = u.hit,
  91916. o.pickedMesh = c,
  91917. o.pickedPoint = u.pickedPoint,
  91918. o.aimTransform = e.xrController.pointer,
  91919. o.gripTransform = e.xrController.grip || null,
  91920. o.originMesh = e.touchCollisionMesh,
  91921. o.distance = u.distance)
  91922. }
  91923. }
  91924. return o
  91925. }
  91926. ,
  91927. t.PickMeshWithSphere = function(e, t, i) {
  91928. void 0 === i && (i = !1);
  91929. var n = e.subMeshes
  91930. , r = new Ui
  91931. , o = e.getBoundingInfo();
  91932. if (!e._generatePointsArray())
  91933. return r;
  91934. if (!e.subMeshes || !o)
  91935. return r;
  91936. if (!i && !ir.Intersects(o.boundingSphere, t))
  91937. return r;
  91938. var a, s, l, c = I.Vector3[0], u = I.Vector3[1], h = 1 / 0, d = I.Vector3[2], p = I.Matrix[0];
  91939. p.copyFrom(e.getWorldMatrix()),
  91940. p.invert(),
  91941. x.TransformCoordinatesToRef(t.center, p, d);
  91942. for (var f = 0; f < n.length; f++)
  91943. n[f].projectToRef(d, e._positions, e.getIndices(), u),
  91944. x.TransformCoordinatesToRef(u, e.getWorldMatrix(), u),
  91945. a = x.Distance(u, t.center),
  91946. l = x.Distance(u, e.getAbsolutePosition()),
  91947. -1 !== (s = x.Distance(t.center, e.getAbsolutePosition())) && -1 !== l && l > s && (a = 0,
  91948. u.copyFrom(t.center)),
  91949. -1 !== a && a < h && (h = a,
  91950. c.copyFrom(u));
  91951. return h < t.radius && (r.hit = !0,
  91952. r.distance = h,
  91953. r.pickedMesh = e,
  91954. r.pickedPoint = c.clone()),
  91955. r
  91956. }
  91957. ,
  91958. t._IdCounter = 200,
  91959. t.Name = Io.NEAR_INTERACTION,
  91960. t.Version = 1,
  91961. t
  91962. }(wp);
  91963. Oo.AddWebXRFeature(Df.Name, (function(e, t) {
  91964. return function() {
  91965. return new Df(e,t)
  91966. }
  91967. }
  91968. ), Df.Version, !0);
  91969. var Nf, Lf = function() {
  91970. function e(e, t, i) {
  91971. this.element = e,
  91972. this.sessionMode = t,
  91973. this.referenceSpaceType = i
  91974. }
  91975. return e.prototype.update = function(e) {}
  91976. ,
  91977. e
  91978. }(), Ff = function() {}, wf = function() {
  91979. function e(e, t) {
  91980. var i = this;
  91981. if (this._scene = e,
  91982. this.options = t,
  91983. this._activeButton = null,
  91984. this._buttons = [],
  91985. this.activeButtonChangedObservable = new h,
  91986. this._onSessionGranted = function(e) {
  91987. i._helper && i._enterXRWithButtonIndex(0)
  91988. }
  91989. ,
  91990. this.overlay = document.createElement("div"),
  91991. this.overlay.classList.add("xr-button-overlay"),
  91992. this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;",
  91993. !t.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted),
  91994. "undefined" != typeof window && window.location && "http:" === window.location.protocol && "localhost" !== window.location.hostname)
  91995. throw gi.Warn("WebXR can only be served over HTTPS"),
  91996. new Error("WebXR can only be served over HTTPS");
  91997. if (t.customButtons)
  91998. this._buttons = t.customButtons;
  91999. else {
  92000. var n = t.sessionMode || "immersive-vr"
  92001. , r = t.referenceSpaceType || "local-floor"
  92002. , o = ".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + ("undefined" == typeof SVGSVGElement ? "https://cdn.babylonjs.com/Assets/vrButton.png" : "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
  92003. o += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
  92004. var a = document.createElement("style");
  92005. a.appendChild(document.createTextNode(o)),
  92006. document.getElementsByTagName("head")[0].appendChild(a);
  92007. var s = document.createElement("button");
  92008. s.className = "babylonVRicon",
  92009. s.title = "".concat(n, " - ").concat(r),
  92010. this._buttons.push(new Lf(s,n,r)),
  92011. this._buttons[this._buttons.length - 1].update = function(e) {
  92012. this.element.style.display = null === e || e === this ? "" : "none",
  92013. s.className = "babylonVRicon" + (e === this ? " vrdisplaypresenting" : "")
  92014. }
  92015. ,
  92016. this._updateButtons(null)
  92017. }
  92018. var l = e.getEngine().getInputElement();
  92019. l && l.parentNode && (l.parentNode.appendChild(this.overlay),
  92020. e.onDisposeObservable.addOnce((function() {
  92021. i.dispose()
  92022. }
  92023. )))
  92024. }
  92025. return e.prototype.setHelperAsync = function(e, t) {
  92026. return G(this, void 0, void 0, (function() {
  92027. var i, n = this;
  92028. return z(this, (function(r) {
  92029. switch (r.label) {
  92030. case 0:
  92031. return this._helper = e,
  92032. this._renderTarget = t,
  92033. i = this._buttons.map((function(t) {
  92034. return e.sessionManager.isSessionSupportedAsync(t.sessionMode)
  92035. }
  92036. )),
  92037. e.onStateChangedObservable.add((function(e) {
  92038. e == Ns.NOT_IN_XR && n._updateButtons(null)
  92039. }
  92040. )),
  92041. [4, Promise.all(i)];
  92042. case 1:
  92043. return r.sent().forEach((function(e, t) {
  92044. e ? (n.overlay.appendChild(n._buttons[t].element),
  92045. n._buttons[t].element.onclick = n._enterXRWithButtonIndex.bind(n, t)) : gi.Warn('Session mode "'.concat(n._buttons[t].sessionMode, '" not supported in browser'))
  92046. }
  92047. )),
  92048. [2]
  92049. }
  92050. }
  92051. ))
  92052. }
  92053. ))
  92054. }
  92055. ,
  92056. e.CreateAsync = function(t, i, n) {
  92057. return G(this, void 0, void 0, (function() {
  92058. var r;
  92059. return z(this, (function(o) {
  92060. switch (o.label) {
  92061. case 0:
  92062. return [4, (r = new e(t,n)).setHelperAsync(i, n.renderTarget || void 0)];
  92063. case 1:
  92064. return o.sent(),
  92065. [2, r]
  92066. }
  92067. }
  92068. ))
  92069. }
  92070. ))
  92071. }
  92072. ,
  92073. e.prototype._enterXRWithButtonIndex = function(e) {
  92074. return void 0 === e && (e = 0),
  92075. G(this, void 0, void 0, (function() {
  92076. var t, i, n;
  92077. return z(this, (function(r) {
  92078. switch (r.label) {
  92079. case 0:
  92080. return this._helper.state != Ns.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
  92081. case 1:
  92082. return r.sent(),
  92083. this._updateButtons(null),
  92084. [3, 6];
  92085. case 2:
  92086. if (this._helper.state != Ns.NOT_IN_XR)
  92087. return [3, 6];
  92088. r.label = 3;
  92089. case 3:
  92090. return r.trys.push([3, 5, , 6]),
  92091. [4, this._helper.enterXRAsync(this._buttons[e].sessionMode, this._buttons[e].referenceSpaceType, this._renderTarget, {
  92092. optionalFeatures: this.options.optionalFeatures,
  92093. requiredFeatures: this.options.requiredFeatures
  92094. })];
  92095. case 4:
  92096. return r.sent(),
  92097. this._updateButtons(this._buttons[e]),
  92098. [3, 6];
  92099. case 5:
  92100. return t = r.sent(),
  92101. this._updateButtons(null),
  92102. i = this._buttons[e].element,
  92103. n = i.title,
  92104. i.title = "Error entering XR session : " + n,
  92105. i.classList.add("xr-error"),
  92106. this.options.onError && this.options.onError(t),
  92107. [3, 6];
  92108. case 6:
  92109. return [2]
  92110. }
  92111. }
  92112. ))
  92113. }
  92114. ))
  92115. }
  92116. ,
  92117. e.prototype.dispose = function() {
  92118. var e = this._scene.getEngine().getInputElement();
  92119. e && e.parentNode && e.parentNode.contains(this.overlay) && e.parentNode.removeChild(this.overlay),
  92120. this.activeButtonChangedObservable.clear(),
  92121. navigator.xr.removeEventListener("sessiongranted", this._onSessionGranted)
  92122. }
  92123. ,
  92124. e.prototype._updateButtons = function(e) {
  92125. var t = this;
  92126. this._activeButton = e,
  92127. this._buttons.forEach((function(e) {
  92128. e.update(t._activeButton)
  92129. }
  92130. )),
  92131. this.activeButtonChangedObservable.notifyObservers(this._activeButton)
  92132. }
  92133. ,
  92134. e
  92135. }();
  92136. function Bf(e) {
  92137. var t, i = 0, n = Date.now();
  92138. e.observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {};
  92139. var r = e.contextObservable.add((function(t) {
  92140. var o = Date.now()
  92141. , a = {
  92142. startTime: n,
  92143. currentTime: o,
  92144. deltaTime: i = o - n,
  92145. completeRate: i / e.timeout,
  92146. payload: t
  92147. };
  92148. e.onTick && e.onTick(a),
  92149. e.breakCondition && e.breakCondition() && (e.contextObservable.remove(r),
  92150. e.onAborted && e.onAborted(a)),
  92151. i >= e.timeout && (e.contextObservable.remove(r),
  92152. e.onEnded && e.onEnded(a))
  92153. }
  92154. ), e.observableParameters.mask, e.observableParameters.insertFirst, e.observableParameters.scope);
  92155. return r
  92156. }
  92157. !function(e) {
  92158. e[e.INIT = 0] = "INIT",
  92159. e[e.STARTED = 1] = "STARTED",
  92160. e[e.ENDED = 2] = "ENDED"
  92161. }(Nf || (Nf = {}));
  92162. var Uf = function() {
  92163. function e(e) {
  92164. var t, i, n = this;
  92165. this.onEachCountObservable = new h,
  92166. this.onTimerAbortedObservable = new h,
  92167. this.onTimerEndedObservable = new h,
  92168. this.onStateChangedObservable = new h,
  92169. this._observer = null,
  92170. this._breakOnNextTick = !1,
  92171. this._tick = function(e) {
  92172. var t = Date.now();
  92173. n._timer = t - n._startTime;
  92174. var i = {
  92175. startTime: n._startTime,
  92176. currentTime: t,
  92177. deltaTime: n._timer,
  92178. completeRate: n._timer / n._timeToEnd,
  92179. payload: e
  92180. }
  92181. , r = n._breakOnNextTick || n._breakCondition(i);
  92182. r || n._timer >= n._timeToEnd ? n._stop(i, r) : n.onEachCountObservable.notifyObservers(i)
  92183. }
  92184. ,
  92185. this._setState(Nf.INIT),
  92186. this._contextObservable = e.contextObservable,
  92187. this._observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {},
  92188. this._breakCondition = null !== (i = e.breakCondition) && void 0 !== i ? i : function() {
  92189. return !1
  92190. }
  92191. ,
  92192. this._timeToEnd = e.timeout,
  92193. e.onEnded && this.onTimerEndedObservable.add(e.onEnded),
  92194. e.onTick && this.onEachCountObservable.add(e.onTick),
  92195. e.onAborted && this.onTimerAbortedObservable.add(e.onAborted)
  92196. }
  92197. return Object.defineProperty(e.prototype, "breakCondition", {
  92198. set: function(e) {
  92199. this._breakCondition = e
  92200. },
  92201. enumerable: !1,
  92202. configurable: !0
  92203. }),
  92204. e.prototype.clearObservables = function() {
  92205. this.onEachCountObservable.clear(),
  92206. this.onTimerAbortedObservable.clear(),
  92207. this.onTimerEndedObservable.clear(),
  92208. this.onStateChangedObservable.clear()
  92209. }
  92210. ,
  92211. e.prototype.start = function(e) {
  92212. if (void 0 === e && (e = this._timeToEnd),
  92213. this._state === Nf.STARTED)
  92214. throw new Error("Timer already started. Please stop it before starting again");
  92215. this._timeToEnd = e,
  92216. this._startTime = Date.now(),
  92217. this._timer = 0,
  92218. this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope),
  92219. this._setState(Nf.STARTED)
  92220. }
  92221. ,
  92222. e.prototype.stop = function() {
  92223. this._state === Nf.STARTED && (this._breakOnNextTick = !0)
  92224. }
  92225. ,
  92226. e.prototype.dispose = function() {
  92227. this._observer && this._contextObservable.remove(this._observer),
  92228. this.clearObservables()
  92229. }
  92230. ,
  92231. e.prototype._setState = function(e) {
  92232. this._state = e,
  92233. this.onStateChangedObservable.notifyObservers(this._state)
  92234. }
  92235. ,
  92236. e.prototype._stop = function(e, t) {
  92237. void 0 === t && (t = !1),
  92238. this._contextObservable.remove(this._observer),
  92239. this._setState(Nf.ENDED),
  92240. t ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e)
  92241. }
  92242. ,
  92243. e
  92244. }()
  92245. , Vf = function(e) {
  92246. function t(t, i) {
  92247. var n = e.call(this, t) || this;
  92248. return n._options = i,
  92249. n._controllers = {},
  92250. n._snappedToPoint = !1,
  92251. n._tmpRay = new _o(new x,new x),
  92252. n._tmpVector = new x,
  92253. n._tmpQuaternion = new C,
  92254. n.skipNextTeleportation = !1,
  92255. n.backwardsMovementEnabled = !0,
  92256. n.backwardsTeleportationDistance = .7,
  92257. n.parabolicCheckRadius = 5,
  92258. n.parabolicRayEnabled = !0,
  92259. n.straightRayEnabled = !0,
  92260. n.rotationAngle = Math.PI / 8,
  92261. n.onTargetMeshPositionUpdatedObservable = new h,
  92262. n.teleportationEnabled = !0,
  92263. n._rotationEnabled = !0,
  92264. n._attachController = function(e) {
  92265. if (!(n._controllers[e.uniqueId] || n._options.forceHandedness && e.inputSource.handedness !== n._options.forceHandedness)) {
  92266. n._controllers[e.uniqueId] = {
  92267. xrController: e,
  92268. teleportationState: {
  92269. forward: !1,
  92270. backwards: !1,
  92271. rotating: !1,
  92272. currentRotation: 0,
  92273. baseRotation: 0
  92274. }
  92275. };
  92276. var t = n._controllers[e.uniqueId];
  92277. if ("tracked-pointer" === t.xrController.inputSource.targetRayMode && t.xrController.inputSource.gamepad) {
  92278. var i = function() {
  92279. if (e.motionController) {
  92280. var i = e.motionController.getComponentOfType(Ap.THUMBSTICK_TYPE) || e.motionController.getComponentOfType(Ap.TOUCHPAD_TYPE);
  92281. if (!i || n._options.useMainComponentOnly) {
  92282. var r = e.motionController.getMainComponent();
  92283. if (!r)
  92284. return;
  92285. t.teleportationComponent = r,
  92286. t.onButtonChangedObserver = r.onButtonStateChangedObservable.add((function() {
  92287. n.teleportationEnabled && r.changes.pressed && (r.changes.pressed.current ? (t.teleportationState.forward = !0,
  92288. n._currentTeleportationControllerId = t.xrController.uniqueId,
  92289. t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
  92290. t.teleportationState.currentRotation = 0,
  92291. Bf({
  92292. timeout: n._options.timeToTeleport || 3e3,
  92293. contextObservable: n._xrSessionManager.onXRFrameObservable,
  92294. breakCondition: function() {
  92295. return !r.pressed
  92296. },
  92297. onEnded: function() {
  92298. n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
  92299. }
  92300. })) : (t.teleportationState.forward = !1,
  92301. n._currentTeleportationControllerId = ""))
  92302. }
  92303. ))
  92304. } else
  92305. t.teleportationComponent = i,
  92306. t.onAxisChangedObserver = i.onAxisValueChangedObservable.add((function(i) {
  92307. if (i.y <= .7 && t.teleportationState.backwards && (t.teleportationState.backwards = !1),
  92308. i.y > .7 && !t.teleportationState.forward && n.backwardsMovementEnabled && !n.snapPointsOnly && !t.teleportationState.backwards) {
  92309. t.teleportationState.backwards = !0,
  92310. n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),
  92311. n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),
  92312. n._tmpVector.x = 0,
  92313. n._tmpVector.z = 0,
  92314. C.FromEulerVectorToRef(n._tmpVector, n._tmpQuaternion),
  92315. n._tmpVector.set(0, 0, n.backwardsTeleportationDistance * (n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
  92316. n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion, n._tmpVector),
  92317. n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),
  92318. n._tmpRay.origin.copyFrom(n._tmpVector),
  92319. n._tmpRay.length = n._options.xrInput.xrCamera.realWorldHeight + .1,
  92320. n._tmpRay.direction.set(0, -1, 0);
  92321. var r = n._xrSessionManager.scene.pickWithRay(n._tmpRay, (function(e) {
  92322. return -1 !== n._floorMeshes.indexOf(e)
  92323. }
  92324. ));
  92325. r && r.pickedPoint && (n._options.xrInput.xrCamera.position.x = r.pickedPoint.x,
  92326. n._options.xrInput.xrCamera.position.z = r.pickedPoint.z)
  92327. }
  92328. if (i.y < -.7 && !n._currentTeleportationControllerId && !t.teleportationState.rotating && n.teleportationEnabled && (t.teleportationState.forward = !0,
  92329. n._currentTeleportationControllerId = t.xrController.uniqueId,
  92330. t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),
  92331. i.x) {
  92332. if (t.teleportationState.forward)
  92333. n._currentTeleportationControllerId === t.xrController.uniqueId && (n.rotationEnabled ? setTimeout((function() {
  92334. t.teleportationState.currentRotation = Math.atan2(i.x, i.y * (n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1))
  92335. }
  92336. )) : t.teleportationState.currentRotation = 0);
  92337. else if (!t.teleportationState.rotating && Math.abs(i.x) > .7) {
  92338. t.teleportationState.rotating = !0;
  92339. var o = n.rotationAngle * (i.x > 0 ? 1 : -1) * (n._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
  92340. C.FromEulerAngles(0, o, 0).multiplyToRef(n._options.xrInput.xrCamera.rotationQuaternion, n._options.xrInput.xrCamera.rotationQuaternion)
  92341. }
  92342. } else
  92343. t.teleportationState.rotating = !1;
  92344. 0 === i.x && 0 === i.y && t.teleportationState.forward && n._teleportForward(e.uniqueId)
  92345. }
  92346. ))
  92347. }
  92348. };
  92349. e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function() {
  92350. i()
  92351. }
  92352. ))
  92353. } else
  92354. n._xrSessionManager.scene.onPointerObservable.add((function(i) {
  92355. i.type === Xi.POINTERDOWN ? (t.teleportationState.forward = !0,
  92356. n._currentTeleportationControllerId = t.xrController.uniqueId,
  92357. t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
  92358. t.teleportationState.currentRotation = 0,
  92359. Bf({
  92360. timeout: n._options.timeToTeleport || 3e3,
  92361. contextObservable: n._xrSessionManager.onXRFrameObservable,
  92362. onEnded: function() {
  92363. n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
  92364. }
  92365. })) : i.type === Xi.POINTERUP && (t.teleportationState.forward = !1,
  92366. n._currentTeleportationControllerId = "")
  92367. }
  92368. ))
  92369. }
  92370. }
  92371. ,
  92372. n._options.teleportationTargetMesh || n._createDefaultTargetMesh(),
  92373. n._floorMeshes = n._options.floorMeshes || [],
  92374. n._snapToPositions = n._options.snapPositions || [],
  92375. n._setTargetMeshVisibility(!1),
  92376. n
  92377. }
  92378. return U(t, e),
  92379. Object.defineProperty(t.prototype, "rotationEnabled", {
  92380. get: function() {
  92381. return this._rotationEnabled
  92382. },
  92383. set: function(e) {
  92384. if (this._rotationEnabled = e,
  92385. this._options.teleportationTargetMesh) {
  92386. var t = this._options.teleportationTargetMesh.getChildMeshes(!1, (function(e) {
  92387. return "rotationCone" === e.name
  92388. }
  92389. ));
  92390. t[0] && t[0].setEnabled(e)
  92391. }
  92392. },
  92393. enumerable: !1,
  92394. configurable: !0
  92395. }),
  92396. Object.defineProperty(t.prototype, "teleportationTargetMesh", {
  92397. get: function() {
  92398. return this._options.teleportationTargetMesh || null
  92399. },
  92400. enumerable: !1,
  92401. configurable: !0
  92402. }),
  92403. Object.defineProperty(t.prototype, "snapPointsOnly", {
  92404. get: function() {
  92405. return !!this._options.snapPointsOnly
  92406. },
  92407. set: function(e) {
  92408. this._options.snapPointsOnly = e
  92409. },
  92410. enumerable: !1,
  92411. configurable: !0
  92412. }),
  92413. t.prototype.addFloorMesh = function(e) {
  92414. this._floorMeshes.push(e)
  92415. }
  92416. ,
  92417. t.prototype.addBlockerMesh = function(e) {
  92418. this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [],
  92419. this._options.pickBlockerMeshes.push(e)
  92420. }
  92421. ,
  92422. t.prototype.addSnapPoint = function(e) {
  92423. this._snapToPositions.push(e)
  92424. }
  92425. ,
  92426. t.prototype.attach = function() {
  92427. var t = this;
  92428. return !!e.prototype.attach.call(this) && (this._currentTeleportationControllerId = "",
  92429. this._options.xrInput.controllers.forEach(this._attachController),
  92430. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  92431. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function(e) {
  92432. t._detachController(e.uniqueId)
  92433. }
  92434. )),
  92435. !0)
  92436. }
  92437. ,
  92438. t.prototype.detach = function() {
  92439. var t = this;
  92440. return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
  92441. t._detachController(e)
  92442. }
  92443. )),
  92444. this._setTargetMeshVisibility(!1),
  92445. this._currentTeleportationControllerId = "",
  92446. this._controllers = {},
  92447. !0)
  92448. }
  92449. ,
  92450. t.prototype.dispose = function() {
  92451. e.prototype.dispose.call(this),
  92452. this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0)
  92453. }
  92454. ,
  92455. t.prototype.removeFloorMesh = function(e) {
  92456. var t = this._floorMeshes.indexOf(e);
  92457. -1 !== t && this._floorMeshes.splice(t, 1)
  92458. }
  92459. ,
  92460. t.prototype.removeBlockerMesh = function(e) {
  92461. this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [];
  92462. var t = this._options.pickBlockerMeshes.indexOf(e);
  92463. -1 !== t && this._options.pickBlockerMeshes.splice(t, 1)
  92464. }
  92465. ,
  92466. t.prototype.removeFloorMeshByName = function(e) {
  92467. var t = this._xrSessionManager.scene.getMeshByName(e);
  92468. t && this.removeFloorMesh(t)
  92469. }
  92470. ,
  92471. t.prototype.removeSnapPoint = function(e) {
  92472. var t = this._snapToPositions.indexOf(e);
  92473. if (-1 === t)
  92474. for (var i = 0; i < this._snapToPositions.length; ++i)
  92475. if (this._snapToPositions[i].equals(e)) {
  92476. t = i;
  92477. break
  92478. }
  92479. return -1 !== t && (this._snapToPositions.splice(t, 1),
  92480. !0)
  92481. }
  92482. ,
  92483. t.prototype.setSelectionFeature = function(e) {
  92484. this._selectionFeature = e
  92485. }
  92486. ,
  92487. t.prototype._onXRFrame = function(e) {
  92488. var t = this
  92489. , i = this._xrSessionManager.currentFrame
  92490. , n = this._xrSessionManager.scene;
  92491. if (this.attach && i) {
  92492. var r = this._options.teleportationTargetMesh;
  92493. if (this._currentTeleportationControllerId) {
  92494. if (!r)
  92495. return;
  92496. r.rotationQuaternion = r.rotationQuaternion || new C;
  92497. var o = this._controllers[this._currentTeleportationControllerId];
  92498. if (o && o.teleportationState.forward) {
  92499. C.RotationYawPitchRollToRef(o.teleportationState.currentRotation + o.teleportationState.baseRotation, 0, 0, r.rotationQuaternion);
  92500. var a = !1;
  92501. if (o.xrController.getWorldPointerRayToRef(this._tmpRay),
  92502. this.straightRayEnabled) {
  92503. if ((s = n.pickWithRay(this._tmpRay, (function(e) {
  92504. if (t._options.pickBlockerMeshes && -1 !== t._options.pickBlockerMeshes.indexOf(e))
  92505. return !0;
  92506. var i = t._floorMeshes.indexOf(e);
  92507. return -1 !== i && t._floorMeshes[i].absolutePosition.y < t._options.xrInput.xrCamera.globalPosition.y
  92508. }
  92509. ))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh))
  92510. return;
  92511. s && s.pickedPoint && (a = !0,
  92512. this._setTargetMeshPosition(s),
  92513. this._setTargetMeshVisibility(!0),
  92514. this._showParabolicPath(s))
  92515. }
  92516. if (this.parabolicRayEnabled && !a) {
  92517. var s, l = o.xrController.pointer.rotationQuaternion.toEulerAngles().x, c = Math.PI / 2 - Math.abs(l) + 1, u = this.parabolicCheckRadius * c;
  92518. if (this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2 * u), this._tmpVector),
  92519. this._tmpVector.y = this._tmpRay.origin.y,
  92520. this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(u)),
  92521. this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction),
  92522. this._tmpRay.direction.normalize(),
  92523. (s = n.pickWithRay(this._tmpRay, (function(e) {
  92524. return !(!t._options.pickBlockerMeshes || -1 === t._options.pickBlockerMeshes.indexOf(e)) || -1 !== t._floorMeshes.indexOf(e)
  92525. }
  92526. ))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh))
  92527. return;
  92528. s && s.pickedPoint && (a = !0,
  92529. this._setTargetMeshPosition(s),
  92530. this._setTargetMeshVisibility(!0),
  92531. this._showParabolicPath(s))
  92532. }
  92533. this._setTargetMeshVisibility(a)
  92534. } else
  92535. this._setTargetMeshVisibility(!1)
  92536. } else
  92537. this._setTargetMeshVisibility(!1)
  92538. }
  92539. }
  92540. ,
  92541. t.prototype._createDefaultTargetMesh = function() {
  92542. this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
  92543. var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
  92544. , t = il("teleportationTarget", {
  92545. width: 2,
  92546. height: 2,
  92547. subdivisions: 2
  92548. }, e);
  92549. t.isPickable = !1;
  92550. var i = new Ds("teleportationPlaneDynamicTexture",512,e,!0);
  92551. i.hasAlpha = !0;
  92552. var n = i.getContext();
  92553. n.beginPath(),
  92554. n.arc(256, 256, 200, 0, 2 * Math.PI, !1),
  92555. n.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444",
  92556. n.fill(),
  92557. n.lineWidth = 10,
  92558. n.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF",
  92559. n.stroke(),
  92560. n.closePath(),
  92561. i.update();
  92562. var r = new Os("teleportationPlaneMaterial",e);
  92563. r.diffuseTexture = i,
  92564. t.material = r;
  92565. var o = qs("torusTeleportation", {
  92566. diameter: .75,
  92567. thickness: .1,
  92568. tessellation: 20
  92569. }, e);
  92570. if (o.isPickable = !1,
  92571. o.parent = t,
  92572. !this._options.defaultTargetMeshOptions.disableAnimation) {
  92573. var a = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CYCLE)
  92574. , s = [];
  92575. s.push({
  92576. frame: 0,
  92577. value: 0
  92578. }),
  92579. s.push({
  92580. frame: 30,
  92581. value: .4
  92582. }),
  92583. s.push({
  92584. frame: 60,
  92585. value: 0
  92586. }),
  92587. a.setKeys(s);
  92588. var l = new kn;
  92589. l.setEasingMode(Mn.EASINGMODE_EASEINOUT),
  92590. a.setEasingFunction(l),
  92591. o.animations = [],
  92592. o.animations.push(a),
  92593. e.beginAnimation(o, 0, 60, !0)
  92594. }
  92595. var c = Ys("rotationCone", {
  92596. diameterTop: 0,
  92597. tessellation: 4
  92598. }, e);
  92599. if (c.isPickable = !1,
  92600. c.scaling.set(.5, .12, .2),
  92601. c.rotate(vn.X, Math.PI / 2),
  92602. c.position.z = .6,
  92603. c.parent = o,
  92604. this._options.defaultTargetMeshOptions.torusArrowMaterial)
  92605. o.material = this._options.defaultTargetMeshOptions.torusArrowMaterial,
  92606. c.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
  92607. else {
  92608. var u = new Os("torusConsMat",e);
  92609. u.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting,
  92610. u.disableLighting ? u.emissiveColor = new D(.3,.3,1) : u.diffuseColor = new D(.3,.3,1),
  92611. u.alpha = .9,
  92612. o.material = u,
  92613. c.material = u,
  92614. this._teleportationRingMaterial = u
  92615. }
  92616. void 0 !== this._options.renderingGroupId && (t.renderingGroupId = this._options.renderingGroupId,
  92617. o.renderingGroupId = this._options.renderingGroupId,
  92618. c.renderingGroupId = this._options.renderingGroupId),
  92619. this._options.teleportationTargetMesh = t
  92620. }
  92621. ,
  92622. t.prototype._detachController = function(e) {
  92623. var t = this._controllers[e];
  92624. t && (t.teleportationComponent && (t.onAxisChangedObserver && t.teleportationComponent.onAxisValueChangedObservable.remove(t.onAxisChangedObserver),
  92625. t.onButtonChangedObserver && t.teleportationComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver)),
  92626. delete this._controllers[e])
  92627. }
  92628. ,
  92629. t.prototype._findClosestSnapPointWithRadius = function(e, t) {
  92630. void 0 === t && (t = this._options.snapToPositionRadius || .8);
  92631. var i = null
  92632. , n = Number.MAX_VALUE;
  92633. if (this._snapToPositions.length) {
  92634. var r = t * t;
  92635. this._snapToPositions.forEach((function(t) {
  92636. var o = x.DistanceSquared(t, e);
  92637. o <= r && o < n && (n = o,
  92638. i = t)
  92639. }
  92640. ))
  92641. }
  92642. return i
  92643. }
  92644. ,
  92645. t.prototype._setTargetMeshPosition = function(e) {
  92646. var t = e.pickedPoint;
  92647. if (this._options.teleportationTargetMesh && t) {
  92648. var i = this._findClosestSnapPointWithRadius(t);
  92649. this._snappedToPoint = !!i,
  92650. this.snapPointsOnly && !this._snappedToPoint && this._teleportationRingMaterial ? this._teleportationRingMaterial.diffuseColor.set(1, .3, .3) : this.snapPointsOnly && this._snappedToPoint && this._teleportationRingMaterial && this._teleportationRingMaterial.diffuseColor.set(.3, .3, 1),
  92651. this._options.teleportationTargetMesh.position.copyFrom(i || t),
  92652. this._options.teleportationTargetMesh.position.y += .01,
  92653. this.onTargetMeshPositionUpdatedObservable.notifyObservers(e)
  92654. }
  92655. }
  92656. ,
  92657. t.prototype._setTargetMeshVisibility = function(e) {
  92658. this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible !== e && (this._options.teleportationTargetMesh.isVisible = e,
  92659. this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach((function(t) {
  92660. t.isVisible = e
  92661. }
  92662. )),
  92663. e ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(),
  92664. this._quadraticBezierCurve = null),
  92665. this._selectionFeature && this._selectionFeature.attach()))
  92666. }
  92667. ,
  92668. t.prototype._showParabolicPath = function(e) {
  92669. if (e.pickedPoint) {
  92670. var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
  92671. , i = this._controllers[this._currentTeleportationControllerId]
  92672. , n = Pn.CreateQuadraticBezier(i.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25);
  92673. this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(n.getPoints(), e) : this._quadraticBezierCurve = Jl("teleportation path line", {
  92674. points: n.getPoints(),
  92675. instance: this._quadraticBezierCurve,
  92676. updatable: !0
  92677. }, t),
  92678. this._quadraticBezierCurve.isPickable = !1,
  92679. void 0 !== this._options.renderingGroupId && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId)
  92680. }
  92681. }
  92682. ,
  92683. t.prototype._teleportForward = function(e) {
  92684. var t = this._controllers[e];
  92685. if (t && t.teleportationState.forward && this.teleportationEnabled && (t.teleportationState.forward = !1,
  92686. this._currentTeleportationControllerId = "",
  92687. !this.snapPointsOnly || this._snappedToPoint))
  92688. if (this.skipNextTeleportation)
  92689. this.skipNextTeleportation = !1;
  92690. else if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
  92691. var i = this._options.xrInput.xrCamera.realWorldHeight;
  92692. this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),
  92693. this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),
  92694. this._options.xrInput.xrCamera.position.y += i,
  92695. C.FromEulerAngles(0, t.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion, this._options.xrInput.xrCamera.rotationQuaternion),
  92696. this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)
  92697. }
  92698. }
  92699. ,
  92700. t.Name = Io.TELEPORTATION,
  92701. t.Version = 1,
  92702. t
  92703. }(wp);
  92704. Oo.AddWebXRFeature(Vf.Name, (function(e, t) {
  92705. return function() {
  92706. return new Vf(e,t)
  92707. }
  92708. }
  92709. ), Vf.Version, !0);
  92710. var kf = function() {}
  92711. , Gf = function() {
  92712. function e() {}
  92713. return e.CreateAsync = function(t, i) {
  92714. void 0 === i && (i = {});
  92715. var n = new e;
  92716. if (t.onDisposeObservable.addOnce((function() {
  92717. n.dispose()
  92718. }
  92719. )),
  92720. !i.disableDefaultUI) {
  92721. var r = V({
  92722. renderTarget: n.renderTarget
  92723. }, i.uiOptions || {});
  92724. i.optionalFeatures && ("boolean" == typeof i.optionalFeatures ? r.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : r.optionalFeatures = i.optionalFeatures),
  92725. n.enterExitUI = new wf(t,r)
  92726. }
  92727. return Sp.CreateAsync(t).then((function(e) {
  92728. if (n.baseExperience = e,
  92729. i.ignoreNativeCameraTransformation && (n.baseExperience.camera.compensateOnFirstFrame = !1),
  92730. n.input = new Fp(e.sessionManager,e.camera,V({
  92731. controllerOptions: {
  92732. renderingGroupId: i.renderingGroupId
  92733. }
  92734. }, i.inputOptions || {})),
  92735. !i.disablePointerSelection) {
  92736. var t = V(V({}, i.pointerSelectionOptions), {
  92737. xrInput: n.input,
  92738. renderingGroupId: i.renderingGroupId
  92739. });
  92740. n.pointerSelection = n.baseExperience.featuresManager.enableFeature(Bp.Name, i.useStablePlugins ? "stable" : "latest", t),
  92741. i.disableTeleportation || (n.teleportation = n.baseExperience.featuresManager.enableFeature(Vf.Name, i.useStablePlugins ? "stable" : "latest", {
  92742. floorMeshes: i.floorMeshes,
  92743. xrInput: n.input,
  92744. renderingGroupId: i.renderingGroupId
  92745. }),
  92746. n.teleportation.setSelectionFeature(n.pointerSelection))
  92747. }
  92748. return i.disableNearInteraction || (n.nearInteraction = n.baseExperience.featuresManager.enableFeature(Df.Name, i.useStablePlugins ? "stable" : "latest", {
  92749. xrInput: n.input,
  92750. farInteractionFeature: n.pointerSelection,
  92751. renderingGroupId: i.renderingGroupId,
  92752. useUtilityLayer: !0,
  92753. enableNearInteractionOnAllControllers: !0
  92754. })),
  92755. n.renderTarget = n.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),
  92756. i.disableDefaultUI ? void 0 : n.enterExitUI.setHelperAsync(n.baseExperience, n.renderTarget)
  92757. }
  92758. )).then((function() {
  92759. return n
  92760. }
  92761. )).catch((function(e) {
  92762. return K.Error("Error initializing XR"),
  92763. K.Error(e),
  92764. n
  92765. }
  92766. ))
  92767. }
  92768. ,
  92769. e.prototype.dispose = function() {
  92770. this.baseExperience && this.baseExperience.dispose(),
  92771. this.input && this.input.dispose(),
  92772. this.enterExitUI && this.enterExitUI.dispose(),
  92773. this.renderTarget && this.renderTarget.dispose()
  92774. }
  92775. ,
  92776. e
  92777. }()
  92778. , zf = !0;
  92779. function Wf(e) {
  92780. for (; e.firstChild; )
  92781. e.removeChild(e.firstChild);
  92782. e.srcObject = null,
  92783. e.src = "",
  92784. e.removeAttribute("src")
  92785. }
  92786. mn.prototype.createDefaultLight = function(e) {
  92787. if (void 0 === e && (e = !1),
  92788. e && this.lights)
  92789. for (var t = 0; t < this.lights.length; t++)
  92790. this.lights[t].dispose();
  92791. 0 === this.lights.length && new ds("default light",x.Up(),this)
  92792. }
  92793. ,
  92794. mn.prototype.createDefaultCamera = function(e, t, i) {
  92795. if (void 0 === e && (e = !1),
  92796. void 0 === t && (t = !1),
  92797. void 0 === i && (i = !1),
  92798. t && this.activeCamera && (this.activeCamera.dispose(),
  92799. this.activeCamera = null),
  92800. !this.activeCamera) {
  92801. var n = this.getWorldExtends((function(e) {
  92802. return e.isVisible && e.isEnabled()
  92803. }
  92804. ))
  92805. , r = n.max.subtract(n.min)
  92806. , o = n.min.add(r.scale(.5))
  92807. , a = void 0
  92808. , s = 1.5 * r.length();
  92809. if (isFinite(s) || (s = 1,
  92810. o.copyFromFloats(0, 0, 0)),
  92811. e) {
  92812. var l = new _a("default camera",-Math.PI / 2,Math.PI / 2,s,o,this);
  92813. l.lowerRadiusLimit = .01 * s,
  92814. l.wheelPrecision = 100 / s,
  92815. a = l
  92816. } else {
  92817. var c = new pa("default camera",new x(o.x,o.y,-s),this);
  92818. c.setTarget(o),
  92819. a = c
  92820. }
  92821. a.minZ = .01 * s,
  92822. a.maxZ = 1e3 * s,
  92823. a.speed = .2 * s,
  92824. this.activeCamera = a,
  92825. i && a.attachControl()
  92826. }
  92827. }
  92828. ,
  92829. mn.prototype.createDefaultCameraOrLight = function(e, t, i) {
  92830. void 0 === e && (e = !1),
  92831. void 0 === t && (t = !1),
  92832. void 0 === i && (i = !1),
  92833. this.createDefaultLight(t),
  92834. this.createDefaultCamera(e, t, i)
  92835. }
  92836. ,
  92837. mn.prototype.createDefaultSkybox = function(e, t, i, n, r) {
  92838. if (void 0 === t && (t = !1),
  92839. void 0 === i && (i = 1e3),
  92840. void 0 === n && (n = 0),
  92841. void 0 === r && (r = !0),
  92842. !e)
  92843. return K.Warn("Can not create default skybox without environment texture."),
  92844. null;
  92845. r && e && (this.environmentTexture = e);
  92846. var o = Ml("hdrSkyBox", {
  92847. size: i
  92848. }, this);
  92849. if (t) {
  92850. var a = new op("skyBox",this);
  92851. a.backFaceCulling = !1,
  92852. a.reflectionTexture = e.clone(),
  92853. a.reflectionTexture && (a.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
  92854. a.microSurface = 1 - n,
  92855. a.disableLighting = !0,
  92856. a.twoSidedLighting = !0,
  92857. o.material = a
  92858. } else {
  92859. var s = new Os("skyBox",this);
  92860. s.backFaceCulling = !1,
  92861. s.reflectionTexture = e.clone(),
  92862. s.reflectionTexture && (s.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
  92863. s.disableLighting = !0,
  92864. o.material = s
  92865. }
  92866. return o.isPickable = !1,
  92867. o.infiniteDistance = !0,
  92868. o.ignoreCameraMaxZ = !0,
  92869. o
  92870. }
  92871. ,
  92872. mn.prototype.createDefaultEnvironment = function(e) {
  92873. return kd ? new kd(e,this) : null
  92874. }
  92875. ,
  92876. mn.prototype.createDefaultVRExperience = function(e) {
  92877. return void 0 === e && (e = {}),
  92878. new hl(this,e)
  92879. }
  92880. ,
  92881. mn.prototype.createDefaultXRExperienceAsync = function(e) {
  92882. return void 0 === e && (e = {}),
  92883. Gf.CreateAsync(this, e).then((function(e) {
  92884. return e
  92885. }
  92886. ))
  92887. }
  92888. ;
  92889. var Hf = function(e) {
  92890. function t(t, i, n, r, o, a, s, l) {
  92891. void 0 === r && (r = !1),
  92892. void 0 === o && (o = !1),
  92893. void 0 === a && (a = io.TRILINEAR_SAMPLINGMODE),
  92894. void 0 === s && (s = {});
  92895. var c = e.call(this, null, n, !r, o) || this;
  92896. c._onUserActionRequestedObservable = null,
  92897. c._stillImageCaptured = !1,
  92898. c._displayingPosterTexture = !1,
  92899. c._frameId = -1,
  92900. c._currentSrc = null,
  92901. c._errorFound = !1,
  92902. c._createInternalTexture = function() {
  92903. if (null != c._texture) {
  92904. if (!c._displayingPosterTexture)
  92905. return;
  92906. c._texture.dispose(),
  92907. c._displayingPosterTexture = !1
  92908. }
  92909. if (!c._getEngine().needPOTTextures || gi.IsExponentOfTwo(c.video.videoWidth) && gi.IsExponentOfTwo(c.video.videoHeight) ? (c.wrapU = io.WRAP_ADDRESSMODE,
  92910. c.wrapV = io.WRAP_ADDRESSMODE) : (c.wrapU = io.CLAMP_ADDRESSMODE,
  92911. c.wrapV = io.CLAMP_ADDRESSMODE,
  92912. c._generateMipMaps = !1),
  92913. c._texture = c._getEngine().createDynamicTexture(c.video.videoWidth, c.video.videoHeight, c._generateMipMaps, c.samplingMode),
  92914. c.video.autoplay || c._settings.poster)
  92915. c._updateInternalTexture(),
  92916. c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c);
  92917. else {
  92918. var e = c.video.onplaying
  92919. , t = c.video.muted;
  92920. c.video.muted = !0,
  92921. c.video.onplaying = function() {
  92922. c.video.muted = t,
  92923. c.video.onplaying = e,
  92924. c._updateInternalTexture(),
  92925. c._errorFound || c.video.pause(),
  92926. c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c)
  92927. }
  92928. ,
  92929. c._handlePlay()
  92930. }
  92931. }
  92932. ,
  92933. c._reset = function() {
  92934. null != c._texture && (c._displayingPosterTexture || (c._texture.dispose(),
  92935. c._texture = null))
  92936. }
  92937. ,
  92938. c._updateInternalTexture = function() {
  92939. if (null != c._texture && !(c.video.readyState < c.video.HAVE_CURRENT_DATA || c._displayingPosterTexture)) {
  92940. var e = c.getScene().getFrameId();
  92941. c._frameId !== e && (c._frameId = e,
  92942. c._getEngine().updateVideoTexture(c._texture, c.video, c._invertY))
  92943. }
  92944. }
  92945. ,
  92946. c._settings = V({
  92947. autoPlay: !0,
  92948. loop: !0,
  92949. autoUpdateTexture: !0
  92950. }, s),
  92951. c._onError = l,
  92952. c._generateMipMaps = r,
  92953. c._initialSamplingMode = a,
  92954. c.autoUpdateTexture = c._settings.autoUpdateTexture,
  92955. c._currentSrc = i,
  92956. c.name = t || c._getName(i),
  92957. c.video = c._getVideo(i),
  92958. s.poster && (c.video.poster = s.poster),
  92959. void 0 !== s.autoPlay && (c.video.autoplay = s.autoPlay),
  92960. void 0 !== s.loop && (c.video.loop = s.loop),
  92961. void 0 !== s.muted && (c.video.muted = s.muted),
  92962. c.video.setAttribute("playsinline", ""),
  92963. c.video.addEventListener("paused", c._updateInternalTexture),
  92964. c.video.addEventListener("seeked", c._updateInternalTexture),
  92965. c.video.addEventListener("emptied", c._reset),
  92966. c._createInternalTextureOnEvent = s.poster && !s.autoPlay ? "play" : "canplay",
  92967. c.video.addEventListener(c._createInternalTextureOnEvent, c._createInternalTexture),
  92968. s.autoPlay && c._handlePlay();
  92969. var u = c.video.readyState >= c.video.HAVE_CURRENT_DATA;
  92970. return !s.poster || s.autoPlay && u ? u && c._createInternalTexture() : (c._texture = c._getEngine().createTexture(s.poster, !1, !c.invertY, n),
  92971. c._displayingPosterTexture = !0),
  92972. c
  92973. }
  92974. return U(t, e),
  92975. Object.defineProperty(t.prototype, "onUserActionRequestedObservable", {
  92976. get: function() {
  92977. return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new h),
  92978. this._onUserActionRequestedObservable
  92979. },
  92980. enumerable: !1,
  92981. configurable: !0
  92982. }),
  92983. t.prototype._processError = function(e) {
  92984. this._errorFound = !0,
  92985. this._onError ? this._onError(null == e ? void 0 : e.message) : K.Error(null == e ? void 0 : e.message)
  92986. }
  92987. ,
  92988. t.prototype._handlePlay = function() {
  92989. var e = this;
  92990. this._errorFound = !1,
  92991. this.video.play().catch((function(t) {
  92992. if ("NotAllowedError" === (null == t ? void 0 : t.name)) {
  92993. if (e._onUserActionRequestedObservable && e._onUserActionRequestedObservable.hasObservers())
  92994. return void e._onUserActionRequestedObservable.notifyObservers(e);
  92995. if (!e.video.muted)
  92996. return K.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),
  92997. e.video.muted = !0,
  92998. e._errorFound = !1,
  92999. void e.video.play().catch((function(t) {
  93000. e._processError(t)
  93001. }
  93002. ))
  93003. }
  93004. e._processError(t)
  93005. }
  93006. ))
  93007. }
  93008. ,
  93009. t.prototype.getClassName = function() {
  93010. return "VideoTexture"
  93011. }
  93012. ,
  93013. t.prototype._getName = function(e) {
  93014. return e instanceof HTMLVideoElement ? e.currentSrc : "object" == typeof e ? e.toString() : e
  93015. }
  93016. ,
  93017. t.prototype._getVideo = function(e) {
  93018. if (e.isNative)
  93019. return e;
  93020. if (e instanceof HTMLVideoElement)
  93021. return gi.SetCorsBehavior(e.currentSrc, e),
  93022. e;
  93023. var t = document.createElement("video");
  93024. return "string" == typeof e ? (gi.SetCorsBehavior(e, t),
  93025. t.src = e) : (gi.SetCorsBehavior(e[0], t),
  93026. e.forEach((function(e) {
  93027. var i = document.createElement("source");
  93028. i.src = e,
  93029. t.appendChild(i)
  93030. }
  93031. ))),
  93032. this.onDisposeObservable.addOnce((function() {
  93033. Wf(t)
  93034. }
  93035. )),
  93036. t
  93037. }
  93038. ,
  93039. t.prototype._rebuild = function() {
  93040. this.update()
  93041. }
  93042. ,
  93043. t.prototype.update = function() {
  93044. this.autoUpdateTexture && this.updateTexture(!0)
  93045. }
  93046. ,
  93047. t.prototype.updateTexture = function(e) {
  93048. e && (this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0,
  93049. this._updateInternalTexture()))
  93050. }
  93051. ,
  93052. t.prototype.updateURL = function(e) {
  93053. this.video.src = e,
  93054. this._currentSrc = e
  93055. }
  93056. ,
  93057. t.prototype.clone = function() {
  93058. return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)
  93059. }
  93060. ,
  93061. t.prototype.dispose = function() {
  93062. e.prototype.dispose.call(this),
  93063. this._currentSrc = null,
  93064. this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(),
  93065. this._onUserActionRequestedObservable = null),
  93066. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture),
  93067. this.video.removeEventListener("paused", this._updateInternalTexture),
  93068. this.video.removeEventListener("seeked", this._updateInternalTexture),
  93069. this.video.removeEventListener("emptied", this._reset),
  93070. this.video.pause()
  93071. }
  93072. ,
  93073. t.CreateFromStreamAsync = function(e, i, n, r) {
  93074. void 0 === r && (r = !0);
  93075. var o = e.getEngine().createVideoElement(n);
  93076. return e.getEngine()._badOS && (document.body.appendChild(o),
  93077. o.style.transform = "scale(0.0001, 0.0001)",
  93078. o.style.opacity = "0",
  93079. o.style.position = "fixed",
  93080. o.style.bottom = "0px",
  93081. o.style.right = "0px"),
  93082. o.setAttribute("autoplay", ""),
  93083. o.setAttribute("muted", "true"),
  93084. o.setAttribute("playsinline", ""),
  93085. o.muted = !0,
  93086. void 0 !== o.mozSrcObject ? o.mozSrcObject = i : "object" == typeof o.srcObject ? o.srcObject = i : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
  93087. o.src = window.URL && window.URL.createObjectURL(i)),
  93088. new Promise((function(i) {
  93089. var n = function() {
  93090. var a = new t("video",o,e,!0,r);
  93091. e.getEngine()._badOS && a.onDisposeObservable.addOnce((function() {
  93092. o.remove()
  93093. }
  93094. )),
  93095. a.onDisposeObservable.addOnce((function() {
  93096. Wf(o)
  93097. }
  93098. )),
  93099. i(a),
  93100. o.removeEventListener("playing", n)
  93101. };
  93102. o.addEventListener("playing", n),
  93103. o.play()
  93104. }
  93105. ))
  93106. }
  93107. ,
  93108. t.CreateFromWebCamAsync = function(e, t, i, n) {
  93109. var r, o = this;
  93110. if (void 0 === i && (i = !1),
  93111. void 0 === n && (n = !0),
  93112. t && t.deviceId && (r = {
  93113. exact: t.deviceId
  93114. }),
  93115. navigator.mediaDevices)
  93116. return navigator.mediaDevices.getUserMedia({
  93117. video: t,
  93118. audio: i
  93119. }).then((function(i) {
  93120. return o.CreateFromStreamAsync(e, i, t, n)
  93121. }
  93122. ));
  93123. var a = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  93124. return a && a({
  93125. video: {
  93126. deviceId: r,
  93127. width: {
  93128. min: t && t.minWidth || 256,
  93129. max: t && t.maxWidth || 640
  93130. },
  93131. height: {
  93132. min: t && t.minHeight || 256,
  93133. max: t && t.maxHeight || 480
  93134. }
  93135. },
  93136. audio: i
  93137. }, (function(i) {
  93138. return o.CreateFromStreamAsync(e, i, t, n)
  93139. }
  93140. ), (function(e) {
  93141. K.Error(e.name)
  93142. }
  93143. )),
  93144. Promise.reject("No support for userMedia on this device")
  93145. }
  93146. ,
  93147. t.CreateFromWebCam = function(e, t, i, n, r) {
  93148. void 0 === n && (n = !1),
  93149. void 0 === r && (r = !0),
  93150. this.CreateFromWebCamAsync(e, i, n, r).then((function(e) {
  93151. t && t(e)
  93152. }
  93153. )).catch((function(e) {
  93154. K.Error(e.name)
  93155. }
  93156. ))
  93157. }
  93158. ,
  93159. t
  93160. }(io)
  93161. , Xf = function(e) {
  93162. function t() {
  93163. return null !== e && e.apply(this, arguments) || this
  93164. }
  93165. return U(t, e),
  93166. Object.defineProperty(t.prototype, "videoTexture", {
  93167. get: function() {
  93168. return this._texture
  93169. },
  93170. enumerable: !1,
  93171. configurable: !0
  93172. }),
  93173. Object.defineProperty(t.prototype, "videoMode", {
  93174. get: function() {
  93175. return this.textureMode
  93176. },
  93177. set: function(e) {
  93178. this.textureMode = e
  93179. },
  93180. enumerable: !1,
  93181. configurable: !0
  93182. }),
  93183. t.prototype._initTexture = function(e, t, i) {
  93184. var n = this
  93185. , r = {
  93186. loop: i.loop,
  93187. autoPlay: i.autoPlay,
  93188. autoUpdateTexture: !0,
  93189. poster: i.poster
  93190. }
  93191. , o = new Hf((this.name || "videoDome") + "_texture",e,t,i.generateMipMaps,this._useDirectMapping,io.TRILINEAR_SAMPLINGMODE,r);
  93192. return i.clickToPlay && (this._pointerObserver = t.onPointerObservable.add((function(e) {
  93193. e.type !== Xi.POINTERUP && n._texture.video.play()
  93194. }
  93195. ))),
  93196. this._textureObserver = o.onLoadObservable.add((function() {
  93197. n.onLoadObservable.notifyObservers()
  93198. }
  93199. )),
  93200. o
  93201. }
  93202. ,
  93203. t.prototype.dispose = function(t, i) {
  93204. void 0 === i && (i = !1),
  93205. this._texture.onLoadObservable.remove(this._textureObserver),
  93206. this._scene.onPointerObservable.remove(this._pointerObserver),
  93207. e.prototype.dispose.call(this, t, i)
  93208. }
  93209. ,
  93210. t.MODE_MONOSCOPIC = Gd.MODE_MONOSCOPIC,
  93211. t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
  93212. t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
  93213. t
  93214. }(Gd)
  93215. , jf = function() {
  93216. function e(e) {
  93217. this.engine = e,
  93218. this._captureGPUFrameTime = !1,
  93219. this._captureShaderCompilationTime = !1,
  93220. this._shaderCompilationTime = new un,
  93221. this._onBeginFrameObserver = null,
  93222. this._onEndFrameObserver = null,
  93223. this._onBeforeShaderCompilationObserver = null,
  93224. this._onAfterShaderCompilationObserver = null
  93225. }
  93226. return Object.defineProperty(e.prototype, "gpuFrameTimeCounter", {
  93227. get: function() {
  93228. return this.engine.getGPUFrameTimeCounter()
  93229. },
  93230. enumerable: !1,
  93231. configurable: !0
  93232. }),
  93233. Object.defineProperty(e.prototype, "captureGPUFrameTime", {
  93234. get: function() {
  93235. return this._captureGPUFrameTime
  93236. },
  93237. set: function(e) {
  93238. e !== this._captureGPUFrameTime && (this._captureGPUFrameTime = e,
  93239. this.engine.captureGPUFrameTime(e))
  93240. },
  93241. enumerable: !1,
  93242. configurable: !0
  93243. }),
  93244. Object.defineProperty(e.prototype, "shaderCompilationTimeCounter", {
  93245. get: function() {
  93246. return this._shaderCompilationTime
  93247. },
  93248. enumerable: !1,
  93249. configurable: !0
  93250. }),
  93251. Object.defineProperty(e.prototype, "captureShaderCompilationTime", {
  93252. get: function() {
  93253. return this._captureShaderCompilationTime
  93254. },
  93255. set: function(e) {
  93256. var t = this;
  93257. e !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = e,
  93258. e ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add((function() {
  93259. t._shaderCompilationTime.fetchNewFrame(),
  93260. t._shaderCompilationTime.beginMonitoring()
  93261. }
  93262. )),
  93263. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add((function() {
  93264. t._shaderCompilationTime.endMonitoring()
  93265. }
  93266. ))) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
  93267. this._onBeforeShaderCompilationObserver = null,
  93268. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
  93269. this._onAfterShaderCompilationObserver = null))
  93270. },
  93271. enumerable: !1,
  93272. configurable: !0
  93273. }),
  93274. e.prototype.dispose = function() {
  93275. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),
  93276. this._onBeginFrameObserver = null,
  93277. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),
  93278. this._onEndFrameObserver = null,
  93279. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
  93280. this._onBeforeShaderCompilationObserver = null,
  93281. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
  93282. this._onAfterShaderCompilationObserver = null,
  93283. this.engine = null
  93284. }
  93285. ,
  93286. e
  93287. }()
  93288. , Yf = function() {
  93289. function e(e) {
  93290. var t = this;
  93291. this.scene = e,
  93292. this._captureActiveMeshesEvaluationTime = !1,
  93293. this._activeMeshesEvaluationTime = new un,
  93294. this._captureRenderTargetsRenderTime = !1,
  93295. this._renderTargetsRenderTime = new un,
  93296. this._registerBeforeRenderTime = new un,
  93297. this._onBeforeRegisterBeforeRenderObserver = null,
  93298. this._onAfterRegisterBeforeRenderObserver = null,
  93299. this._RTT1Time = new un,
  93300. this._onBeforeRTT1Observer = null,
  93301. this._onAfterRTT1Observer = null,
  93302. this._registerAfterRenderTime = new un,
  93303. this._onBeforeRegisterAfterRenderObserver = null,
  93304. this._onAfterRegisterAfterRenderObserver = null,
  93305. this._captureFrameTime = !1,
  93306. this._frameTime = new un,
  93307. this._captureRenderTime = !1,
  93308. this._renderTime = new un,
  93309. this._captureInterFrameTime = !1,
  93310. this._interFrameTime = new un,
  93311. this._captureParticlesRenderTime = !1,
  93312. this._particlesRenderTime = new un,
  93313. this._captureSpritesRenderTime = !1,
  93314. this._spritesRenderTime = new un,
  93315. this._capturePhysicsTime = !1,
  93316. this._physicsTime = new un,
  93317. this._captureAnimationsTime = !1,
  93318. this._animationsTime = new un,
  93319. this._captureCameraRenderTime = !1,
  93320. this._cameraRenderTime = new un,
  93321. this._onBeforeActiveMeshesEvaluationObserver = null,
  93322. this._onAfterActiveMeshesEvaluationObserver = null,
  93323. this._onBeforeRenderTargetsRenderObserver = null,
  93324. this._onAfterRenderTargetsRenderObserver = null,
  93325. this._onAfterRenderObserver = null,
  93326. this._onBeforeDrawPhaseObserver = null,
  93327. this._onAfterDrawPhaseObserver = null,
  93328. this._onBeforeAnimationsObserver = null,
  93329. this._onBeforeParticlesRenderingObserver = null,
  93330. this._onAfterParticlesRenderingObserver = null,
  93331. this._onBeforeSpritesRenderingObserver = null,
  93332. this._onAfterSpritesRenderingObserver = null,
  93333. this._onBeforePhysicsObserver = null,
  93334. this._onAfterPhysicsObserver = null,
  93335. this._onAfterAnimationsObserver = null,
  93336. this._onBeforeCameraRenderObserver = null,
  93337. this._onAfterCameraRenderObserver = null,
  93338. this._onBeforeAnimationsObserver = e.onBeforeAnimationsObservable.add((function() {
  93339. t._captureActiveMeshesEvaluationTime && t._activeMeshesEvaluationTime.fetchNewFrame(),
  93340. t._captureRenderTargetsRenderTime && t._renderTargetsRenderTime.fetchNewFrame(),
  93341. t._captureFrameTime && (gi.StartPerformanceCounter("Scene rendering"),
  93342. t._frameTime.beginMonitoring()),
  93343. t._captureInterFrameTime && t._interFrameTime.endMonitoring(),
  93344. t._captureParticlesRenderTime && t._particlesRenderTime.fetchNewFrame(),
  93345. t._captureSpritesRenderTime && t._spritesRenderTime.fetchNewFrame(),
  93346. t._captureAnimationsTime && t._animationsTime.beginMonitoring(),
  93347. t.scene.getEngine()._drawCalls.fetchNewFrame()
  93348. }
  93349. )),
  93350. this._onAfterRenderObserver = e.onAfterRenderObservable.add((function() {
  93351. t._captureFrameTime && (gi.EndPerformanceCounter("Scene rendering"),
  93352. t._frameTime.endMonitoring()),
  93353. t._captureRenderTime && t._renderTime.endMonitoring(!1),
  93354. t._captureInterFrameTime && t._interFrameTime.beginMonitoring()
  93355. }
  93356. )),
  93357. this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
  93358. t._registerBeforeRenderTime.beginMonitoring()
  93359. }),
  93360. this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
  93361. t._registerBeforeRenderTime.endMonitoring()
  93362. }),
  93363. this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
  93364. t._registerAfterRenderTime.beginMonitoring()
  93365. }),
  93366. this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
  93367. t._registerAfterRenderTime.endMonitoring()
  93368. }),
  93369. this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
  93370. t._RTT1Time.beginMonitoring()
  93371. }),
  93372. this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
  93373. t._RTT1Time.endMonitoring()
  93374. })
  93375. }
  93376. return Object.defineProperty(e.prototype, "activeMeshesEvaluationTimeCounter", {
  93377. get: function() {
  93378. return this._activeMeshesEvaluationTime
  93379. },
  93380. enumerable: !1,
  93381. configurable: !0
  93382. }),
  93383. Object.defineProperty(e.prototype, "captureActiveMeshesEvaluationTime", {
  93384. get: function() {
  93385. return this._captureActiveMeshesEvaluationTime
  93386. },
  93387. set: function(e) {
  93388. var t = this;
  93389. e !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = e,
  93390. e ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add((function() {
  93391. gi.StartPerformanceCounter("Active meshes evaluation"),
  93392. t._activeMeshesEvaluationTime.beginMonitoring()
  93393. }
  93394. )),
  93395. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add((function() {
  93396. gi.EndPerformanceCounter("Active meshes evaluation"),
  93397. t._activeMeshesEvaluationTime.endMonitoring()
  93398. }
  93399. ))) : (this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
  93400. this._onBeforeActiveMeshesEvaluationObserver = null,
  93401. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
  93402. this._onAfterActiveMeshesEvaluationObserver = null))
  93403. },
  93404. enumerable: !1,
  93405. configurable: !0
  93406. }),
  93407. Object.defineProperty(e.prototype, "renderTargetsRenderTimeCounter", {
  93408. get: function() {
  93409. return this._renderTargetsRenderTime
  93410. },
  93411. enumerable: !1,
  93412. configurable: !0
  93413. }),
  93414. Object.defineProperty(e.prototype, "registerBeforeTimeCounter", {
  93415. get: function() {
  93416. return this._registerBeforeRenderTime
  93417. },
  93418. enumerable: !1,
  93419. configurable: !0
  93420. }),
  93421. Object.defineProperty(e.prototype, "getRTT1TimeCounter", {
  93422. get: function() {
  93423. return this._RTT1Time
  93424. },
  93425. enumerable: !1,
  93426. configurable: !0
  93427. }),
  93428. Object.defineProperty(e.prototype, "registerAfterTimeCounter", {
  93429. get: function() {
  93430. return this._registerAfterRenderTime
  93431. },
  93432. enumerable: !1,
  93433. configurable: !0
  93434. }),
  93435. Object.defineProperty(e.prototype, "captureRenderTargetsRenderTime", {
  93436. get: function() {
  93437. return this._captureRenderTargetsRenderTime
  93438. },
  93439. set: function(e) {
  93440. var t = this;
  93441. e !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = e,
  93442. e ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add((function() {
  93443. gi.StartPerformanceCounter("Render targets rendering"),
  93444. t._renderTargetsRenderTime.beginMonitoring()
  93445. }
  93446. )),
  93447. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add((function() {
  93448. gi.EndPerformanceCounter("Render targets rendering"),
  93449. t._renderTargetsRenderTime.endMonitoring(!1)
  93450. }
  93451. ))) : (this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
  93452. this._onBeforeRenderTargetsRenderObserver = null,
  93453. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
  93454. this._onAfterRenderTargetsRenderObserver = null))
  93455. },
  93456. enumerable: !1,
  93457. configurable: !0
  93458. }),
  93459. Object.defineProperty(e.prototype, "particlesRenderTimeCounter", {
  93460. get: function() {
  93461. return this._particlesRenderTime
  93462. },
  93463. enumerable: !1,
  93464. configurable: !0
  93465. }),
  93466. Object.defineProperty(e.prototype, "captureParticlesRenderTime", {
  93467. get: function() {
  93468. return this._captureParticlesRenderTime
  93469. },
  93470. set: function(e) {
  93471. var t = this;
  93472. e !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = e,
  93473. e ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add((function() {
  93474. gi.StartPerformanceCounter("Particles"),
  93475. t._particlesRenderTime.beginMonitoring()
  93476. }
  93477. )),
  93478. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add((function() {
  93479. gi.EndPerformanceCounter("Particles"),
  93480. t._particlesRenderTime.endMonitoring(!1)
  93481. }
  93482. ))) : (this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
  93483. this._onBeforeParticlesRenderingObserver = null,
  93484. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
  93485. this._onAfterParticlesRenderingObserver = null))
  93486. },
  93487. enumerable: !1,
  93488. configurable: !0
  93489. }),
  93490. Object.defineProperty(e.prototype, "spritesRenderTimeCounter", {
  93491. get: function() {
  93492. return this._spritesRenderTime
  93493. },
  93494. enumerable: !1,
  93495. configurable: !0
  93496. }),
  93497. Object.defineProperty(e.prototype, "captureSpritesRenderTime", {
  93498. get: function() {
  93499. return this._captureSpritesRenderTime
  93500. },
  93501. set: function(e) {
  93502. var t = this;
  93503. e !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = e,
  93504. this.scene.spriteManagers && (e ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add((function() {
  93505. gi.StartPerformanceCounter("Sprites"),
  93506. t._spritesRenderTime.beginMonitoring()
  93507. }
  93508. )),
  93509. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add((function() {
  93510. gi.EndPerformanceCounter("Sprites"),
  93511. t._spritesRenderTime.endMonitoring(!1)
  93512. }
  93513. ))) : (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
  93514. this._onBeforeSpritesRenderingObserver = null,
  93515. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
  93516. this._onAfterSpritesRenderingObserver = null)))
  93517. },
  93518. enumerable: !1,
  93519. configurable: !0
  93520. }),
  93521. Object.defineProperty(e.prototype, "physicsTimeCounter", {
  93522. get: function() {
  93523. return this._physicsTime
  93524. },
  93525. enumerable: !1,
  93526. configurable: !0
  93527. }),
  93528. Object.defineProperty(e.prototype, "capturePhysicsTime", {
  93529. get: function() {
  93530. return this._capturePhysicsTime
  93531. },
  93532. set: function(e) {
  93533. var t = this;
  93534. e !== this._capturePhysicsTime && this.scene.onBeforePhysicsObservable && (this._capturePhysicsTime = e,
  93535. e ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add((function() {
  93536. gi.StartPerformanceCounter("Physics"),
  93537. t._physicsTime.beginMonitoring()
  93538. }
  93539. )),
  93540. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add((function() {
  93541. gi.EndPerformanceCounter("Physics"),
  93542. t._physicsTime.endMonitoring()
  93543. }
  93544. ))) : (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
  93545. this._onBeforePhysicsObserver = null,
  93546. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
  93547. this._onAfterPhysicsObserver = null))
  93548. },
  93549. enumerable: !1,
  93550. configurable: !0
  93551. }),
  93552. Object.defineProperty(e.prototype, "animationsTimeCounter", {
  93553. get: function() {
  93554. return this._animationsTime
  93555. },
  93556. enumerable: !1,
  93557. configurable: !0
  93558. }),
  93559. Object.defineProperty(e.prototype, "captureAnimationsTime", {
  93560. get: function() {
  93561. return this._captureAnimationsTime
  93562. },
  93563. set: function(e) {
  93564. var t = this;
  93565. e !== this._captureAnimationsTime && (this._captureAnimationsTime = e,
  93566. e ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add((function() {
  93567. t._animationsTime.endMonitoring()
  93568. }
  93569. )) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
  93570. this._onAfterAnimationsObserver = null))
  93571. },
  93572. enumerable: !1,
  93573. configurable: !0
  93574. }),
  93575. Object.defineProperty(e.prototype, "frameTimeCounter", {
  93576. get: function() {
  93577. return this._frameTime
  93578. },
  93579. enumerable: !1,
  93580. configurable: !0
  93581. }),
  93582. Object.defineProperty(e.prototype, "captureFrameTime", {
  93583. get: function() {
  93584. return this._captureFrameTime
  93585. },
  93586. set: function(e) {
  93587. this._captureFrameTime = e
  93588. },
  93589. enumerable: !1,
  93590. configurable: !0
  93591. }),
  93592. Object.defineProperty(e.prototype, "interFrameTimeCounter", {
  93593. get: function() {
  93594. return this._interFrameTime
  93595. },
  93596. enumerable: !1,
  93597. configurable: !0
  93598. }),
  93599. Object.defineProperty(e.prototype, "captureInterFrameTime", {
  93600. get: function() {
  93601. return this._captureInterFrameTime
  93602. },
  93603. set: function(e) {
  93604. this._captureInterFrameTime = e
  93605. },
  93606. enumerable: !1,
  93607. configurable: !0
  93608. }),
  93609. Object.defineProperty(e.prototype, "renderTimeCounter", {
  93610. get: function() {
  93611. return this._renderTime
  93612. },
  93613. enumerable: !1,
  93614. configurable: !0
  93615. }),
  93616. Object.defineProperty(e.prototype, "captureRenderTime", {
  93617. get: function() {
  93618. return this._captureRenderTime
  93619. },
  93620. set: function(e) {
  93621. var t = this;
  93622. e !== this._captureRenderTime && (this._captureRenderTime = e,
  93623. e ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add((function() {
  93624. t._renderTime.beginMonitoring(),
  93625. gi.StartPerformanceCounter("Main render")
  93626. }
  93627. )),
  93628. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add((function() {
  93629. t._renderTime.endMonitoring(!1),
  93630. gi.EndPerformanceCounter("Main render")
  93631. }
  93632. ))) : (this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
  93633. this._onBeforeDrawPhaseObserver = null,
  93634. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
  93635. this._onAfterDrawPhaseObserver = null))
  93636. },
  93637. enumerable: !1,
  93638. configurable: !0
  93639. }),
  93640. Object.defineProperty(e.prototype, "cameraRenderTimeCounter", {
  93641. get: function() {
  93642. return this._cameraRenderTime
  93643. },
  93644. enumerable: !1,
  93645. configurable: !0
  93646. }),
  93647. Object.defineProperty(e.prototype, "captureCameraRenderTime", {
  93648. get: function() {
  93649. return this._captureCameraRenderTime
  93650. },
  93651. set: function(e) {
  93652. var t = this;
  93653. e !== this._captureCameraRenderTime && (this._captureCameraRenderTime = e,
  93654. e ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add((function(e) {
  93655. t._cameraRenderTime.beginMonitoring(),
  93656. gi.StartPerformanceCounter("Rendering camera ".concat(e.name))
  93657. }
  93658. )),
  93659. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add((function(e) {
  93660. t._cameraRenderTime.endMonitoring(!1),
  93661. gi.EndPerformanceCounter("Rendering camera ".concat(e.name))
  93662. }
  93663. ))) : (this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  93664. this._onBeforeCameraRenderObserver = null,
  93665. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  93666. this._onAfterCameraRenderObserver = null))
  93667. },
  93668. enumerable: !1,
  93669. configurable: !0
  93670. }),
  93671. Object.defineProperty(e.prototype, "drawCallsCounter", {
  93672. get: function() {
  93673. return this.scene.getEngine()._drawCalls
  93674. },
  93675. enumerable: !1,
  93676. configurable: !0
  93677. }),
  93678. e.prototype.dispose = function() {
  93679. this.scene.onBeforeRunRegisterBeforeRenderObservable.remove(this._onBeforeRegisterBeforeRenderObserver),
  93680. this._onBeforeRegisterBeforeRenderObserver = null,
  93681. this.scene.onAfterRunRegisterBeforeRenderObservable.remove(this._onAfterRegisterBeforeRenderObserver),
  93682. this._onAfterRegisterBeforeRenderObserver = null,
  93683. this.scene.onBeforeRunRegisterAfterRenderObservable.remove(this._onBeforeRegisterAfterRenderObserver),
  93684. this._onBeforeRegisterAfterRenderObserver = null,
  93685. this.scene.onAfterRunRegisterAfterRenderObservable.remove(this._onAfterRegisterAfterRenderObserver),
  93686. this._onAfterRegisterAfterRenderObserver = null,
  93687. this.scene.onBeforeRTT1Observable.remove(this._onBeforeRTT1Observer),
  93688. this._onBeforeRTT1Observer = null,
  93689. this.scene.onAfterRTT1Observable.remove(this._onAfterRTT1Observer),
  93690. this._onAfterRTT1Observer = null,
  93691. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  93692. this._onAfterRenderObserver = null,
  93693. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
  93694. this._onBeforeActiveMeshesEvaluationObserver = null,
  93695. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
  93696. this._onAfterActiveMeshesEvaluationObserver = null,
  93697. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
  93698. this._onBeforeRenderTargetsRenderObserver = null,
  93699. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
  93700. this._onAfterRenderTargetsRenderObserver = null,
  93701. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
  93702. this._onBeforeAnimationsObserver = null,
  93703. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
  93704. this._onBeforeParticlesRenderingObserver = null,
  93705. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
  93706. this._onAfterParticlesRenderingObserver = null,
  93707. this._onBeforeSpritesRenderingObserver && (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
  93708. this._onBeforeSpritesRenderingObserver = null),
  93709. this._onAfterSpritesRenderingObserver && (this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
  93710. this._onAfterSpritesRenderingObserver = null),
  93711. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
  93712. this._onBeforeDrawPhaseObserver = null,
  93713. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
  93714. this._onAfterDrawPhaseObserver = null,
  93715. this._onBeforePhysicsObserver && (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
  93716. this._onBeforePhysicsObserver = null),
  93717. this._onAfterPhysicsObserver && (this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
  93718. this._onAfterPhysicsObserver = null),
  93719. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
  93720. this._onAfterAnimationsObserver = null,
  93721. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
  93722. this._onBeforeCameraRenderObserver = null,
  93723. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
  93724. this._onAfterCameraRenderObserver = null,
  93725. this.scene = null
  93726. }
  93727. ,
  93728. e
  93729. }();
  93730. Pt.ShadersStore.glowMapGenerationPixelShader = "#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include<helperFunctions>\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\n#ifdef GLOW\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\nfinalColor.a=albedoTexture.a;\n#endif\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifdef EMISSIVE\nvec4 emissive=texture2D(emissiveSampler,vUVEmissive);\n#ifdef EMISSIVE_ISLINEAR\nemissive=toGammaSpace(emissive);\n#endif\ngl_FragColor=emissive*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef HIGHLIGHT\ngl_FragColor.a=glowColor.a;\n#endif\n}";
  93731. Pt.ShadersStore.glowMapGenerationVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n}";
  93732. var Kf = function() {
  93733. function e(t, i) {
  93734. this._vertexBuffers = {},
  93735. this._maxSize = 0,
  93736. this._mainTextureDesiredSize = {
  93737. width: 0,
  93738. height: 0
  93739. },
  93740. this._shouldRender = !0,
  93741. this._postProcesses = [],
  93742. this._textures = [],
  93743. this._emissiveTextureAndColor = {
  93744. texture: null,
  93745. color: new N
  93746. },
  93747. this.neutralColor = new N,
  93748. this.isEnabled = !0,
  93749. this.disableBoundingBoxesFromEffectLayer = !1,
  93750. this.onDisposeObservable = new h,
  93751. this.onBeforeRenderMainTextureObservable = new h,
  93752. this.onBeforeComposeObservable = new h,
  93753. this.onBeforeRenderMeshToEffect = new h,
  93754. this.onAfterRenderMeshToEffect = new h,
  93755. this.onAfterComposeObservable = new h,
  93756. this.onSizeChangedObservable = new h,
  93757. this._materialForRendering = {},
  93758. this.name = t,
  93759. this._scene = i || E.LastCreatedScene,
  93760. e._SceneComponentInitialization(this._scene),
  93761. this._engine = this._scene.getEngine(),
  93762. this._maxSize = this._engine.getCaps().maxTextureSize,
  93763. this._scene.effectLayers.push(this),
  93764. this._mergeDrawWrapper = [],
  93765. this._generateIndexBuffer(),
  93766. this._generateVertexBuffer()
  93767. }
  93768. return Object.defineProperty(e.prototype, "camera", {
  93769. get: function() {
  93770. return this._effectLayerOptions.camera
  93771. },
  93772. enumerable: !1,
  93773. configurable: !0
  93774. }),
  93775. Object.defineProperty(e.prototype, "renderingGroupId", {
  93776. get: function() {
  93777. return this._effectLayerOptions.renderingGroupId
  93778. },
  93779. set: function(e) {
  93780. this._effectLayerOptions.renderingGroupId = e
  93781. },
  93782. enumerable: !1,
  93783. configurable: !0
  93784. }),
  93785. Object.defineProperty(e.prototype, "mainTexture", {
  93786. get: function() {
  93787. return this._mainTexture
  93788. },
  93789. enumerable: !1,
  93790. configurable: !0
  93791. }),
  93792. e.prototype.setMaterialForRendering = function(e, t) {
  93793. if (this._mainTexture.setMaterialForRendering(e, t),
  93794. Array.isArray(e))
  93795. for (var i = 0; i < e.length; ++i) {
  93796. var n = e[i];
  93797. t ? this._materialForRendering[n.uniqueId] = [n, t] : delete this._materialForRendering[n.uniqueId]
  93798. }
  93799. else
  93800. t ? this._materialForRendering[e.uniqueId] = [e, t] : delete this._materialForRendering[e.uniqueId]
  93801. }
  93802. ,
  93803. e.prototype._numInternalDraws = function() {
  93804. return 1
  93805. }
  93806. ,
  93807. e.prototype._init = function(e) {
  93808. this._effectLayerOptions = V({
  93809. mainTextureRatio: .5,
  93810. alphaBlendingMode: a.ALPHA_COMBINE,
  93811. camera: null,
  93812. renderingGroupId: -1
  93813. }, e),
  93814. this._setMainTextureSize(),
  93815. this._createMainTexture(),
  93816. this._createTextureAndPostProcesses()
  93817. }
  93818. ,
  93819. e.prototype._generateIndexBuffer = function() {
  93820. var e = [];
  93821. e.push(0),
  93822. e.push(1),
  93823. e.push(2),
  93824. e.push(0),
  93825. e.push(2),
  93826. e.push(3),
  93827. this._indexBuffer = this._engine.createIndexBuffer(e)
  93828. }
  93829. ,
  93830. e.prototype._generateVertexBuffer = function() {
  93831. var e = [];
  93832. e.push(1, 1),
  93833. e.push(-1, 1),
  93834. e.push(-1, -1),
  93835. e.push(1, -1);
  93836. var t = new Bi(this._engine,e,Bi.PositionKind,!1,!1,2);
  93837. this._vertexBuffers[Bi.PositionKind] = t
  93838. }
  93839. ,
  93840. e.prototype._setMainTextureSize = function() {
  93841. this._effectLayerOptions.mainTextureFixedSize ? (this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize,
  93842. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize) : (this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio,
  93843. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio,
  93844. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? vr.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width,
  93845. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? vr.GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height),
  93846. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width),
  93847. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height)
  93848. }
  93849. ,
  93850. e.prototype._createMainTexture = function() {
  93851. var e = this;
  93852. for (var t in this._mainTexture = new ns("EffectLayerMainRTT",{
  93853. width: this._mainTextureDesiredSize.width,
  93854. height: this._mainTextureDesiredSize.height
  93855. },this._scene,!1,!0,a.TEXTURETYPE_UNSIGNED_INT),
  93856. this._mainTexture.activeCamera = this._effectLayerOptions.camera,
  93857. this._mainTexture.wrapU = io.CLAMP_ADDRESSMODE,
  93858. this._mainTexture.wrapV = io.CLAMP_ADDRESSMODE,
  93859. this._mainTexture.anisotropicFilteringLevel = 1,
  93860. this._mainTexture.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
  93861. this._mainTexture.renderParticles = !1,
  93862. this._mainTexture.renderList = null,
  93863. this._mainTexture.ignoreCameraViewport = !0,
  93864. this._materialForRendering) {
  93865. var i = this._materialForRendering[t]
  93866. , n = i[0]
  93867. , r = i[1];
  93868. this._mainTexture.setMaterialForRendering(n, r)
  93869. }
  93870. if (this._mainTexture.customIsReadyFunction = function(t, i) {
  93871. if (!t.isReady(!1))
  93872. return !1;
  93873. if (0 === i && t.subMeshes)
  93874. for (var n = 0; n < t.subMeshes.length; ++n) {
  93875. var r = t.subMeshes[n]
  93876. , o = r.getMaterial()
  93877. , a = r.getRenderingMesh();
  93878. if (o) {
  93879. var s = a._getInstancesRenderList(r._id, !!r.getReplacementMesh()).hardwareInstancedRendering[r._id] || a.hasThinInstances;
  93880. if (e._setEmissiveTextureAndColor(a, r, o),
  93881. !e._isReady(r, s, e._emissiveTextureAndColor.texture))
  93882. return !1
  93883. }
  93884. }
  93885. return !0
  93886. }
  93887. ,
  93888. this._mainTexture.customRenderFunction = function(t, i, n, r) {
  93889. var o;
  93890. e.onBeforeRenderMainTextureObservable.notifyObservers(e);
  93891. var a = e._scene.getEngine();
  93892. if (r.length) {
  93893. for (a.setColorWrite(!1),
  93894. o = 0; o < r.length; o++)
  93895. e._renderSubMesh(r.data[o]);
  93896. a.setColorWrite(!0)
  93897. }
  93898. for (o = 0; o < t.length; o++)
  93899. e._renderSubMesh(t.data[o]);
  93900. for (o = 0; o < i.length; o++)
  93901. e._renderSubMesh(i.data[o]);
  93902. var s = a.getAlphaMode();
  93903. for (o = 0; o < n.length; o++)
  93904. e._renderSubMesh(n.data[o], !0);
  93905. a.setAlphaMode(s)
  93906. }
  93907. ,
  93908. this._mainTexture.onClearObservable.add((function(t) {
  93909. t.clear(e.neutralColor, !0, !0, !0)
  93910. }
  93911. )),
  93912. this._scene.getBoundingBoxRenderer) {
  93913. var o = this._scene.getBoundingBoxRenderer().enabled;
  93914. this._mainTexture.onBeforeBindObservable.add((function() {
  93915. e._scene.getBoundingBoxRenderer().enabled = !e.disableBoundingBoxesFromEffectLayer && o
  93916. }
  93917. )),
  93918. this._mainTexture.onAfterUnbindObservable.add((function() {
  93919. e._scene.getBoundingBoxRenderer().enabled = o
  93920. }
  93921. ))
  93922. }
  93923. }
  93924. ,
  93925. e.prototype._addCustomEffectDefines = function(e) {}
  93926. ,
  93927. e.prototype._isReady = function(e, t, i) {
  93928. var n, r = this._scene.getEngine(), o = e.getMesh(), a = null === (n = o._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === n ? void 0 : n[r.currentRenderPassId];
  93929. if (a)
  93930. return a.isReadyForSubMesh(o, e, t);
  93931. var s = e.getMaterial();
  93932. if (!s)
  93933. return !1;
  93934. if (this._useMeshMaterial(e.getRenderingMesh()))
  93935. return s.isReadyForSubMesh(e.getMesh(), e, t);
  93936. var l = []
  93937. , c = [Bi.PositionKind]
  93938. , u = !1
  93939. , h = !1;
  93940. if (s) {
  93941. var d = s.needAlphaTesting()
  93942. , p = s.getAlphaTestTexture()
  93943. , f = p && p.hasAlpha && (s.useAlphaFromDiffuseTexture || s._useAlphaFromAlbedoTexture);
  93944. p && (d || f) && (l.push("#define DIFFUSE"),
  93945. o.isVerticesDataPresent(Bi.UV2Kind) && 1 === p.coordinatesIndex ? (l.push("#define DIFFUSEUV2"),
  93946. h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define DIFFUSEUV1"),
  93947. u = !0),
  93948. d && (l.push("#define ALPHATEST"),
  93949. l.push("#define ALPHATESTVALUE 0.4")),
  93950. p.gammaSpace || l.push("#define DIFFUSE_ISLINEAR"));
  93951. var _ = s.opacityTexture;
  93952. _ && (l.push("#define OPACITY"),
  93953. o.isVerticesDataPresent(Bi.UV2Kind) && 1 === _.coordinatesIndex ? (l.push("#define OPACITYUV2"),
  93954. h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define OPACITYUV1"),
  93955. u = !0))
  93956. }
  93957. i && (l.push("#define EMISSIVE"),
  93958. o.isVerticesDataPresent(Bi.UV2Kind) && 1 === i.coordinatesIndex ? (l.push("#define EMISSIVEUV2"),
  93959. h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define EMISSIVEUV1"),
  93960. u = !0),
  93961. i.gammaSpace || l.push("#define EMISSIVE_ISLINEAR")),
  93962. o.isVerticesDataPresent(Bi.ColorKind) && o.hasVertexAlpha && (c.push(Bi.ColorKind),
  93963. l.push("#define VERTEXALPHA")),
  93964. u && (c.push(Bi.UVKind),
  93965. l.push("#define UV1")),
  93966. h && (c.push(Bi.UV2Kind),
  93967. l.push("#define UV2"));
  93968. var m = new ys;
  93969. if (o.useBones && o.computeBonesUsingShaders) {
  93970. c.push(Bi.MatricesIndicesKind),
  93971. c.push(Bi.MatricesWeightsKind),
  93972. o.numBoneInfluencers > 4 && (c.push(Bi.MatricesIndicesExtraKind),
  93973. c.push(Bi.MatricesWeightsExtraKind)),
  93974. l.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers);
  93975. var g = o.skeleton;
  93976. g && g.isUsingTextureForMatrices ? l.push("#define BONETEXTURE") : l.push("#define BonesPerMesh " + (g ? g.bones.length + 1 : 0)),
  93977. o.numBoneInfluencers > 0 && m.addCPUSkinningFallback(0, o)
  93978. } else
  93979. l.push("#define NUM_BONE_INFLUENCERS 0");
  93980. var v = o.morphTargetManager
  93981. , y = 0;
  93982. v && v.numInfluencers > 0 && (l.push("#define MORPHTARGETS"),
  93983. y = v.numInfluencers,
  93984. l.push("#define NUM_MORPH_INFLUENCERS " + y),
  93985. v.isUsingTextureForTargets && l.push("#define MORPHTARGETS_TEXTURE"),
  93986. Mr.PrepareAttributesForMorphTargetsInfluencers(c, o, y)),
  93987. t && (l.push("#define INSTANCES"),
  93988. Mr.PushAttributesForInstances(c),
  93989. e.getRenderingMesh().hasThinInstances && l.push("#define THIN_INSTANCES")),
  93990. this._addCustomEffectDefines(l);
  93991. var b = e._getDrawWrapper(void 0, !0)
  93992. , T = b.defines
  93993. , E = l.join("\n");
  93994. return T !== E && b.setEffect(this._engine.createEffect("glowMapGeneration", c, ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], E, m, void 0, void 0, {
  93995. maxSimultaneousMorphTargets: y
  93996. }), E),
  93997. b.effect.isReady()
  93998. }
  93999. ,
  94000. e.prototype.render = function() {
  94001. for (var e = 0; e < this._postProcesses.length; e++)
  94002. if (!this._postProcesses[e].isReady())
  94003. return;
  94004. var t = this._scene.getEngine()
  94005. , i = this._numInternalDraws()
  94006. , n = !0;
  94007. for (e = 0; e < i; ++e)
  94008. (o = this._mergeDrawWrapper[e]) || (o = this._mergeDrawWrapper[e] = new Gt(this._engine)).setEffect(this._createMergeEffect()),
  94009. n = n && o.effect.isReady();
  94010. if (n) {
  94011. this.onBeforeComposeObservable.notifyObservers(this);
  94012. var r = t.getAlphaMode();
  94013. for (e = 0; e < i; ++e) {
  94014. var o = this._mergeDrawWrapper[e];
  94015. t.enableEffect(o),
  94016. t.setState(!1),
  94017. t.bindBuffers(this._vertexBuffers, this._indexBuffer, o.effect),
  94018. t.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),
  94019. this._internalRender(o.effect, e)
  94020. }
  94021. t.setAlphaMode(r),
  94022. this.onAfterComposeObservable.notifyObservers(this);
  94023. var a = this._mainTexture.getSize();
  94024. this._setMainTextureSize(),
  94025. a.width === this._mainTextureDesiredSize.width && a.height === this._mainTextureDesiredSize.height || 0 === this._mainTextureDesiredSize.width || 0 === this._mainTextureDesiredSize.height || (this.onSizeChangedObservable.notifyObservers(this),
  94026. this._disposeTextureAndPostProcesses(),
  94027. this._createMainTexture(),
  94028. this._createTextureAndPostProcesses())
  94029. }
  94030. }
  94031. ,
  94032. e.prototype.hasMesh = function(e) {
  94033. return -1 === this.renderingGroupId || e.renderingGroupId === this.renderingGroupId
  94034. }
  94035. ,
  94036. e.prototype.shouldRender = function() {
  94037. return this.isEnabled && this._shouldRender
  94038. }
  94039. ,
  94040. e.prototype._shouldRenderMesh = function(e) {
  94041. return !0
  94042. }
  94043. ,
  94044. e.prototype._canRenderMesh = function(e, t) {
  94045. return !t.needAlphaBlendingForMesh(e)
  94046. }
  94047. ,
  94048. e.prototype._shouldRenderEmissiveTextureForMesh = function() {
  94049. return !0
  94050. }
  94051. ,
  94052. e.prototype._renderSubMesh = function(e, t) {
  94053. var i, n;
  94054. if (void 0 === t && (t = !1),
  94055. this.shouldRender()) {
  94056. var r = e.getMaterial()
  94057. , o = e.getMesh()
  94058. , a = e.getReplacementMesh()
  94059. , s = e.getRenderingMesh()
  94060. , l = e.getEffectiveMesh()
  94061. , c = this._scene
  94062. , u = c.getEngine();
  94063. if (l._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  94064. r && this._canRenderMesh(s, r)) {
  94065. var h = null !== (i = s.overrideMaterialSideOrientation) && void 0 !== i ? i : r.sideOrientation;
  94066. l._getWorldMatrixDeterminant() < 0 && (h = h === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation);
  94067. var d = h === Or.ClockWiseSideOrientation;
  94068. u.setState(r.backFaceCulling, r.zOffset, void 0, d, r.cullBackFaces, void 0, r.zOffsetUnits);
  94069. var p = s._getInstancesRenderList(e._id, !!a);
  94070. if (!p.mustReturn && this._shouldRenderMesh(s)) {
  94071. var f = p.hardwareInstancedRendering[e._id] || s.hasThinInstances;
  94072. if (this._setEmissiveTextureAndColor(s, e, r),
  94073. this.onBeforeRenderMeshToEffect.notifyObservers(o),
  94074. this._useMeshMaterial(s))
  94075. s.render(e, f, a || void 0);
  94076. else if (this._isReady(e, f, this._emissiveTextureAndColor.texture)) {
  94077. var _ = null === (n = l._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === n ? void 0 : n[u.currentRenderPassId]
  94078. , m = e._getDrawWrapper();
  94079. if (!m && _ && (m = _._getDrawWrapper()),
  94080. !m)
  94081. return;
  94082. var g = m.effect;
  94083. if (u.enableEffect(m),
  94084. !f) {
  94085. var v = c.forcePointsCloud ? Or.PointFillMode : c.forceWireframe ? Or.WireFrameFillMode : r.fillMode;
  94086. s._bind(e, g, v)
  94087. }
  94088. if (_ ? _.bindForSubMesh(l.getWorldMatrix(), l, e) : (g.setMatrix("viewProjection", c.getTransformMatrix()),
  94089. g.setMatrix("world", l.getWorldMatrix()),
  94090. g.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)),
  94091. !_) {
  94092. var y = r.needAlphaTesting()
  94093. , b = r.getAlphaTestTexture()
  94094. , T = b && b.hasAlpha && (r.useAlphaFromDiffuseTexture || r._useAlphaFromAlbedoTexture);
  94095. b && (y || T) && (g.setTexture("diffuseSampler", b),
  94096. (E = b.getTextureMatrix()) && g.setMatrix("diffuseMatrix", E));
  94097. var E, S = r.opacityTexture;
  94098. if (S && (g.setTexture("opacitySampler", S),
  94099. g.setFloat("opacityIntensity", S.level),
  94100. (E = S.getTextureMatrix()) && g.setMatrix("opacityMatrix", E)),
  94101. this._emissiveTextureAndColor.texture && (g.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture),
  94102. g.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())),
  94103. s.useBones && s.computeBonesUsingShaders && s.skeleton) {
  94104. var A = s.skeleton;
  94105. if (A.isUsingTextureForMatrices) {
  94106. var x = A.getTransformMatrixTexture(s);
  94107. if (!x)
  94108. return;
  94109. g.setTexture("boneSampler", x),
  94110. g.setFloat("boneTextureWidth", 4 * (A.bones.length + 1))
  94111. } else
  94112. g.setMatrices("mBones", A.getTransformMatrices(s))
  94113. }
  94114. Mr.BindMorphTargetParameters(s, g),
  94115. s.morphTargetManager && s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(g),
  94116. t && u.setAlphaMode(r.alphaMode)
  94117. }
  94118. s._processRendering(l, e, g, r.fillMode, p, f, (function(e, t) {
  94119. return g.setMatrix("world", t)
  94120. }
  94121. ))
  94122. } else
  94123. this._mainTexture.resetRefreshCounter();
  94124. this.onAfterRenderMeshToEffect.notifyObservers(o)
  94125. }
  94126. }
  94127. }
  94128. }
  94129. ,
  94130. e.prototype._useMeshMaterial = function(e) {
  94131. return !1
  94132. }
  94133. ,
  94134. e.prototype._rebuild = function() {
  94135. var e = this._vertexBuffers[Bi.PositionKind];
  94136. e && e._rebuild(),
  94137. this._generateIndexBuffer()
  94138. }
  94139. ,
  94140. e.prototype._disposeTextureAndPostProcesses = function() {
  94141. this._mainTexture.dispose();
  94142. for (var e = 0; e < this._postProcesses.length; e++)
  94143. this._postProcesses[e] && this._postProcesses[e].dispose();
  94144. for (this._postProcesses = [],
  94145. e = 0; e < this._textures.length; e++)
  94146. this._textures[e] && this._textures[e].dispose();
  94147. this._textures = []
  94148. }
  94149. ,
  94150. e.prototype.dispose = function() {
  94151. var e = this._vertexBuffers[Bi.PositionKind];
  94152. e && (e.dispose(),
  94153. this._vertexBuffers[Bi.PositionKind] = null),
  94154. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  94155. this._indexBuffer = null);
  94156. for (var t = 0, i = this._mergeDrawWrapper; t < i.length; t++)
  94157. i[t].dispose();
  94158. this._mergeDrawWrapper = [],
  94159. this._disposeTextureAndPostProcesses();
  94160. var n = this._scene.effectLayers.indexOf(this, 0);
  94161. n > -1 && this._scene.effectLayers.splice(n, 1),
  94162. this.onDisposeObservable.notifyObservers(this),
  94163. this.onDisposeObservable.clear(),
  94164. this.onBeforeRenderMainTextureObservable.clear(),
  94165. this.onBeforeComposeObservable.clear(),
  94166. this.onBeforeRenderMeshToEffect.clear(),
  94167. this.onAfterRenderMeshToEffect.clear(),
  94168. this.onAfterComposeObservable.clear(),
  94169. this.onSizeChangedObservable.clear()
  94170. }
  94171. ,
  94172. e.prototype.getClassName = function() {
  94173. return "EffectLayer"
  94174. }
  94175. ,
  94176. e.Parse = function(e, t, i) {
  94177. return gi.Instantiate(e.customType).Parse(e, t, i)
  94178. }
  94179. ,
  94180. e._SceneComponentInitialization = function(e) {
  94181. throw be("EffectLayerSceneComponent")
  94182. }
  94183. ,
  94184. k([Ce()], e.prototype, "name", void 0),
  94185. k([Fe()], e.prototype, "neutralColor", void 0),
  94186. k([Ce()], e.prototype, "isEnabled", void 0),
  94187. k([Ve()], e.prototype, "camera", null),
  94188. k([Ce()], e.prototype, "renderingGroupId", null),
  94189. k([Ce()], e.prototype, "disableBoundingBoxesFromEffectLayer", void 0),
  94190. e
  94191. }();
  94192. o.AddParser(Wi.NAME_EFFECTLAYER, (function(e, t, i, n) {
  94193. if (e.effectLayers) {
  94194. i.effectLayers || (i.effectLayers = new Array);
  94195. for (var r = 0; r < e.effectLayers.length; r++) {
  94196. var o = Kf.Parse(e.effectLayers[r], t, n);
  94197. i.effectLayers.push(o)
  94198. }
  94199. }
  94200. }
  94201. )),
  94202. o.prototype.removeEffectLayer = function(e) {
  94203. var t = this.effectLayers.indexOf(e);
  94204. return -1 !== t && this.effectLayers.splice(t, 1),
  94205. t
  94206. }
  94207. ,
  94208. o.prototype.addEffectLayer = function(e) {
  94209. this.effectLayers.push(e)
  94210. }
  94211. ;
  94212. var Qf = function() {
  94213. function e(e) {
  94214. this.name = Wi.NAME_EFFECTLAYER,
  94215. this._renderEffects = !1,
  94216. this._needStencil = !1,
  94217. this._previousStencilState = !1,
  94218. this.scene = e || E.LastCreatedScene,
  94219. this.scene && (this._engine = this.scene.getEngine(),
  94220. this.scene.effectLayers = new Array)
  94221. }
  94222. return e.prototype.register = function() {
  94223. this.scene._isReadyForMeshStage.registerStep(Wi.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh),
  94224. this.scene._cameraDrawRenderTargetStage.registerStep(Wi.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture),
  94225. this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil),
  94226. this.scene._afterRenderingGroupDrawStage.registerStep(Wi.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup),
  94227. this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack),
  94228. this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera)
  94229. }
  94230. ,
  94231. e.prototype.rebuild = function() {
  94232. for (var e = 0, t = this.scene.effectLayers; e < t.length; e++)
  94233. t[e]._rebuild()
  94234. }
  94235. ,
  94236. e.prototype.serialize = function(e) {
  94237. e.effectLayers = [];
  94238. for (var t = 0, i = this.scene.effectLayers; t < i.length; t++) {
  94239. var n = i[t];
  94240. n.serialize && e.effectLayers.push(n.serialize())
  94241. }
  94242. }
  94243. ,
  94244. e.prototype.addFromContainer = function(e) {
  94245. var t = this;
  94246. e.effectLayers && e.effectLayers.forEach((function(e) {
  94247. t.scene.addEffectLayer(e)
  94248. }
  94249. ))
  94250. }
  94251. ,
  94252. e.prototype.removeFromContainer = function(e, t) {
  94253. var i = this;
  94254. e.effectLayers && e.effectLayers.forEach((function(e) {
  94255. i.scene.removeEffectLayer(e),
  94256. t && e.dispose()
  94257. }
  94258. ))
  94259. }
  94260. ,
  94261. e.prototype.dispose = function() {
  94262. for (var e = this.scene.effectLayers; e.length; )
  94263. e[0].dispose()
  94264. }
  94265. ,
  94266. e.prototype._isReadyForMesh = function(e, t) {
  94267. for (var i = this._engine.currentRenderPassId, n = 0, r = this.scene.effectLayers; n < r.length; n++) {
  94268. var o = r[n];
  94269. if (o.hasMesh(e)) {
  94270. var a = o._mainTexture;
  94271. this._engine.currentRenderPassId = a.renderPassId;
  94272. for (var s = 0, l = e.subMeshes; s < l.length; s++) {
  94273. var c = l[s];
  94274. if (!o.isReady(c, t))
  94275. return this._engine.currentRenderPassId = i,
  94276. !1
  94277. }
  94278. }
  94279. }
  94280. return this._engine.currentRenderPassId = i,
  94281. !0
  94282. }
  94283. ,
  94284. e.prototype._renderMainTexture = function(e) {
  94285. this._renderEffects = !1,
  94286. this._needStencil = !1;
  94287. var t = !1
  94288. , i = this.scene.effectLayers;
  94289. if (i && i.length > 0) {
  94290. this._previousStencilState = this._engine.getStencilBuffer();
  94291. for (var n = 0, r = i; n < r.length; n++) {
  94292. var o = r[n];
  94293. if (o.shouldRender() && (!o.camera || o.camera.cameraRigMode === Rr.RIG_MODE_NONE && e === o.camera || o.camera.cameraRigMode !== Rr.RIG_MODE_NONE && o.camera._rigCameras.indexOf(e) > -1)) {
  94294. this._renderEffects = !0,
  94295. this._needStencil = this._needStencil || o.needStencil();
  94296. var a = o._mainTexture;
  94297. a._shouldRender() && (this.scene.incrementRenderId(),
  94298. a.render(!1, !1),
  94299. t = !0)
  94300. }
  94301. }
  94302. this.scene.incrementRenderId()
  94303. }
  94304. return t
  94305. }
  94306. ,
  94307. e.prototype._setStencil = function() {
  94308. this._needStencil && this._engine.setStencilBuffer(!0)
  94309. }
  94310. ,
  94311. e.prototype._setStencilBack = function() {
  94312. this._needStencil && this._engine.setStencilBuffer(this._previousStencilState)
  94313. }
  94314. ,
  94315. e.prototype._draw = function(e) {
  94316. if (this._renderEffects) {
  94317. this._engine.setDepthBuffer(!1);
  94318. for (var t = this.scene.effectLayers, i = 0; i < t.length; i++) {
  94319. var n = t[i];
  94320. n.renderingGroupId === e && n.shouldRender() && n.render()
  94321. }
  94322. this._engine.setDepthBuffer(!0)
  94323. }
  94324. }
  94325. ,
  94326. e.prototype._drawCamera = function() {
  94327. this._renderEffects && this._draw(-1)
  94328. }
  94329. ,
  94330. e.prototype._drawRenderingGroup = function(e) {
  94331. !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(e)
  94332. }
  94333. ,
  94334. e
  94335. }();
  94336. Kf._SceneComponentInitialization = function(e) {
  94337. var t = e._getComponent(Wi.NAME_EFFECTLAYER);
  94338. t || (t = new Qf(e),
  94339. e._addComponent(t))
  94340. }
  94341. ;
  94342. Pt.ShadersStore.glowMapMergePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\nuniform float offset;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\n#if LDR\nbaseColor=clamp(baseColor,0.,1.0);\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  94343. Pt.ShadersStore.glowMapMergeVertexShader = "attribute vec2 position;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}",
  94344. o.prototype.getGlowLayerByName = function(e) {
  94345. for (var t = 0; t < this.effectLayers.length; t++)
  94346. if (this.effectLayers[t].name === e && this.effectLayers[t].getEffectName() === qf.EffectName)
  94347. return this.effectLayers[t];
  94348. return null
  94349. }
  94350. ;
  94351. var qf = function(e) {
  94352. function t(i, n, r) {
  94353. var o = e.call(this, i, n) || this;
  94354. return o._intensity = 1,
  94355. o._includedOnlyMeshes = [],
  94356. o._excludedMeshes = [],
  94357. o._meshesUsingTheirOwnMaterials = [],
  94358. o.neutralColor = new N(0,0,0,1),
  94359. o._options = V({
  94360. mainTextureRatio: t.DefaultTextureRatio,
  94361. blurKernelSize: 32,
  94362. mainTextureFixedSize: void 0,
  94363. camera: null,
  94364. mainTextureSamples: 1,
  94365. renderingGroupId: -1,
  94366. ldrMerge: !1,
  94367. alphaBlendingMode: a.ALPHA_ADD
  94368. }, r),
  94369. o._init({
  94370. alphaBlendingMode: o._options.alphaBlendingMode,
  94371. camera: o._options.camera,
  94372. mainTextureFixedSize: o._options.mainTextureFixedSize,
  94373. mainTextureRatio: o._options.mainTextureRatio,
  94374. renderingGroupId: o._options.renderingGroupId
  94375. }),
  94376. o
  94377. }
  94378. return U(t, e),
  94379. Object.defineProperty(t.prototype, "blurKernelSize", {
  94380. get: function() {
  94381. return this._horizontalBlurPostprocess1.kernel
  94382. },
  94383. set: function(e) {
  94384. this._horizontalBlurPostprocess1.kernel = e,
  94385. this._verticalBlurPostprocess1.kernel = e,
  94386. this._horizontalBlurPostprocess2.kernel = e,
  94387. this._verticalBlurPostprocess2.kernel = e
  94388. },
  94389. enumerable: !1,
  94390. configurable: !0
  94391. }),
  94392. Object.defineProperty(t.prototype, "intensity", {
  94393. get: function() {
  94394. return this._intensity
  94395. },
  94396. set: function(e) {
  94397. this._intensity = e
  94398. },
  94399. enumerable: !1,
  94400. configurable: !0
  94401. }),
  94402. t.prototype.getEffectName = function() {
  94403. return t.EffectName
  94404. }
  94405. ,
  94406. t.prototype._createMergeEffect = function() {
  94407. var e = "#define EMISSIVE \n";
  94408. return this._options.ldrMerge && (e += "#define LDR \n"),
  94409. this._engine.createEffect("glowMapMerge", [Bi.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], e)
  94410. }
  94411. ,
  94412. t.prototype._createTextureAndPostProcesses = function() {
  94413. var e = this
  94414. , t = this._mainTextureDesiredSize.width
  94415. , i = this._mainTextureDesiredSize.height;
  94416. t = this._engine.needPOTTextures ? vr.GetExponentOfTwo(t, this._maxSize) : t,
  94417. i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
  94418. var n;
  94419. n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
  94420. this._blurTexture1 = new ns("GlowLayerBlurRTT",{
  94421. width: t,
  94422. height: i
  94423. },this._scene,!1,!0,n),
  94424. this._blurTexture1.wrapU = io.CLAMP_ADDRESSMODE,
  94425. this._blurTexture1.wrapV = io.CLAMP_ADDRESSMODE,
  94426. this._blurTexture1.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
  94427. this._blurTexture1.renderParticles = !1,
  94428. this._blurTexture1.ignoreCameraViewport = !0;
  94429. var r = Math.floor(t / 2)
  94430. , o = Math.floor(i / 2);
  94431. this._blurTexture2 = new ns("GlowLayerBlurRTT2",{
  94432. width: r,
  94433. height: o
  94434. },this._scene,!1,!0,n),
  94435. this._blurTexture2.wrapU = io.CLAMP_ADDRESSMODE,
  94436. this._blurTexture2.wrapV = io.CLAMP_ADDRESSMODE,
  94437. this._blurTexture2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
  94438. this._blurTexture2.renderParticles = !1,
  94439. this._blurTexture2.ignoreCameraViewport = !0,
  94440. this._textures = [this._blurTexture1, this._blurTexture2],
  94441. this._horizontalBlurPostprocess1 = new Fd("GlowLayerHBP1",new A(1,0),this._options.blurKernelSize / 2,{
  94442. width: t,
  94443. height: i
  94444. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94445. this._horizontalBlurPostprocess1.width = t,
  94446. this._horizontalBlurPostprocess1.height = i,
  94447. this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0,
  94448. this._horizontalBlurPostprocess1.onApplyObservable.add((function(t) {
  94449. t.setTexture("textureSampler", e._mainTexture)
  94450. }
  94451. )),
  94452. this._verticalBlurPostprocess1 = new Fd("GlowLayerVBP1",new A(0,1),this._options.blurKernelSize / 2,{
  94453. width: t,
  94454. height: i
  94455. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94456. this._horizontalBlurPostprocess2 = new Fd("GlowLayerHBP2",new A(1,0),this._options.blurKernelSize / 2,{
  94457. width: r,
  94458. height: o
  94459. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94460. this._horizontalBlurPostprocess2.width = r,
  94461. this._horizontalBlurPostprocess2.height = o,
  94462. this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0,
  94463. this._horizontalBlurPostprocess2.onApplyObservable.add((function(t) {
  94464. t.setTexture("textureSampler", e._blurTexture1)
  94465. }
  94466. )),
  94467. this._verticalBlurPostprocess2 = new Fd("GlowLayerVBP2",new A(0,1),this._options.blurKernelSize / 2,{
  94468. width: r,
  94469. height: o
  94470. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94471. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
  94472. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1],
  94473. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
  94474. this._mainTexture.samples = this._options.mainTextureSamples,
  94475. this._mainTexture.onAfterUnbindObservable.add((function() {
  94476. var t = e._blurTexture1.renderTarget;
  94477. if (t) {
  94478. e._scene.postProcessManager.directRender(e._postProcesses1, t, !0);
  94479. var i = e._blurTexture2.renderTarget;
  94480. i && e._scene.postProcessManager.directRender(e._postProcesses2, i, !0),
  94481. e._engine.unBindFramebuffer(null != i ? i : t, !0)
  94482. }
  94483. }
  94484. )),
  94485. this._postProcesses.map((function(e) {
  94486. e.autoClear = !1
  94487. }
  94488. ))
  94489. }
  94490. ,
  94491. t.prototype.isReady = function(t, i) {
  94492. var n = t.getMaterial()
  94493. , r = t.getRenderingMesh();
  94494. if (!n || !r)
  94495. return !1;
  94496. var o = n.emissiveTexture;
  94497. return e.prototype._isReady.call(this, t, i, o)
  94498. }
  94499. ,
  94500. t.prototype.needStencil = function() {
  94501. return !1
  94502. }
  94503. ,
  94504. t.prototype._canRenderMesh = function(e, t) {
  94505. return !0
  94506. }
  94507. ,
  94508. t.prototype._internalRender = function(e) {
  94509. e.setTexture("textureSampler", this._blurTexture1),
  94510. e.setTexture("textureSampler2", this._blurTexture2),
  94511. e.setFloat("offset", this._intensity);
  94512. var t = this._engine
  94513. , i = t.getStencilBuffer();
  94514. t.setStencilBuffer(!1),
  94515. t.drawElementsType(Or.TriangleFillMode, 0, 6),
  94516. t.setStencilBuffer(i)
  94517. }
  94518. ,
  94519. t.prototype._setEmissiveTextureAndColor = function(e, t, i) {
  94520. var n, r = 1;
  94521. this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, t, i) : i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
  94522. this._emissiveTextureAndColor.texture && (r = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null,
  94523. this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, t, i, this._emissiveTextureAndColor.color) : i.emissiveColor ? (r *= null !== (n = i.emissiveIntensity) && void 0 !== n ? n : 1,
  94524. this._emissiveTextureAndColor.color.set(i.emissiveColor.r * r, i.emissiveColor.g * r, i.emissiveColor.b * r, i.alpha)) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a)
  94525. }
  94526. ,
  94527. t.prototype._shouldRenderMesh = function(e) {
  94528. return this.hasMesh(e)
  94529. }
  94530. ,
  94531. t.prototype._addCustomEffectDefines = function(e) {
  94532. e.push("#define GLOW")
  94533. }
  94534. ,
  94535. t.prototype.addExcludedMesh = function(e) {
  94536. -1 === this._excludedMeshes.indexOf(e.uniqueId) && this._excludedMeshes.push(e.uniqueId)
  94537. }
  94538. ,
  94539. t.prototype.removeExcludedMesh = function(e) {
  94540. var t = this._excludedMeshes.indexOf(e.uniqueId);
  94541. -1 !== t && this._excludedMeshes.splice(t, 1)
  94542. }
  94543. ,
  94544. t.prototype.addIncludedOnlyMesh = function(e) {
  94545. -1 === this._includedOnlyMeshes.indexOf(e.uniqueId) && this._includedOnlyMeshes.push(e.uniqueId)
  94546. }
  94547. ,
  94548. t.prototype.removeIncludedOnlyMesh = function(e) {
  94549. var t = this._includedOnlyMeshes.indexOf(e.uniqueId);
  94550. -1 !== t && this._includedOnlyMeshes.splice(t, 1)
  94551. }
  94552. ,
  94553. t.prototype.hasMesh = function(t) {
  94554. return !!e.prototype.hasMesh.call(this, t) && (this._includedOnlyMeshes.length ? -1 !== this._includedOnlyMeshes.indexOf(t.uniqueId) : !this._excludedMeshes.length || -1 === this._excludedMeshes.indexOf(t.uniqueId))
  94555. }
  94556. ,
  94557. t.prototype._useMeshMaterial = function(e) {
  94558. return 0 != this._meshesUsingTheirOwnMaterials.length && this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId) > -1
  94559. }
  94560. ,
  94561. t.prototype.referenceMeshToUseItsOwnMaterial = function(e) {
  94562. var t = this;
  94563. e.resetDrawCache(this._mainTexture.renderPassId),
  94564. this._meshesUsingTheirOwnMaterials.push(e.uniqueId),
  94565. e.onDisposeObservable.add((function() {
  94566. t._disposeMesh(e)
  94567. }
  94568. ))
  94569. }
  94570. ,
  94571. t.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(e) {
  94572. for (var t = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId); t >= 0; )
  94573. this._meshesUsingTheirOwnMaterials.splice(t, 1),
  94574. t = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);
  94575. e.resetDrawCache(this._mainTexture.renderPassId)
  94576. }
  94577. ,
  94578. t.prototype._disposeMesh = function(e) {
  94579. this.removeIncludedOnlyMesh(e),
  94580. this.removeExcludedMesh(e)
  94581. }
  94582. ,
  94583. t.prototype.getClassName = function() {
  94584. return "GlowLayer"
  94585. }
  94586. ,
  94587. t.prototype.serialize = function() {
  94588. var e, t = Ge.Serialize(this);
  94589. if (t.customType = "BABYLON.GlowLayer",
  94590. t.includedMeshes = [],
  94591. this._includedOnlyMeshes.length)
  94592. for (e = 0; e < this._includedOnlyMeshes.length; e++)
  94593. (i = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[e])) && t.includedMeshes.push(i.id);
  94594. if (t.excludedMeshes = [],
  94595. this._excludedMeshes.length)
  94596. for (e = 0; e < this._excludedMeshes.length; e++) {
  94597. var i;
  94598. (i = this._scene.getMeshByUniqueId(this._excludedMeshes[e])) && t.excludedMeshes.push(i.id)
  94599. }
  94600. return t
  94601. }
  94602. ,
  94603. t.Parse = function(e, i, n) {
  94604. var r, o = Ge.Parse((function() {
  94605. return new t(e.name,i,e.options)
  94606. }
  94607. ), e, i, n);
  94608. for (r = 0; r < e.excludedMeshes.length; r++)
  94609. (a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
  94610. for (r = 0; r < e.includedMeshes.length; r++) {
  94611. var a;
  94612. (a = i.getMeshById(e.includedMeshes[r])) && o.addIncludedOnlyMesh(a)
  94613. }
  94614. return o
  94615. }
  94616. ,
  94617. t.EffectName = "GlowLayer",
  94618. t.DefaultBlurKernelSize = 32,
  94619. t.DefaultTextureRatio = .5,
  94620. k([Ce()], t.prototype, "blurKernelSize", null),
  94621. k([Ce()], t.prototype, "intensity", null),
  94622. k([Ce("options")], t.prototype, "_options", void 0),
  94623. t
  94624. }(Kf);
  94625. y("BABYLON.GlowLayer", qf);
  94626. Pt.ShadersStore.glowBlurPostProcessPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",
  94627. o.prototype.getHighlightLayerByName = function(e) {
  94628. for (var t, i = 0; i < (null === (t = this.effectLayers) || void 0 === t ? void 0 : t.length); i++)
  94629. if (this.effectLayers[i].name === e && this.effectLayers[i].getEffectName() === Jf.EffectName)
  94630. return this.effectLayers[i];
  94631. return null
  94632. }
  94633. ;
  94634. var Zf = function(e) {
  94635. function t(t, i, n, r, o, a, s, l) {
  94636. void 0 === a && (a = io.BILINEAR_SAMPLINGMODE);
  94637. var c = e.call(this, t, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, r, o, a, s, l) || this;
  94638. return c.direction = i,
  94639. c.kernel = n,
  94640. c.onApplyObservable.add((function(e) {
  94641. e.setFloat2("screenSize", c.width, c.height),
  94642. e.setVector2("direction", c.direction),
  94643. e.setFloat("blurWidth", c.kernel)
  94644. }
  94645. )),
  94646. c
  94647. }
  94648. return U(t, e),
  94649. t
  94650. }(Ba)
  94651. , Jf = function(e) {
  94652. function t(i, n, r) {
  94653. var o = e.call(this, i, n) || this;
  94654. return o.name = i,
  94655. o.innerGlow = !0,
  94656. o.outerGlow = !0,
  94657. o.onBeforeBlurObservable = new h,
  94658. o.onAfterBlurObservable = new h,
  94659. o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++,
  94660. o._meshes = {},
  94661. o._excludedMeshes = {},
  94662. o.neutralColor = t.NeutralColor,
  94663. o._engine.isStencilEnable || K.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),
  94664. o._options = V({
  94665. mainTextureRatio: .5,
  94666. blurTextureSizeRatio: .5,
  94667. blurHorizontalSize: 1,
  94668. blurVerticalSize: 1,
  94669. alphaBlendingMode: a.ALPHA_COMBINE,
  94670. camera: null,
  94671. renderingGroupId: -1
  94672. }, r),
  94673. o._init({
  94674. alphaBlendingMode: o._options.alphaBlendingMode,
  94675. camera: o._options.camera,
  94676. mainTextureFixedSize: o._options.mainTextureFixedSize,
  94677. mainTextureRatio: o._options.mainTextureRatio,
  94678. renderingGroupId: o._options.renderingGroupId
  94679. }),
  94680. o._shouldRender = !1,
  94681. o
  94682. }
  94683. return U(t, e),
  94684. Object.defineProperty(t.prototype, "blurHorizontalSize", {
  94685. get: function() {
  94686. return this._horizontalBlurPostprocess.kernel
  94687. },
  94688. set: function(e) {
  94689. this._horizontalBlurPostprocess.kernel = e,
  94690. this._options.blurHorizontalSize = e
  94691. },
  94692. enumerable: !1,
  94693. configurable: !0
  94694. }),
  94695. Object.defineProperty(t.prototype, "blurVerticalSize", {
  94696. get: function() {
  94697. return this._verticalBlurPostprocess.kernel
  94698. },
  94699. set: function(e) {
  94700. this._verticalBlurPostprocess.kernel = e,
  94701. this._options.blurVerticalSize = e
  94702. },
  94703. enumerable: !1,
  94704. configurable: !0
  94705. }),
  94706. t.prototype.getEffectName = function() {
  94707. return t.EffectName
  94708. }
  94709. ,
  94710. t.prototype._numInternalDraws = function() {
  94711. return 2
  94712. }
  94713. ,
  94714. t.prototype._createMergeEffect = function() {
  94715. return this._engine.createEffect("glowMapMerge", [Bi.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : void 0)
  94716. }
  94717. ,
  94718. t.prototype._createTextureAndPostProcesses = function() {
  94719. var e = this
  94720. , t = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio
  94721. , i = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  94722. t = this._engine.needPOTTextures ? vr.GetExponentOfTwo(t, this._maxSize) : t,
  94723. i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
  94724. var n;
  94725. n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
  94726. this._blurTexture = new ns("HighlightLayerBlurRTT",{
  94727. width: t,
  94728. height: i
  94729. },this._scene,!1,!0,n),
  94730. this._blurTexture.wrapU = io.CLAMP_ADDRESSMODE,
  94731. this._blurTexture.wrapV = io.CLAMP_ADDRESSMODE,
  94732. this._blurTexture.anisotropicFilteringLevel = 16,
  94733. this._blurTexture.updateSamplingMode(io.TRILINEAR_SAMPLINGMODE),
  94734. this._blurTexture.renderParticles = !1,
  94735. this._blurTexture.ignoreCameraViewport = !0,
  94736. this._textures = [this._blurTexture],
  94737. this._options.alphaBlendingMode === a.ALPHA_COMBINE ? (this._downSamplePostprocess = new Ua("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  94738. this._downSamplePostprocess.externalTextureSamplerBinding = !0,
  94739. this._downSamplePostprocess.onApplyObservable.add((function(t) {
  94740. t.setTexture("textureSampler", e._mainTexture)
  94741. }
  94742. )),
  94743. this._horizontalBlurPostprocess = new Zf("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize,1,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  94744. this._horizontalBlurPostprocess.onApplyObservable.add((function(e) {
  94745. e.setFloat2("screenSize", t, i)
  94746. }
  94747. )),
  94748. this._verticalBlurPostprocess = new Zf("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize,1,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
  94749. this._verticalBlurPostprocess.onApplyObservable.add((function(e) {
  94750. e.setFloat2("screenSize", t, i)
  94751. }
  94752. )),
  94753. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new Fd("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize / 2,{
  94754. width: t,
  94755. height: i
  94756. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94757. this._horizontalBlurPostprocess.width = t,
  94758. this._horizontalBlurPostprocess.height = i,
  94759. this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0,
  94760. this._horizontalBlurPostprocess.onApplyObservable.add((function(t) {
  94761. t.setTexture("textureSampler", e._mainTexture)
  94762. }
  94763. )),
  94764. this._verticalBlurPostprocess = new Fd("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize / 2,{
  94765. width: t,
  94766. height: i
  94767. },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
  94768. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]),
  94769. this._mainTexture.onAfterUnbindObservable.add((function() {
  94770. e.onBeforeBlurObservable.notifyObservers(e);
  94771. var t = e._blurTexture.renderTarget;
  94772. t && (e._scene.postProcessManager.directRender(e._postProcesses, t, !0),
  94773. e._engine.unBindFramebuffer(t, !0)),
  94774. e.onAfterBlurObservable.notifyObservers(e)
  94775. }
  94776. )),
  94777. this._postProcesses.map((function(e) {
  94778. e.autoClear = !1
  94779. }
  94780. ))
  94781. }
  94782. ,
  94783. t.prototype.needStencil = function() {
  94784. return !0
  94785. }
  94786. ,
  94787. t.prototype.isReady = function(t, i) {
  94788. var n = t.getMaterial()
  94789. , r = t.getRenderingMesh();
  94790. if (!n || !r || !this._meshes)
  94791. return !1;
  94792. var o = null
  94793. , a = this._meshes[r.uniqueId];
  94794. return a && a.glowEmissiveOnly && n && (o = n.emissiveTexture),
  94795. e.prototype._isReady.call(this, t, i, o)
  94796. }
  94797. ,
  94798. t.prototype._internalRender = function(e, t) {
  94799. e.setTexture("textureSampler", this._blurTexture);
  94800. var i = this._engine;
  94801. i.cacheStencilState(),
  94802. i.setStencilOperationPass(a.REPLACE),
  94803. i.setStencilOperationFail(a.KEEP),
  94804. i.setStencilOperationDepthFail(a.KEEP),
  94805. i.setStencilMask(0),
  94806. i.setStencilBuffer(!0),
  94807. i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),
  94808. this.outerGlow && 0 === t && (e.setFloat("offset", 0),
  94809. i.setStencilFunction(a.NOTEQUAL),
  94810. i.drawElementsType(Or.TriangleFillMode, 0, 6)),
  94811. this.innerGlow && 1 === t && (e.setFloat("offset", 1),
  94812. i.setStencilFunction(a.EQUAL),
  94813. i.drawElementsType(Or.TriangleFillMode, 0, 6)),
  94814. i.restoreStencilState()
  94815. }
  94816. ,
  94817. t.prototype.shouldRender = function() {
  94818. return !!e.prototype.shouldRender.call(this) && !!this._meshes
  94819. }
  94820. ,
  94821. t.prototype._shouldRenderMesh = function(t) {
  94822. return !(this._excludedMeshes && this._excludedMeshes[t.uniqueId] || !e.prototype.hasMesh.call(this, t))
  94823. }
  94824. ,
  94825. t.prototype._canRenderMesh = function(e, t) {
  94826. return !0
  94827. }
  94828. ,
  94829. t.prototype._addCustomEffectDefines = function(e) {
  94830. e.push("#define HIGHLIGHT")
  94831. }
  94832. ,
  94833. t.prototype._setEmissiveTextureAndColor = function(e, t, i) {
  94834. var n = this._meshes[e.uniqueId];
  94835. n ? this._emissiveTextureAndColor.color.set(n.color.r, n.color.g, n.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a),
  94836. n && n.glowEmissiveOnly && i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
  94837. this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null
  94838. }
  94839. ,
  94840. t.prototype.addExcludedMesh = function(e) {
  94841. this._excludedMeshes && (this._excludedMeshes[e.uniqueId] || (this._excludedMeshes[e.uniqueId] = {
  94842. mesh: e,
  94843. beforeBind: e.onBeforeBindObservable.add((function(e) {
  94844. e.getEngine().setStencilBuffer(!1)
  94845. }
  94846. )),
  94847. afterRender: e.onAfterRenderObservable.add((function(e) {
  94848. e.getEngine().setStencilBuffer(!0)
  94849. }
  94850. ))
  94851. }))
  94852. }
  94853. ,
  94854. t.prototype.removeExcludedMesh = function(e) {
  94855. if (this._excludedMeshes) {
  94856. var t = this._excludedMeshes[e.uniqueId];
  94857. t && (t.beforeBind && e.onBeforeBindObservable.remove(t.beforeBind),
  94858. t.afterRender && e.onAfterRenderObservable.remove(t.afterRender)),
  94859. this._excludedMeshes[e.uniqueId] = null
  94860. }
  94861. }
  94862. ,
  94863. t.prototype.hasMesh = function(t) {
  94864. return !!this._meshes && !!e.prototype.hasMesh.call(this, t) && void 0 !== this._meshes[t.uniqueId] && null !== this._meshes[t.uniqueId]
  94865. }
  94866. ,
  94867. t.prototype.addMesh = function(e, t, i) {
  94868. var n = this;
  94869. if (void 0 === i && (i = !1),
  94870. this._meshes) {
  94871. var r = this._meshes[e.uniqueId];
  94872. r ? r.color = t : (this._meshes[e.uniqueId] = {
  94873. mesh: e,
  94874. color: t,
  94875. observerHighlight: e.onBeforeBindObservable.add((function(e) {
  94876. n.isEnabled && (n._excludedMeshes && n._excludedMeshes[e.uniqueId] ? n._defaultStencilReference(e) : e.getScene().getEngine().setStencilFunctionReference(n._instanceGlowingMeshStencilReference))
  94877. }
  94878. )),
  94879. observerDefault: e.onAfterRenderObservable.add((function(e) {
  94880. n.isEnabled && n._defaultStencilReference(e)
  94881. }
  94882. )),
  94883. glowEmissiveOnly: i
  94884. },
  94885. e.onDisposeObservable.add((function() {
  94886. n._disposeMesh(e)
  94887. }
  94888. ))),
  94889. this._shouldRender = !0
  94890. }
  94891. }
  94892. ,
  94893. t.prototype.removeMesh = function(e) {
  94894. if (this._meshes) {
  94895. var t = this._meshes[e.uniqueId];
  94896. for (var i in t && (t.observerHighlight && e.onBeforeBindObservable.remove(t.observerHighlight),
  94897. t.observerDefault && e.onAfterRenderObservable.remove(t.observerDefault),
  94898. delete this._meshes[e.uniqueId]),
  94899. this._shouldRender = !1,
  94900. this._meshes)
  94901. if (this._meshes[i]) {
  94902. this._shouldRender = !0;
  94903. break
  94904. }
  94905. }
  94906. }
  94907. ,
  94908. t.prototype.removeAllMeshes = function() {
  94909. if (this._meshes)
  94910. for (var e in this._meshes)
  94911. if (Object.prototype.hasOwnProperty.call(this._meshes, e)) {
  94912. var t = this._meshes[e];
  94913. t && this.removeMesh(t.mesh)
  94914. }
  94915. }
  94916. ,
  94917. t.prototype._defaultStencilReference = function(e) {
  94918. e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference)
  94919. }
  94920. ,
  94921. t.prototype._disposeMesh = function(e) {
  94922. this.removeMesh(e),
  94923. this.removeExcludedMesh(e)
  94924. }
  94925. ,
  94926. t.prototype.dispose = function() {
  94927. if (this._meshes) {
  94928. for (var t in this._meshes)
  94929. (i = this._meshes[t]) && i.mesh && (i.observerHighlight && i.mesh.onBeforeBindObservable.remove(i.observerHighlight),
  94930. i.observerDefault && i.mesh.onAfterRenderObservable.remove(i.observerDefault));
  94931. this._meshes = null
  94932. }
  94933. if (this._excludedMeshes) {
  94934. for (var t in this._excludedMeshes) {
  94935. var i;
  94936. (i = this._excludedMeshes[t]) && (i.beforeBind && i.mesh.onBeforeBindObservable.remove(i.beforeBind),
  94937. i.afterRender && i.mesh.onAfterRenderObservable.remove(i.afterRender))
  94938. }
  94939. this._excludedMeshes = null
  94940. }
  94941. e.prototype.dispose.call(this)
  94942. }
  94943. ,
  94944. t.prototype.getClassName = function() {
  94945. return "HighlightLayer"
  94946. }
  94947. ,
  94948. t.prototype.serialize = function() {
  94949. var e = Ge.Serialize(this);
  94950. if (e.customType = "BABYLON.HighlightLayer",
  94951. e.meshes = [],
  94952. this._meshes)
  94953. for (var t in this._meshes) {
  94954. var i = this._meshes[t];
  94955. i && e.meshes.push({
  94956. glowEmissiveOnly: i.glowEmissiveOnly,
  94957. color: i.color.asArray(),
  94958. meshId: i.mesh.id
  94959. })
  94960. }
  94961. if (e.excludedMeshes = [],
  94962. this._excludedMeshes)
  94963. for (var n in this._excludedMeshes) {
  94964. var r = this._excludedMeshes[n];
  94965. r && e.excludedMeshes.push(r.mesh.id)
  94966. }
  94967. return e
  94968. }
  94969. ,
  94970. t.Parse = function(e, i, n) {
  94971. var r, o = Ge.Parse((function() {
  94972. return new t(e.name,i,e.options)
  94973. }
  94974. ), e, i, n);
  94975. for (r = 0; r < e.excludedMeshes.length; r++)
  94976. (a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
  94977. for (r = 0; r < e.meshes.length; r++) {
  94978. var a, s = e.meshes[r];
  94979. (a = i.getMeshById(s.meshId)) && o.addMesh(a, D.FromArray(s.color), s.glowEmissiveOnly)
  94980. }
  94981. return o
  94982. }
  94983. ,
  94984. t.EffectName = "HighlightLayer",
  94985. t.NeutralColor = new N(0,0,0,0),
  94986. t.GlowingMeshStencilReference = 2,
  94987. t.NormalMeshStencilReference = 1,
  94988. k([Ce()], t.prototype, "innerGlow", void 0),
  94989. k([Ce()], t.prototype, "outerGlow", void 0),
  94990. k([Ce()], t.prototype, "blurHorizontalSize", null),
  94991. k([Ce()], t.prototype, "blurVerticalSize", null),
  94992. k([Ce("options")], t.prototype, "_options", void 0),
  94993. t
  94994. }(Kf);
  94995. y("BABYLON.HighlightLayer", Jf);
  94996. var $f = function() {
  94997. function e(e) {
  94998. this.name = Wi.NAME_LAYER,
  94999. this.scene = e || E.LastCreatedScene,
  95000. this.scene && (this._engine = this.scene.getEngine(),
  95001. this.scene.layers = new Array)
  95002. }
  95003. return e.prototype.register = function() {
  95004. this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground),
  95005. this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground),
  95006. this.scene._beforeRenderTargetDrawStage.registerStep(Wi.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground),
  95007. this.scene._afterRenderTargetDrawStage.registerStep(Wi.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground)
  95008. }
  95009. ,
  95010. e.prototype.rebuild = function() {
  95011. for (var e = 0, t = this.scene.layers; e < t.length; e++)
  95012. t[e]._rebuild()
  95013. }
  95014. ,
  95015. e.prototype.dispose = function() {
  95016. for (var e = this.scene.layers; e.length; )
  95017. e[0].dispose()
  95018. }
  95019. ,
  95020. e.prototype._draw = function(e) {
  95021. var t = this.scene.layers;
  95022. if (t.length) {
  95023. this._engine.setDepthBuffer(!1);
  95024. for (var i = 0, n = t; i < n.length; i++) {
  95025. var r = n[i];
  95026. e(r) && r.render()
  95027. }
  95028. this._engine.setDepthBuffer(!0)
  95029. }
  95030. }
  95031. ,
  95032. e.prototype._drawCameraPredicate = function(e, t, i) {
  95033. return !e.renderOnlyInRenderTargetTextures && e.isBackground === t && 0 != (e.layerMask & i)
  95034. }
  95035. ,
  95036. e.prototype._drawCameraBackground = function(e) {
  95037. var t = this;
  95038. this._draw((function(i) {
  95039. return t._drawCameraPredicate(i, !0, e.layerMask)
  95040. }
  95041. ))
  95042. }
  95043. ,
  95044. e.prototype._drawCameraForeground = function(e) {
  95045. var t = this;
  95046. this._draw((function(i) {
  95047. return t._drawCameraPredicate(i, !1, e.layerMask)
  95048. }
  95049. ))
  95050. }
  95051. ,
  95052. e.prototype._drawRenderTargetPredicate = function(e, t, i, n) {
  95053. return e.renderTargetTextures.length > 0 && e.isBackground === t && e.renderTargetTextures.indexOf(n) > -1 && 0 != (e.layerMask & i)
  95054. }
  95055. ,
  95056. e.prototype._drawRenderTargetBackground = function(e) {
  95057. var t = this;
  95058. this._draw((function(i) {
  95059. return t._drawRenderTargetPredicate(i, !0, t.scene.activeCamera.layerMask, e)
  95060. }
  95061. ))
  95062. }
  95063. ,
  95064. e.prototype._drawRenderTargetForeground = function(e) {
  95065. var t = this;
  95066. this._draw((function(i) {
  95067. return t._drawRenderTargetPredicate(i, !1, t.scene.activeCamera.layerMask, e)
  95068. }
  95069. ))
  95070. }
  95071. ,
  95072. e.prototype.addFromContainer = function(e) {
  95073. var t = this;
  95074. e.layers && e.layers.forEach((function(e) {
  95075. t.scene.layers.push(e)
  95076. }
  95077. ))
  95078. }
  95079. ,
  95080. e.prototype.removeFromContainer = function(e, t) {
  95081. var i = this;
  95082. void 0 === t && (t = !1),
  95083. e.layers && e.layers.forEach((function(e) {
  95084. var n = i.scene.layers.indexOf(e);
  95085. -1 !== n && i.scene.layers.splice(n, 1),
  95086. t && e.dispose()
  95087. }
  95088. ))
  95089. }
  95090. ,
  95091. e
  95092. }();
  95093. Pt.ShadersStore.layerPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec4 color;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  95094. Pt.ShadersStore.layerVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  95095. var e_ = function() {
  95096. function e(e, t, i, n, r) {
  95097. this.name = e,
  95098. this.scale = new A(1,1),
  95099. this.offset = new A(0,0),
  95100. this.alphaBlendingMode = a.ALPHA_COMBINE,
  95101. this.layerMask = 268435455,
  95102. this.renderTargetTextures = [],
  95103. this.renderOnlyInRenderTargetTextures = !1,
  95104. this.isEnabled = !0,
  95105. this._vertexBuffers = {},
  95106. this.onDisposeObservable = new h,
  95107. this.onBeforeRenderObservable = new h,
  95108. this.onAfterRenderObservable = new h,
  95109. this.texture = t ? new io(t,i,!0) : null,
  95110. this.isBackground = void 0 === n || n,
  95111. this.color = void 0 === r ? new N(1,1,1,1) : r,
  95112. this._scene = i || E.LastCreatedScene;
  95113. var o = this._scene._getComponent(Wi.NAME_LAYER);
  95114. o || (o = new $f(this._scene),
  95115. this._scene._addComponent(o)),
  95116. this._scene.layers.push(this);
  95117. var s = this._scene.getEngine();
  95118. this._drawWrapper = new Gt(s);
  95119. var l = [];
  95120. l.push(1, 1),
  95121. l.push(-1, 1),
  95122. l.push(-1, -1),
  95123. l.push(1, -1);
  95124. var c = new Bi(s,l,Bi.PositionKind,!1,!1,2);
  95125. this._vertexBuffers[Bi.PositionKind] = c,
  95126. this._createIndexBuffer()
  95127. }
  95128. return Object.defineProperty(e.prototype, "onDispose", {
  95129. set: function(e) {
  95130. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  95131. this._onDisposeObserver = this.onDisposeObservable.add(e)
  95132. },
  95133. enumerable: !1,
  95134. configurable: !0
  95135. }),
  95136. Object.defineProperty(e.prototype, "onBeforeRender", {
  95137. set: function(e) {
  95138. this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
  95139. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
  95140. },
  95141. enumerable: !1,
  95142. configurable: !0
  95143. }),
  95144. Object.defineProperty(e.prototype, "onAfterRender", {
  95145. set: function(e) {
  95146. this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
  95147. this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
  95148. },
  95149. enumerable: !1,
  95150. configurable: !0
  95151. }),
  95152. e.prototype._createIndexBuffer = function() {
  95153. var e = this._scene.getEngine()
  95154. , t = [];
  95155. t.push(0),
  95156. t.push(1),
  95157. t.push(2),
  95158. t.push(0),
  95159. t.push(2),
  95160. t.push(3),
  95161. this._indexBuffer = e.createIndexBuffer(t)
  95162. }
  95163. ,
  95164. e.prototype._rebuild = function() {
  95165. var e = this._vertexBuffers[Bi.PositionKind];
  95166. e && e._rebuild(),
  95167. this._createIndexBuffer()
  95168. }
  95169. ,
  95170. e.prototype.render = function() {
  95171. if (this.isEnabled) {
  95172. var e = this._scene.getEngine()
  95173. , t = "";
  95174. this.alphaTest && (t = "#define ALPHATEST"),
  95175. this.texture && !this.texture.gammaSpace && (t += "\r\n#define LINEAR"),
  95176. this._previousDefines !== t && (this._previousDefines = t,
  95177. this._drawWrapper.effect = e.createEffect("layer", [Bi.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], t));
  95178. var i = this._drawWrapper.effect;
  95179. i && i.isReady() && this.texture && this.texture.isReady() && (this.onBeforeRenderObservable.notifyObservers(this),
  95180. e.enableEffect(this._drawWrapper),
  95181. e.setState(!1),
  95182. i.setTexture("textureSampler", this.texture),
  95183. i.setMatrix("textureMatrix", this.texture.getTextureMatrix()),
  95184. i.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a),
  95185. i.setVector2("offset", this.offset),
  95186. i.setVector2("scale", this.scale),
  95187. e.bindBuffers(this._vertexBuffers, this._indexBuffer, i),
  95188. this.alphaTest ? e.drawElementsType(Or.TriangleFillMode, 0, 6) : (e.setAlphaMode(this.alphaBlendingMode),
  95189. e.drawElementsType(Or.TriangleFillMode, 0, 6),
  95190. e.setAlphaMode(a.ALPHA_DISABLE)),
  95191. this.onAfterRenderObservable.notifyObservers(this))
  95192. }
  95193. }
  95194. ,
  95195. e.prototype.dispose = function() {
  95196. var e = this._vertexBuffers[Bi.PositionKind];
  95197. e && (e.dispose(),
  95198. this._vertexBuffers[Bi.PositionKind] = null),
  95199. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  95200. this._indexBuffer = null),
  95201. this.texture && (this.texture.dispose(),
  95202. this.texture = null),
  95203. this.renderTargetTextures = [];
  95204. var t = this._scene.layers.indexOf(this);
  95205. this._scene.layers.splice(t, 1),
  95206. this.onDisposeObservable.notifyObservers(this),
  95207. this.onDisposeObservable.clear(),
  95208. this.onAfterRenderObservable.clear(),
  95209. this.onBeforeRenderObservable.clear()
  95210. }
  95211. ,
  95212. e
  95213. }()
  95214. , t_ = function() {
  95215. function e(e, t, i, n, r) {
  95216. this.size = e,
  95217. this.position = t,
  95218. this.alphaMode = a.ALPHA_ONEONE,
  95219. this.color = i || new D(1,1,1),
  95220. this.texture = n ? new io(n,r.getScene(),!0) : null,
  95221. this._system = r;
  95222. var o = r.scene.getEngine();
  95223. this._drawWrapper = new Gt(o),
  95224. this._drawWrapper.effect = o.createEffect("lensFlare", [Bi.PositionKind], ["color", "viewportMatrix"], ["textureSampler"], ""),
  95225. r.lensFlares.push(this)
  95226. }
  95227. return e.AddFlare = function(t, i, n, r, o) {
  95228. return new e(t,i,n,r,o)
  95229. }
  95230. ,
  95231. e.prototype.dispose = function() {
  95232. this.texture && this.texture.dispose();
  95233. var e = this._system.lensFlares.indexOf(this);
  95234. this._system.lensFlares.splice(e, 1)
  95235. }
  95236. ,
  95237. e
  95238. }();
  95239. Pt.ShadersStore.lensFlarePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  95240. Pt.ShadersStore.lensFlareVertexShader = "attribute vec2 position;\nuniform mat4 viewportMatrix;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  95241. var i_ = function() {
  95242. function e(t, i, n) {
  95243. this.name = t,
  95244. this.lensFlares = new Array,
  95245. this.borderLimit = 300,
  95246. this.viewportBorder = 0,
  95247. this.layerMask = 268435455,
  95248. this._vertexBuffers = {},
  95249. this._isEnabled = !0,
  95250. this._scene = n || E.LastCreatedScene,
  95251. e._SceneComponentInitialization(this._scene),
  95252. this._emitter = i,
  95253. this.id = t,
  95254. n.lensFlareSystems.push(this),
  95255. this.meshesSelectionPredicate = function(e) {
  95256. return n.activeCamera && e.material && e.isVisible && e.isEnabled() && e.isBlocker && 0 != (e.layerMask & n.activeCamera.layerMask)
  95257. }
  95258. ;
  95259. var r = n.getEngine()
  95260. , o = [];
  95261. o.push(1, 1),
  95262. o.push(-1, 1),
  95263. o.push(-1, -1),
  95264. o.push(1, -1),
  95265. this._vertexBuffers[Bi.PositionKind] = new Bi(r,o,Bi.PositionKind,!1,!1,2),
  95266. this._createIndexBuffer()
  95267. }
  95268. return Object.defineProperty(e.prototype, "scene", {
  95269. get: function() {
  95270. return this._scene
  95271. },
  95272. enumerable: !1,
  95273. configurable: !0
  95274. }),
  95275. e.prototype._createIndexBuffer = function() {
  95276. var e = [];
  95277. e.push(0),
  95278. e.push(1),
  95279. e.push(2),
  95280. e.push(0),
  95281. e.push(2),
  95282. e.push(3),
  95283. this._indexBuffer = this._scene.getEngine().createIndexBuffer(e)
  95284. }
  95285. ,
  95286. Object.defineProperty(e.prototype, "isEnabled", {
  95287. get: function() {
  95288. return this._isEnabled
  95289. },
  95290. set: function(e) {
  95291. this._isEnabled = e
  95292. },
  95293. enumerable: !1,
  95294. configurable: !0
  95295. }),
  95296. e.prototype.getScene = function() {
  95297. return this._scene
  95298. }
  95299. ,
  95300. e.prototype.getEmitter = function() {
  95301. return this._emitter
  95302. }
  95303. ,
  95304. e.prototype.setEmitter = function(e) {
  95305. this._emitter = e
  95306. }
  95307. ,
  95308. e.prototype.getEmitterPosition = function() {
  95309. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position
  95310. }
  95311. ,
  95312. e.prototype.computeEffectivePosition = function(e) {
  95313. var t = this.getEmitterPosition();
  95314. t = x.Project(t, P.Identity(), this._scene.getTransformMatrix(), e),
  95315. this._positionX = t.x,
  95316. this._positionY = t.y,
  95317. t = x.TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix()),
  95318. this.viewportBorder > 0 && (e.x -= this.viewportBorder,
  95319. e.y -= this.viewportBorder,
  95320. e.width += 2 * this.viewportBorder,
  95321. e.height += 2 * this.viewportBorder,
  95322. t.x += this.viewportBorder,
  95323. t.y += this.viewportBorder,
  95324. this._positionX += this.viewportBorder,
  95325. this._positionY += this.viewportBorder);
  95326. var i = this._scene.useRightHandedSystem;
  95327. return !!(t.z > 0 && !i || t.z < 0 && i) && (this._positionX > e.x && this._positionX < e.x + e.width && this._positionY > e.y && (this._positionY,
  95328. e.y,
  95329. e.height),
  95330. !0)
  95331. }
  95332. ,
  95333. e.prototype._isVisible = function() {
  95334. if (!this._isEnabled || !this._scene.activeCamera)
  95335. return !1;
  95336. var e = this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition)
  95337. , t = e.length();
  95338. e.normalize();
  95339. var i = new _o(this._scene.activeCamera.globalPosition,e)
  95340. , n = this._scene.pickWithRay(i, this.meshesSelectionPredicate, !0);
  95341. return !n || !n.hit || n.distance > t
  95342. }
  95343. ,
  95344. e.prototype.render = function() {
  95345. if (!this._scene.activeCamera)
  95346. return !1;
  95347. var e, t, i = this._scene.getEngine(), n = this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0), i.getRenderHeight(!0));
  95348. if (!this.computeEffectivePosition(n))
  95349. return !1;
  95350. if (!this._isVisible())
  95351. return !1;
  95352. var r = (e = this._positionX < this.borderLimit + n.x ? this.borderLimit + n.x - this._positionX : this._positionX > n.x + n.width - this.borderLimit ? this._positionX - n.x - n.width + this.borderLimit : 0) > (t = this._positionY < this.borderLimit + n.y ? this.borderLimit + n.y - this._positionY : this._positionY > n.y + n.height - this.borderLimit ? this._positionY - n.y - n.height + this.borderLimit : 0) ? e : t;
  95353. (r -= this.viewportBorder) > this.borderLimit && (r = this.borderLimit);
  95354. var o = 1 - d.Clamp(r / this.borderLimit, 0, 1);
  95355. if (o < 0)
  95356. return !1;
  95357. o > 1 && (o = 1),
  95358. this.viewportBorder > 0 && (n.x += this.viewportBorder,
  95359. n.y += this.viewportBorder,
  95360. n.width -= 2 * this.viewportBorder,
  95361. n.height -= 2 * this.viewportBorder,
  95362. this._positionX -= this.viewportBorder,
  95363. this._positionY -= this.viewportBorder);
  95364. var s = n.x + n.width / 2
  95365. , l = n.y + n.height / 2
  95366. , c = s - this._positionX
  95367. , u = l - this._positionY;
  95368. i.setState(!1),
  95369. i.setDepthBuffer(!1);
  95370. for (var h = 0; h < this.lensFlares.length; h++) {
  95371. var p = this.lensFlares[h];
  95372. if (p._drawWrapper.effect.isReady() && (!p.texture || p.texture.isReady())) {
  95373. i.enableEffect(p._drawWrapper),
  95374. i.bindBuffers(this._vertexBuffers, this._indexBuffer, p._drawWrapper.effect),
  95375. i.setAlphaMode(p.alphaMode);
  95376. var f = s - c * p.position
  95377. , _ = l - u * p.position
  95378. , m = p.size
  95379. , g = p.size * i.getAspectRatio(this._scene.activeCamera, !0)
  95380. , v = f / (n.width + 2 * n.x) * 2 - 1
  95381. , y = 1 - _ / (n.height + 2 * n.y) * 2
  95382. , b = P.FromValues(m / 2, 0, 0, 0, 0, g / 2, 0, 0, 0, 0, 1, 0, v, y, 0, 1);
  95383. p._drawWrapper.effect.setMatrix("viewportMatrix", b),
  95384. p._drawWrapper.effect.setTexture("textureSampler", p.texture),
  95385. p._drawWrapper.effect.setFloat4("color", p.color.r * o, p.color.g * o, p.color.b * o, 1),
  95386. i.drawElementsType(Or.TriangleFillMode, 0, 6)
  95387. }
  95388. }
  95389. return i.setDepthBuffer(!0),
  95390. i.setAlphaMode(a.ALPHA_DISABLE),
  95391. !0
  95392. }
  95393. ,
  95394. e.prototype.rebuild = function() {
  95395. var e;
  95396. for (var t in this._createIndexBuffer(),
  95397. this._vertexBuffers)
  95398. null === (e = this._vertexBuffers[t]) || void 0 === e || e._rebuild()
  95399. }
  95400. ,
  95401. e.prototype.dispose = function() {
  95402. var e = this._vertexBuffers[Bi.PositionKind];
  95403. for (e && (e.dispose(),
  95404. this._vertexBuffers[Bi.PositionKind] = null),
  95405. this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
  95406. this._indexBuffer = null); this.lensFlares.length; )
  95407. this.lensFlares[0].dispose();
  95408. var t = this._scene.lensFlareSystems.indexOf(this);
  95409. this._scene.lensFlareSystems.splice(t, 1)
  95410. }
  95411. ,
  95412. e.Parse = function(t, i, n) {
  95413. var r = i.getLastEntryById(t.emitterId)
  95414. , o = t.name || "lensFlareSystem#" + t.emitterId
  95415. , a = new e(o,r,i);
  95416. a.id = t.id || o,
  95417. a.borderLimit = t.borderLimit;
  95418. for (var s = 0; s < t.flares.length; s++) {
  95419. var l = t.flares[s];
  95420. t_.AddFlare(l.size, l.position, D.FromArray(l.color), l.textureName ? n + l.textureName : "", a)
  95421. }
  95422. return a
  95423. }
  95424. ,
  95425. e.prototype.serialize = function() {
  95426. var e = {};
  95427. e.id = this.id,
  95428. e.name = this.name,
  95429. e.emitterId = this.getEmitter().id,
  95430. e.borderLimit = this.borderLimit,
  95431. e.flares = [];
  95432. for (var t = 0; t < this.lensFlares.length; t++) {
  95433. var i = this.lensFlares[t];
  95434. e.flares.push({
  95435. size: i.size,
  95436. position: i.position,
  95437. color: i.color.asArray(),
  95438. textureName: gi.GetFilename(i.texture ? i.texture.name : "")
  95439. })
  95440. }
  95441. return e
  95442. }
  95443. ,
  95444. e._SceneComponentInitialization = function(e) {
  95445. throw be("LensFlareSystemSceneComponent")
  95446. }
  95447. ,
  95448. e
  95449. }();
  95450. o.AddParser(Wi.NAME_LENSFLARESYSTEM, (function(e, t, i, n) {
  95451. if (void 0 !== e.lensFlareSystems && null !== e.lensFlareSystems) {
  95452. i.lensFlareSystems || (i.lensFlareSystems = new Array);
  95453. for (var r = 0, o = e.lensFlareSystems.length; r < o; r++) {
  95454. var a = e.lensFlareSystems[r]
  95455. , s = i_.Parse(a, t, n);
  95456. i.lensFlareSystems.push(s)
  95457. }
  95458. }
  95459. }
  95460. )),
  95461. o.prototype.getLensFlareSystemByName = function(e) {
  95462. for (var t = 0; t < this.lensFlareSystems.length; t++)
  95463. if (this.lensFlareSystems[t].name === e)
  95464. return this.lensFlareSystems[t];
  95465. return null
  95466. }
  95467. ,
  95468. o.prototype.getLensFlareSystemById = function(e) {
  95469. for (var t = 0; t < this.lensFlareSystems.length; t++)
  95470. if (this.lensFlareSystems[t].id === e)
  95471. return this.lensFlareSystems[t];
  95472. return null
  95473. }
  95474. ,
  95475. o.prototype.getLensFlareSystemByID = function(e) {
  95476. return this.getLensFlareSystemById(e)
  95477. }
  95478. ,
  95479. o.prototype.removeLensFlareSystem = function(e) {
  95480. var t = this.lensFlareSystems.indexOf(e);
  95481. return -1 !== t && this.lensFlareSystems.splice(t, 1),
  95482. t
  95483. }
  95484. ,
  95485. o.prototype.addLensFlareSystem = function(e) {
  95486. this.lensFlareSystems.push(e)
  95487. }
  95488. ;
  95489. var n_ = function() {
  95490. function e(e) {
  95491. this.name = Wi.NAME_LENSFLARESYSTEM,
  95492. this.scene = e,
  95493. e.lensFlareSystems = new Array
  95494. }
  95495. return e.prototype.register = function() {
  95496. this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw)
  95497. }
  95498. ,
  95499. e.prototype.rebuild = function() {
  95500. for (var e = 0; e < this.scene.lensFlareSystems.length; e++)
  95501. this.scene.lensFlareSystems[e].rebuild()
  95502. }
  95503. ,
  95504. e.prototype.addFromContainer = function(e) {
  95505. var t = this;
  95506. e.lensFlareSystems && e.lensFlareSystems.forEach((function(e) {
  95507. t.scene.addLensFlareSystem(e)
  95508. }
  95509. ))
  95510. }
  95511. ,
  95512. e.prototype.removeFromContainer = function(e, t) {
  95513. var i = this;
  95514. e.lensFlareSystems && e.lensFlareSystems.forEach((function(e) {
  95515. i.scene.removeLensFlareSystem(e),
  95516. t && e.dispose()
  95517. }
  95518. ))
  95519. }
  95520. ,
  95521. e.prototype.serialize = function(e) {
  95522. e.lensFlareSystems = [];
  95523. for (var t = 0, i = this.scene.lensFlareSystems; t < i.length; t++) {
  95524. var n = i[t];
  95525. e.lensFlareSystems.push(n.serialize())
  95526. }
  95527. }
  95528. ,
  95529. e.prototype.dispose = function() {
  95530. for (var e = this.scene.lensFlareSystems; e.length; )
  95531. e[0].dispose()
  95532. }
  95533. ,
  95534. e.prototype._draw = function(e) {
  95535. if (this.scene.lensFlaresEnabled) {
  95536. var t = this.scene.lensFlareSystems;
  95537. gi.StartPerformanceCounter("Lens flares", t.length > 0);
  95538. for (var i = 0, n = t; i < n.length; i++) {
  95539. var r = n[i];
  95540. 0 != (e.layerMask & r.layerMask) && r.render()
  95541. }
  95542. gi.EndPerformanceCounter("Lens flares", t.length > 0)
  95543. }
  95544. }
  95545. ,
  95546. e
  95547. }();
  95548. i_._SceneComponentInitialization = function(e) {
  95549. var t = e._getComponent(Wi.NAME_LENSFLARESYSTEM);
  95550. t || (t = new n_(e),
  95551. e._addComponent(t))
  95552. }
  95553. ;
  95554. Pt.IncludesShadersStore.bayerDitherFunctions = "float bayerDither2(vec2 _P) {\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\n}\nfloat bayerDither4(vec2 _P) {\nvec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\n}\nfloat bayerDither8(vec2 _P) {\nvec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5 *mod(_P,4.0)); \nvec2 P4=floor(0.25*mod(_P,8.0)); \nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);\n}\n";
  95555. Pt.IncludesShadersStore.shadowMapFragmentExtraDeclaration = "#if SM_FLOAT==0\n#include<packingFunctions>\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#include<bayerDitherFunctions>\nuniform float softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nuniform vec3 lightDataSM;\nvarying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";
  95556. Pt.IncludesShadersStore.shadowMapFragment = "float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\n#if SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0); \n#endif\n#elif SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#if SM_ESM==1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT==1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";
  95557. Pt.ShadersStore.shadowMapPixelShader = "#include<shadowMapFragmentExtraDeclaration>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\nif (alphaFromAlphaTexture<0.4)\ndiscard;\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#ifdef ALPHATEST\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\n#endif\n#endif\n#include<shadowMapFragment>\n}";
  95558. Pt.IncludesShadersStore.sceneVertexDeclaration = "uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec4 vEyePosition;\n";
  95559. Pt.IncludesShadersStore.meshVertexDeclaration = "uniform mat4 world;\nuniform float visibility;\n";
  95560. Pt.IncludesShadersStore.shadowMapVertexDeclaration = "#include<sceneVertexDeclaration>\n#include<meshVertexDeclaration>\n";
  95561. Pt.IncludesShadersStore.shadowMapUboDeclaration = "layout(std140,column_major) uniform;\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
  95562. Pt.IncludesShadersStore.shadowMapVertexExtraDeclaration = "#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";
  95563. Pt.IncludesShadersStore.shadowMapVertexNormalBias = "#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\nvec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\nworldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";
  95564. Pt.IncludesShadersStore.shadowMapVertexMetric = "#if SM_USEDISTANCE==1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE==1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nzSM=gl_Position.z;\ngl_Position.z=0.0;\n#elif SM_USEDISTANCE==0\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n";
  95565. Pt.ShadersStore.shadowMapVertexShader = "attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#endif\n#include<helperFunctions>\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<shadowMapVertexExtraDeclaration>\n#include<clipPlaneVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));\nvNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include<shadowMapVertexNormalBias>\ngl_Position=viewProjection*worldPos;\n#include<shadowMapVertexMetric>\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<clipPlaneVertex>\n}";
  95566. Pt.ShadersStore.depthBoxBlurPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";
  95567. Pt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = "#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";
  95568. var r_ = function() {
  95569. function e(t, i, n) {
  95570. this.onBeforeShadowMapRenderObservable = new h,
  95571. this.onAfterShadowMapRenderObservable = new h,
  95572. this.onBeforeShadowMapRenderMeshObservable = new h,
  95573. this.onAfterShadowMapRenderMeshObservable = new h,
  95574. this._bias = 5e-5,
  95575. this._normalBias = 0,
  95576. this._blurBoxOffset = 1,
  95577. this._blurScale = 2,
  95578. this._blurKernel = 1,
  95579. this._useKernelBlur = !1,
  95580. this._filter = e.FILTER_NONE,
  95581. this._filteringQuality = e.QUALITY_HIGH,
  95582. this._contactHardeningLightSizeUVRatio = .1,
  95583. this._darkness = 0,
  95584. this._transparencyShadow = !1,
  95585. this.enableSoftTransparentShadow = !1,
  95586. this.frustumEdgeFalloff = 0,
  95587. this.forceBackFacesOnly = !1,
  95588. this._lightDirection = x.Zero(),
  95589. this._viewMatrix = P.Zero(),
  95590. this._projectionMatrix = P.Zero(),
  95591. this._transformMatrix = P.Zero(),
  95592. this._cachedPosition = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  95593. this._cachedDirection = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
  95594. this._currentFaceIndex = 0,
  95595. this._currentFaceIndexCache = 0,
  95596. this._defaultTextureMatrix = P.Identity(),
  95597. this._mapSize = t,
  95598. this._light = i,
  95599. this._scene = i.getScene(),
  95600. i._shadowGenerator = this,
  95601. this.id = i.id,
  95602. this._useUBO = this._scene.getEngine().supportsUniformBuffers,
  95603. this._useUBO && (this._sceneUBOs = [],
  95604. this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "'.concat(this._light.name, '")')))),
  95605. e._SceneComponentInitialization(this._scene);
  95606. var r = this._scene.getEngine().getCaps();
  95607. n ? r.textureFloatRender && r.textureFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_FLOAT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : this._textureType = a.TEXTURETYPE_UNSIGNED_INT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : r.textureFloatRender && r.textureFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_FLOAT : this._textureType = a.TEXTURETYPE_UNSIGNED_INT,
  95608. this._initializeGenerator(),
  95609. this._applyFilterValues()
  95610. }
  95611. return Object.defineProperty(e.prototype, "bias", {
  95612. get: function() {
  95613. return this._bias
  95614. },
  95615. set: function(e) {
  95616. this._bias = e
  95617. },
  95618. enumerable: !1,
  95619. configurable: !0
  95620. }),
  95621. Object.defineProperty(e.prototype, "normalBias", {
  95622. get: function() {
  95623. return this._normalBias
  95624. },
  95625. set: function(e) {
  95626. this._normalBias = e
  95627. },
  95628. enumerable: !1,
  95629. configurable: !0
  95630. }),
  95631. Object.defineProperty(e.prototype, "blurBoxOffset", {
  95632. get: function() {
  95633. return this._blurBoxOffset
  95634. },
  95635. set: function(e) {
  95636. this._blurBoxOffset !== e && (this._blurBoxOffset = e,
  95637. this._disposeBlurPostProcesses())
  95638. },
  95639. enumerable: !1,
  95640. configurable: !0
  95641. }),
  95642. Object.defineProperty(e.prototype, "blurScale", {
  95643. get: function() {
  95644. return this._blurScale
  95645. },
  95646. set: function(e) {
  95647. this._blurScale !== e && (this._blurScale = e,
  95648. this._disposeBlurPostProcesses())
  95649. },
  95650. enumerable: !1,
  95651. configurable: !0
  95652. }),
  95653. Object.defineProperty(e.prototype, "blurKernel", {
  95654. get: function() {
  95655. return this._blurKernel
  95656. },
  95657. set: function(e) {
  95658. this._blurKernel !== e && (this._blurKernel = e,
  95659. this._disposeBlurPostProcesses())
  95660. },
  95661. enumerable: !1,
  95662. configurable: !0
  95663. }),
  95664. Object.defineProperty(e.prototype, "useKernelBlur", {
  95665. get: function() {
  95666. return this._useKernelBlur
  95667. },
  95668. set: function(e) {
  95669. this._useKernelBlur !== e && (this._useKernelBlur = e,
  95670. this._disposeBlurPostProcesses())
  95671. },
  95672. enumerable: !1,
  95673. configurable: !0
  95674. }),
  95675. Object.defineProperty(e.prototype, "depthScale", {
  95676. get: function() {
  95677. return void 0 !== this._depthScale ? this._depthScale : this._light.getDepthScale()
  95678. },
  95679. set: function(e) {
  95680. this._depthScale = e
  95681. },
  95682. enumerable: !1,
  95683. configurable: !0
  95684. }),
  95685. e.prototype._validateFilter = function(e) {
  95686. return e
  95687. }
  95688. ,
  95689. Object.defineProperty(e.prototype, "filter", {
  95690. get: function() {
  95691. return this._filter
  95692. },
  95693. set: function(t) {
  95694. if (t = this._validateFilter(t),
  95695. this._light.needCube()) {
  95696. if (t === e.FILTER_BLUREXPONENTIALSHADOWMAP)
  95697. return void (this.useExponentialShadowMap = !0);
  95698. if (t === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)
  95699. return void (this.useCloseExponentialShadowMap = !0);
  95700. if (t === e.FILTER_PCF || t === e.FILTER_PCSS)
  95701. return void (this.usePoissonSampling = !0)
  95702. }
  95703. t !== e.FILTER_PCF && t !== e.FILTER_PCSS || this._scene.getEngine()._features.supportShadowSamplers ? this._filter !== t && (this._filter = t,
  95704. this._disposeBlurPostProcesses(),
  95705. this._applyFilterValues(),
  95706. this._light._markMeshesAsLightDirty()) : this.usePoissonSampling = !0
  95707. },
  95708. enumerable: !1,
  95709. configurable: !0
  95710. }),
  95711. Object.defineProperty(e.prototype, "usePoissonSampling", {
  95712. get: function() {
  95713. return this.filter === e.FILTER_POISSONSAMPLING
  95714. },
  95715. set: function(t) {
  95716. var i = this._validateFilter(e.FILTER_POISSONSAMPLING);
  95717. (t || this.filter === e.FILTER_POISSONSAMPLING) && (this.filter = t ? i : e.FILTER_NONE)
  95718. },
  95719. enumerable: !1,
  95720. configurable: !0
  95721. }),
  95722. Object.defineProperty(e.prototype, "useExponentialShadowMap", {
  95723. get: function() {
  95724. return this.filter === e.FILTER_EXPONENTIALSHADOWMAP
  95725. },
  95726. set: function(t) {
  95727. var i = this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);
  95728. (t || this.filter === e.FILTER_EXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
  95729. },
  95730. enumerable: !1,
  95731. configurable: !0
  95732. }),
  95733. Object.defineProperty(e.prototype, "useBlurExponentialShadowMap", {
  95734. get: function() {
  95735. return this.filter === e.FILTER_BLUREXPONENTIALSHADOWMAP
  95736. },
  95737. set: function(t) {
  95738. var i = this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);
  95739. (t || this.filter === e.FILTER_BLUREXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
  95740. },
  95741. enumerable: !1,
  95742. configurable: !0
  95743. }),
  95744. Object.defineProperty(e.prototype, "useCloseExponentialShadowMap", {
  95745. get: function() {
  95746. return this.filter === e.FILTER_CLOSEEXPONENTIALSHADOWMAP
  95747. },
  95748. set: function(t) {
  95749. var i = this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);
  95750. (t || this.filter === e.FILTER_CLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
  95751. },
  95752. enumerable: !1,
  95753. configurable: !0
  95754. }),
  95755. Object.defineProperty(e.prototype, "useBlurCloseExponentialShadowMap", {
  95756. get: function() {
  95757. return this.filter === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP
  95758. },
  95759. set: function(t) {
  95760. var i = this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
  95761. (t || this.filter === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
  95762. },
  95763. enumerable: !1,
  95764. configurable: !0
  95765. }),
  95766. Object.defineProperty(e.prototype, "usePercentageCloserFiltering", {
  95767. get: function() {
  95768. return this.filter === e.FILTER_PCF
  95769. },
  95770. set: function(t) {
  95771. var i = this._validateFilter(e.FILTER_PCF);
  95772. (t || this.filter === e.FILTER_PCF) && (this.filter = t ? i : e.FILTER_NONE)
  95773. },
  95774. enumerable: !1,
  95775. configurable: !0
  95776. }),
  95777. Object.defineProperty(e.prototype, "filteringQuality", {
  95778. get: function() {
  95779. return this._filteringQuality
  95780. },
  95781. set: function(e) {
  95782. this._filteringQuality !== e && (this._filteringQuality = e,
  95783. this._disposeBlurPostProcesses(),
  95784. this._applyFilterValues(),
  95785. this._light._markMeshesAsLightDirty())
  95786. },
  95787. enumerable: !1,
  95788. configurable: !0
  95789. }),
  95790. Object.defineProperty(e.prototype, "useContactHardeningShadow", {
  95791. get: function() {
  95792. return this.filter === e.FILTER_PCSS
  95793. },
  95794. set: function(t) {
  95795. var i = this._validateFilter(e.FILTER_PCSS);
  95796. (t || this.filter === e.FILTER_PCSS) && (this.filter = t ? i : e.FILTER_NONE)
  95797. },
  95798. enumerable: !1,
  95799. configurable: !0
  95800. }),
  95801. Object.defineProperty(e.prototype, "contactHardeningLightSizeUVRatio", {
  95802. get: function() {
  95803. return this._contactHardeningLightSizeUVRatio
  95804. },
  95805. set: function(e) {
  95806. this._contactHardeningLightSizeUVRatio = e
  95807. },
  95808. enumerable: !1,
  95809. configurable: !0
  95810. }),
  95811. Object.defineProperty(e.prototype, "darkness", {
  95812. get: function() {
  95813. return this._darkness
  95814. },
  95815. set: function(e) {
  95816. this.setDarkness(e)
  95817. },
  95818. enumerable: !1,
  95819. configurable: !0
  95820. }),
  95821. e.prototype.getDarkness = function() {
  95822. return this._darkness
  95823. }
  95824. ,
  95825. e.prototype.setDarkness = function(e) {
  95826. return this._darkness = e >= 1 ? 1 : e <= 0 ? 0 : e,
  95827. this
  95828. }
  95829. ,
  95830. Object.defineProperty(e.prototype, "transparencyShadow", {
  95831. get: function() {
  95832. return this._transparencyShadow
  95833. },
  95834. set: function(e) {
  95835. this.setTransparencyShadow(e)
  95836. },
  95837. enumerable: !1,
  95838. configurable: !0
  95839. }),
  95840. e.prototype.setTransparencyShadow = function(e) {
  95841. return this._transparencyShadow = e,
  95842. this
  95843. }
  95844. ,
  95845. e.prototype.getShadowMap = function() {
  95846. return this._shadowMap
  95847. }
  95848. ,
  95849. e.prototype.getShadowMapForRendering = function() {
  95850. return this._shadowMap2 ? this._shadowMap2 : this._shadowMap
  95851. }
  95852. ,
  95853. e.prototype.getClassName = function() {
  95854. return e.CLASSNAME
  95855. }
  95856. ,
  95857. e.prototype.addShadowCaster = function(e, t) {
  95858. if (void 0 === t && (t = !0),
  95859. !this._shadowMap)
  95860. return this;
  95861. if (this._shadowMap.renderList || (this._shadowMap.renderList = []),
  95862. -1 === this._shadowMap.renderList.indexOf(e) && this._shadowMap.renderList.push(e),
  95863. t)
  95864. for (var i = 0, n = e.getChildMeshes(); i < n.length; i++) {
  95865. var r = n[i];
  95866. -1 === this._shadowMap.renderList.indexOf(r) && this._shadowMap.renderList.push(r)
  95867. }
  95868. return this
  95869. }
  95870. ,
  95871. e.prototype.removeShadowCaster = function(e, t) {
  95872. if (void 0 === t && (t = !0),
  95873. !this._shadowMap || !this._shadowMap.renderList)
  95874. return this;
  95875. var i = this._shadowMap.renderList.indexOf(e);
  95876. if (-1 !== i && this._shadowMap.renderList.splice(i, 1),
  95877. t)
  95878. for (var n = 0, r = e.getChildren(); n < r.length; n++) {
  95879. var o = r[n];
  95880. this.removeShadowCaster(o)
  95881. }
  95882. return this
  95883. }
  95884. ,
  95885. e.prototype.getLight = function() {
  95886. return this._light
  95887. }
  95888. ,
  95889. Object.defineProperty(e.prototype, "mapSize", {
  95890. get: function() {
  95891. return this._mapSize
  95892. },
  95893. set: function(e) {
  95894. this._mapSize = e,
  95895. this._light._markMeshesAsLightDirty(),
  95896. this.recreateShadowMap()
  95897. },
  95898. enumerable: !1,
  95899. configurable: !0
  95900. }),
  95901. e.prototype._initializeGenerator = function() {
  95902. this._light._markMeshesAsLightDirty(),
  95903. this._initializeShadowMap()
  95904. }
  95905. ,
  95906. e.prototype._createTargetRenderTexture = function() {
  95907. var e = this._scene.getEngine();
  95908. e._features.supportDepthStencilTexture ? (this._shadowMap = new ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),
  95909. this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)) : this._shadowMap = new ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())
  95910. }
  95911. ,
  95912. e.prototype._initializeShadowMap = function() {
  95913. var t = this;
  95914. if (this._createTargetRenderTexture(),
  95915. null !== this._shadowMap) {
  95916. this._shadowMap.wrapU = io.CLAMP_ADDRESSMODE,
  95917. this._shadowMap.wrapV = io.CLAMP_ADDRESSMODE,
  95918. this._shadowMap.anisotropicFilteringLevel = 1,
  95919. this._shadowMap.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
  95920. this._shadowMap.renderParticles = !1,
  95921. this._shadowMap.ignoreCameraViewport = !0,
  95922. this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId),
  95923. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this),
  95924. this._shadowMap.customIsReadyFunction = function() {
  95925. return !0
  95926. }
  95927. ;
  95928. var i = this._scene.getEngine();
  95929. this._shadowMap.onBeforeBindObservable.add((function() {
  95930. var e;
  95931. t._currentSceneUBO = t._scene.getSceneUniformBuffer(),
  95932. null === (e = i._debugPushGroup) || void 0 === e || e.call(i, "shadow map generation for pass id ".concat(i.currentRenderPassId), 1)
  95933. }
  95934. )),
  95935. this._shadowMap.onBeforeRenderObservable.add((function(n) {
  95936. t._sceneUBOs && t._scene.setSceneUniformBuffer(t._sceneUBOs[0]),
  95937. t._currentFaceIndex = n,
  95938. t._filter === e.FILTER_PCF && i.setColorWrite(!1),
  95939. t.getTransformMatrix(),
  95940. t._scene.setTransformMatrix(t._viewMatrix, t._projectionMatrix),
  95941. t._useUBO && (t._scene.getSceneUniformBuffer().unbindEffect(),
  95942. t._scene.finalizeSceneUbo())
  95943. }
  95944. )),
  95945. this._shadowMap.onAfterUnbindObservable.add((function() {
  95946. var n, r;
  95947. if (t._sceneUBOs && t._scene.setSceneUniformBuffer(t._currentSceneUBO),
  95948. t._scene.updateTransformMatrix(),
  95949. t._filter === e.FILTER_PCF && i.setColorWrite(!0),
  95950. t.useBlurExponentialShadowMap || t.useBlurCloseExponentialShadowMap) {
  95951. var o = t.getShadowMapForRendering();
  95952. o && (t._scene.postProcessManager.directRender(t._blurPostProcesses, o.renderTarget, !0),
  95953. i.unBindFramebuffer(o.renderTarget, !0),
  95954. null === (r = i._debugPopGroup) || void 0 === r || r.call(i, 1))
  95955. } else
  95956. null === (n = i._debugPopGroup) || void 0 === n || n.call(i, 1)
  95957. }
  95958. ));
  95959. var n = new N(0,0,0,0)
  95960. , r = new N(1,1,1,1);
  95961. this._shadowMap.onClearObservable.add((function(i) {
  95962. t._filter === e.FILTER_PCF ? i.clear(r, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? i.clear(n, !0, !0, !1) : i.clear(r, !0, !0, !1)
  95963. }
  95964. )),
  95965. this._shadowMap.onResizeObservable.add((function(e) {
  95966. t._storedUniqueId = t._shadowMap.uniqueId,
  95967. t._mapSize = e.getRenderSize(),
  95968. t._light._markMeshesAsLightDirty(),
  95969. t.recreateShadowMap()
  95970. }
  95971. ));
  95972. for (var o = zi.MIN_RENDERINGGROUPS; o < zi.MAX_RENDERINGGROUPS; o++)
  95973. this._shadowMap.setRenderingAutoClearDepthStencil(o, !1)
  95974. }
  95975. }
  95976. ,
  95977. e.prototype._initializeBlurRTTAndPostProcesses = function() {
  95978. var e = this
  95979. , t = this._scene.getEngine()
  95980. , i = this._mapSize / this.blurScale;
  95981. this.useKernelBlur && 1 === this.blurScale || (this._shadowMap2 = new ns(this._light.name + "_shadowMap2",i,this._scene,!1,!0,this._textureType,void 0,void 0,!1),
  95982. this._shadowMap2.wrapU = io.CLAMP_ADDRESSMODE,
  95983. this._shadowMap2.wrapV = io.CLAMP_ADDRESSMODE,
  95984. this._shadowMap2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE)),
  95985. this.useKernelBlur ? (this._kernelBlurXPostprocess = new Fd(this._light.name + "KernelBlurX",new A(1,0),this.blurKernel,1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
  95986. this._kernelBlurXPostprocess.width = i,
  95987. this._kernelBlurXPostprocess.height = i,
  95988. this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0,
  95989. this._kernelBlurXPostprocess.onApplyObservable.add((function(t) {
  95990. t.setTexture("textureSampler", e._shadowMap)
  95991. }
  95992. )),
  95993. this._kernelBlurYPostprocess = new Fd(this._light.name + "KernelBlurY",new A(0,1),this.blurKernel,1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
  95994. this._kernelBlurXPostprocess.autoClear = !1,
  95995. this._kernelBlurYPostprocess.autoClear = !1,
  95996. this._textureType === a.TEXTURETYPE_UNSIGNED_INT && (this._kernelBlurXPostprocess.packedFloat = !0,
  95997. this._kernelBlurYPostprocess.packedFloat = !0),
  95998. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new Ba(this._light.name + "DepthBoxBlur","depthBoxBlur",["screenSize", "boxOffset"],[],1,null,io.BILINEAR_SAMPLINGMODE,t,!1,"#define OFFSET " + this._blurBoxOffset,this._textureType),
  95999. this._boxBlurPostprocess.externalTextureSamplerBinding = !0,
  96000. this._boxBlurPostprocess.onApplyObservable.add((function(t) {
  96001. t.setFloat2("screenSize", i, i),
  96002. t.setTexture("textureSampler", e._shadowMap)
  96003. }
  96004. )),
  96005. this._boxBlurPostprocess.autoClear = !1,
  96006. this._blurPostProcesses = [this._boxBlurPostprocess])
  96007. }
  96008. ,
  96009. e.prototype._renderForShadowMap = function(e, t, i, n) {
  96010. var r;
  96011. if (n.length)
  96012. for (r = 0; r < n.length; r++)
  96013. this._renderSubMeshForShadowMap(n.data[r]);
  96014. for (r = 0; r < e.length; r++)
  96015. this._renderSubMeshForShadowMap(e.data[r]);
  96016. for (r = 0; r < t.length; r++)
  96017. this._renderSubMeshForShadowMap(t.data[r]);
  96018. if (this._transparencyShadow)
  96019. for (r = 0; r < i.length; r++)
  96020. this._renderSubMeshForShadowMap(i.data[r], !0);
  96021. else
  96022. for (r = 0; r < i.length; r++)
  96023. i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
  96024. }
  96025. ,
  96026. e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t, i) {
  96027. t.setMatrix("viewProjection", this.getTransformMatrix())
  96028. }
  96029. ,
  96030. e.prototype._renderSubMeshForShadowMap = function(e, t) {
  96031. var i, n;
  96032. void 0 === t && (t = !1);
  96033. var r = e.getRenderingMesh()
  96034. , o = e.getEffectiveMesh()
  96035. , s = this._scene
  96036. , l = s.getEngine()
  96037. , c = e.getMaterial();
  96038. if (o._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  96039. c && 0 !== e.verticesCount && e._renderId !== s.getRenderId()) {
  96040. var u = o._getWorldMatrixDeterminant() < 0
  96041. , h = null !== (i = r.overrideMaterialSideOrientation) && void 0 !== i ? i : c.sideOrientation;
  96042. u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation);
  96043. var d = h === a.MATERIAL_ClockWiseSideOrientation;
  96044. l.setState(c.backFaceCulling, void 0, void 0, d, c.cullBackFaces);
  96045. var p = r._getInstancesRenderList(e._id, !!e.getReplacementMesh());
  96046. if (!p.mustReturn) {
  96047. var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || r.hasThinInstances);
  96048. if (!this.customAllowRendering || this.customAllowRendering(e))
  96049. if (this.isReady(e, f, t)) {
  96050. e._renderId = s.getRenderId();
  96051. var _ = c.shadowDepthWrapper
  96052. , m = null !== (n = null == _ ? void 0 : _.getEffect(e, this, l.currentRenderPassId)) && void 0 !== n ? n : e._getDrawWrapper()
  96053. , g = Gt.GetEffect(m);
  96054. if (l.enableEffect(m),
  96055. f || r._bind(e, g, c.fillMode),
  96056. this.getTransformMatrix(),
  96057. g.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
  96058. this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? g.setVector3("lightDataSM", this._cachedDirection) : g.setVector3("lightDataSM", this._cachedPosition),
  96059. s.activeCamera && g.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(s.activeCamera), this.getLight().getDepthMinZ(s.activeCamera) + this.getLight().getDepthMaxZ(s.activeCamera)),
  96060. t && this.enableSoftTransparentShadow && g.setFloat("softTransparentShadowSM", o.visibility * c.alpha),
  96061. _)
  96062. e._setMainDrawWrapperOverride(m),
  96063. _.standalone ? _.baseMaterial.bindForSubMesh(o.getWorldMatrix(), r, e) : c.bindForSubMesh(o.getWorldMatrix(), r, e),
  96064. e._setMainDrawWrapperOverride(null);
  96065. else {
  96066. if (c && c.needAlphaTesting()) {
  96067. var v = c.getAlphaTestTexture();
  96068. v && (g.setTexture("diffuseSampler", v),
  96069. g.setMatrix("diffuseMatrix", v.getTextureMatrix() || this._defaultTextureMatrix))
  96070. }
  96071. if (r.useBones && r.computeBonesUsingShaders && r.skeleton) {
  96072. var y = r.skeleton;
  96073. if (y.isUsingTextureForMatrices) {
  96074. var b = y.getTransformMatrixTexture(r);
  96075. if (!b)
  96076. return;
  96077. g.setTexture("boneSampler", b),
  96078. g.setFloat("boneTextureWidth", 4 * (y.bones.length + 1))
  96079. } else
  96080. g.setMatrices("mBones", y.getTransformMatrices(r))
  96081. }
  96082. Mr.BindMorphTargetParameters(r, g),
  96083. r.morphTargetManager && r.morphTargetManager.isUsingTextureForTargets && r.morphTargetManager._bind(g),
  96084. Mr.BindClipPlane(g, s)
  96085. }
  96086. this._useUBO || _ || this._bindCustomEffectForRenderSubMeshForShadowMap(e, g, o),
  96087. Mr.BindSceneUniformBuffer(g, this._scene.getSceneUniformBuffer()),
  96088. this._scene.getSceneUniformBuffer().bindUniformBuffer();
  96089. var T = o.getWorldMatrix();
  96090. f && (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
  96091. o.transferToEffect(T)),
  96092. this.forceBackFacesOnly && l.setState(!0, 0, !1, !0, c.cullBackFaces),
  96093. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(r),
  96094. this.onBeforeShadowMapRenderObservable.notifyObservers(g),
  96095. r._processRendering(o, e, g, c.fillMode, p, f, (function(e, t) {
  96096. o === r || e ? (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
  96097. o.transferToEffect(e ? t : T)) : (r.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
  96098. r.transferToEffect(t))
  96099. }
  96100. )),
  96101. this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, c.cullBackFaces),
  96102. this.onAfterShadowMapRenderObservable.notifyObservers(g),
  96103. this.onAfterShadowMapRenderMeshObservable.notifyObservers(r)
  96104. } else
  96105. this._shadowMap && this._shadowMap.resetRefreshCounter()
  96106. }
  96107. }
  96108. }
  96109. ,
  96110. e.prototype._applyFilterValues = function() {
  96111. this._shadowMap && (this.filter === e.FILTER_NONE || this.filter === e.FILTER_PCSS ? this._shadowMap.updateSamplingMode(io.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(io.BILINEAR_SAMPLINGMODE))
  96112. }
  96113. ,
  96114. e.prototype.forceCompilation = function(e, t) {
  96115. var i = this
  96116. , n = V({
  96117. useInstances: !1
  96118. }, t)
  96119. , r = this.getShadowMap();
  96120. if (r) {
  96121. var o = r.renderList;
  96122. if (o) {
  96123. for (var a = new Array, s = 0, l = o; s < l.length; s++) {
  96124. var c = l[s];
  96125. a.push.apply(a, c.subMeshes)
  96126. }
  96127. if (0 !== a.length) {
  96128. var u = 0
  96129. , h = function() {
  96130. var t, r;
  96131. if (i._scene && i._scene.getEngine()) {
  96132. for (; i.isReady(a[u], n.useInstances, null !== (r = null === (t = a[u].getMaterial()) || void 0 === t ? void 0 : t.needAlphaBlendingForMesh(a[u].getMesh())) && void 0 !== r && r); )
  96133. if (++u >= a.length)
  96134. return void (e && e(i));
  96135. setTimeout(h, 16)
  96136. }
  96137. };
  96138. h()
  96139. } else
  96140. e && e(this)
  96141. } else
  96142. e && e(this)
  96143. } else
  96144. e && e(this)
  96145. }
  96146. ,
  96147. e.prototype.forceCompilationAsync = function(e) {
  96148. var t = this;
  96149. return new Promise((function(i) {
  96150. t.forceCompilation((function() {
  96151. i()
  96152. }
  96153. ), e)
  96154. }
  96155. ))
  96156. }
  96157. ,
  96158. e.prototype._isReadyCustomDefines = function(e, t, i) {}
  96159. ,
  96160. e.prototype._prepareShadowDefines = function(e, t, i, n) {
  96161. i.push("#define SM_FLOAT " + (this._textureType !== a.TEXTURETYPE_UNSIGNED_INT ? "1" : "0")),
  96162. i.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")),
  96163. i.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
  96164. var r = e.getMesh();
  96165. return i.push("#define SM_NORMALBIAS " + (this.normalBias && r.isVerticesDataPresent(Bi.NormalKind) ? "1" : "0")),
  96166. i.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
  96167. i.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
  96168. i.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && n ? "1" : "0")),
  96169. this._isReadyCustomDefines(i, e, t),
  96170. i
  96171. }
  96172. ,
  96173. e.prototype.isReady = function(e, t, i) {
  96174. var n = e.getMaterial()
  96175. , r = null == n ? void 0 : n.shadowDepthWrapper
  96176. , o = [];
  96177. if (this._prepareShadowDefines(e, t, o, i),
  96178. r) {
  96179. if (!r.isReadyForSubMesh(e, o, this, t, this._scene.getEngine().currentRenderPassId))
  96180. return !1
  96181. } else {
  96182. var a = e._getDrawWrapper(void 0, !0)
  96183. , s = a.effect
  96184. , l = a.defines
  96185. , c = [Bi.PositionKind]
  96186. , u = e.getMesh();
  96187. if (this.normalBias && u.isVerticesDataPresent(Bi.NormalKind) && (c.push(Bi.NormalKind),
  96188. o.push("#define NORMAL"),
  96189. u.nonUniformScaling && o.push("#define NONUNIFORMSCALING")),
  96190. n && n.needAlphaTesting()) {
  96191. var h = n.getAlphaTestTexture();
  96192. if (h) {
  96193. if (!h.isReady())
  96194. return !1;
  96195. o.push("#define ALPHATEST"),
  96196. u.isVerticesDataPresent(Bi.UVKind) && (c.push(Bi.UVKind),
  96197. o.push("#define UV1")),
  96198. u.isVerticesDataPresent(Bi.UV2Kind) && 1 === h.coordinatesIndex && (c.push(Bi.UV2Kind),
  96199. o.push("#define UV2"))
  96200. }
  96201. }
  96202. var d = new ys;
  96203. if (u.useBones && u.computeBonesUsingShaders && u.skeleton) {
  96204. c.push(Bi.MatricesIndicesKind),
  96205. c.push(Bi.MatricesWeightsKind),
  96206. u.numBoneInfluencers > 4 && (c.push(Bi.MatricesIndicesExtraKind),
  96207. c.push(Bi.MatricesWeightsExtraKind));
  96208. var p = u.skeleton;
  96209. o.push("#define NUM_BONE_INFLUENCERS " + u.numBoneInfluencers),
  96210. u.numBoneInfluencers > 0 && d.addCPUSkinningFallback(0, u),
  96211. p.isUsingTextureForMatrices ? o.push("#define BONETEXTURE") : o.push("#define BonesPerMesh " + (p.bones.length + 1))
  96212. } else
  96213. o.push("#define NUM_BONE_INFLUENCERS 0");
  96214. var f = u.morphTargetManager
  96215. , _ = 0;
  96216. f && f.numInfluencers > 0 && (o.push("#define MORPHTARGETS"),
  96217. _ = f.numInfluencers,
  96218. o.push("#define NUM_MORPH_INFLUENCERS " + _),
  96219. f.isUsingTextureForTargets && o.push("#define MORPHTARGETS_TEXTURE"),
  96220. Mr.PrepareAttributesForMorphTargetsInfluencers(c, u, _));
  96221. var m = this._scene;
  96222. if (m.clipPlane && o.push("#define CLIPPLANE"),
  96223. m.clipPlane2 && o.push("#define CLIPPLANE2"),
  96224. m.clipPlane3 && o.push("#define CLIPPLANE3"),
  96225. m.clipPlane4 && o.push("#define CLIPPLANE4"),
  96226. m.clipPlane5 && o.push("#define CLIPPLANE5"),
  96227. m.clipPlane6 && o.push("#define CLIPPLANE6"),
  96228. t && (o.push("#define INSTANCES"),
  96229. Mr.PushAttributesForInstances(c),
  96230. e.getRenderingMesh().hasThinInstances && o.push("#define THIN_INSTANCES")),
  96231. this.customShaderOptions && this.customShaderOptions.defines)
  96232. for (var g = 0, v = this.customShaderOptions.defines; g < v.length; g++) {
  96233. var y = v[g];
  96234. -1 === o.indexOf(y) && o.push(y)
  96235. }
  96236. var b = o.join("\n");
  96237. if (l !== b) {
  96238. l = b;
  96239. var T = "shadowMap"
  96240. , E = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
  96241. , S = ["diffuseSampler", "boneSampler", "morphTargets"];
  96242. if (this.customShaderOptions) {
  96243. if (T = this.customShaderOptions.shaderName,
  96244. this.customShaderOptions.attributes)
  96245. for (var A = 0, x = this.customShaderOptions.attributes; A < x.length; A++) {
  96246. var R = x[A];
  96247. -1 === c.indexOf(R) && c.push(R)
  96248. }
  96249. if (this.customShaderOptions.uniforms)
  96250. for (var C = 0, P = this.customShaderOptions.uniforms; C < P.length; C++) {
  96251. var M = P[C];
  96252. -1 === E.indexOf(M) && E.push(M)
  96253. }
  96254. if (this.customShaderOptions.samplers)
  96255. for (var I = 0, O = this.customShaderOptions.samplers; I < O.length; I++) {
  96256. var D = O[I];
  96257. -1 === S.indexOf(D) && S.push(D)
  96258. }
  96259. }
  96260. var N = this._scene.getEngine();
  96261. s = N.createEffect(T, {
  96262. attributes: c,
  96263. uniformsNames: E,
  96264. uniformBuffersNames: ["Scene", "Mesh"],
  96265. samplers: S,
  96266. defines: b,
  96267. fallbacks: d,
  96268. onCompiled: null,
  96269. onError: null,
  96270. indexParameters: {
  96271. maxSimultaneousMorphTargets: _
  96272. }
  96273. }, N),
  96274. a.setEffect(s, l)
  96275. }
  96276. if (!s.isReady())
  96277. return !1
  96278. }
  96279. return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (this._blurPostProcesses && this._blurPostProcesses.length || this._initializeBlurRTTAndPostProcesses()),
  96280. !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady())
  96281. }
  96282. ,
  96283. e.prototype.prepareDefines = function(t, i) {
  96284. var n = this._scene
  96285. , r = this._light;
  96286. n.shadowsEnabled && r.shadowEnabled && (t["SHADOW" + i] = !0,
  96287. this.useContactHardeningShadow ? (t["SHADOWPCSS" + i] = !0,
  96288. this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePercentageCloserFiltering ? (t["SHADOWPCF" + i] = !0,
  96289. this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePoissonSampling ? t["SHADOWPOISSON" + i] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? t["SHADOWESM" + i] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (t["SHADOWCLOSEESM" + i] = !0),
  96290. r.needCube() && (t["SHADOWCUBE" + i] = !0))
  96291. }
  96292. ,
  96293. e.prototype.bindShadowLight = function(t, i) {
  96294. var n = this._light
  96295. , r = this._scene;
  96296. if (r.shadowsEnabled && n.shadowEnabled) {
  96297. var o = r.activeCamera;
  96298. if (o) {
  96299. var a = this.getShadowMap();
  96300. a && (n.needCube() || i.setMatrix("lightMatrix" + t, this.getTransformMatrix()),
  96301. this._filter === e.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
  96302. n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a.getSize().width, 1 / a.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === e.FILTER_PCSS ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
  96303. i.setTexture("depthSampler" + t, this.getShadowMapForRendering()),
  96304. n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a.getSize().width, this._contactHardeningLightSizeUVRatio * a.getSize().width, this.frustumEdgeFalloff, t)) : (i.setTexture("shadowSampler" + t, this.getShadowMapForRendering()),
  96305. n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / a.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)),
  96306. n._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), t))
  96307. }
  96308. }
  96309. }
  96310. ,
  96311. e.prototype.getTransformMatrix = function() {
  96312. var e = this._scene;
  96313. if (this._currentRenderId === e.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
  96314. return this._transformMatrix;
  96315. this._currentRenderId = e.getRenderId(),
  96316. this._currentFaceIndexCache = this._currentFaceIndex;
  96317. var t = this._light.position;
  96318. if (this._light.computeTransformedInformation() && (t = this._light.transformedPosition),
  96319. x.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
  96320. 1 === Math.abs(x.Dot(this._lightDirection, x.Up())) && (this._lightDirection.z = 1e-13),
  96321. this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !t.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  96322. this._cachedPosition.copyFrom(t),
  96323. this._cachedDirection.copyFrom(this._lightDirection),
  96324. P.LookAtLHToRef(t, t.add(this._lightDirection), x.Up(), this._viewMatrix);
  96325. var i = this.getShadowMap();
  96326. if (i) {
  96327. var n = i.renderList;
  96328. n && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, n)
  96329. }
  96330. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix)
  96331. }
  96332. return this._transformMatrix
  96333. }
  96334. ,
  96335. e.prototype.recreateShadowMap = function() {
  96336. var e = this._shadowMap;
  96337. if (e) {
  96338. var t = e.renderList;
  96339. if (this._disposeRTTandPostProcesses(),
  96340. this._initializeGenerator(),
  96341. this.filter = this._filter,
  96342. this._applyFilterValues(),
  96343. t) {
  96344. this._shadowMap.renderList || (this._shadowMap.renderList = []);
  96345. for (var i = 0, n = t; i < n.length; i++) {
  96346. var r = n[i];
  96347. this._shadowMap.renderList.push(r)
  96348. }
  96349. } else
  96350. this._shadowMap.renderList = null
  96351. }
  96352. }
  96353. ,
  96354. e.prototype._disposeBlurPostProcesses = function() {
  96355. this._shadowMap2 && (this._shadowMap2.dispose(),
  96356. this._shadowMap2 = null),
  96357. this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(),
  96358. this._boxBlurPostprocess = null),
  96359. this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(),
  96360. this._kernelBlurXPostprocess = null),
  96361. this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(),
  96362. this._kernelBlurYPostprocess = null),
  96363. this._blurPostProcesses = []
  96364. }
  96365. ,
  96366. e.prototype._disposeRTTandPostProcesses = function() {
  96367. this._shadowMap && (this._shadowMap.dispose(),
  96368. this._shadowMap = null),
  96369. this._disposeBlurPostProcesses()
  96370. }
  96371. ,
  96372. e.prototype._disposeSceneUBOs = function() {
  96373. if (this._sceneUBOs) {
  96374. for (var e = 0, t = this._sceneUBOs; e < t.length; e++)
  96375. t[e].dispose();
  96376. this._sceneUBOs = []
  96377. }
  96378. }
  96379. ,
  96380. e.prototype.dispose = function() {
  96381. this._disposeRTTandPostProcesses(),
  96382. this._disposeSceneUBOs(),
  96383. this._light && (this._light._shadowGenerator = null,
  96384. this._light._markMeshesAsLightDirty()),
  96385. this.onBeforeShadowMapRenderMeshObservable.clear(),
  96386. this.onBeforeShadowMapRenderObservable.clear(),
  96387. this.onAfterShadowMapRenderMeshObservable.clear(),
  96388. this.onAfterShadowMapRenderObservable.clear()
  96389. }
  96390. ,
  96391. e.prototype.serialize = function() {
  96392. var e = {}
  96393. , t = this.getShadowMap();
  96394. if (!t)
  96395. return e;
  96396. if (e.className = this.getClassName(),
  96397. e.lightId = this._light.id,
  96398. e.id = this.id,
  96399. e.mapSize = t.getRenderSize(),
  96400. e.forceBackFacesOnly = this.forceBackFacesOnly,
  96401. e.darkness = this.getDarkness(),
  96402. e.transparencyShadow = this._transparencyShadow,
  96403. e.frustumEdgeFalloff = this.frustumEdgeFalloff,
  96404. e.bias = this.bias,
  96405. e.normalBias = this.normalBias,
  96406. e.usePercentageCloserFiltering = this.usePercentageCloserFiltering,
  96407. e.useContactHardeningShadow = this.useContactHardeningShadow,
  96408. e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio,
  96409. e.filteringQuality = this.filteringQuality,
  96410. e.useExponentialShadowMap = this.useExponentialShadowMap,
  96411. e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap,
  96412. e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
  96413. e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
  96414. e.usePoissonSampling = this.usePoissonSampling,
  96415. e.depthScale = this.depthScale,
  96416. e.blurBoxOffset = this.blurBoxOffset,
  96417. e.blurKernel = this.blurKernel,
  96418. e.blurScale = this.blurScale,
  96419. e.useKernelBlur = this.useKernelBlur,
  96420. e.renderList = [],
  96421. t.renderList)
  96422. for (var i = 0; i < t.renderList.length; i++) {
  96423. var n = t.renderList[i];
  96424. e.renderList.push(n.id)
  96425. }
  96426. return e
  96427. }
  96428. ,
  96429. e.Parse = function(t, i, n) {
  96430. for (var r = i.getLightById(t.lightId), o = n ? n(t.mapSize, r) : new e(t.mapSize,r), a = o.getShadowMap(), s = 0; s < t.renderList.length; s++)
  96431. i.getMeshesById(t.renderList[s]).forEach((function(e) {
  96432. a && (a.renderList || (a.renderList = []),
  96433. a.renderList.push(e))
  96434. }
  96435. ));
  96436. return void 0 !== t.id && (o.id = t.id),
  96437. o.forceBackFacesOnly = !!t.forceBackFacesOnly,
  96438. void 0 !== t.darkness && o.setDarkness(t.darkness),
  96439. t.transparencyShadow && o.setTransparencyShadow(!0),
  96440. void 0 !== t.frustumEdgeFalloff && (o.frustumEdgeFalloff = t.frustumEdgeFalloff),
  96441. void 0 !== t.bias && (o.bias = t.bias),
  96442. void 0 !== t.normalBias && (o.normalBias = t.normalBias),
  96443. t.usePercentageCloserFiltering ? o.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? o.useContactHardeningShadow = !0 : t.usePoissonSampling ? o.usePoissonSampling = !0 : t.useExponentialShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? o.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? o.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? o.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (o.useBlurExponentialShadowMap = !0),
  96444. void 0 !== t.contactHardeningLightSizeUVRatio && (o.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio),
  96445. void 0 !== t.filteringQuality && (o.filteringQuality = t.filteringQuality),
  96446. t.depthScale && (o.depthScale = t.depthScale),
  96447. t.blurScale && (o.blurScale = t.blurScale),
  96448. t.blurBoxOffset && (o.blurBoxOffset = t.blurBoxOffset),
  96449. t.useKernelBlur && (o.useKernelBlur = t.useKernelBlur),
  96450. t.blurKernel && (o.blurKernel = t.blurKernel),
  96451. o
  96452. }
  96453. ,
  96454. e.CLASSNAME = "ShadowGenerator",
  96455. e.FILTER_NONE = 0,
  96456. e.FILTER_EXPONENTIALSHADOWMAP = 1,
  96457. e.FILTER_POISSONSAMPLING = 2,
  96458. e.FILTER_BLUREXPONENTIALSHADOWMAP = 3,
  96459. e.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4,
  96460. e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5,
  96461. e.FILTER_PCF = 6,
  96462. e.FILTER_PCSS = 7,
  96463. e.QUALITY_HIGH = 0,
  96464. e.QUALITY_MEDIUM = 1,
  96465. e.QUALITY_LOW = 2,
  96466. e._SceneComponentInitialization = function(e) {
  96467. throw be("ShadowGeneratorSceneComponent")
  96468. }
  96469. ,
  96470. e
  96471. }();
  96472. Pt.ShadersStore.depthPixelShader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\n#ifdef PACKED\n#include<packingFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n}";
  96473. Pt.ShadersStore.depthVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));\n#else\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#endif\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
  96474. var o_ = function() {
  96475. function e(t, i, n, r, o) {
  96476. void 0 === i && (i = a.TEXTURETYPE_FLOAT),
  96477. void 0 === n && (n = null),
  96478. void 0 === r && (r = !1),
  96479. void 0 === o && (o = io.TRILINEAR_SAMPLINGMODE);
  96480. var s = this;
  96481. this.enabled = !0,
  96482. this.forceDepthWriteTransparentMeshes = !1,
  96483. this.useOnlyInActiveCamera = !1,
  96484. this._scene = t,
  96485. this._storeNonLinearDepth = r,
  96486. this.isPacked = i === a.TEXTURETYPE_UNSIGNED_BYTE,
  96487. this.isPacked ? this._clearColor = new N(1,1,1,1) : this._clearColor = new N(1,0,0,1),
  96488. e._SceneComponentInitialization(this._scene);
  96489. var l = t.getEngine();
  96490. this._camera = n,
  96491. o !== io.NEAREST_SAMPLINGMODE && (i !== a.TEXTURETYPE_FLOAT || l._caps.textureFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE),
  96492. i !== a.TEXTURETYPE_HALF_FLOAT || l._caps.textureHalfFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE));
  96493. var c = this.isPacked || !l._features.supportExtendedTextureFormats ? a.TEXTUREFORMAT_RGBA : a.TEXTUREFORMAT_R;
  96494. this._depthMap = new ns("DepthRenderer",{
  96495. width: l.getRenderWidth(),
  96496. height: l.getRenderHeight()
  96497. },this._scene,!1,!0,i,!1,o,void 0,void 0,void 0,c),
  96498. this._depthMap.wrapU = io.CLAMP_ADDRESSMODE,
  96499. this._depthMap.wrapV = io.CLAMP_ADDRESSMODE,
  96500. this._depthMap.refreshRate = 1,
  96501. this._depthMap.renderParticles = !1,
  96502. this._depthMap.renderList = null,
  96503. this._depthMap.activeCamera = this._camera,
  96504. this._depthMap.ignoreCameraViewport = !0,
  96505. this._depthMap.useCameraPostProcesses = !1,
  96506. this._depthMap.onClearObservable.add((function(e) {
  96507. e.clear(s._clearColor, !0, !0, !0)
  96508. }
  96509. )),
  96510. this._depthMap.onBeforeBindObservable.add((function() {
  96511. var e;
  96512. null === (e = l._debugPushGroup) || void 0 === e || e.call(l, "depth renderer", 1)
  96513. }
  96514. )),
  96515. this._depthMap.onAfterUnbindObservable.add((function() {
  96516. var e;
  96517. null === (e = l._debugPopGroup) || void 0 === e || e.call(l, 1)
  96518. }
  96519. )),
  96520. this._depthMap.customIsReadyFunction = function(e, t) {
  96521. if (!e.isReady(!1))
  96522. return !1;
  96523. if (0 === t && e.subMeshes)
  96524. for (var i = 0; i < e.subMeshes.length; ++i) {
  96525. var n = e.subMeshes[i]
  96526. , r = n.getRenderingMesh()
  96527. , o = r._getInstancesRenderList(n._id, !!n.getReplacementMesh())
  96528. , a = l.getCaps().instancedArrays && (null !== o.visibleInstances[n._id] && void 0 !== o.visibleInstances[n._id] || r.hasThinInstances);
  96529. if (!s.isReady(n, a))
  96530. return !1
  96531. }
  96532. return !0
  96533. }
  96534. ;
  96535. var u = function(e) {
  96536. var t, i, n = e.getRenderingMesh(), r = e.getEffectiveMesh(), o = s._scene, l = o.getEngine(), c = e.getMaterial();
  96537. if (r._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  96538. c && !r.infiniteDistance && !c.disableDepthWrite && 0 !== e.verticesCount && e._renderId !== o.getRenderId()) {
  96539. var u = r._getWorldMatrixDeterminant() < 0
  96540. , h = null !== (t = n.overrideMaterialSideOrientation) && void 0 !== t ? t : c.sideOrientation;
  96541. u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation);
  96542. var d = h === a.MATERIAL_ClockWiseSideOrientation;
  96543. l.setState(c.backFaceCulling, 0, !1, d, c.cullBackFaces);
  96544. var p = n._getInstancesRenderList(e._id, !!e.getReplacementMesh());
  96545. if (!p.mustReturn) {
  96546. var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || n.hasThinInstances)
  96547. , _ = s._camera || o.activeCamera;
  96548. if (s.isReady(e, f) && _) {
  96549. e._renderId = o.getRenderId();
  96550. var m = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[l.currentRenderPassId]
  96551. , g = e._getDrawWrapper();
  96552. !g && m && (g = m._getDrawWrapper());
  96553. var v = _.mode === Rr.ORTHOGRAPHIC_CAMERA;
  96554. if (!g)
  96555. return;
  96556. var y = g.effect;
  96557. l.enableEffect(g),
  96558. f || n._bind(e, y, c.fillMode),
  96559. m ? m.bindForSubMesh(r.getWorldMatrix(), r, e) : (y.setMatrix("viewProjection", o.getTransformMatrix()),
  96560. y.setMatrix("world", r.getWorldMatrix()));
  96561. var b = void 0
  96562. , T = void 0;
  96563. if (v ? (b = !l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1,
  96564. T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1) : (b = l.useReverseDepthBuffer && l.isNDCHalfZRange ? _.minZ : l.isNDCHalfZRange ? 0 : _.minZ,
  96565. T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : _.maxZ),
  96566. y.setFloat2("depthValues", b, b + T),
  96567. !m) {
  96568. if (c && c.needAlphaTesting()) {
  96569. var E = c.getAlphaTestTexture();
  96570. E && (y.setTexture("diffuseSampler", E),
  96571. y.setMatrix("diffuseMatrix", E.getTextureMatrix()))
  96572. }
  96573. if (n.useBones && n.computeBonesUsingShaders && n.skeleton) {
  96574. var S = n.skeleton;
  96575. if (S.isUsingTextureForMatrices) {
  96576. var A = S.getTransformMatrixTexture(n);
  96577. if (!A)
  96578. return;
  96579. y.setTexture("boneSampler", A),
  96580. y.setFloat("boneTextureWidth", 4 * (S.bones.length + 1))
  96581. } else
  96582. y.setMatrices("mBones", S.getTransformMatrices(n))
  96583. }
  96584. Mr.BindMorphTargetParameters(n, y),
  96585. n.morphTargetManager && n.morphTargetManager.isUsingTextureForTargets && n.morphTargetManager._bind(y)
  96586. }
  96587. n._processRendering(r, e, y, c.fillMode, p, f, (function(e, t) {
  96588. return y.setMatrix("world", t)
  96589. }
  96590. ))
  96591. }
  96592. }
  96593. }
  96594. };
  96595. this._depthMap.customRenderFunction = function(e, t, i, n) {
  96596. var r;
  96597. if (n.length)
  96598. for (r = 0; r < n.length; r++)
  96599. u(n.data[r]);
  96600. for (r = 0; r < e.length; r++)
  96601. u(e.data[r]);
  96602. for (r = 0; r < t.length; r++)
  96603. u(t.data[r]);
  96604. if (s.forceDepthWriteTransparentMeshes)
  96605. for (r = 0; r < i.length; r++)
  96606. u(i.data[r]);
  96607. else
  96608. for (r = 0; r < i.length; r++)
  96609. i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
  96610. }
  96611. }
  96612. return e.prototype.setMaterialForRendering = function(e, t) {
  96613. this._depthMap.setMaterialForRendering(e, t)
  96614. }
  96615. ,
  96616. e.prototype.isReady = function(e, t) {
  96617. var i, n = this._scene.getEngine(), r = e.getMesh(), o = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[n.currentRenderPassId];
  96618. if (o)
  96619. return o.isReadyForSubMesh(r, e, t);
  96620. var a = e.getMaterial();
  96621. if (!a || a.disableDepthWrite)
  96622. return !1;
  96623. var s = []
  96624. , l = [Bi.PositionKind];
  96625. if (a && a.needAlphaTesting() && a.getAlphaTestTexture() && (s.push("#define ALPHATEST"),
  96626. r.isVerticesDataPresent(Bi.UVKind) && (l.push(Bi.UVKind),
  96627. s.push("#define UV1")),
  96628. r.isVerticesDataPresent(Bi.UV2Kind) && (l.push(Bi.UV2Kind),
  96629. s.push("#define UV2"))),
  96630. r.useBones && r.computeBonesUsingShaders) {
  96631. l.push(Bi.MatricesIndicesKind),
  96632. l.push(Bi.MatricesWeightsKind),
  96633. r.numBoneInfluencers > 4 && (l.push(Bi.MatricesIndicesExtraKind),
  96634. l.push(Bi.MatricesWeightsExtraKind)),
  96635. s.push("#define NUM_BONE_INFLUENCERS " + r.numBoneInfluencers),
  96636. s.push("#define BonesPerMesh " + (r.skeleton ? r.skeleton.bones.length + 1 : 0));
  96637. var c = e.getRenderingMesh().skeleton;
  96638. (null == c ? void 0 : c.isUsingTextureForMatrices) && s.push("#define BONETEXTURE")
  96639. } else
  96640. s.push("#define NUM_BONE_INFLUENCERS 0");
  96641. var u = r.morphTargetManager
  96642. , h = 0;
  96643. u && u.numInfluencers > 0 && (h = u.numInfluencers,
  96644. s.push("#define MORPHTARGETS"),
  96645. s.push("#define NUM_MORPH_INFLUENCERS " + h),
  96646. u.isUsingTextureForTargets && s.push("#define MORPHTARGETS_TEXTURE"),
  96647. Mr.PrepareAttributesForMorphTargetsInfluencers(l, r, h)),
  96648. t && (s.push("#define INSTANCES"),
  96649. Mr.PushAttributesForInstances(l),
  96650. e.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES")),
  96651. this._storeNonLinearDepth && s.push("#define NONLINEARDEPTH"),
  96652. this.isPacked && s.push("#define PACKED");
  96653. var d = e._getDrawWrapper(void 0, !0)
  96654. , p = d.defines
  96655. , f = s.join("\n");
  96656. return p !== f && d.setEffect(n.createEffect("depth", l, ["world", "mBones", "boneTextureWidth", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "morphTargets", "boneSampler"], f, void 0, void 0, void 0, {
  96657. maxSimultaneousMorphTargets: h
  96658. }), f),
  96659. d.effect.isReady()
  96660. }
  96661. ,
  96662. e.prototype.getDepthMap = function() {
  96663. return this._depthMap
  96664. }
  96665. ,
  96666. e.prototype.dispose = function() {
  96667. var e = [];
  96668. for (var t in this._scene._depthRenderer)
  96669. this._scene._depthRenderer[t] === this && e.push(t);
  96670. if (e.length > 0) {
  96671. this._depthMap.dispose();
  96672. for (var i = 0, n = e; i < n.length; i++)
  96673. t = n[i],
  96674. delete this._scene._depthRenderer[t]
  96675. }
  96676. }
  96677. ,
  96678. e._SceneComponentInitialization = function(e) {
  96679. throw be("DepthRendererSceneComponent")
  96680. }
  96681. ,
  96682. e
  96683. }();
  96684. Pt.ShadersStore.minmaxReduxPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\nglFragColor=vec4(0.);\nif (true) { \ndiscard;\n}\n}\n#endif\n";
  96685. var a_ = function() {
  96686. function e(e) {
  96687. var t = this;
  96688. this.onAfterReductionPerformed = new h,
  96689. this._forceFullscreenViewport = !0,
  96690. this._activated = !1,
  96691. this._camera = e,
  96692. this._postProcessManager = new Vi(e.getScene()),
  96693. this._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add((function() {
  96694. t._postProcessManager._rebuild()
  96695. }
  96696. ))
  96697. }
  96698. return Object.defineProperty(e.prototype, "sourceTexture", {
  96699. get: function() {
  96700. return this._sourceTexture
  96701. },
  96702. enumerable: !1,
  96703. configurable: !0
  96704. }),
  96705. e.prototype.setSourceTexture = function(e, t, i, n) {
  96706. var r = this;
  96707. if (void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
  96708. void 0 === n && (n = !0),
  96709. e !== this._sourceTexture) {
  96710. this.dispose(!1),
  96711. this._sourceTexture = e,
  96712. this._reductionSteps = [],
  96713. this._forceFullscreenViewport = n;
  96714. var o = this._camera.getScene()
  96715. , s = new Ba("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define INITIAL" + (t ? "\n#define DEPTH_REDUX" : ""),i,void 0,void 0,void 0,a.TEXTUREFORMAT_RG);
  96716. s.autoClear = !1,
  96717. s.forceFullscreenViewport = n;
  96718. var l = this._sourceTexture.getRenderWidth()
  96719. , c = this._sourceTexture.getRenderHeight();
  96720. s.onApply = function(e, t) {
  96721. return function(i) {
  96722. i.setTexture("sourceTexture", r._sourceTexture),
  96723. i.setFloat2("texSize", e, t)
  96724. }
  96725. }(l, c),
  96726. this._reductionSteps.push(s);
  96727. for (var u = 1; l > 1 || c > 1; ) {
  96728. l = Math.max(Math.round(l / 2), 1),
  96729. c = Math.max(Math.round(c / 2), 1);
  96730. var h = new Ba("Reduction phase " + u,"minmaxRedux",["texSize"],null,{
  96731. width: l,
  96732. height: c
  96733. },null,a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define " + (1 == l && 1 == c ? "LAST" : 1 == l || 1 == c ? "ONEBEFORELAST" : "MAIN"),i,void 0,void 0,void 0,a.TEXTUREFORMAT_RG);
  96734. h.autoClear = !1,
  96735. h.forceFullscreenViewport = n,
  96736. h.onApply = function(e, t) {
  96737. return function(i) {
  96738. 1 == e || 1 == t ? i.setInt2("texSize", e, t) : i.setFloat2("texSize", e, t)
  96739. }
  96740. }(l, c),
  96741. this._reductionSteps.push(h),
  96742. u++,
  96743. 1 == l && 1 == c && h.onAfterRenderObservable.add(function(e, t, i) {
  96744. var n = new Float32Array(4 * e * t)
  96745. , a = {
  96746. min: 0,
  96747. max: 0
  96748. };
  96749. return function() {
  96750. o.getEngine()._readTexturePixels(i.inputTexture.texture, e, t, -1, 0, n, !1),
  96751. a.min = n[0],
  96752. a.max = n[1],
  96753. r.onAfterReductionPerformed.notifyObservers(a)
  96754. }
  96755. }(l, c, h))
  96756. }
  96757. }
  96758. }
  96759. ,
  96760. Object.defineProperty(e.prototype, "refreshRate", {
  96761. get: function() {
  96762. return this._sourceTexture ? this._sourceTexture.refreshRate : -1
  96763. },
  96764. set: function(e) {
  96765. this._sourceTexture && (this._sourceTexture.refreshRate = e)
  96766. },
  96767. enumerable: !1,
  96768. configurable: !0
  96769. }),
  96770. Object.defineProperty(e.prototype, "activated", {
  96771. get: function() {
  96772. return this._activated
  96773. },
  96774. enumerable: !1,
  96775. configurable: !0
  96776. }),
  96777. e.prototype.activate = function() {
  96778. var e = this;
  96779. !this._onAfterUnbindObserver && this._sourceTexture && (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add((function() {
  96780. var t, i, n = e._camera.getScene().getEngine();
  96781. null === (t = n._debugPushGroup) || void 0 === t || t.call(n, "min max reduction", 1),
  96782. e._reductionSteps[0].activate(e._camera),
  96783. e._postProcessManager.directRender(e._reductionSteps, e._reductionSteps[0].inputTexture, e._forceFullscreenViewport),
  96784. n.unBindFramebuffer(e._reductionSteps[0].inputTexture, !1),
  96785. null === (i = n._debugPopGroup) || void 0 === i || i.call(n, 1)
  96786. }
  96787. )),
  96788. this._activated = !0)
  96789. }
  96790. ,
  96791. e.prototype.deactivate = function() {
  96792. this._onAfterUnbindObserver && this._sourceTexture && (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
  96793. this._onAfterUnbindObserver = null,
  96794. this._activated = !1)
  96795. }
  96796. ,
  96797. e.prototype.dispose = function(e) {
  96798. if (void 0 === e && (e = !0),
  96799. e && (this.onAfterReductionPerformed.clear(),
  96800. this._onContextRestoredObserver && (this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  96801. this._onContextRestoredObserver = null)),
  96802. this.deactivate(),
  96803. this._reductionSteps) {
  96804. for (var t = 0; t < this._reductionSteps.length; ++t)
  96805. this._reductionSteps[t].dispose();
  96806. this._reductionSteps = null
  96807. }
  96808. this._postProcessManager && e && this._postProcessManager.dispose(),
  96809. this._sourceTexture = null
  96810. }
  96811. ,
  96812. e
  96813. }()
  96814. , s_ = function(e) {
  96815. function t(t) {
  96816. return e.call(this, t) || this
  96817. }
  96818. return U(t, e),
  96819. Object.defineProperty(t.prototype, "depthRenderer", {
  96820. get: function() {
  96821. return this._depthRenderer
  96822. },
  96823. enumerable: !1,
  96824. configurable: !0
  96825. }),
  96826. t.prototype.setDepthRenderer = function(t, i, n) {
  96827. void 0 === t && (t = null),
  96828. void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
  96829. void 0 === n && (n = !0);
  96830. var r = this._camera.getScene();
  96831. this._depthRenderer && (delete r._depthRenderer[this._depthRendererId],
  96832. this._depthRenderer.dispose(),
  96833. this._depthRenderer = null),
  96834. null === t && (r._depthRenderer || (r._depthRenderer = {}),
  96835. (t = this._depthRenderer = new o_(r,i,this._camera,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)).enabled = !1,
  96836. this._depthRendererId = "minmax" + this._camera.id,
  96837. r._depthRenderer[this._depthRendererId] = t),
  96838. e.prototype.setSourceTexture.call(this, t.getDepthMap(), !0, i, n)
  96839. }
  96840. ,
  96841. t.prototype.setSourceTexture = function(t, i, n, r) {
  96842. void 0 === n && (n = a.TEXTURETYPE_HALF_FLOAT),
  96843. void 0 === r && (r = !0),
  96844. e.prototype.setSourceTexture.call(this, t, i, n, r)
  96845. }
  96846. ,
  96847. t.prototype.activate = function() {
  96848. this._depthRenderer && (this._depthRenderer.enabled = !0),
  96849. e.prototype.activate.call(this)
  96850. }
  96851. ,
  96852. t.prototype.deactivate = function() {
  96853. e.prototype.deactivate.call(this),
  96854. this._depthRenderer && (this._depthRenderer.enabled = !1)
  96855. }
  96856. ,
  96857. t.prototype.dispose = function(t) {
  96858. if (void 0 === t && (t = !0),
  96859. e.prototype.dispose.call(this, t),
  96860. this._depthRenderer && t) {
  96861. var i = this._depthRenderer.getDepthMap().getScene();
  96862. i && delete i._depthRenderer[this._depthRendererId],
  96863. this._depthRenderer.dispose(),
  96864. this._depthRenderer = null
  96865. }
  96866. }
  96867. ,
  96868. t
  96869. }(a_)
  96870. , l_ = x.Up()
  96871. , c_ = x.Zero()
  96872. , u_ = new x
  96873. , h_ = new x
  96874. , d_ = new P
  96875. , p_ = function(e) {
  96876. function t(i, n, r) {
  96877. var o = this;
  96878. return t.IsSupported ? ((o = e.call(this, i, n, r) || this).usePercentageCloserFiltering = !0,
  96879. o) : (K.Error("CascadedShadowMap is not supported by the current engine."),
  96880. o)
  96881. }
  96882. return U(t, e),
  96883. t.prototype._validateFilter = function(e) {
  96884. return e === r_.FILTER_NONE || e === r_.FILTER_PCF || e === r_.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'),
  96885. r_.FILTER_NONE)
  96886. }
  96887. ,
  96888. Object.defineProperty(t.prototype, "numCascades", {
  96889. get: function() {
  96890. return this._numCascades
  96891. },
  96892. set: function(e) {
  96893. (e = Math.min(Math.max(e, t.MIN_CASCADES_COUNT), t.MAX_CASCADES_COUNT)) !== this._numCascades && (this._numCascades = e,
  96894. this.recreateShadowMap(),
  96895. this._recreateSceneUBOs())
  96896. },
  96897. enumerable: !1,
  96898. configurable: !0
  96899. }),
  96900. Object.defineProperty(t.prototype, "freezeShadowCastersBoundingInfo", {
  96901. get: function() {
  96902. return this._freezeShadowCastersBoundingInfo
  96903. },
  96904. set: function(e) {
  96905. this._freezeShadowCastersBoundingInfoObservable && e && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
  96906. this._freezeShadowCastersBoundingInfoObservable = null),
  96907. this._freezeShadowCastersBoundingInfoObservable || e || (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),
  96908. this._freezeShadowCastersBoundingInfo = e,
  96909. e && this._computeShadowCastersBoundingInfo()
  96910. },
  96911. enumerable: !1,
  96912. configurable: !0
  96913. }),
  96914. t.prototype._computeShadowCastersBoundingInfo = function() {
  96915. if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
  96916. this._scbiMax.copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
  96917. this._shadowMap && this._shadowMap.renderList) {
  96918. for (var e = this._shadowMap.renderList, t = 0; t < e.length; t++)
  96919. if (r = e[t]) {
  96920. var i = r.getBoundingInfo().boundingBox;
  96921. this._scbiMin.minimizeInPlace(i.minimumWorld),
  96922. this._scbiMax.maximizeInPlace(i.maximumWorld)
  96923. }
  96924. var n = this._scene.meshes;
  96925. for (t = 0; t < n.length; t++) {
  96926. var r;
  96927. (r = n[t]) && r.isVisible && r.isEnabled && r.receiveShadows && (i = r.getBoundingInfo().boundingBox,
  96928. this._scbiMin.minimizeInPlace(i.minimumWorld),
  96929. this._scbiMax.maximizeInPlace(i.maximumWorld))
  96930. }
  96931. }
  96932. this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax)
  96933. }
  96934. ,
  96935. Object.defineProperty(t.prototype, "shadowCastersBoundingInfo", {
  96936. get: function() {
  96937. return this._shadowCastersBoundingInfo
  96938. },
  96939. set: function(e) {
  96940. this._shadowCastersBoundingInfo = e
  96941. },
  96942. enumerable: !1,
  96943. configurable: !0
  96944. }),
  96945. t.prototype.setMinMaxDistance = function(e, t) {
  96946. this._minDistance === e && this._maxDistance === t || (e > t && (e = 0,
  96947. t = 1),
  96948. e < 0 && (e = 0),
  96949. t > 1 && (t = 1),
  96950. this._minDistance = e,
  96951. this._maxDistance = t,
  96952. this._breaksAreDirty = !0)
  96953. }
  96954. ,
  96955. Object.defineProperty(t.prototype, "minDistance", {
  96956. get: function() {
  96957. return this._minDistance
  96958. },
  96959. enumerable: !1,
  96960. configurable: !0
  96961. }),
  96962. Object.defineProperty(t.prototype, "maxDistance", {
  96963. get: function() {
  96964. return this._maxDistance
  96965. },
  96966. enumerable: !1,
  96967. configurable: !0
  96968. }),
  96969. t.prototype.getClassName = function() {
  96970. return t.CLASSNAME
  96971. }
  96972. ,
  96973. t.prototype.getCascadeMinExtents = function(e) {
  96974. return e >= 0 && e < this._numCascades ? this._cascadeMinExtents[e] : null
  96975. }
  96976. ,
  96977. t.prototype.getCascadeMaxExtents = function(e) {
  96978. return e >= 0 && e < this._numCascades ? this._cascadeMaxExtents[e] : null
  96979. }
  96980. ,
  96981. Object.defineProperty(t.prototype, "shadowMaxZ", {
  96982. get: function() {
  96983. return this._scene && this._scene.activeCamera ? this._shadowMaxZ : 0
  96984. },
  96985. set: function(e) {
  96986. this._scene && this._scene.activeCamera ? this._shadowMaxZ === e || e < this._scene.activeCamera.minZ || e > this._scene.activeCamera.maxZ || (this._shadowMaxZ = e,
  96987. this._light._markMeshesAsLightDirty(),
  96988. this._breaksAreDirty = !0) : this._shadowMaxZ = e
  96989. },
  96990. enumerable: !1,
  96991. configurable: !0
  96992. }),
  96993. Object.defineProperty(t.prototype, "debug", {
  96994. get: function() {
  96995. return this._debug
  96996. },
  96997. set: function(e) {
  96998. this._debug = e,
  96999. this._light._markMeshesAsLightDirty()
  97000. },
  97001. enumerable: !1,
  97002. configurable: !0
  97003. }),
  97004. Object.defineProperty(t.prototype, "depthClamp", {
  97005. get: function() {
  97006. return this._depthClamp
  97007. },
  97008. set: function(e) {
  97009. this._depthClamp = e
  97010. },
  97011. enumerable: !1,
  97012. configurable: !0
  97013. }),
  97014. Object.defineProperty(t.prototype, "cascadeBlendPercentage", {
  97015. get: function() {
  97016. return this._cascadeBlendPercentage
  97017. },
  97018. set: function(e) {
  97019. this._cascadeBlendPercentage = e,
  97020. this._light._markMeshesAsLightDirty()
  97021. },
  97022. enumerable: !1,
  97023. configurable: !0
  97024. }),
  97025. Object.defineProperty(t.prototype, "lambda", {
  97026. get: function() {
  97027. return this._lambda
  97028. },
  97029. set: function(e) {
  97030. var t = Math.min(Math.max(e, 0), 1);
  97031. this._lambda != t && (this._lambda = t,
  97032. this._breaksAreDirty = !0)
  97033. },
  97034. enumerable: !1,
  97035. configurable: !0
  97036. }),
  97037. t.prototype.getCascadeViewMatrix = function(e) {
  97038. return e >= 0 && e < this._numCascades ? this._viewMatrices[e] : null
  97039. }
  97040. ,
  97041. t.prototype.getCascadeProjectionMatrix = function(e) {
  97042. return e >= 0 && e < this._numCascades ? this._projectionMatrices[e] : null
  97043. }
  97044. ,
  97045. t.prototype.getCascadeTransformMatrix = function(e) {
  97046. return e >= 0 && e < this._numCascades ? this._transformMatrices[e] : null
  97047. }
  97048. ,
  97049. t.prototype.setDepthRenderer = function(e) {
  97050. this._depthRenderer = e,
  97051. this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer)
  97052. }
  97053. ,
  97054. Object.defineProperty(t.prototype, "autoCalcDepthBounds", {
  97055. get: function() {
  97056. return this._autoCalcDepthBounds
  97057. },
  97058. set: function(e) {
  97059. var t = this
  97060. , i = this._scene.activeCamera;
  97061. if (i) {
  97062. if (this._autoCalcDepthBounds = e,
  97063. !e)
  97064. return this._depthReducer && this._depthReducer.deactivate(),
  97065. void this.setMinMaxDistance(0, 1);
  97066. this._depthReducer || (this._depthReducer = new s_(i),
  97067. this._depthReducer.onAfterReductionPerformed.add((function(e) {
  97068. var i = e.min
  97069. , n = e.max;
  97070. i >= n && (i = 0,
  97071. n = 1),
  97072. i == t._minDistance && n == t._maxDistance || t.setMinMaxDistance(i, n)
  97073. }
  97074. )),
  97075. this._depthReducer.setDepthRenderer(this._depthRenderer)),
  97076. this._depthReducer.activate()
  97077. }
  97078. },
  97079. enumerable: !1,
  97080. configurable: !0
  97081. }),
  97082. Object.defineProperty(t.prototype, "autoCalcDepthBoundsRefreshRate", {
  97083. get: function() {
  97084. var e, t, i;
  97085. return null !== (i = null === (t = null === (e = this._depthReducer) || void 0 === e ? void 0 : e.depthRenderer) || void 0 === t ? void 0 : t.getDepthMap().refreshRate) && void 0 !== i ? i : -1
  97086. },
  97087. set: function(e) {
  97088. var t;
  97089. (null === (t = this._depthReducer) || void 0 === t ? void 0 : t.depthRenderer) && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = e)
  97090. },
  97091. enumerable: !1,
  97092. configurable: !0
  97093. }),
  97094. t.prototype.splitFrustum = function() {
  97095. this._breaksAreDirty = !0
  97096. }
  97097. ,
  97098. t.prototype._splitFrustum = function() {
  97099. var e = this._scene.activeCamera;
  97100. if (e) {
  97101. for (var t = e.minZ, i = e.maxZ, n = i - t, r = this._minDistance, o = t + r * n, a = t + (this._shadowMaxZ < i && this._shadowMaxZ >= t ? Math.min((this._shadowMaxZ - t) / (i - t), this._maxDistance) : this._maxDistance) * n, s = a - o, l = a / o, c = 0; c < this._cascades.length; ++c) {
  97102. var u = (c + 1) / this._numCascades
  97103. , h = o * Math.pow(l, u)
  97104. , d = o + s * u
  97105. , p = this._lambda * (h - d) + d;
  97106. this._cascades[c].prevBreakDistance = 0 === c ? r : this._cascades[c - 1].breakDistance,
  97107. this._cascades[c].breakDistance = (p - t) / n,
  97108. this._viewSpaceFrustumsZ[c] = p,
  97109. this._frustumLengths[c] = (this._cascades[c].breakDistance - this._cascades[c].prevBreakDistance) * n
  97110. }
  97111. this._breaksAreDirty = !1
  97112. }
  97113. }
  97114. ,
  97115. t.prototype._computeMatrices = function() {
  97116. var e = this._scene;
  97117. if (e.activeCamera) {
  97118. x.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection),
  97119. 1 === Math.abs(x.Dot(this._lightDirection, x.Up())) && (this._lightDirection.z = 1e-13),
  97120. this._cachedDirection.copyFrom(this._lightDirection);
  97121. for (var t = e.getEngine().useReverseDepthBuffer, i = 0; i < this._numCascades; ++i) {
  97122. this._computeFrustumInWorldSpace(i),
  97123. this._computeCascadeFrustum(i),
  97124. this._cascadeMaxExtents[i].subtractToRef(this._cascadeMinExtents[i], u_),
  97125. this._frustumCenter[i].addToRef(this._lightDirection.scale(this._cascadeMinExtents[i].z), this._shadowCameraPos[i]),
  97126. P.LookAtLHToRef(this._shadowCameraPos[i], this._frustumCenter[i], l_, this._viewMatrices[i]);
  97127. var n = 0
  97128. , r = u_.z
  97129. , o = this._shadowCastersBoundingInfo;
  97130. o.update(this._viewMatrices[i]),
  97131. r = Math.min(r, o.boundingBox.maximumWorld.z),
  97132. n = this._depthClamp && this.filter !== r_.FILTER_PCSS ? Math.max(n, o.boundingBox.minimumWorld.z) : Math.min(n, o.boundingBox.minimumWorld.z),
  97133. P.OrthoOffCenterLHToRef(this._cascadeMinExtents[i].x, this._cascadeMaxExtents[i].x, this._cascadeMinExtents[i].y, this._cascadeMaxExtents[i].y, t ? r : n, t ? n : r, this._projectionMatrices[i], e.getEngine().isNDCHalfZRange),
  97134. this._cascadeMinExtents[i].z = n,
  97135. this._cascadeMaxExtents[i].z = r,
  97136. this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]),
  97137. x.TransformCoordinatesToRef(c_, this._transformMatrices[i], u_),
  97138. u_.scaleInPlace(this._mapSize / 2),
  97139. h_.copyFromFloats(Math.round(u_.x), Math.round(u_.y), Math.round(u_.z)),
  97140. h_.subtractInPlace(u_).scaleInPlace(2 / this._mapSize),
  97141. P.TranslationToRef(h_.x, h_.y, 0, d_),
  97142. this._projectionMatrices[i].multiplyToRef(d_, this._projectionMatrices[i]),
  97143. this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]),
  97144. this._transformMatrices[i].copyToArray(this._transformMatricesAsArray, 16 * i)
  97145. }
  97146. }
  97147. }
  97148. ,
  97149. t.prototype._computeFrustumInWorldSpace = function(e) {
  97150. if (this._scene.activeCamera) {
  97151. var i = this._cascades[e].prevBreakDistance
  97152. , n = this._cascades[e].breakDistance
  97153. , r = this._scene.getEngine().isNDCHalfZRange;
  97154. this._scene.activeCamera.getViewMatrix();
  97155. for (var o = P.Invert(this._scene.activeCamera.getTransformationMatrix()), a = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, s = 0; s < t._FrustumCornersNDCSpace.length; ++s)
  97156. u_.copyFrom(t._FrustumCornersNDCSpace[(s + a) % t._FrustumCornersNDCSpace.length]),
  97157. r && -1 === u_.z && (u_.z = 0),
  97158. x.TransformCoordinatesToRef(u_, o, this._frustumCornersWorldSpace[e][s]);
  97159. for (s = 0; s < t._FrustumCornersNDCSpace.length / 2; ++s)
  97160. u_.copyFrom(this._frustumCornersWorldSpace[e][s + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][s]),
  97161. h_.copyFrom(u_).scaleInPlace(i),
  97162. u_.scaleInPlace(n),
  97163. u_.addInPlace(this._frustumCornersWorldSpace[e][s]),
  97164. this._frustumCornersWorldSpace[e][s + 4].copyFrom(u_),
  97165. this._frustumCornersWorldSpace[e][s].addInPlace(h_)
  97166. }
  97167. }
  97168. ,
  97169. t.prototype._computeCascadeFrustum = function(e) {
  97170. if (this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
  97171. this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
  97172. this._frustumCenter[e].copyFromFloats(0, 0, 0),
  97173. this._scene.activeCamera) {
  97174. for (var t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)
  97175. this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][t]);
  97176. if (this._frustumCenter[e].scaleInPlace(1 / this._frustumCornersWorldSpace[e].length),
  97177. this.stabilizeCascades) {
  97178. var i = 0;
  97179. for (t = 0; t < this._frustumCornersWorldSpace[e].length; ++t) {
  97180. var n = this._frustumCornersWorldSpace[e][t].subtractToRef(this._frustumCenter[e], u_).length();
  97181. i = Math.max(i, n)
  97182. }
  97183. i = Math.ceil(16 * i) / 16,
  97184. this._cascadeMaxExtents[e].copyFromFloats(i, i, i),
  97185. this._cascadeMinExtents[e].copyFromFloats(-i, -i, -i)
  97186. } else {
  97187. var r = this._frustumCenter[e];
  97188. for (this._frustumCenter[e].addToRef(this._lightDirection, u_),
  97189. P.LookAtLHToRef(r, u_, l_, d_),
  97190. t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)
  97191. x.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][t], d_, u_),
  97192. this._cascadeMinExtents[e].minimizeInPlace(u_),
  97193. this._cascadeMaxExtents[e].maximizeInPlace(u_)
  97194. }
  97195. }
  97196. }
  97197. ,
  97198. t.prototype._recreateSceneUBOs = function() {
  97199. if (this._disposeSceneUBOs(),
  97200. this._sceneUBOs)
  97201. for (var e = 0; e < this._numCascades; ++e)
  97202. this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "'.concat(this._light.name, '" cascade #').concat(e, ")")))
  97203. }
  97204. ,
  97205. Object.defineProperty(t, "IsSupported", {
  97206. get: function() {
  97207. var e = E.LastCreatedEngine;
  97208. return !!e && e._features.supportCSM
  97209. },
  97210. enumerable: !1,
  97211. configurable: !0
  97212. }),
  97213. t.prototype._initializeGenerator = function() {
  97214. var i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T;
  97215. this.penumbraDarkness = null !== (i = this.penumbraDarkness) && void 0 !== i ? i : 1,
  97216. this._numCascades = null !== (n = this._numCascades) && void 0 !== n ? n : t.DEFAULT_CASCADES_COUNT,
  97217. this.stabilizeCascades = null !== (r = this.stabilizeCascades) && void 0 !== r && r,
  97218. this._freezeShadowCastersBoundingInfoObservable = null !== (o = this._freezeShadowCastersBoundingInfoObservable) && void 0 !== o ? o : null,
  97219. this.freezeShadowCastersBoundingInfo = null !== (a = this.freezeShadowCastersBoundingInfo) && void 0 !== a && a,
  97220. this._scbiMin = null !== (s = this._scbiMin) && void 0 !== s ? s : new x(0,0,0),
  97221. this._scbiMax = null !== (l = this._scbiMax) && void 0 !== l ? l : new x(0,0,0),
  97222. this._shadowCastersBoundingInfo = null !== (c = this._shadowCastersBoundingInfo) && void 0 !== c ? c : new sr(new x(0,0,0),new x(0,0,0)),
  97223. this._breaksAreDirty = null === (u = this._breaksAreDirty) || void 0 === u || u,
  97224. this._minDistance = null !== (h = this._minDistance) && void 0 !== h ? h : 0,
  97225. this._maxDistance = null !== (d = this._maxDistance) && void 0 !== d ? d : 1,
  97226. this._currentLayer = null !== (p = this._currentLayer) && void 0 !== p ? p : 0,
  97227. this._shadowMaxZ = null !== (m = null !== (f = this._shadowMaxZ) && void 0 !== f ? f : null === (_ = this._scene.activeCamera) || void 0 === _ ? void 0 : _.maxZ) && void 0 !== m ? m : 1e4,
  97228. this._debug = null !== (g = this._debug) && void 0 !== g && g,
  97229. this._depthClamp = null === (v = this._depthClamp) || void 0 === v || v,
  97230. this._cascadeBlendPercentage = null !== (y = this._cascadeBlendPercentage) && void 0 !== y ? y : .1,
  97231. this._lambda = null !== (b = this._lambda) && void 0 !== b ? b : .5,
  97232. this._autoCalcDepthBounds = null !== (T = this._autoCalcDepthBounds) && void 0 !== T && T,
  97233. this._recreateSceneUBOs(),
  97234. e.prototype._initializeGenerator.call(this)
  97235. }
  97236. ,
  97237. t.prototype._createTargetRenderTexture = function() {
  97238. var e = this._scene.getEngine()
  97239. , t = {
  97240. width: this._mapSize,
  97241. height: this._mapSize,
  97242. layers: this.numCascades
  97243. };
  97244. this._shadowMap = new ns(this._light.name + "_CSMShadowMap",t,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),
  97245. this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)
  97246. }
  97247. ,
  97248. t.prototype._initializeShadowMap = function() {
  97249. var i = this;
  97250. if (e.prototype._initializeShadowMap.call(this),
  97251. null !== this._shadowMap) {
  97252. this._transformMatricesAsArray = new Float32Array(16 * this._numCascades),
  97253. this._viewSpaceFrustumsZ = new Array(this._numCascades),
  97254. this._frustumLengths = new Array(this._numCascades),
  97255. this._lightSizeUVCorrection = new Array(2 * this._numCascades),
  97256. this._depthCorrection = new Array(this._numCascades),
  97257. this._cascades = [],
  97258. this._viewMatrices = [],
  97259. this._projectionMatrices = [],
  97260. this._transformMatrices = [],
  97261. this._cascadeMinExtents = [],
  97262. this._cascadeMaxExtents = [],
  97263. this._frustumCenter = [],
  97264. this._shadowCameraPos = [],
  97265. this._frustumCornersWorldSpace = [];
  97266. for (var n = 0; n < this._numCascades; ++n) {
  97267. this._cascades[n] = {
  97268. prevBreakDistance: 0,
  97269. breakDistance: 0
  97270. },
  97271. this._viewMatrices[n] = P.Zero(),
  97272. this._projectionMatrices[n] = P.Zero(),
  97273. this._transformMatrices[n] = P.Zero(),
  97274. this._cascadeMinExtents[n] = new x,
  97275. this._cascadeMaxExtents[n] = new x,
  97276. this._frustumCenter[n] = new x,
  97277. this._shadowCameraPos[n] = new x,
  97278. this._frustumCornersWorldSpace[n] = new Array(t._FrustumCornersNDCSpace.length);
  97279. for (var r = 0; r < t._FrustumCornersNDCSpace.length; ++r)
  97280. this._frustumCornersWorldSpace[n][r] = new x
  97281. }
  97282. var o = this._scene.getEngine();
  97283. this._shadowMap.onBeforeBindObservable.clear(),
  97284. this._shadowMap.onBeforeRenderObservable.clear(),
  97285. this._shadowMap.onBeforeRenderObservable.add((function(e) {
  97286. i._sceneUBOs && i._scene.setSceneUniformBuffer(i._sceneUBOs[e]),
  97287. i._currentLayer = e,
  97288. i._filter === r_.FILTER_PCF && o.setColorWrite(!1),
  97289. i._scene.setTransformMatrix(i.getCascadeViewMatrix(e), i.getCascadeProjectionMatrix(e)),
  97290. i._useUBO && (i._scene.getSceneUniformBuffer().unbindEffect(),
  97291. i._scene.finalizeSceneUbo())
  97292. }
  97293. )),
  97294. this._shadowMap.onBeforeBindObservable.add((function() {
  97295. var e;
  97296. i._currentSceneUBO = i._scene.getSceneUniformBuffer(),
  97297. null === (e = o._debugPushGroup) || void 0 === e || e.call(o, "cascaded shadow map generation for pass id ".concat(o.currentRenderPassId), 1),
  97298. i._breaksAreDirty && i._splitFrustum(),
  97299. i._computeMatrices()
  97300. }
  97301. )),
  97302. this._splitFrustum()
  97303. }
  97304. }
  97305. ,
  97306. t.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t) {
  97307. t.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer))
  97308. }
  97309. ,
  97310. t.prototype._isReadyCustomDefines = function(e) {
  97311. e.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== r_.FILTER_PCSS ? "1" : "0"))
  97312. }
  97313. ,
  97314. t.prototype.prepareDefines = function(t, i) {
  97315. e.prototype.prepareDefines.call(this, t, i);
  97316. var n = this._scene
  97317. , r = this._light;
  97318. if (n.shadowsEnabled && r.shadowEnabled) {
  97319. t["SHADOWCSM" + i] = !0,
  97320. t["SHADOWCSMDEBUG" + i] = this.debug,
  97321. t["SHADOWCSMNUM_CASCADES" + i] = this.numCascades,
  97322. t["SHADOWCSM_RIGHTHANDED" + i] = n.useRightHandedSystem;
  97323. var o = n.activeCamera;
  97324. o && this._shadowMaxZ < o.maxZ && (t["SHADOWCSMUSESHADOWMAXZ" + i] = !0),
  97325. 0 === this.cascadeBlendPercentage && (t["SHADOWCSMNOBLEND" + i] = !0)
  97326. }
  97327. }
  97328. ,
  97329. t.prototype.bindShadowLight = function(e, t) {
  97330. var i = this._light
  97331. , n = this._scene;
  97332. if (n.shadowsEnabled && i.shadowEnabled) {
  97333. var r = n.activeCamera;
  97334. if (r) {
  97335. var o = this.getShadowMap();
  97336. if (o) {
  97337. var a = o.getSize().width;
  97338. if (t.setMatrices("lightMatrix" + e, this._transformMatricesAsArray),
  97339. t.setArray("viewFrustumZ" + e, this._viewSpaceFrustumsZ),
  97340. t.setFloat("cascadeBlendFactor" + e, 0 === this.cascadeBlendPercentage ? 1e4 : 1 / this.cascadeBlendPercentage),
  97341. t.setArray("frustumLengths" + e, this._frustumLengths),
  97342. this._filter === r_.FILTER_PCF)
  97343. t.setDepthStencilTexture("shadowSampler" + e, o),
  97344. i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, this.frustumEdgeFalloff, e);
  97345. else if (this._filter === r_.FILTER_PCSS) {
  97346. for (var s = 0; s < this._numCascades; ++s)
  97347. this._lightSizeUVCorrection[2 * s + 0] = 0 === s ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[s].x - this._cascadeMinExtents[s].x),
  97348. this._lightSizeUVCorrection[2 * s + 1] = 0 === s ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[s].y - this._cascadeMinExtents[s].y),
  97349. this._depthCorrection[s] = 0 === s ? 1 : (this._cascadeMaxExtents[s].z - this._cascadeMinExtents[s].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
  97350. t.setDepthStencilTexture("shadowSampler" + e, o),
  97351. t.setTexture("depthSampler" + e, o),
  97352. t.setArray2("lightSizeUVCorrection" + e, this._lightSizeUVCorrection),
  97353. t.setArray("depthCorrection" + e, this._depthCorrection),
  97354. t.setFloat("penumbraDarkness" + e, this.penumbraDarkness),
  97355. i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a, this._contactHardeningLightSizeUVRatio * a, this.frustumEdgeFalloff, e)
  97356. } else
  97357. t.setTexture("shadowSampler" + e, o),
  97358. i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, this.frustumEdgeFalloff, e);
  97359. i._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(r), this.getLight().getDepthMinZ(r) + this.getLight().getDepthMaxZ(r), e)
  97360. }
  97361. }
  97362. }
  97363. }
  97364. ,
  97365. t.prototype.getTransformMatrix = function() {
  97366. return this.getCascadeTransformMatrix(0)
  97367. }
  97368. ,
  97369. t.prototype.dispose = function() {
  97370. e.prototype.dispose.call(this),
  97371. this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
  97372. this._freezeShadowCastersBoundingInfoObservable = null),
  97373. this._depthReducer && (this._depthReducer.dispose(),
  97374. this._depthReducer = null)
  97375. }
  97376. ,
  97377. t.prototype.serialize = function() {
  97378. var t = e.prototype.serialize.call(this)
  97379. , i = this.getShadowMap();
  97380. if (!i)
  97381. return t;
  97382. if (t.numCascades = this._numCascades,
  97383. t.debug = this._debug,
  97384. t.stabilizeCascades = this.stabilizeCascades,
  97385. t.lambda = this._lambda,
  97386. t.cascadeBlendPercentage = this.cascadeBlendPercentage,
  97387. t.depthClamp = this._depthClamp,
  97388. t.autoCalcDepthBounds = this.autoCalcDepthBounds,
  97389. t.shadowMaxZ = this._shadowMaxZ,
  97390. t.penumbraDarkness = this.penumbraDarkness,
  97391. t.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo,
  97392. t.minDistance = this.minDistance,
  97393. t.maxDistance = this.maxDistance,
  97394. t.renderList = [],
  97395. i.renderList)
  97396. for (var n = 0; n < i.renderList.length; n++) {
  97397. var r = i.renderList[n];
  97398. t.renderList.push(r.id)
  97399. }
  97400. return t
  97401. }
  97402. ,
  97403. t.Parse = function(e, i) {
  97404. var n = r_.Parse(e, i, (function(e, i) {
  97405. return new t(e,i)
  97406. }
  97407. ));
  97408. return void 0 !== e.numCascades && (n.numCascades = e.numCascades),
  97409. void 0 !== e.debug && (n.debug = e.debug),
  97410. void 0 !== e.stabilizeCascades && (n.stabilizeCascades = e.stabilizeCascades),
  97411. void 0 !== e.lambda && (n.lambda = e.lambda),
  97412. void 0 !== e.cascadeBlendPercentage && (n.cascadeBlendPercentage = e.cascadeBlendPercentage),
  97413. void 0 !== e.depthClamp && (n.depthClamp = e.depthClamp),
  97414. void 0 !== e.autoCalcDepthBounds && (n.autoCalcDepthBounds = e.autoCalcDepthBounds),
  97415. void 0 !== e.shadowMaxZ && (n.shadowMaxZ = e.shadowMaxZ),
  97416. void 0 !== e.penumbraDarkness && (n.penumbraDarkness = e.penumbraDarkness),
  97417. void 0 !== e.freezeShadowCastersBoundingInfo && (n.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo),
  97418. void 0 !== e.minDistance && void 0 !== e.maxDistance && n.setMinMaxDistance(e.minDistance, e.maxDistance),
  97419. n
  97420. }
  97421. ,
  97422. t._FrustumCornersNDCSpace = [new x(-1,1,-1), new x(1,1,-1), new x(1,-1,-1), new x(-1,-1,-1), new x(-1,1,1), new x(1,1,1), new x(1,-1,1), new x(-1,-1,1)],
  97423. t.CLASSNAME = "CascadedShadowGenerator",
  97424. t.DEFAULT_CASCADES_COUNT = 4,
  97425. t.MIN_CASCADES_COUNT = 2,
  97426. t.MAX_CASCADES_COUNT = 4,
  97427. t._SceneComponentInitialization = function(e) {
  97428. throw be("ShadowGeneratorSceneComponent")
  97429. }
  97430. ,
  97431. t
  97432. }(r_);
  97433. o.AddParser(Wi.NAME_SHADOWGENERATOR, (function(e, t) {
  97434. if (void 0 !== e.shadowGenerators && null !== e.shadowGenerators)
  97435. for (var i = 0, n = e.shadowGenerators.length; i < n; i++) {
  97436. var r = e.shadowGenerators[i];
  97437. r.className === p_.CLASSNAME ? p_.Parse(r, t) : r_.Parse(r, t)
  97438. }
  97439. }
  97440. ));
  97441. var f_ = function() {
  97442. function e(e) {
  97443. this.name = Wi.NAME_SHADOWGENERATOR,
  97444. this.scene = e
  97445. }
  97446. return e.prototype.register = function() {
  97447. this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets)
  97448. }
  97449. ,
  97450. e.prototype.rebuild = function() {}
  97451. ,
  97452. e.prototype.serialize = function(e) {
  97453. e.shadowGenerators = [];
  97454. for (var t = 0, i = this.scene.lights; t < i.length; t++) {
  97455. var n = i[t].getShadowGenerator();
  97456. n && e.shadowGenerators.push(n.serialize())
  97457. }
  97458. }
  97459. ,
  97460. e.prototype.addFromContainer = function(e) {}
  97461. ,
  97462. e.prototype.removeFromContainer = function(e, t) {}
  97463. ,
  97464. e.prototype.dispose = function() {}
  97465. ,
  97466. e.prototype._gatherRenderTargets = function(e) {
  97467. var t = this.scene;
  97468. if (this.scene.shadowsEnabled)
  97469. for (var i = 0; i < t.lights.length; i++) {
  97470. var n = t.lights[i]
  97471. , r = n.getShadowGenerator();
  97472. if (n.isEnabled() && n.shadowEnabled && r) {
  97473. var o = r.getShadowMap();
  97474. -1 !== t.textures.indexOf(o) && e.push(o)
  97475. }
  97476. }
  97477. }
  97478. ,
  97479. e
  97480. }();
  97481. r_._SceneComponentInitialization = function(e) {
  97482. var t = e._getComponent(Wi.NAME_SHADOWGENERATOR);
  97483. t || (t = new f_(e),
  97484. e._addComponent(t))
  97485. }
  97486. ,
  97487. Xe.AddNodeConstructor("Light_Type_0", (function(e, t) {
  97488. return function() {
  97489. return new __(e,x.Zero(),t)
  97490. }
  97491. }
  97492. ));
  97493. var __ = function(e) {
  97494. function t(t, i, n) {
  97495. var r = e.call(this, t, n) || this;
  97496. return r._shadowAngle = Math.PI / 2,
  97497. r.position = i,
  97498. r
  97499. }
  97500. return U(t, e),
  97501. Object.defineProperty(t.prototype, "shadowAngle", {
  97502. get: function() {
  97503. return this._shadowAngle
  97504. },
  97505. set: function(e) {
  97506. this._shadowAngle = e,
  97507. this.forceProjectionMatrixCompute()
  97508. },
  97509. enumerable: !1,
  97510. configurable: !0
  97511. }),
  97512. Object.defineProperty(t.prototype, "direction", {
  97513. get: function() {
  97514. return this._direction
  97515. },
  97516. set: function(e) {
  97517. var t = this.needCube();
  97518. this._direction = e,
  97519. this.needCube() !== t && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
  97520. },
  97521. enumerable: !1,
  97522. configurable: !0
  97523. }),
  97524. t.prototype.getClassName = function() {
  97525. return "PointLight"
  97526. }
  97527. ,
  97528. t.prototype.getTypeID = function() {
  97529. return Cr.LIGHTTYPEID_POINTLIGHT
  97530. }
  97531. ,
  97532. t.prototype.needCube = function() {
  97533. return !this.direction
  97534. }
  97535. ,
  97536. t.prototype.getShadowDirection = function(t) {
  97537. if (this.direction)
  97538. return e.prototype.getShadowDirection.call(this, t);
  97539. switch (t) {
  97540. case 0:
  97541. return new x(1,0,0);
  97542. case 1:
  97543. return new x(-1,0,0);
  97544. case 2:
  97545. return new x(0,-1,0);
  97546. case 3:
  97547. return new x(0,1,0);
  97548. case 4:
  97549. return new x(0,0,1);
  97550. case 5:
  97551. return new x(0,0,-1)
  97552. }
  97553. return x.Zero()
  97554. }
  97555. ,
  97556. t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
  97557. var n = this.getScene().activeCamera;
  97558. if (n) {
  97559. var r = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
  97560. , o = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
  97561. , a = this.getScene().getEngine().useReverseDepthBuffer;
  97562. P.PerspectiveFovLHToRef(this.shadowAngle, 1, a ? o : r, a ? r : o, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, a)
  97563. }
  97564. }
  97565. ,
  97566. t.prototype._buildUniformLayout = function() {
  97567. this._uniformBuffer.addUniform("vLightData", 4),
  97568. this._uniformBuffer.addUniform("vLightDiffuse", 4),
  97569. this._uniformBuffer.addUniform("vLightSpecular", 4),
  97570. this._uniformBuffer.addUniform("vLightFalloff", 4),
  97571. this._uniformBuffer.addUniform("shadowsInfo", 3),
  97572. this._uniformBuffer.addUniform("depthValues", 2),
  97573. this._uniformBuffer.create()
  97574. }
  97575. ,
  97576. t.prototype.transferToEffect = function(e, t) {
  97577. return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, t) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, t),
  97578. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, t),
  97579. this
  97580. }
  97581. ,
  97582. t.prototype.transferToNodeMaterialEffect = function(e, t) {
  97583. return this.computeTransformedInformation() ? e.setFloat3(t, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : e.setFloat3(t, this.position.x, this.position.y, this.position.z),
  97584. this
  97585. }
  97586. ,
  97587. t.prototype.prepareLightSpecificDefines = function(e, t) {
  97588. e["POINTLIGHT" + t] = !0
  97589. }
  97590. ,
  97591. k([Ce()], t.prototype, "shadowAngle", null),
  97592. t
  97593. }(xd)
  97594. , m_ = function() {
  97595. function e(e, t, i) {
  97596. void 0 === t && (t = ""),
  97597. void 0 === i && (i = "black");
  97598. var n = this;
  97599. this._renderingCanvas = e,
  97600. this._loadingText = t,
  97601. this._loadingDivBackgroundColor = i,
  97602. this._resizeLoadingUI = function() {
  97603. var e = n._renderingCanvas.getBoundingClientRect()
  97604. , t = window.getComputedStyle(n._renderingCanvas).position;
  97605. n._loadingDiv && (n._loadingDiv.style.position = "fixed" === t ? "fixed" : "absolute",
  97606. n._loadingDiv.style.left = e.left + "px",
  97607. n._loadingDiv.style.top = e.top + "px",
  97608. n._loadingDiv.style.width = e.width + "px",
  97609. n._loadingDiv.style.height = e.height + "px")
  97610. }
  97611. }
  97612. return e.prototype.displayLoadingUI = function() {
  97613. if (!this._loadingDiv) {
  97614. this._loadingDiv = document.createElement("div"),
  97615. this._loadingDiv.id = "babylonjsLoadingDiv",
  97616. this._loadingDiv.style.opacity = "0",
  97617. this._loadingDiv.style.transition = "opacity 1.5s ease",
  97618. this._loadingDiv.style.pointerEvents = "none",
  97619. this._loadingDiv.style.display = "grid",
  97620. this._loadingDiv.style.gridTemplateRows = "100%",
  97621. this._loadingDiv.style.gridTemplateColumns = "100%",
  97622. this._loadingDiv.style.justifyItems = "center",
  97623. this._loadingDiv.style.alignItems = "center",
  97624. this._loadingTextDiv = document.createElement("div"),
  97625. this._loadingTextDiv.style.position = "absolute",
  97626. this._loadingTextDiv.style.left = "0",
  97627. this._loadingTextDiv.style.top = "50%",
  97628. this._loadingTextDiv.style.marginTop = "80px",
  97629. this._loadingTextDiv.style.width = "100%",
  97630. this._loadingTextDiv.style.height = "20px",
  97631. this._loadingTextDiv.style.fontFamily = "Arial",
  97632. this._loadingTextDiv.style.fontSize = "14px",
  97633. this._loadingTextDiv.style.color = "white",
  97634. this._loadingTextDiv.style.textAlign = "center",
  97635. this._loadingTextDiv.style.zIndex = "1",
  97636. this._loadingTextDiv.innerHTML = "Loading",
  97637. this._loadingDiv.appendChild(this._loadingTextDiv),
  97638. this._loadingTextDiv.innerHTML = this._loadingText,
  97639. this._style = document.createElement("style"),
  97640. this._style.type = "text/css",
  97641. this._style.innerHTML = "@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",
  97642. document.getElementsByTagName("head")[0].appendChild(this._style);
  97643. var t = !!window.SVGSVGElement
  97644. , i = new Image;
  97645. e.DefaultLogoUrl ? i.src = e.DefaultLogoUrl : i.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png",
  97646. i.style.width = "150px",
  97647. i.style.gridColumn = "1",
  97648. i.style.gridRow = "1",
  97649. i.style.top = "50%",
  97650. i.style.left = "50%",
  97651. i.style.transform = "translate(-50%, -50%)",
  97652. i.style.position = "absolute";
  97653. var n = document.createElement("div");
  97654. n.style.width = "300px",
  97655. n.style.gridColumn = "1",
  97656. n.style.gridRow = "1",
  97657. n.style.top = "50%",
  97658. n.style.left = "50%",
  97659. n.style.transform = "translate(-50%, -50%)",
  97660. n.style.position = "absolute";
  97661. var r = new Image;
  97662. if (e.DefaultSpinnerUrl ? r.src = e.DefaultSpinnerUrl : r.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png",
  97663. r.style.animation = "spin1 0.75s infinite linear",
  97664. r.style.webkitAnimation = "spin1 0.75s infinite linear",
  97665. r.style.transformOrigin = "50% 50%",
  97666. r.style.webkitTransformOrigin = "50% 50%",
  97667. !t) {
  97668. var o = {
  97669. w: 16,
  97670. h: 18.5
  97671. }
  97672. , a = {
  97673. w: 30,
  97674. h: 30
  97675. };
  97676. i.style.width = "".concat(o.w, "vh"),
  97677. i.style.height = "".concat(o.h, "vh"),
  97678. i.style.left = "calc(50% - ".concat(o.w / 2, "vh)"),
  97679. i.style.top = "calc(50% - ".concat(o.h / 2, "vh)"),
  97680. r.style.width = "".concat(a.w, "vh"),
  97681. r.style.height = "".concat(a.h, "vh"),
  97682. r.style.left = "calc(50% - ".concat(a.w / 2, "vh)"),
  97683. r.style.top = "calc(50% - ".concat(a.h / 2, "vh)")
  97684. }
  97685. n.appendChild(r),
  97686. this._loadingDiv.appendChild(i),
  97687. this._loadingDiv.appendChild(n),
  97688. this._resizeLoadingUI(),
  97689. window.addEventListener("resize", this._resizeLoadingUI),
  97690. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor,
  97691. document.body.appendChild(this._loadingDiv),
  97692. this._loadingDiv.style.opacity = "1"
  97693. }
  97694. }
  97695. ,
  97696. e.prototype.hideLoadingUI = function() {
  97697. var e = this;
  97698. this._loadingDiv && (this._loadingDiv.style.opacity = "0",
  97699. this._loadingDiv.addEventListener("transitionend", (function() {
  97700. e._loadingDiv && (e._loadingDiv.parentElement && e._loadingDiv.parentElement.removeChild(e._loadingDiv),
  97701. e._loadingDiv = null),
  97702. e._style && (e._style.parentElement && e._style.parentElement.removeChild(e._style),
  97703. e._style = null),
  97704. window.removeEventListener("resize", e._resizeLoadingUI)
  97705. }
  97706. )))
  97707. }
  97708. ,
  97709. Object.defineProperty(e.prototype, "loadingUIText", {
  97710. get: function() {
  97711. return this._loadingText
  97712. },
  97713. set: function(e) {
  97714. this._loadingText = e,
  97715. this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText)
  97716. },
  97717. enumerable: !1,
  97718. configurable: !0
  97719. }),
  97720. Object.defineProperty(e.prototype, "loadingUIBackgroundColor", {
  97721. get: function() {
  97722. return this._loadingDivBackgroundColor
  97723. },
  97724. set: function(e) {
  97725. this._loadingDivBackgroundColor = e,
  97726. this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor)
  97727. },
  97728. enumerable: !1,
  97729. configurable: !0
  97730. }),
  97731. e.DefaultLogoUrl = "",
  97732. e.DefaultSpinnerUrl = "",
  97733. e
  97734. }();
  97735. vr.DefaultLoadingScreenFactory = function(e) {
  97736. return new m_(e)
  97737. }
  97738. ;
  97739. var g_ = function() {
  97740. function e() {}
  97741. return e.ConvertPanoramaToCubemap = function(e, t, i, n) {
  97742. if (!e)
  97743. throw "ConvertPanoramaToCubemap: input cannot be null";
  97744. if (e.length != t * i * 3)
  97745. throw "ConvertPanoramaToCubemap: input size is wrong";
  97746. return {
  97747. front: this.CreateCubemapTexture(n, this.FACE_FRONT, e, t, i),
  97748. back: this.CreateCubemapTexture(n, this.FACE_BACK, e, t, i),
  97749. left: this.CreateCubemapTexture(n, this.FACE_LEFT, e, t, i),
  97750. right: this.CreateCubemapTexture(n, this.FACE_RIGHT, e, t, i),
  97751. up: this.CreateCubemapTexture(n, this.FACE_UP, e, t, i),
  97752. down: this.CreateCubemapTexture(n, this.FACE_DOWN, e, t, i),
  97753. size: n,
  97754. type: a.TEXTURETYPE_FLOAT,
  97755. format: a.TEXTUREFORMAT_RGB,
  97756. gammaSpace: !1
  97757. }
  97758. }
  97759. ,
  97760. e.CreateCubemapTexture = function(e, t, i, n, r) {
  97761. for (var o = new ArrayBuffer(e * e * 4 * 3), a = new Float32Array(o), s = t[1].subtract(t[0]).scale(1 / e), l = t[3].subtract(t[2]).scale(1 / e), c = 1 / e, u = 0, h = 0; h < e; h++) {
  97762. for (var d = t[0], p = t[2], f = 0; f < e; f++) {
  97763. var _ = p.subtract(d).scale(u).add(d);
  97764. _.normalize();
  97765. var m = this.CalcProjectionSpherical(_, i, n, r);
  97766. a[h * e * 3 + 3 * f + 0] = m.r,
  97767. a[h * e * 3 + 3 * f + 1] = m.g,
  97768. a[h * e * 3 + 3 * f + 2] = m.b,
  97769. d = d.add(s),
  97770. p = p.add(l)
  97771. }
  97772. u += c
  97773. }
  97774. return a
  97775. }
  97776. ,
  97777. e.CalcProjectionSpherical = function(e, t, i, n) {
  97778. for (var r = Math.atan2(e.z, e.x), o = Math.acos(e.y); r < -Math.PI; )
  97779. r += 2 * Math.PI;
  97780. for (; r > Math.PI; )
  97781. r -= 2 * Math.PI;
  97782. var a = r / Math.PI
  97783. , s = o / Math.PI;
  97784. a = .5 * a + .5;
  97785. var l = Math.round(a * i);
  97786. l < 0 ? l = 0 : l >= i && (l = i - 1);
  97787. var c = Math.round(s * n);
  97788. c < 0 ? c = 0 : c >= n && (c = n - 1);
  97789. var u = n - c - 1;
  97790. return {
  97791. r: t[u * i * 3 + 3 * l + 0],
  97792. g: t[u * i * 3 + 3 * l + 1],
  97793. b: t[u * i * 3 + 3 * l + 2]
  97794. }
  97795. }
  97796. ,
  97797. e.FACE_LEFT = [new x(-1,-1,-1), new x(1,-1,-1), new x(-1,1,-1), new x(1,1,-1)],
  97798. e.FACE_RIGHT = [new x(1,-1,1), new x(-1,-1,1), new x(1,1,1), new x(-1,1,1)],
  97799. e.FACE_FRONT = [new x(1,-1,-1), new x(1,-1,1), new x(1,1,-1), new x(1,1,1)],
  97800. e.FACE_BACK = [new x(-1,-1,1), new x(-1,-1,-1), new x(-1,1,1), new x(-1,1,-1)],
  97801. e.FACE_DOWN = [new x(1,1,-1), new x(1,1,1), new x(-1,1,-1), new x(-1,1,1)],
  97802. e.FACE_UP = [new x(-1,-1,-1), new x(-1,-1,1), new x(1,-1,-1), new x(1,-1,1)],
  97803. e
  97804. }()
  97805. , v_ = function() {
  97806. function e() {}
  97807. return e._Ldexp = function(e, t) {
  97808. return t > 1023 ? e * Math.pow(2, 1023) * Math.pow(2, t - 1023) : t < -1074 ? e * Math.pow(2, -1074) * Math.pow(2, t + 1074) : e * Math.pow(2, t)
  97809. }
  97810. ,
  97811. e._Rgbe2float = function(e, t, i, n, r, o) {
  97812. r > 0 ? (r = this._Ldexp(1, r - 136),
  97813. e[o + 0] = t * r,
  97814. e[o + 1] = i * r,
  97815. e[o + 2] = n * r) : (e[o + 0] = 0,
  97816. e[o + 1] = 0,
  97817. e[o + 2] = 0)
  97818. }
  97819. ,
  97820. e._ReadStringLine = function(e, t) {
  97821. for (var i = "", n = "", r = t; r < e.length - t && "\n" != (n = String.fromCharCode(e[r])); r++)
  97822. i += n;
  97823. return i
  97824. }
  97825. ,
  97826. e.RGBE_ReadHeader = function(e) {
  97827. var t, i, n = this._ReadStringLine(e, 0);
  97828. if ("#" != n[0] || "?" != n[1])
  97829. throw "Bad HDR Format.";
  97830. var r = !1
  97831. , o = !1
  97832. , a = 0;
  97833. do {
  97834. a += n.length + 1,
  97835. "FORMAT=32-bit_rle_rgbe" == (n = this._ReadStringLine(e, a)) ? o = !0 : 0 == n.length && (r = !0)
  97836. } while (!r);
  97837. if (!o)
  97838. throw "HDR Bad header format, unsupported FORMAT";
  97839. a += n.length + 1,
  97840. n = this._ReadStringLine(e, a);
  97841. var s = /^-Y (.*) \+X (.*)$/g.exec(n);
  97842. if (!s || s.length < 3)
  97843. throw "HDR Bad header format, no size";
  97844. if (i = parseInt(s[2]),
  97845. t = parseInt(s[1]),
  97846. i < 8 || i > 32767)
  97847. throw "HDR Bad header format, unsupported size";
  97848. return {
  97849. height: t,
  97850. width: i,
  97851. dataPosition: a += n.length + 1
  97852. }
  97853. }
  97854. ,
  97855. e.GetCubeMapTextureData = function(e, t) {
  97856. var i = new Uint8Array(e)
  97857. , n = this.RGBE_ReadHeader(i)
  97858. , r = this.RGBE_ReadPixels(i, n);
  97859. return g_.ConvertPanoramaToCubemap(r, n.width, n.height, t)
  97860. }
  97861. ,
  97862. e.RGBE_ReadPixels = function(e, t) {
  97863. return this._RGBEReadPixelsRLE(e, t)
  97864. }
  97865. ,
  97866. e._RGBEReadPixelsRLE = function(e, t) {
  97867. for (var i, n, r, o, a, s = t.height, l = t.width, c = t.dataPosition, u = 0, h = 0, d = 0, p = new ArrayBuffer(4 * l), f = new Uint8Array(p), _ = new ArrayBuffer(t.width * t.height * 4 * 3), m = new Float32Array(_); s > 0; ) {
  97868. if (i = e[c++],
  97869. n = e[c++],
  97870. r = e[c++],
  97871. o = e[c++],
  97872. 2 != i || 2 != n || 128 & r || t.width < 8 || t.width > 32767)
  97873. return this._RGBEReadPixelsNOTRLE(e, t);
  97874. if ((r << 8 | o) != l)
  97875. throw "HDR Bad header format, wrong scan line width";
  97876. for (u = 0,
  97877. d = 0; d < 4; d++)
  97878. for (h = (d + 1) * l; u < h; )
  97879. if (i = e[c++],
  97880. n = e[c++],
  97881. i > 128) {
  97882. if (0 == (a = i - 128) || a > h - u)
  97883. throw "HDR Bad Format, bad scanline data (run)";
  97884. for (; a-- > 0; )
  97885. f[u++] = n
  97886. } else {
  97887. if (0 == (a = i) || a > h - u)
  97888. throw "HDR Bad Format, bad scanline data (non-run)";
  97889. if (f[u++] = n,
  97890. --a > 0)
  97891. for (var g = 0; g < a; g++)
  97892. f[u++] = e[c++]
  97893. }
  97894. for (d = 0; d < l; d++)
  97895. i = f[d],
  97896. n = f[d + l],
  97897. r = f[d + 2 * l],
  97898. o = f[d + 3 * l],
  97899. this._Rgbe2float(m, i, n, r, o, (t.height - s) * l * 3 + 3 * d);
  97900. s--
  97901. }
  97902. return m
  97903. }
  97904. ,
  97905. e._RGBEReadPixelsNOTRLE = function(e, t) {
  97906. for (var i, n, r, o, a, s = t.height, l = t.width, c = t.dataPosition, u = new ArrayBuffer(t.width * t.height * 4 * 3), h = new Float32Array(u); s > 0; ) {
  97907. for (a = 0; a < t.width; a++)
  97908. i = e[c++],
  97909. n = e[c++],
  97910. r = e[c++],
  97911. o = e[c++],
  97912. this._Rgbe2float(h, i, n, r, o, (t.height - s) * l * 3 + 3 * a);
  97913. s--
  97914. }
  97915. return h
  97916. }
  97917. ,
  97918. e
  97919. }()
  97920. , y_ = function() {
  97921. function e(t, i) {
  97922. var n;
  97923. void 0 === i && (i = e._DefaultOptions);
  97924. var r = this;
  97925. this._engine = t,
  97926. this._fullscreenViewport = new xr(0,0,1,1),
  97927. i = V(V({}, e._DefaultOptions), i),
  97928. this._vertexBuffers = ((n = {})[Bi.PositionKind] = new Bi(t,i.positions,Bi.PositionKind,!1,!1,2),
  97929. n),
  97930. this._indexBuffer = t.createIndexBuffer(i.indices),
  97931. this._onContextRestoredObserver = t.onContextRestoredObservable.add((function() {
  97932. for (var e in r._indexBuffer = t.createIndexBuffer(i.indices),
  97933. r._vertexBuffers)
  97934. r._vertexBuffers[e]._rebuild()
  97935. }
  97936. ))
  97937. }
  97938. return e.prototype.setViewport = function(e) {
  97939. void 0 === e && (e = this._fullscreenViewport),
  97940. this._engine.setViewport(e)
  97941. }
  97942. ,
  97943. e.prototype.bindBuffers = function(e) {
  97944. this._engine.bindBuffers(this._vertexBuffers, this._indexBuffer, e)
  97945. }
  97946. ,
  97947. e.prototype.applyEffectWrapper = function(e) {
  97948. this._engine.depthCullingState.depthTest = !1,
  97949. this._engine.stencilState.stencilTest = !1,
  97950. this._engine.enableEffect(e._drawWrapper),
  97951. this.bindBuffers(e.effect),
  97952. e.onApplyObservable.notifyObservers({})
  97953. }
  97954. ,
  97955. e.prototype.restoreStates = function() {
  97956. this._engine.depthCullingState.depthTest = !0,
  97957. this._engine.stencilState.stencilTest = !0
  97958. }
  97959. ,
  97960. e.prototype.draw = function() {
  97961. this._engine.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6)
  97962. }
  97963. ,
  97964. e.prototype._isRenderTargetTexture = function(e) {
  97965. return void 0 !== e.renderTarget
  97966. }
  97967. ,
  97968. e.prototype.render = function(e, t) {
  97969. if (void 0 === t && (t = null),
  97970. e.effect.isReady()) {
  97971. this.setViewport();
  97972. var i = null === t ? null : this._isRenderTargetTexture(t) ? t.renderTarget : t;
  97973. i && this._engine.bindFramebuffer(i),
  97974. this.applyEffectWrapper(e),
  97975. this.draw(),
  97976. i && this._engine.unBindFramebuffer(i),
  97977. this.restoreStates()
  97978. }
  97979. }
  97980. ,
  97981. e.prototype.dispose = function() {
  97982. var e = this._vertexBuffers[Bi.PositionKind];
  97983. e && (e.dispose(),
  97984. delete this._vertexBuffers[Bi.PositionKind]),
  97985. this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
  97986. this._onContextRestoredObserver && (this._engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),
  97987. this._onContextRestoredObserver = null)
  97988. }
  97989. ,
  97990. e._DefaultOptions = {
  97991. positions: [1, 1, -1, 1, -1, -1, 1, -1],
  97992. indices: [0, 1, 2, 0, 2, 3]
  97993. },
  97994. e
  97995. }()
  97996. , b_ = function() {
  97997. function e(e) {
  97998. var t, i = this;
  97999. this.onApplyObservable = new h;
  98000. var n = e.uniformNames || [];
  98001. e.vertexShader ? t = {
  98002. fragmentSource: e.fragmentShader,
  98003. vertexSource: e.vertexShader,
  98004. spectorName: e.name || "effectWrapper"
  98005. } : (n.push("scale"),
  98006. t = {
  98007. fragmentSource: e.fragmentShader,
  98008. vertex: "postprocess",
  98009. spectorName: e.name || "effectWrapper"
  98010. },
  98011. this.onApplyObservable.add((function() {
  98012. i.effect.setFloat2("scale", 1, 1)
  98013. }
  98014. )));
  98015. var r = e.defines ? e.defines.join("\n") : "";
  98016. this._drawWrapper = new Gt(e.engine),
  98017. e.useShaderStore ? (t.fragment = t.fragmentSource,
  98018. t.vertex || (t.vertex = t.vertexSource),
  98019. delete t.fragmentSource,
  98020. delete t.vertexSource,
  98021. this.effect = e.engine.createEffect(t, e.attributeNames || ["position"], n, e.samplerNames, r, void 0, e.onCompiled, void 0, void 0, e.shaderLanguage)) : (this.effect = new Mt(t,e.attributeNames || ["position"],n,e.samplerNames,e.engine,r,void 0,e.onCompiled,void 0,void 0,void 0,e.shaderLanguage),
  98022. this._onContextRestoredObserver = e.engine.onContextRestoredObservable.add((function() {
  98023. i.effect._pipelineContext = null,
  98024. i.effect._wasPreviouslyReady = !1,
  98025. i.effect._prepareEffect()
  98026. }
  98027. )))
  98028. }
  98029. return Object.defineProperty(e.prototype, "effect", {
  98030. get: function() {
  98031. return this._drawWrapper.effect
  98032. },
  98033. set: function(e) {
  98034. this._drawWrapper.effect = e
  98035. },
  98036. enumerable: !1,
  98037. configurable: !0
  98038. }),
  98039. e.prototype.dispose = function() {
  98040. this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
  98041. this._onContextRestoredObserver = null),
  98042. this.effect.dispose()
  98043. }
  98044. ,
  98045. e
  98046. }();
  98047. Pt.ShadersStore.hdrFilteringVertexShader = "attribute vec2 position;\nvarying vec3 direction;\nuniform vec3 up;\nuniform vec3 right;\nuniform vec3 front;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nmat3 view=mat3(up,right,front);\ndirection=view*vec3(position,1.0);\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  98048. Pt.ShadersStore.hdrFilteringPixelShader = "#include<helperFunctions>\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nuniform float alphaG;\nuniform samplerCube inputTexture;\nuniform vec2 vFilteringInfo;\nuniform float hdrScale;\nvarying vec3 direction;\nvoid main() {\nvec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);\ngl_FragColor=vec4(color*hdrScale,1.0);\n}";
  98049. var T_ = function() {
  98050. function e(e, t) {
  98051. void 0 === t && (t = {}),
  98052. this._lodGenerationOffset = 0,
  98053. this._lodGenerationScale = .8,
  98054. this.quality = a.TEXTURE_FILTERING_QUALITY_OFFLINE,
  98055. this.hdrScale = 1,
  98056. this._engine = e,
  98057. this.hdrScale = t.hdrScale || this.hdrScale,
  98058. this.quality = t.hdrScale || this.quality
  98059. }
  98060. return e.prototype._createRenderTarget = function(e) {
  98061. var t = a.TEXTURETYPE_UNSIGNED_BYTE;
  98062. this._engine.getCaps().textureHalfFloatRender ? t = a.TEXTURETYPE_HALF_FLOAT : this._engine.getCaps().textureFloatRender && (t = a.TEXTURETYPE_FLOAT);
  98063. var i = this._engine.createRenderTargetCubeTexture(e, {
  98064. format: a.TEXTUREFORMAT_RGBA,
  98065. type: t,
  98066. createMipMaps: !0,
  98067. generateMipMaps: !1,
  98068. generateDepthBuffer: !1,
  98069. generateStencilBuffer: !1,
  98070. samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE
  98071. });
  98072. return this._engine.updateTextureWrappingMode(i.texture, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE),
  98073. this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, i.texture, !0),
  98074. i
  98075. }
  98076. ,
  98077. e.prototype._prefilterInternal = function(e) {
  98078. var t = e.getSize().width
  98079. , i = d.ILog2(t) + 1
  98080. , n = this._effectWrapper.effect
  98081. , r = this._createRenderTarget(t);
  98082. this._effectRenderer.setViewport();
  98083. var o = e.getInternalTexture();
  98084. o && this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, o, !0),
  98085. this._effectRenderer.applyEffectWrapper(this._effectWrapper);
  98086. var s = [[new x(0,0,-1), new x(0,-1,0), new x(1,0,0)], [new x(0,0,1), new x(0,-1,0), new x(-1,0,0)], [new x(1,0,0), new x(0,0,1), new x(0,1,0)], [new x(1,0,0), new x(0,0,-1), new x(0,-1,0)], [new x(1,0,0), new x(0,-1,0), new x(0,0,1)], [new x(-1,0,0), new x(0,-1,0), new x(0,0,-1)]];
  98087. n.setFloat("hdrScale", this.hdrScale),
  98088. n.setFloat2("vFilteringInfo", e.getSize().width, i),
  98089. n.setTexture("inputTexture", e);
  98090. for (var l = 0; l < 6; l++) {
  98091. n.setVector3("up", s[l][0]),
  98092. n.setVector3("right", s[l][1]),
  98093. n.setVector3("front", s[l][2]);
  98094. for (var c = 0; c < i; c++) {
  98095. this._engine.bindFramebuffer(r, l, void 0, void 0, !0, c),
  98096. this._effectRenderer.applyEffectWrapper(this._effectWrapper);
  98097. var u = Math.pow(2, (c - this._lodGenerationOffset) / this._lodGenerationScale) / t;
  98098. 0 === c && (u = 0),
  98099. n.setFloat("alphaG", u),
  98100. this._effectRenderer.draw()
  98101. }
  98102. }
  98103. return this._effectRenderer.restoreStates(),
  98104. this._engine.restoreDefaultFramebuffer(),
  98105. this._engine._releaseTexture(e._texture),
  98106. r._swapAndDie(e._texture),
  98107. e._prefiltered = !0,
  98108. e
  98109. }
  98110. ,
  98111. e.prototype._createEffect = function(e, t) {
  98112. var i = [];
  98113. return e.gammaSpace && i.push("#define GAMMA_INPUT"),
  98114. i.push("#define NUM_SAMPLES " + this.quality + "u"),
  98115. new b_({
  98116. engine: this._engine,
  98117. name: "hdrFiltering",
  98118. vertexShader: "hdrFiltering",
  98119. fragmentShader: "hdrFiltering",
  98120. samplerNames: ["inputTexture"],
  98121. uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"],
  98122. useShaderStore: !0,
  98123. defines: i,
  98124. onCompiled: t
  98125. })
  98126. }
  98127. ,
  98128. e.prototype.isReady = function(e) {
  98129. return e.isReady() && this._effectWrapper.effect.isReady()
  98130. }
  98131. ,
  98132. e.prototype.prefilter = function(e, t) {
  98133. var i = this;
  98134. return void 0 === t && (t = null),
  98135. this._engine._features.allowTexturePrefiltering ? new Promise((function(n) {
  98136. i._effectRenderer = new y_(i._engine),
  98137. i._effectWrapper = i._createEffect(e),
  98138. i._effectWrapper.effect.executeWhenCompiled((function() {
  98139. i._prefilterInternal(e),
  98140. i._effectRenderer.dispose(),
  98141. i._effectWrapper.dispose(),
  98142. n(),
  98143. t && t()
  98144. }
  98145. ))
  98146. }
  98147. )) : (K.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),
  98148. Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))
  98149. }
  98150. ,
  98151. e
  98152. }()
  98153. , E_ = function(e) {
  98154. function t(t, i, n, r, o, s, l, c, u) {
  98155. void 0 === r && (r = !1),
  98156. void 0 === o && (o = !0),
  98157. void 0 === s && (s = !1),
  98158. void 0 === l && (l = !1),
  98159. void 0 === c && (c = null),
  98160. void 0 === u && (u = null);
  98161. var d, p = this;
  98162. return (p = e.call(this, i) || this)._generateHarmonics = !0,
  98163. p._onError = null,
  98164. p._isBlocking = !0,
  98165. p._rotationY = 0,
  98166. p.boundingBoxPosition = x.Zero(),
  98167. p.onLoadObservable = new h,
  98168. t ? (p._coordinatesMode = io.CUBIC_MODE,
  98169. p.name = t,
  98170. p.url = t,
  98171. p.hasAlpha = !1,
  98172. p.isCube = !0,
  98173. p._textureMatrix = P.Identity(),
  98174. p._prefilterOnLoad = l,
  98175. p._onLoad = function() {
  98176. p.onLoadObservable.notifyObservers(p),
  98177. c && c()
  98178. }
  98179. ,
  98180. p._onError = u,
  98181. p.gammaSpace = s,
  98182. p._noMipmap = r,
  98183. p._size = n,
  98184. p._generateHarmonics = o,
  98185. p._texture = p._getFromCache(t, p._noMipmap),
  98186. p._texture ? p._texture.isReady ? gi.SetImmediate((function() {
  98187. return p._onLoad()
  98188. }
  98189. )) : p._texture.onLoadedObservable.add(p._onLoad) : (null === (d = p.getScene()) || void 0 === d ? void 0 : d.useDelayedTextureLoading) ? p.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : p._loadTexture(),
  98190. p) : p
  98191. }
  98192. return U(t, e),
  98193. Object.defineProperty(t.prototype, "isBlocking", {
  98194. get: function() {
  98195. return this._isBlocking
  98196. },
  98197. set: function(e) {
  98198. this._isBlocking = e
  98199. },
  98200. enumerable: !1,
  98201. configurable: !0
  98202. }),
  98203. Object.defineProperty(t.prototype, "rotationY", {
  98204. get: function() {
  98205. return this._rotationY
  98206. },
  98207. set: function(e) {
  98208. this._rotationY = e,
  98209. this.setReflectionTextureMatrix(P.RotationY(this._rotationY))
  98210. },
  98211. enumerable: !1,
  98212. configurable: !0
  98213. }),
  98214. Object.defineProperty(t.prototype, "boundingBoxSize", {
  98215. get: function() {
  98216. return this._boundingBoxSize
  98217. },
  98218. set: function(e) {
  98219. if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
  98220. this._boundingBoxSize = e;
  98221. var t = this.getScene();
  98222. t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
  98223. }
  98224. },
  98225. enumerable: !1,
  98226. configurable: !0
  98227. }),
  98228. t.prototype.getClassName = function() {
  98229. return "HDRCubeTexture"
  98230. }
  98231. ,
  98232. t.prototype._loadTexture = function() {
  98233. var e = this
  98234. , i = this._getEngine()
  98235. , n = i.getCaps()
  98236. , r = a.TEXTURETYPE_UNSIGNED_BYTE;
  98237. if (n.textureFloat && n.textureFloatLinearFiltering ? r = a.TEXTURETYPE_FLOAT : n.textureHalfFloat && n.textureHalfFloatLinearFiltering && (r = a.TEXTURETYPE_HALF_FLOAT),
  98238. i._features.allowTexturePrefiltering && this._prefilterOnLoad) {
  98239. var o = this._onLoad
  98240. , s = new T_(i);
  98241. this._onLoad = function() {
  98242. s.prefilter(e, o)
  98243. }
  98244. }
  98245. this._texture = i.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, a.TEXTUREFORMAT_RGB, r, this._noMipmap, (function(i) {
  98246. e.lodGenerationOffset = 0,
  98247. e.lodGenerationScale = .8;
  98248. var n = v_.GetCubeMapTextureData(i, e._size);
  98249. if (e._generateHarmonics) {
  98250. var o = wc.ConvertCubeMapToSphericalPolynomial(n);
  98251. e.sphericalPolynomial = o
  98252. }
  98253. for (var s = [], l = null, c = null, u = 0; u < 6; u++) {
  98254. r === a.TEXTURETYPE_HALF_FLOAT ? c = new Uint16Array(e._size * e._size * 3) : r === a.TEXTURETYPE_UNSIGNED_BYTE && (l = new Uint8Array(e._size * e._size * 3));
  98255. var h = n[t._FacesMapping[u]];
  98256. if (e.gammaSpace || c || l)
  98257. for (var d = 0; d < e._size * e._size; d++)
  98258. if (e.gammaSpace && (h[3 * d + 0] = Math.pow(h[3 * d + 0], p),
  98259. h[3 * d + 1] = Math.pow(h[3 * d + 1], p),
  98260. h[3 * d + 2] = Math.pow(h[3 * d + 2], p)),
  98261. c && (c[3 * d + 0] = Oc(h[3 * d + 0]),
  98262. c[3 * d + 1] = Oc(h[3 * d + 1]),
  98263. c[3 * d + 2] = Oc(h[3 * d + 2])),
  98264. l) {
  98265. var f = Math.max(255 * h[3 * d + 0], 0)
  98266. , _ = Math.max(255 * h[3 * d + 1], 0)
  98267. , m = Math.max(255 * h[3 * d + 2], 0)
  98268. , g = Math.max(Math.max(f, _), m);
  98269. if (g > 255) {
  98270. var v = 255 / g;
  98271. f *= v,
  98272. _ *= v,
  98273. m *= v
  98274. }
  98275. l[3 * d + 0] = f,
  98276. l[3 * d + 1] = _,
  98277. l[3 * d + 2] = m
  98278. }
  98279. c ? s.push(c) : l ? s.push(l) : s.push(h)
  98280. }
  98281. return s
  98282. }
  98283. ), null, this._onLoad, this._onError)
  98284. }
  98285. ,
  98286. t.prototype.clone = function() {
  98287. var e = new t(this.url,this.getScene() || this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);
  98288. return e.level = this.level,
  98289. e.wrapU = this.wrapU,
  98290. e.wrapV = this.wrapV,
  98291. e.coordinatesIndex = this.coordinatesIndex,
  98292. e.coordinatesMode = this.coordinatesMode,
  98293. e
  98294. }
  98295. ,
  98296. t.prototype.delayLoad = function() {
  98297. this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
  98298. this._texture = this._getFromCache(this.url, this._noMipmap),
  98299. this._texture || this._loadTexture())
  98300. }
  98301. ,
  98302. t.prototype.getReflectionTextureMatrix = function() {
  98303. return this._textureMatrix
  98304. }
  98305. ,
  98306. t.prototype.setReflectionTextureMatrix = function(e) {
  98307. var t, i = this;
  98308. this._textureMatrix = e,
  98309. e.updateFlag !== this._textureMatrix.updateFlag && e.isIdentity() !== this._textureMatrix.isIdentity() && (null === (t = this.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  98310. return -1 !== e.getActiveTextures().indexOf(i)
  98311. }
  98312. )))
  98313. }
  98314. ,
  98315. t.prototype.dispose = function() {
  98316. this.onLoadObservable.clear(),
  98317. e.prototype.dispose.call(this)
  98318. }
  98319. ,
  98320. t.Parse = function(e, i, n) {
  98321. var r = null;
  98322. return e.name && !e.isRenderTarget && ((r = new t(n + e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name = e.name,
  98323. r.hasAlpha = e.hasAlpha,
  98324. r.level = e.level,
  98325. r.coordinatesMode = e.coordinatesMode,
  98326. r.isBlocking = e.isBlocking),
  98327. r && (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
  98328. e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
  98329. e.rotationY && (r.rotationY = e.rotationY)),
  98330. r
  98331. }
  98332. ,
  98333. t.prototype.serialize = function() {
  98334. if (!this.name)
  98335. return null;
  98336. var e = {};
  98337. return e.name = this.name,
  98338. e.hasAlpha = this.hasAlpha,
  98339. e.isCube = !0,
  98340. e.level = this.level,
  98341. e.size = this._size,
  98342. e.coordinatesMode = this.coordinatesMode,
  98343. e.useInGammaSpace = this.gammaSpace,
  98344. e.generateHarmonics = this._generateHarmonics,
  98345. e.customType = "BABYLON.HDRCubeTexture",
  98346. e.noMipmap = this._noMipmap,
  98347. e.isBlocking = this._isBlocking,
  98348. e.rotationY = this._rotationY,
  98349. e
  98350. }
  98351. ,
  98352. t._FacesMapping = ["right", "left", "up", "down", "front", "back"],
  98353. t
  98354. }(Zr);
  98355. y("BABYLON.HDRCubeTexture", E_);
  98356. var S_ = function() {
  98357. function e(e, t, i) {
  98358. void 0 === t && (t = 0),
  98359. void 0 === i && (i = null),
  98360. this.name = e,
  98361. this.animations = new Array,
  98362. this._positions = null,
  98363. this._normals = null,
  98364. this._tangents = null,
  98365. this._uvs = null,
  98366. this._uniqueId = 0,
  98367. this.onInfluenceChanged = new h,
  98368. this._onDataLayoutChanged = new h,
  98369. this._animationPropertiesOverride = null,
  98370. this._scene = i || E.LastCreatedScene,
  98371. this.influence = t,
  98372. this._scene && (this._uniqueId = this._scene.getUniqueId())
  98373. }
  98374. return Object.defineProperty(e.prototype, "influence", {
  98375. get: function() {
  98376. return this._influence
  98377. },
  98378. set: function(e) {
  98379. if (this._influence !== e) {
  98380. var t = this._influence;
  98381. this._influence = e,
  98382. this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(0 === t || 0 === e)
  98383. }
  98384. },
  98385. enumerable: !1,
  98386. configurable: !0
  98387. }),
  98388. Object.defineProperty(e.prototype, "animationPropertiesOverride", {
  98389. get: function() {
  98390. return !this._animationPropertiesOverride && this._scene ? this._scene.animationPropertiesOverride : this._animationPropertiesOverride
  98391. },
  98392. set: function(e) {
  98393. this._animationPropertiesOverride = e
  98394. },
  98395. enumerable: !1,
  98396. configurable: !0
  98397. }),
  98398. Object.defineProperty(e.prototype, "uniqueId", {
  98399. get: function() {
  98400. return this._uniqueId
  98401. },
  98402. enumerable: !1,
  98403. configurable: !0
  98404. }),
  98405. Object.defineProperty(e.prototype, "hasPositions", {
  98406. get: function() {
  98407. return !!this._positions
  98408. },
  98409. enumerable: !1,
  98410. configurable: !0
  98411. }),
  98412. Object.defineProperty(e.prototype, "hasNormals", {
  98413. get: function() {
  98414. return !!this._normals
  98415. },
  98416. enumerable: !1,
  98417. configurable: !0
  98418. }),
  98419. Object.defineProperty(e.prototype, "hasTangents", {
  98420. get: function() {
  98421. return !!this._tangents
  98422. },
  98423. enumerable: !1,
  98424. configurable: !0
  98425. }),
  98426. Object.defineProperty(e.prototype, "hasUVs", {
  98427. get: function() {
  98428. return !!this._uvs
  98429. },
  98430. enumerable: !1,
  98431. configurable: !0
  98432. }),
  98433. e.prototype.setPositions = function(e) {
  98434. var t = this.hasPositions;
  98435. this._positions = e,
  98436. t !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0)
  98437. }
  98438. ,
  98439. e.prototype.getPositions = function() {
  98440. return this._positions
  98441. }
  98442. ,
  98443. e.prototype.setNormals = function(e) {
  98444. var t = this.hasNormals;
  98445. this._normals = e,
  98446. t !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0)
  98447. }
  98448. ,
  98449. e.prototype.getNormals = function() {
  98450. return this._normals
  98451. }
  98452. ,
  98453. e.prototype.setTangents = function(e) {
  98454. var t = this.hasTangents;
  98455. this._tangents = e,
  98456. t !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0)
  98457. }
  98458. ,
  98459. e.prototype.getTangents = function() {
  98460. return this._tangents
  98461. }
  98462. ,
  98463. e.prototype.setUVs = function(e) {
  98464. var t = this.hasUVs;
  98465. this._uvs = e,
  98466. t !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0)
  98467. }
  98468. ,
  98469. e.prototype.getUVs = function() {
  98470. return this._uvs
  98471. }
  98472. ,
  98473. e.prototype.clone = function() {
  98474. var t = this
  98475. , i = Ge.Clone((function() {
  98476. return new e(t.name,t.influence,t._scene)
  98477. }
  98478. ), this);
  98479. return i._positions = this._positions,
  98480. i._normals = this._normals,
  98481. i._tangents = this._tangents,
  98482. i._uvs = this._uvs,
  98483. i
  98484. }
  98485. ,
  98486. e.prototype.serialize = function() {
  98487. var e = {};
  98488. return e.name = this.name,
  98489. e.influence = this.influence,
  98490. e.positions = Array.prototype.slice.call(this.getPositions()),
  98491. null != this.id && (e.id = this.id),
  98492. this.hasNormals && (e.normals = Array.prototype.slice.call(this.getNormals())),
  98493. this.hasTangents && (e.tangents = Array.prototype.slice.call(this.getTangents())),
  98494. this.hasUVs && (e.uvs = Array.prototype.slice.call(this.getUVs())),
  98495. Ge.AppendSerializedAnimations(this, e),
  98496. e
  98497. }
  98498. ,
  98499. e.prototype.getClassName = function() {
  98500. return "MorphTarget"
  98501. }
  98502. ,
  98503. e.Parse = function(t, i) {
  98504. var n = new e(t.name,t.influence);
  98505. if (n.setPositions(t.positions),
  98506. null != t.id && (n.id = t.id),
  98507. t.normals && n.setNormals(t.normals),
  98508. t.tangents && n.setTangents(t.tangents),
  98509. t.uvs && n.setUVs(t.uvs),
  98510. t.animations) {
  98511. for (var r = 0; r < t.animations.length; r++) {
  98512. var o = t.animations[r]
  98513. , a = b("BABYLON.Animation");
  98514. a && n.animations.push(a.Parse(o))
  98515. }
  98516. t.autoAnimate && i && i.beginAnimation(n, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1)
  98517. }
  98518. return n
  98519. }
  98520. ,
  98521. e.FromMesh = function(t, i, n) {
  98522. i || (i = t.name);
  98523. var r = new e(i,n,t.getScene());
  98524. return r.setPositions(t.getVerticesData(Bi.PositionKind)),
  98525. t.isVerticesDataPresent(Bi.NormalKind) && r.setNormals(t.getVerticesData(Bi.NormalKind)),
  98526. t.isVerticesDataPresent(Bi.TangentKind) && r.setTangents(t.getVerticesData(Bi.TangentKind)),
  98527. t.isVerticesDataPresent(Bi.UVKind) && r.setUVs(t.getVerticesData(Bi.UVKind)),
  98528. r
  98529. }
  98530. ,
  98531. k([Ce()], e.prototype, "id", void 0),
  98532. e
  98533. }()
  98534. , A_ = function(e) {
  98535. function t(t, i, n, r, o, s, l, c, u, h) {
  98536. void 0 === l && (l = !0),
  98537. void 0 === c && (c = !1),
  98538. void 0 === u && (u = io.TRILINEAR_SAMPLINGMODE),
  98539. void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
  98540. var d = e.call(this, null, s, !l, c) || this;
  98541. return d.format = o,
  98542. d._texture = s.getEngine().createRawTexture2DArray(t, i, n, r, o, l, c, u, null, h),
  98543. d._depth = r,
  98544. d.is2DArray = !0,
  98545. d
  98546. }
  98547. return U(t, e),
  98548. Object.defineProperty(t.prototype, "depth", {
  98549. get: function() {
  98550. return this._depth
  98551. },
  98552. enumerable: !1,
  98553. configurable: !0
  98554. }),
  98555. t.prototype.update = function(e) {
  98556. this._texture && this._getEngine().updateRawTexture2DArray(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
  98557. }
  98558. ,
  98559. t.CreateRGBATexture = function(e, i, n, r, o, s, l, c, u) {
  98560. return void 0 === s && (s = !0),
  98561. void 0 === l && (l = !1),
  98562. void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  98563. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  98564. new t(e,i,n,r,a.TEXTUREFORMAT_RGBA,o,s,l,c,u)
  98565. }
  98566. ,
  98567. t
  98568. }(io)
  98569. , x_ = function() {
  98570. function e(e) {
  98571. if (void 0 === e && (e = null),
  98572. this._targets = new Array,
  98573. this._targetInfluenceChangedObservers = new Array,
  98574. this._targetDataLayoutChangedObservers = new Array,
  98575. this._activeTargets = new bi(16),
  98576. this._supportsNormals = !1,
  98577. this._supportsTangents = !1,
  98578. this._supportsUVs = !1,
  98579. this._vertexCount = 0,
  98580. this._textureVertexStride = 0,
  98581. this._textureWidth = 0,
  98582. this._textureHeight = 1,
  98583. this._uniqueId = 0,
  98584. this._tempInfluences = new Array,
  98585. this._canUseTextureForTargets = !1,
  98586. this._blockCounter = 0,
  98587. this._parentContainer = null,
  98588. this.optimizeInfluencers = !0,
  98589. this.enableNormalMorphing = !0,
  98590. this.enableTangentMorphing = !0,
  98591. this.enableUVMorphing = !0,
  98592. this._useTextureToStoreTargets = !0,
  98593. e || (e = E.LastCreatedScene),
  98594. this._scene = e,
  98595. this._scene) {
  98596. this._scene.morphTargetManagers.push(this),
  98597. this._uniqueId = this._scene.getUniqueId();
  98598. var t = this._scene.getEngine().getCaps();
  98599. this._canUseTextureForTargets = t.canUseGLVertexID && t.textureFloat && t.maxVertexTextureImageUnits > 0
  98600. }
  98601. }
  98602. return Object.defineProperty(e.prototype, "areUpdatesFrozen", {
  98603. get: function() {
  98604. return this._blockCounter > 0
  98605. },
  98606. set: function(e) {
  98607. e ? this._blockCounter++ : (this._blockCounter--,
  98608. this._blockCounter <= 0 && (this._blockCounter = 0,
  98609. this._syncActiveTargets(!0)))
  98610. },
  98611. enumerable: !1,
  98612. configurable: !0
  98613. }),
  98614. Object.defineProperty(e.prototype, "uniqueId", {
  98615. get: function() {
  98616. return this._uniqueId
  98617. },
  98618. enumerable: !1,
  98619. configurable: !0
  98620. }),
  98621. Object.defineProperty(e.prototype, "vertexCount", {
  98622. get: function() {
  98623. return this._vertexCount
  98624. },
  98625. enumerable: !1,
  98626. configurable: !0
  98627. }),
  98628. Object.defineProperty(e.prototype, "supportsNormals", {
  98629. get: function() {
  98630. return this._supportsNormals && this.enableNormalMorphing
  98631. },
  98632. enumerable: !1,
  98633. configurable: !0
  98634. }),
  98635. Object.defineProperty(e.prototype, "supportsTangents", {
  98636. get: function() {
  98637. return this._supportsTangents && this.enableTangentMorphing
  98638. },
  98639. enumerable: !1,
  98640. configurable: !0
  98641. }),
  98642. Object.defineProperty(e.prototype, "supportsUVs", {
  98643. get: function() {
  98644. return this._supportsUVs && this.enableUVMorphing
  98645. },
  98646. enumerable: !1,
  98647. configurable: !0
  98648. }),
  98649. Object.defineProperty(e.prototype, "numTargets", {
  98650. get: function() {
  98651. return this._targets.length
  98652. },
  98653. enumerable: !1,
  98654. configurable: !0
  98655. }),
  98656. Object.defineProperty(e.prototype, "numInfluencers", {
  98657. get: function() {
  98658. return this._activeTargets.length
  98659. },
  98660. enumerable: !1,
  98661. configurable: !0
  98662. }),
  98663. Object.defineProperty(e.prototype, "influences", {
  98664. get: function() {
  98665. return this._influences
  98666. },
  98667. enumerable: !1,
  98668. configurable: !0
  98669. }),
  98670. Object.defineProperty(e.prototype, "useTextureToStoreTargets", {
  98671. get: function() {
  98672. return this._useTextureToStoreTargets
  98673. },
  98674. set: function(e) {
  98675. this._useTextureToStoreTargets = e
  98676. },
  98677. enumerable: !1,
  98678. configurable: !0
  98679. }),
  98680. Object.defineProperty(e.prototype, "isUsingTextureForTargets", {
  98681. get: function() {
  98682. return e.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets
  98683. },
  98684. enumerable: !1,
  98685. configurable: !0
  98686. }),
  98687. e.prototype.getActiveTarget = function(e) {
  98688. return this._activeTargets.data[e]
  98689. }
  98690. ,
  98691. e.prototype.getTarget = function(e) {
  98692. return this._targets[e]
  98693. }
  98694. ,
  98695. e.prototype.addTarget = function(e) {
  98696. var t = this;
  98697. this._targets.push(e),
  98698. this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((function(e) {
  98699. t._syncActiveTargets(e)
  98700. }
  98701. ))),
  98702. this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((function() {
  98703. t._syncActiveTargets(!0)
  98704. }
  98705. ))),
  98706. this._syncActiveTargets(!0)
  98707. }
  98708. ,
  98709. e.prototype.removeTarget = function(e) {
  98710. var t = this._targets.indexOf(e);
  98711. t >= 0 && (this._targets.splice(t, 1),
  98712. e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t, 1)[0]),
  98713. e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t, 1)[0]),
  98714. this._syncActiveTargets(!0))
  98715. }
  98716. ,
  98717. e.prototype._bind = function(e) {
  98718. e.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight),
  98719. e.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices),
  98720. e.setTexture("morphTargets", this._targetStoreTexture)
  98721. }
  98722. ,
  98723. e.prototype.clone = function() {
  98724. for (var t = new e(this._scene), i = 0, n = this._targets; i < n.length; i++) {
  98725. var r = n[i];
  98726. t.addTarget(r.clone())
  98727. }
  98728. return t.enableNormalMorphing = this.enableNormalMorphing,
  98729. t.enableTangentMorphing = this.enableTangentMorphing,
  98730. t.enableUVMorphing = this.enableUVMorphing,
  98731. t
  98732. }
  98733. ,
  98734. e.prototype.serialize = function() {
  98735. var e = {};
  98736. e.id = this.uniqueId,
  98737. e.targets = [];
  98738. for (var t = 0, i = this._targets; t < i.length; t++) {
  98739. var n = i[t];
  98740. e.targets.push(n.serialize())
  98741. }
  98742. return e
  98743. }
  98744. ,
  98745. e.prototype._syncActiveTargets = function(e) {
  98746. if (!this.areUpdatesFrozen) {
  98747. var t = 0;
  98748. this._activeTargets.reset(),
  98749. this._supportsNormals = !0,
  98750. this._supportsTangents = !0,
  98751. this._supportsUVs = !0,
  98752. this._vertexCount = 0,
  98753. this._morphTargetTextureIndices && this._morphTargetTextureIndices.length === this._targets.length || (this._morphTargetTextureIndices = new Float32Array(this._targets.length));
  98754. for (var i = -1, n = 0, r = this._targets; n < r.length; n++) {
  98755. var o = r[n];
  98756. if (i++,
  98757. 0 !== o.influence || !this.optimizeInfluencers) {
  98758. this._activeTargets.push(o),
  98759. this._morphTargetTextureIndices[t] = i,
  98760. this._tempInfluences[t++] = o.influence,
  98761. this._supportsNormals = this._supportsNormals && o.hasNormals,
  98762. this._supportsTangents = this._supportsTangents && o.hasTangents,
  98763. this._supportsUVs = this._supportsUVs && o.hasUVs;
  98764. var a = o.getPositions();
  98765. if (a) {
  98766. var s = a.length / 3;
  98767. if (0 === this._vertexCount)
  98768. this._vertexCount = s;
  98769. else if (this._vertexCount !== s)
  98770. return void K.Error("Incompatible target. Targets must all have the same vertices count.")
  98771. }
  98772. }
  98773. }
  98774. this._influences && this._influences.length === t || (this._influences = new Float32Array(t));
  98775. for (var l = 0; l < t; l++)
  98776. this._influences[l] = this._tempInfluences[l];
  98777. e && this.synchronize()
  98778. }
  98779. }
  98780. ,
  98781. e.prototype.synchronize = function() {
  98782. if (this._scene && !this.areUpdatesFrozen) {
  98783. if (this.isUsingTextureForTargets && this._vertexCount) {
  98784. this._textureVertexStride = 1,
  98785. this._supportsNormals && this._textureVertexStride++,
  98786. this._supportsTangents && this._textureVertexStride++,
  98787. this._supportsUVs && this._textureVertexStride++,
  98788. this._textureWidth = this._vertexCount * this._textureVertexStride,
  98789. this._textureHeight = 1;
  98790. var e = this._scene.getEngine().getCaps().maxTextureSize;
  98791. this._textureWidth > e && (this._textureHeight = Math.ceil(this._textureWidth / e),
  98792. this._textureWidth = e);
  98793. var t = !0;
  98794. if (this._targetStoreTexture) {
  98795. var i = this._targetStoreTexture.getSize();
  98796. i.width === this._textureWidth && i.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (t = !1)
  98797. }
  98798. if (t) {
  98799. this._targetStoreTexture && this._targetStoreTexture.dispose();
  98800. for (var n = this._targets.length, r = new Float32Array(n * this._textureWidth * this._textureHeight * 4), o = 0, s = 0; s < n; s++) {
  98801. var l = this._targets[s]
  98802. , c = l.getPositions()
  98803. , u = l.getNormals()
  98804. , h = l.getUVs()
  98805. , d = l.getTangents();
  98806. if (!c)
  98807. return void (0 === s && K.Error("Invalid morph target. Target must have positions."));
  98808. o = s * this._textureWidth * this._textureHeight * 4;
  98809. for (var p = 0; p < this._vertexCount; p++)
  98810. r[o] = c[3 * p],
  98811. r[o + 1] = c[3 * p + 1],
  98812. r[o + 2] = c[3 * p + 2],
  98813. o += 4,
  98814. u && (r[o] = u[3 * p],
  98815. r[o + 1] = u[3 * p + 1],
  98816. r[o + 2] = u[3 * p + 2],
  98817. o += 4),
  98818. h && (r[o] = h[2 * p],
  98819. r[o + 1] = h[2 * p + 1],
  98820. o += 4),
  98821. d && (r[o] = d[3 * p],
  98822. r[o + 1] = d[3 * p + 1],
  98823. r[o + 2] = d[3 * p + 2],
  98824. o += 4)
  98825. }
  98826. this._targetStoreTexture = A_.CreateRGBATexture(r, this._textureWidth, this._textureHeight, n, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT)
  98827. }
  98828. }
  98829. for (var f = 0, _ = this._scene.meshes; f < _.length; f++) {
  98830. var m = _[f];
  98831. m.morphTargetManager === this && m._syncGeometryWithMorphTargetManager()
  98832. }
  98833. }
  98834. }
  98835. ,
  98836. e.prototype.dispose = function() {
  98837. if (this._targetStoreTexture && this._targetStoreTexture.dispose(),
  98838. this._targetStoreTexture = null,
  98839. this._scene && (this._scene.removeMorphTargetManager(this),
  98840. this._parentContainer)) {
  98841. var e = this._parentContainer.morphTargetManagers.indexOf(this);
  98842. e > -1 && this._parentContainer.morphTargetManagers.splice(e, 1),
  98843. this._parentContainer = null
  98844. }
  98845. }
  98846. ,
  98847. e.Parse = function(t, i) {
  98848. var n = new e(i);
  98849. n._uniqueId = t.id;
  98850. for (var r = 0, o = t.targets; r < o.length; r++) {
  98851. var a = o[r];
  98852. n.addTarget(S_.Parse(a, i))
  98853. }
  98854. return n
  98855. }
  98856. ,
  98857. e.EnableTextureStorage = !0,
  98858. e
  98859. }()
  98860. , R_ = function() {
  98861. function e(t, i) {
  98862. if (void 0 === i && (i = e.DefaultPluginFactory()),
  98863. this._physicsPlugin = i,
  98864. this._impostors = [],
  98865. this._joints = [],
  98866. this._subTimeStep = 0,
  98867. this._uniqueIdCounter = 0,
  98868. !this._physicsPlugin.isSupported())
  98869. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
  98870. t = t || new x(0,-9.807,0),
  98871. this.setGravity(t),
  98872. this.setTimeStep()
  98873. }
  98874. return e.DefaultPluginFactory = function() {
  98875. throw be("CannonJSPlugin")
  98876. }
  98877. ,
  98878. e.prototype.setGravity = function(e) {
  98879. this.gravity = e,
  98880. this._physicsPlugin.setGravity(this.gravity)
  98881. }
  98882. ,
  98883. e.prototype.setTimeStep = function(e) {
  98884. void 0 === e && (e = 1 / 60),
  98885. this._physicsPlugin.setTimeStep(e)
  98886. }
  98887. ,
  98888. e.prototype.getTimeStep = function() {
  98889. return this._physicsPlugin.getTimeStep()
  98890. }
  98891. ,
  98892. e.prototype.setSubTimeStep = function(e) {
  98893. void 0 === e && (e = 0),
  98894. this._subTimeStep = e
  98895. }
  98896. ,
  98897. e.prototype.getSubTimeStep = function() {
  98898. return this._subTimeStep
  98899. }
  98900. ,
  98901. e.prototype.dispose = function() {
  98902. this._impostors.forEach((function(e) {
  98903. e.dispose()
  98904. }
  98905. )),
  98906. this._physicsPlugin.dispose()
  98907. }
  98908. ,
  98909. e.prototype.getPhysicsPluginName = function() {
  98910. return this._physicsPlugin.name
  98911. }
  98912. ,
  98913. e.prototype.addImpostor = function(e) {
  98914. this._impostors.push(e),
  98915. e.uniqueId = this._uniqueIdCounter++,
  98916. e.parent || this._physicsPlugin.generatePhysicsBody(e)
  98917. }
  98918. ,
  98919. e.prototype.removeImpostor = function(e) {
  98920. var t = this._impostors.indexOf(e);
  98921. t > -1 && this._impostors.splice(t, 1).length && this.getPhysicsPlugin().removePhysicsBody(e)
  98922. }
  98923. ,
  98924. e.prototype.addJoint = function(e, t, i) {
  98925. var n = {
  98926. mainImpostor: e,
  98927. connectedImpostor: t,
  98928. joint: i
  98929. };
  98930. i.physicsPlugin = this._physicsPlugin,
  98931. this._joints.push(n),
  98932. this._physicsPlugin.generateJoint(n)
  98933. }
  98934. ,
  98935. e.prototype.removeJoint = function(e, t, i) {
  98936. var n = this._joints.filter((function(n) {
  98937. return n.connectedImpostor === t && n.joint === i && n.mainImpostor === e
  98938. }
  98939. ));
  98940. n.length && this._physicsPlugin.removeJoint(n[0])
  98941. }
  98942. ,
  98943. e.prototype._step = function(e) {
  98944. var t = this;
  98945. this._impostors.forEach((function(e) {
  98946. e.isBodyInitRequired() && t._physicsPlugin.generatePhysicsBody(e)
  98947. }
  98948. )),
  98949. e > .1 ? e = .1 : e <= 0 && (e = 1 / 60),
  98950. this._physicsPlugin.executeStep(e, this._impostors)
  98951. }
  98952. ,
  98953. e.prototype.getPhysicsPlugin = function() {
  98954. return this._physicsPlugin
  98955. }
  98956. ,
  98957. e.prototype.getImpostors = function() {
  98958. return this._impostors
  98959. }
  98960. ,
  98961. e.prototype.getImpostorForPhysicsObject = function(e) {
  98962. for (var t = 0; t < this._impostors.length; ++t)
  98963. if (this._impostors[t].object === e)
  98964. return this._impostors[t];
  98965. return null
  98966. }
  98967. ,
  98968. e.prototype.getImpostorWithPhysicsBody = function(e) {
  98969. for (var t = 0; t < this._impostors.length; ++t)
  98970. if (this._impostors[t].physicsBody === e)
  98971. return this._impostors[t];
  98972. return null
  98973. }
  98974. ,
  98975. e.prototype.raycast = function(e, t) {
  98976. return this._physicsPlugin.raycast(e, t)
  98977. }
  98978. ,
  98979. e.Epsilon = .001,
  98980. e
  98981. }()
  98982. , C_ = function() {
  98983. function e() {
  98984. this._hasHit = !1,
  98985. this._hitDistance = 0,
  98986. this._hitNormalWorld = x.Zero(),
  98987. this._hitPointWorld = x.Zero(),
  98988. this._rayFromWorld = x.Zero(),
  98989. this._rayToWorld = x.Zero()
  98990. }
  98991. return Object.defineProperty(e.prototype, "hasHit", {
  98992. get: function() {
  98993. return this._hasHit
  98994. },
  98995. enumerable: !1,
  98996. configurable: !0
  98997. }),
  98998. Object.defineProperty(e.prototype, "hitDistance", {
  98999. get: function() {
  99000. return this._hitDistance
  99001. },
  99002. enumerable: !1,
  99003. configurable: !0
  99004. }),
  99005. Object.defineProperty(e.prototype, "hitNormalWorld", {
  99006. get: function() {
  99007. return this._hitNormalWorld
  99008. },
  99009. enumerable: !1,
  99010. configurable: !0
  99011. }),
  99012. Object.defineProperty(e.prototype, "hitPointWorld", {
  99013. get: function() {
  99014. return this._hitPointWorld
  99015. },
  99016. enumerable: !1,
  99017. configurable: !0
  99018. }),
  99019. Object.defineProperty(e.prototype, "rayFromWorld", {
  99020. get: function() {
  99021. return this._rayFromWorld
  99022. },
  99023. enumerable: !1,
  99024. configurable: !0
  99025. }),
  99026. Object.defineProperty(e.prototype, "rayToWorld", {
  99027. get: function() {
  99028. return this._rayToWorld
  99029. },
  99030. enumerable: !1,
  99031. configurable: !0
  99032. }),
  99033. e.prototype.setHitData = function(e, t) {
  99034. this._hasHit = !0,
  99035. this._hitNormalWorld = new x(e.x,e.y,e.z),
  99036. this._hitPointWorld = new x(t.x,t.y,t.z)
  99037. }
  99038. ,
  99039. e.prototype.setHitDistance = function(e) {
  99040. this._hitDistance = e
  99041. }
  99042. ,
  99043. e.prototype.calculateHitDistance = function() {
  99044. this._hitDistance = x.Distance(this._rayFromWorld, this._hitPointWorld)
  99045. }
  99046. ,
  99047. e.prototype.reset = function(e, t) {
  99048. void 0 === e && (e = x.Zero()),
  99049. void 0 === t && (t = x.Zero()),
  99050. this._rayFromWorld = e,
  99051. this._rayToWorld = t,
  99052. this._hasHit = !1,
  99053. this._hitDistance = 0,
  99054. this._hitNormalWorld = x.Zero(),
  99055. this._hitPointWorld = x.Zero()
  99056. }
  99057. ,
  99058. e
  99059. }()
  99060. , P_ = function() {
  99061. function e(e, t, i) {
  99062. void 0 === e && (e = !0),
  99063. void 0 === t && (t = 10),
  99064. void 0 === i && (i = CANNON),
  99065. this._useDeltaForWorldStep = e,
  99066. this.name = "CannonJSPlugin",
  99067. this._physicsMaterials = new Array,
  99068. this._fixedTimeStep = 1 / 60,
  99069. this._physicsBodysToRemoveAfterStep = new Array,
  99070. this._firstFrame = !0,
  99071. this._tmpQuaternion = new C,
  99072. this._minus90X = new C(-.7071067811865475,0,0,.7071067811865475),
  99073. this._plus90X = new C(.7071067811865475,0,0,.7071067811865475),
  99074. this._tmpPosition = x.Zero(),
  99075. this._tmpDeltaPosition = x.Zero(),
  99076. this._tmpUnityRotation = new C,
  99077. this.BJSCANNON = i,
  99078. this.isSupported() ? (this._extendNamespace(),
  99079. this.world = new this.BJSCANNON.World,
  99080. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase,
  99081. this.world.solver.iterations = t,
  99082. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult,
  99083. this._raycastResult = new C_) : K.Error("CannonJS is not available. Please make sure you included the js file.")
  99084. }
  99085. return e.prototype.setGravity = function(e) {
  99086. var t = e;
  99087. this.world.gravity.set(t.x, t.y, t.z)
  99088. }
  99089. ,
  99090. e.prototype.setTimeStep = function(e) {
  99091. this._fixedTimeStep = e
  99092. }
  99093. ,
  99094. e.prototype.getTimeStep = function() {
  99095. return this._fixedTimeStep
  99096. }
  99097. ,
  99098. e.prototype.executeStep = function(e, t) {
  99099. if (this._firstFrame) {
  99100. this._firstFrame = !1;
  99101. for (var i = 0, n = t; i < n.length; i++) {
  99102. var r = n[i];
  99103. r.type != Vl.HeightmapImpostor && r.type !== Vl.PlaneImpostor && r.beforeStep()
  99104. }
  99105. }
  99106. this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep),
  99107. this._removeMarkedPhysicsBodiesFromWorld()
  99108. }
  99109. ,
  99110. e.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
  99111. var e = this;
  99112. this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach((function(t) {
  99113. "function" == typeof e.world.removeBody ? e.world.removeBody(t) : e.world.remove(t)
  99114. }
  99115. )),
  99116. this._physicsBodysToRemoveAfterStep = [])
  99117. }
  99118. ,
  99119. e.prototype.applyImpulse = function(e, t, i) {
  99120. var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
  99121. , r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
  99122. e.physicsBody.applyImpulse(r, n)
  99123. }
  99124. ,
  99125. e.prototype.applyForce = function(e, t, i) {
  99126. var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
  99127. , r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
  99128. e.physicsBody.applyForce(r, n)
  99129. }
  99130. ,
  99131. e.prototype.generatePhysicsBody = function(e) {
  99132. if (this._removeMarkedPhysicsBodiesFromWorld(),
  99133. e.parent)
  99134. e.physicsBody && (this.removePhysicsBody(e),
  99135. e.forceUpdate());
  99136. else {
  99137. if (e.isBodyInitRequired()) {
  99138. var t = this._createShape(e);
  99139. if (!t)
  99140. return void K.Warn("It was not possible to create a physics body for this object.");
  99141. var i = e.physicsBody;
  99142. i && this.removePhysicsBody(e);
  99143. var n = this._addMaterial("mat-" + e.uniqueId, e.getParam("friction"), e.getParam("restitution"))
  99144. , r = {
  99145. mass: e.getParam("mass"),
  99146. material: n
  99147. }
  99148. , o = e.getParam("nativeOptions");
  99149. for (var a in o)
  99150. Object.prototype.hasOwnProperty.call(o, a) && (r[a] = o[a]);
  99151. e.physicsBody = new this.BJSCANNON.Body(r),
  99152. e.physicsBody.addEventListener("collide", e.onCollide),
  99153. this.world.addEventListener("preStep", e.beforeStep),
  99154. this.world.addEventListener("postStep", e.afterStep),
  99155. e.physicsBody.addShape(t),
  99156. "function" == typeof this.world.addBody ? this.world.addBody(e.physicsBody) : this.world.add(e.physicsBody),
  99157. i && ["force", "torque", "velocity", "angularVelocity"].forEach((function(t) {
  99158. var n = i[t];
  99159. e.physicsBody[t].set(n.x, n.y, n.z)
  99160. }
  99161. )),
  99162. this._processChildMeshes(e)
  99163. }
  99164. this._updatePhysicsBodyTransformation(e)
  99165. }
  99166. }
  99167. ,
  99168. e.prototype._processChildMeshes = function(e) {
  99169. var t = this
  99170. , i = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []
  99171. , n = e.object.rotationQuaternion;
  99172. if (n ? n.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1),
  99173. i.length) {
  99174. var r = function(i) {
  99175. if (i.rotationQuaternion) {
  99176. var n = i.getPhysicsImpostor();
  99177. if (n && n.parent !== e && i.parent) {
  99178. var o = i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition())
  99179. , a = i.rotationQuaternion.multiply(t._tmpQuaternion);
  99180. n.physicsBody && (t.removePhysicsBody(n),
  99181. n.physicsBody = null),
  99182. n.parent = e,
  99183. n.resetUpdateFlags(),
  99184. e.physicsBody.addShape(t._createShape(n), new t.BJSCANNON.Vec3(o.x,o.y,o.z), new t.BJSCANNON.Quaternion(a.x,a.y,a.z,a.w)),
  99185. e.physicsBody.mass += n.getParam("mass")
  99186. }
  99187. i.getChildMeshes(!0).filter((function(e) {
  99188. return !!e.physicsImpostor
  99189. }
  99190. )).forEach(r)
  99191. }
  99192. };
  99193. i.filter((function(e) {
  99194. return !!e.physicsImpostor
  99195. }
  99196. )).forEach(r)
  99197. }
  99198. }
  99199. ,
  99200. e.prototype.removePhysicsBody = function(e) {
  99201. e.physicsBody.removeEventListener("collide", e.onCollide),
  99202. this.world.removeEventListener("preStep", e.beforeStep),
  99203. this.world.removeEventListener("postStep", e.afterStep),
  99204. -1 === this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody) && this._physicsBodysToRemoveAfterStep.push(e.physicsBody)
  99205. }
  99206. ,
  99207. e.prototype.generateJoint = function(e) {
  99208. var t = e.mainImpostor.physicsBody
  99209. , i = e.connectedImpostor.physicsBody;
  99210. if (t && i) {
  99211. var n, r = e.joint.jointData, o = {
  99212. pivotA: r.mainPivot ? (new this.BJSCANNON.Vec3).set(r.mainPivot.x, r.mainPivot.y, r.mainPivot.z) : null,
  99213. pivotB: r.connectedPivot ? (new this.BJSCANNON.Vec3).set(r.connectedPivot.x, r.connectedPivot.y, r.connectedPivot.z) : null,
  99214. axisA: r.mainAxis ? (new this.BJSCANNON.Vec3).set(r.mainAxis.x, r.mainAxis.y, r.mainAxis.z) : null,
  99215. axisB: r.connectedAxis ? (new this.BJSCANNON.Vec3).set(r.connectedAxis.x, r.connectedAxis.y, r.connectedAxis.z) : null,
  99216. maxForce: r.nativeParams.maxForce,
  99217. collideConnected: !!r.collision
  99218. };
  99219. switch (e.joint.type) {
  99220. case Ll.HingeJoint:
  99221. case Ll.Hinge2Joint:
  99222. n = new this.BJSCANNON.HingeConstraint(t,i,o);
  99223. break;
  99224. case Ll.DistanceJoint:
  99225. n = new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance || 2);
  99226. break;
  99227. case Ll.SpringJoint:
  99228. var a = r;
  99229. n = new this.BJSCANNON.Spring(t,i,{
  99230. restLength: a.length,
  99231. stiffness: a.stiffness,
  99232. damping: a.damping,
  99233. localAnchorA: o.pivotA,
  99234. localAnchorB: o.pivotB
  99235. });
  99236. break;
  99237. case Ll.LockJoint:
  99238. n = new this.BJSCANNON.LockConstraint(t,i,o);
  99239. break;
  99240. case Ll.PointToPointJoint:
  99241. case Ll.BallAndSocketJoint:
  99242. default:
  99243. n = new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)
  99244. }
  99245. n.collideConnected = !!r.collision,
  99246. e.joint.physicsJoint = n,
  99247. e.joint.type !== Ll.SpringJoint ? this.world.addConstraint(n) : (e.joint.jointData.forceApplicationCallback = e.joint.jointData.forceApplicationCallback || function() {
  99248. n.applyForce()
  99249. }
  99250. ,
  99251. e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))
  99252. }
  99253. }
  99254. ,
  99255. e.prototype.removeJoint = function(e) {
  99256. e.joint.type !== Ll.SpringJoint ? this.world.removeConstraint(e.joint.physicsJoint) : e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)
  99257. }
  99258. ,
  99259. e.prototype._addMaterial = function(e, t, i) {
  99260. var n, r;
  99261. for (n = 0; n < this._physicsMaterials.length; n++)
  99262. if ((r = this._physicsMaterials[n]).friction === t && r.restitution === i)
  99263. return r;
  99264. var o = new this.BJSCANNON.Material(e);
  99265. return o.friction = t,
  99266. o.restitution = i,
  99267. this._physicsMaterials.push(o),
  99268. o
  99269. }
  99270. ,
  99271. e.prototype._checkWithEpsilon = function(e) {
  99272. return e < R_.Epsilon ? R_.Epsilon : e
  99273. }
  99274. ,
  99275. e.prototype._createShape = function(e) {
  99276. var t, i = e.object, n = e.getObjectExtendSize();
  99277. switch (e.type) {
  99278. case Vl.SphereImpostor:
  99279. var r = n.x
  99280. , o = n.y
  99281. , a = n.z;
  99282. t = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(r), this._checkWithEpsilon(o), this._checkWithEpsilon(a)) / 2);
  99283. break;
  99284. case Vl.CylinderImpostor:
  99285. var s = e.getParam("nativeOptions");
  99286. s || (s = {});
  99287. var l = void 0 !== s.radiusTop ? s.radiusTop : this._checkWithEpsilon(n.x) / 2
  99288. , c = void 0 !== s.radiusBottom ? s.radiusBottom : this._checkWithEpsilon(n.x) / 2
  99289. , u = void 0 !== s.height ? s.height : this._checkWithEpsilon(n.y)
  99290. , h = void 0 !== s.numSegments ? s.numSegments : 16;
  99291. t = new this.BJSCANNON.Cylinder(l,c,u,h);
  99292. var d = new this.BJSCANNON.Quaternion;
  99293. d.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0), -Math.PI / 2);
  99294. var p = new this.BJSCANNON.Vec3(0,0,0);
  99295. t.transformAllPoints(p, d);
  99296. break;
  99297. case Vl.BoxImpostor:
  99298. var f = n.scale(.5);
  99299. t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(f.x),this._checkWithEpsilon(f.y),this._checkWithEpsilon(f.z)));
  99300. break;
  99301. case Vl.PlaneImpostor:
  99302. K.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),
  99303. t = new this.BJSCANNON.Plane;
  99304. break;
  99305. case Vl.MeshImpostor:
  99306. var _ = i.getVerticesData ? i.getVerticesData(Bi.PositionKind) : []
  99307. , m = i.getIndices ? i.getIndices() : [];
  99308. if (!_)
  99309. return void K.Warn("Tried to create a MeshImpostor for an object without vertices. This will fail.");
  99310. var g = i.position.clone()
  99311. , v = i.rotation && i.rotation.clone()
  99312. , y = i.rotationQuaternion && i.rotationQuaternion.clone();
  99313. i.position.copyFromFloats(0, 0, 0),
  99314. i.rotation && i.rotation.copyFromFloats(0, 0, 0),
  99315. i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
  99316. i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace();
  99317. var b = i.computeWorldMatrix(!0)
  99318. , T = new Array
  99319. , E = void 0;
  99320. for (E = 0; E < _.length; E += 3)
  99321. x.TransformCoordinates(x.FromArray(_, E), b).toArray(T, E);
  99322. K.Warn("MeshImpostor only collides against spheres."),
  99323. t = new this.BJSCANNON.Trimesh(T,m),
  99324. i.position.copyFrom(g),
  99325. v && i.rotation && i.rotation.copyFrom(v),
  99326. y && i.rotationQuaternion && i.rotationQuaternion.copyFrom(y);
  99327. break;
  99328. case Vl.HeightmapImpostor:
  99329. var S = i.position.clone()
  99330. , A = i.rotation && i.rotation.clone()
  99331. , R = i.rotationQuaternion && i.rotationQuaternion.clone();
  99332. i.position.copyFromFloats(0, 0, 0),
  99333. i.rotation && i.rotation.copyFromFloats(0, 0, 0),
  99334. i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
  99335. i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(),
  99336. i.rotationQuaternion && i.rotationQuaternion.multiplyInPlace(this._minus90X),
  99337. t = this._createHeightmap(i),
  99338. i.position.copyFrom(S),
  99339. A && i.rotation && i.rotation.copyFrom(A),
  99340. R && i.rotationQuaternion && i.rotationQuaternion.copyFrom(R),
  99341. i.computeWorldMatrix(!0);
  99342. break;
  99343. case Vl.ParticleImpostor:
  99344. t = new this.BJSCANNON.Particle;
  99345. break;
  99346. case Vl.NoImpostor:
  99347. t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))
  99348. }
  99349. return t
  99350. }
  99351. ,
  99352. e.prototype._createHeightmap = function(e, t) {
  99353. var i, n = e.getVerticesData(Bi.PositionKind), r = e.computeWorldMatrix(!0), o = new Array;
  99354. for (i = 0; i < n.length; i += 3)
  99355. x.TransformCoordinates(x.FromArray(n, i), r).toArray(o, i);
  99356. n = o;
  99357. for (var a = new Array, s = t || ~~(Math.sqrt(n.length / 3) - 1), l = e.getBoundingInfo(), c = Math.min(l.boundingBox.extendSizeWorld.x, l.boundingBox.extendSizeWorld.y), u = l.boundingBox.extendSizeWorld.z, h = 2 * c / s, d = 0; d < n.length; d += 3) {
  99358. var p = Math.round(n[d + 0] / h + s / 2)
  99359. , f = Math.round(-1 * (n[d + 1] / h - s / 2))
  99360. , _ = -n[d + 2] + u;
  99361. a[p] || (a[p] = []),
  99362. a[p][f] || (a[p][f] = _),
  99363. a[p][f] = Math.max(_, a[p][f])
  99364. }
  99365. for (p = 0; p <= s; ++p) {
  99366. if (!a[p]) {
  99367. for (var m = 1; !a[(p + m) % s]; )
  99368. m++;
  99369. a[p] = a[(p + m) % s].slice()
  99370. }
  99371. for (f = 0; f <= s; ++f)
  99372. if (!a[p][f]) {
  99373. m = 1;
  99374. for (var g = void 0; void 0 === g; )
  99375. g = a[p][(f + m++) % s];
  99376. a[p][f] = g
  99377. }
  99378. }
  99379. var v = new this.BJSCANNON.Heightfield(a,{
  99380. elementSize: h
  99381. });
  99382. return v.minY = u,
  99383. v
  99384. }
  99385. ,
  99386. e.prototype._updatePhysicsBodyTransformation = function(e) {
  99387. var t = e.object;
  99388. if (t.computeWorldMatrix && t.computeWorldMatrix(!0),
  99389. t.getBoundingInfo()) {
  99390. var i = e.getObjectCenter();
  99391. this._tmpDeltaPosition.copyFrom(t.getAbsolutePivotPoint().subtract(i)),
  99392. this._tmpDeltaPosition.divideInPlace(e.object.scaling),
  99393. this._tmpPosition.copyFrom(i);
  99394. var n = t.rotationQuaternion;
  99395. if (n) {
  99396. if (e.type !== Vl.PlaneImpostor && e.type !== Vl.HeightmapImpostor || (n = n.multiply(this._minus90X),
  99397. e.setDeltaRotation(this._plus90X)),
  99398. e.type === Vl.HeightmapImpostor) {
  99399. var r = t
  99400. , o = r.getBoundingInfo()
  99401. , a = r.rotationQuaternion;
  99402. r.rotationQuaternion = this._tmpUnityRotation,
  99403. r.computeWorldMatrix(!0);
  99404. var s = i.clone()
  99405. , l = r.getPivotMatrix();
  99406. l = l ? l.clone() : P.Identity();
  99407. var c = P.Translation(o.boundingBox.extendSizeWorld.x, 0, -o.boundingBox.extendSizeWorld.z);
  99408. r.setPreTransformMatrix(c),
  99409. r.computeWorldMatrix(!0);
  99410. var u = (o = r.getBoundingInfo()).boundingBox.centerWorld.subtract(i).subtract(r.position).negate();
  99411. this._tmpPosition.copyFromFloats(u.x, u.y - o.boundingBox.extendSizeWorld.y, u.z),
  99412. this._tmpDeltaPosition.copyFrom(o.boundingBox.centerWorld.subtract(s)),
  99413. this._tmpDeltaPosition.y += o.boundingBox.extendSizeWorld.y,
  99414. r.rotationQuaternion = a,
  99415. r.setPreTransformMatrix(l),
  99416. r.computeWorldMatrix(!0)
  99417. } else
  99418. e.type === Vl.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  99419. e.setDeltaPosition(this._tmpDeltaPosition),
  99420. e.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z),
  99421. e.physicsBody.quaternion.set(n.x, n.y, n.z, n.w)
  99422. }
  99423. }
  99424. }
  99425. ,
  99426. e.prototype.setTransformationFromPhysicsBody = function(e) {
  99427. if (e.object.position.set(e.physicsBody.position.x, e.physicsBody.position.y, e.physicsBody.position.z),
  99428. e.object.rotationQuaternion) {
  99429. var t = e.physicsBody.quaternion;
  99430. e.object.rotationQuaternion.set(t.x, t.y, t.z, t.w)
  99431. }
  99432. }
  99433. ,
  99434. e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
  99435. e.physicsBody.position.set(t.x, t.y, t.z),
  99436. e.physicsBody.quaternion.set(i.x, i.y, i.z, i.w)
  99437. }
  99438. ,
  99439. e.prototype.isSupported = function() {
  99440. return void 0 !== this.BJSCANNON
  99441. }
  99442. ,
  99443. e.prototype.setLinearVelocity = function(e, t) {
  99444. e.physicsBody.velocity.set(t.x, t.y, t.z)
  99445. }
  99446. ,
  99447. e.prototype.setAngularVelocity = function(e, t) {
  99448. e.physicsBody.angularVelocity.set(t.x, t.y, t.z)
  99449. }
  99450. ,
  99451. e.prototype.getLinearVelocity = function(e) {
  99452. var t = e.physicsBody.velocity;
  99453. return t ? new x(t.x,t.y,t.z) : null
  99454. }
  99455. ,
  99456. e.prototype.getAngularVelocity = function(e) {
  99457. var t = e.physicsBody.angularVelocity;
  99458. return t ? new x(t.x,t.y,t.z) : null
  99459. }
  99460. ,
  99461. e.prototype.setBodyMass = function(e, t) {
  99462. e.physicsBody.mass = t,
  99463. e.physicsBody.updateMassProperties()
  99464. }
  99465. ,
  99466. e.prototype.getBodyMass = function(e) {
  99467. return e.physicsBody.mass
  99468. }
  99469. ,
  99470. e.prototype.getBodyFriction = function(e) {
  99471. return e.physicsBody.material.friction
  99472. }
  99473. ,
  99474. e.prototype.setBodyFriction = function(e, t) {
  99475. e.physicsBody.material.friction = t
  99476. }
  99477. ,
  99478. e.prototype.getBodyRestitution = function(e) {
  99479. return e.physicsBody.material.restitution
  99480. }
  99481. ,
  99482. e.prototype.setBodyRestitution = function(e, t) {
  99483. e.physicsBody.material.restitution = t
  99484. }
  99485. ,
  99486. e.prototype.sleepBody = function(e) {
  99487. e.physicsBody.sleep()
  99488. }
  99489. ,
  99490. e.prototype.wakeUpBody = function(e) {
  99491. e.physicsBody.wakeUp()
  99492. }
  99493. ,
  99494. e.prototype.updateDistanceJoint = function(e, t) {
  99495. e.physicsJoint.distance = t
  99496. }
  99497. ,
  99498. e.prototype.setMotor = function(e, t, i, n) {
  99499. n || (e.physicsJoint.enableMotor(),
  99500. e.physicsJoint.setMotorSpeed(t),
  99501. i && this.setLimit(e, i))
  99502. }
  99503. ,
  99504. e.prototype.setLimit = function(e, t, i) {
  99505. e.physicsJoint.motorEquation.maxForce = t,
  99506. e.physicsJoint.motorEquation.minForce = void 0 === i ? -t : i
  99507. }
  99508. ,
  99509. e.prototype.syncMeshWithImpostor = function(e, t) {
  99510. var i = t.physicsBody;
  99511. e.position.x = i.position.x,
  99512. e.position.y = i.position.y,
  99513. e.position.z = i.position.z,
  99514. e.rotationQuaternion && (e.rotationQuaternion.x = i.quaternion.x,
  99515. e.rotationQuaternion.y = i.quaternion.y,
  99516. e.rotationQuaternion.z = i.quaternion.z,
  99517. e.rotationQuaternion.w = i.quaternion.w)
  99518. }
  99519. ,
  99520. e.prototype.getRadius = function(e) {
  99521. return e.physicsBody.shapes[0].boundingSphereRadius
  99522. }
  99523. ,
  99524. e.prototype.getBoxSizeToRef = function(e, t) {
  99525. var i = e.physicsBody.shapes[0];
  99526. t.x = 2 * i.halfExtents.x,
  99527. t.y = 2 * i.halfExtents.y,
  99528. t.z = 2 * i.halfExtents.z
  99529. }
  99530. ,
  99531. e.prototype.dispose = function() {}
  99532. ,
  99533. e.prototype._extendNamespace = function() {
  99534. var e = new this.BJSCANNON.Vec3
  99535. , t = this.BJSCANNON;
  99536. this.BJSCANNON.World.prototype.step = function(i, n, r) {
  99537. if (r = r || 10,
  99538. 0 === (n = n || 0))
  99539. this.internalStep(i),
  99540. this.time += i;
  99541. else {
  99542. var o = Math.floor((this.time + n) / i) - Math.floor(this.time / i);
  99543. o = Math.min(o, r) || 1;
  99544. for (var a = performance.now(), s = 0; s !== o && (this.internalStep(i),
  99545. !(performance.now() - a > 1e3 * i)); s++)
  99546. ;
  99547. this.time += n;
  99548. for (var l = this.time % i / i, c = e, u = this.bodies, h = 0; h !== u.length; h++) {
  99549. var d = u[h];
  99550. d.type !== t.Body.STATIC && d.sleepState !== t.Body.SLEEPING ? (d.position.vsub(d.previousPosition, c),
  99551. c.scale(l, c),
  99552. d.position.vadd(c, d.interpolatedPosition)) : (d.interpolatedPosition.set(d.position.x, d.position.y, d.position.z),
  99553. d.interpolatedQuaternion.set(d.quaternion.x, d.quaternion.y, d.quaternion.z, d.quaternion.w))
  99554. }
  99555. }
  99556. }
  99557. }
  99558. ,
  99559. e.prototype.raycast = function(e, t) {
  99560. return this._cannonRaycastResult.reset(),
  99561. this.world.raycastClosest(e, t, {}, this._cannonRaycastResult),
  99562. this._raycastResult.reset(e, t),
  99563. this._cannonRaycastResult.hasHit && (this._raycastResult.setHitData({
  99564. x: this._cannonRaycastResult.hitNormalWorld.x,
  99565. y: this._cannonRaycastResult.hitNormalWorld.y,
  99566. z: this._cannonRaycastResult.hitNormalWorld.z
  99567. }, {
  99568. x: this._cannonRaycastResult.hitPointWorld.x,
  99569. y: this._cannonRaycastResult.hitPointWorld.y,
  99570. z: this._cannonRaycastResult.hitPointWorld.z
  99571. }),
  99572. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),
  99573. this._raycastResult
  99574. }
  99575. ,
  99576. e
  99577. }();
  99578. R_.DefaultPluginFactory = function() {
  99579. return new P_
  99580. }
  99581. ;
  99582. var M_ = function() {
  99583. function e(e, t, i) {
  99584. void 0 === e && (e = !0),
  99585. void 0 === i && (i = OIMO),
  99586. this._useDeltaForWorldStep = e,
  99587. this.name = "OimoJSPlugin",
  99588. this._fixedTimeStep = 1 / 60,
  99589. this._tmpImpostorsArray = [],
  99590. this._tmpPositionVector = x.Zero(),
  99591. this.BJSOIMO = i,
  99592. this.world = new this.BJSOIMO.World({
  99593. iterations: t
  99594. }),
  99595. this.world.clear(),
  99596. this._raycastResult = new C_
  99597. }
  99598. return e.prototype.setGravity = function(e) {
  99599. this.world.gravity.set(e.x, e.y, e.z)
  99600. }
  99601. ,
  99602. e.prototype.setTimeStep = function(e) {
  99603. this.world.timeStep = e
  99604. }
  99605. ,
  99606. e.prototype.getTimeStep = function() {
  99607. return this.world.timeStep
  99608. }
  99609. ,
  99610. e.prototype.executeStep = function(e, t) {
  99611. var i = this;
  99612. t.forEach((function(e) {
  99613. e.beforeStep()
  99614. }
  99615. )),
  99616. this.world.timeStep = this._useDeltaForWorldStep ? e : this._fixedTimeStep,
  99617. this.world.step(),
  99618. t.forEach((function(e) {
  99619. e.afterStep(),
  99620. i._tmpImpostorsArray[e.uniqueId] = e
  99621. }
  99622. ));
  99623. for (var n = this.world.contacts; null !== n; )
  99624. if (!n.touching || n.body1.sleeping || n.body2.sleeping) {
  99625. var r = this._tmpImpostorsArray[+n.body1.name]
  99626. , o = this._tmpImpostorsArray[+n.body2.name];
  99627. r && o ? (r.onCollide({
  99628. body: o.physicsBody,
  99629. point: null
  99630. }),
  99631. o.onCollide({
  99632. body: r.physicsBody,
  99633. point: null
  99634. }),
  99635. n = n.next) : n = n.next
  99636. } else
  99637. n = n.next
  99638. }
  99639. ,
  99640. e.prototype.applyImpulse = function(e, t, i) {
  99641. var n = e.physicsBody.mass;
  99642. e.physicsBody.applyImpulse(i.scale(this.world.invScale), t.scale(this.world.invScale * n))
  99643. }
  99644. ,
  99645. e.prototype.applyForce = function(e, t, i) {
  99646. K.Warn("Oimo doesn't support applying force. Using impule instead."),
  99647. this.applyImpulse(e, t, i)
  99648. }
  99649. ,
  99650. e.prototype.generatePhysicsBody = function(e) {
  99651. var t = this;
  99652. if (e.parent)
  99653. e.physicsBody && (this.removePhysicsBody(e),
  99654. e.forceUpdate());
  99655. else {
  99656. if (e.isBodyInitRequired()) {
  99657. var i = {
  99658. name: e.uniqueId,
  99659. config: [e.getParam("mass") || .001, e.getParam("friction"), e.getParam("restitution")],
  99660. size: [],
  99661. type: [],
  99662. pos: [],
  99663. posShape: [],
  99664. rot: [],
  99665. rotShape: [],
  99666. move: 0 !== e.getParam("mass"),
  99667. density: e.getParam("mass"),
  99668. friction: e.getParam("friction"),
  99669. restitution: e.getParam("restitution"),
  99670. world: this.world
  99671. }
  99672. , n = [e];
  99673. (a = e.object).getChildMeshes && a.getChildMeshes().forEach((function(e) {
  99674. e.physicsImpostor && n.push(e.physicsImpostor)
  99675. }
  99676. ));
  99677. var r = function(e) {
  99678. return Math.max(e, R_.Epsilon)
  99679. }
  99680. , o = new C;
  99681. n.forEach((function(n) {
  99682. if (n.object.rotationQuaternion) {
  99683. var a = n.object.rotationQuaternion;
  99684. o.copyFrom(a),
  99685. n.object.rotationQuaternion.set(0, 0, 0, 1),
  99686. n.object.computeWorldMatrix(!0);
  99687. var s = o.toEulerAngles()
  99688. , l = n.getObjectExtendSize()
  99689. , c = 57.29577951308232;
  99690. if (n === e) {
  99691. var u = e.getObjectCenter();
  99692. e.object.getAbsolutePivotPoint().subtractToRef(u, t._tmpPositionVector),
  99693. t._tmpPositionVector.divideInPlace(e.object.scaling),
  99694. i.pos.push(u.x),
  99695. i.pos.push(u.y),
  99696. i.pos.push(u.z),
  99697. i.posShape.push(0, 0, 0),
  99698. i.rotShape.push(0, 0, 0)
  99699. } else {
  99700. var h = n.object.position.clone();
  99701. i.posShape.push(h.x),
  99702. i.posShape.push(h.y),
  99703. i.posShape.push(h.z),
  99704. i.rotShape.push(s.x * c, s.y * c, s.z * c)
  99705. }
  99706. switch (n.object.rotationQuaternion.copyFrom(o),
  99707. n.type) {
  99708. case Vl.ParticleImpostor:
  99709. K.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  99710. case Vl.SphereImpostor:
  99711. var d = l.x
  99712. , p = l.y
  99713. , f = l.z
  99714. , _ = Math.max(r(d), r(p), r(f)) / 2;
  99715. i.type.push("sphere"),
  99716. i.size.push(_),
  99717. i.size.push(_),
  99718. i.size.push(_);
  99719. break;
  99720. case Vl.CylinderImpostor:
  99721. var m = r(l.x) / 2
  99722. , g = r(l.y);
  99723. i.type.push("cylinder"),
  99724. i.size.push(m),
  99725. i.size.push(g),
  99726. i.size.push(g);
  99727. break;
  99728. case Vl.PlaneImpostor:
  99729. case Vl.BoxImpostor:
  99730. default:
  99731. m = r(l.x),
  99732. g = r(l.y);
  99733. var v = r(l.z);
  99734. i.type.push("box"),
  99735. i.size.push(m),
  99736. i.size.push(g),
  99737. i.size.push(v)
  99738. }
  99739. n.object.rotationQuaternion = a
  99740. }
  99741. }
  99742. )),
  99743. e.physicsBody = this.world.add(i),
  99744. e.physicsBody.resetQuaternion(o),
  99745. e.physicsBody.updatePosition(0)
  99746. } else
  99747. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  99748. var a;
  99749. e.setDeltaPosition(this._tmpPositionVector)
  99750. }
  99751. }
  99752. ,
  99753. e.prototype.removePhysicsBody = function(e) {
  99754. this.world.removeRigidBody(e.physicsBody)
  99755. }
  99756. ,
  99757. e.prototype.generateJoint = function(e) {
  99758. var t = e.mainImpostor.physicsBody
  99759. , i = e.connectedImpostor.physicsBody;
  99760. if (t && i) {
  99761. var n, r = e.joint.jointData, o = r.nativeParams || {}, a = {
  99762. body1: t,
  99763. body2: i,
  99764. axe1: o.axe1 || (r.mainAxis ? r.mainAxis.asArray() : null),
  99765. axe2: o.axe2 || (r.connectedAxis ? r.connectedAxis.asArray() : null),
  99766. pos1: o.pos1 || (r.mainPivot ? r.mainPivot.asArray() : null),
  99767. pos2: o.pos2 || (r.connectedPivot ? r.connectedPivot.asArray() : null),
  99768. min: o.min,
  99769. max: o.max,
  99770. collision: o.collision || r.collision,
  99771. spring: o.spring,
  99772. world: this.world
  99773. };
  99774. switch (e.joint.type) {
  99775. case Ll.BallAndSocketJoint:
  99776. n = "jointBall";
  99777. break;
  99778. case Ll.SpringJoint:
  99779. K.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  99780. var s = r;
  99781. a.min = s.length || a.min,
  99782. a.max = Math.max(a.min, a.max);
  99783. case Ll.DistanceJoint:
  99784. n = "jointDistance",
  99785. a.max = r.maxDistance;
  99786. break;
  99787. case Ll.PrismaticJoint:
  99788. n = "jointPrisme";
  99789. break;
  99790. case Ll.SliderJoint:
  99791. n = "jointSlide";
  99792. break;
  99793. case Ll.WheelJoint:
  99794. n = "jointWheel";
  99795. break;
  99796. case Ll.HingeJoint:
  99797. default:
  99798. n = "jointHinge"
  99799. }
  99800. a.type = n,
  99801. e.joint.physicsJoint = this.world.add(a)
  99802. }
  99803. }
  99804. ,
  99805. e.prototype.removeJoint = function(e) {
  99806. try {
  99807. this.world.removeJoint(e.joint.physicsJoint)
  99808. } catch (e) {
  99809. K.Warn(e)
  99810. }
  99811. }
  99812. ,
  99813. e.prototype.isSupported = function() {
  99814. return void 0 !== this.BJSOIMO
  99815. }
  99816. ,
  99817. e.prototype.setTransformationFromPhysicsBody = function(e) {
  99818. if (!e.physicsBody.sleeping) {
  99819. if (e.physicsBody.shapes.next) {
  99820. for (var t = e.physicsBody.shapes; t.next; )
  99821. t = t.next;
  99822. e.object.position.set(t.position.x, t.position.y, t.position.z)
  99823. } else {
  99824. var i = e.physicsBody.getPosition();
  99825. e.object.position.set(i.x, i.y, i.z)
  99826. }
  99827. if (e.object.rotationQuaternion) {
  99828. var n = e.physicsBody.getQuaternion();
  99829. e.object.rotationQuaternion.set(n.x, n.y, n.z, n.w)
  99830. }
  99831. }
  99832. }
  99833. ,
  99834. e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
  99835. var n = e.physicsBody;
  99836. e.physicsBody.shapes.next || (n.position.set(t.x, t.y, t.z),
  99837. n.orientation.set(i.x, i.y, i.z, i.w),
  99838. n.syncShapes(),
  99839. n.awake())
  99840. }
  99841. ,
  99842. e.prototype.setLinearVelocity = function(e, t) {
  99843. e.physicsBody.linearVelocity.set(t.x, t.y, t.z)
  99844. }
  99845. ,
  99846. e.prototype.setAngularVelocity = function(e, t) {
  99847. e.physicsBody.angularVelocity.set(t.x, t.y, t.z)
  99848. }
  99849. ,
  99850. e.prototype.getLinearVelocity = function(e) {
  99851. var t = e.physicsBody.linearVelocity;
  99852. return t ? new x(t.x,t.y,t.z) : null
  99853. }
  99854. ,
  99855. e.prototype.getAngularVelocity = function(e) {
  99856. var t = e.physicsBody.angularVelocity;
  99857. return t ? new x(t.x,t.y,t.z) : null
  99858. }
  99859. ,
  99860. e.prototype.setBodyMass = function(e, t) {
  99861. var i = 0 === t;
  99862. e.physicsBody.shapes.density = i ? 1 : t,
  99863. e.physicsBody.setupMass(i ? 2 : 1)
  99864. }
  99865. ,
  99866. e.prototype.getBodyMass = function(e) {
  99867. return e.physicsBody.shapes.density
  99868. }
  99869. ,
  99870. e.prototype.getBodyFriction = function(e) {
  99871. return e.physicsBody.shapes.friction
  99872. }
  99873. ,
  99874. e.prototype.setBodyFriction = function(e, t) {
  99875. e.physicsBody.shapes.friction = t
  99876. }
  99877. ,
  99878. e.prototype.getBodyRestitution = function(e) {
  99879. return e.physicsBody.shapes.restitution
  99880. }
  99881. ,
  99882. e.prototype.setBodyRestitution = function(e, t) {
  99883. e.physicsBody.shapes.restitution = t
  99884. }
  99885. ,
  99886. e.prototype.sleepBody = function(e) {
  99887. e.physicsBody.sleep()
  99888. }
  99889. ,
  99890. e.prototype.wakeUpBody = function(e) {
  99891. e.physicsBody.awake()
  99892. }
  99893. ,
  99894. e.prototype.updateDistanceJoint = function(e, t, i) {
  99895. e.physicsJoint.limitMotor.upperLimit = t,
  99896. void 0 !== i && (e.physicsJoint.limitMotor.lowerLimit = i)
  99897. }
  99898. ,
  99899. e.prototype.setMotor = function(e, t, i, n) {
  99900. void 0 !== i ? K.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : i = 1e6,
  99901. t *= -1;
  99902. var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
  99903. r && r.setMotor(t, i)
  99904. }
  99905. ,
  99906. e.prototype.setLimit = function(e, t, i, n) {
  99907. var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
  99908. r && r.setLimit(t, void 0 === i ? -t : i)
  99909. }
  99910. ,
  99911. e.prototype.syncMeshWithImpostor = function(e, t) {
  99912. var i = t.physicsBody;
  99913. e.position.x = i.position.x,
  99914. e.position.y = i.position.y,
  99915. e.position.z = i.position.z,
  99916. e.rotationQuaternion && (e.rotationQuaternion.x = i.orientation.x,
  99917. e.rotationQuaternion.y = i.orientation.y,
  99918. e.rotationQuaternion.z = i.orientation.z,
  99919. e.rotationQuaternion.w = i.orientation.s)
  99920. }
  99921. ,
  99922. e.prototype.getRadius = function(e) {
  99923. return e.physicsBody.shapes.radius
  99924. }
  99925. ,
  99926. e.prototype.getBoxSizeToRef = function(e, t) {
  99927. var i = e.physicsBody.shapes;
  99928. t.x = 2 * i.halfWidth,
  99929. t.y = 2 * i.halfHeight,
  99930. t.z = 2 * i.halfDepth
  99931. }
  99932. ,
  99933. e.prototype.dispose = function() {
  99934. this.world.clear()
  99935. }
  99936. ,
  99937. e.prototype.raycast = function(e, t) {
  99938. return K.Warn("raycast is not currently supported by the Oimo physics plugin"),
  99939. this._raycastResult.reset(e, t),
  99940. this._raycastResult
  99941. }
  99942. ,
  99943. e
  99944. }()
  99945. , I_ = function() {
  99946. function e(e, t, i) {
  99947. void 0 === e && (e = !0),
  99948. void 0 === t && (t = Ammo),
  99949. void 0 === i && (i = null);
  99950. var n = this;
  99951. this._useDeltaForWorldStep = e,
  99952. this.bjsAMMO = {},
  99953. this.name = "AmmoJSPlugin",
  99954. this._timeStep = 1 / 60,
  99955. this._fixedTimeStep = 1 / 60,
  99956. this._maxSteps = 5,
  99957. this._tmpQuaternion = new C,
  99958. this._tmpContactCallbackResult = !1,
  99959. this._tmpContactPoint = new x,
  99960. this._tmpVec3 = new x,
  99961. this._tmpMatrix = new P,
  99962. "function" != typeof t ? (this.bjsAMMO = t,
  99963. this.isSupported() ? (this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,
  99964. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),
  99965. this._overlappingPairCache = i || new this.bjsAMMO.btDbvtBroadphase,
  99966. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver,
  99967. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver,
  99968. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),
  99969. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback,
  99970. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function(e) {
  99971. var t = (e = n.bjsAMMO.wrapPointer(e, n.bjsAMMO.btManifoldPoint)).getPositionWorldOnA();
  99972. n._tmpContactPoint.x = t.x(),
  99973. n._tmpContactPoint.y = t.y(),
  99974. n._tmpContactPoint.z = t.z(),
  99975. n._tmpContactCallbackResult = !0
  99976. }
  99977. ,
  99978. this._raycastResult = new C_,
  99979. this._tmpAmmoTransform = new this.bjsAMMO.btTransform,
  99980. this._tmpAmmoTransform.setIdentity(),
  99981. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0,0,0,1),
  99982. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0,0,0),
  99983. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0,0,0),
  99984. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0,0,0),
  99985. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0,0,0)) : K.Error("AmmoJS is not available. Please make sure you included the js file.")) : K.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")
  99986. }
  99987. return e.prototype.setGravity = function(e) {
  99988. this._tmpAmmoVectorA.setValue(e.x, e.y, e.z),
  99989. this.world.setGravity(this._tmpAmmoVectorA),
  99990. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)
  99991. }
  99992. ,
  99993. e.prototype.setTimeStep = function(e) {
  99994. this._timeStep = e
  99995. }
  99996. ,
  99997. e.prototype.setFixedTimeStep = function(e) {
  99998. this._fixedTimeStep = e
  99999. }
  100000. ,
  100001. e.prototype.setMaxSteps = function(e) {
  100002. this._maxSteps = e
  100003. }
  100004. ,
  100005. e.prototype.getTimeStep = function() {
  100006. return this._timeStep
  100007. }
  100008. ,
  100009. e.prototype._isImpostorInContact = function(e) {
  100010. return this._tmpContactCallbackResult = !1,
  100011. this.world.contactTest(e.physicsBody, this._tmpAmmoConcreteContactResultCallback),
  100012. this._tmpContactCallbackResult
  100013. }
  100014. ,
  100015. e.prototype._isImpostorPairInContact = function(e, t) {
  100016. return this._tmpContactCallbackResult = !1,
  100017. this.world.contactPairTest(e.physicsBody, t.physicsBody, this._tmpAmmoConcreteContactResultCallback),
  100018. this._tmpContactCallbackResult
  100019. }
  100020. ,
  100021. e.prototype._stepSimulation = function(e, t, i) {
  100022. if (void 0 === e && (e = 1 / 60),
  100023. void 0 === t && (t = 10),
  100024. void 0 === i && (i = 1 / 60),
  100025. 0 == t)
  100026. this.world.stepSimulation(e, 0);
  100027. else
  100028. for (; t > 0 && e > 0; )
  100029. e - i < i ? (this.world.stepSimulation(e, 0),
  100030. e = 0) : (e -= i,
  100031. this.world.stepSimulation(i, 0)),
  100032. t--
  100033. }
  100034. ,
  100035. e.prototype.executeStep = function(e, t) {
  100036. for (var i = 0, n = t; i < n.length; i++) {
  100037. var r = n[i];
  100038. r.soft || r.beforeStep()
  100039. }
  100040. this._stepSimulation(this._useDeltaForWorldStep ? e : this._timeStep, this._maxSteps, this._fixedTimeStep);
  100041. for (var o = 0, a = t; o < a.length; o++) {
  100042. var s = a[o];
  100043. if (s.soft ? this._afterSoftStep(s) : s.afterStep(),
  100044. s._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(s))
  100045. for (var l = 0, c = s._onPhysicsCollideCallbacks; l < c.length; l++)
  100046. for (var u = 0, h = c[l].otherImpostors; u < h.length; u++) {
  100047. var d = h[u];
  100048. (s.physicsBody.isActive() || d.physicsBody.isActive()) && this._isImpostorPairInContact(s, d) && (s.onCollide({
  100049. body: d.physicsBody,
  100050. point: this._tmpContactPoint
  100051. }),
  100052. d.onCollide({
  100053. body: s.physicsBody,
  100054. point: this._tmpContactPoint
  100055. }))
  100056. }
  100057. }
  100058. }
  100059. ,
  100060. e.prototype._afterSoftStep = function(e) {
  100061. e.type === Vl.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e)
  100062. }
  100063. ,
  100064. e.prototype._ropeStep = function(e) {
  100065. for (var t, i, n, r, o = e.physicsBody.get_m_nodes(), a = o.size(), s = new Array, l = 0; l < a; l++)
  100066. i = (t = o.at(l).get_m_x()).x(),
  100067. n = t.y(),
  100068. r = t.z(),
  100069. s.push(new x(i,n,r));
  100070. var c = e.object
  100071. , u = e.getParam("shape");
  100072. e._isFromLine ? e.object = Jl("lines", {
  100073. points: s,
  100074. instance: c
  100075. }) : e.object = oc("ext", {
  100076. shape: u,
  100077. path: s,
  100078. instance: c
  100079. })
  100080. }
  100081. ,
  100082. e.prototype._softbodyOrClothStep = function(e) {
  100083. var t = e.type === Vl.ClothImpostor ? 1 : -1
  100084. , i = e.object
  100085. , n = i.getVerticesData(Bi.PositionKind);
  100086. n || (n = []);
  100087. var r = i.getVerticesData(Bi.NormalKind);
  100088. r || (r = []);
  100089. for (var o, a, s, l, c, u, h, d, p = n.length / 3, f = e.physicsBody.get_m_nodes(), _ = 0; _ < p; _++) {
  100090. s = (a = (o = f.at(_)).get_m_x()).x(),
  100091. l = a.y(),
  100092. c = a.z() * t;
  100093. var m = o.get_m_n();
  100094. u = m.x(),
  100095. h = m.y(),
  100096. d = m.z() * t,
  100097. n[3 * _] = s,
  100098. n[3 * _ + 1] = l,
  100099. n[3 * _ + 2] = c,
  100100. r[3 * _] = u,
  100101. r[3 * _ + 1] = h,
  100102. r[3 * _ + 2] = d
  100103. }
  100104. var g = new $n;
  100105. g.positions = n,
  100106. g.normals = r,
  100107. g.uvs = i.getVerticesData(Bi.UVKind),
  100108. g.colors = i.getVerticesData(Bi.ColorKind),
  100109. i && i.getIndices && (g.indices = i.getIndices()),
  100110. g.applyToMesh(i)
  100111. }
  100112. ,
  100113. e.prototype.applyImpulse = function(e, t, i) {
  100114. if (e.soft)
  100115. K.Warn("Cannot be applied to a soft body");
  100116. else {
  100117. e.physicsBody.activate();
  100118. var n = this._tmpAmmoVectorA
  100119. , r = this._tmpAmmoVectorB;
  100120. e.object && e.object.getWorldMatrix && i.subtractInPlace(e.object.getWorldMatrix().getTranslation()),
  100121. n.setValue(i.x, i.y, i.z),
  100122. r.setValue(t.x, t.y, t.z),
  100123. e.physicsBody.applyImpulse(r, n)
  100124. }
  100125. }
  100126. ,
  100127. e.prototype.applyForce = function(e, t, i) {
  100128. if (e.soft)
  100129. K.Warn("Cannot be applied to a soft body");
  100130. else {
  100131. e.physicsBody.activate();
  100132. var n = this._tmpAmmoVectorA
  100133. , r = this._tmpAmmoVectorB;
  100134. if (e.object && e.object.getWorldMatrix) {
  100135. var o = e.object.getWorldMatrix().getTranslation();
  100136. n.setValue(i.x - o.x, i.y - o.y, i.z - o.z)
  100137. } else
  100138. n.setValue(i.x, i.y, i.z);
  100139. r.setValue(t.x, t.y, t.z),
  100140. e.physicsBody.applyForce(r, n)
  100141. }
  100142. }
  100143. ,
  100144. e.prototype.generatePhysicsBody = function(t) {
  100145. if (t._pluginData.toDispose = [],
  100146. t.parent)
  100147. t.physicsBody && (this.removePhysicsBody(t),
  100148. t.forceUpdate());
  100149. else if (t.isBodyInitRequired()) {
  100150. var i = this._createShape(t)
  100151. , n = t.getParam("mass");
  100152. if (t._pluginData.mass = n,
  100153. t.soft)
  100154. i.get_m_cfg().set_collisions(17),
  100155. i.get_m_cfg().set_kDP(t.getParam("damping")),
  100156. this.bjsAMMO.castObject(i, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")),
  100157. i.setActivationState(e._DISABLE_DEACTIVATION_FLAG),
  100158. this.world.addSoftBody(i, 1, -1),
  100159. t.physicsBody = i,
  100160. t._pluginData.toDispose.push(i),
  100161. this.setBodyPressure(t, 0),
  100162. t.type === Vl.SoftbodyImpostor && this.setBodyPressure(t, t.getParam("pressure")),
  100163. this.setBodyStiffness(t, t.getParam("stiffness")),
  100164. this.setBodyVelocityIterations(t, t.getParam("velocityIterations")),
  100165. this.setBodyPositionIterations(t, t.getParam("positionIterations"));
  100166. else {
  100167. var r = new this.bjsAMMO.btVector3(0,0,0)
  100168. , o = new this.bjsAMMO.btTransform;
  100169. t.object.computeWorldMatrix(!0),
  100170. o.setIdentity(),
  100171. 0 !== n && i.calculateLocalInertia(n, r),
  100172. this._tmpAmmoVectorA.setValue(t.object.position.x, t.object.position.y, t.object.position.z),
  100173. this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x, t.object.rotationQuaternion.y, t.object.rotationQuaternion.z, t.object.rotationQuaternion.w),
  100174. o.setOrigin(this._tmpAmmoVectorA),
  100175. o.setRotation(this._tmpAmmoQuaternion);
  100176. var a = new this.bjsAMMO.btDefaultMotionState(o)
  100177. , s = new this.bjsAMMO.btRigidBodyConstructionInfo(n,a,i,r)
  100178. , l = new this.bjsAMMO.btRigidBody(s);
  100179. if (0 === n && (l.setCollisionFlags(l.getCollisionFlags() | e._KINEMATIC_FLAG),
  100180. l.setActivationState(e._DISABLE_DEACTIVATION_FLAG)),
  100181. t.type != Vl.NoImpostor || i.getChildShape || l.setCollisionFlags(l.getCollisionFlags() | e._DISABLE_COLLISION_FLAG),
  100182. t.type !== Vl.MeshImpostor && t.type !== Vl.NoImpostor) {
  100183. var c = t.object.getBoundingInfo();
  100184. this._tmpVec3.copyFrom(t.object.getAbsolutePosition()),
  100185. this._tmpVec3.subtractInPlace(c.boundingBox.centerWorld),
  100186. this._tmpVec3.x /= t.object.scaling.x,
  100187. this._tmpVec3.y /= t.object.scaling.y,
  100188. this._tmpVec3.z /= t.object.scaling.z,
  100189. t.setDeltaPosition(this._tmpVec3)
  100190. }
  100191. var u = t.getParam("group")
  100192. , h = t.getParam("mask");
  100193. u && h ? this.world.addRigidBody(l, u, h) : this.world.addRigidBody(l),
  100194. t.physicsBody = l,
  100195. t._pluginData.toDispose = t._pluginData.toDispose.concat([l, s, a, o, r, i])
  100196. }
  100197. this.setBodyRestitution(t, t.getParam("restitution")),
  100198. this.setBodyFriction(t, t.getParam("friction"))
  100199. }
  100200. }
  100201. ,
  100202. e.prototype.removePhysicsBody = function(e) {
  100203. var t = this;
  100204. this.world && (e.soft ? this.world.removeSoftBody(e.physicsBody) : this.world.removeRigidBody(e.physicsBody),
  100205. e._pluginData && (e._pluginData.toDispose.forEach((function(e) {
  100206. t.bjsAMMO.destroy(e)
  100207. }
  100208. )),
  100209. e._pluginData.toDispose = []))
  100210. }
  100211. ,
  100212. e.prototype.generateJoint = function(e) {
  100213. var t = e.mainImpostor.physicsBody
  100214. , i = e.connectedImpostor.physicsBody;
  100215. if (t && i) {
  100216. var n, r = e.joint.jointData;
  100217. switch (r.mainPivot || (r.mainPivot = new x(0,0,0)),
  100218. r.connectedPivot || (r.connectedPivot = new x(0,0,0)),
  100219. e.joint.type) {
  100220. case Ll.DistanceJoint:
  100221. var o = r.maxDistance;
  100222. o && (r.mainPivot = new x(0,-o / 2,0),
  100223. r.connectedPivot = new x(0,o / 2,0)),
  100224. n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
  100225. break;
  100226. case Ll.HingeJoint:
  100227. r.mainAxis || (r.mainAxis = new x(0,0,0)),
  100228. r.connectedAxis || (r.connectedAxis = new x(0,0,0));
  100229. var a = new this.bjsAMMO.btVector3(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z)
  100230. , s = new this.bjsAMMO.btVector3(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z);
  100231. n = new this.bjsAMMO.btHingeConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z),a,s);
  100232. break;
  100233. case Ll.BallAndSocketJoint:
  100234. n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
  100235. break;
  100236. default:
  100237. K.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),
  100238. n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z))
  100239. }
  100240. this.world.addConstraint(n, !e.joint.jointData.collision),
  100241. e.joint.physicsJoint = n
  100242. }
  100243. }
  100244. ,
  100245. e.prototype.removeJoint = function(e) {
  100246. this.world && this.world.removeConstraint(e.joint.physicsJoint)
  100247. }
  100248. ,
  100249. e.prototype._addMeshVerts = function(e, t, i) {
  100250. var n = this
  100251. , r = 0;
  100252. if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
  100253. var o = i.getIndices();
  100254. o || (o = []);
  100255. var a = i.getVerticesData(Bi.PositionKind);
  100256. a || (a = []);
  100257. var s = void 0;
  100258. if (t && t !== i) {
  100259. var l;
  100260. l = t.rotationQuaternion ? t.rotationQuaternion : t.rotation ? C.FromEulerAngles(t.rotation.x, t.rotation.y, t.rotation.z) : C.Identity(),
  100261. P.Compose(x.One(), l, t.position).invertToRef(this._tmpMatrix),
  100262. s = i.computeWorldMatrix(!1).multiply(this._tmpMatrix)
  100263. } else
  100264. P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix),
  100265. s = this._tmpMatrix;
  100266. for (var c = o.length / 3, u = 0; u < c; u++) {
  100267. for (var h = [], d = 0; d < 3; d++) {
  100268. var p = new x(a[3 * o[3 * u + d] + 0],a[3 * o[3 * u + d] + 1],a[3 * o[3 * u + d] + 2]);
  100269. p = x.TransformCoordinates(p, s);
  100270. var f = void 0;
  100271. (f = 0 == d ? this._tmpAmmoVectorA : 1 == d ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(p.x, p.y, p.z),
  100272. h.push(f)
  100273. }
  100274. e.addTriangle(h[0], h[1], h[2]),
  100275. r++
  100276. }
  100277. i.getChildMeshes().forEach((function(i) {
  100278. r += n._addMeshVerts(e, t, i)
  100279. }
  100280. ))
  100281. }
  100282. return r
  100283. }
  100284. ,
  100285. e.prototype._softVertexData = function(e) {
  100286. var t = e.object;
  100287. if (t && t.getIndices && t.getWorldMatrix && t.getChildMeshes) {
  100288. var i = t.getIndices();
  100289. i || (i = []);
  100290. var n = t.getVerticesData(Bi.PositionKind);
  100291. n || (n = []);
  100292. var r = t.getVerticesData(Bi.NormalKind);
  100293. r || (r = []),
  100294. t.computeWorldMatrix(!1);
  100295. for (var o = [], a = [], s = 0; s < n.length; s += 3) {
  100296. var l = new x(n[s],n[s + 1],n[s + 2])
  100297. , c = new x(r[s],r[s + 1],r[s + 2]);
  100298. l = x.TransformCoordinates(l, t.getWorldMatrix()),
  100299. c = x.TransformNormal(c, t.getWorldMatrix()),
  100300. o.push(l.x, l.y, l.z),
  100301. a.push(c.x, c.y, c.z)
  100302. }
  100303. var u = new $n;
  100304. return u.positions = o,
  100305. u.normals = a,
  100306. u.uvs = t.getVerticesData(Bi.UVKind),
  100307. u.colors = t.getVerticesData(Bi.ColorKind),
  100308. t && t.getIndices && (u.indices = t.getIndices()),
  100309. u.applyToMesh(t),
  100310. t.position = x.Zero(),
  100311. t.rotationQuaternion = null,
  100312. t.rotation = x.Zero(),
  100313. t.computeWorldMatrix(!0),
  100314. u
  100315. }
  100316. return $n.ExtractFromMesh(t)
  100317. }
  100318. ,
  100319. e.prototype._createSoftbody = function(e) {
  100320. var t = e.object;
  100321. if (t && t.getIndices) {
  100322. var i = t.getIndices();
  100323. i || (i = []);
  100324. var n = this._softVertexData(e)
  100325. , r = n.positions
  100326. , o = n.normals;
  100327. if (null === r || null === o)
  100328. return new this.bjsAMMO.btCompoundShape;
  100329. for (var a = [], s = [], l = 0; l < r.length; l += 3) {
  100330. var c = new x(r[l],r[l + 1],r[l + 2])
  100331. , u = new x(o[l],o[l + 1],o[l + 2]);
  100332. a.push(c.x, c.y, -c.z),
  100333. s.push(u.x, u.y, -u.z)
  100334. }
  100335. var h = (new this.bjsAMMO.btSoftBodyHelpers).CreateFromTriMesh(this.world.getWorldInfo(), a, t.getIndices(), i.length / 3, !0)
  100336. , d = r.length / 3
  100337. , p = h.get_m_nodes()
  100338. , f = void 0;
  100339. for (l = 0; l < d; l++)
  100340. (f = p.at(l).get_m_n()).setX(s[3 * l]),
  100341. f.setY(s[3 * l + 1]),
  100342. f.setZ(s[3 * l + 2]);
  100343. return h
  100344. }
  100345. }
  100346. ,
  100347. e.prototype._createCloth = function(e) {
  100348. var t = e.object;
  100349. if (t && t.getIndices) {
  100350. var i = t.getIndices();
  100351. i || (i = []);
  100352. var n = this._softVertexData(e)
  100353. , r = n.positions
  100354. , o = n.normals;
  100355. if (null === r || null === o)
  100356. return new this.bjsAMMO.btCompoundShape;
  100357. var a = r.length
  100358. , s = Math.sqrt(a / 3);
  100359. e.segments = s;
  100360. var l = s - 1;
  100361. return this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
  100362. this._tmpAmmoVectorB.setValue(r[3 * l], r[3 * l + 1], r[3 * l + 2]),
  100363. this._tmpAmmoVectorD.setValue(r[a - 3], r[a - 2], r[a - 1]),
  100364. this._tmpAmmoVectorC.setValue(r[a - 3 - 3 * l], r[a - 2 - 3 * l], r[a - 1 - 3 * l]),
  100365. (new this.bjsAMMO.btSoftBodyHelpers).CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, s, s, e.getParam("fixedPoints"), !0)
  100366. }
  100367. }
  100368. ,
  100369. e.prototype._createRope = function(e) {
  100370. var t, i, n = this._softVertexData(e), r = n.positions, o = n.normals;
  100371. if (null === r || null === o)
  100372. return new this.bjsAMMO.btCompoundShape;
  100373. if (n.applyToMesh(e.object, !0),
  100374. e._isFromLine = !0,
  100375. 0 === o.map((function(e) {
  100376. return e * e
  100377. }
  100378. )).reduce((function(e, t) {
  100379. return e + t
  100380. }
  100381. )))
  100382. i = (t = r.length) / 3 - 1,
  100383. this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
  100384. this._tmpAmmoVectorB.setValue(r[t - 3], r[t - 2], r[t - 1]);
  100385. else {
  100386. e._isFromLine = !1;
  100387. var a = e.getParam("path");
  100388. if (null === e.getParam("shape"))
  100389. return K.Warn("No shape available for extruded mesh"),
  100390. new this.bjsAMMO.btCompoundShape;
  100391. i = (t = a.length) - 1,
  100392. this._tmpAmmoVectorA.setValue(a[0].x, a[0].y, a[0].z),
  100393. this._tmpAmmoVectorB.setValue(a[t - 1].x, a[t - 1].y, a[t - 1].z)
  100394. }
  100395. e.segments = i;
  100396. var s = e.getParam("fixedPoints");
  100397. s = s > 3 ? 3 : s;
  100398. var l = (new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, i - 1, s);
  100399. return l.get_m_cfg().set_collisions(17),
  100400. l
  100401. }
  100402. ,
  100403. e.prototype._createCustom = function(e) {
  100404. var t = null;
  100405. return this.onCreateCustomShape && (t = this.onCreateCustomShape(e)),
  100406. null == t && (t = new this.bjsAMMO.btCompoundShape),
  100407. t
  100408. }
  100409. ,
  100410. e.prototype._addHullVerts = function(e, t, i) {
  100411. var n = this
  100412. , r = 0;
  100413. if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
  100414. var o = i.getIndices();
  100415. o || (o = []);
  100416. var a = i.getVerticesData(Bi.PositionKind);
  100417. a || (a = []),
  100418. i.computeWorldMatrix(!1);
  100419. for (var s = o.length / 3, l = 0; l < s; l++) {
  100420. for (var c = [], u = 0; u < 3; u++) {
  100421. var h = new x(a[3 * o[3 * l + u] + 0],a[3 * o[3 * l + u] + 1],a[3 * o[3 * l + u] + 2]);
  100422. P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix),
  100423. h = x.TransformCoordinates(h, this._tmpMatrix);
  100424. var d = void 0;
  100425. (d = 0 == u ? this._tmpAmmoVectorA : 1 == u ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(h.x, h.y, h.z),
  100426. c.push(d)
  100427. }
  100428. e.addPoint(c[0], !0),
  100429. e.addPoint(c[1], !0),
  100430. e.addPoint(c[2], !0),
  100431. r++
  100432. }
  100433. i.getChildMeshes().forEach((function(i) {
  100434. r += n._addHullVerts(e, t, i)
  100435. }
  100436. ))
  100437. }
  100438. return r
  100439. }
  100440. ,
  100441. e.prototype._createShape = function(e, t) {
  100442. var i = this;
  100443. void 0 === t && (t = !1);
  100444. var n, r = e.object, o = e.getObjectExtendSize();
  100445. if (!t) {
  100446. var a = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : [];
  100447. n = new this.bjsAMMO.btCompoundShape;
  100448. var s = 0;
  100449. if (a.forEach((function(e) {
  100450. var t = e.getPhysicsImpostor();
  100451. if (t) {
  100452. if (t.type == Vl.MeshImpostor)
  100453. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  100454. var r = i._createShape(t)
  100455. , o = e.parent.getWorldMatrix().clone()
  100456. , a = new x;
  100457. o.decompose(a),
  100458. i._tmpAmmoTransform.getOrigin().setValue(e.position.x * a.x, e.position.y * a.y, e.position.z * a.z),
  100459. i._tmpAmmoQuaternion.setValue(e.rotationQuaternion.x, e.rotationQuaternion.y, e.rotationQuaternion.z, e.rotationQuaternion.w),
  100460. i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion),
  100461. n.addChildShape(i._tmpAmmoTransform, r),
  100462. t.dispose(),
  100463. s++
  100464. }
  100465. }
  100466. )),
  100467. s > 0) {
  100468. if (e.type != Vl.NoImpostor) {
  100469. var l = this._createShape(e, !0);
  100470. l && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0),
  100471. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1),
  100472. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),
  100473. n.addChildShape(this._tmpAmmoTransform, l))
  100474. }
  100475. return n
  100476. }
  100477. this.bjsAMMO.destroy(n),
  100478. n = null
  100479. }
  100480. switch (e.type) {
  100481. case Vl.SphereImpostor:
  100482. if (d.WithinEpsilon(o.x, o.y, 1e-4) && d.WithinEpsilon(o.x, o.z, 1e-4))
  100483. n = new this.bjsAMMO.btSphereShape(o.x / 2);
  100484. else {
  100485. var c = [new this.bjsAMMO.btVector3(0,0,0)];
  100486. (n = new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x / 2,o.y / 2,o.z / 2))
  100487. }
  100488. break;
  100489. case Vl.CapsuleImpostor:
  100490. var u = o.x / 2;
  100491. n = new this.bjsAMMO.btCapsuleShape(u,o.y - 2 * u);
  100492. break;
  100493. case Vl.CylinderImpostor:
  100494. this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
  100495. n = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
  100496. break;
  100497. case Vl.PlaneImpostor:
  100498. case Vl.BoxImpostor:
  100499. this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
  100500. n = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
  100501. break;
  100502. case Vl.MeshImpostor:
  100503. if (0 == e.getParam("mass")) {
  100504. if (this.onCreateCustomMeshImpostor)
  100505. n = this.onCreateCustomMeshImpostor(e);
  100506. else {
  100507. var h = new this.bjsAMMO.btTriangleMesh;
  100508. e._pluginData.toDispose.push(h);
  100509. var p = this._addMeshVerts(h, r, r);
  100510. n = 0 == p ? new this.bjsAMMO.btCompoundShape : new this.bjsAMMO.btBvhTriangleMeshShape(h)
  100511. }
  100512. break
  100513. }
  100514. case Vl.ConvexHullImpostor:
  100515. if (this.onCreateCustomConvexHullImpostor)
  100516. n = this.onCreateCustomConvexHullImpostor(e);
  100517. else {
  100518. var f = new this.bjsAMMO.btConvexHullShape;
  100519. 0 == (p = this._addHullVerts(f, r, r)) ? (e._pluginData.toDispose.push(f),
  100520. n = new this.bjsAMMO.btCompoundShape) : n = f
  100521. }
  100522. break;
  100523. case Vl.NoImpostor:
  100524. n = new this.bjsAMMO.btSphereShape(o.x / 2);
  100525. break;
  100526. case Vl.CustomImpostor:
  100527. n = this._createCustom(e);
  100528. break;
  100529. case Vl.SoftbodyImpostor:
  100530. n = this._createSoftbody(e);
  100531. break;
  100532. case Vl.ClothImpostor:
  100533. n = this._createCloth(e);
  100534. break;
  100535. case Vl.RopeImpostor:
  100536. n = this._createRope(e);
  100537. break;
  100538. default:
  100539. K.Warn("The impostor type is not currently supported by the ammo plugin.")
  100540. }
  100541. return n
  100542. }
  100543. ,
  100544. e.prototype.setTransformationFromPhysicsBody = function(e) {
  100545. e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),
  100546. e.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z()),
  100547. e.object.rotationQuaternion ? e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()) : e.object.rotation && (this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()),
  100548. this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))
  100549. }
  100550. ,
  100551. e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
  100552. var n = e.physicsBody.getWorldTransform();
  100553. if (Math.abs(n.getOrigin().x() - t.x) > m || Math.abs(n.getOrigin().y() - t.y) > m || Math.abs(n.getOrigin().z() - t.z) > m || Math.abs(n.getRotation().x() - i.x) > m || Math.abs(n.getRotation().y() - i.y) > m || Math.abs(n.getRotation().z() - i.z) > m || Math.abs(n.getRotation().w() - i.w) > m)
  100554. if (this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
  100555. n.setOrigin(this._tmpAmmoVectorA),
  100556. this._tmpAmmoQuaternion.setValue(i.x, i.y, i.z, i.w),
  100557. n.setRotation(this._tmpAmmoQuaternion),
  100558. e.physicsBody.setWorldTransform(n),
  100559. 0 == e.mass) {
  100560. var r = e.physicsBody.getMotionState();
  100561. r && r.setWorldTransform(n)
  100562. } else
  100563. e.physicsBody.activate()
  100564. }
  100565. ,
  100566. e.prototype.isSupported = function() {
  100567. return void 0 !== this.bjsAMMO
  100568. }
  100569. ,
  100570. e.prototype.setLinearVelocity = function(e, t) {
  100571. this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
  100572. e.soft ? e.physicsBody.linearVelocity(this._tmpAmmoVectorA) : e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)
  100573. }
  100574. ,
  100575. e.prototype.setAngularVelocity = function(e, t) {
  100576. this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
  100577. e.soft ? e.physicsBody.angularVelocity(this._tmpAmmoVectorA) : e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)
  100578. }
  100579. ,
  100580. e.prototype.getLinearVelocity = function(e) {
  100581. var t;
  100582. if (!(t = e.soft ? e.physicsBody.linearVelocity() : e.physicsBody.getLinearVelocity()))
  100583. return null;
  100584. var i = new x(t.x(),t.y(),t.z());
  100585. return this.bjsAMMO.destroy(t),
  100586. i
  100587. }
  100588. ,
  100589. e.prototype.getAngularVelocity = function(e) {
  100590. var t;
  100591. if (!(t = e.soft ? e.physicsBody.angularVelocity() : e.physicsBody.getAngularVelocity()))
  100592. return null;
  100593. var i = new x(t.x(),t.y(),t.z());
  100594. return this.bjsAMMO.destroy(t),
  100595. i
  100596. }
  100597. ,
  100598. e.prototype.setBodyMass = function(e, t) {
  100599. e.soft ? e.physicsBody.setTotalMass(t, !1) : e.physicsBody.setMassProps(t),
  100600. e._pluginData.mass = t
  100601. }
  100602. ,
  100603. e.prototype.getBodyMass = function(e) {
  100604. return e._pluginData.mass || 0
  100605. }
  100606. ,
  100607. e.prototype.getBodyFriction = function(e) {
  100608. return e._pluginData.friction || 0
  100609. }
  100610. ,
  100611. e.prototype.setBodyFriction = function(e, t) {
  100612. e.soft ? e.physicsBody.get_m_cfg().set_kDF(t) : e.physicsBody.setFriction(t),
  100613. e._pluginData.friction = t
  100614. }
  100615. ,
  100616. e.prototype.getBodyRestitution = function(e) {
  100617. return e._pluginData.restitution || 0
  100618. }
  100619. ,
  100620. e.prototype.setBodyRestitution = function(e, t) {
  100621. e.physicsBody.setRestitution(t),
  100622. e._pluginData.restitution = t
  100623. }
  100624. ,
  100625. e.prototype.getBodyPressure = function(e) {
  100626. return e.soft ? e._pluginData.pressure || 0 : (K.Warn("Pressure is not a property of a rigid body"),
  100627. 0)
  100628. }
  100629. ,
  100630. e.prototype.setBodyPressure = function(e, t) {
  100631. e.soft ? e.type === Vl.SoftbodyImpostor ? (e.physicsBody.get_m_cfg().set_kPR(t),
  100632. e._pluginData.pressure = t) : (e.physicsBody.get_m_cfg().set_kPR(0),
  100633. e._pluginData.pressure = 0) : K.Warn("Pressure can only be applied to a softbody")
  100634. }
  100635. ,
  100636. e.prototype.getBodyStiffness = function(e) {
  100637. return e.soft ? e._pluginData.stiffness || 0 : (K.Warn("Stiffness is not a property of a rigid body"),
  100638. 0)
  100639. }
  100640. ,
  100641. e.prototype.setBodyStiffness = function(e, t) {
  100642. e.soft ? (t = (t = t < 0 ? 0 : t) > 1 ? 1 : t,
  100643. e.physicsBody.get_m_materials().at(0).set_m_kLST(t),
  100644. e._pluginData.stiffness = t) : K.Warn("Stiffness cannot be applied to a rigid body")
  100645. }
  100646. ,
  100647. e.prototype.getBodyVelocityIterations = function(e) {
  100648. return e.soft ? e._pluginData.velocityIterations || 0 : (K.Warn("Velocity iterations is not a property of a rigid body"),
  100649. 0)
  100650. }
  100651. ,
  100652. e.prototype.setBodyVelocityIterations = function(e, t) {
  100653. e.soft ? (t = t < 0 ? 0 : t,
  100654. e.physicsBody.get_m_cfg().set_viterations(t),
  100655. e._pluginData.velocityIterations = t) : K.Warn("Velocity iterations cannot be applied to a rigid body")
  100656. }
  100657. ,
  100658. e.prototype.getBodyPositionIterations = function(e) {
  100659. return e.soft ? e._pluginData.positionIterations || 0 : (K.Warn("Position iterations is not a property of a rigid body"),
  100660. 0)
  100661. }
  100662. ,
  100663. e.prototype.setBodyPositionIterations = function(e, t) {
  100664. e.soft ? (t = t < 0 ? 0 : t,
  100665. e.physicsBody.get_m_cfg().set_piterations(t),
  100666. e._pluginData.positionIterations = t) : K.Warn("Position iterations cannot be applied to a rigid body")
  100667. }
  100668. ,
  100669. e.prototype.appendAnchor = function(e, t, i, n, r, o) {
  100670. void 0 === r && (r = 1),
  100671. void 0 === o && (o = !1);
  100672. var a = e.segments
  100673. , s = Math.round((a - 1) * i) + a * (a - 1 - Math.round((a - 1) * n));
  100674. e.physicsBody.appendAnchor(s, t.physicsBody, o, r)
  100675. }
  100676. ,
  100677. e.prototype.appendHook = function(e, t, i, n, r) {
  100678. void 0 === n && (n = 1),
  100679. void 0 === r && (r = !1);
  100680. var o = Math.round(e.segments * i);
  100681. e.physicsBody.appendAnchor(o, t.physicsBody, r, n)
  100682. }
  100683. ,
  100684. e.prototype.sleepBody = function(e) {
  100685. e.physicsBody.forceActivationState(0)
  100686. }
  100687. ,
  100688. e.prototype.wakeUpBody = function(e) {
  100689. e.physicsBody.activate()
  100690. }
  100691. ,
  100692. e.prototype.updateDistanceJoint = function() {
  100693. K.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")
  100694. }
  100695. ,
  100696. e.prototype.setMotor = function(e, t, i) {
  100697. e.physicsJoint.enableAngularMotor(!0, t, i)
  100698. }
  100699. ,
  100700. e.prototype.setLimit = function() {
  100701. K.Warn("setLimit is not currently supported by the Ammo physics plugin")
  100702. }
  100703. ,
  100704. e.prototype.syncMeshWithImpostor = function(e, t) {
  100705. t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),
  100706. e.position.x = this._tmpAmmoTransform.getOrigin().x(),
  100707. e.position.y = this._tmpAmmoTransform.getOrigin().y(),
  100708. e.position.z = this._tmpAmmoTransform.getOrigin().z(),
  100709. e.rotationQuaternion && (e.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x(),
  100710. e.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y(),
  100711. e.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z(),
  100712. e.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w())
  100713. }
  100714. ,
  100715. e.prototype.getRadius = function(e) {
  100716. return e.getObjectExtendSize().x / 2
  100717. }
  100718. ,
  100719. e.prototype.getBoxSizeToRef = function(e, t) {
  100720. var i = e.getObjectExtendSize();
  100721. t.x = i.x,
  100722. t.y = i.y,
  100723. t.z = i.z
  100724. }
  100725. ,
  100726. e.prototype.dispose = function() {
  100727. this.bjsAMMO.destroy(this.world),
  100728. this.bjsAMMO.destroy(this._solver),
  100729. this.bjsAMMO.destroy(this._overlappingPairCache),
  100730. this.bjsAMMO.destroy(this._dispatcher),
  100731. this.bjsAMMO.destroy(this._collisionConfiguration),
  100732. this.bjsAMMO.destroy(this._tmpAmmoVectorA),
  100733. this.bjsAMMO.destroy(this._tmpAmmoVectorB),
  100734. this.bjsAMMO.destroy(this._tmpAmmoVectorC),
  100735. this.bjsAMMO.destroy(this._tmpAmmoTransform),
  100736. this.bjsAMMO.destroy(this._tmpAmmoQuaternion),
  100737. this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),
  100738. this.world = null
  100739. }
  100740. ,
  100741. e.prototype.raycast = function(e, t) {
  100742. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(e.x,e.y,e.z),
  100743. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(t.x,t.y,t.z);
  100744. var i = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);
  100745. return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, i),
  100746. this._raycastResult.reset(e, t),
  100747. i.hasHit() && (this._raycastResult.setHitData({
  100748. x: i.get_m_hitNormalWorld().x(),
  100749. y: i.get_m_hitNormalWorld().y(),
  100750. z: i.get_m_hitNormalWorld().z()
  100751. }, {
  100752. x: i.get_m_hitPointWorld().x(),
  100753. y: i.get_m_hitPointWorld().y(),
  100754. z: i.get_m_hitPointWorld().z()
  100755. }),
  100756. this._raycastResult.calculateHitDistance()),
  100757. this.bjsAMMO.destroy(i),
  100758. this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),
  100759. this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),
  100760. this._raycastResult
  100761. }
  100762. ,
  100763. e._DISABLE_COLLISION_FLAG = 4,
  100764. e._KINEMATIC_FLAG = 2,
  100765. e._DISABLE_DEACTIVATION_FLAG = 4,
  100766. e
  100767. }();
  100768. o.prototype.removeReflectionProbe = function(e) {
  100769. if (!this.reflectionProbes)
  100770. return -1;
  100771. var t = this.reflectionProbes.indexOf(e);
  100772. return -1 !== t && this.reflectionProbes.splice(t, 1),
  100773. t
  100774. }
  100775. ,
  100776. o.prototype.addReflectionProbe = function(e) {
  100777. this.reflectionProbes || (this.reflectionProbes = []),
  100778. this.reflectionProbes.push(e)
  100779. }
  100780. ;
  100781. var O_ = function() {
  100782. function e(e, t, i, n, r, o) {
  100783. void 0 === n && (n = !0),
  100784. void 0 === r && (r = !1),
  100785. void 0 === o && (o = !1);
  100786. var s = this;
  100787. if (this.name = e,
  100788. this._viewMatrix = P.Identity(),
  100789. this._target = x.Zero(),
  100790. this._add = x.Zero(),
  100791. this._invertYAxis = !1,
  100792. this.position = x.Zero(),
  100793. this._parentContainer = null,
  100794. this._scene = i,
  100795. i.getEngine().supportsUniformBuffers) {
  100796. this._sceneUBOs = [];
  100797. for (var l = 0; l < 6; ++l)
  100798. this._sceneUBOs.push(i.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(e, '") face #').concat(l)))
  100799. }
  100800. this._scene.reflectionProbes || (this._scene.reflectionProbes = new Array),
  100801. this._scene.reflectionProbes.push(this);
  100802. var c = a.TEXTURETYPE_UNSIGNED_BYTE;
  100803. if (r) {
  100804. var u = this._scene.getEngine().getCaps();
  100805. u.textureHalfFloatRender ? c = a.TEXTURETYPE_HALF_FLOAT : u.textureFloatRender && (c = a.TEXTURETYPE_FLOAT)
  100806. }
  100807. this._renderTargetTexture = new ns(e,t,i,n,!0,c,!0),
  100808. this._renderTargetTexture.gammaSpace = !o;
  100809. var h, d = i.getEngine().useReverseDepthBuffer;
  100810. this._renderTargetTexture.onBeforeRenderObservable.add((function(e) {
  100811. switch (s._sceneUBOs && (i.setSceneUniformBuffer(s._sceneUBOs[e]),
  100812. i.getSceneUniformBuffer().unbindEffect()),
  100813. e) {
  100814. case 0:
  100815. s._add.copyFromFloats(1, 0, 0);
  100816. break;
  100817. case 1:
  100818. s._add.copyFromFloats(-1, 0, 0);
  100819. break;
  100820. case 2:
  100821. s._add.copyFromFloats(0, s._invertYAxis ? 1 : -1, 0);
  100822. break;
  100823. case 3:
  100824. s._add.copyFromFloats(0, s._invertYAxis ? -1 : 1, 0);
  100825. break;
  100826. case 4:
  100827. s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? -1 : 1);
  100828. break;
  100829. case 5:
  100830. s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? 1 : -1)
  100831. }
  100832. s._attachedMesh && s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),
  100833. s.position.addToRef(s._add, s._target);
  100834. var t = i.useRightHandedSystem ? P.LookAtRHToRef : P.LookAtLHToRef
  100835. , n = i.useRightHandedSystem ? P.PerspectiveFovRH : P.PerspectiveFovLH;
  100836. t(s.position, s._target, x.Up(), s._viewMatrix),
  100837. i.activeCamera && (s._projectionMatrix = n(Math.PI / 2, 1, d ? i.activeCamera.maxZ : i.activeCamera.minZ, d ? i.activeCamera.minZ : i.activeCamera.maxZ, s._scene.getEngine().isNDCHalfZRange),
  100838. i.setTransformMatrix(s._viewMatrix, s._projectionMatrix),
  100839. i.activeCamera.isRigCamera && !s._renderTargetTexture.activeCamera && (s._renderTargetTexture.activeCamera = i.activeCamera.rigParent || null)),
  100840. i._forcedViewPosition = s.position
  100841. }
  100842. )),
  100843. this._renderTargetTexture.onBeforeBindObservable.add((function() {
  100844. var t, n;
  100845. s._currentSceneUBO = i.getSceneUniformBuffer(),
  100846. null === (n = (t = i.getEngine())._debugPushGroup) || void 0 === n || n.call(t, "reflection probe generation for ".concat(e), 1),
  100847. h = s._scene.imageProcessingConfiguration.applyByPostProcess,
  100848. o && (i.imageProcessingConfiguration.applyByPostProcess = !0)
  100849. }
  100850. )),
  100851. this._renderTargetTexture.onAfterUnbindObservable.add((function() {
  100852. var e, t;
  100853. i.imageProcessingConfiguration.applyByPostProcess = h,
  100854. i._forcedViewPosition = null,
  100855. s._sceneUBOs && i.setSceneUniformBuffer(s._currentSceneUBO),
  100856. i.updateTransformMatrix(!0),
  100857. null === (t = (e = i.getEngine())._debugPopGroup) || void 0 === t || t.call(e, 1)
  100858. }
  100859. ))
  100860. }
  100861. return Object.defineProperty(e.prototype, "samples", {
  100862. get: function() {
  100863. return this._renderTargetTexture.samples
  100864. },
  100865. set: function(e) {
  100866. this._renderTargetTexture.samples = e
  100867. },
  100868. enumerable: !1,
  100869. configurable: !0
  100870. }),
  100871. Object.defineProperty(e.prototype, "refreshRate", {
  100872. get: function() {
  100873. return this._renderTargetTexture.refreshRate
  100874. },
  100875. set: function(e) {
  100876. this._renderTargetTexture.refreshRate = e
  100877. },
  100878. enumerable: !1,
  100879. configurable: !0
  100880. }),
  100881. e.prototype.getScene = function() {
  100882. return this._scene
  100883. }
  100884. ,
  100885. Object.defineProperty(e.prototype, "cubeTexture", {
  100886. get: function() {
  100887. return this._renderTargetTexture
  100888. },
  100889. enumerable: !1,
  100890. configurable: !0
  100891. }),
  100892. Object.defineProperty(e.prototype, "renderList", {
  100893. get: function() {
  100894. return this._renderTargetTexture.renderList
  100895. },
  100896. enumerable: !1,
  100897. configurable: !0
  100898. }),
  100899. e.prototype.attachToMesh = function(e) {
  100900. this._attachedMesh = e
  100901. }
  100902. ,
  100903. e.prototype.setRenderingAutoClearDepthStencil = function(e, t) {
  100904. this._renderTargetTexture.setRenderingAutoClearDepthStencil(e, t)
  100905. }
  100906. ,
  100907. e.prototype.dispose = function() {
  100908. var e = this._scene.reflectionProbes.indexOf(this);
  100909. if (-1 !== e && this._scene.reflectionProbes.splice(e, 1),
  100910. this._parentContainer) {
  100911. var t = this._parentContainer.reflectionProbes.indexOf(this);
  100912. t > -1 && this._parentContainer.reflectionProbes.splice(t, 1),
  100913. this._parentContainer = null
  100914. }
  100915. if (this._renderTargetTexture && (this._renderTargetTexture.dispose(),
  100916. this._renderTargetTexture = null),
  100917. this._sceneUBOs) {
  100918. for (var i = 0, n = this._sceneUBOs; i < n.length; i++)
  100919. n[i].dispose();
  100920. this._sceneUBOs = []
  100921. }
  100922. }
  100923. ,
  100924. e.prototype.toString = function(e) {
  100925. var t = "Name: " + this.name;
  100926. return e && (t += ", position: " + this.position.toString(),
  100927. this._attachedMesh && (t += ", attached mesh: " + this._attachedMesh.name)),
  100928. t
  100929. }
  100930. ,
  100931. e.prototype.getClassName = function() {
  100932. return "ReflectionProbe"
  100933. }
  100934. ,
  100935. e.prototype.serialize = function() {
  100936. var e = Ge.Serialize(this, this._renderTargetTexture.serialize());
  100937. return e.isReflectionProbe = !0,
  100938. e
  100939. }
  100940. ,
  100941. e.Parse = function(t, i, n) {
  100942. var r = null;
  100943. if (i.reflectionProbes)
  100944. for (var o = 0; o < i.reflectionProbes.length; o++) {
  100945. var a = i.reflectionProbes[o];
  100946. if (a.name === t.name) {
  100947. r = a;
  100948. break
  100949. }
  100950. }
  100951. return (r = Ge.Parse((function() {
  100952. return r || new e(t.name,t.renderTargetSize,i,t._generateMipMaps)
  100953. }
  100954. ), t, i, n)).cubeTexture._waitingRenderList = t.renderList,
  100955. t._attachedMesh && r.attachToMesh(i.getMeshById(t._attachedMesh)),
  100956. r
  100957. }
  100958. ,
  100959. k([Ne()], e.prototype, "_attachedMesh", void 0),
  100960. k([De()], e.prototype, "position", void 0),
  100961. e
  100962. }()
  100963. , D_ = !0
  100964. , N_ = function() {
  100965. function e() {}
  100966. return e.LoaderInjectedPhysicsEngine = void 0,
  100967. e
  100968. }()
  100969. , L_ = {}
  100970. , F_ = {}
  100971. , w_ = function(e, t, i, n) {
  100972. if (!t.materials)
  100973. return null;
  100974. for (var r = 0, o = t.materials.length; r < o; r++) {
  100975. var a = t.materials[r];
  100976. if (e(a))
  100977. return Or.Parse(a, i, n)
  100978. }
  100979. return null
  100980. }
  100981. , B_ = function(e, t) {
  100982. return e + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown")
  100983. }
  100984. , U_ = function(e, t) {
  100985. var i = t;
  100986. if (t._waitingData.lods) {
  100987. if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) {
  100988. var n = t._waitingData.lods.ids
  100989. , r = i.isEnabled(!1);
  100990. if (t._waitingData.lods.distances) {
  100991. var o = t._waitingData.lods.distances;
  100992. if (o.length >= n.length) {
  100993. var a = o.length > n.length ? o[o.length - 1] : 0;
  100994. i.setEnabled(!1);
  100995. for (var s = 0; s < n.length; s++) {
  100996. var l = n[s]
  100997. , c = e.getMeshById(l);
  100998. null != c && i.addLODLevel(o[s], c)
  100999. }
  101000. a > 0 && i.addLODLevel(a, null),
  101001. !0 === r && i.setEnabled(!0)
  101002. } else
  101003. gi.Warn("Invalid level of detail distances for " + t.name)
  101004. }
  101005. }
  101006. t._waitingData.lods = null
  101007. }
  101008. }
  101009. , V_ = function(e, t) {
  101010. return "number" != typeof e ? t.getLastEntryById(e) : L_[e]
  101011. }
  101012. , k_ = function(e, t) {
  101013. return "number" != typeof e ? t.getLastMaterialById(e, !0) : F_[e]
  101014. }
  101015. , G_ = function(e, t, i, n, r) {
  101016. void 0 === r && (r = !1);
  101017. var a = new zr(e)
  101018. , s = "importScene has failed JSON parse";
  101019. try {
  101020. var l = JSON.parse(t);
  101021. s = "";
  101022. var c = od.loggingLevel === od.DETAILED_LOGGING
  101023. , u = void 0
  101024. , h = void 0;
  101025. if (void 0 !== l.environmentTexture && null !== l.environmentTexture) {
  101026. var d = void 0 === l.isPBR || l.isPBR;
  101027. if (l.environmentTextureType && "BABYLON.HDRCubeTexture" === l.environmentTextureType) {
  101028. var p = l.environmentTextureSize ? l.environmentTextureSize : 128
  101029. , f = new E_((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e,p,!0,!d);
  101030. l.environmentTextureRotationY && (f.rotationY = l.environmentTextureRotationY),
  101031. e.environmentTexture = f
  101032. } else if (oe(l.environmentTexture, ".env")) {
  101033. var _ = new Bd((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e);
  101034. l.environmentTextureRotationY && (_.rotationY = l.environmentTextureRotationY),
  101035. e.environmentTexture = _
  101036. } else {
  101037. var m = Bd.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture, e);
  101038. l.environmentTextureRotationY && (m.rotationY = l.environmentTextureRotationY),
  101039. e.environmentTexture = m
  101040. }
  101041. if (!0 === l.createDefaultSkybox) {
  101042. var g = void 0 !== e.activeCamera && null !== e.activeCamera ? (e.activeCamera.maxZ - e.activeCamera.minZ) / 2 : 1e3
  101043. , v = l.skyboxBlurLevel || 0;
  101044. e.createDefaultSkybox(e.environmentTexture, d, g, v)
  101045. }
  101046. a.environmentTexture = e.environmentTexture
  101047. }
  101048. if (void 0 !== l.environmentIntensity && null !== l.environmentIntensity && (e.environmentIntensity = l.environmentIntensity),
  101049. void 0 !== l.lights && null !== l.lights)
  101050. for (u = 0,
  101051. h = l.lights.length; u < h; u++) {
  101052. var y = l.lights[u];
  101053. (ie = Cr.Parse(y, e)) && (L_[y.uniqueId] = ie,
  101054. a.lights.push(ie),
  101055. ie._parentContainer = a,
  101056. s += 0 === u ? "\n\tLights:" : "",
  101057. s += "\n\t\t" + ie.toString(c))
  101058. }
  101059. if (void 0 !== l.reflectionProbes && null !== l.reflectionProbes)
  101060. for (u = 0,
  101061. h = l.reflectionProbes.length; u < h; u++) {
  101062. var T = l.reflectionProbes[u]
  101063. , E = O_.Parse(T, e, i);
  101064. E && (a.reflectionProbes.push(E),
  101065. E._parentContainer = a,
  101066. s += 0 === u ? "\n\tReflection Probes:" : "",
  101067. s += "\n\t\t" + E.toString(c))
  101068. }
  101069. if (void 0 !== l.animations && null !== l.animations)
  101070. for (u = 0,
  101071. h = l.animations.length; u < h; u++) {
  101072. var S = l.animations[u]
  101073. , A = b("BABYLON.Animation");
  101074. if (A) {
  101075. var x = A.Parse(S);
  101076. e.animations.push(x),
  101077. a.animations.push(x),
  101078. s += 0 === u ? "\n\tAnimations:" : "",
  101079. s += "\n\t\t" + x.toString(c)
  101080. }
  101081. }
  101082. if (void 0 !== l.materials && null !== l.materials)
  101083. for (u = 0,
  101084. h = l.materials.length; u < h; u++) {
  101085. var R = l.materials[u]
  101086. , C = Or.Parse(R, e, i);
  101087. C && (F_[R.uniqueId || R.id] = C,
  101088. a.materials.push(C),
  101089. C._parentContainer = a,
  101090. s += 0 === u ? "\n\tMaterials:" : "",
  101091. s += "\n\t\t" + C.toString(c),
  101092. C.getActiveTextures().forEach((function(e) {
  101093. -1 == a.textures.indexOf(e) && (a.textures.push(e),
  101094. e._parentContainer = a)
  101095. }
  101096. )))
  101097. }
  101098. if (void 0 !== l.multiMaterials && null !== l.multiMaterials)
  101099. for (u = 0,
  101100. h = l.multiMaterials.length; u < h; u++) {
  101101. var P = l.multiMaterials[u]
  101102. , M = Dr.ParseMultiMaterial(P, e);
  101103. F_[P.uniqueId || P.id] = M,
  101104. a.multiMaterials.push(M),
  101105. M._parentContainer = a,
  101106. s += 0 === u ? "\n\tMultiMaterials:" : "",
  101107. s += "\n\t\t" + M.toString(c),
  101108. M.getActiveTextures().forEach((function(e) {
  101109. -1 == a.textures.indexOf(e) && (a.textures.push(e),
  101110. e._parentContainer = a)
  101111. }
  101112. ))
  101113. }
  101114. if (void 0 !== l.morphTargetManagers && null !== l.morphTargetManagers)
  101115. for (var I = 0, O = l.morphTargetManagers; I < O.length; I++) {
  101116. var D = O[I]
  101117. , N = x_.Parse(D, e);
  101118. a.morphTargetManagers.push(N),
  101119. N._parentContainer = a
  101120. }
  101121. if (void 0 !== l.skeletons && null !== l.skeletons)
  101122. for (u = 0,
  101123. h = l.skeletons.length; u < h; u++) {
  101124. var L = l.skeletons[u]
  101125. , F = Fo.Parse(L, e);
  101126. a.skeletons.push(F),
  101127. F._parentContainer = a,
  101128. s += 0 === u ? "\n\tSkeletons:" : "",
  101129. s += "\n\t\t" + F.toString(c)
  101130. }
  101131. var w = l.geometries;
  101132. if (null != w) {
  101133. var B = new Array
  101134. , U = w.vertexData;
  101135. if (null != U)
  101136. for (u = 0,
  101137. h = U.length; u < h; u++) {
  101138. var V = U[u];
  101139. B.push(fr.Parse(V, e, i))
  101140. }
  101141. B.forEach((function(e) {
  101142. e && (a.geometries.push(e),
  101143. e._parentContainer = a)
  101144. }
  101145. ))
  101146. }
  101147. if (void 0 !== l.transformNodes && null !== l.transformNodes)
  101148. for (u = 0,
  101149. h = l.transformNodes.length; u < h; u++) {
  101150. var k = l.transformNodes[u]
  101151. , G = yr.Parse(k, e, i);
  101152. L_[k.uniqueId] = G,
  101153. a.transformNodes.push(G),
  101154. G._parentContainer = a
  101155. }
  101156. if (void 0 !== l.meshes && null !== l.meshes)
  101157. for (u = 0,
  101158. h = l.meshes.length; u < h; u++) {
  101159. var z = l.meshes[u]
  101160. , W = Vr.Parse(z, e, i);
  101161. if (L_[z.uniqueId] = W,
  101162. a.meshes.push(W),
  101163. W._parentContainer = a,
  101164. W.hasInstances)
  101165. for (var H = 0, X = W.instances; H < X.length; H++) {
  101166. var j = X[H];
  101167. a.meshes.push(j),
  101168. j._parentContainer = a
  101169. }
  101170. s += 0 === u ? "\n\tMeshes:" : "",
  101171. s += "\n\t\t" + W.toString(c)
  101172. }
  101173. if (void 0 !== l.cameras && null !== l.cameras)
  101174. for (u = 0,
  101175. h = l.cameras.length; u < h; u++) {
  101176. var Y = l.cameras[u]
  101177. , Q = Rr.Parse(Y, e);
  101178. L_[Y.uniqueId] = Q,
  101179. a.cameras.push(Q),
  101180. Q._parentContainer = a,
  101181. s += 0 === u ? "\n\tCameras:" : "",
  101182. s += "\n\t\t" + Q.toString(c)
  101183. }
  101184. if (void 0 !== l.postProcesses && null !== l.postProcesses)
  101185. for (u = 0,
  101186. h = l.postProcesses.length; u < h; u++) {
  101187. var q = l.postProcesses[u]
  101188. , Z = Ba.Parse(q, e, i);
  101189. Z && (a.postProcesses.push(Z),
  101190. Z._parentContainer = a,
  101191. s += 0 === u ? "\nPostprocesses:" : "",
  101192. s += "\n\t\t" + Z.toString())
  101193. }
  101194. if (void 0 !== l.animationGroups && null !== l.animationGroups)
  101195. for (u = 0,
  101196. h = l.animationGroups.length; u < h; u++) {
  101197. var J = l.animationGroups[u]
  101198. , $ = Hn.Parse(J, e);
  101199. a.animationGroups.push($),
  101200. $._parentContainer = a,
  101201. s += 0 === u ? "\n\tAnimationGroups:" : "",
  101202. s += "\n\t\t" + $.toString(c)
  101203. }
  101204. for (u = 0,
  101205. h = e.cameras.length; u < h; u++)
  101206. null !== (Q = e.cameras[u])._waitingParentId && (Q.parent = V_(Q._waitingParentId, e),
  101207. Q._waitingParentId = null);
  101208. for (u = 0,
  101209. h = e.lights.length; u < h; u++)
  101210. (ie = e.lights[u]) && null !== ie._waitingParentId && (ie.parent = V_(ie._waitingParentId, e),
  101211. ie._waitingParentId = null);
  101212. for (u = 0,
  101213. h = e.transformNodes.length; u < h; u++) {
  101214. var ee = e.transformNodes[u];
  101215. null !== ee._waitingParentId && (ee.parent = V_(ee._waitingParentId, e),
  101216. ee._waitingParentId = null)
  101217. }
  101218. for (u = 0,
  101219. h = e.meshes.length; u < h; u++)
  101220. null !== (W = e.meshes[u])._waitingParentId && (W.parent = V_(W._waitingParentId, e),
  101221. W._waitingParentId = null),
  101222. W._waitingData.lods && U_(e, W);
  101223. for (e.multiMaterials.forEach((function(t) {
  101224. t._waitingSubMaterialsUniqueIds.forEach((function(i) {
  101225. t.subMaterials.push(k_(i, e))
  101226. }
  101227. )),
  101228. t._waitingSubMaterialsUniqueIds = []
  101229. }
  101230. )),
  101231. e.meshes.forEach((function(t) {
  101232. null !== t._waitingMaterialId && (t.material = k_(t._waitingMaterialId, e),
  101233. t._waitingMaterialId = null)
  101234. }
  101235. )),
  101236. u = 0,
  101237. h = e.skeletons.length; u < h; u++)
  101238. (F = e.skeletons[u])._hasWaitingData && (null != F.bones && F.bones.forEach((function(t) {
  101239. if (t._waitingTransformNodeId) {
  101240. var i = e.getLastEntryById(t._waitingTransformNodeId);
  101241. i && t.linkTransformNode(i),
  101242. t._waitingTransformNodeId = null
  101243. }
  101244. }
  101245. )),
  101246. F._hasWaitingData = null);
  101247. for (u = 0,
  101248. h = e.meshes.length; u < h; u++) {
  101249. var te = e.meshes[u];
  101250. te._waitingData.freezeWorldMatrix ? (te.freezeWorldMatrix(),
  101251. te._waitingData.freezeWorldMatrix = null) : te.computeWorldMatrix(!0)
  101252. }
  101253. for (u = 0,
  101254. h = e.lights.length; u < h; u++) {
  101255. var ie;
  101256. if ((ie = e.lights[u])._excludedMeshesIds.length > 0) {
  101257. for (var ne = 0; ne < ie._excludedMeshesIds.length; ne++) {
  101258. var re = e.getMeshById(ie._excludedMeshesIds[ne]);
  101259. re && ie.excludedMeshes.push(re)
  101260. }
  101261. ie._excludedMeshesIds = []
  101262. }
  101263. if (ie._includedOnlyMeshesIds.length > 0) {
  101264. for (var ae = 0; ae < ie._includedOnlyMeshesIds.length; ae++) {
  101265. var se = e.getMeshById(ie._includedOnlyMeshesIds[ae]);
  101266. se && ie.includedOnlyMeshes.push(se)
  101267. }
  101268. ie._includedOnlyMeshesIds = []
  101269. }
  101270. }
  101271. for (o.Parse(l, e, a, i),
  101272. u = 0,
  101273. h = e.meshes.length; u < h; u++)
  101274. (W = e.meshes[u])._waitingData.actions && (_e.Parse(W._waitingData.actions, W, e),
  101275. W._waitingData.actions = null);
  101276. void 0 !== l.actions && null !== l.actions && _e.Parse(l.actions, null, e)
  101277. } catch (e) {
  101278. var le = B_("loadAssets", l ? l.producer : "Unknown") + s;
  101279. if (!n)
  101280. throw K.Log(le),
  101281. e;
  101282. n(le, e)
  101283. } finally {
  101284. L_ = {},
  101285. r || a.removeAllFromScene(),
  101286. null !== s && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("loadAssets", l ? l.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? s : ""))
  101287. }
  101288. return a
  101289. };
  101290. od.RegisterPlugin({
  101291. name: "babylon.js",
  101292. extensions: ".babylon",
  101293. canDirectLoad: function(e) {
  101294. return -1 !== e.indexOf("babylon")
  101295. },
  101296. importMesh: function(e, t, i, n, r, a, s, l) {
  101297. var c, u = "importMesh has failed JSON parse";
  101298. try {
  101299. var h = JSON.parse(i);
  101300. u = "";
  101301. var d = od.loggingLevel === od.DETAILED_LOGGING;
  101302. e ? Array.isArray(e) || (e = [e]) : e = null;
  101303. var p = new Array
  101304. , f = [];
  101305. if (void 0 !== h.transformNodes && null !== h.transformNodes)
  101306. for (var _ = 0, m = h.transformNodes.length; _ < m; _++) {
  101307. var g = h.transformNodes[_];
  101308. f.push(yr.Parse(g, t, n))
  101309. }
  101310. if (void 0 !== h.meshes && null !== h.meshes) {
  101311. var v = []
  101312. , y = []
  101313. , b = []
  101314. , T = []
  101315. , E = function(i, o) {
  101316. var a = h.meshes[i];
  101317. if (null === e || function(e, t, i) {
  101318. for (var n in t)
  101319. if (e.name === t[n])
  101320. return i.push(e.id),
  101321. !0;
  101322. return void 0 !== e.parentId && -1 !== i.indexOf(e.parentId) && (i.push(e.id),
  101323. !0)
  101324. }(a, e, p)) {
  101325. if (null !== e && delete e[e.indexOf(a.name)],
  101326. void 0 !== a.geometryId && null !== a.geometryId && void 0 !== h.geometries && null !== h.geometries) {
  101327. var l = !1;
  101328. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach((function(e) {
  101329. !0 !== l && h.geometries[e] && Array.isArray(h.geometries[e]) && h.geometries[e].forEach((function(i) {
  101330. i.id === a.geometryId && ("vertexData" === e && fr.Parse(i, t, n),
  101331. l = !0)
  101332. }
  101333. ))
  101334. }
  101335. )),
  101336. !1 === l && K.Warn("Geometry not found for mesh " + a.id)
  101337. }
  101338. if (a.materialUniqueId || a.materialId) {
  101339. var c = a.materialUniqueId ? b : y
  101340. , f = -1 !== c.indexOf(a.materialUniqueId || a.materialId);
  101341. if (!1 === f && void 0 !== h.multiMaterials && null !== h.multiMaterials)
  101342. for (var _ = function(e, i) {
  101343. c.push(e);
  101344. var r = w_(i, h, t, n);
  101345. r && (u += "\n\tMaterial " + r.toString(d))
  101346. }, m = 0, g = h.multiMaterials.length; m < g; m++) {
  101347. var E = h.multiMaterials[m];
  101348. if (a.materialUniqueId && E.uniqueId === a.materialUniqueId || E.id === a.materialId) {
  101349. E.materialsUniqueIds ? E.materialsUniqueIds.forEach((function(e) {
  101350. return _(e, (function(t) {
  101351. return t.uniqueId === e
  101352. }
  101353. ))
  101354. }
  101355. )) : E.materials.forEach((function(e) {
  101356. return _(e, (function(t) {
  101357. return t.id === e
  101358. }
  101359. ))
  101360. }
  101361. )),
  101362. c.push(E.uniqueId || E.id);
  101363. var S = Dr.ParseMultiMaterial(E, t);
  101364. F_[E.uniqueId || E.id] = S,
  101365. S && (f = !0,
  101366. u += "\n\tMulti-Material " + S.toString(d));
  101367. break
  101368. }
  101369. }
  101370. if (!1 === f) {
  101371. c.push(a.materialUniqueId || a.materialId);
  101372. var A = w_((function(e) {
  101373. return a.MaterialUniqueId && e.uniqueId === a.materialUniqueId || e.id === a.materialId
  101374. }
  101375. ), h, t, n);
  101376. A ? u += "\n\tMaterial " + A.toString(d) : K.Warn("Material not found for mesh " + a.id)
  101377. }
  101378. }
  101379. if (a.skeletonId > -1 && void 0 !== h.skeletons && null !== h.skeletons && !(v.indexOf(a.skeletonId) > -1))
  101380. for (var x = 0, R = h.skeletons.length; x < R; x++) {
  101381. var C = h.skeletons[x];
  101382. if (C.id === a.skeletonId) {
  101383. var P = Fo.Parse(C, t);
  101384. s.push(P),
  101385. v.push(C.id),
  101386. u += "\n\tSkeleton " + P.toString(d)
  101387. }
  101388. }
  101389. if (a.morphTargetManagerId > -1 && void 0 !== h.morphTargetManagers && null !== h.morphTargetManagers && !(T.indexOf(a.morphTargetManagerId) > -1))
  101390. for (var M = 0, I = h.morphTargetManagers.length; M < I; M++) {
  101391. var O = h.morphTargetManagers[M];
  101392. if (O.id === a.morphTargetManagerId) {
  101393. var D = x_.Parse(O, t);
  101394. T.push(D.uniqueId),
  101395. u += "\nMorph target " + D.toString()
  101396. }
  101397. }
  101398. var N = Vr.Parse(a, t, n);
  101399. r.push(N),
  101400. u += "\n\tMesh " + N.toString(d)
  101401. }
  101402. };
  101403. for (_ = 0,
  101404. m = h.meshes.length; _ < m; _++)
  101405. E(_);
  101406. for (t.multiMaterials.forEach((function(e) {
  101407. e._waitingSubMaterialsUniqueIds.forEach((function(i) {
  101408. e.subMaterials.push(k_(i, t))
  101409. }
  101410. )),
  101411. e._waitingSubMaterialsUniqueIds = []
  101412. }
  101413. )),
  101414. t.meshes.forEach((function(e) {
  101415. null !== e._waitingMaterialId && (e.material = k_(e._waitingMaterialId, t),
  101416. e._waitingMaterialId = null)
  101417. }
  101418. )),
  101419. _ = 0,
  101420. m = t.transformNodes.length; _ < m; _++)
  101421. null !== (C = t.transformNodes[_])._waitingParentId && (C.parent = t.getLastEntryById(C._waitingParentId),
  101422. C._waitingParentId = null);
  101423. var S = void 0;
  101424. for (_ = 0,
  101425. m = t.meshes.length; _ < m; _++) {
  101426. if ((S = t.meshes[_])._waitingParentId) {
  101427. if (S.parent = t.getLastEntryById(S._waitingParentId),
  101428. "TransformNode" === (null === (c = S.parent) || void 0 === c ? void 0 : c.getClassName())) {
  101429. var A = f.indexOf(S.parent);
  101430. A > -1 && f.splice(A, 1)
  101431. }
  101432. S._waitingParentId = null
  101433. }
  101434. S._waitingData.lods && U_(t, S)
  101435. }
  101436. for (var x = 0, R = f; x < R.length; x++) {
  101437. var C;
  101438. (C = R[x]).dispose()
  101439. }
  101440. for (_ = 0,
  101441. m = t.skeletons.length; _ < m; _++) {
  101442. var P = t.skeletons[_];
  101443. P._hasWaitingData && (null != P.bones && P.bones.forEach((function(e) {
  101444. if (e._waitingTransformNodeId) {
  101445. var i = t.getLastEntryById(e._waitingTransformNodeId);
  101446. i && e.linkTransformNode(i),
  101447. e._waitingTransformNodeId = null
  101448. }
  101449. }
  101450. )),
  101451. P._hasWaitingData = null)
  101452. }
  101453. for (_ = 0,
  101454. m = t.meshes.length; _ < m; _++)
  101455. (S = t.meshes[_])._waitingData.freezeWorldMatrix ? (S.freezeWorldMatrix(),
  101456. S._waitingData.freezeWorldMatrix = null) : S.computeWorldMatrix(!0)
  101457. }
  101458. if (void 0 !== h.particleSystems && null !== h.particleSystems) {
  101459. var M = o.GetIndividualParser(Wi.NAME_PARTICLESYSTEM);
  101460. if (M)
  101461. for (_ = 0,
  101462. m = h.particleSystems.length; _ < m; _++) {
  101463. var I = h.particleSystems[_];
  101464. -1 !== p.indexOf(I.emitterId) && a.push(M(I, t, n))
  101465. }
  101466. }
  101467. return !0
  101468. } catch (e) {
  101469. var O = B_("importMesh", h ? h.producer : "Unknown") + u;
  101470. if (!l)
  101471. throw K.Log(O),
  101472. e;
  101473. l(O, e)
  101474. } finally {
  101475. null !== u && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importMesh", h ? h.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? u : ""))
  101476. }
  101477. return !1
  101478. },
  101479. load: function(e, t, i, n) {
  101480. var r = "importScene has failed JSON parse";
  101481. try {
  101482. var o = JSON.parse(t);
  101483. if (r = "",
  101484. void 0 !== o.useDelayedTextureLoading && null !== o.useDelayedTextureLoading && (e.useDelayedTextureLoading = o.useDelayedTextureLoading && !od.ForceFullSceneLoadingForIncremental),
  101485. void 0 !== o.autoClear && null !== o.autoClear && (e.autoClear = o.autoClear),
  101486. void 0 !== o.clearColor && null !== o.clearColor && (e.clearColor = N.FromArray(o.clearColor)),
  101487. void 0 !== o.ambientColor && null !== o.ambientColor && (e.ambientColor = D.FromArray(o.ambientColor)),
  101488. void 0 !== o.gravity && null !== o.gravity && (e.gravity = x.FromArray(o.gravity)),
  101489. void 0 !== o.useRightHandedSystem && (e.useRightHandedSystem = !!o.useRightHandedSystem),
  101490. o.fogMode && 0 !== o.fogMode)
  101491. switch (e.fogMode = o.fogMode,
  101492. e.fogColor = D.FromArray(o.fogColor),
  101493. e.fogStart = o.fogStart,
  101494. e.fogEnd = o.fogEnd,
  101495. e.fogDensity = o.fogDensity,
  101496. r += "\tFog mode for scene: ",
  101497. e.fogMode) {
  101498. case 1:
  101499. r += "exp\n";
  101500. break;
  101501. case 2:
  101502. r += "exp2\n";
  101503. break;
  101504. case 3:
  101505. r += "linear\n"
  101506. }
  101507. if (o.physicsEnabled) {
  101508. var a = void 0;
  101509. "cannon" === o.physicsEngine ? a = new P_(void 0,void 0,N_.LoaderInjectedPhysicsEngine) : "oimo" === o.physicsEngine ? a = new M_(void 0,N_.LoaderInjectedPhysicsEngine) : "ammo" === o.physicsEngine && (a = new I_(void 0,N_.LoaderInjectedPhysicsEngine,void 0)),
  101510. r = "\tPhysics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + " enabled\n";
  101511. var s = o.physicsGravity ? x.FromArray(o.physicsGravity) : null;
  101512. e.enablePhysics(s, a)
  101513. }
  101514. return void 0 !== o.metadata && null !== o.metadata && (e.metadata = o.metadata),
  101515. void 0 !== o.collisionsEnabled && null !== o.collisionsEnabled && (e.collisionsEnabled = o.collisionsEnabled),
  101516. !!G_(e, t, i, n, !0) && (o.autoAnimate && e.beginAnimation(e, o.autoAnimateFrom, o.autoAnimateTo, o.autoAnimateLoop, o.autoAnimateSpeed || 1),
  101517. void 0 !== o.activeCameraID && null !== o.activeCameraID && e.setActiveCameraById(o.activeCameraID),
  101518. !0)
  101519. } catch (e) {
  101520. var l = B_("importScene", o ? o.producer : "Unknown") + r;
  101521. if (!n)
  101522. throw K.Log(l),
  101523. e;
  101524. n(l, e)
  101525. } finally {
  101526. null !== r && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importScene", o ? o.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? r : ""))
  101527. }
  101528. return !1
  101529. },
  101530. loadAssetContainer: function(e, t, i, n) {
  101531. return G_(e, t, i, n)
  101532. }
  101533. });
  101534. var z_ = function() {
  101535. function e(e) {
  101536. void 0 === e && (e = {}),
  101537. this._isEnabled = !0,
  101538. this.bias = void 0 === e.bias ? 0 : e.bias,
  101539. this.power = void 0 === e.power ? 1 : e.power,
  101540. this.leftColor = e.leftColor || D.White(),
  101541. this.rightColor = e.rightColor || D.Black(),
  101542. !1 === e.isEnabled && (this.isEnabled = !1)
  101543. }
  101544. return Object.defineProperty(e.prototype, "isEnabled", {
  101545. get: function() {
  101546. return this._isEnabled
  101547. },
  101548. set: function(e) {
  101549. this._isEnabled !== e && (this._isEnabled = e,
  101550. vr.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag | a.MATERIAL_MiscDirtyFlag))
  101551. },
  101552. enumerable: !1,
  101553. configurable: !0
  101554. }),
  101555. e.prototype.clone = function() {
  101556. var t = new e;
  101557. return fe.DeepCopy(this, t),
  101558. t
  101559. }
  101560. ,
  101561. e.prototype.equals = function(e) {
  101562. return e && this.bias === e.bias && this.power === e.power && this.leftColor.equals(e.leftColor) && this.rightColor.equals(e.rightColor) && this.isEnabled === e.isEnabled
  101563. }
  101564. ,
  101565. e.prototype.serialize = function() {
  101566. return {
  101567. isEnabled: this.isEnabled,
  101568. leftColor: this.leftColor.asArray(),
  101569. rightColor: this.rightColor.asArray(),
  101570. bias: this.bias,
  101571. power: this.power
  101572. }
  101573. }
  101574. ,
  101575. e.Parse = function(t) {
  101576. return new e({
  101577. isEnabled: t.isEnabled,
  101578. leftColor: D.FromArray(t.leftColor),
  101579. rightColor: D.FromArray(t.rightColor),
  101580. bias: t.bias,
  101581. power: t.power || 1
  101582. })
  101583. }
  101584. ,
  101585. e
  101586. }();
  101587. Ge._FresnelParametersParser = z_.Parse;
  101588. var W_ = function(e) {
  101589. function t(t, i) {
  101590. var n = e.call(this, t, i, "color", {
  101591. attributes: ["position"],
  101592. uniforms: ["world", "viewProjection", "color"]
  101593. }) || this;
  101594. return n.disableColorWrite = !0,
  101595. n.forceDepthWrite = !0,
  101596. n.setColor4("color", new N(0,0,0,1)),
  101597. n
  101598. }
  101599. return U(t, e),
  101600. t
  101601. }(jl)
  101602. , H_ = function(e) {
  101603. function t(t, i) {
  101604. var n = e.call(this, t, i) || this;
  101605. return n.maxSimultaneousLights = 4,
  101606. n.disableLighting = !1,
  101607. n.invertNormalMapX = !1,
  101608. n.invertNormalMapY = !1,
  101609. n.emissiveColor = new D(0,0,0),
  101610. n.occlusionStrength = 1,
  101611. n.useLightmapAsShadowmap = !1,
  101612. n._useAlphaFromAlbedoTexture = !0,
  101613. n._useAmbientInGrayScale = !0,
  101614. n
  101615. }
  101616. return U(t, e),
  101617. Object.defineProperty(t.prototype, "doubleSided", {
  101618. get: function() {
  101619. return this._twoSidedLighting
  101620. },
  101621. set: function(e) {
  101622. this._twoSidedLighting !== e && (this._twoSidedLighting = e,
  101623. this.backFaceCulling = !e,
  101624. this._markAllSubMeshesAsTexturesDirty())
  101625. },
  101626. enumerable: !1,
  101627. configurable: !0
  101628. }),
  101629. t.prototype.getClassName = function() {
  101630. return "PBRBaseSimpleMaterial"
  101631. }
  101632. ,
  101633. k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
  101634. k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
  101635. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0),
  101636. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
  101637. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
  101638. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0),
  101639. k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
  101640. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
  101641. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0),
  101642. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0),
  101643. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0),
  101644. k([Ce()], t.prototype, "doubleSided", null),
  101645. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
  101646. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
  101647. t
  101648. }(rp)
  101649. , X_ = function(e) {
  101650. function t(t, i) {
  101651. var n = e.call(this, t, i) || this;
  101652. return n._useRoughnessFromMetallicTextureAlpha = !1,
  101653. n._useRoughnessFromMetallicTextureGreen = !0,
  101654. n._useMetallnessFromMetallicTextureBlue = !0,
  101655. n.metallic = 1,
  101656. n.roughness = 1,
  101657. n
  101658. }
  101659. return U(t, e),
  101660. t.prototype.getClassName = function() {
  101661. return "PBRMetallicRoughnessMaterial"
  101662. }
  101663. ,
  101664. t.prototype.clone = function(e) {
  101665. var i = this
  101666. , n = Ge.Clone((function() {
  101667. return new t(e,i.getScene())
  101668. }
  101669. ), this);
  101670. return n.id = e,
  101671. n.name = e,
  101672. this.clearCoat.copyTo(n.clearCoat),
  101673. this.anisotropy.copyTo(n.anisotropy),
  101674. this.brdf.copyTo(n.brdf),
  101675. this.sheen.copyTo(n.sheen),
  101676. this.subSurface.copyTo(n.subSurface),
  101677. n
  101678. }
  101679. ,
  101680. t.prototype.serialize = function() {
  101681. var e = Ge.Serialize(this);
  101682. return e.customType = "BABYLON.PBRMetallicRoughnessMaterial",
  101683. e.clearCoat = this.clearCoat.serialize(),
  101684. e.anisotropy = this.anisotropy.serialize(),
  101685. e.brdf = this.brdf.serialize(),
  101686. e.sheen = this.sheen.serialize(),
  101687. e.subSurface = this.subSurface.serialize(),
  101688. e
  101689. }
  101690. ,
  101691. t.Parse = function(e, i, n) {
  101692. var r = Ge.Parse((function() {
  101693. return new t(e.name,i)
  101694. }
  101695. ), e, i, n);
  101696. return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
  101697. e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
  101698. e.brdf && r.brdf.parse(e.brdf, i, n),
  101699. e.sheen && r.sheen.parse(e.sheen, i, n),
  101700. e.subSurface && r.subSurface.parse(e.subSurface, i, n),
  101701. r
  101702. }
  101703. ,
  101704. k([Me(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0),
  101705. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0),
  101706. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
  101707. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
  101708. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0),
  101709. t
  101710. }(H_);
  101711. y("BABYLON.PBRMetallicRoughnessMaterial", X_);
  101712. var j_ = function(e) {
  101713. function t(t, i) {
  101714. var n = e.call(this, t, i) || this;
  101715. return n._useMicroSurfaceFromReflectivityMapAlpha = !0,
  101716. n
  101717. }
  101718. return U(t, e),
  101719. Object.defineProperty(t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", {
  101720. get: function() {
  101721. return this._useMicroSurfaceFromReflectivityMapAlpha
  101722. },
  101723. enumerable: !1,
  101724. configurable: !0
  101725. }),
  101726. t.prototype.getClassName = function() {
  101727. return "PBRSpecularGlossinessMaterial"
  101728. }
  101729. ,
  101730. t.prototype.clone = function(e) {
  101731. var i = this
  101732. , n = Ge.Clone((function() {
  101733. return new t(e,i.getScene())
  101734. }
  101735. ), this);
  101736. return n.id = e,
  101737. n.name = e,
  101738. this.clearCoat.copyTo(n.clearCoat),
  101739. this.anisotropy.copyTo(n.anisotropy),
  101740. this.brdf.copyTo(n.brdf),
  101741. this.sheen.copyTo(n.sheen),
  101742. this.subSurface.copyTo(n.subSurface),
  101743. n
  101744. }
  101745. ,
  101746. t.prototype.serialize = function() {
  101747. var e = Ge.Serialize(this);
  101748. return e.customType = "BABYLON.PBRSpecularGlossinessMaterial",
  101749. e.clearCoat = this.clearCoat.serialize(),
  101750. e.anisotropy = this.anisotropy.serialize(),
  101751. e.brdf = this.brdf.serialize(),
  101752. e.sheen = this.sheen.serialize(),
  101753. e.subSurface = this.subSurface.serialize(),
  101754. e
  101755. }
  101756. ,
  101757. t.Parse = function(e, i, n) {
  101758. var r = Ge.Parse((function() {
  101759. return new t(e.name,i)
  101760. }
  101761. ), e, i, n);
  101762. return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
  101763. e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
  101764. e.brdf && r.brdf.parse(e.brdf, i, n),
  101765. e.sheen && r.sheen.parse(e.sheen, i, n),
  101766. e.subSurface && r.subSurface.parse(e.subSurface, i, n),
  101767. r
  101768. }
  101769. ,
  101770. k([Me("diffuse"), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0),
  101771. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0),
  101772. k([Me("specular"), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0),
  101773. k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0),
  101774. k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0),
  101775. t
  101776. }(H_);
  101777. y("BABYLON.PBRSpecularGlossinessMaterial", j_);
  101778. var Y_ = function(e) {
  101779. function t(t, i, n) {
  101780. void 0 === n && (n = null);
  101781. var r = e.call(this, i) || this;
  101782. if (!t)
  101783. return r;
  101784. if (r._textureMatrix = P.Identity(),
  101785. r.name = t,
  101786. r.url = t,
  101787. r._onLoad = n,
  101788. r._texture = r._getFromCache(t, !0),
  101789. r._texture)
  101790. r._triggerOnLoad();
  101791. else {
  101792. var o = r.getScene();
  101793. o && o.useDelayedTextureLoading ? r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : r._loadTexture()
  101794. }
  101795. return r
  101796. }
  101797. return U(t, e),
  101798. t.prototype._triggerOnLoad = function() {
  101799. this._onLoad && this._onLoad()
  101800. }
  101801. ,
  101802. t.prototype.getTextureMatrix = function() {
  101803. return this._textureMatrix
  101804. }
  101805. ,
  101806. t.prototype._load3dlTexture = function() {
  101807. var e, i = this, n = this._getEngine();
  101808. e = n._features.support3DTextures ? n.createRawTexture3D(null, 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT) : n.createRawTexture(null, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT),
  101809. this._texture = e,
  101810. this._texture.isReady = !1,
  101811. this.isCube = !1,
  101812. this.is3D = n._features.support3DTextures,
  101813. this.wrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
  101814. this.wrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
  101815. this.wrapR = a.TEXTURE_CLAMP_ADDRESSMODE,
  101816. this.anisotropicFilteringLevel = 1;
  101817. var r = function(r) {
  101818. if ("string" == typeof r) {
  101819. for (var o, s = null, l = null, c = r.split("\n"), u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0; _ < c.length; _++)
  101820. if (o = c[_],
  101821. t._NoneEmptyLineRegex.test(o) && 0 !== o.indexOf("#")) {
  101822. var m = o.split(" ");
  101823. if (0 !== u) {
  101824. if (0 != u) {
  101825. var g = Math.max(parseInt(m[0]), 0)
  101826. , v = Math.max(parseInt(m[1]), 0)
  101827. , y = Math.max(parseInt(m[2]), 0);
  101828. f = Math.max(g, f),
  101829. f = Math.max(v, f),
  101830. f = Math.max(y, f);
  101831. var b = 4 * (h + p * u + d * u * u);
  101832. l && (l[b + 0] = g,
  101833. l[b + 1] = v,
  101834. l[b + 2] = y),
  101835. ++d % u == 0 && (d = 0,
  101836. ++p % u == 0 && (h++,
  101837. p = 0))
  101838. }
  101839. } else
  101840. u = m.length,
  101841. s = new Uint8Array(u * u * u * 4),
  101842. l = new Float32Array(u * u * u * 4)
  101843. }
  101844. if (l && s)
  101845. for (_ = 0; _ < l.length; _++)
  101846. if (_ > 0 && (_ + 1) % 4 == 0)
  101847. s[_] = 255;
  101848. else {
  101849. var T = l[_];
  101850. s[_] = T / f * 255
  101851. }
  101852. e.is3D ? (e.updateSize(u, u, u),
  101853. n.updateRawTexture3D(e, s, a.TEXTUREFORMAT_RGBA, !1)) : (e.updateSize(u * u, u),
  101854. n.updateRawTexture(e, s, a.TEXTUREFORMAT_RGBA, !1)),
  101855. e.isReady = !0,
  101856. i._triggerOnLoad()
  101857. }
  101858. }
  101859. , o = this.getScene();
  101860. return o ? o._loadFile(this.url, r) : n._loadFile(this.url, r),
  101861. this._texture
  101862. }
  101863. ,
  101864. t.prototype._loadTexture = function() {
  101865. this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == this.url.length - 4 && this._load3dlTexture()
  101866. }
  101867. ,
  101868. t.prototype.clone = function() {
  101869. var e = new t(this.url,this.getScene() || this._getEngine());
  101870. return e.level = this.level,
  101871. e
  101872. }
  101873. ,
  101874. t.prototype.delayLoad = function() {
  101875. this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
  101876. this._texture = this._getFromCache(this.url, !0),
  101877. this._texture || this._loadTexture())
  101878. }
  101879. ,
  101880. t.Parse = function(e, i) {
  101881. var n = null;
  101882. return e.name && !e.isRenderTarget && ((n = new t(e.name,i)).name = e.name,
  101883. n.level = e.level),
  101884. n
  101885. }
  101886. ,
  101887. t.prototype.serialize = function() {
  101888. if (!this.name)
  101889. return null;
  101890. var e = {};
  101891. return e.name = this.name,
  101892. e.level = this.level,
  101893. e.customType = "BABYLON.ColorGradingTexture",
  101894. e
  101895. }
  101896. ,
  101897. t._NoneEmptyLineRegex = /\S+/,
  101898. t
  101899. }(Zr);
  101900. y("BABYLON.ColorGradingTexture", Y_);
  101901. var K_ = function(e) {
  101902. function t(t, i, n, r, o, s, l) {
  101903. void 0 === r && (r = !1),
  101904. void 0 === o && (o = !0),
  101905. void 0 === s && (s = null),
  101906. void 0 === l && (l = null);
  101907. var c = e.call(this, i) || this;
  101908. if (c._onLoad = null,
  101909. c._onError = null,
  101910. !t)
  101911. throw new Error("Image url is not set");
  101912. return c._coordinatesMode = io.CUBIC_MODE,
  101913. c.name = t,
  101914. c.url = t,
  101915. c._size = n,
  101916. c._noMipmap = r,
  101917. c.gammaSpace = o,
  101918. c._onLoad = s,
  101919. c._onError = l,
  101920. c.hasAlpha = !1,
  101921. c.isCube = !0,
  101922. c._texture = c._getFromCache(t, c._noMipmap),
  101923. c._texture ? s && (c._texture.isReady ? gi.SetImmediate((function() {
  101924. return s()
  101925. }
  101926. )) : c._texture.onLoadedObservable.add(s)) : i.useDelayedTextureLoading ? c.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : c._loadImage(c._loadTexture.bind(c), c._onError),
  101927. c
  101928. }
  101929. return U(t, e),
  101930. t.prototype._loadImage = function(e, t) {
  101931. var i = this
  101932. , n = document.createElement("canvas");
  101933. $t(this.url, (function(t) {
  101934. i._width = t.width,
  101935. i._height = t.height,
  101936. n.width = i._width,
  101937. n.height = i._height;
  101938. var r = n.getContext("2d");
  101939. r.drawImage(t, 0, 0);
  101940. var o = r.getImageData(0, 0, t.width, t.height);
  101941. i._buffer = o.data.buffer,
  101942. n.remove(),
  101943. e()
  101944. }
  101945. ), (function(e, n) {
  101946. t && t("".concat(i.getClassName(), " could not be loaded"), n)
  101947. }
  101948. ), null)
  101949. }
  101950. ,
  101951. t.prototype._loadTexture = function() {
  101952. var e = this
  101953. , i = this.getScene();
  101954. i && (this._texture = i.getEngine().createRawCubeTextureFromUrl(this.url, i, this._size, a.TEXTUREFORMAT_RGB, i.getEngine().getCaps().textureFloat ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, (function() {
  101955. for (var i = e._getFloat32ArrayFromArrayBuffer(e._buffer), n = g_.ConvertPanoramaToCubemap(i, e._width, e._height, e._size), r = [], o = 0; o < 6; o++) {
  101956. var a = n[t._FacesMapping[o]];
  101957. r.push(a)
  101958. }
  101959. return r
  101960. }
  101961. ), null, this._onLoad, this._onError))
  101962. }
  101963. ,
  101964. t.prototype._getFloat32ArrayFromArrayBuffer = function(e) {
  101965. for (var t = new DataView(e), i = new Float32Array(3 * e.byteLength / 4), n = 0, r = 0; r < e.byteLength; r++)
  101966. (r + 1) % 4 != 0 && (i[n++] = t.getUint8(r) / 255);
  101967. return i
  101968. }
  101969. ,
  101970. t.prototype.getClassName = function() {
  101971. return "EquiRectangularCubeTexture"
  101972. }
  101973. ,
  101974. t.prototype.clone = function() {
  101975. var e = this.getScene();
  101976. if (!e)
  101977. return this;
  101978. var i = new t(this.url,e,this._size,this._noMipmap,this.gammaSpace);
  101979. return i.level = this.level,
  101980. i.wrapU = this.wrapU,
  101981. i.wrapV = this.wrapV,
  101982. i.coordinatesIndex = this.coordinatesIndex,
  101983. i.coordinatesMode = this.coordinatesMode,
  101984. i
  101985. }
  101986. ,
  101987. t._FacesMapping = ["right", "left", "up", "down", "front", "back"],
  101988. t
  101989. }(Zr)
  101990. , Q_ = function(e) {
  101991. function t(i, n, r) {
  101992. var o = e.call(this, r.scene || r.engine) || this;
  101993. return n && (r.engine || r.scene) ? (r = V(V({}, t._DefaultOptions), r),
  101994. o._generateMipMaps = r.generateMipMaps,
  101995. o._samplingMode = r.samplingMode,
  101996. o._textureMatrix = P.Identity(),
  101997. o.name = i,
  101998. o.element = n,
  101999. o._isVideo = n instanceof HTMLVideoElement,
  102000. o.anisotropicFilteringLevel = 1,
  102001. o._createInternalTexture(),
  102002. o) : o
  102003. }
  102004. return U(t, e),
  102005. t.prototype._createInternalTexture = function() {
  102006. var e = 0
  102007. , t = 0;
  102008. this._isVideo ? (e = this.element.videoWidth,
  102009. t = this.element.videoHeight) : (e = this.element.width,
  102010. t = this.element.height);
  102011. var i = this._getEngine();
  102012. i && (this._texture = i.createDynamicTexture(e, t, this._generateMipMaps, this._samplingMode)),
  102013. this.update()
  102014. }
  102015. ,
  102016. t.prototype.getTextureMatrix = function() {
  102017. return this._textureMatrix
  102018. }
  102019. ,
  102020. t.prototype.update = function(e) {
  102021. void 0 === e && (e = null);
  102022. var t = this._getEngine();
  102023. if (null != this._texture && null != t)
  102024. if (this._isVideo) {
  102025. var i = this.element;
  102026. if (i.readyState < i.HAVE_CURRENT_DATA)
  102027. return;
  102028. t.updateVideoTexture(this._texture, i, null === e || e)
  102029. } else {
  102030. var n = this.element;
  102031. t.updateDynamicTexture(this._texture, n, null === e || e, !1)
  102032. }
  102033. }
  102034. ,
  102035. t._DefaultOptions = {
  102036. generateMipMaps: !1,
  102037. samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE,
  102038. engine: null,
  102039. scene: null
  102040. },
  102041. t
  102042. }(Zr);
  102043. function q_(e) {
  102044. var t = 0;
  102045. return {
  102046. id_length: e[t++],
  102047. colormap_type: e[t++],
  102048. image_type: e[t++],
  102049. colormap_index: e[t++] | e[t++] << 8,
  102050. colormap_length: e[t++] | e[t++] << 8,
  102051. colormap_size: e[t++],
  102052. origin: [e[t++] | e[t++] << 8, e[t++] | e[t++] << 8],
  102053. width: e[t++] | e[t++] << 8,
  102054. height: e[t++] | e[t++] << 8,
  102055. pixel_size: e[t++],
  102056. flags: e[t++]
  102057. }
  102058. }
  102059. function Z_(e, t) {
  102060. if (t.length < 19)
  102061. K.Error("Unable to load TGA file - Not enough data to contain header");
  102062. else {
  102063. var i = 18
  102064. , n = q_(t);
  102065. if (n.id_length + i > t.length)
  102066. K.Error("Unable to load TGA file - Not enough data");
  102067. else {
  102068. i += n.id_length;
  102069. var r, o = !1, a = !1, s = !1;
  102070. switch (n.image_type) {
  102071. case 9:
  102072. o = !0;
  102073. case 1:
  102074. a = !0;
  102075. break;
  102076. case 10:
  102077. o = !0;
  102078. case 2:
  102079. break;
  102080. case 11:
  102081. o = !0;
  102082. case 3:
  102083. s = !0
  102084. }
  102085. var l, c, u, h, d, p, f, _ = n.pixel_size >> 3, m = n.width * n.height * _;
  102086. if (a && (l = t.subarray(i, i += n.colormap_length * (n.colormap_size >> 3))),
  102087. o) {
  102088. r = new Uint8Array(m);
  102089. for (var g = void 0, v = void 0, y = void 0, b = 0, T = new Uint8Array(_); i < m && b < m; )
  102090. if (v = 1 + (127 & (g = t[i++])),
  102091. 128 & g) {
  102092. for (y = 0; y < _; ++y)
  102093. T[y] = t[i++];
  102094. for (y = 0; y < v; ++y)
  102095. r.set(T, b + y * _);
  102096. b += _ * v
  102097. } else {
  102098. for (v *= _,
  102099. y = 0; y < v; ++y)
  102100. r[b + y] = t[i++];
  102101. b += v
  102102. }
  102103. } else
  102104. r = t.subarray(i, i += a ? n.width * n.height : m);
  102105. switch ((48 & n.flags) >> 4) {
  102106. default:
  102107. case 2:
  102108. c = 0,
  102109. h = 1,
  102110. f = n.width,
  102111. u = 0,
  102112. d = 1,
  102113. p = n.height;
  102114. break;
  102115. case 0:
  102116. c = 0,
  102117. h = 1,
  102118. f = n.width,
  102119. u = n.height - 1,
  102120. d = -1,
  102121. p = -1;
  102122. break;
  102123. case 3:
  102124. c = n.width - 1,
  102125. h = -1,
  102126. f = -1,
  102127. u = 0,
  102128. d = 1,
  102129. p = n.height;
  102130. break;
  102131. case 1:
  102132. c = n.width - 1,
  102133. h = -1,
  102134. f = -1,
  102135. u = n.height - 1,
  102136. d = -1,
  102137. p = -1
  102138. }
  102139. var E = "_getImageData" + (s ? "Grey" : "") + n.pixel_size + "bits"
  102140. , S = J_[E](n, l, r, u, d, p, c, h, f);
  102141. e.getEngine()._uploadDataToTextureDirectly(e, S)
  102142. }
  102143. }
  102144. }
  102145. var J_ = {
  102146. GetTGAHeader: q_,
  102147. UploadContent: Z_,
  102148. _getImageData8bits: function(e, t, i, n, r, o, a, s, l) {
  102149. var c, u, h, d = i, p = t, f = e.width, _ = e.height, m = 0, g = new Uint8Array(f * _ * 4);
  102150. for (h = n; h !== o; h += r)
  102151. for (u = a; u !== l; u += s,
  102152. m++)
  102153. c = d[m],
  102154. g[4 * (u + f * h) + 3] = 255,
  102155. g[4 * (u + f * h) + 2] = p[3 * c + 0],
  102156. g[4 * (u + f * h) + 1] = p[3 * c + 1],
  102157. g[4 * (u + f * h) + 0] = p[3 * c + 2];
  102158. return g
  102159. },
  102160. _getImageData16bits: function(e, t, i, n, r, o, a, s, l) {
  102161. var c, u, h, d = i, p = e.width, f = e.height, _ = 0, m = new Uint8Array(p * f * 4);
  102162. for (h = n; h !== o; h += r)
  102163. for (u = a; u !== l; u += s,
  102164. _ += 2) {
  102165. var g = 255 * ((31744 & (c = d[_ + 0] + (d[_ + 1] << 8))) >> 10) / 31 | 0
  102166. , v = 255 * ((992 & c) >> 5) / 31 | 0
  102167. , y = 255 * (31 & c) / 31 | 0;
  102168. m[4 * (u + p * h) + 0] = g,
  102169. m[4 * (u + p * h) + 1] = v,
  102170. m[4 * (u + p * h) + 2] = y,
  102171. m[4 * (u + p * h) + 3] = 32768 & c ? 0 : 255
  102172. }
  102173. return m
  102174. },
  102175. _getImageData24bits: function(e, t, i, n, r, o, a, s, l) {
  102176. var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
  102177. for (u = n; u !== o; u += r)
  102178. for (c = a; c !== l; c += s,
  102179. f += 3)
  102180. _[4 * (c + d * u) + 3] = 255,
  102181. _[4 * (c + d * u) + 2] = h[f + 0],
  102182. _[4 * (c + d * u) + 1] = h[f + 1],
  102183. _[4 * (c + d * u) + 0] = h[f + 2];
  102184. return _
  102185. },
  102186. _getImageData32bits: function(e, t, i, n, r, o, a, s, l) {
  102187. var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
  102188. for (u = n; u !== o; u += r)
  102189. for (c = a; c !== l; c += s,
  102190. f += 4)
  102191. _[4 * (c + d * u) + 2] = h[f + 0],
  102192. _[4 * (c + d * u) + 1] = h[f + 1],
  102193. _[4 * (c + d * u) + 0] = h[f + 2],
  102194. _[4 * (c + d * u) + 3] = h[f + 3];
  102195. return _
  102196. },
  102197. _getImageDataGrey8bits: function(e, t, i, n, r, o, a, s, l) {
  102198. var c, u, h, d = i, p = e.width, f = e.height, _ = 0, m = new Uint8Array(p * f * 4);
  102199. for (h = n; h !== o; h += r)
  102200. for (u = a; u !== l; u += s,
  102201. _++)
  102202. c = d[_],
  102203. m[4 * (u + p * h) + 0] = c,
  102204. m[4 * (u + p * h) + 1] = c,
  102205. m[4 * (u + p * h) + 2] = c,
  102206. m[4 * (u + p * h) + 3] = 255;
  102207. return m
  102208. },
  102209. _getImageDataGrey16bits: function(e, t, i, n, r, o, a, s, l) {
  102210. var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
  102211. for (u = n; u !== o; u += r)
  102212. for (c = a; c !== l; c += s,
  102213. f += 2)
  102214. _[4 * (c + d * u) + 0] = h[f + 0],
  102215. _[4 * (c + d * u) + 1] = h[f + 0],
  102216. _[4 * (c + d * u) + 2] = h[f + 0],
  102217. _[4 * (c + d * u) + 3] = h[f + 1];
  102218. return _
  102219. }
  102220. }
  102221. , $_ = function() {
  102222. function e() {
  102223. this.supportCascades = !1
  102224. }
  102225. return e.prototype.canLoad = function(e) {
  102226. return oe(e, ".tga")
  102227. }
  102228. ,
  102229. e.prototype.loadCubeData = function() {
  102230. throw ".env not supported in Cube."
  102231. }
  102232. ,
  102233. e.prototype.loadData = function(e, t, i) {
  102234. var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength)
  102235. , r = q_(n);
  102236. i(r.width, r.height, t.generateMipMaps, !1, (function() {
  102237. Z_(t, n)
  102238. }
  102239. ))
  102240. }
  102241. ,
  102242. e
  102243. }();
  102244. vr._TextureLoaders.push(new $_);
  102245. var em = function() {
  102246. function e() {
  102247. this.supportCascades = !1
  102248. }
  102249. return e.prototype.canLoad = function(e) {
  102250. return oe(e, ".hdr")
  102251. }
  102252. ,
  102253. e.prototype.loadCubeData = function() {
  102254. throw ".env not supported in Cube."
  102255. }
  102256. ,
  102257. e.prototype.loadData = function(e, t, i) {
  102258. for (var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength), r = v_.RGBE_ReadHeader(n), o = v_.RGBE_ReadPixels(n, r), s = r.width * r.height, l = new Float32Array(4 * s), c = 0; c < s; c += 1)
  102259. l[4 * c] = o[3 * c],
  102260. l[4 * c + 1] = o[3 * c + 1],
  102261. l[4 * c + 2] = o[3 * c + 2],
  102262. l[4 * c + 3] = 1;
  102263. i(r.width, r.height, t.generateMipMaps, !1, (function() {
  102264. var e = t.getEngine();
  102265. t.type = a.TEXTURETYPE_FLOAT,
  102266. t.format = a.TEXTUREFORMAT_RGBA,
  102267. t._gammaSpace = !1,
  102268. e._uploadDataToTextureDirectly(t, l)
  102269. }
  102270. ))
  102271. }
  102272. ,
  102273. e
  102274. }();
  102275. vr._TextureLoaders.push(new em);
  102276. var tm, im = function() {};
  102277. !function(e) {
  102278. e[e.cTFETC1 = 0] = "cTFETC1",
  102279. e[e.cTFBC1 = 1] = "cTFBC1",
  102280. e[e.cTFBC4 = 2] = "cTFBC4",
  102281. e[e.cTFPVRTC1_4_OPAQUE_ONLY = 3] = "cTFPVRTC1_4_OPAQUE_ONLY",
  102282. e[e.cTFBC7_M6_OPAQUE_ONLY = 4] = "cTFBC7_M6_OPAQUE_ONLY",
  102283. e[e.cTFETC2 = 5] = "cTFETC2",
  102284. e[e.cTFBC3 = 6] = "cTFBC3",
  102285. e[e.cTFBC5 = 7] = "cTFBC5"
  102286. }(tm || (tm = {}));
  102287. var nm = {
  102288. JSModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",
  102289. WasmModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm"
  102290. }
  102291. , rm = function(e, t) {
  102292. var i;
  102293. switch (e) {
  102294. case tm.cTFETC1:
  102295. i = a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;
  102296. break;
  102297. case tm.cTFBC1:
  102298. i = a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;
  102299. break;
  102300. case tm.cTFBC4:
  102301. i = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5
  102302. }
  102303. if (void 0 === i)
  102304. throw "The chosen Basis transcoder format is not currently supported";
  102305. return i
  102306. }
  102307. , om = null
  102308. , am = null
  102309. , sm = 0
  102310. , lm = function(e, t) {
  102311. var i = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
  102312. return new Promise((function(e, n) {
  102313. (om || (om = new Promise((function(e, t) {
  102314. am ? e(am) : gi.LoadFileAsync(nm.WasmModuleURL).then((function(i) {
  102315. var n = URL.createObjectURL(new Blob(["(".concat(hm, ")()")],{
  102316. type: "application/javascript"
  102317. }));
  102318. am = new Worker(n);
  102319. var r = function(i) {
  102320. "init" === i.data.action ? (am.removeEventListener("message", r),
  102321. e(am)) : "error" === i.data.action && t(i.data.error || "error initializing worker")
  102322. };
  102323. am.addEventListener("message", r),
  102324. am.postMessage({
  102325. action: "init",
  102326. url: nm.JSModuleURL,
  102327. wasmBinary: i
  102328. })
  102329. }
  102330. )).catch(t)
  102331. }
  102332. ))),
  102333. om).then((function() {
  102334. var r = sm++
  102335. , o = function(t) {
  102336. "transcode" === t.data.action && t.data.id === r && (am.removeEventListener("message", o),
  102337. t.data.success ? e(t.data) : n("Transcode is not supported on this device"))
  102338. };
  102339. am.addEventListener("message", o);
  102340. var a = new Uint8Array(i.byteLength);
  102341. a.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),
  102342. am.postMessage({
  102343. action: "transcode",
  102344. id: r,
  102345. imageData: a,
  102346. config: t,
  102347. ignoreSupportedFormats: !1
  102348. }, [a.buffer])
  102349. }
  102350. ), (function(e) {
  102351. n(e)
  102352. }
  102353. ))
  102354. }
  102355. ))
  102356. }
  102357. , cm = function(e, t) {
  102358. for (var i = e.getEngine(), n = function(n) {
  102359. var r = t.fileInfo.images[n].levels[0];
  102360. if (e._invertVScale = e.invertY,
  102361. -1 === t.format)
  102362. if (e.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
  102363. e.format = a.TEXTUREFORMAT_RGB,
  102364. !i._features.basisNeedsPOT || d.Log2(r.width) % 1 == 0 && d.Log2(r.height) % 1 == 0)
  102365. e._invertVScale = !e.invertY,
  102366. e.width = r.width + 3 & -4,
  102367. e.height = r.height + 3 & -4,
  102368. i._uploadDataToTextureDirectly(e, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0);
  102369. else {
  102370. var o = new Lt(i,At.Temp);
  102371. e._invertVScale = e.invertY,
  102372. o.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
  102373. o.format = a.TEXTUREFORMAT_RGB,
  102374. o.width = r.width + 3 & -4,
  102375. o.height = r.height + 3 & -4,
  102376. i._bindTextureDirectly(i._gl.TEXTURE_2D, o, !0),
  102377. i._uploadDataToTextureDirectly(o, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0),
  102378. i._rescaleTexture(o, e, i.scenes[0], i._getInternalFormat(a.TEXTUREFORMAT_RGB), (function() {
  102379. i._releaseTexture(o),
  102380. i._bindTextureDirectly(i._gl.TEXTURE_2D, e, !0)
  102381. }
  102382. ))
  102383. }
  102384. else
  102385. e.width = r.width,
  102386. e.height = r.height,
  102387. e.generateMipMaps = t.fileInfo.images[n].levels.length > 1,
  102388. t.fileInfo.images[n].levels.forEach((function(r, o) {
  102389. i._uploadCompressedDataToTextureDirectly(e, um.GetInternalFormatFromBasisFormat(t.format, i), r.width, r.height, r.transcodedPixels, n, o)
  102390. }
  102391. )),
  102392. !i._features.basisNeedsPOT || d.Log2(e.width) % 1 == 0 && d.Log2(e.height) % 1 == 0 || (gi.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),
  102393. e._cachedWrapU = io.CLAMP_ADDRESSMODE,
  102394. e._cachedWrapV = io.CLAMP_ADDRESSMODE)
  102395. }, r = 0; r < t.fileInfo.images.length; r++)
  102396. n(r)
  102397. }
  102398. , um = {
  102399. JSModuleURL: nm.JSModuleURL,
  102400. WasmModuleURL: nm.WasmModuleURL,
  102401. GetInternalFormatFromBasisFormat: rm,
  102402. TranscodeAsync: lm,
  102403. LoadTextureFromTranscodeResult: cm
  102404. };
  102405. function hm() {
  102406. var e = null;
  102407. function t(e, t, i, n, r) {
  102408. var o = e.getImageTranscodedSizeInBytes(t, i, n)
  102409. , a = new Uint8Array(o);
  102410. return e.transcodeImage(a, t, i, n, 1, 0) ? (r && (a = function(e, t, i, n) {
  102411. for (var r = new Uint16Array(4), o = new Uint16Array(i * n), a = i / 4, s = n / 4, l = 0; l < s; l++)
  102412. for (var c = 0; c < a; c++) {
  102413. var u = 0 + 8 * (l * a + c);
  102414. r[0] = e[u] | e[u + 1] << 8,
  102415. r[1] = e[u + 2] | e[u + 3] << 8,
  102416. r[2] = (2 * (31 & r[0]) + 1 * (31 & r[1])) / 3 | (2 * (2016 & r[0]) + 1 * (2016 & r[1])) / 3 & 2016 | (2 * (63488 & r[0]) + 1 * (63488 & r[1])) / 3 & 63488,
  102417. r[3] = (2 * (31 & r[1]) + 1 * (31 & r[0])) / 3 | (2 * (2016 & r[1]) + 1 * (2016 & r[0])) / 3 & 2016 | (2 * (63488 & r[1]) + 1 * (63488 & r[0])) / 3 & 63488;
  102418. for (var h = 0; h < 4; h++) {
  102419. var d = e[u + 4 + h]
  102420. , p = (4 * l + h) * i + 4 * c;
  102421. o[p++] = r[3 & d],
  102422. o[p++] = r[d >> 2 & 3],
  102423. o[p++] = r[d >> 4 & 3],
  102424. o[p++] = r[d >> 6 & 3]
  102425. }
  102426. }
  102427. return o
  102428. }(a, 0, e.getImageWidth(t, i) + 3 & -4, e.getImageHeight(t, i) + 3 & -4)),
  102429. a) : null
  102430. }
  102431. onmessage = function(i) {
  102432. if ("init" === i.data.action) {
  102433. if (!e) {
  102434. Module = {
  102435. wasmBinary: i.data.wasmBinary
  102436. };
  102437. try {
  102438. importScripts(i.data.url)
  102439. } catch (e) {
  102440. postMessage({
  102441. action: "error",
  102442. error: e
  102443. })
  102444. }
  102445. e = new Promise((function(e) {
  102446. Module.onRuntimeInitialized = function() {
  102447. Module.initializeBasis(),
  102448. e()
  102449. }
  102450. }
  102451. ))
  102452. }
  102453. e.then((function() {
  102454. postMessage({
  102455. action: "init"
  102456. })
  102457. }
  102458. ))
  102459. } else if ("transcode" === i.data.action) {
  102460. var n = i.data.config
  102461. , r = i.data.imageData
  102462. , o = new Module.BasisFile(r)
  102463. , a = function(e) {
  102464. for (var t = e.getHasAlpha(), i = e.getNumImages(), n = [], r = 0; r < i; r++) {
  102465. for (var o = {
  102466. levels: []
  102467. }, a = e.getNumLevels(r), s = 0; s < a; s++) {
  102468. var l = {
  102469. width: e.getImageWidth(r, s),
  102470. height: e.getImageHeight(r, s)
  102471. };
  102472. o.levels.push(l)
  102473. }
  102474. n.push(o)
  102475. }
  102476. return {
  102477. hasAlpha: t,
  102478. images: n
  102479. }
  102480. }(o)
  102481. , s = i.data.ignoreSupportedFormats ? null : function(e, t) {
  102482. var i = null;
  102483. return e.supportedCompressionFormats && (e.supportedCompressionFormats.etc1 ? i = 0 : e.supportedCompressionFormats.s3tc ? i = t.hasAlpha ? 6 : 1 : e.supportedCompressionFormats.pvrtc || e.supportedCompressionFormats.etc2 && (i = 5)),
  102484. i
  102485. }(i.data.config, a)
  102486. , l = !1;
  102487. null === s && (l = !0,
  102488. s = a.hasAlpha ? 6 : 1);
  102489. var c = !0;
  102490. o.startTranscoding() || (c = !1);
  102491. for (var u = [], h = 0; h < a.images.length && c; h++) {
  102492. var d = a.images[h];
  102493. if (void 0 === n.loadSingleImage || n.loadSingleImage === h) {
  102494. var p = d.levels.length;
  102495. !1 === n.loadMipmapLevels && (p = 1);
  102496. for (var f = 0; f < p; f++) {
  102497. var _ = d.levels[f]
  102498. , m = t(o, h, f, s, l);
  102499. if (!m) {
  102500. c = !1;
  102501. break
  102502. }
  102503. _.transcodedPixels = m,
  102504. u.push(_.transcodedPixels.buffer)
  102505. }
  102506. }
  102507. }
  102508. o.close(),
  102509. o.delete(),
  102510. l && (s = -1),
  102511. c ? postMessage({
  102512. action: "transcode",
  102513. success: c,
  102514. id: i.data.id,
  102515. fileInfo: a,
  102516. format: s
  102517. }, u) : postMessage({
  102518. action: "transcode",
  102519. success: c,
  102520. id: i.data.id
  102521. })
  102522. }
  102523. }
  102524. }
  102525. Object.defineProperty(um, "JSModuleURL", {
  102526. get: function() {
  102527. return nm.JSModuleURL
  102528. },
  102529. set: function(e) {
  102530. nm.JSModuleURL = e
  102531. }
  102532. }),
  102533. Object.defineProperty(um, "WasmModuleURL", {
  102534. get: function() {
  102535. return nm.WasmModuleURL
  102536. },
  102537. set: function(e) {
  102538. nm.WasmModuleURL = e
  102539. }
  102540. });
  102541. var dm = function() {
  102542. function e() {
  102543. this.supportCascades = !1
  102544. }
  102545. return e.prototype.canLoad = function(e) {
  102546. return oe(e, ".basis")
  102547. }
  102548. ,
  102549. e.prototype.loadCubeData = function(e, t, i, n, r) {
  102550. if (!Array.isArray(e)) {
  102551. var o = t.getEngine().getCaps()
  102552. , a = {
  102553. supportedCompressionFormats: {
  102554. etc1: !!o.etc1,
  102555. s3tc: !!o.s3tc,
  102556. pvrtc: !!o.pvrtc,
  102557. etc2: !!o.etc2
  102558. }
  102559. };
  102560. lm(e, a).then((function(e) {
  102561. var i = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
  102562. cm(t, e),
  102563. t.getEngine()._setCubeMapTextureParams(t, i),
  102564. t.isReady = !0,
  102565. t.onLoadedObservable.notifyObservers(t),
  102566. t.onLoadedObservable.clear(),
  102567. n && n()
  102568. }
  102569. )).catch((function(e) {
  102570. gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
  102571. t.isReady = !0,
  102572. r && r(e)
  102573. }
  102574. ))
  102575. }
  102576. }
  102577. ,
  102578. e.prototype.loadData = function(e, t, i) {
  102579. var n = t.getEngine().getCaps()
  102580. , r = {
  102581. supportedCompressionFormats: {
  102582. etc1: !!n.etc1,
  102583. s3tc: !!n.s3tc,
  102584. pvrtc: !!n.pvrtc,
  102585. etc2: !!n.etc2
  102586. }
  102587. };
  102588. lm(e, r).then((function(e) {
  102589. var n = e.fileInfo.images[0].levels[0]
  102590. , r = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
  102591. i(n.width, n.height, r, -1 !== e.format, (function() {
  102592. cm(t, e)
  102593. }
  102594. ))
  102595. }
  102596. )).catch((function() {
  102597. gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
  102598. i(0, 0, !1, !1, (function() {}
  102599. ), !0)
  102600. }
  102601. ))
  102602. }
  102603. ,
  102604. e
  102605. }();
  102606. vr._TextureLoaders.push(new dm);
  102607. var pm = function(e) {
  102608. function t(t, i, n, r, o, s) {
  102609. var l = this
  102610. , c = !(!o || !o.generateMipMaps) && o.generateMipMaps
  102611. , u = !(!o || !o.generateDepthTexture) && o.generateDepthTexture
  102612. , h = o && o.depthTextureFormat ? o.depthTextureFormat : a.TEXTUREFORMAT_DEPTH16
  102613. , d = !o || void 0 === o.doNotChangeAspectRatio || o.doNotChangeAspectRatio
  102614. , p = !(!o || !o.drawOnlyOnFirstAttachmentByDefault) && o.drawOnlyOnFirstAttachmentByDefault;
  102615. if (!(l = e.call(this, t, i, r, c, d, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0) || this).isSupported)
  102616. return l.dispose(),
  102617. l;
  102618. var f = []
  102619. , _ = [];
  102620. l._initTypes(n, f, _, o);
  102621. var m = !o || void 0 === o.generateDepthBuffer || o.generateDepthBuffer
  102622. , g = !(!o || void 0 === o.generateStencilBuffer) && o.generateStencilBuffer;
  102623. return l._size = i,
  102624. l._multiRenderTargetOptions = {
  102625. samplingModes: _,
  102626. generateMipMaps: c,
  102627. generateDepthBuffer: m,
  102628. generateStencilBuffer: g,
  102629. generateDepthTexture: u,
  102630. depthTextureFormat: h,
  102631. types: f,
  102632. textureCount: n
  102633. },
  102634. l._count = n,
  102635. l._drawOnlyOnFirstAttachmentByDefault = p,
  102636. n > 0 && (l._createInternalTextures(),
  102637. l._createTextures(s)),
  102638. l
  102639. }
  102640. return U(t, e),
  102641. Object.defineProperty(t.prototype, "isSupported", {
  102642. get: function() {
  102643. var e, t;
  102644. return null !== (t = null === (e = this._engine) || void 0 === e ? void 0 : e.getCaps().drawBuffersExtension) && void 0 !== t && t
  102645. },
  102646. enumerable: !1,
  102647. configurable: !0
  102648. }),
  102649. Object.defineProperty(t.prototype, "textures", {
  102650. get: function() {
  102651. return this._textures
  102652. },
  102653. enumerable: !1,
  102654. configurable: !0
  102655. }),
  102656. Object.defineProperty(t.prototype, "count", {
  102657. get: function() {
  102658. return this._count
  102659. },
  102660. enumerable: !1,
  102661. configurable: !0
  102662. }),
  102663. Object.defineProperty(t.prototype, "depthTexture", {
  102664. get: function() {
  102665. return this._textures[this._textures.length - 1]
  102666. },
  102667. enumerable: !1,
  102668. configurable: !0
  102669. }),
  102670. Object.defineProperty(t.prototype, "wrapU", {
  102671. set: function(e) {
  102672. if (this._textures)
  102673. for (var t = 0; t < this._textures.length; t++)
  102674. this._textures[t].wrapU = e
  102675. },
  102676. enumerable: !1,
  102677. configurable: !0
  102678. }),
  102679. Object.defineProperty(t.prototype, "wrapV", {
  102680. set: function(e) {
  102681. if (this._textures)
  102682. for (var t = 0; t < this._textures.length; t++)
  102683. this._textures[t].wrapV = e
  102684. },
  102685. enumerable: !1,
  102686. configurable: !0
  102687. }),
  102688. t.prototype._initTypes = function(e, t, i, n) {
  102689. for (var r = 0; r < e; r++)
  102690. n && n.types && void 0 !== n.types[r] ? t.push(n.types[r]) : t.push(n && n.defaultType ? n.defaultType : a.TEXTURETYPE_UNSIGNED_INT),
  102691. n && n.samplingModes && void 0 !== n.samplingModes[r] ? i.push(n.samplingModes[r]) : i.push(io.BILINEAR_SAMPLINGMODE)
  102692. }
  102693. ,
  102694. t.prototype._rebuild = function(e, t) {
  102695. if (void 0 === e && (e = !1),
  102696. !(this._count < 1)) {
  102697. this.releaseInternalTextures(),
  102698. this._createInternalTextures(),
  102699. e && (this._releaseTextures(),
  102700. this._createTextures(t));
  102701. for (var i = this._renderTarget.textures, n = 0; n < i.length; n++)
  102702. this._textures[n]._texture = i[n];
  102703. 1 !== this.samples && this._renderTarget.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, !0)
  102704. }
  102705. }
  102706. ,
  102707. t.prototype._createInternalTextures = function() {
  102708. this._renderTarget = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault),
  102709. this._texture = this._renderTarget.texture
  102710. }
  102711. ,
  102712. t.prototype._releaseTextures = function() {
  102713. if (this._textures)
  102714. for (var e = 0; e < this._textures.length; e++)
  102715. this._textures[e]._texture = null,
  102716. this._textures[e].dispose()
  102717. }
  102718. ,
  102719. t.prototype._createTextures = function(e) {
  102720. var t = this._renderTarget.textures;
  102721. this._textures = [];
  102722. for (var i = 0; i < t.length; i++) {
  102723. var n = new io(null,this.getScene());
  102724. (null == e ? void 0 : e[i]) && (n.name = e[i]),
  102725. n._texture = t[i],
  102726. this._textures.push(n)
  102727. }
  102728. }
  102729. ,
  102730. t.prototype.setInternalTexture = function(e, t, i) {
  102731. void 0 === i && (i = !0),
  102732. this.renderTarget && (0 === t && (this._texture = e),
  102733. this.renderTarget.setTexture(e, t, i),
  102734. this.textures[t] || (this.textures[t] = new io(null,this.getScene())),
  102735. this.textures[t]._texture = e,
  102736. this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0,
  102737. this._multiRenderTargetOptions.types && (this._multiRenderTargetOptions.types[t] = e.type),
  102738. this._multiRenderTargetOptions.samplingModes && (this._multiRenderTargetOptions.samplingModes[t] = e.samplingMode))
  102739. }
  102740. ,
  102741. Object.defineProperty(t.prototype, "samples", {
  102742. get: function() {
  102743. return this._samples
  102744. },
  102745. set: function(e) {
  102746. this._renderTarget ? this._samples = this._renderTarget.setSamples(e) : this._samples = e
  102747. },
  102748. enumerable: !1,
  102749. configurable: !0
  102750. }),
  102751. t.prototype.resize = function(e) {
  102752. this._size = e,
  102753. this._rebuild()
  102754. }
  102755. ,
  102756. t.prototype.updateCount = function(e, t, i) {
  102757. this._multiRenderTargetOptions.textureCount = e,
  102758. this._count = e;
  102759. var n = []
  102760. , r = [];
  102761. this._initTypes(e, n, r, t),
  102762. this._multiRenderTargetOptions.types = n,
  102763. this._multiRenderTargetOptions.samplingModes = r,
  102764. this._rebuild(!0, i)
  102765. }
  102766. ,
  102767. t.prototype._unbindFrameBuffer = function(e, t) {
  102768. var i = this;
  102769. this._renderTarget && e.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, (function() {
  102770. i.onAfterRenderObservable.notifyObservers(t)
  102771. }
  102772. ))
  102773. }
  102774. ,
  102775. t.prototype.dispose = function(t) {
  102776. void 0 === t && (t = !1),
  102777. this._releaseTextures(),
  102778. t ? this._texture = null : this.releaseInternalTextures(),
  102779. e.prototype.dispose.call(this)
  102780. }
  102781. ,
  102782. t.prototype.releaseInternalTextures = function() {
  102783. var e, t, i = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.textures;
  102784. if (i) {
  102785. for (var n = i.length - 1; n >= 0; n--)
  102786. this._textures[n]._texture = null;
  102787. null === (t = this._renderTarget) || void 0 === t || t.dispose(),
  102788. this._renderTarget = null
  102789. }
  102790. }
  102791. ,
  102792. t
  102793. }(ns)
  102794. , fm = function(e, t, i) {
  102795. this.id = e,
  102796. this.scale = t,
  102797. this.offset = i
  102798. }
  102799. , _m = function() {
  102800. function e(t, i, n, r) {
  102801. var o, a, s, l, c, u, h, d, p, f, _, m, g;
  102802. return this.name = t,
  102803. this.meshes = i,
  102804. this.scene = r,
  102805. this.options = n,
  102806. this.options.map = null !== (o = this.options.map) && void 0 !== o ? o : ["ambientTexture", "bumpTexture", "diffuseTexture", "emissiveTexture", "lightmapTexture", "opacityTexture", "reflectionTexture", "refractionTexture", "specularTexture"],
  102807. this.options.uvsIn = null !== (a = this.options.uvsIn) && void 0 !== a ? a : Bi.UVKind,
  102808. this.options.uvsOut = null !== (s = this.options.uvsOut) && void 0 !== s ? s : Bi.UVKind,
  102809. this.options.layout = null !== (l = this.options.layout) && void 0 !== l ? l : e.LAYOUT_STRIP,
  102810. this.options.layout === e.LAYOUT_COLNUM && (this.options.colnum = null !== (c = this.options.colnum) && void 0 !== c ? c : 8),
  102811. this.options.updateInputMeshes = null === (u = this.options.updateInputMeshes) || void 0 === u || u,
  102812. this.options.disposeSources = null === (h = this.options.disposeSources) || void 0 === h || h,
  102813. this._expecting = 0,
  102814. this.options.fillBlanks = null === (d = this.options.fillBlanks) || void 0 === d || d,
  102815. !0 === this.options.fillBlanks && (this.options.customFillColor = null !== (p = this.options.customFillColor) && void 0 !== p ? p : "black"),
  102816. this.options.frameSize = null !== (f = this.options.frameSize) && void 0 !== f ? f : 256,
  102817. this.options.paddingRatio = null !== (_ = this.options.paddingRatio) && void 0 !== _ ? _ : .0115,
  102818. this._paddingValue = Math.ceil(this.options.frameSize * this.options.paddingRatio),
  102819. this._paddingValue % 2 != 0 && this._paddingValue++,
  102820. this.options.paddingMode = null !== (m = this.options.paddingMode) && void 0 !== m ? m : e.SUBUV_WRAP,
  102821. this.options.paddingMode === e.SUBUV_COLOR && (this.options.paddingColor = null !== (g = this.options.paddingColor) && void 0 !== g ? g : new N(0,0,0,1)),
  102822. this.sets = {},
  102823. this.frames = [],
  102824. this
  102825. }
  102826. return e.prototype._createFrames = function(e) {
  102827. for (var t = this, i = this._calculateSize(), n = new A(1,1).divide(i), r = 0, o = this._expecting, a = this.meshes.length, s = Object.keys(this.sets), l = 0; l < s.length; l++) {
  102828. var c = s[l]
  102829. , u = new Ds(this.name + ".TexturePack." + c + "Set",{
  102830. width: i.x,
  102831. height: i.y
  102832. },this.scene,!0,io.TRILINEAR_SAMPLINGMODE,vr.TEXTUREFORMAT_RGBA)
  102833. , h = u.getContext();
  102834. h.fillStyle = "rgba(0,0,0,0)",
  102835. h.fillRect(0, 0, i.x, i.y),
  102836. u.update(!1),
  102837. this.sets[c] = u
  102838. }
  102839. var d = this.options.frameSize || 256
  102840. , p = this._paddingValue
  102841. , f = d + 2 * p;
  102842. for (l = 0; l < a; l++)
  102843. for (var _ = this.meshes[l].material, m = function(a) {
  102844. var c = new Ds("temp",f,g.scene,!0)
  102845. , u = c.getContext()
  102846. , h = g._getFrameOffset(l)
  102847. , m = function() {
  102848. r++,
  102849. c.update(!1);
  102850. var a = u.getImageData(0, 0, f, f)
  102851. , s = t.sets[v];
  102852. if (s.getContext().putImageData(a, i.x * h.x, i.y * h.y),
  102853. c.dispose(),
  102854. s.update(!1),
  102855. r == o)
  102856. return t._calculateMeshUVFrames(d, p, i, n, t.options.updateInputMeshes || !1),
  102857. void e()
  102858. }
  102859. , v = s[a] || "_blank";
  102860. if (_ && null !== _[v]) {
  102861. var y = _[v]
  102862. , b = new Image;
  102863. b.src = y instanceof Ds ? y.getContext().canvas.toDataURL("image/png") : y.url,
  102864. gi.SetCorsBehavior(b.src, b),
  102865. b.onload = function() {
  102866. u.fillStyle = "rgba(0,0,0,0)",
  102867. u.fillRect(0, 0, f, f),
  102868. c.update(!1),
  102869. u.setTransform(1, 0, 0, -1, 0, 0);
  102870. var e = [0, 0, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -2, 0, -1, 1, -1];
  102871. switch (t.options.paddingMode) {
  102872. case 0:
  102873. for (var i = 0; i < 9; i++)
  102874. u.drawImage(b, 0, 0, b.width, b.height, p + d * e[i], p + d * e[i + 1] - f, d, d);
  102875. break;
  102876. case 1:
  102877. for (var n = 0; n < p; n++)
  102878. u.drawImage(b, 0, 0, b.width, b.height, n + d * e[0], p - f, d, d),
  102879. u.drawImage(b, 0, 0, b.width, b.height, 2 * p - n, p - f, d, d),
  102880. u.drawImage(b, 0, 0, b.width, b.height, p, n - f, d, d),
  102881. u.drawImage(b, 0, 0, b.width, b.height, p, 2 * p - n - f, d, d);
  102882. u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d);
  102883. break;
  102884. case 2:
  102885. u.fillStyle = (t.options.paddingColor || D.Black()).toHexString(),
  102886. u.fillRect(0, 0, f, -f),
  102887. u.clearRect(p, p, d, d),
  102888. u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d)
  102889. }
  102890. u.setTransform(1, 0, 0, 1, 0, 0),
  102891. m()
  102892. }
  102893. } else
  102894. u.fillStyle = "rgba(0,0,0,0)",
  102895. g.options.fillBlanks && (u.fillStyle = g.options.customFillColor),
  102896. u.fillRect(0, 0, f, f),
  102897. m()
  102898. }, g = this, v = 0; v < s.length; v++)
  102899. m(v)
  102900. }
  102901. ,
  102902. e.prototype._calculateSize = function() {
  102903. var e = this.meshes.length || 0
  102904. , t = this.options.frameSize || 0
  102905. , i = this._paddingValue || 0;
  102906. switch (this.options.layout) {
  102907. case 0:
  102908. return new A(t * e + 2 * i * e,t + 2 * i);
  102909. case 1:
  102910. var n = Math.max(2, Math.ceil(Math.sqrt(e)))
  102911. , r = t * n + 2 * i * n;
  102912. return new A(r,r);
  102913. case 2:
  102914. var o = this.options.colnum || 1
  102915. , a = Math.max(1, Math.ceil(e / o));
  102916. return new A(t * o + 2 * i * o,t * a + 2 * i * a)
  102917. }
  102918. return A.Zero()
  102919. }
  102920. ,
  102921. e.prototype._calculateMeshUVFrames = function(e, t, i, n, r) {
  102922. for (var o = this.meshes.length, a = 0; a < o; a++) {
  102923. var s = this.meshes[a]
  102924. , l = new A(e / i.x,e / i.y)
  102925. , c = n.clone().scale(t)
  102926. , u = this._getFrameOffset(a).add(c)
  102927. , h = new fm(a,l,u);
  102928. this.frames.push(h),
  102929. r && (this._updateMeshUV(s, a),
  102930. this._updateTextureReferences(s))
  102931. }
  102932. }
  102933. ,
  102934. e.prototype._getFrameOffset = function(e) {
  102935. var t, i, n, r = this.meshes.length;
  102936. switch (this.options.layout) {
  102937. case 0:
  102938. return new A(e * (t = 1 / r),0);
  102939. case 1:
  102940. var o = Math.max(2, Math.ceil(Math.sqrt(r)));
  102941. return i = Math.floor(e / o),
  102942. new A((n = e - i * o) * (t = 1 / o),i * t);
  102943. case 2:
  102944. var a = this.options.colnum || 1
  102945. , s = Math.max(1, Math.ceil(r / a));
  102946. return i = e - (n = Math.floor(e / s)) * s,
  102947. t = new A(1 / a,1 / s),
  102948. new A(n * t.x,i * t.y)
  102949. }
  102950. return A.Zero()
  102951. }
  102952. ,
  102953. e.prototype._updateMeshUV = function(e, t) {
  102954. var i = this.frames[t]
  102955. , n = e.getVerticesData(this.options.uvsIn || Bi.UVKind)
  102956. , r = []
  102957. , o = 0;
  102958. n.length && (o = n.length || 0);
  102959. for (var a = 0; a < o; a += 2)
  102960. r.push(n[a] * i.scale.x + i.offset.x, n[a + 1] * i.scale.y + i.offset.y);
  102961. e.setVerticesData(this.options.uvsOut || Bi.UVKind, r)
  102962. }
  102963. ,
  102964. e.prototype._updateTextureReferences = function(e, t) {
  102965. void 0 === t && (t = !1);
  102966. for (var i = e.material, n = Object.keys(this.sets), r = function(e) {
  102967. e.dispose && e.dispose()
  102968. }, o = 0; o < n.length; o++) {
  102969. var a = n[o];
  102970. if (t)
  102971. null !== i[a] && r(i[a]),
  102972. i[a] = this.sets[a];
  102973. else {
  102974. if (!i)
  102975. return;
  102976. null !== i[a] && (r(i[a]),
  102977. i[a] = this.sets[a])
  102978. }
  102979. }
  102980. }
  102981. ,
  102982. e.prototype.setMeshToFrame = function(e, t, i) {
  102983. void 0 === i && (i = !1),
  102984. this._updateMeshUV(e, t),
  102985. i && this._updateTextureReferences(e, !0)
  102986. }
  102987. ,
  102988. e.prototype.processAsync = function() {
  102989. var e = this;
  102990. return new Promise((function(t, i) {
  102991. try {
  102992. if (0 === e.meshes.length)
  102993. return void t();
  102994. for (var n = 0, r = function(i) {
  102995. var r = e.meshes[i]
  102996. , o = r.material;
  102997. if (!o)
  102998. return ++n === e.meshes.length ? {
  102999. value: e._createFrames(t)
  103000. } : "continue";
  103001. o.forceCompilationAsync(r).then((function() {
  103002. !function(i) {
  103003. if (n++,
  103004. e.options.map) {
  103005. for (var r = 0; r < e.options.map.length; r++)
  103006. null !== i[e.options.map[r]] && (e.sets[e.options.map[r]] || (e.sets[e.options.map[r]] = !0),
  103007. e._expecting++);
  103008. n === e.meshes.length && e._createFrames(t)
  103009. }
  103010. }(o)
  103011. }
  103012. ))
  103013. }, o = 0; o < e.meshes.length; o++) {
  103014. var a = r(o);
  103015. if ("object" == typeof a)
  103016. return a.value
  103017. }
  103018. } catch (e) {
  103019. return i(e)
  103020. }
  103021. }
  103022. ))
  103023. }
  103024. ,
  103025. e.prototype.dispose = function() {
  103026. for (var e = Object.keys(this.sets), t = 0; t < e.length; t++) {
  103027. var i = e[t];
  103028. this.sets[i].dispose()
  103029. }
  103030. }
  103031. ,
  103032. e.prototype.download = function(e, t) {
  103033. var i = this;
  103034. void 0 === e && (e = "png"),
  103035. void 0 === t && (t = 1),
  103036. setTimeout((function() {
  103037. var n = {
  103038. name: i.name,
  103039. sets: {},
  103040. options: {},
  103041. frames: []
  103042. }
  103043. , r = Object.keys(i.sets)
  103044. , o = Object.keys(i.options);
  103045. try {
  103046. for (var a = 0; a < r.length; a++) {
  103047. var s = r[a]
  103048. , l = i.sets[s];
  103049. n.sets[s] = l.getContext().canvas.toDataURL("image/" + e, t)
  103050. }
  103051. for (a = 0; a < o.length; a++) {
  103052. var c = o[a];
  103053. n.options[c] = i.options[c]
  103054. }
  103055. for (a = 0; a < i.frames.length; a++) {
  103056. var u = i.frames[a];
  103057. n.frames.push(u.scale.x, u.scale.y, u.offset.x, u.offset.y)
  103058. }
  103059. } catch (e) {
  103060. return void K.Warn("Unable to download: " + e)
  103061. }
  103062. var h = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(n, null, 4))
  103063. , d = document.createElement("a");
  103064. d.setAttribute("href", h),
  103065. d.setAttribute("download", i.name + "_texurePackage.json"),
  103066. document.body.appendChild(d),
  103067. d.click(),
  103068. d.remove()
  103069. }
  103070. ), 0)
  103071. }
  103072. ,
  103073. e.prototype.updateFromJSON = function(e) {
  103074. try {
  103075. var t = JSON.parse(e);
  103076. this.name = t.name;
  103077. for (var i = Object.keys(t.options), n = 0; n < i.length; n++)
  103078. this.options[i[n]] = t.options[i[n]];
  103079. for (n = 0; n < t.frames.length; n += 4) {
  103080. var r = new fm(n / 4,new A(t.frames[n],t.frames[n + 1]),new A(t.frames[n + 2],t.frames[n + 3]));
  103081. this.frames.push(r)
  103082. }
  103083. var o = Object.keys(t.sets);
  103084. for (n = 0; n < o.length; n++) {
  103085. var a = new io(t.sets[o[n]],this.scene,!1,!1);
  103086. this.sets[o[n]] = a
  103087. }
  103088. } catch (e) {
  103089. K.Warn("Unable to update from JSON: " + e)
  103090. }
  103091. }
  103092. ,
  103093. e.LAYOUT_STRIP = 0,
  103094. e.LAYOUT_POWER2 = 1,
  103095. e.LAYOUT_COLNUM = 2,
  103096. e.SUBUV_WRAP = 0,
  103097. e.SUBUV_EXTEND = 1,
  103098. e.SUBUV_COLOR = 2,
  103099. e
  103100. }()
  103101. , mm = function(e) {
  103102. function t(t, i, n, r, o, a) {
  103103. var s = e.call(this, t, n, null, r, o, a) || this;
  103104. return s._animate = !0,
  103105. s._time = 0,
  103106. s._texturePath = i,
  103107. s._loadJson(i),
  103108. s.refreshRate = 1,
  103109. s
  103110. }
  103111. return U(t, e),
  103112. t.prototype._loadJson = function(e) {
  103113. var t = this
  103114. , i = function() {
  103115. try {
  103116. t.setFragment(t._texturePath)
  103117. } catch (e) {
  103118. K.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture")
  103119. }
  103120. }
  103121. , n = e + "/config.json"
  103122. , r = new Ye;
  103123. r.open("GET", n),
  103124. r.addEventListener("load", (function() {
  103125. if (200 === r.status || r.responseText && r.responseText.length > 0)
  103126. try {
  103127. t._config = JSON.parse(r.response),
  103128. t.updateShaderUniforms(),
  103129. t.updateTextures(),
  103130. t.setFragment(t._texturePath + "/custom"),
  103131. t._animate = t._config.animate,
  103132. t.refreshRate = t._config.refreshrate
  103133. } catch (e) {
  103134. i()
  103135. }
  103136. else
  103137. i()
  103138. }
  103139. ), !1),
  103140. r.addEventListener("error", (function() {
  103141. i()
  103142. }
  103143. ), !1);
  103144. try {
  103145. r.send()
  103146. } catch (e) {
  103147. K.Error("CustomProceduralTexture: Error on XHR send request.")
  103148. }
  103149. }
  103150. ,
  103151. t.prototype.isReady = function() {
  103152. if (!e.prototype.isReady.call(this))
  103153. return !1;
  103154. for (var t in this._textures)
  103155. if (!this._textures[t].isReady())
  103156. return !1;
  103157. return !0
  103158. }
  103159. ,
  103160. t.prototype.render = function(t) {
  103161. var i = this.getScene();
  103162. this._animate && i && (this._time += .03 * i.getAnimationRatio(),
  103163. this.updateShaderUniforms()),
  103164. e.prototype.render.call(this, t)
  103165. }
  103166. ,
  103167. t.prototype.updateTextures = function() {
  103168. for (var e = 0; e < this._config.sampler2Ds.length; e++)
  103169. this.setTexture(this._config.sampler2Ds[e].sample2Dname, new io(this._texturePath + "/" + this._config.sampler2Ds[e].textureRelativeUrl,this.getScene()))
  103170. }
  103171. ,
  103172. t.prototype.updateShaderUniforms = function() {
  103173. if (this._config)
  103174. for (var e = 0; e < this._config.uniforms.length; e++) {
  103175. var t = this._config.uniforms[e];
  103176. switch (t.type) {
  103177. case "float":
  103178. this.setFloat(t.name, t.value);
  103179. break;
  103180. case "color3":
  103181. this.setColor3(t.name, new D(t.r,t.g,t.b));
  103182. break;
  103183. case "color4":
  103184. this.setColor4(t.name, new N(t.r,t.g,t.b,t.a));
  103185. break;
  103186. case "vector2":
  103187. this.setVector2(t.name, new A(t.x,t.y));
  103188. break;
  103189. case "vector3":
  103190. this.setVector3(t.name, new x(t.x,t.y,t.z))
  103191. }
  103192. }
  103193. this.setFloat("time", this._time)
  103194. }
  103195. ,
  103196. Object.defineProperty(t.prototype, "animate", {
  103197. get: function() {
  103198. return this._animate
  103199. },
  103200. set: function(e) {
  103201. this._animate = e
  103202. },
  103203. enumerable: !1,
  103204. configurable: !0
  103205. }),
  103206. t
  103207. }(xf);
  103208. Pt.ShadersStore.noisePixelShader = "uniform float brightness;\nuniform float persistence;\nuniform float timeScale;\nvarying vec2 vUV;\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y); \nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i<OCTAVES; i++)\n{\nfrequency=pow(2.0,float(i));\namplitude=pow(persistence,float(i));\nsum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;\n}\nreturn sum;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat x=abs(vUV.x);\nfloat y=abs(vUV.y);\nfloat noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);\ngl_FragColor=vec4(noise,noise,noise,1.0);\n}\n";
  103209. var gm = function(e) {
  103210. function t(t, i, n, r, o) {
  103211. void 0 === i && (i = 256),
  103212. void 0 === n && (n = E.LastCreatedScene);
  103213. var a = e.call(this, t, i, "noise", n, r, o) || this;
  103214. return a.time = 0,
  103215. a.brightness = .2,
  103216. a.octaves = 3,
  103217. a.persistence = .8,
  103218. a.animationSpeedFactor = 1,
  103219. a.autoClear = !1,
  103220. a._updateShaderUniforms(),
  103221. a
  103222. }
  103223. return U(t, e),
  103224. t.prototype._updateShaderUniforms = function() {
  103225. var e = this.getScene();
  103226. e && (this.time += e.getAnimationRatio() * this.animationSpeedFactor * .01,
  103227. this.setFloat("brightness", this.brightness),
  103228. this.setFloat("persistence", this.persistence),
  103229. this.setFloat("timeScale", this.time))
  103230. }
  103231. ,
  103232. t.prototype._getDefines = function() {
  103233. return "#define OCTAVES " + (0 | this.octaves)
  103234. }
  103235. ,
  103236. t.prototype.render = function(t) {
  103237. this._updateShaderUniforms(),
  103238. e.prototype.render.call(this, t)
  103239. }
  103240. ,
  103241. t.prototype.serialize = function() {
  103242. var e = {
  103243. customType: "BABYLON.NoiseProceduralTexture"
  103244. };
  103245. return e.brightness = this.brightness,
  103246. e.octaves = this.octaves,
  103247. e.persistence = this.persistence,
  103248. e.animationSpeedFactor = this.animationSpeedFactor,
  103249. e.size = this.getSize().width,
  103250. e.generateMipMaps = this._generateMipMaps,
  103251. e.time = this.time,
  103252. e
  103253. }
  103254. ,
  103255. t.prototype.clone = function() {
  103256. var e = this.getSize()
  103257. , i = new t(this.name,e.width,this.getScene(),this._fallbackTexture ? this._fallbackTexture : void 0,this._generateMipMaps);
  103258. return i.hasAlpha = this.hasAlpha,
  103259. i.level = this.level,
  103260. i.coordinatesMode = this.coordinatesMode,
  103261. i.brightness = this.brightness,
  103262. i.octaves = this.octaves,
  103263. i.persistence = this.persistence,
  103264. i.animationSpeedFactor = this.animationSpeedFactor,
  103265. i.time = this.time,
  103266. i
  103267. }
  103268. ,
  103269. t.Parse = function(e, i) {
  103270. var n, r = new t(e.name,e.size,i,void 0,e.generateMipMaps);
  103271. return r.brightness = e.brightness,
  103272. r.octaves = e.octaves,
  103273. r.persistence = e.persistence,
  103274. r.animationSpeedFactor = e.animationSpeedFactor,
  103275. r.time = null !== (n = e.time) && void 0 !== n ? n : 0,
  103276. r
  103277. }
  103278. ,
  103279. t
  103280. }(xf);
  103281. y("BABYLON.NoiseProceduralTexture", gm);
  103282. var vm = function(e) {
  103283. function t(t, i, n, r, o, s, l, c, u) {
  103284. void 0 === r && (r = a.TEXTUREFORMAT_RGBA),
  103285. void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
  103286. void 0 === s && (s = !1),
  103287. void 0 === l && (l = !1),
  103288. void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
  103289. void 0 === u && (u = null);
  103290. var h = e.call(this, "", t) || this;
  103291. return h._texture = t.getEngine().createRawCubeTexture(i, n, r, o, s, l, c, u),
  103292. h
  103293. }
  103294. return U(t, e),
  103295. t.prototype.update = function(e, t, i, n, r) {
  103296. void 0 === r && (r = null),
  103297. this._texture.getEngine().updateRawCubeTexture(this._texture, e, t, i, n, r)
  103298. }
  103299. ,
  103300. t.prototype.updateRGBDAsync = function(e, t, i, n) {
  103301. return void 0 === t && (t = null),
  103302. void 0 === i && (i = .8),
  103303. void 0 === n && (n = 0),
  103304. Kc(this._texture, e, t, i, n).then((function() {}
  103305. ))
  103306. }
  103307. ,
  103308. t.prototype.clone = function() {
  103309. var e = this;
  103310. return Ge.Clone((function() {
  103311. var i = e.getScene()
  103312. , n = e._texture
  103313. , r = new t(i,n._bufferViewArray,n.width,n.format,n.type,n.generateMipMaps,n.invertY,n.samplingMode,n._compression);
  103314. return n.source === At.CubeRawRGBD && r.updateRGBDAsync(n._bufferViewArrayArray, n._sphericalPolynomial, n._lodGenerationScale, n._lodGenerationOffset),
  103315. r
  103316. }
  103317. ), this)
  103318. }
  103319. ,
  103320. t
  103321. }(Bd)
  103322. , ym = function(e) {
  103323. function t(t, i, n, r, o, s, l, c, u, h) {
  103324. void 0 === l && (l = !0),
  103325. void 0 === c && (c = !1),
  103326. void 0 === u && (u = io.TRILINEAR_SAMPLINGMODE),
  103327. void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
  103328. var d = e.call(this, null, s, !l, c) || this;
  103329. return d.format = o,
  103330. d._texture = s.getEngine().createRawTexture3D(t, i, n, r, o, l, c, u, null, h),
  103331. d.is3D = !0,
  103332. d
  103333. }
  103334. return U(t, e),
  103335. t.prototype.update = function(e) {
  103336. this._texture && this._getEngine().updateRawTexture3D(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
  103337. }
  103338. ,
  103339. t
  103340. }(io)
  103341. , bm = function(e) {
  103342. function t(t, i, n, r) {
  103343. var o = e.call(this, t, i, n, r, !0) || this;
  103344. return o.refractionPlane = new hn(0,1,0,1),
  103345. o.depth = 2,
  103346. o.onBeforeRenderObservable.add((function() {
  103347. o.getScene().clipPlane = o.refractionPlane
  103348. }
  103349. )),
  103350. o.onAfterRenderObservable.add((function() {
  103351. o.getScene().clipPlane = null
  103352. }
  103353. )),
  103354. o
  103355. }
  103356. return U(t, e),
  103357. t.prototype.clone = function() {
  103358. var e = this.getScene();
  103359. if (!e)
  103360. return this;
  103361. var i = this.getSize()
  103362. , n = new t(this.name,i.width,e,this._generateMipMaps);
  103363. return n.hasAlpha = this.hasAlpha,
  103364. n.level = this.level,
  103365. n.refractionPlane = this.refractionPlane.clone(),
  103366. this.renderList && (n.renderList = this.renderList.slice(0)),
  103367. n.depth = this.depth,
  103368. n
  103369. }
  103370. ,
  103371. t.prototype.serialize = function() {
  103372. if (!this.name)
  103373. return null;
  103374. var t = e.prototype.serialize.call(this);
  103375. return t.mirrorPlane = this.refractionPlane.asArray(),
  103376. t.depth = this.depth,
  103377. t
  103378. }
  103379. ,
  103380. t
  103381. }(ns)
  103382. , Tm = function(e) {
  103383. function t(t, i, n) {
  103384. var r = e.call(this, null) || this;
  103385. return r._renderTarget = null,
  103386. r._engine = t,
  103387. r._renderTargetOptions = n,
  103388. r.resize(i),
  103389. r
  103390. }
  103391. return U(t, e),
  103392. Object.defineProperty(t.prototype, "renderTarget", {
  103393. get: function() {
  103394. return this._renderTarget
  103395. },
  103396. enumerable: !1,
  103397. configurable: !0
  103398. }),
  103399. t.prototype.resize = function(e) {
  103400. var t;
  103401. null === (t = this._renderTarget) || void 0 === t || t.dispose(),
  103402. this._renderTarget = null,
  103403. this._texture = null,
  103404. this._size = e,
  103405. this._engine && (this._renderTarget = this._engine.createRenderTargetTexture(this._size, this._renderTargetOptions)),
  103406. this._texture = this.renderTarget.texture
  103407. }
  103408. ,
  103409. t.prototype.getInternalTexture = function() {
  103410. return this._texture
  103411. }
  103412. ,
  103413. t.prototype.getClassName = function() {
  103414. return "ThinRenderTargetTexture"
  103415. }
  103416. ,
  103417. t.prototype.dispose = function(e) {
  103418. var t;
  103419. void 0 === e && (e = !1),
  103420. null === (t = this._renderTarget) || void 0 === t || t.dispose(!0),
  103421. this._renderTarget = null,
  103422. e || this.dispose()
  103423. }
  103424. ,
  103425. t
  103426. }(qr)
  103427. , Em = function(e) {
  103428. function t(t) {
  103429. var i = e.call(this, t, Dp.Vertex) || this;
  103430. return i.registerInput("matricesIndices", Op.Vector4),
  103431. i.registerInput("matricesWeights", Op.Vector4),
  103432. i.registerInput("matricesIndicesExtra", Op.Vector4, !0),
  103433. i.registerInput("matricesWeightsExtra", Op.Vector4, !0),
  103434. i.registerInput("world", Op.Matrix),
  103435. i.registerOutput("output", Op.Matrix),
  103436. i
  103437. }
  103438. return U(t, e),
  103439. t.prototype.initialize = function(e) {
  103440. e._excludeVariableName("boneSampler"),
  103441. e._excludeVariableName("boneTextureWidth"),
  103442. e._excludeVariableName("mBones"),
  103443. e._excludeVariableName("BonesPerMesh")
  103444. }
  103445. ,
  103446. t.prototype.getClassName = function() {
  103447. return "BonesBlock"
  103448. }
  103449. ,
  103450. Object.defineProperty(t.prototype, "matricesIndices", {
  103451. get: function() {
  103452. return this._inputs[0]
  103453. },
  103454. enumerable: !1,
  103455. configurable: !0
  103456. }),
  103457. Object.defineProperty(t.prototype, "matricesWeights", {
  103458. get: function() {
  103459. return this._inputs[1]
  103460. },
  103461. enumerable: !1,
  103462. configurable: !0
  103463. }),
  103464. Object.defineProperty(t.prototype, "matricesIndicesExtra", {
  103465. get: function() {
  103466. return this._inputs[2]
  103467. },
  103468. enumerable: !1,
  103469. configurable: !0
  103470. }),
  103471. Object.defineProperty(t.prototype, "matricesWeightsExtra", {
  103472. get: function() {
  103473. return this._inputs[3]
  103474. },
  103475. enumerable: !1,
  103476. configurable: !0
  103477. }),
  103478. Object.defineProperty(t.prototype, "world", {
  103479. get: function() {
  103480. return this._inputs[4]
  103481. },
  103482. enumerable: !1,
  103483. configurable: !0
  103484. }),
  103485. Object.defineProperty(t.prototype, "output", {
  103486. get: function() {
  103487. return this._outputs[0]
  103488. },
  103489. enumerable: !1,
  103490. configurable: !0
  103491. }),
  103492. t.prototype.autoConfigure = function(e) {
  103493. if (!this.matricesIndices.isConnected) {
  103494. var t = e.getInputBlockByPredicate((function(e) {
  103495. return e.isAttribute && "matricesIndices" === e.name
  103496. }
  103497. ));
  103498. t || (t = new tf("matricesIndices")).setAsAttribute("matricesIndices"),
  103499. t.output.connectTo(this.matricesIndices)
  103500. }
  103501. if (!this.matricesWeights.isConnected) {
  103502. var i = e.getInputBlockByPredicate((function(e) {
  103503. return e.isAttribute && "matricesWeights" === e.name
  103504. }
  103505. ));
  103506. i || (i = new tf("matricesWeights")).setAsAttribute("matricesWeights"),
  103507. i.output.connectTo(this.matricesWeights)
  103508. }
  103509. if (!this.world.isConnected) {
  103510. var n = e.getInputBlockByPredicate((function(e) {
  103511. return e.systemValue === Qp.World
  103512. }
  103513. ));
  103514. n || (n = new tf("world")).setAsSystemValue(Qp.World),
  103515. n.output.connectTo(this.world)
  103516. }
  103517. }
  103518. ,
  103519. t.prototype.provideFallbacks = function(e, t) {
  103520. e && e.useBones && e.computeBonesUsingShaders && e.skeleton && t.addCPUSkinningFallback(0, e)
  103521. }
  103522. ,
  103523. t.prototype.bind = function(e, t, i) {
  103524. Mr.BindBonesParameters(i, e)
  103525. }
  103526. ,
  103527. t.prototype.prepareDefines = function(e, t, i) {
  103528. i._areAttributesDirty && Mr.PrepareDefinesForBones(e, i)
  103529. }
  103530. ,
  103531. t.prototype._buildBlock = function(t) {
  103532. e.prototype._buildBlock.call(this, t),
  103533. t.sharedData.blocksWithFallbacks.push(this),
  103534. t.sharedData.forcedBindableBlocks.push(this),
  103535. t.sharedData.blocksWithDefines.push(this),
  103536. t.uniforms.push("boneTextureWidth"),
  103537. t.uniforms.push("mBones"),
  103538. t.samplers.push("boneSampler");
  103539. var i = "//".concat(this.name);
  103540. t._emitFunctionFromInclude("bonesDeclaration", i, {
  103541. removeAttributes: !0,
  103542. removeUniforms: !1,
  103543. removeVaryings: !0,
  103544. removeIfDef: !1
  103545. });
  103546. var n = t._getFreeVariableName("influence");
  103547. t.compilationString += t._emitCodeFromInclude("bonesVertex", i, {
  103548. replaceStrings: [{
  103549. search: /finalWorld=finalWorld\*influence;/,
  103550. replace: ""
  103551. }, {
  103552. search: /influence/gm,
  103553. replace: n
  103554. }]
  103555. });
  103556. var r = this._outputs[0]
  103557. , o = this.world;
  103558. return t.compilationString += "#if NUM_BONE_INFLUENCERS>0\r\n",
  103559. t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, " * ").concat(n, ";\r\n"),
  103560. t.compilationString += "#else\r\n",
  103561. t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, ";\r\n"),
  103562. t.compilationString += "#endif\r\n",
  103563. this
  103564. }
  103565. ,
  103566. t
  103567. }(Wp);
  103568. y("BABYLON.BonesBlock", Em);
  103569. var Sm = function(e) {
  103570. function t(t) {
  103571. var i = e.call(this, t, Dp.Vertex) || this;
  103572. return i.registerInput("world0", Op.Vector4),
  103573. i.registerInput("world1", Op.Vector4),
  103574. i.registerInput("world2", Op.Vector4),
  103575. i.registerInput("world3", Op.Vector4),
  103576. i.registerInput("world", Op.Matrix, !0),
  103577. i.registerOutput("output", Op.Matrix),
  103578. i.registerOutput("instanceID", Op.Float),
  103579. i
  103580. }
  103581. return U(t, e),
  103582. t.prototype.getClassName = function() {
  103583. return "InstancesBlock"
  103584. }
  103585. ,
  103586. Object.defineProperty(t.prototype, "world0", {
  103587. get: function() {
  103588. return this._inputs[0]
  103589. },
  103590. enumerable: !1,
  103591. configurable: !0
  103592. }),
  103593. Object.defineProperty(t.prototype, "world1", {
  103594. get: function() {
  103595. return this._inputs[1]
  103596. },
  103597. enumerable: !1,
  103598. configurable: !0
  103599. }),
  103600. Object.defineProperty(t.prototype, "world2", {
  103601. get: function() {
  103602. return this._inputs[2]
  103603. },
  103604. enumerable: !1,
  103605. configurable: !0
  103606. }),
  103607. Object.defineProperty(t.prototype, "world3", {
  103608. get: function() {
  103609. return this._inputs[3]
  103610. },
  103611. enumerable: !1,
  103612. configurable: !0
  103613. }),
  103614. Object.defineProperty(t.prototype, "world", {
  103615. get: function() {
  103616. return this._inputs[4]
  103617. },
  103618. enumerable: !1,
  103619. configurable: !0
  103620. }),
  103621. Object.defineProperty(t.prototype, "output", {
  103622. get: function() {
  103623. return this._outputs[0]
  103624. },
  103625. enumerable: !1,
  103626. configurable: !0
  103627. }),
  103628. Object.defineProperty(t.prototype, "instanceID", {
  103629. get: function() {
  103630. return this._outputs[1]
  103631. },
  103632. enumerable: !1,
  103633. configurable: !0
  103634. }),
  103635. t.prototype.autoConfigure = function(e) {
  103636. if (!this.world0.connectedPoint) {
  103637. var t = e.getInputBlockByPredicate((function(e) {
  103638. return e.isAttribute && "world0" === e.name
  103639. }
  103640. ));
  103641. t || (t = new tf("world0")).setAsAttribute("world0"),
  103642. t.output.connectTo(this.world0)
  103643. }
  103644. if (!this.world1.connectedPoint) {
  103645. var i = e.getInputBlockByPredicate((function(e) {
  103646. return e.isAttribute && "world1" === e.name
  103647. }
  103648. ));
  103649. i || (i = new tf("world1")).setAsAttribute("world1"),
  103650. i.output.connectTo(this.world1)
  103651. }
  103652. if (!this.world2.connectedPoint) {
  103653. var n = e.getInputBlockByPredicate((function(e) {
  103654. return e.isAttribute && "world2" === e.name
  103655. }
  103656. ));
  103657. n || (n = new tf("world2")).setAsAttribute("world2"),
  103658. n.output.connectTo(this.world2)
  103659. }
  103660. if (!this.world3.connectedPoint) {
  103661. var r = e.getInputBlockByPredicate((function(e) {
  103662. return e.isAttribute && "world3" === e.name
  103663. }
  103664. ));
  103665. r || (r = new tf("world3")).setAsAttribute("world3"),
  103666. r.output.connectTo(this.world3)
  103667. }
  103668. if (!this.world.connectedPoint) {
  103669. var o = e.getInputBlockByPredicate((function(e) {
  103670. return e.isAttribute && "world" === e.name
  103671. }
  103672. ));
  103673. o || (o = new tf("world")).setAsSystemValue(Qp.World),
  103674. o.output.connectTo(this.world)
  103675. }
  103676. this.world.define = "!INSTANCES || THIN_INSTANCES"
  103677. }
  103678. ,
  103679. t.prototype.prepareDefines = function(e, t, i, n, r) {
  103680. void 0 === n && (n = !1);
  103681. var o = !1;
  103682. i.INSTANCES !== n && (i.setValue("INSTANCES", n),
  103683. o = !0),
  103684. r && i.THIN_INSTANCES !== !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances) && (i.setValue("THIN_INSTANCES", !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances)),
  103685. o = !0),
  103686. o && i.markAsUnprocessed()
  103687. }
  103688. ,
  103689. t.prototype._buildBlock = function(t) {
  103690. e.prototype._buildBlock.call(this, t);
  103691. var i = t.sharedData.scene.getEngine();
  103692. t.sharedData.blocksWithDefines.push(this);
  103693. var n = this._outputs[0]
  103694. , r = this._outputs[1]
  103695. , o = this.world0
  103696. , a = this.world1
  103697. , s = this.world2
  103698. , l = this.world3;
  103699. return t.compilationString += "#ifdef INSTANCES\r\n",
  103700. t.compilationString += this._declareOutput(n, t) + " = mat4(".concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ", ").concat(l.associatedVariableName, ");\r\n"),
  103701. t.compilationString += "#ifdef THIN_INSTANCES\r\n",
  103702. t.compilationString += "".concat(n.associatedVariableName, " = ").concat(this.world.associatedVariableName, " * ").concat(n.associatedVariableName, ";\r\n"),
  103703. t.compilationString += "#endif\r\n",
  103704. i._caps.canUseGLInstanceID ? t.compilationString += this._declareOutput(r, t) + " = float(gl_InstanceID);\r\n" : t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
  103705. t.compilationString += "#else\r\n",
  103706. t.compilationString += this._declareOutput(n, t) + " = ".concat(this.world.associatedVariableName, ";\r\n"),
  103707. t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
  103708. t.compilationString += "#endif\r\n",
  103709. this
  103710. }
  103711. ,
  103712. t
  103713. }(Wp);
  103714. y("BABYLON.InstancesBlock", Sm);
  103715. var Am = function(e) {
  103716. function t(t) {
  103717. var i = e.call(this, t, Dp.Vertex) || this;
  103718. return i.registerInput("position", Op.Vector3),
  103719. i.registerInput("normal", Op.Vector3),
  103720. i.registerInput("tangent", Op.Vector3),
  103721. i.registerInput("uv", Op.Vector2),
  103722. i.registerOutput("positionOutput", Op.Vector3),
  103723. i.registerOutput("normalOutput", Op.Vector3),
  103724. i.registerOutput("tangentOutput", Op.Vector3),
  103725. i.registerOutput("uvOutput", Op.Vector2),
  103726. i
  103727. }
  103728. return U(t, e),
  103729. t.prototype.getClassName = function() {
  103730. return "MorphTargetsBlock"
  103731. }
  103732. ,
  103733. Object.defineProperty(t.prototype, "position", {
  103734. get: function() {
  103735. return this._inputs[0]
  103736. },
  103737. enumerable: !1,
  103738. configurable: !0
  103739. }),
  103740. Object.defineProperty(t.prototype, "normal", {
  103741. get: function() {
  103742. return this._inputs[1]
  103743. },
  103744. enumerable: !1,
  103745. configurable: !0
  103746. }),
  103747. Object.defineProperty(t.prototype, "tangent", {
  103748. get: function() {
  103749. return this._inputs[2]
  103750. },
  103751. enumerable: !1,
  103752. configurable: !0
  103753. }),
  103754. Object.defineProperty(t.prototype, "uv", {
  103755. get: function() {
  103756. return this._inputs[3]
  103757. },
  103758. enumerable: !1,
  103759. configurable: !0
  103760. }),
  103761. Object.defineProperty(t.prototype, "positionOutput", {
  103762. get: function() {
  103763. return this._outputs[0]
  103764. },
  103765. enumerable: !1,
  103766. configurable: !0
  103767. }),
  103768. Object.defineProperty(t.prototype, "normalOutput", {
  103769. get: function() {
  103770. return this._outputs[1]
  103771. },
  103772. enumerable: !1,
  103773. configurable: !0
  103774. }),
  103775. Object.defineProperty(t.prototype, "tangentOutput", {
  103776. get: function() {
  103777. return this._outputs[2]
  103778. },
  103779. enumerable: !1,
  103780. configurable: !0
  103781. }),
  103782. Object.defineProperty(t.prototype, "uvOutput", {
  103783. get: function() {
  103784. return this._outputs[3]
  103785. },
  103786. enumerable: !1,
  103787. configurable: !0
  103788. }),
  103789. t.prototype.initialize = function(e) {
  103790. e._excludeVariableName("morphTargetInfluences")
  103791. }
  103792. ,
  103793. t.prototype.autoConfigure = function(e) {
  103794. if (!this.position.isConnected) {
  103795. var t = e.getInputBlockByPredicate((function(e) {
  103796. return e.isAttribute && "position" === e.name
  103797. }
  103798. ));
  103799. t || (t = new tf("position")).setAsAttribute(),
  103800. t.output.connectTo(this.position)
  103801. }
  103802. if (!this.normal.isConnected) {
  103803. var i = e.getInputBlockByPredicate((function(e) {
  103804. return e.isAttribute && "normal" === e.name
  103805. }
  103806. ));
  103807. i || (i = new tf("normal")).setAsAttribute("normal"),
  103808. i.output.connectTo(this.normal)
  103809. }
  103810. if (!this.tangent.isConnected) {
  103811. var n = e.getInputBlockByPredicate((function(e) {
  103812. return e.isAttribute && "tangent" === e.name
  103813. }
  103814. ));
  103815. n || (n = new tf("tangent")).setAsAttribute("tangent"),
  103816. n.output.connectTo(this.tangent)
  103817. }
  103818. if (!this.uv.isConnected) {
  103819. var r = e.getInputBlockByPredicate((function(e) {
  103820. return e.isAttribute && "uv" === e.name
  103821. }
  103822. ));
  103823. r || (r = new tf("uv")).setAsAttribute("uv"),
  103824. r.output.connectTo(this.uv)
  103825. }
  103826. }
  103827. ,
  103828. t.prototype.prepareDefines = function(e, t, i) {
  103829. if (e.morphTargetManager) {
  103830. var n = e.morphTargetManager;
  103831. (null == n ? void 0 : n.isUsingTextureForTargets) && n.numInfluencers !== i.NUM_MORPH_INFLUENCERS && i.markAsAttributesDirty()
  103832. }
  103833. i._areAttributesDirty && Mr.PrepareDefinesForMorphTargets(e, i)
  103834. }
  103835. ,
  103836. t.prototype.bind = function(e, t, i) {
  103837. i && i.morphTargetManager && i.morphTargetManager.numInfluencers > 0 && (Mr.BindMorphTargetParameters(i, e),
  103838. i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(e))
  103839. }
  103840. ,
  103841. t.prototype.replaceRepeatableContent = function(e, t, i, n) {
  103842. var r = this.position
  103843. , o = this.normal
  103844. , a = this.tangent
  103845. , s = this.uv
  103846. , l = this.positionOutput
  103847. , c = this.normalOutput
  103848. , u = this.tangentOutput
  103849. , h = this.uvOutput
  103850. , d = e
  103851. , p = n.NUM_MORPH_INFLUENCERS
  103852. , f = i.morphTargetManager
  103853. , _ = f && f.supportsNormals && n.NORMAL
  103854. , m = f && f.supportsTangents && n.TANGENT
  103855. , g = f && f.supportsUVs && n.UV1
  103856. , v = "";
  103857. (null == f ? void 0 : f.isUsingTextureForTargets) && p > 0 && (v += "float vertexID;\r\n");
  103858. for (var y = 0; y < p; y++)
  103859. v += "#ifdef MORPHTARGETS\r\n",
  103860. (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r\n",
  103861. v += "".concat(l.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
  103862. v += "vertexID += 1.0;\r\n") : v += "".concat(l.associatedVariableName, " += (position").concat(y, " - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
  103863. _ && (v += "#ifdef MORPHTARGETS_NORMAL\r\n",
  103864. (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(c.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
  103865. v += "vertexID += 1.0;\r\n") : v += "".concat(c.associatedVariableName, " += (normal").concat(y, " - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
  103866. v += "#endif\r\n"),
  103867. g && (v += "#ifdef MORPHTARGETS_UV\r\n",
  103868. (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(h.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID).xy - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
  103869. v += "vertexID += 1.0;\r\n") : v += "".concat(h.associatedVariableName, ".xy += (uv_").concat(y, " - ").concat(s.associatedVariableName, ".xy) * morphTargetInfluences[").concat(y, "];\r\n"),
  103870. v += "#endif\r\n"),
  103871. m && (v += "#ifdef MORPHTARGETS_TANGENT\r\n",
  103872. (null == f ? void 0 : f.isUsingTextureForTargets) ? v += "".concat(u.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(a.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n") : v += "".concat(u.associatedVariableName, ".xyz += (tangent").concat(y, " - ").concat(a.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(y, "];\r\n"),
  103873. v += "#endif\r\n"),
  103874. v += "#endif\r\n";
  103875. if (d.compilationString = d.compilationString.replace(this._repeatableContentAnchor, v),
  103876. p > 0)
  103877. for (y = 0; y < p; y++)
  103878. d.attributes.push(Bi.PositionKind + y),
  103879. _ && d.attributes.push(Bi.NormalKind + y),
  103880. m && d.attributes.push(Bi.TangentKind + y),
  103881. g && d.attributes.push(Bi.UVKind + "_" + y)
  103882. }
  103883. ,
  103884. t.prototype._buildBlock = function(t) {
  103885. e.prototype._buildBlock.call(this, t),
  103886. t.sharedData.blocksWithDefines.push(this),
  103887. t.sharedData.bindableBlocks.push(this),
  103888. t.sharedData.repeatableContentBlocks.push(this);
  103889. var i = this.position
  103890. , n = this.normal
  103891. , r = this.tangent
  103892. , o = this.uv
  103893. , a = this.positionOutput
  103894. , s = this.normalOutput
  103895. , l = this.tangentOutput
  103896. , c = this.uvOutput
  103897. , u = "//".concat(this.name);
  103898. return t.uniforms.push("morphTargetInfluences"),
  103899. t.uniforms.push("morphTargetTextureInfo"),
  103900. t.uniforms.push("morphTargetTextureIndices"),
  103901. t.samplers.push("morphTargets"),
  103902. t._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", u),
  103903. t._emitFunctionFromInclude("morphTargetsVertexDeclaration", u, {
  103904. repeatKey: "maxSimultaneousMorphTargets"
  103905. }),
  103906. t.compilationString += "".concat(this._declareOutput(a, t), " = ").concat(i.associatedVariableName, ";\r\n"),
  103907. t.compilationString += "#ifdef NORMAL\r\n",
  103908. t.compilationString += "".concat(this._declareOutput(s, t), " = ").concat(n.associatedVariableName, ";\r\n"),
  103909. t.compilationString += "#else\r\n",
  103910. t.compilationString += "".concat(this._declareOutput(s, t), " = vec3(0., 0., 0.);\r\n"),
  103911. t.compilationString += "#endif\r\n",
  103912. t.compilationString += "#ifdef TANGENT\r\n",
  103913. t.compilationString += "".concat(this._declareOutput(l, t), " = ").concat(r.associatedVariableName, ";\r\n"),
  103914. t.compilationString += "#else\r\n",
  103915. t.compilationString += "".concat(this._declareOutput(l, t), " = vec3(0., 0., 0.);\r\n"),
  103916. t.compilationString += "#endif\r\n",
  103917. t.compilationString += "#ifdef UV1\r\n",
  103918. t.compilationString += "".concat(this._declareOutput(c, t), " = ").concat(o.associatedVariableName, ";\r\n"),
  103919. t.compilationString += "#else\r\n",
  103920. t.compilationString += "".concat(this._declareOutput(c, t), " = vec2(0., 0.);\r\n"),
  103921. t.compilationString += "#endif\r\n",
  103922. this._repeatableContentAnchor = t._repeatableContentAnchor,
  103923. t.compilationString += this._repeatableContentAnchor,
  103924. this
  103925. }
  103926. ,
  103927. t
  103928. }(Wp);
  103929. y("BABYLON.MorphTargetsBlock", Am);
  103930. var xm = function(e) {
  103931. function t(t) {
  103932. var i = e.call(this, t, Dp.Vertex) || this;
  103933. return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
  103934. i.registerOutput("direction", Op.Vector3),
  103935. i.registerOutput("color", Op.Color3),
  103936. i.registerOutput("intensity", Op.Float),
  103937. i
  103938. }
  103939. return U(t, e),
  103940. t.prototype.getClassName = function() {
  103941. return "LightInformationBlock"
  103942. }
  103943. ,
  103944. Object.defineProperty(t.prototype, "worldPosition", {
  103945. get: function() {
  103946. return this._inputs[0]
  103947. },
  103948. enumerable: !1,
  103949. configurable: !0
  103950. }),
  103951. Object.defineProperty(t.prototype, "direction", {
  103952. get: function() {
  103953. return this._outputs[0]
  103954. },
  103955. enumerable: !1,
  103956. configurable: !0
  103957. }),
  103958. Object.defineProperty(t.prototype, "color", {
  103959. get: function() {
  103960. return this._outputs[1]
  103961. },
  103962. enumerable: !1,
  103963. configurable: !0
  103964. }),
  103965. Object.defineProperty(t.prototype, "intensity", {
  103966. get: function() {
  103967. return this._outputs[2]
  103968. },
  103969. enumerable: !1,
  103970. configurable: !0
  103971. }),
  103972. t.prototype.bind = function(e, t, i) {
  103973. if (i) {
  103974. this.light && this.light.isDisposed && (this.light = null);
  103975. var n = this.light
  103976. , r = t.getScene();
  103977. if (!n && r.lights.length && (n = this.light = r.lights[0],
  103978. this._forcePrepareDefines = !0),
  103979. !n || !n.isEnabled)
  103980. return e.setFloat3(this._lightDataUniformName, 0, 0, 0),
  103981. void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
  103982. n.transferToNodeMaterialEffect(e, this._lightDataUniformName),
  103983. e.setColor4(this._lightColorUniformName, n.diffuse, n.intensity)
  103984. }
  103985. }
  103986. ,
  103987. t.prototype.prepareDefines = function(e, t, i) {
  103988. if (i._areLightsDirty || this._forcePrepareDefines) {
  103989. this._forcePrepareDefines = !1;
  103990. var n = this.light;
  103991. i.setValue(this._lightTypeDefineName, !!(n && n instanceof __), !0)
  103992. }
  103993. }
  103994. ,
  103995. t.prototype._buildBlock = function(t) {
  103996. e.prototype._buildBlock.call(this, t),
  103997. t.sharedData.bindableBlocks.push(this),
  103998. t.sharedData.blocksWithDefines.push(this);
  103999. var i = this.direction
  104000. , n = this.color
  104001. , r = this.intensity;
  104002. return this._lightDataUniformName = t._getFreeVariableName("lightData"),
  104003. this._lightColorUniformName = t._getFreeVariableName("lightColor"),
  104004. this._lightTypeDefineName = t._getFreeDefineName("LIGHTPOINTTYPE"),
  104005. t._emitUniformFromString(this._lightDataUniformName, "vec3"),
  104006. t._emitUniformFromString(this._lightColorUniformName, "vec4"),
  104007. t.compilationString += "#ifdef ".concat(this._lightTypeDefineName, "\r\n"),
  104008. t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.worldPosition.associatedVariableName, ".xyz - ").concat(this._lightDataUniformName, ");\r\n"),
  104009. t.compilationString += "#else\r\n",
  104010. t.compilationString += this._declareOutput(i, t) + " = ".concat(this._lightDataUniformName, ";\r\n"),
  104011. t.compilationString += "#endif\r\n",
  104012. t.compilationString += this._declareOutput(n, t) + " = ".concat(this._lightColorUniformName, ".rgb;\r\n"),
  104013. t.compilationString += this._declareOutput(r, t) + " = ".concat(this._lightColorUniformName, ".a;\r\n"),
  104014. this
  104015. }
  104016. ,
  104017. t.prototype.serialize = function() {
  104018. var t = e.prototype.serialize.call(this);
  104019. return this.light && (t.lightId = this.light.id),
  104020. t
  104021. }
  104022. ,
  104023. t.prototype._deserialize = function(t, i, n) {
  104024. e.prototype._deserialize.call(this, t, i, n),
  104025. t.lightId && (this.light = i.getLightById(t.lightId))
  104026. }
  104027. ,
  104028. t
  104029. }(Wp);
  104030. y("BABYLON.LightInformationBlock", xm);
  104031. var Rm = function(e) {
  104032. function t(t) {
  104033. var i = e.call(this, t, Dp.Fragment) || this;
  104034. return i.convertInputToLinearSpace = !0,
  104035. i.registerInput("color", Op.Color4),
  104036. i.registerOutput("output", Op.Color4),
  104037. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  104038. i
  104039. }
  104040. return U(t, e),
  104041. t.prototype.getClassName = function() {
  104042. return "ImageProcessingBlock"
  104043. }
  104044. ,
  104045. Object.defineProperty(t.prototype, "color", {
  104046. get: function() {
  104047. return this._inputs[0]
  104048. },
  104049. enumerable: !1,
  104050. configurable: !0
  104051. }),
  104052. Object.defineProperty(t.prototype, "output", {
  104053. get: function() {
  104054. return this._outputs[0]
  104055. },
  104056. enumerable: !1,
  104057. configurable: !0
  104058. }),
  104059. t.prototype.initialize = function(e) {
  104060. e._excludeVariableName("exposureLinear"),
  104061. e._excludeVariableName("contrast"),
  104062. e._excludeVariableName("vInverseScreenSize"),
  104063. e._excludeVariableName("vignetteSettings1"),
  104064. e._excludeVariableName("vignetteSettings2"),
  104065. e._excludeVariableName("vCameraColorCurveNegative"),
  104066. e._excludeVariableName("vCameraColorCurveNeutral"),
  104067. e._excludeVariableName("vCameraColorCurvePositive"),
  104068. e._excludeVariableName("txColorTransform"),
  104069. e._excludeVariableName("colorTransformSettings")
  104070. }
  104071. ,
  104072. t.prototype.isReady = function(e, t, i) {
  104073. return !(i._areImageProcessingDirty && t.imageProcessingConfiguration && !t.imageProcessingConfiguration.isReady())
  104074. }
  104075. ,
  104076. t.prototype.prepareDefines = function(e, t, i) {
  104077. i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i)
  104078. }
  104079. ,
  104080. t.prototype.bind = function(e, t, i) {
  104081. i && t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e)
  104082. }
  104083. ,
  104084. t.prototype._buildBlock = function(t) {
  104085. e.prototype._buildBlock.call(this, t),
  104086. t.sharedData.blocksWithDefines.push(this),
  104087. t.sharedData.blockingBlocks.push(this),
  104088. t.sharedData.bindableBlocks.push(this),
  104089. t.uniforms.push("exposureLinear"),
  104090. t.uniforms.push("contrast"),
  104091. t.uniforms.push("vInverseScreenSize"),
  104092. t.uniforms.push("vignetteSettings1"),
  104093. t.uniforms.push("vignetteSettings2"),
  104094. t.uniforms.push("vCameraColorCurveNegative"),
  104095. t.uniforms.push("vCameraColorCurveNeutral"),
  104096. t.uniforms.push("vCameraColorCurvePositive"),
  104097. t.uniforms.push("txColorTransform"),
  104098. t.uniforms.push("colorTransformSettings");
  104099. var i = this.color
  104100. , n = this._outputs[0]
  104101. , r = "//".concat(this.name);
  104102. return t._emitFunctionFromInclude("helperFunctions", r),
  104103. t._emitFunctionFromInclude("imageProcessingDeclaration", r),
  104104. t._emitFunctionFromInclude("imageProcessingFunctions", r),
  104105. i.connectedPoint.type === Op.Color4 || i.connectedPoint.type === Op.Vector4 ? t.compilationString += "".concat(this._declareOutput(n, t), " = ").concat(i.associatedVariableName, ";\r\n") : t.compilationString += "".concat(this._declareOutput(n, t), " = vec4(").concat(i.associatedVariableName, ", 1.0);\r\n"),
  104106. t.compilationString += "#ifdef IMAGEPROCESSINGPOSTPROCESS\r\n",
  104107. this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
  104108. t.compilationString += "#else\r\n",
  104109. t.compilationString += "#ifdef IMAGEPROCESSING\r\n",
  104110. this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
  104111. t.compilationString += "".concat(n.associatedVariableName, " = applyImageProcessing(").concat(n.associatedVariableName, ");\r\n"),
  104112. t.compilationString += "#endif\r\n",
  104113. t.compilationString += "#endif\r\n",
  104114. this
  104115. }
  104116. ,
  104117. t.prototype._dumpPropertiesCode = function() {
  104118. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace, ";\r\n")
  104119. }
  104120. ,
  104121. t.prototype.serialize = function() {
  104122. var t = e.prototype.serialize.call(this);
  104123. return t.convertInputToLinearSpace = this.convertInputToLinearSpace,
  104124. t
  104125. }
  104126. ,
  104127. t.prototype._deserialize = function(t, i, n) {
  104128. var r;
  104129. e.prototype._deserialize.call(this, t, i, n),
  104130. this.convertInputToLinearSpace = null === (r = t.convertInputToLinearSpace) || void 0 === r || r
  104131. }
  104132. ,
  104133. k([Yp("Convert input to linear space", Xp.Boolean, "ADVANCED")], t.prototype, "convertInputToLinearSpace", void 0),
  104134. t
  104135. }(Wp);
  104136. y("BABYLON.ImageProcessingBlock", Rm);
  104137. var Cm = function(e) {
  104138. function t(t) {
  104139. var i = e.call(this, t, Dp.Fragment) || this;
  104140. return i._tangentSpaceParameterName = "",
  104141. i.invertX = !1,
  104142. i.invertY = !1,
  104143. i.useParallaxOcclusion = !1,
  104144. i._isUnique = !0,
  104145. i.registerInput("worldPosition", Op.Vector4, !1),
  104146. i.registerInput("worldNormal", Op.Vector4, !1),
  104147. i.registerInput("worldTangent", Op.Vector4, !0),
  104148. i.registerInput("uv", Op.Vector2, !1),
  104149. i.registerInput("normalMapColor", Op.Color3, !1),
  104150. i.registerInput("strength", Op.Float, !1),
  104151. i.registerInput("viewDirection", Op.Vector3, !0),
  104152. i.registerInput("parallaxScale", Op.Float, !0),
  104153. i.registerInput("parallaxHeight", Op.Float, !0),
  104154. i.registerOutput("output", Op.Vector4),
  104155. i.registerOutput("uvOffset", Op.Vector2),
  104156. i
  104157. }
  104158. return U(t, e),
  104159. t.prototype.getClassName = function() {
  104160. return "PerturbNormalBlock"
  104161. }
  104162. ,
  104163. Object.defineProperty(t.prototype, "worldPosition", {
  104164. get: function() {
  104165. return this._inputs[0]
  104166. },
  104167. enumerable: !1,
  104168. configurable: !0
  104169. }),
  104170. Object.defineProperty(t.prototype, "worldNormal", {
  104171. get: function() {
  104172. return this._inputs[1]
  104173. },
  104174. enumerable: !1,
  104175. configurable: !0
  104176. }),
  104177. Object.defineProperty(t.prototype, "worldTangent", {
  104178. get: function() {
  104179. return this._inputs[2]
  104180. },
  104181. enumerable: !1,
  104182. configurable: !0
  104183. }),
  104184. Object.defineProperty(t.prototype, "uv", {
  104185. get: function() {
  104186. return this._inputs[3]
  104187. },
  104188. enumerable: !1,
  104189. configurable: !0
  104190. }),
  104191. Object.defineProperty(t.prototype, "normalMapColor", {
  104192. get: function() {
  104193. return this._inputs[4]
  104194. },
  104195. enumerable: !1,
  104196. configurable: !0
  104197. }),
  104198. Object.defineProperty(t.prototype, "strength", {
  104199. get: function() {
  104200. return this._inputs[5]
  104201. },
  104202. enumerable: !1,
  104203. configurable: !0
  104204. }),
  104205. Object.defineProperty(t.prototype, "viewDirection", {
  104206. get: function() {
  104207. return this._inputs[6]
  104208. },
  104209. enumerable: !1,
  104210. configurable: !0
  104211. }),
  104212. Object.defineProperty(t.prototype, "parallaxScale", {
  104213. get: function() {
  104214. return this._inputs[7]
  104215. },
  104216. enumerable: !1,
  104217. configurable: !0
  104218. }),
  104219. Object.defineProperty(t.prototype, "parallaxHeight", {
  104220. get: function() {
  104221. return this._inputs[8]
  104222. },
  104223. enumerable: !1,
  104224. configurable: !0
  104225. }),
  104226. Object.defineProperty(t.prototype, "output", {
  104227. get: function() {
  104228. return this._outputs[0]
  104229. },
  104230. enumerable: !1,
  104231. configurable: !0
  104232. }),
  104233. Object.defineProperty(t.prototype, "uvOffset", {
  104234. get: function() {
  104235. return this._outputs[1]
  104236. },
  104237. enumerable: !1,
  104238. configurable: !0
  104239. }),
  104240. t.prototype.prepareDefines = function(e, t, i) {
  104241. var n = this.normalMapColor.connectedPoint._ownerBlock.samplerName
  104242. , r = this.viewDirection.isConnected && (this.useParallaxOcclusion && n || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
  104243. i.setValue("BUMP", !0),
  104244. i.setValue("PARALLAX", r, !0),
  104245. i.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
  104246. }
  104247. ,
  104248. t.prototype.bind = function(e, t) {
  104249. t.getScene()._mirroredCameraPosition ? e.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : e.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1)
  104250. }
  104251. ,
  104252. t.prototype.autoConfigure = function(e) {
  104253. if (!this.uv.isConnected) {
  104254. var t = e.getInputBlockByPredicate((function(e) {
  104255. return e.isAttribute && "uv" === e.name
  104256. }
  104257. ));
  104258. t || (t = new tf("uv")).setAsAttribute(),
  104259. t.output.connectTo(this.uv)
  104260. }
  104261. if (!this.strength.isConnected) {
  104262. var i = new tf("strength");
  104263. i.value = 1,
  104264. i.output.connectTo(this.strength)
  104265. }
  104266. }
  104267. ,
  104268. t.prototype._buildBlock = function(t) {
  104269. e.prototype._buildBlock.call(this, t);
  104270. var i = "//".concat(this.name)
  104271. , n = this.uv
  104272. , r = this.worldPosition
  104273. , o = this.worldNormal
  104274. , a = this.worldTangent;
  104275. t.sharedData.blocksWithDefines.push(this),
  104276. t.sharedData.bindableBlocks.push(this),
  104277. this._tangentSpaceParameterName = t._getFreeDefineName("tangentSpaceParameter"),
  104278. t._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
  104279. var s = this.normalMapColor.connectedPoint._ownerBlock.samplerName
  104280. , l = this.viewDirection.isConnected && (this.useParallaxOcclusion && s || !this.useParallaxOcclusion && this.parallaxHeight.isConnected)
  104281. , c = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? t._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05"
  104282. , u = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\n".concat(t._emitFloat(this.strength.connectInputBlock.value)) : "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\n".concat(this.strength.associatedVariableName);
  104283. t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  104284. var h = {
  104285. search: /defined\(TANGENT\)/g,
  104286. replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  104287. };
  104288. a.isConnected && (t.compilationString += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
  104289. t.compilationString += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
  104290. t.compilationString += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
  104291. t.compilationString += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
  104292. t._emitFunctionFromInclude("bumpFragmentMainFunctions", i, {
  104293. replaceStrings: [h, {
  104294. search: /varying mat3 vTBN/g,
  104295. replace: ""
  104296. }]
  104297. }),
  104298. t._emitFunctionFromInclude("bumpFragmentFunctions", i, {
  104299. replaceStrings: [{
  104300. search: /#include<samplerFragmentDeclaration>\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,
  104301. replace: ""
  104302. }, {
  104303. search: /uniform sampler2D bumpSampler;/g,
  104304. replace: ""
  104305. }, {
  104306. search: /vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,
  104307. replace: "#define inline\r\nvec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)"
  104308. }, {
  104309. search: /vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,
  104310. replace: "vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"
  104311. }, {
  104312. search: /texture2D\(bumpSampler,vBumpUV\)\.w/g,
  104313. replace: "height_"
  104314. }]
  104315. });
  104316. var d = l && s ? "texture2D(".concat(s, ", ").concat(n.associatedVariableName, " + uvOffset).xyz") : this.normalMapColor.associatedVariableName;
  104317. return t.compilationString += this._declareOutput(this.output, t) + " = vec4(0.);\r\n",
  104318. t.compilationString += t._emitCodeFromInclude("bumpFragment", i, {
  104319. replaceStrings: [{
  104320. search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
  104321. replace: "perturbNormal(TBN, ".concat(d, ", vBumpInfos.y)")
  104322. }, {
  104323. search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,
  104324. replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(l && this.useParallaxOcclusion ? s : "bumpSampler", ")")
  104325. }, {
  104326. search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,
  104327. replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(l ? this.parallaxHeight.associatedVariableName : "0.", ")")
  104328. }, {
  104329. search: /vTangentSpaceParams/g,
  104330. replace: this._tangentSpaceParameterName
  104331. }, {
  104332. search: /vBumpInfos.y/g,
  104333. replace: u
  104334. }, {
  104335. search: /vBumpInfos.z/g,
  104336. replace: c
  104337. }, {
  104338. search: /vBumpUV/g,
  104339. replace: n.associatedVariableName
  104340. }, {
  104341. search: /vPositionW/g,
  104342. replace: r.associatedVariableName + ".xyz"
  104343. }, {
  104344. search: /normalW=/g,
  104345. replace: this.output.associatedVariableName + ".xyz = "
  104346. }, {
  104347. search: /mat3\(normalMatrix\)\*normalW/g,
  104348. replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz"
  104349. }, {
  104350. search: /normalW/g,
  104351. replace: o.associatedVariableName + ".xyz"
  104352. }, {
  104353. search: /viewDirectionW/g,
  104354. replace: l ? this.viewDirection.associatedVariableName : "vec3(0.)"
  104355. }, h]
  104356. }),
  104357. this
  104358. }
  104359. ,
  104360. t.prototype._dumpPropertiesCode = function() {
  104361. var t = e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".invertX = ").concat(this.invertX, ";\r\n");
  104362. return (t += "".concat(this._codeVariableName, ".invertY = ").concat(this.invertY, ";\r\n")) + "".concat(this._codeVariableName, ".useParallaxOcclusion = ").concat(this.useParallaxOcclusion, ";\r\n")
  104363. }
  104364. ,
  104365. t.prototype.serialize = function() {
  104366. var t = e.prototype.serialize.call(this);
  104367. return t.invertX = this.invertX,
  104368. t.invertY = this.invertY,
  104369. t.useParallaxOcclusion = this.useParallaxOcclusion,
  104370. t
  104371. }
  104372. ,
  104373. t.prototype._deserialize = function(t, i, n) {
  104374. e.prototype._deserialize.call(this, t, i, n),
  104375. this.invertX = t.invertX,
  104376. this.invertY = t.invertY,
  104377. this.useParallaxOcclusion = !!t.useParallaxOcclusion
  104378. }
  104379. ,
  104380. k([Yp("Invert X axis", Xp.Boolean, "PROPERTIES", {
  104381. notifiers: {
  104382. update: !1
  104383. }
  104384. })], t.prototype, "invertX", void 0),
  104385. k([Yp("Invert Y axis", Xp.Boolean, "PROPERTIES", {
  104386. notifiers: {
  104387. update: !1
  104388. }
  104389. })], t.prototype, "invertY", void 0),
  104390. k([Yp("Use parallax occlusion", Xp.Boolean)], t.prototype, "useParallaxOcclusion", void 0),
  104391. t
  104392. }(Wp);
  104393. y("BABYLON.PerturbNormalBlock", Cm);
  104394. var Pm = function(e) {
  104395. function t(t) {
  104396. var i = e.call(this, t, Dp.Fragment, !0) || this;
  104397. return i.registerInput("value", Op.Float, !0),
  104398. i.registerInput("cutoff", Op.Float, !0),
  104399. i
  104400. }
  104401. return U(t, e),
  104402. t.prototype.getClassName = function() {
  104403. return "DiscardBlock"
  104404. }
  104405. ,
  104406. Object.defineProperty(t.prototype, "value", {
  104407. get: function() {
  104408. return this._inputs[0]
  104409. },
  104410. enumerable: !1,
  104411. configurable: !0
  104412. }),
  104413. Object.defineProperty(t.prototype, "cutoff", {
  104414. get: function() {
  104415. return this._inputs[1]
  104416. },
  104417. enumerable: !1,
  104418. configurable: !0
  104419. }),
  104420. t.prototype._buildBlock = function(t) {
  104421. if (e.prototype._buildBlock.call(this, t),
  104422. t.sharedData.hints.needAlphaTesting = !0,
  104423. this.cutoff.isConnected && this.value.isConnected)
  104424. return t.compilationString += "if (".concat(this.value.associatedVariableName, " < ").concat(this.cutoff.associatedVariableName, ") discard;\r\n"),
  104425. this
  104426. }
  104427. ,
  104428. t
  104429. }(Wp);
  104430. y("BABYLON.DiscardBlock", Pm);
  104431. var Mm = function(e) {
  104432. function t(t) {
  104433. var i = e.call(this, t, Dp.Fragment) || this;
  104434. return i.registerOutput("output", Op.Float, Dp.Fragment),
  104435. i
  104436. }
  104437. return U(t, e),
  104438. t.prototype.getClassName = function() {
  104439. return "FrontFacingBlock"
  104440. }
  104441. ,
  104442. Object.defineProperty(t.prototype, "output", {
  104443. get: function() {
  104444. return this._outputs[0]
  104445. },
  104446. enumerable: !1,
  104447. configurable: !0
  104448. }),
  104449. t.prototype._buildBlock = function(t) {
  104450. if (e.prototype._buildBlock.call(this, t),
  104451. t.target === Dp.Vertex)
  104452. throw "FrontFacingBlock must only be used in a fragment shader";
  104453. var i = this._outputs[0];
  104454. return t.compilationString += this._declareOutput(i, t) + " = gl_FrontFacing ? 1.0 : 0.0;\r\n",
  104455. this
  104456. }
  104457. ,
  104458. t
  104459. }(Wp);
  104460. y("BABYLON.FrontFacingBlock", Mm);
  104461. var Im = function(e) {
  104462. function t(t) {
  104463. var i = e.call(this, t, Dp.Fragment) || this;
  104464. return i.registerInput("input", Op.AutoDetect, !1),
  104465. i.registerOutput("dx", Op.BasedOnInput),
  104466. i.registerOutput("dy", Op.BasedOnInput),
  104467. i._outputs[0]._typeConnectionSource = i._inputs[0],
  104468. i._outputs[1]._typeConnectionSource = i._inputs[0],
  104469. i
  104470. }
  104471. return U(t, e),
  104472. t.prototype.getClassName = function() {
  104473. return "DerivativeBlock"
  104474. }
  104475. ,
  104476. Object.defineProperty(t.prototype, "input", {
  104477. get: function() {
  104478. return this._inputs[0]
  104479. },
  104480. enumerable: !1,
  104481. configurable: !0
  104482. }),
  104483. Object.defineProperty(t.prototype, "dx", {
  104484. get: function() {
  104485. return this._outputs[0]
  104486. },
  104487. enumerable: !1,
  104488. configurable: !0
  104489. }),
  104490. Object.defineProperty(t.prototype, "dy", {
  104491. get: function() {
  104492. return this._outputs[1]
  104493. },
  104494. enumerable: !1,
  104495. configurable: !0
  104496. }),
  104497. t.prototype._buildBlock = function(t) {
  104498. e.prototype._buildBlock.call(this, t);
  104499. var i = this._outputs[0]
  104500. , n = this._outputs[1];
  104501. return t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
  104502. i.hasEndpoints && (t.compilationString += this._declareOutput(i, t) + " = dFdx(".concat(this.input.associatedVariableName, ");\r\n")),
  104503. n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = dFdy(".concat(this.input.associatedVariableName, ");\r\n")),
  104504. this
  104505. }
  104506. ,
  104507. t
  104508. }(Wp);
  104509. y("BABYLON.DerivativeBlock", Im);
  104510. var Om = function(e) {
  104511. function t(t) {
  104512. var i = e.call(this, t, Dp.Fragment) || this;
  104513. return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
  104514. i.registerOutput("xyz", Op.Vector3, Dp.Fragment),
  104515. i.registerOutput("xyzw", Op.Vector4, Dp.Fragment),
  104516. i.registerOutput("x", Op.Float, Dp.Fragment),
  104517. i.registerOutput("y", Op.Float, Dp.Fragment),
  104518. i.registerOutput("z", Op.Float, Dp.Fragment),
  104519. i.registerOutput("w", Op.Float, Dp.Fragment),
  104520. i
  104521. }
  104522. return U(t, e),
  104523. t.prototype.getClassName = function() {
  104524. return "FragCoordBlock"
  104525. }
  104526. ,
  104527. Object.defineProperty(t.prototype, "xy", {
  104528. get: function() {
  104529. return this._outputs[0]
  104530. },
  104531. enumerable: !1,
  104532. configurable: !0
  104533. }),
  104534. Object.defineProperty(t.prototype, "xyz", {
  104535. get: function() {
  104536. return this._outputs[1]
  104537. },
  104538. enumerable: !1,
  104539. configurable: !0
  104540. }),
  104541. Object.defineProperty(t.prototype, "xyzw", {
  104542. get: function() {
  104543. return this._outputs[2]
  104544. },
  104545. enumerable: !1,
  104546. configurable: !0
  104547. }),
  104548. Object.defineProperty(t.prototype, "x", {
  104549. get: function() {
  104550. return this._outputs[3]
  104551. },
  104552. enumerable: !1,
  104553. configurable: !0
  104554. }),
  104555. Object.defineProperty(t.prototype, "y", {
  104556. get: function() {
  104557. return this._outputs[4]
  104558. },
  104559. enumerable: !1,
  104560. configurable: !0
  104561. }),
  104562. Object.defineProperty(t.prototype, "z", {
  104563. get: function() {
  104564. return this._outputs[5]
  104565. },
  104566. enumerable: !1,
  104567. configurable: !0
  104568. }),
  104569. Object.defineProperty(t.prototype, "output", {
  104570. get: function() {
  104571. return this._outputs[6]
  104572. },
  104573. enumerable: !1,
  104574. configurable: !0
  104575. }),
  104576. t.prototype.writeOutputs = function(e) {
  104577. for (var t = "", i = 0, n = this._outputs; i < n.length; i++) {
  104578. var r = n[i];
  104579. r.hasEndpoints && (t += "".concat(this._declareOutput(r, e), " = gl_FragCoord.").concat(r.name, ";\r\n"))
  104580. }
  104581. return t
  104582. }
  104583. ,
  104584. t.prototype._buildBlock = function(t) {
  104585. if (e.prototype._buildBlock.call(this, t),
  104586. t.target === Dp.Vertex)
  104587. throw "FragCoordBlock must only be used in a fragment shader";
  104588. return t.compilationString += this.writeOutputs(t),
  104589. this
  104590. }
  104591. ,
  104592. t
  104593. }(Wp);
  104594. y("BABYLON.FragCoordBlock", Om);
  104595. var Dm = function(e) {
  104596. function t(t) {
  104597. var i = e.call(this, t, Dp.Fragment) || this;
  104598. return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
  104599. i.registerOutput("x", Op.Float, Dp.Fragment),
  104600. i.registerOutput("y", Op.Float, Dp.Fragment),
  104601. i
  104602. }
  104603. return U(t, e),
  104604. t.prototype.getClassName = function() {
  104605. return "ScreenSizeBlock"
  104606. }
  104607. ,
  104608. Object.defineProperty(t.prototype, "xy", {
  104609. get: function() {
  104610. return this._outputs[0]
  104611. },
  104612. enumerable: !1,
  104613. configurable: !0
  104614. }),
  104615. Object.defineProperty(t.prototype, "x", {
  104616. get: function() {
  104617. return this._outputs[1]
  104618. },
  104619. enumerable: !1,
  104620. configurable: !0
  104621. }),
  104622. Object.defineProperty(t.prototype, "y", {
  104623. get: function() {
  104624. return this._outputs[2]
  104625. },
  104626. enumerable: !1,
  104627. configurable: !0
  104628. }),
  104629. t.prototype.bind = function(e) {
  104630. var t = this._scene.getEngine();
  104631. e.setFloat2(this._varName, t.getRenderWidth(), t.getRenderHeight())
  104632. }
  104633. ,
  104634. t.prototype.writeOutputs = function(e, t) {
  104635. for (var i = "", n = 0, r = this._outputs; n < r.length; n++) {
  104636. var o = r[n];
  104637. o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\n"))
  104638. }
  104639. return i
  104640. }
  104641. ,
  104642. t.prototype._buildBlock = function(t) {
  104643. if (e.prototype._buildBlock.call(this, t),
  104644. this._scene = t.sharedData.scene,
  104645. t.target === Dp.Vertex)
  104646. throw "ScreenSizeBlock must only be used in a fragment shader";
  104647. return t.sharedData.bindableBlocks.push(this),
  104648. this._varName = t._getFreeVariableName("screenSize"),
  104649. t._emitUniformFromString(this._varName, "vec2"),
  104650. t.compilationString += this.writeOutputs(t, this._varName),
  104651. this
  104652. }
  104653. ,
  104654. t
  104655. }(Wp);
  104656. y("BABYLON.ScreenSizeBlock", Dm);
  104657. var Nm = function(e) {
  104658. function t(t) {
  104659. var i = e.call(this, t, Dp.Fragment) || this;
  104660. return i.registerInput("vector", Op.Vector3),
  104661. i.registerInput("worldViewProjection", Op.Matrix),
  104662. i.registerOutput("output", Op.Vector2),
  104663. i.registerOutput("x", Op.Float),
  104664. i.registerOutput("y", Op.Float),
  104665. i.inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  104666. i
  104667. }
  104668. return U(t, e),
  104669. t.prototype.getClassName = function() {
  104670. return "ScreenSpaceBlock"
  104671. }
  104672. ,
  104673. Object.defineProperty(t.prototype, "vector", {
  104674. get: function() {
  104675. return this._inputs[0]
  104676. },
  104677. enumerable: !1,
  104678. configurable: !0
  104679. }),
  104680. Object.defineProperty(t.prototype, "worldViewProjection", {
  104681. get: function() {
  104682. return this._inputs[1]
  104683. },
  104684. enumerable: !1,
  104685. configurable: !0
  104686. }),
  104687. Object.defineProperty(t.prototype, "output", {
  104688. get: function() {
  104689. return this._outputs[0]
  104690. },
  104691. enumerable: !1,
  104692. configurable: !0
  104693. }),
  104694. Object.defineProperty(t.prototype, "x", {
  104695. get: function() {
  104696. return this._outputs[1]
  104697. },
  104698. enumerable: !1,
  104699. configurable: !0
  104700. }),
  104701. Object.defineProperty(t.prototype, "y", {
  104702. get: function() {
  104703. return this._outputs[2]
  104704. },
  104705. enumerable: !1,
  104706. configurable: !0
  104707. }),
  104708. t.prototype.autoConfigure = function(e) {
  104709. if (!this.worldViewProjection.isConnected) {
  104710. var t = e.getInputBlockByPredicate((function(e) {
  104711. return e.systemValue === Qp.WorldViewProjection
  104712. }
  104713. ));
  104714. t || (t = new tf("worldViewProjection")).setAsSystemValue(Qp.WorldViewProjection),
  104715. t.output.connectTo(this.worldViewProjection)
  104716. }
  104717. }
  104718. ,
  104719. t.prototype._buildBlock = function(t) {
  104720. e.prototype._buildBlock.call(this, t);
  104721. var i = this.vector
  104722. , n = this.worldViewProjection;
  104723. if (i.connectedPoint) {
  104724. var r = n.associatedVariableName
  104725. , o = t._getFreeVariableName("screenSpaceTemp");
  104726. switch (i.connectedPoint.type) {
  104727. case Op.Vector3:
  104728. t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * vec4(").concat(i.associatedVariableName, ", 1.0);\r\n");
  104729. break;
  104730. case Op.Vector4:
  104731. t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * ").concat(i.associatedVariableName, ";\r\n")
  104732. }
  104733. return t.compilationString += "".concat(o, ".xy /= ").concat(o, ".w;"),
  104734. t.compilationString += "".concat(o, ".xy = ").concat(o, ".xy * 0.5 + vec2(0.5, 0.5);"),
  104735. this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, ".xy;\r\n")),
  104736. this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(o, ".x;\r\n")),
  104737. this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(o, ".y;\r\n")),
  104738. this
  104739. }
  104740. }
  104741. ,
  104742. t
  104743. }(Wp);
  104744. y("BABYLON.ScreenSpaceBlock", Nm);
  104745. var Lm = function(e) {
  104746. function t(t) {
  104747. var i = e.call(this, t, Dp.Fragment) || this;
  104748. return i.registerInput("input", Op.Vector2),
  104749. i.registerInput("strength", Op.Float),
  104750. i.registerInput("center", Op.Vector2),
  104751. i.registerInput("offset", Op.Vector2),
  104752. i.registerOutput("output", Op.Vector2),
  104753. i.registerOutput("x", Op.Float),
  104754. i.registerOutput("y", Op.Float),
  104755. i
  104756. }
  104757. return U(t, e),
  104758. t.prototype.getClassName = function() {
  104759. return "TwirlBlock"
  104760. }
  104761. ,
  104762. Object.defineProperty(t.prototype, "input", {
  104763. get: function() {
  104764. return this._inputs[0]
  104765. },
  104766. enumerable: !1,
  104767. configurable: !0
  104768. }),
  104769. Object.defineProperty(t.prototype, "strength", {
  104770. get: function() {
  104771. return this._inputs[1]
  104772. },
  104773. enumerable: !1,
  104774. configurable: !0
  104775. }),
  104776. Object.defineProperty(t.prototype, "center", {
  104777. get: function() {
  104778. return this._inputs[2]
  104779. },
  104780. enumerable: !1,
  104781. configurable: !0
  104782. }),
  104783. Object.defineProperty(t.prototype, "offset", {
  104784. get: function() {
  104785. return this._inputs[3]
  104786. },
  104787. enumerable: !1,
  104788. configurable: !0
  104789. }),
  104790. Object.defineProperty(t.prototype, "output", {
  104791. get: function() {
  104792. return this._outputs[0]
  104793. },
  104794. enumerable: !1,
  104795. configurable: !0
  104796. }),
  104797. Object.defineProperty(t.prototype, "x", {
  104798. get: function() {
  104799. return this._outputs[1]
  104800. },
  104801. enumerable: !1,
  104802. configurable: !0
  104803. }),
  104804. Object.defineProperty(t.prototype, "y", {
  104805. get: function() {
  104806. return this._outputs[2]
  104807. },
  104808. enumerable: !1,
  104809. configurable: !0
  104810. }),
  104811. t.prototype.autoConfigure = function() {
  104812. if (!this.center.isConnected) {
  104813. var e = new tf("center");
  104814. e.value = new A(.5,.5),
  104815. e.output.connectTo(this.center)
  104816. }
  104817. if (!this.strength.isConnected) {
  104818. var t = new tf("strength");
  104819. t.value = 1,
  104820. t.output.connectTo(this.strength)
  104821. }
  104822. if (!this.offset.isConnected) {
  104823. var i = new tf("offset");
  104824. i.value = new A(0,0),
  104825. i.output.connectTo(this.offset)
  104826. }
  104827. }
  104828. ,
  104829. t.prototype._buildBlock = function(t) {
  104830. e.prototype._buildBlock.call(this, t);
  104831. var i = t._getFreeVariableName("delta")
  104832. , n = t._getFreeVariableName("angle")
  104833. , r = t._getFreeVariableName("x")
  104834. , o = t._getFreeVariableName("y")
  104835. , a = t._getFreeVariableName("result");
  104836. return t.compilationString += "\n vec2 ".concat(i, " = ").concat(this.input.associatedVariableName, " - ").concat(this.center.associatedVariableName, ";\n float ").concat(n, " = ").concat(this.strength.associatedVariableName, " * length(").concat(i, ");\n float ").concat(r, " = cos(").concat(n, ") * ").concat(i, ".x - sin(").concat(n, ") * ").concat(i, ".y;\n float ").concat(o, " = sin(").concat(n, ") * ").concat(i, ".x + cos(").concat(n, ") * ").concat(i, ".y;\n vec2 ").concat(a, " = vec2(").concat(r, " + ").concat(this.center.associatedVariableName, ".x + ").concat(this.offset.associatedVariableName, ".x, ").concat(o, " + ").concat(this.center.associatedVariableName, ".y + ").concat(this.offset.associatedVariableName, ".y);\n "),
  104837. this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(a, ";\r\n")),
  104838. this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(a, ".x;\r\n")),
  104839. this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(a, ".y;\r\n")),
  104840. this
  104841. }
  104842. ,
  104843. t
  104844. }(Wp);
  104845. y("BABYLON.TwirlBlock", Lm);
  104846. var Fm = function(e) {
  104847. function t(t) {
  104848. var i = e.call(this, t, Dp.VertexAndFragment, !1) || this;
  104849. return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
  104850. i.registerInput("view", Op.Matrix, !1, Dp.Vertex),
  104851. i.registerInput("input", Op.Color3, !1, Dp.Fragment),
  104852. i.registerInput("fogColor", Op.Color3, !1, Dp.Fragment),
  104853. i.registerOutput("output", Op.Color3, Dp.Fragment),
  104854. i.input.acceptedConnectionPointTypes.push(Op.Color4),
  104855. i.fogColor.acceptedConnectionPointTypes.push(Op.Color4),
  104856. i
  104857. }
  104858. return U(t, e),
  104859. t.prototype.getClassName = function() {
  104860. return "FogBlock"
  104861. }
  104862. ,
  104863. Object.defineProperty(t.prototype, "worldPosition", {
  104864. get: function() {
  104865. return this._inputs[0]
  104866. },
  104867. enumerable: !1,
  104868. configurable: !0
  104869. }),
  104870. Object.defineProperty(t.prototype, "view", {
  104871. get: function() {
  104872. return this._inputs[1]
  104873. },
  104874. enumerable: !1,
  104875. configurable: !0
  104876. }),
  104877. Object.defineProperty(t.prototype, "input", {
  104878. get: function() {
  104879. return this._inputs[2]
  104880. },
  104881. enumerable: !1,
  104882. configurable: !0
  104883. }),
  104884. Object.defineProperty(t.prototype, "fogColor", {
  104885. get: function() {
  104886. return this._inputs[3]
  104887. },
  104888. enumerable: !1,
  104889. configurable: !0
  104890. }),
  104891. Object.defineProperty(t.prototype, "output", {
  104892. get: function() {
  104893. return this._outputs[0]
  104894. },
  104895. enumerable: !1,
  104896. configurable: !0
  104897. }),
  104898. t.prototype.autoConfigure = function(e) {
  104899. if (!this.view.isConnected) {
  104900. var t = e.getInputBlockByPredicate((function(e) {
  104901. return e.systemValue === Qp.View
  104902. }
  104903. ));
  104904. t || (t = new tf("view")).setAsSystemValue(Qp.View),
  104905. t.output.connectTo(this.view)
  104906. }
  104907. if (!this.fogColor.isConnected) {
  104908. var i = e.getInputBlockByPredicate((function(e) {
  104909. return e.systemValue === Qp.FogColor
  104910. }
  104911. ));
  104912. i || (i = new tf("fogColor",void 0,Op.Color3)).setAsSystemValue(Qp.FogColor),
  104913. i.output.connectTo(this.fogColor)
  104914. }
  104915. }
  104916. ,
  104917. t.prototype.prepareDefines = function(e, t, i) {
  104918. var n = e.getScene();
  104919. i.setValue("FOG", t.fogEnabled && Mr.GetFogState(e, n))
  104920. }
  104921. ,
  104922. t.prototype.bind = function(e, t, i) {
  104923. if (i) {
  104924. var n = i.getScene();
  104925. e.setFloat4(this._fogParameters, n.fogMode, n.fogStart, n.fogEnd, n.fogDensity)
  104926. }
  104927. }
  104928. ,
  104929. t.prototype._buildBlock = function(t) {
  104930. if (e.prototype._buildBlock.call(this, t),
  104931. t.target === Dp.Fragment) {
  104932. t.sharedData.blocksWithDefines.push(this),
  104933. t.sharedData.bindableBlocks.push(this),
  104934. t._emitFunctionFromInclude("fogFragmentDeclaration", "//".concat(this.name), {
  104935. removeUniforms: !0,
  104936. removeVaryings: !0,
  104937. removeIfDef: !1,
  104938. replaceStrings: [{
  104939. search: /float CalcFogFactor\(\)/,
  104940. replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"
  104941. }]
  104942. });
  104943. var i = t._getFreeVariableName("fog")
  104944. , n = this.input
  104945. , r = this.fogColor;
  104946. this._fogParameters = t._getFreeVariableName("fogParameters");
  104947. var o = this._outputs[0];
  104948. t._emitUniformFromString(this._fogParameters, "vec4"),
  104949. t.compilationString += "#ifdef FOG\r\n",
  104950. t.compilationString += "float ".concat(i, " = CalcFogFactor(").concat(this._fogDistanceName, ", ").concat(this._fogParameters, ");\r\n"),
  104951. t.compilationString += this._declareOutput(o, t) + " = ".concat(i, " * ").concat(n.associatedVariableName, ".rgb + (1.0 - ").concat(i, ") * ").concat(r.associatedVariableName, ".rgb;\r\n"),
  104952. t.compilationString += "#else\r\n".concat(this._declareOutput(o, t), " = ").concat(n.associatedVariableName, ".rgb;\r\n"),
  104953. t.compilationString += "#endif\r\n"
  104954. } else {
  104955. var a = this.worldPosition
  104956. , s = this.view;
  104957. this._fogDistanceName = t._getFreeVariableName("vFogDistance"),
  104958. t._emitVaryingFromString(this._fogDistanceName, "vec3"),
  104959. t.compilationString += "".concat(this._fogDistanceName, " = (").concat(s.associatedVariableName, " * ").concat(a.associatedVariableName, ").xyz;\r\n")
  104960. }
  104961. return this
  104962. }
  104963. ,
  104964. t
  104965. }(Wp);
  104966. y("BABYLON.FogBlock", Fm);
  104967. var wm = function(e) {
  104968. function t(t) {
  104969. var i = e.call(this, t, Dp.VertexAndFragment) || this;
  104970. return i._isUnique = !0,
  104971. i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
  104972. i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
  104973. i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
  104974. i.registerInput("glossiness", Op.Float, !0, Dp.Fragment),
  104975. i.registerInput("glossPower", Op.Float, !0, Dp.Fragment),
  104976. i.registerInput("diffuseColor", Op.Color3, !0, Dp.Fragment),
  104977. i.registerInput("specularColor", Op.Color3, !0, Dp.Fragment),
  104978. i.registerInput("view", Op.Matrix, !0),
  104979. i.registerOutput("diffuseOutput", Op.Color3, Dp.Fragment),
  104980. i.registerOutput("specularOutput", Op.Color3, Dp.Fragment),
  104981. i.registerOutput("shadow", Op.Float, Dp.Fragment),
  104982. i
  104983. }
  104984. return U(t, e),
  104985. t.prototype.getClassName = function() {
  104986. return "LightBlock"
  104987. }
  104988. ,
  104989. Object.defineProperty(t.prototype, "worldPosition", {
  104990. get: function() {
  104991. return this._inputs[0]
  104992. },
  104993. enumerable: !1,
  104994. configurable: !0
  104995. }),
  104996. Object.defineProperty(t.prototype, "worldNormal", {
  104997. get: function() {
  104998. return this._inputs[1]
  104999. },
  105000. enumerable: !1,
  105001. configurable: !0
  105002. }),
  105003. Object.defineProperty(t.prototype, "cameraPosition", {
  105004. get: function() {
  105005. return this._inputs[2]
  105006. },
  105007. enumerable: !1,
  105008. configurable: !0
  105009. }),
  105010. Object.defineProperty(t.prototype, "glossiness", {
  105011. get: function() {
  105012. return this._inputs[3]
  105013. },
  105014. enumerable: !1,
  105015. configurable: !0
  105016. }),
  105017. Object.defineProperty(t.prototype, "glossPower", {
  105018. get: function() {
  105019. return this._inputs[4]
  105020. },
  105021. enumerable: !1,
  105022. configurable: !0
  105023. }),
  105024. Object.defineProperty(t.prototype, "diffuseColor", {
  105025. get: function() {
  105026. return this._inputs[5]
  105027. },
  105028. enumerable: !1,
  105029. configurable: !0
  105030. }),
  105031. Object.defineProperty(t.prototype, "specularColor", {
  105032. get: function() {
  105033. return this._inputs[6]
  105034. },
  105035. enumerable: !1,
  105036. configurable: !0
  105037. }),
  105038. Object.defineProperty(t.prototype, "view", {
  105039. get: function() {
  105040. return this._inputs[7]
  105041. },
  105042. enumerable: !1,
  105043. configurable: !0
  105044. }),
  105045. Object.defineProperty(t.prototype, "diffuseOutput", {
  105046. get: function() {
  105047. return this._outputs[0]
  105048. },
  105049. enumerable: !1,
  105050. configurable: !0
  105051. }),
  105052. Object.defineProperty(t.prototype, "specularOutput", {
  105053. get: function() {
  105054. return this._outputs[1]
  105055. },
  105056. enumerable: !1,
  105057. configurable: !0
  105058. }),
  105059. Object.defineProperty(t.prototype, "shadow", {
  105060. get: function() {
  105061. return this._outputs[2]
  105062. },
  105063. enumerable: !1,
  105064. configurable: !0
  105065. }),
  105066. t.prototype.autoConfigure = function(e) {
  105067. if (!this.cameraPosition.isConnected) {
  105068. var t = e.getInputBlockByPredicate((function(e) {
  105069. return e.systemValue === Qp.CameraPosition
  105070. }
  105071. ));
  105072. t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
  105073. t.output.connectTo(this.cameraPosition)
  105074. }
  105075. }
  105076. ,
  105077. t.prototype.prepareDefines = function(e, t, i) {
  105078. if (i._areLightsDirty) {
  105079. var n = e.getScene();
  105080. if (this.light) {
  105081. var r = {
  105082. needNormals: !1,
  105083. needRebuild: !1,
  105084. lightmapMode: !1,
  105085. shadowEnabled: !1,
  105086. specularEnabled: !1
  105087. };
  105088. Mr.PrepareDefinesForLight(n, e, this.light, this._lightId, i, !0, r),
  105089. r.needRebuild && i.rebuild()
  105090. } else
  105091. Mr.PrepareDefinesForLights(n, e, i, !0, t.maxSimultaneousLights)
  105092. }
  105093. }
  105094. ,
  105095. t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
  105096. for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
  105097. var o = e.uniforms.indexOf("vLightData" + r) >= 0;
  105098. Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, o)
  105099. }
  105100. }
  105101. ,
  105102. t.prototype.bind = function(e, t, i) {
  105103. if (i) {
  105104. var n = i.getScene();
  105105. this.light ? Mr.BindLight(this.light, this._lightId, n, e, !0) : Mr.BindLights(n, i, e, !0, t.maxSimultaneousLights)
  105106. }
  105107. }
  105108. ,
  105109. t.prototype._injectVertexCode = function(e) {
  105110. var t = this.worldPosition
  105111. , i = "//".concat(this.name);
  105112. this.light ? (this._lightId = (void 0 !== e.counters.lightCounter ? e.counters.lightCounter : -1) + 1,
  105113. e.counters.lightCounter = this._lightId,
  105114. e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", i, {
  105115. replaceStrings: [{
  105116. search: /{X}/g,
  105117. replace: this._lightId.toString()
  105118. }]
  105119. }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", i, {
  105120. repeatKey: "maxSimultaneousLights"
  105121. }),
  105122. this._lightId = 0,
  105123. e.sharedData.dynamicUniformBlocks.push(this));
  105124. var n = "v_" + t.associatedVariableName;
  105125. e._emitVaryingFromString(n, "vec4") && (e.compilationString += "".concat(n, " = ").concat(t.associatedVariableName, ";\r\n")),
  105126. this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, {
  105127. replaceStrings: [{
  105128. search: /{X}/g,
  105129. replace: this._lightId.toString()
  105130. }, {
  105131. search: /worldPos/g,
  105132. replace: t.associatedVariableName
  105133. }]
  105134. }) : (e.compilationString += "vec4 worldPos = ".concat(t.associatedVariableName, ";\r\n"),
  105135. this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
  105136. e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, {
  105137. repeatKey: "maxSimultaneousLights"
  105138. }))
  105139. }
  105140. ,
  105141. t.prototype._buildBlock = function(t) {
  105142. if (e.prototype._buildBlock.call(this, t),
  105143. t.target === Dp.Fragment) {
  105144. t.sharedData.forcedBindableBlocks.push(this),
  105145. t.sharedData.blocksWithDefines.push(this);
  105146. var i = "//".concat(this.name)
  105147. , n = this.worldPosition;
  105148. t._emitFunctionFromInclude("helperFunctions", i),
  105149. t._emitFunctionFromInclude("lightsFragmentFunctions", i, {
  105150. replaceStrings: [{
  105151. search: /vPositionW/g,
  105152. replace: "v_" + n.associatedVariableName + ".xyz"
  105153. }]
  105154. }),
  105155. t._emitFunctionFromInclude("shadowsFragmentFunctions", i, {
  105156. replaceStrings: [{
  105157. search: /vPositionW/g,
  105158. replace: "v_" + n.associatedVariableName + ".xyz"
  105159. }]
  105160. }),
  105161. this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, {
  105162. replaceStrings: [{
  105163. search: /{X}/g,
  105164. replace: this._lightId.toString()
  105165. }]
  105166. }, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, {
  105167. repeatKey: "maxSimultaneousLights"
  105168. }),
  105169. 0 === this._lightId && (t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat("v_" + n.associatedVariableName, ".xyz);\r\n")),
  105170. t.compilationString += "lightingInfo info;\r\n",
  105171. t.compilationString += "float shadow = 1.;\r\n",
  105172. t.compilationString += "float glossiness = ".concat(this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0", " * ").concat(this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0", ";\r\n"),
  105173. t.compilationString += "vec3 diffuseBase = vec3(0., 0., 0.);\r\n",
  105174. t.compilationString += "vec3 specularBase = vec3(0., 0., 0.);\r\n",
  105175. t.compilationString += "vec3 normalW = ".concat(this.worldNormal.associatedVariableName, ".xyz;\r\n")),
  105176. this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", i, {
  105177. replaceStrings: [{
  105178. search: /{X}/g,
  105179. replace: this._lightId.toString()
  105180. }]
  105181. }) : t.compilationString += t._emitCodeFromInclude("lightFragment", i, {
  105182. repeatKey: "maxSimultaneousLights"
  105183. });
  105184. var r = this.diffuseOutput
  105185. , o = this.specularOutput;
  105186. return t.compilationString += this._declareOutput(r, t) + " = diffuseBase".concat(this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "", ";\r\n"),
  105187. o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = specularBase".concat(this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "", ";\r\n")),
  105188. this.shadow.hasEndpoints && (t.compilationString += this._declareOutput(this.shadow, t) + " = shadow;\r\n"),
  105189. this
  105190. }
  105191. this._injectVertexCode(t)
  105192. }
  105193. ,
  105194. t.prototype.serialize = function() {
  105195. var t = e.prototype.serialize.call(this);
  105196. return this.light && (t.lightId = this.light.id),
  105197. t
  105198. }
  105199. ,
  105200. t.prototype._deserialize = function(t, i, n) {
  105201. e.prototype._deserialize.call(this, t, i, n),
  105202. t.lightId && (this.light = i.getLightById(t.lightId))
  105203. }
  105204. ,
  105205. t
  105206. }(Wp);
  105207. y("BABYLON.LightBlock", wm);
  105208. var Bm = function(e) {
  105209. function t(t, i, n, r, o, a) {
  105210. var s = e.call(this, t, i, n) || this;
  105211. return s._blockType = r,
  105212. s._blockName = o,
  105213. s._nameForCheking = a,
  105214. s._nameForCheking || (s._nameForCheking = t),
  105215. s.needDualDirectionValidation = !0,
  105216. s
  105217. }
  105218. return U(t, e),
  105219. t.prototype.checkCompatibilityState = function(e) {
  105220. return e instanceof t && e.name === this._nameForCheking ? Up.Compatible : Up.TypeIncompatible
  105221. }
  105222. ,
  105223. t.prototype.createCustomInputBlock = function() {
  105224. return [new this._blockType(this._blockName), this.name]
  105225. }
  105226. ,
  105227. t
  105228. }(zp)
  105229. , Um = function(e) {
  105230. function t(i) {
  105231. var n = e.call(this, i, Dp.VertexAndFragment) || this;
  105232. return n.registerOutput("source", Op.Object, Dp.VertexAndFragment, new Bm("source",n,Vp.Output,t,"ImageSourceBlock")),
  105233. n
  105234. }
  105235. return U(t, e),
  105236. Object.defineProperty(t.prototype, "texture", {
  105237. get: function() {
  105238. return this._texture
  105239. },
  105240. set: function(e) {
  105241. var t, i = this;
  105242. if (this._texture !== e) {
  105243. var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
  105244. !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  105245. return e.hasTexture(i._texture)
  105246. }
  105247. )),
  105248. this._texture = e,
  105249. e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
  105250. return t.hasTexture(e)
  105251. }
  105252. ))
  105253. }
  105254. },
  105255. enumerable: !1,
  105256. configurable: !0
  105257. }),
  105258. Object.defineProperty(t.prototype, "samplerName", {
  105259. get: function() {
  105260. return this._samplerName
  105261. },
  105262. enumerable: !1,
  105263. configurable: !0
  105264. }),
  105265. t.prototype.bind = function(e) {
  105266. this.texture && e.setTexture(this._samplerName, this.texture)
  105267. }
  105268. ,
  105269. t.prototype.isReady = function() {
  105270. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  105271. }
  105272. ,
  105273. t.prototype.getClassName = function() {
  105274. return "ImageSourceBlock"
  105275. }
  105276. ,
  105277. Object.defineProperty(t.prototype, "source", {
  105278. get: function() {
  105279. return this._outputs[0]
  105280. },
  105281. enumerable: !1,
  105282. configurable: !0
  105283. }),
  105284. t.prototype._buildBlock = function(t) {
  105285. return e.prototype._buildBlock.call(this, t),
  105286. t.target === Dp.Vertex && (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
  105287. t.sharedData.blockingBlocks.push(this),
  105288. t.sharedData.textureBlocks.push(this),
  105289. t.sharedData.bindableBlocks.push(this)),
  105290. t._emit2DSampler(this._samplerName),
  105291. this
  105292. }
  105293. ,
  105294. t.prototype._dumpPropertiesCode = function() {
  105295. var t = e.prototype._dumpPropertiesCode.call(this);
  105296. return this.texture ? (t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, ");\r\n"),
  105297. t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
  105298. t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
  105299. t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
  105300. t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
  105301. t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
  105302. t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
  105303. t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
  105304. t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
  105305. t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
  105306. t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")) : t
  105307. }
  105308. ,
  105309. t.prototype.serialize = function() {
  105310. var t = e.prototype.serialize.call(this);
  105311. return this.texture && !this.texture.isRenderTarget && "VideoTexture" !== this.texture.getClassName() && (t.texture = this.texture.serialize()),
  105312. t
  105313. }
  105314. ,
  105315. t.prototype._deserialize = function(t, i, n) {
  105316. e.prototype._deserialize.call(this, t, i, n),
  105317. t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  105318. this.texture = io.Parse(t.texture, i, n))
  105319. }
  105320. ,
  105321. t
  105322. }(Wp);
  105323. y("BABYLON.ImageSourceBlock", Um);
  105324. var Vm = function(e) {
  105325. function t(t, i) {
  105326. void 0 === i && (i = !1);
  105327. var n = e.call(this, t, i ? Dp.Fragment : Dp.VertexAndFragment) || this;
  105328. return n._convertToGammaSpace = !1,
  105329. n._convertToLinearSpace = !1,
  105330. n.disableLevelMultiplication = !1,
  105331. n._fragmentOnly = i,
  105332. n.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
  105333. n.registerInput("source", Op.Object, !0, Dp.VertexAndFragment, new Bm("source",n,Vp.Input,Um,"ImageSourceBlock")),
  105334. n.registerOutput("rgba", Op.Color4, Dp.Neutral),
  105335. n.registerOutput("rgb", Op.Color3, Dp.Neutral),
  105336. n.registerOutput("r", Op.Float, Dp.Neutral),
  105337. n.registerOutput("g", Op.Float, Dp.Neutral),
  105338. n.registerOutput("b", Op.Float, Dp.Neutral),
  105339. n.registerOutput("a", Op.Float, Dp.Neutral),
  105340. n.registerOutput("level", Op.Float, Dp.Neutral),
  105341. n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  105342. n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  105343. n._inputs[0]._prioritizeVertex = !i,
  105344. n
  105345. }
  105346. return U(t, e),
  105347. Object.defineProperty(t.prototype, "texture", {
  105348. get: function() {
  105349. var e;
  105350. return this.source.isConnected ? (null === (e = this.source.connectedPoint) || void 0 === e ? void 0 : e.ownerBlock).texture : this._texture
  105351. },
  105352. set: function(e) {
  105353. var t, i = this;
  105354. if (this._texture !== e) {
  105355. var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
  105356. !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  105357. return e.hasTexture(i._texture)
  105358. }
  105359. )),
  105360. this._texture = e,
  105361. e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
  105362. return t.hasTexture(e)
  105363. }
  105364. ))
  105365. }
  105366. },
  105367. enumerable: !1,
  105368. configurable: !0
  105369. }),
  105370. Object.defineProperty(t.prototype, "samplerName", {
  105371. get: function() {
  105372. return this._imageSource ? this._imageSource.samplerName : this._samplerName
  105373. },
  105374. enumerable: !1,
  105375. configurable: !0
  105376. }),
  105377. Object.defineProperty(t.prototype, "hasImageSource", {
  105378. get: function() {
  105379. return !!this._imageSource
  105380. },
  105381. enumerable: !1,
  105382. configurable: !0
  105383. }),
  105384. Object.defineProperty(t.prototype, "convertToGammaSpace", {
  105385. get: function() {
  105386. return this._convertToGammaSpace
  105387. },
  105388. set: function(e) {
  105389. var t, i = this;
  105390. if (e !== this._convertToGammaSpace && (this._convertToGammaSpace = e,
  105391. this.texture)) {
  105392. var n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
  105393. null == n || n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  105394. return e.hasTexture(i.texture)
  105395. }
  105396. ))
  105397. }
  105398. },
  105399. enumerable: !1,
  105400. configurable: !0
  105401. }),
  105402. Object.defineProperty(t.prototype, "convertToLinearSpace", {
  105403. get: function() {
  105404. return this._convertToLinearSpace
  105405. },
  105406. set: function(e) {
  105407. var t, i = this;
  105408. if (e !== this._convertToLinearSpace && (this._convertToLinearSpace = e,
  105409. this.texture)) {
  105410. var n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
  105411. null == n || n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  105412. return e.hasTexture(i.texture)
  105413. }
  105414. ))
  105415. }
  105416. },
  105417. enumerable: !1,
  105418. configurable: !0
  105419. }),
  105420. t.prototype.getClassName = function() {
  105421. return "TextureBlock"
  105422. }
  105423. ,
  105424. Object.defineProperty(t.prototype, "uv", {
  105425. get: function() {
  105426. return this._inputs[0]
  105427. },
  105428. enumerable: !1,
  105429. configurable: !0
  105430. }),
  105431. Object.defineProperty(t.prototype, "source", {
  105432. get: function() {
  105433. return this._inputs[1]
  105434. },
  105435. enumerable: !1,
  105436. configurable: !0
  105437. }),
  105438. Object.defineProperty(t.prototype, "rgba", {
  105439. get: function() {
  105440. return this._outputs[0]
  105441. },
  105442. enumerable: !1,
  105443. configurable: !0
  105444. }),
  105445. Object.defineProperty(t.prototype, "rgb", {
  105446. get: function() {
  105447. return this._outputs[1]
  105448. },
  105449. enumerable: !1,
  105450. configurable: !0
  105451. }),
  105452. Object.defineProperty(t.prototype, "r", {
  105453. get: function() {
  105454. return this._outputs[2]
  105455. },
  105456. enumerable: !1,
  105457. configurable: !0
  105458. }),
  105459. Object.defineProperty(t.prototype, "g", {
  105460. get: function() {
  105461. return this._outputs[3]
  105462. },
  105463. enumerable: !1,
  105464. configurable: !0
  105465. }),
  105466. Object.defineProperty(t.prototype, "b", {
  105467. get: function() {
  105468. return this._outputs[4]
  105469. },
  105470. enumerable: !1,
  105471. configurable: !0
  105472. }),
  105473. Object.defineProperty(t.prototype, "a", {
  105474. get: function() {
  105475. return this._outputs[5]
  105476. },
  105477. enumerable: !1,
  105478. configurable: !0
  105479. }),
  105480. Object.defineProperty(t.prototype, "level", {
  105481. get: function() {
  105482. return this._outputs[6]
  105483. },
  105484. enumerable: !1,
  105485. configurable: !0
  105486. }),
  105487. Object.defineProperty(t.prototype, "target", {
  105488. get: function() {
  105489. if (this._fragmentOnly)
  105490. return Dp.Fragment;
  105491. if (!this.uv.isConnected)
  105492. return Dp.VertexAndFragment;
  105493. if (this.uv.sourceBlock.isInput)
  105494. return Dp.VertexAndFragment;
  105495. for (var e = this.uv.connectedPoint; e; ) {
  105496. if (e.target === Dp.Fragment)
  105497. return Dp.Fragment;
  105498. if (e.target === Dp.Vertex)
  105499. return Dp.VertexAndFragment;
  105500. if (e.target === Dp.Neutral || e.target === Dp.VertexAndFragment) {
  105501. var t = e.ownerBlock;
  105502. if (t.target === Dp.Fragment)
  105503. return Dp.Fragment;
  105504. e = null;
  105505. for (var i = 0, n = t.inputs; i < n.length; i++) {
  105506. var r = n[i];
  105507. if (r.connectedPoint) {
  105508. e = r.connectedPoint;
  105509. break
  105510. }
  105511. }
  105512. }
  105513. }
  105514. return Dp.VertexAndFragment
  105515. },
  105516. set: function(e) {},
  105517. enumerable: !1,
  105518. configurable: !0
  105519. }),
  105520. t.prototype.autoConfigure = function(e) {
  105521. if (!this.uv.isConnected)
  105522. if (e.mode === cf.PostProcess)
  105523. (t = e.getBlockByPredicate((function(e) {
  105524. return "uv" === e.name
  105525. }
  105526. ))) && t.connectTo(this);
  105527. else {
  105528. var t, i = e.mode === cf.Particle ? "particle_uv" : "uv";
  105529. (t = e.getInputBlockByPredicate((function(e) {
  105530. return e.isAttribute && e.name === i
  105531. }
  105532. ))) || (t = new tf("uv")).setAsAttribute(i),
  105533. t.output.connectTo(this.uv)
  105534. }
  105535. }
  105536. ,
  105537. t.prototype.initializeDefines = function(e, t, i) {
  105538. i._areTexturesDirty && void 0 !== this._mainUVDefineName && i.setValue(this._mainUVDefineName, !1, !0)
  105539. }
  105540. ,
  105541. t.prototype.prepareDefines = function(e, t, i) {
  105542. if (i._areTexturesDirty)
  105543. if (this.texture && this.texture.getTextureMatrix) {
  105544. var n = this.convertToGammaSpace && this.texture && !this.texture.gammaSpace
  105545. , r = this.convertToLinearSpace && this.texture && this.texture.gammaSpace;
  105546. i.setValue(this._linearDefineName, n, !0),
  105547. i.setValue(this._gammaDefineName, r, !0),
  105548. this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (i.setValue(this._defineName, !1, !0),
  105549. i.setValue(this._mainUVDefineName, !0, !0)) : (i.setValue(this._defineName, !0),
  105550. null == i[this._mainUVDefineName] && i.setValue(this._mainUVDefineName, !1, !0)))
  105551. } else
  105552. this._isMixed && (i.setValue(this._defineName, !1, !0),
  105553. i.setValue(this._mainUVDefineName, !0, !0))
  105554. }
  105555. ,
  105556. t.prototype.isReady = function() {
  105557. return !(this.texture && !this.texture.isReadyOrNotBlocking())
  105558. }
  105559. ,
  105560. t.prototype.bind = function(e) {
  105561. this.texture && (this._isMixed && (e.setFloat(this._textureInfoName, this.texture.level),
  105562. e.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())),
  105563. this._imageSource || e.setTexture(this._samplerName, this.texture))
  105564. }
  105565. ,
  105566. Object.defineProperty(t.prototype, "_isMixed", {
  105567. get: function() {
  105568. return this.target !== Dp.Fragment
  105569. },
  105570. enumerable: !1,
  105571. configurable: !0
  105572. }),
  105573. t.prototype._injectVertexCode = function(e) {
  105574. var t = this.uv;
  105575. if (this._defineName = e._getFreeDefineName("UVTRANSFORM"),
  105576. this._mainUVDefineName = "VMAIN" + t.associatedVariableName.toUpperCase(),
  105577. this._mainUVName = "vMain" + t.associatedVariableName,
  105578. this._transformedUVName = e._getFreeVariableName("transformedUV"),
  105579. this._textureTransformName = e._getFreeVariableName("textureTransform"),
  105580. this._textureInfoName = e._getFreeVariableName("textureInfoName"),
  105581. this.level.associatedVariableName = this._textureInfoName,
  105582. e._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName),
  105583. e._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName),
  105584. e._emitUniformFromString(this._textureTransformName, "mat4", this._defineName),
  105585. e.compilationString += "#ifdef ".concat(this._defineName, "\r\n"),
  105586. e.compilationString += "".concat(this._transformedUVName, " = vec2(").concat(this._textureTransformName, " * vec4(").concat(t.associatedVariableName, ".xy, 1.0, 0.0));\r\n"),
  105587. e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
  105588. e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
  105589. e.compilationString += "#endif\r\n",
  105590. this._outputs.some((function(e) {
  105591. return e.isConnectedInVertexShader
  105592. }
  105593. ))) {
  105594. this._writeTextureRead(e, !0);
  105595. for (var i = 0, n = this._outputs; i < n.length; i++) {
  105596. var r = n[i];
  105597. r.hasEndpoints && "level" !== r.name && this._writeOutput(e, r, r.name, !0)
  105598. }
  105599. }
  105600. }
  105601. ,
  105602. t.prototype._generateTextureLookup = function(e) {
  105603. var t = this.samplerName;
  105604. e.compilationString += "#ifdef ".concat(this._defineName, "\r\n"),
  105605. e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._transformedUVName, ");\r\n"),
  105606. e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
  105607. e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._mainUVName ? this._mainUVName : this.uv.associatedVariableName, ");\r\n"),
  105608. e.compilationString += "#endif\r\n"
  105609. }
  105610. ,
  105611. t.prototype._writeTextureRead = function(e, t) {
  105612. void 0 === t && (t = !1);
  105613. var i = this.uv;
  105614. if (t) {
  105615. if (e.target === Dp.Fragment)
  105616. return;
  105617. this._generateTextureLookup(e)
  105618. } else
  105619. this.uv.ownerBlock.target !== Dp.Fragment ? this._generateTextureLookup(e) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this.samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
  105620. }
  105621. ,
  105622. t.prototype._generateConversionCode = function(e, t, i) {
  105623. "a" !== i && (this.texture && this.texture.gammaSpace || (e.compilationString += "#ifdef ".concat(this._linearDefineName, "\n ").concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\n #endif\n ")),
  105624. e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\n ").concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\n #endif\n "))
  105625. }
  105626. ,
  105627. t.prototype._writeOutput = function(e, t, i, n) {
  105628. if (void 0 === n && (n = !1),
  105629. n) {
  105630. if (e.target === Dp.Fragment)
  105631. return;
  105632. return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
  105633. void this._generateConversionCode(e, t, i)
  105634. }
  105635. if (this.uv.ownerBlock.target === Dp.Fragment)
  105636. return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
  105637. void this._generateConversionCode(e, t, i);
  105638. var r = "";
  105639. this.disableLevelMultiplication || (r = " * ".concat(this._textureInfoName)),
  105640. e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i).concat(r, ";\r\n"),
  105641. this._generateConversionCode(e, t, i)
  105642. }
  105643. ,
  105644. t.prototype._buildBlock = function(t) {
  105645. if (e.prototype._buildBlock.call(this, t),
  105646. this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
  105647. (t.target === Dp.Vertex || this._fragmentOnly || t.target === Dp.Fragment && void 0 === this._tempTextureRead) && (this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
  105648. this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
  105649. this._gammaDefineName = t._getFreeDefineName("ISGAMMA")),
  105650. (!this._isMixed && t.target === Dp.Fragment || this._isMixed && t.target === Dp.Vertex) && (this._imageSource || (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
  105651. t._emit2DSampler(this._samplerName)),
  105652. t.sharedData.blockingBlocks.push(this),
  105653. t.sharedData.textureBlocks.push(this),
  105654. t.sharedData.blocksWithDefines.push(this),
  105655. t.sharedData.bindableBlocks.push(this)),
  105656. t.target === Dp.Fragment) {
  105657. if (this._outputs.some((function(e) {
  105658. return e.isConnectedInFragmentShader
  105659. }
  105660. ))) {
  105661. this._isMixed && !this._imageSource && t._emit2DSampler(this._samplerName);
  105662. var i = "//".concat(this.name);
  105663. t._emitFunctionFromInclude("helperFunctions", i),
  105664. this._isMixed && t._emitUniformFromString(this._textureInfoName, "float"),
  105665. this._writeTextureRead(t);
  105666. for (var n = 0, r = this._outputs; n < r.length; n++) {
  105667. var o = r[n];
  105668. o.hasEndpoints && "level" !== o.name && this._writeOutput(t, o, o.name)
  105669. }
  105670. return this
  105671. }
  105672. } else
  105673. this._injectVertexCode(t)
  105674. }
  105675. ,
  105676. t.prototype._dumpPropertiesCode = function() {
  105677. var t = e.prototype._dumpPropertiesCode.call(this);
  105678. return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\r\n"),
  105679. t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n"),
  105680. t += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, ";\r\n"),
  105681. this.texture ? (t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, ");\r\n"),
  105682. t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
  105683. t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
  105684. t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
  105685. t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
  105686. t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
  105687. t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
  105688. t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
  105689. t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
  105690. t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
  105691. t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")) : t
  105692. }
  105693. ,
  105694. t.prototype.serialize = function() {
  105695. var t = e.prototype.serialize.call(this);
  105696. return t.convertToGammaSpace = this.convertToGammaSpace,
  105697. t.convertToLinearSpace = this.convertToLinearSpace,
  105698. t.fragmentOnly = this._fragmentOnly,
  105699. t.disableLevelMultiplication = this.disableLevelMultiplication,
  105700. this.hasImageSource || !this.texture || this.texture.isRenderTarget || "VideoTexture" === this.texture.getClassName() || (t.texture = this.texture.serialize()),
  105701. t
  105702. }
  105703. ,
  105704. t.prototype._deserialize = function(t, i, n) {
  105705. e.prototype._deserialize.call(this, t, i, n),
  105706. this.convertToGammaSpace = t.convertToGammaSpace,
  105707. this.convertToLinearSpace = !!t.convertToLinearSpace,
  105708. this._fragmentOnly = !!t.fragmentOnly,
  105709. this.disableLevelMultiplication = !!t.disableLevelMultiplication,
  105710. t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  105711. this.texture = io.Parse(t.texture, i, n))
  105712. }
  105713. ,
  105714. t
  105715. }(Wp);
  105716. y("BABYLON.TextureBlock", Vm);
  105717. var km = function(e) {
  105718. function t(t) {
  105719. return e.call(this, t, Dp.VertexAndFragment) || this
  105720. }
  105721. return U(t, e),
  105722. Object.defineProperty(t.prototype, "texture", {
  105723. get: function() {
  105724. return this._texture
  105725. },
  105726. set: function(e) {
  105727. var t, i = this;
  105728. if (this._texture !== e) {
  105729. var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
  105730. !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
  105731. return e.hasTexture(i._texture)
  105732. }
  105733. )),
  105734. this._texture = e,
  105735. e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
  105736. return t.hasTexture(e)
  105737. }
  105738. ))
  105739. }
  105740. },
  105741. enumerable: !1,
  105742. configurable: !0
  105743. }),
  105744. t.prototype.getClassName = function() {
  105745. return "ReflectionTextureBaseBlock"
  105746. }
  105747. ,
  105748. t.prototype._getTexture = function() {
  105749. return this.texture
  105750. }
  105751. ,
  105752. t.prototype.autoConfigure = function(e) {
  105753. if (!this.position.isConnected) {
  105754. var t = e.getInputBlockByPredicate((function(e) {
  105755. return e.isAttribute && "position" === e.name
  105756. }
  105757. ));
  105758. t || (t = new tf("position")).setAsAttribute(),
  105759. t.output.connectTo(this.position)
  105760. }
  105761. if (!this.world.isConnected) {
  105762. var i = e.getInputBlockByPredicate((function(e) {
  105763. return e.systemValue === Qp.World
  105764. }
  105765. ));
  105766. i || (i = new tf("world")).setAsSystemValue(Qp.World),
  105767. i.output.connectTo(this.world)
  105768. }
  105769. if (this.view && !this.view.isConnected) {
  105770. var n = e.getInputBlockByPredicate((function(e) {
  105771. return e.systemValue === Qp.View
  105772. }
  105773. ));
  105774. n || (n = new tf("view")).setAsSystemValue(Qp.View),
  105775. n.output.connectTo(this.view)
  105776. }
  105777. }
  105778. ,
  105779. t.prototype.prepareDefines = function(e, t, i) {
  105780. if (i._areTexturesDirty) {
  105781. var n = this._getTexture();
  105782. n && n.getTextureMatrix && (i.setValue(this._define3DName, n.isCube, !0),
  105783. i.setValue(this._defineLocalCubicName, !!n.boundingBoxSize, !0),
  105784. i.setValue(this._defineExplicitName, n.coordinatesMode === a.TEXTURE_EXPLICIT_MODE, !0),
  105785. i.setValue(this._defineSkyboxName, n.coordinatesMode === a.TEXTURE_SKYBOX_MODE, !0),
  105786. i.setValue(this._defineCubicName, n.coordinatesMode === a.TEXTURE_CUBIC_MODE || n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
  105787. i.setValue("INVERTCUBICMAP", n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
  105788. i.setValue(this._defineSphericalName, n.coordinatesMode === a.TEXTURE_SPHERICAL_MODE, !0),
  105789. i.setValue(this._definePlanarName, n.coordinatesMode === a.TEXTURE_PLANAR_MODE, !0),
  105790. i.setValue(this._defineProjectionName, n.coordinatesMode === a.TEXTURE_PROJECTION_MODE, !0),
  105791. i.setValue(this._defineEquirectangularName, n.coordinatesMode === a.TEXTURE_EQUIRECTANGULAR_MODE, !0),
  105792. i.setValue(this._defineEquirectangularFixedName, n.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0),
  105793. i.setValue(this._defineMirroredEquirectangularFixedName, n.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, !0))
  105794. }
  105795. }
  105796. ,
  105797. t.prototype.isReady = function() {
  105798. var e = this._getTexture();
  105799. return !(e && !e.isReadyOrNotBlocking())
  105800. }
  105801. ,
  105802. t.prototype.bind = function(e, t, i) {
  105803. var n = this._getTexture();
  105804. if (i && n && (e.setMatrix(this._reflectionMatrixName, n.getReflectionTextureMatrix()),
  105805. n.isCube ? e.setTexture(this._cubeSamplerName, n) : e.setTexture(this._2DSamplerName, n),
  105806. n.boundingBoxSize)) {
  105807. var r = n;
  105808. e.setVector3(this._reflectionPositionName, r.boundingBoxPosition),
  105809. e.setVector3(this._reflectionSizeName, r.boundingBoxSize)
  105810. }
  105811. }
  105812. ,
  105813. t.prototype.handleVertexSide = function(e) {
  105814. this._define3DName = e._getFreeDefineName("REFLECTIONMAP_3D"),
  105815. this._defineCubicName = e._getFreeDefineName("REFLECTIONMAP_CUBIC"),
  105816. this._defineSphericalName = e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),
  105817. this._definePlanarName = e._getFreeDefineName("REFLECTIONMAP_PLANAR"),
  105818. this._defineProjectionName = e._getFreeDefineName("REFLECTIONMAP_PROJECTION"),
  105819. this._defineExplicitName = e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),
  105820. this._defineEquirectangularName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),
  105821. this._defineLocalCubicName = e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),
  105822. this._defineMirroredEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),
  105823. this._defineEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),
  105824. this._defineSkyboxName = e._getFreeDefineName("REFLECTIONMAP_SKYBOX"),
  105825. this._defineOppositeZ = e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),
  105826. this._reflectionMatrixName = e._getFreeVariableName("reflectionMatrix"),
  105827. e._emitUniformFromString(this._reflectionMatrixName, "mat4");
  105828. var t = ""
  105829. , i = "v_" + this.worldPosition.associatedVariableName;
  105830. return e._emitVaryingFromString(i, "vec4") && (t += "".concat(i, " = ").concat(this.worldPosition.associatedVariableName, ";\r\n")),
  105831. this._positionUVWName = e._getFreeVariableName("positionUVW"),
  105832. this._directionWName = e._getFreeVariableName("directionW"),
  105833. e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (t += "#ifdef ".concat(this._defineSkyboxName, "\r\n"),
  105834. t += "".concat(this._positionUVWName, " = ").concat(this.position.associatedVariableName, ".xyz;\r\n"),
  105835. t += "#endif\r\n"),
  105836. e._emitVaryingFromString(this._directionWName, "vec3", "defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")")) && (t += "#if defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")\r\n"),
  105837. t += "".concat(this._directionWName, " = normalize(vec3(").concat(this.world.associatedVariableName, " * vec4(").concat(this.position.associatedVariableName, ".xyz, 0.0)));\r\n"),
  105838. t += "#endif\r\n"),
  105839. t
  105840. }
  105841. ,
  105842. t.prototype.handleFragmentSideInits = function(e) {
  105843. e.sharedData.blockingBlocks.push(this),
  105844. e.sharedData.textureBlocks.push(this),
  105845. this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"),
  105846. e.samplers.push(this._cubeSamplerName),
  105847. this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"),
  105848. e.samplers.push(this._2DSamplerName),
  105849. e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\r\n"),
  105850. e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
  105851. e._samplerDeclaration += "#else\r\n",
  105852. e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
  105853. e._samplerDeclaration += "#endif\r\n",
  105854. e.sharedData.blocksWithDefines.push(this),
  105855. e.sharedData.bindableBlocks.push(this);
  105856. var t = "//".concat(this.name);
  105857. e._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""),
  105858. e._emitFunctionFromInclude("helperFunctions", t),
  105859. e._emitFunctionFromInclude("reflectionFunction", t, {
  105860. replaceStrings: [{
  105861. search: /vec3 computeReflectionCoords/g,
  105862. replace: "void DUMMYFUNC"
  105863. }]
  105864. }),
  105865. this._reflectionColorName = e._getFreeVariableName("reflectionColor"),
  105866. this._reflectionVectorName = e._getFreeVariableName("reflectionUVW"),
  105867. this._reflectionCoordsName = e._getFreeVariableName("reflectionCoords"),
  105868. this._reflectionPositionName = e._getFreeVariableName("vReflectionPosition"),
  105869. e._emitUniformFromString(this._reflectionPositionName, "vec3"),
  105870. this._reflectionSizeName = e._getFreeVariableName("vReflectionPosition"),
  105871. e._emitUniformFromString(this._reflectionSizeName, "vec3")
  105872. }
  105873. ,
  105874. t.prototype.handleFragmentSideCodeReflectionCoords = function(e, t, i) {
  105875. void 0 === i && (i = !1),
  105876. t || (t = "v_".concat(this.worldPosition.associatedVariableName));
  105877. var n = this._reflectionMatrixName
  105878. , r = "normalize(".concat(this._directionWName, ")")
  105879. , o = "".concat(this._positionUVWName)
  105880. , a = "".concat(this.cameraPosition.associatedVariableName)
  105881. , s = "".concat(this.view.associatedVariableName);
  105882. e += ".xyz";
  105883. var l = "\n #ifdef ".concat(this._defineMirroredEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeMirroredFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularName, "\n vec3 ").concat(this._reflectionVectorName, " = computeEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSphericalName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSphericalCoords(").concat(t, ", ").concat(e, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._definePlanarName, "\n vec3 ").concat(this._reflectionVectorName, " = computePlanarCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineCubicName, "\n #ifdef ").concat(this._defineLocalCubicName, "\n vec3 ").concat(this._reflectionVectorName, " = computeCubicLocalCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ", ").concat(this._reflectionSizeName, ", ").concat(this._reflectionPositionName, ");\n #else\n vec3 ").concat(this._reflectionVectorName, " = computeCubicCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n #endif\n\n #ifdef ").concat(this._defineProjectionName, "\n vec3 ").concat(this._reflectionVectorName, " = computeProjectionCoords(").concat(t, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSkyboxName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSkyBoxCoords(").concat(o, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineExplicitName, "\n vec3 ").concat(this._reflectionVectorName, " = vec3(0, 0, 0);\n #endif\n\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(this._reflectionVectorName, ".z *= -1.0;\n #endif\r\n");
  105884. return i || (l += "\n #ifdef ".concat(this._define3DName, "\n vec3 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ";\n #else\n vec2 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ".xy;\n #ifdef ").concat(this._defineProjectionName, "\n ").concat(this._reflectionCoordsName, " /= ").concat(this._reflectionVectorName, ".z;\n #endif\n ").concat(this._reflectionCoordsName, ".y = 1.0 - ").concat(this._reflectionCoordsName, ".y;\n #endif\r\n")),
  105885. l
  105886. }
  105887. ,
  105888. t.prototype.handleFragmentSideCodeReflectionColor = function(e, t) {
  105889. void 0 === t && (t = ".rgb");
  105890. var i = "vec" + (0 === t.length ? "4" : t.length - 1)
  105891. , n = "".concat(i, " ").concat(this._reflectionColorName, ";\n #ifdef ").concat(this._define3DName, "\r\n");
  105892. return n += e ? "".concat(this._reflectionColorName, " = textureCubeLodEXT(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = textureCube(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ")").concat(t, ";\r\n"),
  105893. n += "\n #else\r\n",
  105894. (n += e ? "".concat(this._reflectionColorName, " = texture2DLodEXT(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = texture2D(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ")").concat(t, ";\r\n")) + "#endif\r\n"
  105895. }
  105896. ,
  105897. t.prototype.writeOutputs = function(e, t) {
  105898. var i = "";
  105899. if (e.target === Dp.Fragment)
  105900. for (var n = 0, r = this._outputs; n < r.length; n++) {
  105901. var o = r[n];
  105902. o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\n"))
  105903. }
  105904. return i
  105905. }
  105906. ,
  105907. t.prototype._buildBlock = function(t) {
  105908. return e.prototype._buildBlock.call(this, t),
  105909. this
  105910. }
  105911. ,
  105912. t.prototype._dumpPropertiesCode = function() {
  105913. var t = e.prototype._dumpPropertiesCode.call(this);
  105914. if (!this.texture)
  105915. return t;
  105916. if (this.texture.isCube) {
  105917. var i = this.texture.forcedExtension;
  105918. t += "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '", undefined, undefined, ').concat(this.texture.noMipmap, ", null, undefined, undefined, undefined, ").concat(this.texture._prefiltered, ", ").concat(i ? '"' + i + '"' : "null", ");\r\n")
  105919. } else
  105920. t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null);\r\n');
  105921. return t + "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")
  105922. }
  105923. ,
  105924. t.prototype.serialize = function() {
  105925. var t = e.prototype.serialize.call(this);
  105926. return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
  105927. t
  105928. }
  105929. ,
  105930. t.prototype._deserialize = function(t, i, n) {
  105931. e.prototype._deserialize.call(this, t, i, n),
  105932. t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  105933. t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n))
  105934. }
  105935. ,
  105936. t
  105937. }(Wp);
  105938. y("BABYLON.ReflectionTextureBaseBlock", km);
  105939. var Gm = function(e) {
  105940. function t(t) {
  105941. var i = e.call(this, t) || this;
  105942. return i.registerInput("position", Op.Vector3, !1, Dp.Vertex),
  105943. i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
  105944. i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
  105945. i.registerInput("world", Op.Matrix, !1, Dp.Vertex),
  105946. i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
  105947. i.registerInput("view", Op.Matrix, !1, Dp.Fragment),
  105948. i.registerOutput("rgb", Op.Color3, Dp.Fragment),
  105949. i.registerOutput("rgba", Op.Color4, Dp.Fragment),
  105950. i.registerOutput("r", Op.Float, Dp.Fragment),
  105951. i.registerOutput("g", Op.Float, Dp.Fragment),
  105952. i.registerOutput("b", Op.Float, Dp.Fragment),
  105953. i.registerOutput("a", Op.Float, Dp.Fragment),
  105954. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  105955. i
  105956. }
  105957. return U(t, e),
  105958. t.prototype.getClassName = function() {
  105959. return "ReflectionTextureBlock"
  105960. }
  105961. ,
  105962. Object.defineProperty(t.prototype, "position", {
  105963. get: function() {
  105964. return this._inputs[0]
  105965. },
  105966. enumerable: !1,
  105967. configurable: !0
  105968. }),
  105969. Object.defineProperty(t.prototype, "worldPosition", {
  105970. get: function() {
  105971. return this._inputs[1]
  105972. },
  105973. enumerable: !1,
  105974. configurable: !0
  105975. }),
  105976. Object.defineProperty(t.prototype, "worldNormal", {
  105977. get: function() {
  105978. return this._inputs[2]
  105979. },
  105980. enumerable: !1,
  105981. configurable: !0
  105982. }),
  105983. Object.defineProperty(t.prototype, "world", {
  105984. get: function() {
  105985. return this._inputs[3]
  105986. },
  105987. enumerable: !1,
  105988. configurable: !0
  105989. }),
  105990. Object.defineProperty(t.prototype, "cameraPosition", {
  105991. get: function() {
  105992. return this._inputs[4]
  105993. },
  105994. enumerable: !1,
  105995. configurable: !0
  105996. }),
  105997. Object.defineProperty(t.prototype, "view", {
  105998. get: function() {
  105999. return this._inputs[5]
  106000. },
  106001. enumerable: !1,
  106002. configurable: !0
  106003. }),
  106004. Object.defineProperty(t.prototype, "rgb", {
  106005. get: function() {
  106006. return this._outputs[0]
  106007. },
  106008. enumerable: !1,
  106009. configurable: !0
  106010. }),
  106011. Object.defineProperty(t.prototype, "rgba", {
  106012. get: function() {
  106013. return this._outputs[1]
  106014. },
  106015. enumerable: !1,
  106016. configurable: !0
  106017. }),
  106018. Object.defineProperty(t.prototype, "r", {
  106019. get: function() {
  106020. return this._outputs[2]
  106021. },
  106022. enumerable: !1,
  106023. configurable: !0
  106024. }),
  106025. Object.defineProperty(t.prototype, "g", {
  106026. get: function() {
  106027. return this._outputs[3]
  106028. },
  106029. enumerable: !1,
  106030. configurable: !0
  106031. }),
  106032. Object.defineProperty(t.prototype, "b", {
  106033. get: function() {
  106034. return this._outputs[4]
  106035. },
  106036. enumerable: !1,
  106037. configurable: !0
  106038. }),
  106039. Object.defineProperty(t.prototype, "a", {
  106040. get: function() {
  106041. return this._outputs[5]
  106042. },
  106043. enumerable: !1,
  106044. configurable: !0
  106045. }),
  106046. t.prototype.autoConfigure = function(t) {
  106047. if (e.prototype.autoConfigure.call(this, t),
  106048. !this.cameraPosition.isConnected) {
  106049. var i = t.getInputBlockByPredicate((function(e) {
  106050. return e.systemValue === Qp.CameraPosition
  106051. }
  106052. ));
  106053. i || (i = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
  106054. i.output.connectTo(this.cameraPosition)
  106055. }
  106056. }
  106057. ,
  106058. t.prototype._buildBlock = function(t) {
  106059. if (e.prototype._buildBlock.call(this, t),
  106060. !this.texture)
  106061. return t.compilationString += this.writeOutputs(t, "vec3(0.)"),
  106062. this;
  106063. if (t.target !== Dp.Fragment)
  106064. return t.compilationString += this.handleVertexSide(t),
  106065. this;
  106066. this.handleFragmentSideInits(t);
  106067. var i = t._getFreeVariableName("normalWUnit");
  106068. return t.compilationString += "vec4 ".concat(i, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
  106069. t.compilationString += this.handleFragmentSideCodeReflectionCoords(i),
  106070. t.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
  106071. t.compilationString += this.writeOutputs(t, this._reflectionColorName),
  106072. this
  106073. }
  106074. ,
  106075. t
  106076. }(km);
  106077. y("BABYLON.ReflectionTextureBlock", Gm);
  106078. var zm = function(e) {
  106079. function t(t) {
  106080. var i = e.call(this, t, Dp.VertexAndFragment) || this;
  106081. return i._samplerName = "textureSampler",
  106082. i.useNonLinearDepth = !1,
  106083. i.force32itsFloat = !1,
  106084. i._isUnique = !0,
  106085. i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
  106086. i.registerOutput("depth", Op.Float, Dp.Neutral),
  106087. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  106088. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  106089. i._inputs[0]._prioritizeVertex = !1,
  106090. i
  106091. }
  106092. return U(t, e),
  106093. t.prototype.getClassName = function() {
  106094. return "SceneDepthBlock"
  106095. }
  106096. ,
  106097. Object.defineProperty(t.prototype, "uv", {
  106098. get: function() {
  106099. return this._inputs[0]
  106100. },
  106101. enumerable: !1,
  106102. configurable: !0
  106103. }),
  106104. Object.defineProperty(t.prototype, "depth", {
  106105. get: function() {
  106106. return this._outputs[0]
  106107. },
  106108. enumerable: !1,
  106109. configurable: !0
  106110. }),
  106111. t.prototype.initialize = function(e) {
  106112. e._excludeVariableName("textureSampler")
  106113. }
  106114. ,
  106115. Object.defineProperty(t.prototype, "target", {
  106116. get: function() {
  106117. return this.uv.isConnected ? this.uv.sourceBlock.isInput ? Dp.VertexAndFragment : Dp.Fragment : Dp.VertexAndFragment
  106118. },
  106119. enumerable: !1,
  106120. configurable: !0
  106121. }),
  106122. t.prototype._getTexture = function(e) {
  106123. return e.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat).getDepthMap()
  106124. }
  106125. ,
  106126. t.prototype.bind = function(e, t) {
  106127. var i = this._getTexture(t.getScene());
  106128. e.setTexture(this._samplerName, i)
  106129. }
  106130. ,
  106131. t.prototype._injectVertexCode = function(e) {
  106132. var t = this.uv;
  106133. if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec" + (t.type === Op.Vector3 ? "3" : t.type === Op.Vector4 ? "4" : "2"))),
  106134. this._mainUVName = "vMain" + t.associatedVariableName,
  106135. e._emitVaryingFromString(this._mainUVName, "vec2"),
  106136. e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
  106137. this._outputs.some((function(e) {
  106138. return e.isConnectedInVertexShader
  106139. }
  106140. ))) {
  106141. this._writeTextureRead(e, !0);
  106142. for (var i = 0, n = this._outputs; i < n.length; i++) {
  106143. var r = n[i];
  106144. r.hasEndpoints && this._writeOutput(e, r, "r", !0)
  106145. }
  106146. }
  106147. }
  106148. ,
  106149. t.prototype._writeTextureRead = function(e, t) {
  106150. void 0 === t && (t = !1);
  106151. var i = this.uv;
  106152. if (t) {
  106153. if (e.target === Dp.Fragment)
  106154. return;
  106155. e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
  106156. } else
  106157. this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
  106158. }
  106159. ,
  106160. t.prototype._writeOutput = function(e, t, i, n) {
  106161. if (void 0 === n && (n = !1),
  106162. n) {
  106163. if (e.target === Dp.Fragment)
  106164. return;
  106165. e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
  106166. } else
  106167. this.uv.ownerBlock.target,
  106168. Dp.Fragment,
  106169. e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
  106170. }
  106171. ,
  106172. t.prototype._buildBlock = function(t) {
  106173. if (e.prototype._buildBlock.call(this, t),
  106174. this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
  106175. t.sharedData.bindableBlocks.indexOf(this) < 0 && t.sharedData.bindableBlocks.push(this),
  106176. t.target !== Dp.Fragment)
  106177. return t._emit2DSampler(this._samplerName),
  106178. void this._injectVertexCode(t);
  106179. if (this._outputs.some((function(e) {
  106180. return e.isConnectedInFragmentShader
  106181. }
  106182. ))) {
  106183. t._emit2DSampler(this._samplerName),
  106184. this._writeTextureRead(t);
  106185. for (var i = 0, n = this._outputs; i < n.length; i++) {
  106186. var r = n[i];
  106187. r.hasEndpoints && this._writeOutput(t, r, "r")
  106188. }
  106189. return this
  106190. }
  106191. }
  106192. ,
  106193. t.prototype.serialize = function() {
  106194. var t = e.prototype.serialize.call(this);
  106195. return t.useNonLinearDepth = this.useNonLinearDepth,
  106196. t.force32itsFloat = this.force32itsFloat,
  106197. t
  106198. }
  106199. ,
  106200. t.prototype._deserialize = function(t, i, n) {
  106201. e.prototype._deserialize.call(this, t, i, n),
  106202. this.useNonLinearDepth = t.useNonLinearDepth,
  106203. this.force32itsFloat = t.force32itsFloat
  106204. }
  106205. ,
  106206. k([Yp("Use non linear depth", Xp.Boolean, "ADVANCED", {
  106207. notifiers: {
  106208. activatePreviewCommand: !0,
  106209. callback: function(e) {
  106210. return e.disableDepthRenderer()
  106211. }
  106212. }
  106213. })], t.prototype, "useNonLinearDepth", void 0),
  106214. k([Yp("Force 32 bits float", Xp.Boolean, "ADVANCED", {
  106215. notifiers: {
  106216. activatePreviewCommand: !0,
  106217. callback: function(e) {
  106218. return e.disableDepthRenderer()
  106219. }
  106220. }
  106221. })], t.prototype, "force32itsFloat", void 0),
  106222. t
  106223. }(Wp);
  106224. y("BABYLON.SceneDepthBlock", zm);
  106225. var Wm = function(e) {
  106226. function t(t) {
  106227. var i = e.call(this, t, Dp.VertexAndFragment, !0) || this;
  106228. return i.registerInput("worldPosition", Op.Vector4, !1),
  106229. i
  106230. }
  106231. return U(t, e),
  106232. t.prototype.getClassName = function() {
  106233. return "ClipPlanesBlock"
  106234. }
  106235. ,
  106236. t.prototype.initialize = function(e) {
  106237. e._excludeVariableName("vClipPlane"),
  106238. e._excludeVariableName("fClipDistance"),
  106239. e._excludeVariableName("vClipPlane2"),
  106240. e._excludeVariableName("fClipDistance2"),
  106241. e._excludeVariableName("vClipPlane3"),
  106242. e._excludeVariableName("fClipDistance3"),
  106243. e._excludeVariableName("vClipPlane4"),
  106244. e._excludeVariableName("fClipDistance4"),
  106245. e._excludeVariableName("vClipPlane5"),
  106246. e._excludeVariableName("fClipDistance5"),
  106247. e._excludeVariableName("vClipPlane6"),
  106248. e._excludeVariableName("fClipDistance6")
  106249. }
  106250. ,
  106251. Object.defineProperty(t.prototype, "worldPosition", {
  106252. get: function() {
  106253. return this._inputs[0]
  106254. },
  106255. enumerable: !1,
  106256. configurable: !0
  106257. }),
  106258. Object.defineProperty(t.prototype, "target", {
  106259. get: function() {
  106260. return Dp.VertexAndFragment
  106261. },
  106262. set: function(e) {},
  106263. enumerable: !1,
  106264. configurable: !0
  106265. }),
  106266. t.prototype.prepareDefines = function(e, t, i) {
  106267. var n = e.getScene()
  106268. , r = void 0 !== n.clipPlane && null !== n.clipPlane
  106269. , o = void 0 !== n.clipPlane2 && null !== n.clipPlane2
  106270. , a = void 0 !== n.clipPlane3 && null !== n.clipPlane3
  106271. , s = void 0 !== n.clipPlane4 && null !== n.clipPlane4
  106272. , l = void 0 !== n.clipPlane5 && null !== n.clipPlane5
  106273. , c = void 0 !== n.clipPlane6 && null !== n.clipPlane6;
  106274. i.setValue("CLIPPLANE", r, !0),
  106275. i.setValue("CLIPPLANE2", o, !0),
  106276. i.setValue("CLIPPLANE3", a, !0),
  106277. i.setValue("CLIPPLANE4", s, !0),
  106278. i.setValue("CLIPPLANE5", l, !0),
  106279. i.setValue("CLIPPLANE6", c, !0)
  106280. }
  106281. ,
  106282. t.prototype.bind = function(e, t, i) {
  106283. if (i) {
  106284. var n = i.getScene();
  106285. Mr.BindClipPlane(e, n)
  106286. }
  106287. }
  106288. ,
  106289. t.prototype._buildBlock = function(t) {
  106290. e.prototype._buildBlock.call(this, t);
  106291. var i = "//".concat(this.name);
  106292. if (t.target !== Dp.Fragment) {
  106293. var n = this.worldPosition;
  106294. return t._emitFunctionFromInclude("clipPlaneVertexDeclaration", i, {
  106295. replaceStrings: [{
  106296. search: /uniform vec4 vClipPlane\d*;/g,
  106297. replace: ""
  106298. }]
  106299. }),
  106300. t.compilationString += t._emitCodeFromInclude("clipPlaneVertex", i, {
  106301. replaceStrings: [{
  106302. search: /worldPos/g,
  106303. replace: n.associatedVariableName
  106304. }]
  106305. }),
  106306. t._emitUniformFromString("vClipPlane", "vec4"),
  106307. t._emitUniformFromString("vClipPlane2", "vec4"),
  106308. t._emitUniformFromString("vClipPlane3", "vec4"),
  106309. t._emitUniformFromString("vClipPlane4", "vec4"),
  106310. t._emitUniformFromString("vClipPlane5", "vec4"),
  106311. void t._emitUniformFromString("vClipPlane6", "vec4")
  106312. }
  106313. return t.sharedData.bindableBlocks.push(this),
  106314. t.sharedData.blocksWithDefines.push(this),
  106315. t._emitFunctionFromInclude("clipPlaneFragmentDeclaration", i),
  106316. t.compilationString += t._emitCodeFromInclude("clipPlaneFragment", i),
  106317. this
  106318. }
  106319. ,
  106320. t
  106321. }(Wp);
  106322. y("BABYLON.ClipPlanesBlock", Wm);
  106323. var Hm = function(e) {
  106324. function t(t) {
  106325. var i = e.call(this, t, Dp.Neutral) || this;
  106326. return i.registerInput("left", Op.AutoDetect),
  106327. i.registerInput("right", Op.AutoDetect),
  106328. i.registerOutput("output", Op.BasedOnInput),
  106329. i._outputs[0]._typeConnectionSource = i._inputs[0],
  106330. i._linkConnectionTypes(0, 1),
  106331. i
  106332. }
  106333. return U(t, e),
  106334. t.prototype.getClassName = function() {
  106335. return "AddBlock"
  106336. }
  106337. ,
  106338. Object.defineProperty(t.prototype, "left", {
  106339. get: function() {
  106340. return this._inputs[0]
  106341. },
  106342. enumerable: !1,
  106343. configurable: !0
  106344. }),
  106345. Object.defineProperty(t.prototype, "right", {
  106346. get: function() {
  106347. return this._inputs[1]
  106348. },
  106349. enumerable: !1,
  106350. configurable: !0
  106351. }),
  106352. Object.defineProperty(t.prototype, "output", {
  106353. get: function() {
  106354. return this._outputs[0]
  106355. },
  106356. enumerable: !1,
  106357. configurable: !0
  106358. }),
  106359. t.prototype._buildBlock = function(t) {
  106360. e.prototype._buildBlock.call(this, t);
  106361. var i = this._outputs[0];
  106362. return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " + ").concat(this.right.associatedVariableName, ";\r\n"),
  106363. this
  106364. }
  106365. ,
  106366. t
  106367. }(Wp);
  106368. y("BABYLON.AddBlock", Hm);
  106369. var Xm = function(e) {
  106370. function t(t) {
  106371. var i = e.call(this, t, Dp.Neutral) || this;
  106372. return i.registerInput("input", Op.AutoDetect),
  106373. i.registerInput("factor", Op.Float),
  106374. i.registerOutput("output", Op.BasedOnInput),
  106375. i._outputs[0]._typeConnectionSource = i._inputs[0],
  106376. i
  106377. }
  106378. return U(t, e),
  106379. t.prototype.getClassName = function() {
  106380. return "ScaleBlock"
  106381. }
  106382. ,
  106383. Object.defineProperty(t.prototype, "input", {
  106384. get: function() {
  106385. return this._inputs[0]
  106386. },
  106387. enumerable: !1,
  106388. configurable: !0
  106389. }),
  106390. Object.defineProperty(t.prototype, "factor", {
  106391. get: function() {
  106392. return this._inputs[1]
  106393. },
  106394. enumerable: !1,
  106395. configurable: !0
  106396. }),
  106397. Object.defineProperty(t.prototype, "output", {
  106398. get: function() {
  106399. return this._outputs[0]
  106400. },
  106401. enumerable: !1,
  106402. configurable: !0
  106403. }),
  106404. t.prototype._buildBlock = function(t) {
  106405. e.prototype._buildBlock.call(this, t);
  106406. var i = this._outputs[0];
  106407. return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " * ").concat(this.factor.associatedVariableName, ";\r\n"),
  106408. this
  106409. }
  106410. ,
  106411. t
  106412. }(Wp);
  106413. y("BABYLON.ScaleBlock", Xm);
  106414. var jm = function(e) {
  106415. function t(t) {
  106416. var i = e.call(this, t, Dp.Neutral) || this;
  106417. return i.minimum = 0,
  106418. i.maximum = 1,
  106419. i.registerInput("value", Op.AutoDetect),
  106420. i.registerOutput("output", Op.BasedOnInput),
  106421. i._outputs[0]._typeConnectionSource = i._inputs[0],
  106422. i
  106423. }
  106424. return U(t, e),
  106425. t.prototype.getClassName = function() {
  106426. return "ClampBlock"
  106427. }
  106428. ,
  106429. Object.defineProperty(t.prototype, "value", {
  106430. get: function() {
  106431. return this._inputs[0]
  106432. },
  106433. enumerable: !1,
  106434. configurable: !0
  106435. }),
  106436. Object.defineProperty(t.prototype, "output", {
  106437. get: function() {
  106438. return this._outputs[0]
  106439. },
  106440. enumerable: !1,
  106441. configurable: !0
  106442. }),
  106443. t.prototype._buildBlock = function(t) {
  106444. e.prototype._buildBlock.call(this, t);
  106445. var i = this._outputs[0];
  106446. return t.compilationString += this._declareOutput(i, t) + " = clamp(".concat(this.value.associatedVariableName, ", ").concat(this._writeFloat(this.minimum), ", ").concat(this._writeFloat(this.maximum), ");\r\n"),
  106447. this
  106448. }
  106449. ,
  106450. t.prototype._dumpPropertiesCode = function() {
  106451. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".minimum = ").concat(this.minimum, ";\r\n") + "".concat(this._codeVariableName, ".maximum = ").concat(this.maximum, ";\r\n")
  106452. }
  106453. ,
  106454. t.prototype.serialize = function() {
  106455. var t = e.prototype.serialize.call(this);
  106456. return t.minimum = this.minimum,
  106457. t.maximum = this.maximum,
  106458. t
  106459. }
  106460. ,
  106461. t.prototype._deserialize = function(t, i, n) {
  106462. e.prototype._deserialize.call(this, t, i, n),
  106463. this.minimum = t.minimum,
  106464. this.maximum = t.maximum
  106465. }
  106466. ,
  106467. k([Yp("Minimum", Xp.Float)], t.prototype, "minimum", void 0),
  106468. k([Yp("Maximum", Xp.Float)], t.prototype, "maximum", void 0),
  106469. t
  106470. }(Wp);
  106471. y("BABYLON.ClampBlock", jm);
  106472. var Ym = function(e) {
  106473. function t(t) {
  106474. var i = e.call(this, t, Dp.Neutral) || this;
  106475. return i.registerInput("left", Op.AutoDetect),
  106476. i.registerInput("right", Op.AutoDetect),
  106477. i.registerOutput("output", Op.Vector3),
  106478. i._linkConnectionTypes(0, 1),
  106479. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  106480. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  106481. i._inputs[0].excludedConnectionPointTypes.push(Op.Vector2),
  106482. i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
  106483. i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
  106484. i._inputs[1].excludedConnectionPointTypes.push(Op.Vector2),
  106485. i
  106486. }
  106487. return U(t, e),
  106488. t.prototype.getClassName = function() {
  106489. return "CrossBlock"
  106490. }
  106491. ,
  106492. Object.defineProperty(t.prototype, "left", {
  106493. get: function() {
  106494. return this._inputs[0]
  106495. },
  106496. enumerable: !1,
  106497. configurable: !0
  106498. }),
  106499. Object.defineProperty(t.prototype, "right", {
  106500. get: function() {
  106501. return this._inputs[1]
  106502. },
  106503. enumerable: !1,
  106504. configurable: !0
  106505. }),
  106506. Object.defineProperty(t.prototype, "output", {
  106507. get: function() {
  106508. return this._outputs[0]
  106509. },
  106510. enumerable: !1,
  106511. configurable: !0
  106512. }),
  106513. t.prototype._buildBlock = function(t) {
  106514. e.prototype._buildBlock.call(this, t);
  106515. var i = this._outputs[0];
  106516. return t.compilationString += this._declareOutput(i, t) + " = cross(".concat(this.left.associatedVariableName, ".xyz, ").concat(this.right.associatedVariableName, ".xyz);\r\n"),
  106517. this
  106518. }
  106519. ,
  106520. t
  106521. }(Wp);
  106522. y("BABYLON.CrossBlock", Ym);
  106523. var Km = function(e) {
  106524. function t(t) {
  106525. return e.call(this, t) || this
  106526. }
  106527. return U(t, e),
  106528. Object.defineProperty(t.prototype, "options", {
  106529. get: function() {
  106530. return this._options
  106531. },
  106532. set: function(e) {
  106533. this._deserializeOptions(e)
  106534. },
  106535. enumerable: !1,
  106536. configurable: !0
  106537. }),
  106538. t.prototype.getClassName = function() {
  106539. return "CustomBlock"
  106540. }
  106541. ,
  106542. t.prototype._buildBlock = function(t) {
  106543. var i = this;
  106544. e.prototype._buildBlock.call(this, t);
  106545. var n = this._code
  106546. , r = this._options.functionName;
  106547. this._inputs.forEach((function(e) {
  106548. var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
  106549. , o = t._getGLType(e.type);
  106550. n = n.replace(i, o),
  106551. r = r.replace(i, o)
  106552. }
  106553. )),
  106554. this._outputs.forEach((function(e) {
  106555. var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
  106556. , o = t._getGLType(e.type);
  106557. n = n.replace(i, o),
  106558. r = r.replace(i, o)
  106559. }
  106560. )),
  106561. t._emitFunction(r, n, ""),
  106562. this._outputs.forEach((function(e) {
  106563. t.compilationString += i._declareOutput(e, t) + ";\r\n"
  106564. }
  106565. )),
  106566. t.compilationString += r + "(";
  106567. var o = !1;
  106568. return this._inputs.forEach((function(e, i) {
  106569. i > 0 && (t.compilationString += ", "),
  106570. t.compilationString += e.associatedVariableName,
  106571. o = !0
  106572. }
  106573. )),
  106574. this._outputs.forEach((function(e, i) {
  106575. (i > 0 || o) && (t.compilationString += ", "),
  106576. t.compilationString += e.associatedVariableName
  106577. }
  106578. )),
  106579. t.compilationString += ");\r\n",
  106580. this
  106581. }
  106582. ,
  106583. t.prototype._dumpPropertiesCode = function() {
  106584. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".options = ").concat(JSON.stringify(this._options), ";\r\n")
  106585. }
  106586. ,
  106587. t.prototype.serialize = function() {
  106588. var t = e.prototype.serialize.call(this);
  106589. return t.options = this._options,
  106590. t
  106591. }
  106592. ,
  106593. t.prototype._deserialize = function(t, i, n) {
  106594. this._deserializeOptions(t.options),
  106595. e.prototype._deserialize.call(this, t, i, n)
  106596. }
  106597. ,
  106598. t.prototype._deserializeOptions = function(e) {
  106599. var t, i, n, r = this;
  106600. this._options = e,
  106601. this._code = e.code.join("\r\n") + "\r\n",
  106602. this.name = this.name || e.name,
  106603. this.target = Dp[e.target],
  106604. null === (t = e.inParameters) || void 0 === t || t.forEach((function(e, t) {
  106605. var i = Op[e.type];
  106606. r.registerInput(e.name, i),
  106607. Object.defineProperty(r, e.name, {
  106608. get: function() {
  106609. return this._inputs[t]
  106610. },
  106611. enumerable: !0,
  106612. configurable: !0
  106613. })
  106614. }
  106615. )),
  106616. null === (i = e.outParameters) || void 0 === i || i.forEach((function(e, t) {
  106617. r.registerOutput(e.name, Op[e.type]),
  106618. Object.defineProperty(r, e.name, {
  106619. get: function() {
  106620. return this._outputs[t]
  106621. },
  106622. enumerable: !0,
  106623. configurable: !0
  106624. }),
  106625. "BasedOnInput" === e.type && (r._outputs[t]._typeConnectionSource = r._findInputByName(e.typeFromInput)[0])
  106626. }
  106627. )),
  106628. null === (n = e.inLinkedConnectionTypes) || void 0 === n || n.forEach((function(e) {
  106629. r._linkConnectionTypes(r._findInputByName(e.input1)[1], r._findInputByName(e.input2)[1])
  106630. }
  106631. ))
  106632. }
  106633. ,
  106634. t.prototype._findInputByName = function(e) {
  106635. if (!e)
  106636. return null;
  106637. for (var t = 0; t < this._inputs.length; t++)
  106638. if (this._inputs[t].name === e)
  106639. return [this._inputs[t], t];
  106640. return null
  106641. }
  106642. ,
  106643. t
  106644. }(Wp);
  106645. y("BABYLON.CustomBlock", Km);
  106646. var Qm = function(e) {
  106647. function t(t) {
  106648. var i = e.call(this, t, Dp.Neutral) || this;
  106649. return i.registerInput("left", Op.AutoDetect),
  106650. i.registerInput("right", Op.AutoDetect),
  106651. i.registerOutput("output", Op.Float),
  106652. i._linkConnectionTypes(0, 1),
  106653. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  106654. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  106655. i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
  106656. i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
  106657. i
  106658. }
  106659. return U(t, e),
  106660. t.prototype.getClassName = function() {
  106661. return "DotBlock"
  106662. }
  106663. ,
  106664. Object.defineProperty(t.prototype, "left", {
  106665. get: function() {
  106666. return this._inputs[0]
  106667. },
  106668. enumerable: !1,
  106669. configurable: !0
  106670. }),
  106671. Object.defineProperty(t.prototype, "right", {
  106672. get: function() {
  106673. return this._inputs[1]
  106674. },
  106675. enumerable: !1,
  106676. configurable: !0
  106677. }),
  106678. Object.defineProperty(t.prototype, "output", {
  106679. get: function() {
  106680. return this._outputs[0]
  106681. },
  106682. enumerable: !1,
  106683. configurable: !0
  106684. }),
  106685. t.prototype._buildBlock = function(t) {
  106686. e.prototype._buildBlock.call(this, t);
  106687. var i = this._outputs[0];
  106688. return t.compilationString += this._declareOutput(i, t) + " = dot(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
  106689. this
  106690. }
  106691. ,
  106692. t
  106693. }(Wp);
  106694. y("BABYLON.DotBlock", Qm);
  106695. var qm = function(e) {
  106696. function t(t) {
  106697. var i = e.call(this, t, Dp.Neutral) || this;
  106698. return i.registerInput("input", Op.AutoDetect),
  106699. i.registerOutput("output", Op.BasedOnInput),
  106700. i._outputs[0]._typeConnectionSource = i._inputs[0],
  106701. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  106702. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  106703. i
  106704. }
  106705. return U(t, e),
  106706. t.prototype.getClassName = function() {
  106707. return "NormalizeBlock"
  106708. }
  106709. ,
  106710. Object.defineProperty(t.prototype, "input", {
  106711. get: function() {
  106712. return this._inputs[0]
  106713. },
  106714. enumerable: !1,
  106715. configurable: !0
  106716. }),
  106717. Object.defineProperty(t.prototype, "output", {
  106718. get: function() {
  106719. return this._outputs[0]
  106720. },
  106721. enumerable: !1,
  106722. configurable: !0
  106723. }),
  106724. t.prototype._buildBlock = function(t) {
  106725. e.prototype._buildBlock.call(this, t);
  106726. var i = this._outputs[0]
  106727. , n = this._inputs[0];
  106728. return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(n.associatedVariableName, ");\r\n"),
  106729. this
  106730. }
  106731. ,
  106732. t
  106733. }(Wp);
  106734. y("BABYLON.NormalizeBlock", qm);
  106735. var Zm = function(e) {
  106736. function t(t) {
  106737. var i = e.call(this, t, Dp.Neutral) || this;
  106738. return i.rSwizzle = "r",
  106739. i.gSwizzle = "g",
  106740. i.bSwizzle = "b",
  106741. i.aSwizzle = "a",
  106742. i.registerInput("rgb ", Op.Color3, !0),
  106743. i.registerInput("r", Op.Float, !0),
  106744. i.registerInput("g", Op.Float, !0),
  106745. i.registerInput("b", Op.Float, !0),
  106746. i.registerInput("a", Op.Float, !0),
  106747. i.registerOutput("rgba", Op.Color4),
  106748. i.registerOutput("rgb", Op.Color3),
  106749. i
  106750. }
  106751. return U(t, e),
  106752. t.prototype.getClassName = function() {
  106753. return "ColorMergerBlock"
  106754. }
  106755. ,
  106756. Object.defineProperty(t.prototype, "rgbIn", {
  106757. get: function() {
  106758. return this._inputs[0]
  106759. },
  106760. enumerable: !1,
  106761. configurable: !0
  106762. }),
  106763. Object.defineProperty(t.prototype, "r", {
  106764. get: function() {
  106765. return this._inputs[1]
  106766. },
  106767. enumerable: !1,
  106768. configurable: !0
  106769. }),
  106770. Object.defineProperty(t.prototype, "g", {
  106771. get: function() {
  106772. return this._inputs[2]
  106773. },
  106774. enumerable: !1,
  106775. configurable: !0
  106776. }),
  106777. Object.defineProperty(t.prototype, "b", {
  106778. get: function() {
  106779. return this._inputs[3]
  106780. },
  106781. enumerable: !1,
  106782. configurable: !0
  106783. }),
  106784. Object.defineProperty(t.prototype, "a", {
  106785. get: function() {
  106786. return this._inputs[4]
  106787. },
  106788. enumerable: !1,
  106789. configurable: !0
  106790. }),
  106791. Object.defineProperty(t.prototype, "rgba", {
  106792. get: function() {
  106793. return this._outputs[0]
  106794. },
  106795. enumerable: !1,
  106796. configurable: !0
  106797. }),
  106798. Object.defineProperty(t.prototype, "rgbOut", {
  106799. get: function() {
  106800. return this._outputs[1]
  106801. },
  106802. enumerable: !1,
  106803. configurable: !0
  106804. }),
  106805. Object.defineProperty(t.prototype, "rgb", {
  106806. get: function() {
  106807. return this.rgbOut
  106808. },
  106809. enumerable: !1,
  106810. configurable: !0
  106811. }),
  106812. t.prototype._inputRename = function(e) {
  106813. return "rgb " === e ? "rgbIn" : e
  106814. }
  106815. ,
  106816. t.prototype._buildSwizzle = function(e) {
  106817. return "." + (this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle).substr(0, e)
  106818. }
  106819. ,
  106820. t.prototype._buildBlock = function(t) {
  106821. e.prototype._buildBlock.call(this, t);
  106822. var i = this.r
  106823. , n = this.g
  106824. , r = this.b
  106825. , o = this.a
  106826. , a = this.rgbIn
  106827. , s = this._outputs[0]
  106828. , l = this._outputs[1];
  106829. return a.isConnected ? (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
  106830. l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n"))) : (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
  106831. l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n"))),
  106832. this
  106833. }
  106834. ,
  106835. t.prototype.serialize = function() {
  106836. var t = e.prototype.serialize.call(this);
  106837. return t.rSwizzle = this.rSwizzle,
  106838. t.gSwizzle = this.gSwizzle,
  106839. t.bSwizzle = this.bSwizzle,
  106840. t.aSwizzle = this.aSwizzle,
  106841. t
  106842. }
  106843. ,
  106844. t.prototype._deserialize = function(t, i, n) {
  106845. var r, o, a, s;
  106846. e.prototype._deserialize.call(this, t, i, n),
  106847. this.rSwizzle = null !== (r = t.rSwizzle) && void 0 !== r ? r : "r",
  106848. this.gSwizzle = null !== (o = t.gSwizzle) && void 0 !== o ? o : "g",
  106849. this.bSwizzle = null !== (a = t.bSwizzle) && void 0 !== a ? a : "b",
  106850. this.aSwizzle = null !== (s = t.aSwizzle) && void 0 !== s ? s : "a"
  106851. }
  106852. ,
  106853. t.prototype._dumpPropertiesCode = function() {
  106854. var t = e.prototype._dumpPropertiesCode.call(this);
  106855. return t += "".concat(this._codeVariableName, ".rSwizzle = ").concat(this.rSwizzle, "};\r\n"),
  106856. t += "".concat(this._codeVariableName, ".gSwizzle = ").concat(this.gSwizzle, "};\r\n"),
  106857. (t += "".concat(this._codeVariableName, ".bSwizzle = ").concat(this.bSwizzle, "};\r\n")) + "".concat(this._codeVariableName, ".aSwizzle = ").concat(this.aSwizzle, "};\r\n")
  106858. }
  106859. ,
  106860. t
  106861. }(Wp);
  106862. y("BABYLON.ColorMergerBlock", Zm);
  106863. var Jm = function(e) {
  106864. function t(t) {
  106865. var i = e.call(this, t, Dp.Neutral) || this;
  106866. return i.registerInput("xyzw", Op.Vector4, !0),
  106867. i.registerInput("xyz ", Op.Vector3, !0),
  106868. i.registerInput("xy ", Op.Vector2, !0),
  106869. i.registerOutput("xyz", Op.Vector3),
  106870. i.registerOutput("xy", Op.Vector2),
  106871. i.registerOutput("zw", Op.Vector2),
  106872. i.registerOutput("x", Op.Float),
  106873. i.registerOutput("y", Op.Float),
  106874. i.registerOutput("z", Op.Float),
  106875. i.registerOutput("w", Op.Float),
  106876. i.inputsAreExclusive = !0,
  106877. i
  106878. }
  106879. return U(t, e),
  106880. t.prototype.getClassName = function() {
  106881. return "VectorSplitterBlock"
  106882. }
  106883. ,
  106884. Object.defineProperty(t.prototype, "xyzw", {
  106885. get: function() {
  106886. return this._inputs[0]
  106887. },
  106888. enumerable: !1,
  106889. configurable: !0
  106890. }),
  106891. Object.defineProperty(t.prototype, "xyzIn", {
  106892. get: function() {
  106893. return this._inputs[1]
  106894. },
  106895. enumerable: !1,
  106896. configurable: !0
  106897. }),
  106898. Object.defineProperty(t.prototype, "xyIn", {
  106899. get: function() {
  106900. return this._inputs[2]
  106901. },
  106902. enumerable: !1,
  106903. configurable: !0
  106904. }),
  106905. Object.defineProperty(t.prototype, "xyzOut", {
  106906. get: function() {
  106907. return this._outputs[0]
  106908. },
  106909. enumerable: !1,
  106910. configurable: !0
  106911. }),
  106912. Object.defineProperty(t.prototype, "xyOut", {
  106913. get: function() {
  106914. return this._outputs[1]
  106915. },
  106916. enumerable: !1,
  106917. configurable: !0
  106918. }),
  106919. Object.defineProperty(t.prototype, "zw", {
  106920. get: function() {
  106921. return this._outputs[2]
  106922. },
  106923. enumerable: !1,
  106924. configurable: !0
  106925. }),
  106926. Object.defineProperty(t.prototype, "x", {
  106927. get: function() {
  106928. return this._outputs[3]
  106929. },
  106930. enumerable: !1,
  106931. configurable: !0
  106932. }),
  106933. Object.defineProperty(t.prototype, "y", {
  106934. get: function() {
  106935. return this._outputs[4]
  106936. },
  106937. enumerable: !1,
  106938. configurable: !0
  106939. }),
  106940. Object.defineProperty(t.prototype, "z", {
  106941. get: function() {
  106942. return this._outputs[5]
  106943. },
  106944. enumerable: !1,
  106945. configurable: !0
  106946. }),
  106947. Object.defineProperty(t.prototype, "w", {
  106948. get: function() {
  106949. return this._outputs[6]
  106950. },
  106951. enumerable: !1,
  106952. configurable: !0
  106953. }),
  106954. t.prototype._inputRename = function(e) {
  106955. switch (e) {
  106956. case "xy ":
  106957. return "xyIn";
  106958. case "xyz ":
  106959. return "xyzIn";
  106960. default:
  106961. return e
  106962. }
  106963. }
  106964. ,
  106965. t.prototype._outputRename = function(e) {
  106966. switch (e) {
  106967. case "xy":
  106968. return "xyOut";
  106969. case "xyz":
  106970. return "xyzOut";
  106971. default:
  106972. return e
  106973. }
  106974. }
  106975. ,
  106976. t.prototype._buildBlock = function(t) {
  106977. e.prototype._buildBlock.call(this, t);
  106978. var i = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn
  106979. , n = this._outputs[0]
  106980. , r = this._outputs[1]
  106981. , o = this._outputs[2]
  106982. , a = this._outputs[3]
  106983. , s = this._outputs[4]
  106984. , l = this._outputs[5]
  106985. , c = this._outputs[6];
  106986. return n.hasEndpoints && (i === this.xyIn ? t.compilationString += this._declareOutput(n, t) + " = vec3(".concat(i.associatedVariableName, ", 0.0);\r\n") : t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".xyz;\r\n")),
  106987. o.hasEndpoints && this.xyzw.isConnected && (t.compilationString += this._declareOutput(o, t) + " = ".concat(this.xyzw.associatedVariableName, ".zw;\r\n")),
  106988. r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".xy;\r\n")),
  106989. a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".x;\r\n")),
  106990. s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".y;\r\n")),
  106991. l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(i.associatedVariableName, ".z;\r\n")),
  106992. c.hasEndpoints && (t.compilationString += this._declareOutput(c, t) + " = ".concat(i.associatedVariableName, ".w;\r\n")),
  106993. this
  106994. }
  106995. ,
  106996. t
  106997. }(Wp);
  106998. y("BABYLON.VectorSplitterBlock", Jm);
  106999. var $m = function(e) {
  107000. function t(t) {
  107001. var i = e.call(this, t, Dp.Neutral) || this;
  107002. return i.registerInput("left", Op.AutoDetect),
  107003. i.registerInput("right", Op.AutoDetect),
  107004. i.registerInput("gradient", Op.AutoDetect),
  107005. i.registerOutput("output", Op.BasedOnInput),
  107006. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107007. i._linkConnectionTypes(0, 1),
  107008. i._linkConnectionTypes(1, 2, !0),
  107009. i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
  107010. i
  107011. }
  107012. return U(t, e),
  107013. t.prototype.getClassName = function() {
  107014. return "LerpBlock"
  107015. }
  107016. ,
  107017. Object.defineProperty(t.prototype, "left", {
  107018. get: function() {
  107019. return this._inputs[0]
  107020. },
  107021. enumerable: !1,
  107022. configurable: !0
  107023. }),
  107024. Object.defineProperty(t.prototype, "right", {
  107025. get: function() {
  107026. return this._inputs[1]
  107027. },
  107028. enumerable: !1,
  107029. configurable: !0
  107030. }),
  107031. Object.defineProperty(t.prototype, "gradient", {
  107032. get: function() {
  107033. return this._inputs[2]
  107034. },
  107035. enumerable: !1,
  107036. configurable: !0
  107037. }),
  107038. Object.defineProperty(t.prototype, "output", {
  107039. get: function() {
  107040. return this._outputs[0]
  107041. },
  107042. enumerable: !1,
  107043. configurable: !0
  107044. }),
  107045. t.prototype._buildBlock = function(t) {
  107046. e.prototype._buildBlock.call(this, t);
  107047. var i = this._outputs[0];
  107048. return t.compilationString += this._declareOutput(i, t) + " = mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, ");\r\n"),
  107049. this
  107050. }
  107051. ,
  107052. t
  107053. }(Wp);
  107054. y("BABYLON.LerpBlock", $m);
  107055. var eg = function(e) {
  107056. function t(t) {
  107057. var i = e.call(this, t, Dp.Neutral) || this;
  107058. return i.registerInput("left", Op.AutoDetect),
  107059. i.registerInput("right", Op.AutoDetect),
  107060. i.registerOutput("output", Op.BasedOnInput),
  107061. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107062. i._linkConnectionTypes(0, 1),
  107063. i
  107064. }
  107065. return U(t, e),
  107066. t.prototype.getClassName = function() {
  107067. return "DivideBlock"
  107068. }
  107069. ,
  107070. Object.defineProperty(t.prototype, "left", {
  107071. get: function() {
  107072. return this._inputs[0]
  107073. },
  107074. enumerable: !1,
  107075. configurable: !0
  107076. }),
  107077. Object.defineProperty(t.prototype, "right", {
  107078. get: function() {
  107079. return this._inputs[1]
  107080. },
  107081. enumerable: !1,
  107082. configurable: !0
  107083. }),
  107084. Object.defineProperty(t.prototype, "output", {
  107085. get: function() {
  107086. return this._outputs[0]
  107087. },
  107088. enumerable: !1,
  107089. configurable: !0
  107090. }),
  107091. t.prototype._buildBlock = function(t) {
  107092. e.prototype._buildBlock.call(this, t);
  107093. var i = this._outputs[0];
  107094. return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " / ").concat(this.right.associatedVariableName, ";\r\n"),
  107095. this
  107096. }
  107097. ,
  107098. t
  107099. }(Wp);
  107100. y("BABYLON.DivideBlock", eg);
  107101. var tg = function(e) {
  107102. function t(t) {
  107103. var i = e.call(this, t, Dp.Neutral) || this;
  107104. return i.registerInput("left", Op.AutoDetect),
  107105. i.registerInput("right", Op.AutoDetect),
  107106. i.registerOutput("output", Op.BasedOnInput),
  107107. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107108. i._linkConnectionTypes(0, 1),
  107109. i
  107110. }
  107111. return U(t, e),
  107112. t.prototype.getClassName = function() {
  107113. return "SubtractBlock"
  107114. }
  107115. ,
  107116. Object.defineProperty(t.prototype, "left", {
  107117. get: function() {
  107118. return this._inputs[0]
  107119. },
  107120. enumerable: !1,
  107121. configurable: !0
  107122. }),
  107123. Object.defineProperty(t.prototype, "right", {
  107124. get: function() {
  107125. return this._inputs[1]
  107126. },
  107127. enumerable: !1,
  107128. configurable: !0
  107129. }),
  107130. Object.defineProperty(t.prototype, "output", {
  107131. get: function() {
  107132. return this._outputs[0]
  107133. },
  107134. enumerable: !1,
  107135. configurable: !0
  107136. }),
  107137. t.prototype._buildBlock = function(t) {
  107138. e.prototype._buildBlock.call(this, t);
  107139. var i = this._outputs[0];
  107140. return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, ";\r\n"),
  107141. this
  107142. }
  107143. ,
  107144. t
  107145. }(Wp);
  107146. y("BABYLON.SubtractBlock", tg);
  107147. var ig = function(e) {
  107148. function t(t) {
  107149. var i = e.call(this, t, Dp.Neutral) || this;
  107150. return i.registerInput("value", Op.Float),
  107151. i.registerInput("edge", Op.Float),
  107152. i.registerOutput("output", Op.Float),
  107153. i
  107154. }
  107155. return U(t, e),
  107156. t.prototype.getClassName = function() {
  107157. return "StepBlock"
  107158. }
  107159. ,
  107160. Object.defineProperty(t.prototype, "value", {
  107161. get: function() {
  107162. return this._inputs[0]
  107163. },
  107164. enumerable: !1,
  107165. configurable: !0
  107166. }),
  107167. Object.defineProperty(t.prototype, "edge", {
  107168. get: function() {
  107169. return this._inputs[1]
  107170. },
  107171. enumerable: !1,
  107172. configurable: !0
  107173. }),
  107174. Object.defineProperty(t.prototype, "output", {
  107175. get: function() {
  107176. return this._outputs[0]
  107177. },
  107178. enumerable: !1,
  107179. configurable: !0
  107180. }),
  107181. t.prototype._buildBlock = function(t) {
  107182. e.prototype._buildBlock.call(this, t);
  107183. var i = this._outputs[0];
  107184. return t.compilationString += this._declareOutput(i, t) + " = step(".concat(this.edge.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\r\n"),
  107185. this
  107186. }
  107187. ,
  107188. t
  107189. }(Wp);
  107190. y("BABYLON.StepBlock", ig);
  107191. var ng = function(e) {
  107192. function t(t) {
  107193. var i = e.call(this, t, Dp.Neutral) || this;
  107194. return i.registerInput("input", Op.AutoDetect),
  107195. i.registerOutput("output", Op.BasedOnInput),
  107196. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107197. i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107198. i
  107199. }
  107200. return U(t, e),
  107201. t.prototype.getClassName = function() {
  107202. return "OneMinusBlock"
  107203. }
  107204. ,
  107205. Object.defineProperty(t.prototype, "input", {
  107206. get: function() {
  107207. return this._inputs[0]
  107208. },
  107209. enumerable: !1,
  107210. configurable: !0
  107211. }),
  107212. Object.defineProperty(t.prototype, "output", {
  107213. get: function() {
  107214. return this._outputs[0]
  107215. },
  107216. enumerable: !1,
  107217. configurable: !0
  107218. }),
  107219. t.prototype._buildBlock = function(t) {
  107220. e.prototype._buildBlock.call(this, t);
  107221. var i = this._outputs[0];
  107222. return t.compilationString += this._declareOutput(i, t) + " = 1. - ".concat(this.input.associatedVariableName, ";\r\n"),
  107223. this
  107224. }
  107225. ,
  107226. t
  107227. }(Wp);
  107228. y("BABYLON.OneMinusBlock", ng),
  107229. y("BABYLON.OppositeBlock", ng);
  107230. var rg = function(e) {
  107231. function t(t) {
  107232. var i = e.call(this, t, Dp.Neutral) || this;
  107233. return i.registerInput("worldPosition", Op.Vector4),
  107234. i.registerInput("cameraPosition", Op.Vector3),
  107235. i.registerOutput("output", Op.Vector3),
  107236. i
  107237. }
  107238. return U(t, e),
  107239. t.prototype.getClassName = function() {
  107240. return "ViewDirectionBlock"
  107241. }
  107242. ,
  107243. Object.defineProperty(t.prototype, "worldPosition", {
  107244. get: function() {
  107245. return this._inputs[0]
  107246. },
  107247. enumerable: !1,
  107248. configurable: !0
  107249. }),
  107250. Object.defineProperty(t.prototype, "cameraPosition", {
  107251. get: function() {
  107252. return this._inputs[1]
  107253. },
  107254. enumerable: !1,
  107255. configurable: !0
  107256. }),
  107257. Object.defineProperty(t.prototype, "output", {
  107258. get: function() {
  107259. return this._outputs[0]
  107260. },
  107261. enumerable: !1,
  107262. configurable: !0
  107263. }),
  107264. t.prototype.autoConfigure = function(e) {
  107265. if (!this.cameraPosition.isConnected) {
  107266. var t = e.getInputBlockByPredicate((function(e) {
  107267. return e.systemValue === Qp.CameraPosition
  107268. }
  107269. ));
  107270. t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
  107271. t.output.connectTo(this.cameraPosition)
  107272. }
  107273. }
  107274. ,
  107275. t.prototype._buildBlock = function(t) {
  107276. e.prototype._buildBlock.call(this, t);
  107277. var i = this._outputs[0];
  107278. return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(this.worldPosition.associatedVariableName, ".xyz);\r\n"),
  107279. this
  107280. }
  107281. ,
  107282. t
  107283. }(Wp);
  107284. y("BABYLON.ViewDirectionBlock", rg);
  107285. var og = function(e) {
  107286. function t(t) {
  107287. var i = e.call(this, t, Dp.Neutral) || this;
  107288. return i.registerInput("worldNormal", Op.Vector4),
  107289. i.registerInput("viewDirection", Op.Vector3),
  107290. i.registerInput("bias", Op.Float),
  107291. i.registerInput("power", Op.Float),
  107292. i.registerOutput("fresnel", Op.Float),
  107293. i
  107294. }
  107295. return U(t, e),
  107296. t.prototype.getClassName = function() {
  107297. return "FresnelBlock"
  107298. }
  107299. ,
  107300. Object.defineProperty(t.prototype, "worldNormal", {
  107301. get: function() {
  107302. return this._inputs[0]
  107303. },
  107304. enumerable: !1,
  107305. configurable: !0
  107306. }),
  107307. Object.defineProperty(t.prototype, "viewDirection", {
  107308. get: function() {
  107309. return this._inputs[1]
  107310. },
  107311. enumerable: !1,
  107312. configurable: !0
  107313. }),
  107314. Object.defineProperty(t.prototype, "bias", {
  107315. get: function() {
  107316. return this._inputs[2]
  107317. },
  107318. enumerable: !1,
  107319. configurable: !0
  107320. }),
  107321. Object.defineProperty(t.prototype, "power", {
  107322. get: function() {
  107323. return this._inputs[3]
  107324. },
  107325. enumerable: !1,
  107326. configurable: !0
  107327. }),
  107328. Object.defineProperty(t.prototype, "fresnel", {
  107329. get: function() {
  107330. return this._outputs[0]
  107331. },
  107332. enumerable: !1,
  107333. configurable: !0
  107334. }),
  107335. t.prototype.autoConfigure = function(e) {
  107336. if (!this.viewDirection.isConnected) {
  107337. var t = new rg("View direction");
  107338. t.output.connectTo(this.viewDirection),
  107339. t.autoConfigure(e)
  107340. }
  107341. if (!this.bias.isConnected) {
  107342. var i = new tf("bias");
  107343. i.value = 0,
  107344. i.output.connectTo(this.bias)
  107345. }
  107346. if (!this.power.isConnected) {
  107347. var n = new tf("power");
  107348. n.value = 1,
  107349. n.output.connectTo(this.power)
  107350. }
  107351. }
  107352. ,
  107353. t.prototype._buildBlock = function(t) {
  107354. e.prototype._buildBlock.call(this, t);
  107355. var i = "//".concat(this.name);
  107356. return t._emitFunctionFromInclude("fresnelFunction", i, {
  107357. removeIfDef: !0
  107358. }),
  107359. t.compilationString += this._declareOutput(this.fresnel, t) + " = computeFresnelTerm(".concat(this.viewDirection.associatedVariableName, ".xyz, ").concat(this.worldNormal.associatedVariableName, ".xyz, ").concat(this.bias.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\r\n"),
  107360. this
  107361. }
  107362. ,
  107363. t
  107364. }(Wp);
  107365. y("BABYLON.FresnelBlock", og);
  107366. var ag = function(e) {
  107367. function t(t) {
  107368. var i = e.call(this, t, Dp.Neutral) || this;
  107369. return i.registerInput("left", Op.AutoDetect),
  107370. i.registerInput("right", Op.AutoDetect),
  107371. i.registerOutput("output", Op.BasedOnInput),
  107372. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107373. i._linkConnectionTypes(0, 1),
  107374. i
  107375. }
  107376. return U(t, e),
  107377. t.prototype.getClassName = function() {
  107378. return "MaxBlock"
  107379. }
  107380. ,
  107381. Object.defineProperty(t.prototype, "left", {
  107382. get: function() {
  107383. return this._inputs[0]
  107384. },
  107385. enumerable: !1,
  107386. configurable: !0
  107387. }),
  107388. Object.defineProperty(t.prototype, "right", {
  107389. get: function() {
  107390. return this._inputs[1]
  107391. },
  107392. enumerable: !1,
  107393. configurable: !0
  107394. }),
  107395. Object.defineProperty(t.prototype, "output", {
  107396. get: function() {
  107397. return this._outputs[0]
  107398. },
  107399. enumerable: !1,
  107400. configurable: !0
  107401. }),
  107402. t.prototype._buildBlock = function(t) {
  107403. e.prototype._buildBlock.call(this, t);
  107404. var i = this._outputs[0];
  107405. return t.compilationString += this._declareOutput(i, t) + " = max(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
  107406. this
  107407. }
  107408. ,
  107409. t
  107410. }(Wp);
  107411. y("BABYLON.MaxBlock", ag);
  107412. var sg = function(e) {
  107413. function t(t) {
  107414. var i = e.call(this, t, Dp.Neutral) || this;
  107415. return i.registerInput("left", Op.AutoDetect),
  107416. i.registerInput("right", Op.AutoDetect),
  107417. i.registerOutput("output", Op.BasedOnInput),
  107418. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107419. i._linkConnectionTypes(0, 1),
  107420. i
  107421. }
  107422. return U(t, e),
  107423. t.prototype.getClassName = function() {
  107424. return "MinBlock"
  107425. }
  107426. ,
  107427. Object.defineProperty(t.prototype, "left", {
  107428. get: function() {
  107429. return this._inputs[0]
  107430. },
  107431. enumerable: !1,
  107432. configurable: !0
  107433. }),
  107434. Object.defineProperty(t.prototype, "right", {
  107435. get: function() {
  107436. return this._inputs[1]
  107437. },
  107438. enumerable: !1,
  107439. configurable: !0
  107440. }),
  107441. Object.defineProperty(t.prototype, "output", {
  107442. get: function() {
  107443. return this._outputs[0]
  107444. },
  107445. enumerable: !1,
  107446. configurable: !0
  107447. }),
  107448. t.prototype._buildBlock = function(t) {
  107449. e.prototype._buildBlock.call(this, t);
  107450. var i = this._outputs[0];
  107451. return t.compilationString += this._declareOutput(i, t) + " = min(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
  107452. this
  107453. }
  107454. ,
  107455. t
  107456. }(Wp);
  107457. y("BABYLON.MinBlock", sg);
  107458. var lg = function(e) {
  107459. function t(t) {
  107460. var i = e.call(this, t, Dp.Neutral) || this;
  107461. return i.registerInput("left", Op.AutoDetect),
  107462. i.registerInput("right", Op.AutoDetect),
  107463. i.registerOutput("output", Op.Float),
  107464. i._linkConnectionTypes(0, 1),
  107465. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  107466. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107467. i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
  107468. i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
  107469. i
  107470. }
  107471. return U(t, e),
  107472. t.prototype.getClassName = function() {
  107473. return "DistanceBlock"
  107474. }
  107475. ,
  107476. Object.defineProperty(t.prototype, "left", {
  107477. get: function() {
  107478. return this._inputs[0]
  107479. },
  107480. enumerable: !1,
  107481. configurable: !0
  107482. }),
  107483. Object.defineProperty(t.prototype, "right", {
  107484. get: function() {
  107485. return this._inputs[1]
  107486. },
  107487. enumerable: !1,
  107488. configurable: !0
  107489. }),
  107490. Object.defineProperty(t.prototype, "output", {
  107491. get: function() {
  107492. return this._outputs[0]
  107493. },
  107494. enumerable: !1,
  107495. configurable: !0
  107496. }),
  107497. t.prototype._buildBlock = function(t) {
  107498. e.prototype._buildBlock.call(this, t);
  107499. var i = this._outputs[0];
  107500. return t.compilationString += this._declareOutput(i, t) + " = length(".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, ");\r\n"),
  107501. this
  107502. }
  107503. ,
  107504. t
  107505. }(Wp);
  107506. y("BABYLON.DistanceBlock", lg);
  107507. var cg = function(e) {
  107508. function t(t) {
  107509. var i = e.call(this, t, Dp.Neutral) || this;
  107510. return i.registerInput("value", Op.AutoDetect),
  107511. i.registerOutput("output", Op.Float),
  107512. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  107513. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107514. i
  107515. }
  107516. return U(t, e),
  107517. t.prototype.getClassName = function() {
  107518. return "LengthBlock"
  107519. }
  107520. ,
  107521. Object.defineProperty(t.prototype, "value", {
  107522. get: function() {
  107523. return this._inputs[0]
  107524. },
  107525. enumerable: !1,
  107526. configurable: !0
  107527. }),
  107528. Object.defineProperty(t.prototype, "output", {
  107529. get: function() {
  107530. return this._outputs[0]
  107531. },
  107532. enumerable: !1,
  107533. configurable: !0
  107534. }),
  107535. t.prototype._buildBlock = function(t) {
  107536. e.prototype._buildBlock.call(this, t);
  107537. var i = this._outputs[0];
  107538. return t.compilationString += this._declareOutput(i, t) + " = length(".concat(this.value.associatedVariableName, ");\r\n"),
  107539. this
  107540. }
  107541. ,
  107542. t
  107543. }(Wp);
  107544. y("BABYLON.LengthBlock", cg);
  107545. var ug = function(e) {
  107546. function t(t) {
  107547. var i = e.call(this, t, Dp.Neutral) || this;
  107548. return i.registerInput("value", Op.AutoDetect),
  107549. i.registerOutput("output", Op.BasedOnInput),
  107550. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107551. i
  107552. }
  107553. return U(t, e),
  107554. t.prototype.getClassName = function() {
  107555. return "NegateBlock"
  107556. }
  107557. ,
  107558. Object.defineProperty(t.prototype, "value", {
  107559. get: function() {
  107560. return this._inputs[0]
  107561. },
  107562. enumerable: !1,
  107563. configurable: !0
  107564. }),
  107565. Object.defineProperty(t.prototype, "output", {
  107566. get: function() {
  107567. return this._outputs[0]
  107568. },
  107569. enumerable: !1,
  107570. configurable: !0
  107571. }),
  107572. t.prototype._buildBlock = function(t) {
  107573. e.prototype._buildBlock.call(this, t);
  107574. var i = this._outputs[0];
  107575. return t.compilationString += this._declareOutput(i, t) + " = -1.0 * ".concat(this.value.associatedVariableName, ";\r\n"),
  107576. this
  107577. }
  107578. ,
  107579. t
  107580. }(Wp);
  107581. y("BABYLON.NegateBlock", ug);
  107582. var hg = function(e) {
  107583. function t(t) {
  107584. var i = e.call(this, t, Dp.Neutral) || this;
  107585. return i.registerInput("value", Op.AutoDetect),
  107586. i.registerInput("power", Op.AutoDetect),
  107587. i.registerOutput("output", Op.BasedOnInput),
  107588. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107589. i._linkConnectionTypes(0, 1),
  107590. i
  107591. }
  107592. return U(t, e),
  107593. t.prototype.getClassName = function() {
  107594. return "PowBlock"
  107595. }
  107596. ,
  107597. Object.defineProperty(t.prototype, "value", {
  107598. get: function() {
  107599. return this._inputs[0]
  107600. },
  107601. enumerable: !1,
  107602. configurable: !0
  107603. }),
  107604. Object.defineProperty(t.prototype, "power", {
  107605. get: function() {
  107606. return this._inputs[1]
  107607. },
  107608. enumerable: !1,
  107609. configurable: !0
  107610. }),
  107611. Object.defineProperty(t.prototype, "output", {
  107612. get: function() {
  107613. return this._outputs[0]
  107614. },
  107615. enumerable: !1,
  107616. configurable: !0
  107617. }),
  107618. t.prototype._buildBlock = function(t) {
  107619. e.prototype._buildBlock.call(this, t);
  107620. var i = this._outputs[0];
  107621. return t.compilationString += this._declareOutput(i, t) + " = pow(".concat(this.value.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\r\n"),
  107622. this
  107623. }
  107624. ,
  107625. t
  107626. }(Wp);
  107627. y("BABYLON.PowBlock", hg);
  107628. var dg = function(e) {
  107629. function t(t) {
  107630. var i = e.call(this, t, Dp.Neutral) || this;
  107631. return i.registerInput("seed", Op.Vector2),
  107632. i.registerOutput("output", Op.Float),
  107633. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  107634. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  107635. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  107636. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
  107637. i
  107638. }
  107639. return U(t, e),
  107640. t.prototype.getClassName = function() {
  107641. return "RandomNumberBlock"
  107642. }
  107643. ,
  107644. Object.defineProperty(t.prototype, "seed", {
  107645. get: function() {
  107646. return this._inputs[0]
  107647. },
  107648. enumerable: !1,
  107649. configurable: !0
  107650. }),
  107651. Object.defineProperty(t.prototype, "output", {
  107652. get: function() {
  107653. return this._outputs[0]
  107654. },
  107655. enumerable: !1,
  107656. configurable: !0
  107657. }),
  107658. t.prototype._buildBlock = function(t) {
  107659. e.prototype._buildBlock.call(this, t);
  107660. var i = this._outputs[0]
  107661. , n = "//".concat(this.name);
  107662. return t._emitFunctionFromInclude("helperFunctions", n),
  107663. t.compilationString += this._declareOutput(i, t) + " = getRand(".concat(this.seed.associatedVariableName, ".xy);\r\n"),
  107664. this
  107665. }
  107666. ,
  107667. t
  107668. }(Wp);
  107669. y("BABYLON.RandomNumberBlock", dg);
  107670. var pg = function(e) {
  107671. function t(t) {
  107672. var i = e.call(this, t, Dp.Neutral) || this;
  107673. return i.registerInput("x", Op.Float),
  107674. i.registerInput("y", Op.Float),
  107675. i.registerOutput("output", Op.Float),
  107676. i
  107677. }
  107678. return U(t, e),
  107679. t.prototype.getClassName = function() {
  107680. return "ArcTan2Block"
  107681. }
  107682. ,
  107683. Object.defineProperty(t.prototype, "x", {
  107684. get: function() {
  107685. return this._inputs[0]
  107686. },
  107687. enumerable: !1,
  107688. configurable: !0
  107689. }),
  107690. Object.defineProperty(t.prototype, "y", {
  107691. get: function() {
  107692. return this._inputs[1]
  107693. },
  107694. enumerable: !1,
  107695. configurable: !0
  107696. }),
  107697. Object.defineProperty(t.prototype, "output", {
  107698. get: function() {
  107699. return this._outputs[0]
  107700. },
  107701. enumerable: !1,
  107702. configurable: !0
  107703. }),
  107704. t.prototype._buildBlock = function(t) {
  107705. e.prototype._buildBlock.call(this, t);
  107706. var i = this._outputs[0];
  107707. return t.compilationString += this._declareOutput(i, t) + " = atan(".concat(this.x.associatedVariableName, ", ").concat(this.y.associatedVariableName, ");\r\n"),
  107708. this
  107709. }
  107710. ,
  107711. t
  107712. }(Wp);
  107713. y("BABYLON.ArcTan2Block", pg);
  107714. var fg = function(e) {
  107715. function t(t) {
  107716. var i = e.call(this, t, Dp.Neutral) || this;
  107717. return i.registerInput("value", Op.AutoDetect),
  107718. i.registerInput("edge0", Op.Float),
  107719. i.registerInput("edge1", Op.Float),
  107720. i.registerOutput("output", Op.BasedOnInput),
  107721. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107722. i
  107723. }
  107724. return U(t, e),
  107725. t.prototype.getClassName = function() {
  107726. return "SmoothStepBlock"
  107727. }
  107728. ,
  107729. Object.defineProperty(t.prototype, "value", {
  107730. get: function() {
  107731. return this._inputs[0]
  107732. },
  107733. enumerable: !1,
  107734. configurable: !0
  107735. }),
  107736. Object.defineProperty(t.prototype, "edge0", {
  107737. get: function() {
  107738. return this._inputs[1]
  107739. },
  107740. enumerable: !1,
  107741. configurable: !0
  107742. }),
  107743. Object.defineProperty(t.prototype, "edge1", {
  107744. get: function() {
  107745. return this._inputs[2]
  107746. },
  107747. enumerable: !1,
  107748. configurable: !0
  107749. }),
  107750. Object.defineProperty(t.prototype, "output", {
  107751. get: function() {
  107752. return this._outputs[0]
  107753. },
  107754. enumerable: !1,
  107755. configurable: !0
  107756. }),
  107757. t.prototype._buildBlock = function(t) {
  107758. e.prototype._buildBlock.call(this, t);
  107759. var i = this._outputs[0];
  107760. return t.compilationString += this._declareOutput(i, t) + " = smoothstep(".concat(this.edge0.associatedVariableName, ", ").concat(this.edge1.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\r\n"),
  107761. this
  107762. }
  107763. ,
  107764. t
  107765. }(Wp);
  107766. y("BABYLON.SmoothStepBlock", fg);
  107767. var _g = function(e) {
  107768. function t(t) {
  107769. var i = e.call(this, t, Dp.Neutral) || this;
  107770. return i.registerInput("input", Op.AutoDetect),
  107771. i.registerOutput("output", Op.BasedOnInput),
  107772. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107773. i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107774. i
  107775. }
  107776. return U(t, e),
  107777. t.prototype.getClassName = function() {
  107778. return "ReciprocalBlock"
  107779. }
  107780. ,
  107781. Object.defineProperty(t.prototype, "input", {
  107782. get: function() {
  107783. return this._inputs[0]
  107784. },
  107785. enumerable: !1,
  107786. configurable: !0
  107787. }),
  107788. Object.defineProperty(t.prototype, "output", {
  107789. get: function() {
  107790. return this._outputs[0]
  107791. },
  107792. enumerable: !1,
  107793. configurable: !0
  107794. }),
  107795. t.prototype._buildBlock = function(t) {
  107796. e.prototype._buildBlock.call(this, t);
  107797. var i = this._outputs[0];
  107798. return t.compilationString += this._declareOutput(i, t) + " = 1. / ".concat(this.input.associatedVariableName, ";\r\n"),
  107799. this
  107800. }
  107801. ,
  107802. t
  107803. }(Wp);
  107804. y("BABYLON.ReciprocalBlock", _g);
  107805. var mg = function(e) {
  107806. function t(t) {
  107807. var i = e.call(this, t, Dp.Neutral) || this;
  107808. return i.registerInput("value", Op.AutoDetect),
  107809. i.registerInput("reference", Op.AutoDetect),
  107810. i.registerInput("distance", Op.Float),
  107811. i.registerInput("replacement", Op.AutoDetect),
  107812. i.registerOutput("output", Op.BasedOnInput),
  107813. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107814. i._linkConnectionTypes(0, 1),
  107815. i._linkConnectionTypes(0, 3),
  107816. i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
  107817. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107818. i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
  107819. i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
  107820. i._inputs[3].excludedConnectionPointTypes.push(Op.Float),
  107821. i._inputs[3].excludedConnectionPointTypes.push(Op.Matrix),
  107822. i
  107823. }
  107824. return U(t, e),
  107825. t.prototype.getClassName = function() {
  107826. return "ReplaceColorBlock"
  107827. }
  107828. ,
  107829. Object.defineProperty(t.prototype, "value", {
  107830. get: function() {
  107831. return this._inputs[0]
  107832. },
  107833. enumerable: !1,
  107834. configurable: !0
  107835. }),
  107836. Object.defineProperty(t.prototype, "reference", {
  107837. get: function() {
  107838. return this._inputs[1]
  107839. },
  107840. enumerable: !1,
  107841. configurable: !0
  107842. }),
  107843. Object.defineProperty(t.prototype, "distance", {
  107844. get: function() {
  107845. return this._inputs[2]
  107846. },
  107847. enumerable: !1,
  107848. configurable: !0
  107849. }),
  107850. Object.defineProperty(t.prototype, "replacement", {
  107851. get: function() {
  107852. return this._inputs[3]
  107853. },
  107854. enumerable: !1,
  107855. configurable: !0
  107856. }),
  107857. Object.defineProperty(t.prototype, "output", {
  107858. get: function() {
  107859. return this._outputs[0]
  107860. },
  107861. enumerable: !1,
  107862. configurable: !0
  107863. }),
  107864. t.prototype._buildBlock = function(t) {
  107865. e.prototype._buildBlock.call(this, t);
  107866. var i = this._outputs[0];
  107867. return t.compilationString += this._declareOutput(i, t) + ";\r\n",
  107868. t.compilationString += "if (length(".concat(this.value.associatedVariableName, " - ").concat(this.reference.associatedVariableName, ") < ").concat(this.distance.associatedVariableName, ") {\r\n"),
  107869. t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.replacement.associatedVariableName, ";\r\n"),
  107870. t.compilationString += "} else {\r\n",
  107871. t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.value.associatedVariableName, ";\r\n"),
  107872. t.compilationString += "}\r\n",
  107873. this
  107874. }
  107875. ,
  107876. t
  107877. }(Wp);
  107878. y("BABYLON.ReplaceColorBlock", mg);
  107879. var gg, vg = function(e) {
  107880. function t(t) {
  107881. var i = e.call(this, t, Dp.Neutral) || this;
  107882. return i.registerInput("value", Op.AutoDetect),
  107883. i.registerInput("steps", Op.AutoDetect),
  107884. i.registerOutput("output", Op.BasedOnInput),
  107885. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107886. i._linkConnectionTypes(0, 1),
  107887. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107888. i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
  107889. i
  107890. }
  107891. return U(t, e),
  107892. t.prototype.getClassName = function() {
  107893. return "PosterizeBlock"
  107894. }
  107895. ,
  107896. Object.defineProperty(t.prototype, "value", {
  107897. get: function() {
  107898. return this._inputs[0]
  107899. },
  107900. enumerable: !1,
  107901. configurable: !0
  107902. }),
  107903. Object.defineProperty(t.prototype, "steps", {
  107904. get: function() {
  107905. return this._inputs[1]
  107906. },
  107907. enumerable: !1,
  107908. configurable: !0
  107909. }),
  107910. Object.defineProperty(t.prototype, "output", {
  107911. get: function() {
  107912. return this._outputs[0]
  107913. },
  107914. enumerable: !1,
  107915. configurable: !0
  107916. }),
  107917. t.prototype._buildBlock = function(t) {
  107918. e.prototype._buildBlock.call(this, t);
  107919. var i = this._outputs[0];
  107920. return t.compilationString += this._declareOutput(i, t) + " = floor(".concat(this.value.associatedVariableName, " / (1.0 / ").concat(this.steps.associatedVariableName, ")) * (1.0 / ").concat(this.steps.associatedVariableName, ");\r\n"),
  107921. this
  107922. }
  107923. ,
  107924. t
  107925. }(Wp);
  107926. y("BABYLON.PosterizeBlock", vg),
  107927. function(e) {
  107928. e[e.SawTooth = 0] = "SawTooth",
  107929. e[e.Square = 1] = "Square",
  107930. e[e.Triangle = 2] = "Triangle"
  107931. }(gg || (gg = {}));
  107932. var yg = function(e) {
  107933. function t(t) {
  107934. var i = e.call(this, t, Dp.Neutral) || this;
  107935. return i.kind = gg.SawTooth,
  107936. i.registerInput("input", Op.AutoDetect),
  107937. i.registerOutput("output", Op.BasedOnInput),
  107938. i._outputs[0]._typeConnectionSource = i._inputs[0],
  107939. i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
  107940. i
  107941. }
  107942. return U(t, e),
  107943. t.prototype.getClassName = function() {
  107944. return "WaveBlock"
  107945. }
  107946. ,
  107947. Object.defineProperty(t.prototype, "input", {
  107948. get: function() {
  107949. return this._inputs[0]
  107950. },
  107951. enumerable: !1,
  107952. configurable: !0
  107953. }),
  107954. Object.defineProperty(t.prototype, "output", {
  107955. get: function() {
  107956. return this._outputs[0]
  107957. },
  107958. enumerable: !1,
  107959. configurable: !0
  107960. }),
  107961. t.prototype._buildBlock = function(t) {
  107962. e.prototype._buildBlock.call(this, t);
  107963. var i = this._outputs[0];
  107964. switch (this.kind) {
  107965. case gg.SawTooth:
  107966. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, ");\r\n");
  107967. break;
  107968. case gg.Square:
  107969. t.compilationString += this._declareOutput(i, t) + " = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName, "));\r\n");
  107970. break;
  107971. case gg.Triangle:
  107972. t.compilationString += this._declareOutput(i, t) + " = 2.0 * abs(2.0 * (".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, "))) - 1.0;\r\n")
  107973. }
  107974. return this
  107975. }
  107976. ,
  107977. t.prototype.serialize = function() {
  107978. var t = e.prototype.serialize.call(this);
  107979. return t.kind = this.kind,
  107980. t
  107981. }
  107982. ,
  107983. t.prototype._deserialize = function(t, i, n) {
  107984. e.prototype._deserialize.call(this, t, i, n),
  107985. this.kind = t.kind
  107986. }
  107987. ,
  107988. t
  107989. }(Wp);
  107990. y("BABYLON.WaveBlock", yg);
  107991. var bg = function() {
  107992. function e(e, t) {
  107993. this.step = e,
  107994. this.color = t
  107995. }
  107996. return Object.defineProperty(e.prototype, "step", {
  107997. get: function() {
  107998. return this._step
  107999. },
  108000. set: function(e) {
  108001. this._step = e
  108002. },
  108003. enumerable: !1,
  108004. configurable: !0
  108005. }),
  108006. Object.defineProperty(e.prototype, "color", {
  108007. get: function() {
  108008. return this._color
  108009. },
  108010. set: function(e) {
  108011. this._color = e
  108012. },
  108013. enumerable: !1,
  108014. configurable: !0
  108015. }),
  108016. e
  108017. }()
  108018. , Tg = function(e) {
  108019. function t(t) {
  108020. var i = e.call(this, t, Dp.Neutral) || this;
  108021. return i.colorSteps = [new bg(0,D.Black()), new bg(1,D.White())],
  108022. i.onValueChangedObservable = new h,
  108023. i.registerInput("gradient", Op.Float),
  108024. i.registerOutput("output", Op.Color3),
  108025. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
  108026. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  108027. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  108028. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  108029. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
  108030. i
  108031. }
  108032. return U(t, e),
  108033. t.prototype.colorStepsUpdated = function() {
  108034. this.onValueChangedObservable.notifyObservers(this)
  108035. }
  108036. ,
  108037. t.prototype.getClassName = function() {
  108038. return "GradientBlock"
  108039. }
  108040. ,
  108041. Object.defineProperty(t.prototype, "gradient", {
  108042. get: function() {
  108043. return this._inputs[0]
  108044. },
  108045. enumerable: !1,
  108046. configurable: !0
  108047. }),
  108048. Object.defineProperty(t.prototype, "output", {
  108049. get: function() {
  108050. return this._outputs[0]
  108051. },
  108052. enumerable: !1,
  108053. configurable: !0
  108054. }),
  108055. t.prototype._writeColorConstant = function(e) {
  108056. var t = this.colorSteps[e];
  108057. return "vec3(".concat(t.color.r, ", ").concat(t.color.g, ", ").concat(t.color.b, ")")
  108058. }
  108059. ,
  108060. t.prototype._buildBlock = function(t) {
  108061. e.prototype._buildBlock.call(this, t);
  108062. var i = this._outputs[0];
  108063. if (this.colorSteps.length && this.gradient.connectedPoint) {
  108064. var n = t._getFreeVariableName("gradientTempColor")
  108065. , r = t._getFreeVariableName("gradientTempPosition");
  108066. t.compilationString += "vec3 ".concat(n, " = ").concat(this._writeColorConstant(0), ";\r\n"),
  108067. t.compilationString += "float ".concat(r, ";\r\n");
  108068. var o = this.gradient.associatedVariableName;
  108069. this.gradient.connectedPoint.type !== Op.Float && (o += ".x");
  108070. for (var a = 1; a < this.colorSteps.length; a++) {
  108071. var s = this.colorSteps[a]
  108072. , l = this.colorSteps[a - 1];
  108073. t.compilationString += "".concat(r, " = clamp((").concat(o, " - ").concat(t._emitFloat(l.step), ") / (").concat(t._emitFloat(s.step), " - ").concat(t._emitFloat(l.step), "), 0.0, 1.0) * step(").concat(t._emitFloat(a), ", ").concat(t._emitFloat(this.colorSteps.length - 1), ");\r\n"),
  108074. t.compilationString += "".concat(n, " = mix(").concat(n, ", ").concat(this._writeColorConstant(a), ", ").concat(r, ");\r\n")
  108075. }
  108076. return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, ";\r\n"),
  108077. this
  108078. }
  108079. t.compilationString += this._declareOutput(i, t) + " = vec3(0., 0., 0.);\r\n"
  108080. }
  108081. ,
  108082. t.prototype.serialize = function() {
  108083. var t = e.prototype.serialize.call(this);
  108084. t.colorSteps = [];
  108085. for (var i = 0, n = this.colorSteps; i < n.length; i++) {
  108086. var r = n[i];
  108087. t.colorSteps.push({
  108088. step: r.step,
  108089. color: {
  108090. r: r.color.r,
  108091. g: r.color.g,
  108092. b: r.color.b
  108093. }
  108094. })
  108095. }
  108096. return t
  108097. }
  108098. ,
  108099. t.prototype._deserialize = function(t, i, n) {
  108100. e.prototype._deserialize.call(this, t, i, n),
  108101. this.colorSteps = [];
  108102. for (var r = 0, o = t.colorSteps; r < o.length; r++) {
  108103. var a = o[r];
  108104. this.colorSteps.push(new bg(a.step,new D(a.color.r,a.color.g,a.color.b)))
  108105. }
  108106. }
  108107. ,
  108108. t.prototype._dumpPropertiesCode = function() {
  108109. var t = e.prototype._dumpPropertiesCode.call(this);
  108110. t += "".concat(this._codeVariableName, ".colorSteps = [];\r\n");
  108111. for (var i = 0, n = this.colorSteps; i < n.length; i++) {
  108112. var r = n[i];
  108113. t += "".concat(this._codeVariableName, ".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(r.step, ", new BABYLON.Color3(").concat(r.color.r, ", ").concat(r.color.g, ", ").concat(r.color.b, ")));\r\n")
  108114. }
  108115. return t
  108116. }
  108117. ,
  108118. t
  108119. }(Wp);
  108120. y("BABYLON.GradientBlock", Tg);
  108121. var Eg = function(e) {
  108122. function t(t) {
  108123. var i = e.call(this, t, Dp.Neutral) || this;
  108124. return i.registerInput("left", Op.AutoDetect),
  108125. i.registerInput("right", Op.AutoDetect),
  108126. i.registerInput("gradient", Op.AutoDetect),
  108127. i.registerOutput("output", Op.BasedOnInput),
  108128. i._outputs[0]._typeConnectionSource = i._inputs[0],
  108129. i._linkConnectionTypes(0, 1),
  108130. i._linkConnectionTypes(1, 2, !0),
  108131. i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
  108132. i
  108133. }
  108134. return U(t, e),
  108135. t.prototype.getClassName = function() {
  108136. return "NLerpBlock"
  108137. }
  108138. ,
  108139. Object.defineProperty(t.prototype, "left", {
  108140. get: function() {
  108141. return this._inputs[0]
  108142. },
  108143. enumerable: !1,
  108144. configurable: !0
  108145. }),
  108146. Object.defineProperty(t.prototype, "right", {
  108147. get: function() {
  108148. return this._inputs[1]
  108149. },
  108150. enumerable: !1,
  108151. configurable: !0
  108152. }),
  108153. Object.defineProperty(t.prototype, "gradient", {
  108154. get: function() {
  108155. return this._inputs[2]
  108156. },
  108157. enumerable: !1,
  108158. configurable: !0
  108159. }),
  108160. Object.defineProperty(t.prototype, "output", {
  108161. get: function() {
  108162. return this._outputs[0]
  108163. },
  108164. enumerable: !1,
  108165. configurable: !0
  108166. }),
  108167. t.prototype._buildBlock = function(t) {
  108168. e.prototype._buildBlock.call(this, t);
  108169. var i = this._outputs[0];
  108170. return t.compilationString += this._declareOutput(i, t) + " = normalize(mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, "));\r\n"),
  108171. this
  108172. }
  108173. ,
  108174. t
  108175. }(Wp);
  108176. y("BABYLON.NLerpBlock", Eg);
  108177. var Sg = function(e) {
  108178. function t(t) {
  108179. var i = e.call(this, t, Dp.Neutral) || this;
  108180. return i.manhattanDistance = !1,
  108181. i.registerInput("seed", Op.Vector3),
  108182. i.registerInput("jitter", Op.Float),
  108183. i.registerOutput("output", Op.Vector2),
  108184. i.registerOutput("x", Op.Float),
  108185. i.registerOutput("y", Op.Float),
  108186. i
  108187. }
  108188. return U(t, e),
  108189. t.prototype.getClassName = function() {
  108190. return "WorleyNoise3DBlock"
  108191. }
  108192. ,
  108193. Object.defineProperty(t.prototype, "seed", {
  108194. get: function() {
  108195. return this._inputs[0]
  108196. },
  108197. enumerable: !1,
  108198. configurable: !0
  108199. }),
  108200. Object.defineProperty(t.prototype, "jitter", {
  108201. get: function() {
  108202. return this._inputs[1]
  108203. },
  108204. enumerable: !1,
  108205. configurable: !0
  108206. }),
  108207. Object.defineProperty(t.prototype, "output", {
  108208. get: function() {
  108209. return this._outputs[0]
  108210. },
  108211. enumerable: !1,
  108212. configurable: !0
  108213. }),
  108214. Object.defineProperty(t.prototype, "x", {
  108215. get: function() {
  108216. return this._outputs[1]
  108217. },
  108218. enumerable: !1,
  108219. configurable: !0
  108220. }),
  108221. Object.defineProperty(t.prototype, "y", {
  108222. get: function() {
  108223. return this._outputs[2]
  108224. },
  108225. enumerable: !1,
  108226. configurable: !0
  108227. }),
  108228. t.prototype._buildBlock = function(t) {
  108229. if (e.prototype._buildBlock.call(this, t),
  108230. this.seed.isConnected && (this.output.hasEndpoints || this.x.hasEndpoints || this.y.hasEndpoints)) {
  108231. t._emitFunction("worley3D", "vec3 permute(vec3 x){\r\n return mod((34.0 * x + 1.0) * x, 289.0);\r\n}\r\n\r\nvec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r\n return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r\n}\r\n\r\nvec2 worley(vec3 P, float jitter, bool manhattanDistance){\r\n float K = 0.142857142857; // 1/7\r\n float Ko = 0.428571428571; // 1/2-K/2\r\n float K2 = 0.020408163265306; // 1/(7*7)\r\n float Kz = 0.166666666667; // 1/6\r\n float Kzo = 0.416666666667; // 1/2-1/6*2\r\n\r\n vec3 Pi = mod(floor(P), 289.0);\r\n vec3 Pf = fract(P) - 0.5;\r\n\r\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r\n\r\n vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r\n vec3 p1 = permute(p + Pi.y - 1.0);\r\n vec3 p2 = permute(p + Pi.y);\r\n vec3 p3 = permute(p + Pi.y + 1.0);\r\n\r\n vec3 p11 = permute(p1 + Pi.z - 1.0);\r\n vec3 p12 = permute(p1 + Pi.z);\r\n vec3 p13 = permute(p1 + Pi.z + 1.0);\r\n\r\n vec3 p21 = permute(p2 + Pi.z - 1.0);\r\n vec3 p22 = permute(p2 + Pi.z);\r\n vec3 p23 = permute(p2 + Pi.z + 1.0);\r\n\r\n vec3 p31 = permute(p3 + Pi.z - 1.0);\r\n vec3 p32 = permute(p3 + Pi.z);\r\n vec3 p33 = permute(p3 + Pi.z + 1.0);\r\n\r\n vec3 ox11 = fract(p11*K) - Ko;\r\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r\n vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r\n\r\n vec3 ox12 = fract(p12*K) - Ko;\r\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r\n\r\n vec3 ox13 = fract(p13*K) - Ko;\r\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r\n\r\n vec3 ox21 = fract(p21*K) - Ko;\r\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r\n\r\n vec3 ox22 = fract(p22*K) - Ko;\r\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r\n\r\n vec3 ox23 = fract(p23*K) - Ko;\r\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r\n\r\n vec3 ox31 = fract(p31*K) - Ko;\r\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r\n\r\n vec3 ox32 = fract(p32*K) - Ko;\r\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r\n\r\n vec3 ox33 = fract(p33*K) - Ko;\r\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r\n\r\n vec3 dx11 = Pfx + jitter*ox11;\r\n vec3 dy11 = Pfy.x + jitter*oy11;\r\n vec3 dz11 = Pfz.x + jitter*oz11;\r\n\r\n vec3 dx12 = Pfx + jitter*ox12;\r\n vec3 dy12 = Pfy.x + jitter*oy12;\r\n vec3 dz12 = Pfz.y + jitter*oz12;\r\n\r\n vec3 dx13 = Pfx + jitter*ox13;\r\n vec3 dy13 = Pfy.x + jitter*oy13;\r\n vec3 dz13 = Pfz.z + jitter*oz13;\r\n\r\n vec3 dx21 = Pfx + jitter*ox21;\r\n vec3 dy21 = Pfy.y + jitter*oy21;\r\n vec3 dz21 = Pfz.x + jitter*oz21;\r\n\r\n vec3 dx22 = Pfx + jitter*ox22;\r\n vec3 dy22 = Pfy.y + jitter*oy22;\r\n vec3 dz22 = Pfz.y + jitter*oz22;\r\n\r\n vec3 dx23 = Pfx + jitter*ox23;\r\n vec3 dy23 = Pfy.y + jitter*oy23;\r\n vec3 dz23 = Pfz.z + jitter*oz23;\r\n\r\n vec3 dx31 = Pfx + jitter*ox31;\r\n vec3 dy31 = Pfy.z + jitter*oy31;\r\n vec3 dz31 = Pfz.x + jitter*oz31;\r\n\r\n vec3 dx32 = Pfx + jitter*ox32;\r\n vec3 dy32 = Pfy.z + jitter*oy32;\r\n vec3 dz32 = Pfz.y + jitter*oz32;\r\n\r\n vec3 dx33 = Pfx + jitter*ox33;\r\n vec3 dy33 = Pfy.z + jitter*oy33;\r\n vec3 dz33 = Pfz.z + jitter*oz33;\r\n\r\n vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r\n vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r\n vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r\n vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r\n vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r\n vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r\n vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r\n vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r\n vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r\n\r\n vec3 d1a = min(d11, d12);\r\n d12 = max(d11, d12);\r\n d11 = min(d1a, d13); // Smallest now not in d12 or d13\r\n d13 = max(d1a, d13);\r\n d12 = min(d12, d13); // 2nd smallest now not in d13\r\n vec3 d2a = min(d21, d22);\r\n d22 = max(d21, d22);\r\n d21 = min(d2a, d23); // Smallest now not in d22 or d23\r\n d23 = max(d2a, d23);\r\n d22 = min(d22, d23); // 2nd smallest now not in d23\r\n vec3 d3a = min(d31, d32);\r\n d32 = max(d31, d32);\r\n d31 = min(d3a, d33); // Smallest now not in d32 or d33\r\n d33 = max(d3a, d33);\r\n d32 = min(d32, d33); // 2nd smallest now not in d33\r\n vec3 da = min(d11, d21);\r\n d21 = max(d11, d21);\r\n d11 = min(da, d31); // Smallest now in d11\r\n d31 = max(da, d31); // 2nd smallest now not in d31\r\n d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r\n d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r\n d12 = min(d12, d21); // 2nd smallest now not in d21\r\n d12 = min(d12, d22); // nor in d22\r\n d12 = min(d12, d31); // nor in d31\r\n d12 = min(d12, d32); // nor in d32\r\n d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r\n d11.y = min(d11.y,d12.z); // Only two more to go\r\n d11.y = min(d11.y,d11.z); // Done! (Phew!)\r\n return sqrt(d11.xy); // F1, F2\r\n}\r\n\r\n", "// Worley3D");
  108232. var i = t._getFreeVariableName("worleyTemp");
  108233. return t.compilationString += "vec2 ".concat(i, " = worley(").concat(this.seed.associatedVariableName, ", ").concat(this.jitter.associatedVariableName, ", ").concat(this.manhattanDistance, ");\r\n"),
  108234. this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(i, ";\r\n")),
  108235. this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(i, ".x;\r\n")),
  108236. this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(i, ".y;\r\n")),
  108237. this
  108238. }
  108239. }
  108240. ,
  108241. t.prototype._dumpPropertiesCode = function() {
  108242. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".manhattanDistance = ").concat(this.manhattanDistance, ";\r\n")
  108243. }
  108244. ,
  108245. t.prototype.serialize = function() {
  108246. var t = e.prototype.serialize.call(this);
  108247. return t.manhattanDistance = this.manhattanDistance,
  108248. t
  108249. }
  108250. ,
  108251. t.prototype._deserialize = function(t, i, n) {
  108252. e.prototype._deserialize.call(this, t, i, n),
  108253. this.manhattanDistance = t.manhattanDistance
  108254. }
  108255. ,
  108256. k([Yp("Use Manhattan Distance", Xp.Boolean, "PROPERTIES", {
  108257. notifiers: {
  108258. update: !1
  108259. }
  108260. })], t.prototype, "manhattanDistance", void 0),
  108261. t
  108262. }(Wp);
  108263. y("BABYLON.WorleyNoise3DBlock", Sg);
  108264. var Ag = function(e) {
  108265. function t(t) {
  108266. var i = e.call(this, t, Dp.Neutral) || this;
  108267. return i.registerInput("seed", Op.Vector3),
  108268. i.registerOutput("output", Op.Float),
  108269. i
  108270. }
  108271. return U(t, e),
  108272. t.prototype.getClassName = function() {
  108273. return "SimplexPerlin3DBlock"
  108274. }
  108275. ,
  108276. Object.defineProperty(t.prototype, "seed", {
  108277. get: function() {
  108278. return this._inputs[0]
  108279. },
  108280. enumerable: !1,
  108281. configurable: !0
  108282. }),
  108283. Object.defineProperty(t.prototype, "output", {
  108284. get: function() {
  108285. return this._outputs[0]
  108286. },
  108287. enumerable: !1,
  108288. configurable: !0
  108289. }),
  108290. t.prototype._buildBlock = function(t) {
  108291. if (e.prototype._buildBlock.call(this, t),
  108292. this.seed.isConnected && this._outputs[0].hasEndpoints)
  108293. return t._emitFunction("SimplexPerlin3D", "const float SKEWFACTOR = 1.0/3.0;\r\nconst float UNSKEWFACTOR = 1.0/6.0;\r\nconst float SIMPLEX_CORNER_POS = 0.5;\r\nconst float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\nfloat SimplexPerlin3D( vec3 P ){\r\n P.x = P == vec3(0., 0., 0.) ? 0.00001 : P.x;\r\n P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n vec3 g = step(x0.yzx, x0.xyz);\r\n vec3 l = 1.0 - g;\r\n vec3 Pi_1 = min( g.xyz, l.zxy );\r\n vec3 Pi_2 = max( g.xyz, l.zxy );\r\n vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n Pt *= Pt;\r\n vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\n vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r\n const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n}\r\n", "// SimplexPerlin3D"),
  108294. t.compilationString += this._declareOutput(this._outputs[0], t) + " = SimplexPerlin3D(".concat(this.seed.associatedVariableName, ");\r\n"),
  108295. this
  108296. }
  108297. ,
  108298. t
  108299. }(Wp);
  108300. y("BABYLON.SimplexPerlin3DBlock", Ag);
  108301. var xg = function(e) {
  108302. function t(t) {
  108303. var i = e.call(this, t, Dp.Neutral) || this;
  108304. return i.registerInput("normalMap0", Op.Vector3),
  108305. i.registerInput("normalMap1", Op.Vector3),
  108306. i.registerOutput("output", Op.Vector3),
  108307. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  108308. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
  108309. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  108310. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
  108311. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
  108312. i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
  108313. i
  108314. }
  108315. return U(t, e),
  108316. t.prototype.getClassName = function() {
  108317. return "NormalBlendBlock"
  108318. }
  108319. ,
  108320. Object.defineProperty(t.prototype, "normalMap0", {
  108321. get: function() {
  108322. return this._inputs[0]
  108323. },
  108324. enumerable: !1,
  108325. configurable: !0
  108326. }),
  108327. Object.defineProperty(t.prototype, "normalMap1", {
  108328. get: function() {
  108329. return this._inputs[1]
  108330. },
  108331. enumerable: !1,
  108332. configurable: !0
  108333. }),
  108334. Object.defineProperty(t.prototype, "output", {
  108335. get: function() {
  108336. return this._outputs[0]
  108337. },
  108338. enumerable: !1,
  108339. configurable: !0
  108340. }),
  108341. t.prototype._buildBlock = function(t) {
  108342. e.prototype._buildBlock.call(this, t);
  108343. var i = this._outputs[0]
  108344. , n = this._inputs[0]
  108345. , r = this._inputs[1]
  108346. , o = t._getFreeVariableName("stepR")
  108347. , a = t._getFreeVariableName("stepG");
  108348. return t.compilationString += "float ".concat(o, " = step(0.5, ").concat(n.associatedVariableName, ".r);\r\n"),
  108349. t.compilationString += "float ".concat(a, " = step(0.5, ").concat(n.associatedVariableName, ".g);\r\n"),
  108350. t.compilationString += this._declareOutput(i, t) + ";\r\n",
  108351. t.compilationString += "".concat(i.associatedVariableName, ".r = (1.0 - ").concat(o, ") * ").concat(n.associatedVariableName, ".r * ").concat(r.associatedVariableName, ".r * 2.0 + ").concat(o, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".r) * (1.0 - ").concat(r.associatedVariableName, ".r) * 2.0);\r\n"),
  108352. t.compilationString += "".concat(i.associatedVariableName, ".g = (1.0 - ").concat(a, ") * ").concat(n.associatedVariableName, ".g * ").concat(r.associatedVariableName, ".g * 2.0 + ").concat(a, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".g) * (1.0 - ").concat(r.associatedVariableName, ".g) * 2.0);\r\n"),
  108353. t.compilationString += "".concat(i.associatedVariableName, ".b = ").concat(n.associatedVariableName, ".b * ").concat(r.associatedVariableName, ".b;\r\n"),
  108354. this
  108355. }
  108356. ,
  108357. t
  108358. }(Wp);
  108359. y("BABYLON.NormalBlendBlock", xg);
  108360. var Rg = function(e) {
  108361. function t(t) {
  108362. var i = e.call(this, t, Dp.Neutral) || this;
  108363. return i.registerInput("input", Op.Vector2),
  108364. i.registerInput("angle", Op.Float),
  108365. i.registerOutput("output", Op.Vector2),
  108366. i
  108367. }
  108368. return U(t, e),
  108369. t.prototype.getClassName = function() {
  108370. return "Rotate2dBlock"
  108371. }
  108372. ,
  108373. Object.defineProperty(t.prototype, "input", {
  108374. get: function() {
  108375. return this._inputs[0]
  108376. },
  108377. enumerable: !1,
  108378. configurable: !0
  108379. }),
  108380. Object.defineProperty(t.prototype, "angle", {
  108381. get: function() {
  108382. return this._inputs[1]
  108383. },
  108384. enumerable: !1,
  108385. configurable: !0
  108386. }),
  108387. Object.defineProperty(t.prototype, "output", {
  108388. get: function() {
  108389. return this._outputs[0]
  108390. },
  108391. enumerable: !1,
  108392. configurable: !0
  108393. }),
  108394. t.prototype.autoConfigure = function() {
  108395. if (!this.angle.isConnected) {
  108396. var e = new tf("angle");
  108397. e.value = 0,
  108398. e.output.connectTo(this.angle)
  108399. }
  108400. }
  108401. ,
  108402. t.prototype._buildBlock = function(t) {
  108403. e.prototype._buildBlock.call(this, t);
  108404. var i = this._outputs[0]
  108405. , n = this.angle
  108406. , r = this.input;
  108407. return t.compilationString += this._declareOutput(i, t) + " = vec2(cos(".concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x - sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y, sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x + cos(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y);\r\n"),
  108408. this
  108409. }
  108410. ,
  108411. t
  108412. }(Wp);
  108413. y("BABYLON.Rotate2dBlock", Rg);
  108414. var Cg = function(e) {
  108415. function t(t) {
  108416. var i = e.call(this, t, Dp.Neutral) || this;
  108417. return i.registerInput("incident", Op.Vector3),
  108418. i.registerInput("normal", Op.Vector3),
  108419. i.registerOutput("output", Op.Vector3),
  108420. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  108421. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  108422. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
  108423. i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
  108424. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
  108425. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
  108426. i
  108427. }
  108428. return U(t, e),
  108429. t.prototype.getClassName = function() {
  108430. return "ReflectBlock"
  108431. }
  108432. ,
  108433. Object.defineProperty(t.prototype, "incident", {
  108434. get: function() {
  108435. return this._inputs[0]
  108436. },
  108437. enumerable: !1,
  108438. configurable: !0
  108439. }),
  108440. Object.defineProperty(t.prototype, "normal", {
  108441. get: function() {
  108442. return this._inputs[1]
  108443. },
  108444. enumerable: !1,
  108445. configurable: !0
  108446. }),
  108447. Object.defineProperty(t.prototype, "output", {
  108448. get: function() {
  108449. return this._outputs[0]
  108450. },
  108451. enumerable: !1,
  108452. configurable: !0
  108453. }),
  108454. t.prototype._buildBlock = function(t) {
  108455. e.prototype._buildBlock.call(this, t);
  108456. var i = this._outputs[0];
  108457. return t.compilationString += this._declareOutput(i, t) + " = reflect(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz);\r\n"),
  108458. this
  108459. }
  108460. ,
  108461. t
  108462. }(Wp);
  108463. y("BABYLON.ReflectBlock", Cg);
  108464. var Pg = function(e) {
  108465. function t(t) {
  108466. var i = e.call(this, t, Dp.Neutral) || this;
  108467. return i.registerInput("incident", Op.Vector3),
  108468. i.registerInput("normal", Op.Vector3),
  108469. i.registerInput("ior", Op.Float),
  108470. i.registerOutput("output", Op.Vector3),
  108471. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
  108472. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
  108473. i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
  108474. i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
  108475. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
  108476. i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
  108477. i
  108478. }
  108479. return U(t, e),
  108480. t.prototype.getClassName = function() {
  108481. return "RefractBlock"
  108482. }
  108483. ,
  108484. Object.defineProperty(t.prototype, "incident", {
  108485. get: function() {
  108486. return this._inputs[0]
  108487. },
  108488. enumerable: !1,
  108489. configurable: !0
  108490. }),
  108491. Object.defineProperty(t.prototype, "normal", {
  108492. get: function() {
  108493. return this._inputs[1]
  108494. },
  108495. enumerable: !1,
  108496. configurable: !0
  108497. }),
  108498. Object.defineProperty(t.prototype, "ior", {
  108499. get: function() {
  108500. return this._inputs[2]
  108501. },
  108502. enumerable: !1,
  108503. configurable: !0
  108504. }),
  108505. Object.defineProperty(t.prototype, "output", {
  108506. get: function() {
  108507. return this._outputs[0]
  108508. },
  108509. enumerable: !1,
  108510. configurable: !0
  108511. }),
  108512. t.prototype._buildBlock = function(t) {
  108513. e.prototype._buildBlock.call(this, t);
  108514. var i = this._outputs[0];
  108515. return t.compilationString += this._declareOutput(i, t) + " = refract(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz, ").concat(this.ior.associatedVariableName, ");\r\n"),
  108516. this
  108517. }
  108518. ,
  108519. t
  108520. }(Wp);
  108521. y("BABYLON.RefractBlock", Pg);
  108522. var Mg = function(e) {
  108523. function t(t) {
  108524. var i = e.call(this, t, Dp.Neutral) || this;
  108525. return i.registerInput("color", Op.Color3),
  108526. i.registerInput("level", Op.Float),
  108527. i.registerOutput("output", Op.Color3),
  108528. i
  108529. }
  108530. return U(t, e),
  108531. t.prototype.getClassName = function() {
  108532. return "DesaturateBlock"
  108533. }
  108534. ,
  108535. Object.defineProperty(t.prototype, "color", {
  108536. get: function() {
  108537. return this._inputs[0]
  108538. },
  108539. enumerable: !1,
  108540. configurable: !0
  108541. }),
  108542. Object.defineProperty(t.prototype, "level", {
  108543. get: function() {
  108544. return this._inputs[1]
  108545. },
  108546. enumerable: !1,
  108547. configurable: !0
  108548. }),
  108549. Object.defineProperty(t.prototype, "output", {
  108550. get: function() {
  108551. return this._outputs[0]
  108552. },
  108553. enumerable: !1,
  108554. configurable: !0
  108555. }),
  108556. t.prototype._buildBlock = function(t) {
  108557. e.prototype._buildBlock.call(this, t);
  108558. var i = this._outputs[0]
  108559. , n = this.color.associatedVariableName
  108560. , r = t._getFreeVariableName("colorMin")
  108561. , o = t._getFreeVariableName("colorMax")
  108562. , a = t._getFreeVariableName("colorMerge");
  108563. return t.compilationString += "float ".concat(r, " = min(min(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
  108564. t.compilationString += "float ".concat(o, " = max(max(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
  108565. t.compilationString += "float ".concat(a, " = 0.5 * (").concat(r, " + ").concat(o, ");\r\n"),
  108566. t.compilationString += this._declareOutput(i, t) + " = mix(".concat(n, ", vec3(").concat(a, ", ").concat(a, ", ").concat(a, "), ").concat(this.level.associatedVariableName, ");\r\n"),
  108567. this
  108568. }
  108569. ,
  108570. t
  108571. }(Wp);
  108572. y("BABYLON.DesaturateBlock", Mg);
  108573. var Ig = function(e) {
  108574. function t(i) {
  108575. var n = e.call(this, i, Dp.Fragment) || this;
  108576. return n.albedoScaling = !1,
  108577. n.linkSheenWithAlbedo = !1,
  108578. n._isUnique = !0,
  108579. n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
  108580. n.registerInput("color", Op.Color3, !0, Dp.Fragment),
  108581. n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
  108582. n.registerOutput("sheen", Op.Object, Dp.Fragment, new Bm("sheen",n,Vp.Output,t,"SheenBlock")),
  108583. n
  108584. }
  108585. return U(t, e),
  108586. t.prototype.initialize = function(e) {
  108587. e._excludeVariableName("sheenOut"),
  108588. e._excludeVariableName("sheenMapData"),
  108589. e._excludeVariableName("vSheenColor"),
  108590. e._excludeVariableName("vSheenRoughness")
  108591. }
  108592. ,
  108593. t.prototype.getClassName = function() {
  108594. return "SheenBlock"
  108595. }
  108596. ,
  108597. Object.defineProperty(t.prototype, "intensity", {
  108598. get: function() {
  108599. return this._inputs[0]
  108600. },
  108601. enumerable: !1,
  108602. configurable: !0
  108603. }),
  108604. Object.defineProperty(t.prototype, "color", {
  108605. get: function() {
  108606. return this._inputs[1]
  108607. },
  108608. enumerable: !1,
  108609. configurable: !0
  108610. }),
  108611. Object.defineProperty(t.prototype, "roughness", {
  108612. get: function() {
  108613. return this._inputs[2]
  108614. },
  108615. enumerable: !1,
  108616. configurable: !0
  108617. }),
  108618. Object.defineProperty(t.prototype, "sheen", {
  108619. get: function() {
  108620. return this._outputs[0]
  108621. },
  108622. enumerable: !1,
  108623. configurable: !0
  108624. }),
  108625. t.prototype.prepareDefines = function(t, i, n) {
  108626. e.prototype.prepareDefines.call(this, t, i, n),
  108627. n.setValue("SHEEN", !0),
  108628. n.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
  108629. n.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0),
  108630. n.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0),
  108631. n.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0)
  108632. }
  108633. ,
  108634. t.prototype.getCode = function(e) {
  108635. var t = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)"
  108636. , i = this.intensity.isConnected ? this.intensity.associatedVariableName : "1."
  108637. , n = this.roughness.isConnected ? this.roughness.associatedVariableName : "0.";
  108638. return "#ifdef SHEEN\n sheenOutParams sheenOut;\n\n vec4 vSheenColor = vec4(".concat(t, ", ").concat(i, ");\n\n sheenBlock(\n vSheenColor,\n #ifdef SHEEN_ROUGHNESS\n ").concat(n, ",\n #endif\n roughness,\n #ifdef SHEEN_TEXTURE\n ").concat("vec4(0.)", ",\n 1.0,\n #endif\n reflectance,\n #ifdef SHEEN_LINKWITHALBEDO\n baseColor,\n surfaceAlbedo,\n #endif\n #ifdef ENVIRONMENTBRDF\n NdotV,\n environmentBrdf,\n #endif\n #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\n AARoughnessFactors,\n ").concat(null == e ? void 0 : e._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == e ? void 0 : e._vReflectionInfosName, ",\n ").concat(null == e ? void 0 : e.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n reflectionOut.reflectionCoords,\n NdotVUnclamped,\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(RADIANCEOCCLUSION)\n seo,\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(").concat(null == e ? void 0 : e._define3DName, ")\n eho,\n #endif\n #endif\n sheenOut\n );\n\n #ifdef SHEEN_LINKWITHALBEDO\n surfaceAlbedo = sheenOut.surfaceAlbedo;\n #endif\n #endif\r\n")
  108639. }
  108640. ,
  108641. t.prototype._buildBlock = function(e) {
  108642. return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
  108643. this
  108644. }
  108645. ,
  108646. t.prototype._dumpPropertiesCode = function() {
  108647. var t = e.prototype._dumpPropertiesCode.call(this);
  108648. return (t += "".concat(this._codeVariableName, ".albedoScaling = ").concat(this.albedoScaling, ";\r\n")) + "".concat(this._codeVariableName, ".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo, ";\r\n")
  108649. }
  108650. ,
  108651. t.prototype.serialize = function() {
  108652. var t = e.prototype.serialize.call(this);
  108653. return t.albedoScaling = this.albedoScaling,
  108654. t.linkSheenWithAlbedo = this.linkSheenWithAlbedo,
  108655. t
  108656. }
  108657. ,
  108658. t.prototype._deserialize = function(t, i, n) {
  108659. e.prototype._deserialize.call(this, t, i, n),
  108660. this.albedoScaling = t.albedoScaling,
  108661. this.linkSheenWithAlbedo = t.linkSheenWithAlbedo
  108662. }
  108663. ,
  108664. k([Yp("Albedo scaling", Xp.Boolean, "PROPERTIES", {
  108665. notifiers: {
  108666. update: !0
  108667. }
  108668. })], t.prototype, "albedoScaling", void 0),
  108669. k([Yp("Link sheen with albedo", Xp.Boolean, "PROPERTIES", {
  108670. notifiers: {
  108671. update: !0
  108672. }
  108673. })], t.prototype, "linkSheenWithAlbedo", void 0),
  108674. t
  108675. }(Wp);
  108676. y("BABYLON.SheenBlock", Ig);
  108677. var Og = function(e) {
  108678. function t(i) {
  108679. var n = e.call(this, i, Dp.Fragment) || this;
  108680. return n._isUnique = !0,
  108681. n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
  108682. n.registerInput("direction", Op.Vector2, !0, Dp.Fragment),
  108683. n.registerInput("uv", Op.Vector2, !0),
  108684. n.registerInput("worldTangent", Op.Vector4, !0),
  108685. n.registerOutput("anisotropy", Op.Object, Dp.Fragment, new Bm("anisotropy",n,Vp.Output,t,"AnisotropyBlock")),
  108686. n
  108687. }
  108688. return U(t, e),
  108689. t.prototype.initialize = function(e) {
  108690. e._excludeVariableName("anisotropicOut"),
  108691. e._excludeVariableName("TBN")
  108692. }
  108693. ,
  108694. t.prototype.getClassName = function() {
  108695. return "AnisotropyBlock"
  108696. }
  108697. ,
  108698. Object.defineProperty(t.prototype, "intensity", {
  108699. get: function() {
  108700. return this._inputs[0]
  108701. },
  108702. enumerable: !1,
  108703. configurable: !0
  108704. }),
  108705. Object.defineProperty(t.prototype, "direction", {
  108706. get: function() {
  108707. return this._inputs[1]
  108708. },
  108709. enumerable: !1,
  108710. configurable: !0
  108711. }),
  108712. Object.defineProperty(t.prototype, "uv", {
  108713. get: function() {
  108714. return this._inputs[2]
  108715. },
  108716. enumerable: !1,
  108717. configurable: !0
  108718. }),
  108719. Object.defineProperty(t.prototype, "worldTangent", {
  108720. get: function() {
  108721. return this._inputs[3]
  108722. },
  108723. enumerable: !1,
  108724. configurable: !0
  108725. }),
  108726. Object.defineProperty(t.prototype, "anisotropy", {
  108727. get: function() {
  108728. return this._outputs[0]
  108729. },
  108730. enumerable: !1,
  108731. configurable: !0
  108732. }),
  108733. t.prototype._generateTBNSpace = function(e) {
  108734. var t = ""
  108735. , i = "//".concat(this.name)
  108736. , n = this.uv
  108737. , r = this.worldPositionConnectionPoint
  108738. , o = this.worldNormalConnectionPoint
  108739. , a = this.worldTangent;
  108740. n.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"),
  108741. e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  108742. var s = {
  108743. search: /defined\(TANGENT\)/g,
  108744. replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  108745. };
  108746. return a.isConnected && (t += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
  108747. t += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
  108748. t += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
  108749. t += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
  108750. t += "\n #if defined(".concat(a.isConnected ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n mat3 TBN = vTBN;\n #else\n mat3 TBN = cotangent_frame(").concat(o.associatedVariableName + ".xyz", ", ").concat("v_" + r.associatedVariableName + ".xyz", ", ").concat(n.isConnected ? n.associatedVariableName : "vec2(0.)", ", vec2(1., 1.));\n #endif\r\n"),
  108751. e._emitFunctionFromInclude("bumpFragmentMainFunctions", i, {
  108752. replaceStrings: [s]
  108753. }),
  108754. t
  108755. }
  108756. ,
  108757. t.prototype.getCode = function(e, t) {
  108758. void 0 === t && (t = !1);
  108759. var i = "";
  108760. t && (i += this._generateTBNSpace(e));
  108761. var n = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0"
  108762. , r = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
  108763. return i + "anisotropicOutParams anisotropicOut;\n anisotropicBlock(\n vec3(".concat(r, ", ").concat(n, "),\n #ifdef ANISOTROPIC_TEXTURE\n vec3(0.),\n #endif\n TBN,\n normalW,\n viewDirectionW,\n anisotropicOut\n );\r\n")
  108764. }
  108765. ,
  108766. t.prototype.prepareDefines = function(t, i, n) {
  108767. e.prototype.prepareDefines.call(this, t, i, n),
  108768. n.setValue("ANISOTROPIC", !0),
  108769. n.setValue("ANISOTROPIC_TEXTURE", !1, !0)
  108770. }
  108771. ,
  108772. t.prototype._buildBlock = function(e) {
  108773. return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
  108774. this
  108775. }
  108776. ,
  108777. t
  108778. }(Wp);
  108779. y("BABYLON.AnisotropyBlock", Og);
  108780. var Dg = function(e) {
  108781. function t(i) {
  108782. var n = e.call(this, i) || this;
  108783. return n.useSphericalHarmonics = !0,
  108784. n.forceIrradianceInFragment = !1,
  108785. n._isUnique = !0,
  108786. n.registerInput("position", Op.Vector3, !1, Dp.Vertex),
  108787. n.registerInput("world", Op.Matrix, !1, Dp.Vertex),
  108788. n.registerInput("color", Op.Color3, !0, Dp.Fragment),
  108789. n.registerOutput("reflection", Op.Object, Dp.Fragment, new Bm("reflection",n,Vp.Output,t,"ReflectionBlock")),
  108790. n
  108791. }
  108792. return U(t, e),
  108793. t.prototype.getClassName = function() {
  108794. return "ReflectionBlock"
  108795. }
  108796. ,
  108797. Object.defineProperty(t.prototype, "position", {
  108798. get: function() {
  108799. return this._inputs[0]
  108800. },
  108801. enumerable: !1,
  108802. configurable: !0
  108803. }),
  108804. Object.defineProperty(t.prototype, "worldPosition", {
  108805. get: function() {
  108806. return this.worldPositionConnectionPoint
  108807. },
  108808. enumerable: !1,
  108809. configurable: !0
  108810. }),
  108811. Object.defineProperty(t.prototype, "worldNormal", {
  108812. get: function() {
  108813. return this.worldNormalConnectionPoint
  108814. },
  108815. enumerable: !1,
  108816. configurable: !0
  108817. }),
  108818. Object.defineProperty(t.prototype, "world", {
  108819. get: function() {
  108820. return this._inputs[1]
  108821. },
  108822. enumerable: !1,
  108823. configurable: !0
  108824. }),
  108825. Object.defineProperty(t.prototype, "cameraPosition", {
  108826. get: function() {
  108827. return this.cameraPositionConnectionPoint
  108828. },
  108829. enumerable: !1,
  108830. configurable: !0
  108831. }),
  108832. Object.defineProperty(t.prototype, "view", {
  108833. get: function() {
  108834. return this.viewConnectionPoint
  108835. },
  108836. enumerable: !1,
  108837. configurable: !0
  108838. }),
  108839. Object.defineProperty(t.prototype, "color", {
  108840. get: function() {
  108841. return this._inputs[2]
  108842. },
  108843. enumerable: !1,
  108844. configurable: !0
  108845. }),
  108846. Object.defineProperty(t.prototype, "reflection", {
  108847. get: function() {
  108848. return this._outputs[0]
  108849. },
  108850. enumerable: !1,
  108851. configurable: !0
  108852. }),
  108853. Object.defineProperty(t.prototype, "hasTexture", {
  108854. get: function() {
  108855. return !!this._getTexture()
  108856. },
  108857. enumerable: !1,
  108858. configurable: !0
  108859. }),
  108860. Object.defineProperty(t.prototype, "reflectionColor", {
  108861. get: function() {
  108862. return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)"
  108863. },
  108864. enumerable: !1,
  108865. configurable: !0
  108866. }),
  108867. t.prototype._getTexture = function() {
  108868. return this.texture ? this.texture : this._scene.environmentTexture
  108869. }
  108870. ,
  108871. t.prototype.prepareDefines = function(t, i, n) {
  108872. e.prototype.prepareDefines.call(this, t, i, n);
  108873. var r = this._getTexture()
  108874. , o = r && r.getTextureMatrix;
  108875. n.setValue("REFLECTION", o, !0),
  108876. o && (n.setValue(this._defineLODReflectionAlpha, r.lodLevelInAlpha, !0),
  108877. n.setValue(this._defineLinearSpecularReflection, r.linearSpecularLOD, !0),
  108878. n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
  108879. n.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0),
  108880. n.setValue("GAMMAREFLECTION", r.gammaSpace, !0),
  108881. n.setValue("RGBDREFLECTION", r.isRGBD, !0),
  108882. r && r.coordinatesMode !== io.SKYBOX_MODE && r.isCube && (n.setValue("USESPHERICALFROMREFLECTIONMAP", !0),
  108883. n.setValue("USEIRRADIANCEMAP", !1),
  108884. this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? n.setValue("USESPHERICALINVERTEX", !1) : n.setValue("USESPHERICALINVERTEX", !0)))
  108885. }
  108886. ,
  108887. t.prototype.bind = function(t, i, n, r) {
  108888. e.prototype.bind.call(this, t, i, n);
  108889. var o = this._getTexture();
  108890. if (o && r) {
  108891. o.isCube ? t.setTexture(this._cubeSamplerName, o) : t.setTexture(this._2DSamplerName, o);
  108892. var a = o.getSize().width;
  108893. t.setFloat3(this._vReflectionMicrosurfaceInfosName, a, o.lodGenerationScale, o.lodGenerationOffset),
  108894. t.setFloat2(this._vReflectionFilteringInfoName, a, d.Log2(a));
  108895. var s = r.materialDefines
  108896. , l = o.sphericalPolynomial;
  108897. if (s.USESPHERICALFROMREFLECTIONMAP && l)
  108898. if (s.SPHERICAL_HARMONICS) {
  108899. var c = l.preScaledHarmonics;
  108900. t.setVector3("vSphericalL00", c.l00),
  108901. t.setVector3("vSphericalL1_1", c.l1_1),
  108902. t.setVector3("vSphericalL10", c.l10),
  108903. t.setVector3("vSphericalL11", c.l11),
  108904. t.setVector3("vSphericalL2_2", c.l2_2),
  108905. t.setVector3("vSphericalL2_1", c.l2_1),
  108906. t.setVector3("vSphericalL20", c.l20),
  108907. t.setVector3("vSphericalL21", c.l21),
  108908. t.setVector3("vSphericalL22", c.l22)
  108909. } else
  108910. t.setFloat3("vSphericalX", l.x.x, l.x.y, l.x.z),
  108911. t.setFloat3("vSphericalY", l.y.x, l.y.y, l.y.z),
  108912. t.setFloat3("vSphericalZ", l.z.x, l.z.y, l.z.z),
  108913. t.setFloat3("vSphericalXX_ZZ", l.xx.x - l.zz.x, l.xx.y - l.zz.y, l.xx.z - l.zz.z),
  108914. t.setFloat3("vSphericalYY_ZZ", l.yy.x - l.zz.x, l.yy.y - l.zz.y, l.yy.z - l.zz.z),
  108915. t.setFloat3("vSphericalZZ", l.zz.x, l.zz.y, l.zz.z),
  108916. t.setFloat3("vSphericalXY", l.xy.x, l.xy.y, l.xy.z),
  108917. t.setFloat3("vSphericalYZ", l.yz.x, l.yz.y, l.yz.z),
  108918. t.setFloat3("vSphericalZX", l.zx.x, l.zx.y, l.zx.z)
  108919. }
  108920. }
  108921. ,
  108922. t.prototype.handleVertexSide = function(t) {
  108923. var i = e.prototype.handleVertexSide.call(this, t);
  108924. t._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), {
  108925. replaceStrings: [{
  108926. search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
  108927. replace: ""
  108928. }, {
  108929. search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
  108930. replace: ""
  108931. }]
  108932. });
  108933. var n = t._getFreeVariableName("reflectionVector");
  108934. return this._vEnvironmentIrradianceName = t._getFreeVariableName("vEnvironmentIrradiance"),
  108935. t._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),
  108936. t._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"),
  108937. t._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"),
  108938. t._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"),
  108939. t._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"),
  108940. t._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"),
  108941. t._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"),
  108942. t._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"),
  108943. t._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"),
  108944. t._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"),
  108945. t._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0),
  108946. t._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0),
  108947. t._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0),
  108948. t._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  108949. t._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  108950. t._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0),
  108951. t._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0),
  108952. t._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0),
  108953. t._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0),
  108954. i + "#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n vec3 ".concat(n, " = vec3(").concat(this._reflectionMatrixName, " * vec4(normalize(").concat(this.worldNormal.associatedVariableName, ").xyz, 0)).xyz;\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(n, ".z *= -1.0;\n #endif\n ").concat(this._vEnvironmentIrradianceName, " = computeEnvironmentIrradiance(").concat(n, ");\n #endif\r\n")
  108955. }
  108956. ,
  108957. t.prototype.getCode = function(e, t) {
  108958. var i = "";
  108959. this.handleFragmentSideInits(e),
  108960. e._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), {
  108961. replaceStrings: [{
  108962. search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
  108963. replace: ""
  108964. }, {
  108965. search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
  108966. replace: ""
  108967. }]
  108968. }),
  108969. e._emitFunction("sampleReflection", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflection(s, c) textureCube(s, c)\n #else\n #define sampleReflection(s, c) texture2D(s, c)\n #endif\r\n"), "//".concat(this.name)),
  108970. e._emitFunction("sampleReflectionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n"), "//".concat(this.name));
  108971. var n = "\n vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {\n ".concat(this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0), "\n return ").concat(this._reflectionVectorName, ";\n }\r\n");
  108972. return e._emitFunction("computeReflectionCoordsPBR", n, "//".concat(this.name)),
  108973. this._vReflectionMicrosurfaceInfosName = e._getFreeVariableName("vReflectionMicrosurfaceInfos"),
  108974. e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"),
  108975. this._vReflectionInfosName = e._getFreeVariableName("vReflectionInfos"),
  108976. this._vReflectionFilteringInfoName = e._getFreeVariableName("vReflectionFilteringInfo"),
  108977. e._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"),
  108978. i + "#ifdef REFLECTION\n vec2 ".concat(this._vReflectionInfosName, " = vec2(1., 0.);\n\n reflectionOutParams reflectionOut;\n\n reflectionBlock(\n ").concat("v_" + this.worldPosition.associatedVariableName + ".xyz", ",\n ").concat(t, ",\n alphaG,\n ").concat(this._vReflectionMicrosurfaceInfosName, ",\n ").concat(this._vReflectionInfosName, ",\n ").concat(this.reflectionColor, ",\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #if defined(").concat(this._defineLODReflectionAlpha, ") && !defined(").concat(this._defineSkyboxName, ")\n NdotVUnclamped,\n #endif\n #ifdef ").concat(this._defineLinearSpecularReflection, "\n roughness,\n #endif\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n #endif\n #if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n ").concat(this._vEnvironmentIrradianceName, ",\n #endif\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n ").concat(this._reflectionMatrixName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler, // ** not handled **\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n ").concat(this._2DSamplerName, ",\n #endif\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(this._vReflectionFilteringInfoName, ",\n #endif\n reflectionOut\n );\n #endif\r\n")
  108979. }
  108980. ,
  108981. t.prototype._buildBlock = function(e) {
  108982. return this._scene = e.sharedData.scene,
  108983. e.target !== Dp.Fragment && (this._defineLODReflectionAlpha = e._getFreeDefineName("LODINREFLECTIONALPHA"),
  108984. this._defineLinearSpecularReflection = e._getFreeDefineName("LINEARSPECULARREFLECTION")),
  108985. this
  108986. }
  108987. ,
  108988. t.prototype._dumpPropertiesCode = function() {
  108989. var t = e.prototype._dumpPropertiesCode.call(this);
  108990. return this.texture && (t += "".concat(this._codeVariableName, ".texture.gammaSpace = ").concat(this.texture.gammaSpace, ";\r\n")),
  108991. (t += "".concat(this._codeVariableName, ".useSphericalHarmonics = ").concat(this.useSphericalHarmonics, ";\r\n")) + "".concat(this._codeVariableName, ".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment, ";\r\n")
  108992. }
  108993. ,
  108994. t.prototype.serialize = function() {
  108995. var t, i, n = e.prototype.serialize.call(this);
  108996. return n.useSphericalHarmonics = this.useSphericalHarmonics,
  108997. n.forceIrradianceInFragment = this.forceIrradianceInFragment,
  108998. n.gammaSpace = null === (i = null === (t = this.texture) || void 0 === t ? void 0 : t.gammaSpace) || void 0 === i || i,
  108999. n
  109000. }
  109001. ,
  109002. t.prototype._deserialize = function(t, i, n) {
  109003. e.prototype._deserialize.call(this, t, i, n),
  109004. this.useSphericalHarmonics = t.useSphericalHarmonics,
  109005. this.forceIrradianceInFragment = t.forceIrradianceInFragment,
  109006. this.texture && (this.texture.gammaSpace = t.gammaSpace)
  109007. }
  109008. ,
  109009. k([Yp("Spherical Harmonics", Xp.Boolean, "ADVANCED", {
  109010. notifiers: {
  109011. update: !0
  109012. }
  109013. })], t.prototype, "useSphericalHarmonics", void 0),
  109014. k([Yp("Force irradiance in fragment", Xp.Boolean, "ADVANCED", {
  109015. notifiers: {
  109016. update: !0
  109017. }
  109018. })], t.prototype, "forceIrradianceInFragment", void 0),
  109019. t
  109020. }(km);
  109021. y("BABYLON.ReflectionBlock", Dg);
  109022. var Ng = function(e) {
  109023. function t(i) {
  109024. var n = e.call(this, i, Dp.Fragment) || this;
  109025. return n.remapF0OnInterfaceChange = !0,
  109026. n._isUnique = !0,
  109027. n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
  109028. n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
  109029. n.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
  109030. n.registerInput("normalMapColor", Op.Color3, !0, Dp.Fragment),
  109031. n.registerInput("uv", Op.Vector2, !0, Dp.Fragment),
  109032. n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
  109033. n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
  109034. n.registerInput("tintThickness", Op.Float, !0, Dp.Fragment),
  109035. n.registerInput("worldTangent", Op.Vector4, !0),
  109036. n.registerOutput("clearcoat", Op.Object, Dp.Fragment, new Bm("clearcoat",n,Vp.Output,t,"ClearCoatBlock")),
  109037. n
  109038. }
  109039. return U(t, e),
  109040. t.prototype.initialize = function(e) {
  109041. e._excludeVariableName("clearcoatOut"),
  109042. e._excludeVariableName("vClearCoatParams"),
  109043. e._excludeVariableName("vClearCoatTintParams"),
  109044. e._excludeVariableName("vClearCoatRefractionParams"),
  109045. e._excludeVariableName("vClearCoatTangentSpaceParams")
  109046. }
  109047. ,
  109048. t.prototype.getClassName = function() {
  109049. return "ClearCoatBlock"
  109050. }
  109051. ,
  109052. Object.defineProperty(t.prototype, "intensity", {
  109053. get: function() {
  109054. return this._inputs[0]
  109055. },
  109056. enumerable: !1,
  109057. configurable: !0
  109058. }),
  109059. Object.defineProperty(t.prototype, "roughness", {
  109060. get: function() {
  109061. return this._inputs[1]
  109062. },
  109063. enumerable: !1,
  109064. configurable: !0
  109065. }),
  109066. Object.defineProperty(t.prototype, "indexOfRefraction", {
  109067. get: function() {
  109068. return this._inputs[2]
  109069. },
  109070. enumerable: !1,
  109071. configurable: !0
  109072. }),
  109073. Object.defineProperty(t.prototype, "normalMapColor", {
  109074. get: function() {
  109075. return this._inputs[3]
  109076. },
  109077. enumerable: !1,
  109078. configurable: !0
  109079. }),
  109080. Object.defineProperty(t.prototype, "uv", {
  109081. get: function() {
  109082. return this._inputs[4]
  109083. },
  109084. enumerable: !1,
  109085. configurable: !0
  109086. }),
  109087. Object.defineProperty(t.prototype, "tintColor", {
  109088. get: function() {
  109089. return this._inputs[5]
  109090. },
  109091. enumerable: !1,
  109092. configurable: !0
  109093. }),
  109094. Object.defineProperty(t.prototype, "tintAtDistance", {
  109095. get: function() {
  109096. return this._inputs[6]
  109097. },
  109098. enumerable: !1,
  109099. configurable: !0
  109100. }),
  109101. Object.defineProperty(t.prototype, "tintThickness", {
  109102. get: function() {
  109103. return this._inputs[7]
  109104. },
  109105. enumerable: !1,
  109106. configurable: !0
  109107. }),
  109108. Object.defineProperty(t.prototype, "worldTangent", {
  109109. get: function() {
  109110. return this._inputs[8]
  109111. },
  109112. enumerable: !1,
  109113. configurable: !0
  109114. }),
  109115. Object.defineProperty(t.prototype, "clearcoat", {
  109116. get: function() {
  109117. return this._outputs[0]
  109118. },
  109119. enumerable: !1,
  109120. configurable: !0
  109121. }),
  109122. t.prototype.autoConfigure = function() {
  109123. if (!this.intensity.isConnected) {
  109124. var e = new tf("ClearCoat intensity",Dp.Fragment,Op.Float);
  109125. e.value = 1,
  109126. e.output.connectTo(this.intensity)
  109127. }
  109128. }
  109129. ,
  109130. t.prototype.prepareDefines = function(t, i, n) {
  109131. e.prototype.prepareDefines.call(this, t, i, n),
  109132. n.setValue("CLEARCOAT", !0),
  109133. n.setValue("CLEARCOAT_TEXTURE", !1, !0),
  109134. n.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
  109135. n.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0),
  109136. n.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0),
  109137. n.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === Qd._DefaultIndexOfRefraction, !0),
  109138. n.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0)
  109139. }
  109140. ,
  109141. t.prototype.bind = function(t, i, n) {
  109142. var r, o;
  109143. e.prototype.bind.call(this, t, i, n);
  109144. var a = null !== (o = null === (r = this.indexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.value) && void 0 !== o ? o : Qd._DefaultIndexOfRefraction
  109145. , s = 1 - a
  109146. , l = 1 + a
  109147. , c = Math.pow(-s / l, 2)
  109148. , u = 1 / a;
  109149. t.setFloat4("vClearCoatRefractionParams", c, u, s, l);
  109150. var h = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null
  109151. , d = (null == h ? void 0 : h.perturbedNormal.isConnected) ? h.perturbedNormal.connectedPoint.ownerBlock : null;
  109152. this._scene._mirroredCameraPosition ? t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? 1 : -1, (null == d ? void 0 : d.invertY) ? 1 : -1) : t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? -1 : 1, (null == d ? void 0 : d.invertY) ? -1 : 1)
  109153. }
  109154. ,
  109155. t.prototype._generateTBNSpace = function(e, t, i) {
  109156. var n = ""
  109157. , r = "//".concat(this.name)
  109158. , o = this.worldTangent;
  109159. e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
  109160. var a = {
  109161. search: /defined\(TANGENT\)/g,
  109162. replace: o.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
  109163. };
  109164. return o.isConnected && (n += "vec3 tbnNormal = normalize(".concat(i, ".xyz);\r\n"),
  109165. n += "vec3 tbnTangent = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
  109166. n += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
  109167. n += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
  109168. e._emitFunctionFromInclude("bumpFragmentMainFunctions", r, {
  109169. replaceStrings: [a]
  109170. }),
  109171. n
  109172. }
  109173. ,
  109174. t.GetCode = function(e, t, i, n, r, o, a) {
  109175. var s = ""
  109176. , l = (null == t ? void 0 : t.intensity.isConnected) ? t.intensity.associatedVariableName : "1."
  109177. , c = (null == t ? void 0 : t.roughness.isConnected) ? t.roughness.associatedVariableName : "0."
  109178. , u = (null == t ? void 0 : t.normalMapColor.isConnected) ? t.normalMapColor.associatedVariableName : "vec3(0.)"
  109179. , h = (null == t ? void 0 : t.uv.isConnected) ? t.uv.associatedVariableName : "vec2(0.)"
  109180. , d = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)"
  109181. , p = (null == t ? void 0 : t.tintThickness.isConnected) ? t.tintThickness.associatedVariableName : "1."
  109182. , f = (null == t ? void 0 : t.tintAtDistance.isConnected) ? t.tintAtDistance.associatedVariableName : "1.";
  109183. return t && (e._emitUniformFromString("vClearCoatRefractionParams", "vec4"),
  109184. e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")),
  109185. r && t && (s += t._generateTBNSpace(e, n, a),
  109186. o = t.worldTangent.isConnected),
  109187. s + "clearcoatOutParams clearcoatOut;\n\n #ifdef CLEARCOAT\n vec2 vClearCoatParams = vec2(".concat(l, ", ").concat(c, ");\n vec4 vClearCoatTintParams = vec4(").concat(d, ", ").concat(p, ");\n\n clearcoatBlock(\n ").concat(n, ".xyz,\n geometricNormalW,\n viewDirectionW,\n vClearCoatParams,\n specularEnvironmentR0,\n #ifdef CLEARCOAT_TEXTURE\n vec2(0.),\n #endif\n #ifdef CLEARCOAT_TINT\n vClearCoatTintParams,\n ").concat(f, ",\n vClearCoatRefractionParams,\n #ifdef CLEARCOAT_TINT_TEXTURE\n ").concat("vec4(0.)", ",\n #endif\n #endif\n #ifdef CLEARCOAT_BUMP\n vec2(0., 1.),\n vec4(").concat(u, ", 0.),\n ").concat(h, ",\n #if defined(").concat(o ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n vTBN,\n #else\n vClearCoatTangentSpaceParams,\n #endif\n #ifdef OBJECTSPACE_NORMALMAP\n normalMatrix,\n #endif\n #endif\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\n faceNormal,\n #endif\n #ifdef REFLECTION\n ").concat(null == i ? void 0 : i._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == i ? void 0 : i._vReflectionInfosName, ",\n ").concat(null == i ? void 0 : i.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #endif\n #endif\n #if defined(ENVIRONMENTBRDF) && !defined(").concat(null == i ? void 0 : i._defineSkyboxName, ")\n #ifdef RADIANCEOCCLUSION\n ambientMonochrome,\n #endif\n #endif\n #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\n (gl_FrontFacing ? 1. : -1.),\n #endif\n clearcoatOut\n );\n #else\n clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;\n #endif\r\n")
  109188. }
  109189. ,
  109190. t.prototype._buildBlock = function(e) {
  109191. return this._scene = e.sharedData.scene,
  109192. e.target === Dp.Fragment && (e.sharedData.bindableBlocks.push(this),
  109193. e.sharedData.blocksWithDefines.push(this)),
  109194. this
  109195. }
  109196. ,
  109197. t.prototype._dumpPropertiesCode = function() {
  109198. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange, ";\r\n")
  109199. }
  109200. ,
  109201. t.prototype.serialize = function() {
  109202. var t = e.prototype.serialize.call(this);
  109203. return t.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange,
  109204. t
  109205. }
  109206. ,
  109207. t.prototype._deserialize = function(t, i, n) {
  109208. var r;
  109209. e.prototype._deserialize.call(this, t, i, n),
  109210. this.remapF0OnInterfaceChange = null === (r = t.remapF0OnInterfaceChange) || void 0 === r || r
  109211. }
  109212. ,
  109213. k([Yp("Remap F0 on interface change", Xp.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0),
  109214. t
  109215. }(Wp);
  109216. y("BABYLON.ClearCoatBlock", Ng);
  109217. var Lg = function(e) {
  109218. function t(i) {
  109219. var n = e.call(this, i, Dp.Fragment) || this;
  109220. return n.linkRefractionWithTransparency = !1,
  109221. n.invertRefractionY = !1,
  109222. n.useThicknessAsDepth = !1,
  109223. n._isUnique = !0,
  109224. n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
  109225. n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
  109226. n.registerInput("volumeIndexOfRefraction", Op.Float, !0, Dp.Fragment),
  109227. n.registerOutput("refraction", Op.Object, Dp.Fragment, new Bm("refraction",n,Vp.Output,t,"RefractionBlock")),
  109228. n
  109229. }
  109230. return U(t, e),
  109231. t.prototype.initialize = function(e) {
  109232. e._excludeVariableName("vRefractionPosition"),
  109233. e._excludeVariableName("vRefractionSize")
  109234. }
  109235. ,
  109236. t.prototype.getClassName = function() {
  109237. return "RefractionBlock"
  109238. }
  109239. ,
  109240. Object.defineProperty(t.prototype, "intensity", {
  109241. get: function() {
  109242. return this._inputs[0]
  109243. },
  109244. enumerable: !1,
  109245. configurable: !0
  109246. }),
  109247. Object.defineProperty(t.prototype, "tintAtDistance", {
  109248. get: function() {
  109249. return this._inputs[1]
  109250. },
  109251. enumerable: !1,
  109252. configurable: !0
  109253. }),
  109254. Object.defineProperty(t.prototype, "volumeIndexOfRefraction", {
  109255. get: function() {
  109256. return this._inputs[2]
  109257. },
  109258. enumerable: !1,
  109259. configurable: !0
  109260. }),
  109261. Object.defineProperty(t.prototype, "view", {
  109262. get: function() {
  109263. return this.viewConnectionPoint
  109264. },
  109265. enumerable: !1,
  109266. configurable: !0
  109267. }),
  109268. Object.defineProperty(t.prototype, "refraction", {
  109269. get: function() {
  109270. return this._outputs[0]
  109271. },
  109272. enumerable: !1,
  109273. configurable: !0
  109274. }),
  109275. Object.defineProperty(t.prototype, "hasTexture", {
  109276. get: function() {
  109277. return !!this._getTexture()
  109278. },
  109279. enumerable: !1,
  109280. configurable: !0
  109281. }),
  109282. t.prototype._getTexture = function() {
  109283. return this.texture ? this.texture : this._scene.environmentTexture
  109284. }
  109285. ,
  109286. t.prototype.autoConfigure = function(e) {
  109287. if (!this.intensity.isConnected) {
  109288. var t = new tf("Refraction intensity",Dp.Fragment,Op.Float);
  109289. t.value = 1,
  109290. t.output.connectTo(this.intensity)
  109291. }
  109292. if (this.view && !this.view.isConnected) {
  109293. var i = e.getInputBlockByPredicate((function(e) {
  109294. return e.systemValue === Qp.View
  109295. }
  109296. ));
  109297. i || (i = new tf("view")).setAsSystemValue(Qp.View),
  109298. i.output.connectTo(this.view)
  109299. }
  109300. }
  109301. ,
  109302. t.prototype.prepareDefines = function(t, i, n) {
  109303. e.prototype.prepareDefines.call(this, t, i, n);
  109304. var r = this._getTexture()
  109305. , o = r && r.getTextureMatrix;
  109306. n.setValue("SS_REFRACTION", o, !0),
  109307. o && (n.setValue(this._define3DName, r.isCube, !0),
  109308. n.setValue(this._defineLODRefractionAlpha, r.lodLevelInAlpha, !0),
  109309. n.setValue(this._defineLinearSpecularRefraction, r.linearSpecularLOD, !0),
  109310. n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
  109311. n.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0),
  109312. n.setValue("SS_GAMMAREFRACTION", r.gammaSpace, !0),
  109313. n.setValue("SS_RGBDREFRACTION", r.isRGBD, !0),
  109314. n.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!r.boundingBoxSize, !0),
  109315. n.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0))
  109316. }
  109317. ,
  109318. t.prototype.isReady = function() {
  109319. var e = this._getTexture();
  109320. return !(e && !e.isReadyOrNotBlocking())
  109321. }
  109322. ,
  109323. t.prototype.bind = function(t, i, n) {
  109324. var r, o, a, s;
  109325. e.prototype.bind.call(this, t, i, n);
  109326. var l = this._getTexture();
  109327. if (l) {
  109328. l.isCube ? t.setTexture(this._cubeSamplerName, l) : t.setTexture(this._2DSamplerName, l),
  109329. t.setMatrix(this._refractionMatrixName, l.getReflectionTextureMatrix());
  109330. var c = 1;
  109331. l.isCube || l.depth && (c = l.depth);
  109332. var u = null !== (s = null !== (o = null === (r = this.volumeIndexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.value) && void 0 !== o ? o : null === (a = this.indexOfRefractionConnectionPoint.connectInputBlock) || void 0 === a ? void 0 : a.value) && void 0 !== s ? s : 1.5;
  109333. t.setFloat4(this._vRefractionInfosName, l.level, 1 / u, c, this.invertRefractionY ? -1 : 1),
  109334. t.setFloat4(this._vRefractionMicrosurfaceInfosName, l.getSize().width, l.lodGenerationScale, l.lodGenerationOffset, 1 / u);
  109335. var h = l.getSize().width;
  109336. if (t.setFloat2(this._vRefractionFilteringInfoName, h, d.Log2(h)),
  109337. l.boundingBoxSize) {
  109338. var p = l;
  109339. t.setVector3("vRefractionPosition", p.boundingBoxPosition),
  109340. t.setVector3("vRefractionSize", p.boundingBoxSize)
  109341. }
  109342. }
  109343. }
  109344. ,
  109345. t.prototype.getCode = function(e) {
  109346. return e.sharedData.blockingBlocks.push(this),
  109347. e.sharedData.textureBlocks.push(this),
  109348. this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"),
  109349. e.samplers.push(this._cubeSamplerName),
  109350. this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"),
  109351. e.samplers.push(this._2DSamplerName),
  109352. this._define3DName = e._getFreeDefineName("SS_REFRACTIONMAP_3D"),
  109353. e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\r\n"),
  109354. e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
  109355. e._samplerDeclaration += "#else\r\n",
  109356. e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
  109357. e._samplerDeclaration += "#endif\r\n",
  109358. e.sharedData.blocksWithDefines.push(this),
  109359. e.sharedData.bindableBlocks.push(this),
  109360. this._defineLODRefractionAlpha = e._getFreeDefineName("SS_LODINREFRACTIONALPHA"),
  109361. this._defineLinearSpecularRefraction = e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),
  109362. this._defineOppositeZ = e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),
  109363. this._refractionMatrixName = e._getFreeVariableName("refractionMatrix"),
  109364. e._emitUniformFromString(this._refractionMatrixName, "mat4"),
  109365. e._emitFunction("sampleRefraction", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefraction(s, c) textureCube(s, c)\n #else\n #define sampleRefraction(s, c) texture2D(s, c)\n #endif\r\n"), "//".concat(this.name)),
  109366. e._emitFunction("sampleRefractionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n"), "//".concat(this.name)),
  109367. this._vRefractionMicrosurfaceInfosName = e._getFreeVariableName("vRefractionMicrosurfaceInfos"),
  109368. e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"),
  109369. this._vRefractionInfosName = e._getFreeVariableName("vRefractionInfos"),
  109370. e._emitUniformFromString(this._vRefractionInfosName, "vec4"),
  109371. this._vRefractionFilteringInfoName = e._getFreeVariableName("vRefractionFilteringInfo"),
  109372. e._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"),
  109373. e._emitUniformFromString("vRefractionPosition", "vec3"),
  109374. e._emitUniformFromString("vRefractionSize", "vec3"),
  109375. ""
  109376. }
  109377. ,
  109378. t.prototype._buildBlock = function(e) {
  109379. return this._scene = e.sharedData.scene,
  109380. this
  109381. }
  109382. ,
  109383. t.prototype._dumpPropertiesCode = function() {
  109384. var t = e.prototype._dumpPropertiesCode.call(this);
  109385. return this.texture && (t = this.texture.isCube ? "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '");\r\n') : "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '");\r\n'),
  109386. t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")),
  109387. t += "".concat(this._codeVariableName, ".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency, ";\r\n"),
  109388. (t += "".concat(this._codeVariableName, ".invertRefractionY = ").concat(this.invertRefractionY, ";\r\n")) + "".concat(this._codeVariableName, ".useThicknessAsDepth = ").concat(this.useThicknessAsDepth, ";\r\n")
  109389. }
  109390. ,
  109391. t.prototype.serialize = function() {
  109392. var t = e.prototype.serialize.call(this);
  109393. return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
  109394. t.linkRefractionWithTransparency = this.linkRefractionWithTransparency,
  109395. t.invertRefractionY = this.invertRefractionY,
  109396. t.useThicknessAsDepth = this.useThicknessAsDepth,
  109397. t
  109398. }
  109399. ,
  109400. t.prototype._deserialize = function(t, i, n) {
  109401. e.prototype._deserialize.call(this, t, i, n),
  109402. t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
  109403. t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n)),
  109404. this.linkRefractionWithTransparency = t.linkRefractionWithTransparency,
  109405. this.invertRefractionY = t.invertRefractionY,
  109406. this.useThicknessAsDepth = !!t.useThicknessAsDepth
  109407. }
  109408. ,
  109409. k([Yp("Link refraction to transparency", Xp.Boolean, "ADVANCED", {
  109410. notifiers: {
  109411. update: !0
  109412. }
  109413. })], t.prototype, "linkRefractionWithTransparency", void 0),
  109414. k([Yp("Invert refraction Y", Xp.Boolean, "ADVANCED", {
  109415. notifiers: {
  109416. update: !0
  109417. }
  109418. })], t.prototype, "invertRefractionY", void 0),
  109419. k([Yp("Use thickness as depth", Xp.Boolean, "ADVANCED", {
  109420. notifiers: {
  109421. update: !0
  109422. }
  109423. })], t.prototype, "useThicknessAsDepth", void 0),
  109424. t
  109425. }(Wp);
  109426. y("BABYLON.RefractionBlock", Lg);
  109427. var Fg = function(e) {
  109428. function t(i) {
  109429. var n = e.call(this, i, Dp.Fragment) || this;
  109430. return n._isUnique = !0,
  109431. n.registerInput("thickness", Op.Float, !1, Dp.Fragment),
  109432. n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
  109433. n.registerInput("translucencyIntensity", Op.Float, !0, Dp.Fragment),
  109434. n.registerInput("translucencyDiffusionDist", Op.Color3, !0, Dp.Fragment),
  109435. n.registerInput("refraction", Op.Object, !0, Dp.Fragment, new Bm("refraction",n,Vp.Input,Lg,"RefractionBlock")),
  109436. n.registerOutput("subsurface", Op.Object, Dp.Fragment, new Bm("subsurface",n,Vp.Output,t,"SubSurfaceBlock")),
  109437. n
  109438. }
  109439. return U(t, e),
  109440. t.prototype.initialize = function(e) {
  109441. e._excludeVariableName("subSurfaceOut"),
  109442. e._excludeVariableName("vThicknessParam"),
  109443. e._excludeVariableName("vTintColor"),
  109444. e._excludeVariableName("vSubSurfaceIntensity")
  109445. }
  109446. ,
  109447. t.prototype.getClassName = function() {
  109448. return "SubSurfaceBlock"
  109449. }
  109450. ,
  109451. Object.defineProperty(t.prototype, "thickness", {
  109452. get: function() {
  109453. return this._inputs[0]
  109454. },
  109455. enumerable: !1,
  109456. configurable: !0
  109457. }),
  109458. Object.defineProperty(t.prototype, "tintColor", {
  109459. get: function() {
  109460. return this._inputs[1]
  109461. },
  109462. enumerable: !1,
  109463. configurable: !0
  109464. }),
  109465. Object.defineProperty(t.prototype, "translucencyIntensity", {
  109466. get: function() {
  109467. return this._inputs[2]
  109468. },
  109469. enumerable: !1,
  109470. configurable: !0
  109471. }),
  109472. Object.defineProperty(t.prototype, "translucencyDiffusionDist", {
  109473. get: function() {
  109474. return this._inputs[3]
  109475. },
  109476. enumerable: !1,
  109477. configurable: !0
  109478. }),
  109479. Object.defineProperty(t.prototype, "refraction", {
  109480. get: function() {
  109481. return this._inputs[4]
  109482. },
  109483. enumerable: !1,
  109484. configurable: !0
  109485. }),
  109486. Object.defineProperty(t.prototype, "subsurface", {
  109487. get: function() {
  109488. return this._outputs[0]
  109489. },
  109490. enumerable: !1,
  109491. configurable: !0
  109492. }),
  109493. t.prototype.autoConfigure = function() {
  109494. if (!this.thickness.isConnected) {
  109495. var e = new tf("SubSurface thickness",Dp.Fragment,Op.Float);
  109496. e.value = 0,
  109497. e.output.connectTo(this.thickness)
  109498. }
  109499. }
  109500. ,
  109501. t.prototype.prepareDefines = function(t, i, n) {
  109502. e.prototype.prepareDefines.call(this, t, i, n);
  109503. var r = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
  109504. n.setValue("SUBSURFACE", r || this.refraction.isConnected, !0),
  109505. n.setValue("SS_TRANSLUCENCY", r, !0),
  109506. n.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0),
  109507. n.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0),
  109508. n.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0),
  109509. n.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0),
  109510. n.setValue("SS_USE_GLTF_TEXTURES", !1, !0)
  109511. }
  109512. ,
  109513. t.GetCode = function(e, t, i, n) {
  109514. var r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b = "", T = (null == t ? void 0 : t.thickness.isConnected) ? t.thickness.associatedVariableName : "0.", E = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)", S = (null == t ? void 0 : t.translucencyIntensity.isConnected) ? null == t ? void 0 : t.translucencyIntensity.associatedVariableName : "1.", A = (null == t ? void 0 : t.translucencyDiffusionDist.isConnected) ? null == t ? void 0 : t.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", x = (null == t ? void 0 : t.refraction.isConnected) ? null === (r = null == t ? void 0 : t.refraction.connectedPoint) || void 0 === r ? void 0 : r.ownerBlock : null, R = (null == x ? void 0 : x.tintAtDistance.isConnected) ? x.tintAtDistance.associatedVariableName : "1.", C = (null == x ? void 0 : x.intensity.isConnected) ? x.intensity.associatedVariableName : "1.", P = (null == x ? void 0 : x.view.isConnected) ? x.view.associatedVariableName : "";
  109515. return (b += null !== (o = null == x ? void 0 : x.getCode(e)) && void 0 !== o ? o : "") + "subSurfaceOutParams subSurfaceOut;\n\n #ifdef SUBSURFACE\n vec2 vThicknessParam = vec2(0., ".concat(T, ");\n vec4 vTintColor = vec4(").concat(E, ", ").concat(R, ");\n vec3 vSubSurfaceIntensity = vec3(").concat(C, ", ").concat(S, ", 0.);\n\n subSurfaceBlock(\n vSubSurfaceIntensity,\n vThicknessParam,\n vTintColor,\n normalW,\n specularEnvironmentReflectance,\n #ifdef SS_THICKNESSANDMASK_TEXTURE\n vec4(0.),\n #endif\n #ifdef REFLECTION\n #ifdef SS_TRANSLUCENCY\n ").concat(null == i ? void 0 : i._reflectionMatrixName, ",\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n reflectionOut.irradianceVector,\n #endif\n #if defined(REALTIME_FILTERING)\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._vReflectionFilteringInfoName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler,\n #endif\n #endif\n #endif\n #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\n surfaceAlbedo,\n #endif\n #ifdef SS_REFRACTION\n ").concat(n, ".xyz,\n viewDirectionW,\n ").concat(P, ",\n ").concat(null !== (a = null == x ? void 0 : x._vRefractionInfosName) && void 0 !== a ? a : "", ",\n ").concat(null !== (s = null == x ? void 0 : x._refractionMatrixName) && void 0 !== s ? s : "", ",\n ").concat(null !== (l = null == x ? void 0 : x._vRefractionMicrosurfaceInfosName) && void 0 !== l ? l : "", ",\n vLightingIntensity,\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha,\n #endif\n #ifdef ").concat(null !== (c = null == x ? void 0 : x._defineLODRefractionAlpha) && void 0 !== c ? c : "IGNORE", "\n NdotVUnclamped,\n #endif\n #ifdef ").concat(null !== (u = null == x ? void 0 : x._defineLinearSpecularRefraction) && void 0 !== u ? u : "IGNORE", "\n roughness,\n #endif\n alphaG,\n #ifdef ").concat(null !== (h = null == x ? void 0 : x._define3DName) && void 0 !== h ? h : "IGNORE", "\n ").concat(null !== (d = null == x ? void 0 : x._cubeSamplerName) && void 0 !== d ? d : "", ",\n #else\n ").concat(null !== (p = null == x ? void 0 : x._2DSamplerName) && void 0 !== p ? p : "", ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null !== (f = null == x ? void 0 : x._define3DName) && void 0 !== f ? f : "IGNORE", "\n ").concat(null !== (_ = null == x ? void 0 : x._cubeSamplerName) && void 0 !== _ ? _ : "", ",\n ").concat(null !== (m = null == x ? void 0 : x._cubeSamplerName) && void 0 !== m ? m : "", ",\n #else\n ").concat(null !== (g = null == x ? void 0 : x._2DSamplerName) && void 0 !== g ? g : "", ",\n ").concat(null !== (v = null == x ? void 0 : x._2DSamplerName) && void 0 !== v ? v : "", ",\n #endif\n #endif\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(null !== (y = null == x ? void 0 : x._vRefractionFilteringInfoName) && void 0 !== y ? y : "", ",\n #endif\n #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\n vRefractionPosition,\n vRefractionSize,\n #endif\n #endif\n #ifdef SS_TRANSLUCENCY\n ").concat(A, ",\n #endif\n subSurfaceOut\n );\n\n #ifdef SS_REFRACTION\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha = subSurfaceOut.alpha;\n #endif\n #endif\n #else\n subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;\n #endif\r\n")
  109516. }
  109517. ,
  109518. t.prototype._buildBlock = function(e) {
  109519. return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
  109520. this
  109521. }
  109522. ,
  109523. t
  109524. }(Wp);
  109525. y("BABYLON.SubSurfaceBlock", Fg);
  109526. var wg = {
  109527. ambientClr: ["finalAmbient", ""],
  109528. diffuseDir: ["finalDiffuse", ""],
  109529. specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"],
  109530. clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"],
  109531. sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"],
  109532. diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"],
  109533. specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"],
  109534. clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"],
  109535. sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"],
  109536. refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"],
  109537. lighting: ["finalColor.rgb", ""],
  109538. shadow: ["shadow", ""],
  109539. alpha: ["alpha", ""]
  109540. }
  109541. , Bg = function(e) {
  109542. function t(t) {
  109543. var i = e.call(this, t, Dp.VertexAndFragment) || this;
  109544. return i._environmentBRDFTexture = null,
  109545. i._metallicReflectanceColor = D.White(),
  109546. i._metallicF0Factor = 1,
  109547. i.directIntensity = 1,
  109548. i.environmentIntensity = 1,
  109549. i.specularIntensity = 1,
  109550. i.lightFalloff = 0,
  109551. i.useAlphaTest = !1,
  109552. i.alphaTestCutoff = .5,
  109553. i.useAlphaBlending = !1,
  109554. i.useRadianceOverAlpha = !0,
  109555. i.useSpecularOverAlpha = !0,
  109556. i.enableSpecularAntiAliasing = !1,
  109557. i.realTimeFiltering = !1,
  109558. i.realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW,
  109559. i.useEnergyConservation = !0,
  109560. i.useRadianceOcclusion = !0,
  109561. i.useHorizonOcclusion = !0,
  109562. i.unlit = !1,
  109563. i.forceNormalForward = !1,
  109564. i.debugMode = 0,
  109565. i.debugLimit = 0,
  109566. i.debugFactor = 1,
  109567. i._isUnique = !0,
  109568. i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
  109569. i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
  109570. i.registerInput("view", Op.Matrix, !1),
  109571. i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
  109572. i.registerInput("perturbedNormal", Op.Vector4, !0, Dp.Fragment),
  109573. i.registerInput("baseColor", Op.Color3, !0, Dp.Fragment),
  109574. i.registerInput("metallic", Op.Float, !1, Dp.Fragment),
  109575. i.registerInput("roughness", Op.Float, !1, Dp.Fragment),
  109576. i.registerInput("ambientOcc", Op.Float, !0, Dp.Fragment),
  109577. i.registerInput("opacity", Op.Float, !0, Dp.Fragment),
  109578. i.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
  109579. i.registerInput("ambientColor", Op.Color3, !0, Dp.Fragment),
  109580. i.registerInput("reflection", Op.Object, !0, Dp.Fragment, new Bm("reflection",i,Vp.Input,Dg,"ReflectionBlock")),
  109581. i.registerInput("clearcoat", Op.Object, !0, Dp.Fragment, new Bm("clearcoat",i,Vp.Input,Ng,"ClearCoatBlock")),
  109582. i.registerInput("sheen", Op.Object, !0, Dp.Fragment, new Bm("sheen",i,Vp.Input,Ig,"SheenBlock")),
  109583. i.registerInput("subsurface", Op.Object, !0, Dp.Fragment, new Bm("subsurface",i,Vp.Input,Fg,"SubSurfaceBlock")),
  109584. i.registerInput("anisotropy", Op.Object, !0, Dp.Fragment, new Bm("anisotropy",i,Vp.Input,Og,"AnisotropyBlock")),
  109585. i.registerOutput("ambientClr", Op.Color3, Dp.Fragment),
  109586. i.registerOutput("diffuseDir", Op.Color3, Dp.Fragment),
  109587. i.registerOutput("specularDir", Op.Color3, Dp.Fragment),
  109588. i.registerOutput("clearcoatDir", Op.Color3, Dp.Fragment),
  109589. i.registerOutput("sheenDir", Op.Color3, Dp.Fragment),
  109590. i.registerOutput("diffuseInd", Op.Color3, Dp.Fragment),
  109591. i.registerOutput("specularInd", Op.Color3, Dp.Fragment),
  109592. i.registerOutput("clearcoatInd", Op.Color3, Dp.Fragment),
  109593. i.registerOutput("sheenInd", Op.Color3, Dp.Fragment),
  109594. i.registerOutput("refraction", Op.Color3, Dp.Fragment),
  109595. i.registerOutput("lighting", Op.Color3, Dp.Fragment),
  109596. i.registerOutput("shadow", Op.Float, Dp.Fragment),
  109597. i.registerOutput("alpha", Op.Float, Dp.Fragment),
  109598. i
  109599. }
  109600. return U(t, e),
  109601. t.prototype.initialize = function(e) {
  109602. e._excludeVariableName("vLightingIntensity"),
  109603. e._excludeVariableName("geometricNormalW"),
  109604. e._excludeVariableName("normalW"),
  109605. e._excludeVariableName("faceNormal"),
  109606. e._excludeVariableName("albedoOpacityOut"),
  109607. e._excludeVariableName("surfaceAlbedo"),
  109608. e._excludeVariableName("alpha"),
  109609. e._excludeVariableName("aoOut"),
  109610. e._excludeVariableName("baseColor"),
  109611. e._excludeVariableName("reflectivityOut"),
  109612. e._excludeVariableName("microSurface"),
  109613. e._excludeVariableName("roughness"),
  109614. e._excludeVariableName("NdotVUnclamped"),
  109615. e._excludeVariableName("NdotV"),
  109616. e._excludeVariableName("alphaG"),
  109617. e._excludeVariableName("AARoughnessFactors"),
  109618. e._excludeVariableName("environmentBrdf"),
  109619. e._excludeVariableName("ambientMonochrome"),
  109620. e._excludeVariableName("seo"),
  109621. e._excludeVariableName("eho"),
  109622. e._excludeVariableName("environmentRadiance"),
  109623. e._excludeVariableName("irradianceVector"),
  109624. e._excludeVariableName("environmentIrradiance"),
  109625. e._excludeVariableName("diffuseBase"),
  109626. e._excludeVariableName("specularBase"),
  109627. e._excludeVariableName("preInfo"),
  109628. e._excludeVariableName("info"),
  109629. e._excludeVariableName("shadow"),
  109630. e._excludeVariableName("finalDiffuse"),
  109631. e._excludeVariableName("finalAmbient"),
  109632. e._excludeVariableName("ambientOcclusionForDirectDiffuse"),
  109633. e._excludeVariableName("finalColor"),
  109634. e._excludeVariableName("vClipSpacePosition"),
  109635. e._excludeVariableName("vDebugMode")
  109636. }
  109637. ,
  109638. t.prototype.getClassName = function() {
  109639. return "PBRMetallicRoughnessBlock"
  109640. }
  109641. ,
  109642. Object.defineProperty(t.prototype, "worldPosition", {
  109643. get: function() {
  109644. return this._inputs[0]
  109645. },
  109646. enumerable: !1,
  109647. configurable: !0
  109648. }),
  109649. Object.defineProperty(t.prototype, "worldNormal", {
  109650. get: function() {
  109651. return this._inputs[1]
  109652. },
  109653. enumerable: !1,
  109654. configurable: !0
  109655. }),
  109656. Object.defineProperty(t.prototype, "view", {
  109657. get: function() {
  109658. return this._inputs[2]
  109659. },
  109660. enumerable: !1,
  109661. configurable: !0
  109662. }),
  109663. Object.defineProperty(t.prototype, "cameraPosition", {
  109664. get: function() {
  109665. return this._inputs[3]
  109666. },
  109667. enumerable: !1,
  109668. configurable: !0
  109669. }),
  109670. Object.defineProperty(t.prototype, "perturbedNormal", {
  109671. get: function() {
  109672. return this._inputs[4]
  109673. },
  109674. enumerable: !1,
  109675. configurable: !0
  109676. }),
  109677. Object.defineProperty(t.prototype, "baseColor", {
  109678. get: function() {
  109679. return this._inputs[5]
  109680. },
  109681. enumerable: !1,
  109682. configurable: !0
  109683. }),
  109684. Object.defineProperty(t.prototype, "metallic", {
  109685. get: function() {
  109686. return this._inputs[6]
  109687. },
  109688. enumerable: !1,
  109689. configurable: !0
  109690. }),
  109691. Object.defineProperty(t.prototype, "roughness", {
  109692. get: function() {
  109693. return this._inputs[7]
  109694. },
  109695. enumerable: !1,
  109696. configurable: !0
  109697. }),
  109698. Object.defineProperty(t.prototype, "ambientOcc", {
  109699. get: function() {
  109700. return this._inputs[8]
  109701. },
  109702. enumerable: !1,
  109703. configurable: !0
  109704. }),
  109705. Object.defineProperty(t.prototype, "opacity", {
  109706. get: function() {
  109707. return this._inputs[9]
  109708. },
  109709. enumerable: !1,
  109710. configurable: !0
  109711. }),
  109712. Object.defineProperty(t.prototype, "indexOfRefraction", {
  109713. get: function() {
  109714. return this._inputs[10]
  109715. },
  109716. enumerable: !1,
  109717. configurable: !0
  109718. }),
  109719. Object.defineProperty(t.prototype, "ambientColor", {
  109720. get: function() {
  109721. return this._inputs[11]
  109722. },
  109723. enumerable: !1,
  109724. configurable: !0
  109725. }),
  109726. Object.defineProperty(t.prototype, "reflection", {
  109727. get: function() {
  109728. return this._inputs[12]
  109729. },
  109730. enumerable: !1,
  109731. configurable: !0
  109732. }),
  109733. Object.defineProperty(t.prototype, "clearcoat", {
  109734. get: function() {
  109735. return this._inputs[13]
  109736. },
  109737. enumerable: !1,
  109738. configurable: !0
  109739. }),
  109740. Object.defineProperty(t.prototype, "sheen", {
  109741. get: function() {
  109742. return this._inputs[14]
  109743. },
  109744. enumerable: !1,
  109745. configurable: !0
  109746. }),
  109747. Object.defineProperty(t.prototype, "subsurface", {
  109748. get: function() {
  109749. return this._inputs[15]
  109750. },
  109751. enumerable: !1,
  109752. configurable: !0
  109753. }),
  109754. Object.defineProperty(t.prototype, "anisotropy", {
  109755. get: function() {
  109756. return this._inputs[16]
  109757. },
  109758. enumerable: !1,
  109759. configurable: !0
  109760. }),
  109761. Object.defineProperty(t.prototype, "ambientClr", {
  109762. get: function() {
  109763. return this._outputs[0]
  109764. },
  109765. enumerable: !1,
  109766. configurable: !0
  109767. }),
  109768. Object.defineProperty(t.prototype, "diffuseDir", {
  109769. get: function() {
  109770. return this._outputs[1]
  109771. },
  109772. enumerable: !1,
  109773. configurable: !0
  109774. }),
  109775. Object.defineProperty(t.prototype, "specularDir", {
  109776. get: function() {
  109777. return this._outputs[2]
  109778. },
  109779. enumerable: !1,
  109780. configurable: !0
  109781. }),
  109782. Object.defineProperty(t.prototype, "clearcoatDir", {
  109783. get: function() {
  109784. return this._outputs[3]
  109785. },
  109786. enumerable: !1,
  109787. configurable: !0
  109788. }),
  109789. Object.defineProperty(t.prototype, "sheenDir", {
  109790. get: function() {
  109791. return this._outputs[4]
  109792. },
  109793. enumerable: !1,
  109794. configurable: !0
  109795. }),
  109796. Object.defineProperty(t.prototype, "diffuseInd", {
  109797. get: function() {
  109798. return this._outputs[5]
  109799. },
  109800. enumerable: !1,
  109801. configurable: !0
  109802. }),
  109803. Object.defineProperty(t.prototype, "specularInd", {
  109804. get: function() {
  109805. return this._outputs[6]
  109806. },
  109807. enumerable: !1,
  109808. configurable: !0
  109809. }),
  109810. Object.defineProperty(t.prototype, "clearcoatInd", {
  109811. get: function() {
  109812. return this._outputs[7]
  109813. },
  109814. enumerable: !1,
  109815. configurable: !0
  109816. }),
  109817. Object.defineProperty(t.prototype, "sheenInd", {
  109818. get: function() {
  109819. return this._outputs[8]
  109820. },
  109821. enumerable: !1,
  109822. configurable: !0
  109823. }),
  109824. Object.defineProperty(t.prototype, "refraction", {
  109825. get: function() {
  109826. return this._outputs[9]
  109827. },
  109828. enumerable: !1,
  109829. configurable: !0
  109830. }),
  109831. Object.defineProperty(t.prototype, "lighting", {
  109832. get: function() {
  109833. return this._outputs[10]
  109834. },
  109835. enumerable: !1,
  109836. configurable: !0
  109837. }),
  109838. Object.defineProperty(t.prototype, "shadow", {
  109839. get: function() {
  109840. return this._outputs[11]
  109841. },
  109842. enumerable: !1,
  109843. configurable: !0
  109844. }),
  109845. Object.defineProperty(t.prototype, "alpha", {
  109846. get: function() {
  109847. return this._outputs[12]
  109848. },
  109849. enumerable: !1,
  109850. configurable: !0
  109851. }),
  109852. t.prototype.autoConfigure = function(e) {
  109853. if (!this.cameraPosition.isConnected) {
  109854. var t = e.getInputBlockByPredicate((function(e) {
  109855. return e.systemValue === Qp.CameraPosition
  109856. }
  109857. ));
  109858. t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
  109859. t.output.connectTo(this.cameraPosition)
  109860. }
  109861. if (!this.view.isConnected) {
  109862. var i = e.getInputBlockByPredicate((function(e) {
  109863. return e.systemValue === Qp.View
  109864. }
  109865. ));
  109866. i || (i = new tf("view")).setAsSystemValue(Qp.View),
  109867. i.output.connectTo(this.view)
  109868. }
  109869. }
  109870. ,
  109871. t.prototype.prepareDefines = function(e, t, i) {
  109872. i.setValue("PBR", !0),
  109873. i.setValue("METALLICWORKFLOW", !0),
  109874. i.setValue("DEBUGMODE", this.debugMode, !0),
  109875. i.setValue("NORMALXYSCALE", !0),
  109876. i.setValue("BUMP", this.perturbedNormal.isConnected, !0),
  109877. i.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD),
  109878. i.setValue("ALBEDO", !1, !0),
  109879. i.setValue("OPACITY", this.opacity.isConnected, !0),
  109880. i.setValue("AMBIENT", !0, !0),
  109881. i.setValue("AMBIENTINGRAYSCALE", !1, !0),
  109882. i.setValue("REFLECTIVITY", !1, !0),
  109883. i.setValue("AOSTOREINMETALMAPRED", !1, !0),
  109884. i.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0),
  109885. i.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0),
  109886. i.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0),
  109887. this.lightFalloff === rp.LIGHTFALLOFF_STANDARD ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
  109888. i.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === rp.LIGHTFALLOFF_GLTF ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
  109889. i.setValue("USEGLTFLIGHTFALLOFF", !0)) : (i.setValue("USEPHYSICALLIGHTFALLOFF", !0),
  109890. i.setValue("USEGLTFLIGHTFALLOFF", !1));
  109891. var n = this.alphaTestCutoff.toString();
  109892. i.setValue("ALPHABLEND", this.useAlphaBlending, !0),
  109893. i.setValue("ALPHAFROMALBEDO", !1, !0),
  109894. i.setValue("ALPHATEST", this.useAlphaTest, !0),
  109895. i.setValue("ALPHATESTVALUE", n.indexOf(".") < 0 ? n + "." : n, !0),
  109896. i.setValue("OPACITYRGB", !1, !0),
  109897. i.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0),
  109898. i.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0),
  109899. i.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0),
  109900. i.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0);
  109901. var r = e.getScene();
  109902. if (r.getEngine()._features.needTypeSuffixInShaderConstants ? i.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : i.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0),
  109903. i.setValue("BRDF_V_HEIGHT_CORRELATED", !0),
  109904. i.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0),
  109905. i.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0),
  109906. i.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0),
  109907. i.setValue("UNLIT", this.unlit, !0),
  109908. i.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0),
  109909. this._environmentBRDFTexture && vs.ReflectionTextureEnabled ? (i.setValue("ENVIRONMENTBRDF", !0),
  109910. i.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (i.setValue("ENVIRONMENTBRDF", !1),
  109911. i.setValue("ENVIRONMENTBRDF_RGBD", !1)),
  109912. i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i),
  109913. i._areLightsDirty)
  109914. if (this.light) {
  109915. var o = {
  109916. needNormals: !1,
  109917. needRebuild: !1,
  109918. lightmapMode: !1,
  109919. shadowEnabled: !1,
  109920. specularEnabled: !1
  109921. };
  109922. Mr.PrepareDefinesForLight(r, e, this.light, this._lightId, i, !0, o),
  109923. o.needRebuild && i.rebuild()
  109924. } else
  109925. Mr.PrepareDefinesForLights(r, e, i, !0, t.maxSimultaneousLights),
  109926. i._needNormals = !0,
  109927. Mr.PrepareDefinesForMultiview(r, i)
  109928. }
  109929. ,
  109930. t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
  109931. for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
  109932. var o = e.uniforms.indexOf("vLightData" + r) >= 0;
  109933. Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, o)
  109934. }
  109935. }
  109936. ,
  109937. t.prototype.isReady = function(e, t, i) {
  109938. return !(this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady() || i._areImageProcessingDirty && t.imageProcessingConfiguration && !t.imageProcessingConfiguration.isReady())
  109939. }
  109940. ,
  109941. t.prototype.bind = function(e, t, i) {
  109942. var n, r;
  109943. if (i) {
  109944. var o = i.getScene();
  109945. this.light ? Mr.BindLight(this.light, this._lightId, o, e, !0) : Mr.BindLights(o, i, e, !0, t.maxSimultaneousLights),
  109946. e.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture),
  109947. e.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  109948. var a = this._scene.ambientColor;
  109949. a && e.setColor3("ambientFromScene", a);
  109950. var s = o.useRightHandedSystem === (null != o._mirroredCameraPosition);
  109951. e.setFloat(this._invertNormalName, s ? -1 : 1),
  109952. e.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
  109953. var l = null !== (r = null === (n = this.indexOfRefraction.connectInputBlock) || void 0 === n ? void 0 : n.value) && void 0 !== r ? r : 1.5
  109954. , c = Math.pow((l - 1) / (l + 1), 2);
  109955. this._metallicReflectanceColor.scaleToRef(c * this._metallicF0Factor, L.Color3[0]);
  109956. var u = this._metallicF0Factor;
  109957. e.setColor4(this._vMetallicReflectanceFactorsName, L.Color3[0], u),
  109958. t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e)
  109959. }
  109960. }
  109961. ,
  109962. t.prototype._injectVertexCode = function(e) {
  109963. var t, i, n = this.worldPosition, r = "//".concat(this.name);
  109964. this.light ? (this._lightId = (void 0 !== e.counters.lightCounter ? e.counters.lightCounter : -1) + 1,
  109965. e.counters.lightCounter = this._lightId,
  109966. e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, {
  109967. replaceStrings: [{
  109968. search: /{X}/g,
  109969. replace: this._lightId.toString()
  109970. }]
  109971. }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, {
  109972. repeatKey: "maxSimultaneousLights"
  109973. }),
  109974. this._lightId = 0,
  109975. e.sharedData.dynamicUniformBlocks.push(this));
  109976. var o = "v_" + n.associatedVariableName;
  109977. e._emitVaryingFromString(o, "vec4") && (e.compilationString += "".concat(o, " = ").concat(n.associatedVariableName, ";\r\n"));
  109978. var a = this.reflection.isConnected ? null === (t = this.reflection.connectedPoint) || void 0 === t ? void 0 : t.ownerBlock : null;
  109979. a && (a.viewConnectionPoint = this.view),
  109980. e.compilationString += null !== (i = null == a ? void 0 : a.handleVertexSide(e)) && void 0 !== i ? i : "",
  109981. e._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"),
  109982. e._emitUniformFromString("ambientFromScene", "vec3"),
  109983. e._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (e._injectAtEnd += "#if DEBUGMODE > 0\r\n",
  109984. e._injectAtEnd += "vClipSpacePosition = gl_Position;\r\n",
  109985. e._injectAtEnd += "#endif\r\n"),
  109986. this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
  109987. replaceStrings: [{
  109988. search: /{X}/g,
  109989. replace: this._lightId.toString()
  109990. }, {
  109991. search: /worldPos/g,
  109992. replace: n.associatedVariableName
  109993. }]
  109994. }) : (e.compilationString += "vec4 worldPos = ".concat(n.associatedVariableName, ";\r\n"),
  109995. this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
  109996. e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
  109997. repeatKey: "maxSimultaneousLights"
  109998. }))
  109999. }
  110000. ,
  110001. t.prototype._getAlbedoOpacityCode = function() {
  110002. var e = "albedoOpacityOutParams albedoOpacityOut;\r\n"
  110003. , t = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)"
  110004. , i = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
  110005. return e + "albedoOpacityBlock(\n vec4(".concat(t, ", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4(").concat(i, "),\n vec2(1., 1.),\n #endif\n albedoOpacityOut\n );\n\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\n float alpha = albedoOpacityOut.alpha;\r\n")
  110006. }
  110007. ,
  110008. t.prototype._getAmbientOcclusionCode = function() {
  110009. var e = "ambientOcclusionOutParams aoOut;\r\n"
  110010. , t = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
  110011. return e + "ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3(".concat(t, "),\n vec4(0., 1.0, 1.0, 0.),\n #endif\n aoOut\n );\r\n")
  110012. }
  110013. ,
  110014. t.prototype._getReflectivityCode = function(e) {
  110015. var t = "reflectivityOutParams reflectivityOut;\r\n";
  110016. return this._vMetallicReflectanceFactorsName = e._getFreeVariableName("vMetallicReflectanceFactors"),
  110017. e._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"),
  110018. t + "vec3 baseColor = surfaceAlbedo;\n\n reflectivityBlock(\n vec4(".concat(this.metallic.associatedVariableName, ", ").concat(this.roughness.associatedVariableName, ", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n ").concat(this._vMetallicReflectanceFactorsName, ",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., ").concat("1.", "),\n vec4(1.),\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor,\n #endif\n #ifdef MICROSURFACEMAP\n microSurfaceTexel, <== not handled!\n #endif\n reflectivityOut\n );\n\n float microSurface = reflectivityOut.microSurface;\n float roughness = reflectivityOut.roughness;\n\n #ifdef METALLICWORKFLOW\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\n #endif\r\n")
  110019. }
  110020. ,
  110021. t.prototype._buildBlock = function(t) {
  110022. var i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L, F, w, B, U, V, k, G;
  110023. e.prototype._buildBlock.call(this, t),
  110024. this._scene = t.sharedData.scene,
  110025. this._environmentBRDFTexture || (this._environmentBRDFTexture = Hd(this._scene));
  110026. var z = this.reflection.isConnected ? null === (i = this.reflection.connectedPoint) || void 0 === i ? void 0 : i.ownerBlock : null;
  110027. if (z && (z.worldPositionConnectionPoint = this.worldPosition,
  110028. z.cameraPositionConnectionPoint = this.cameraPosition,
  110029. z.worldNormalConnectionPoint = this.worldNormal),
  110030. t.target !== Dp.Fragment)
  110031. return this._injectVertexCode(t),
  110032. this;
  110033. t.sharedData.forcedBindableBlocks.push(this),
  110034. t.sharedData.blocksWithDefines.push(this),
  110035. t.sharedData.blockingBlocks.push(this);
  110036. var W = "//".concat(this.name)
  110037. , H = "v_" + this.worldPosition.associatedVariableName
  110038. , X = this.perturbedNormal;
  110039. this._environmentBrdfSamplerName = t._getFreeVariableName("environmentBrdfSampler"),
  110040. t._emit2DSampler(this._environmentBrdfSamplerName),
  110041. t.sharedData.hints.needAlphaBlending = t.sharedData.hints.needAlphaBlending || this.useAlphaBlending,
  110042. t.sharedData.hints.needAlphaTesting = t.sharedData.hints.needAlphaTesting || this.useAlphaTest,
  110043. t._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"),
  110044. t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
  110045. t.uniforms.push("exposureLinear"),
  110046. t.uniforms.push("contrast"),
  110047. t.uniforms.push("vInverseScreenSize"),
  110048. t.uniforms.push("vignetteSettings1"),
  110049. t.uniforms.push("vignetteSettings2"),
  110050. t.uniforms.push("vCameraColorCurveNegative"),
  110051. t.uniforms.push("vCameraColorCurveNeutral"),
  110052. t.uniforms.push("vCameraColorCurvePositive"),
  110053. t.uniforms.push("txColorTransform"),
  110054. t.uniforms.push("colorTransformSettings"),
  110055. this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
  110056. replaceStrings: [{
  110057. search: /{X}/g,
  110058. replace: this._lightId.toString()
  110059. }]
  110060. }, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
  110061. repeatKey: "maxSimultaneousLights"
  110062. }),
  110063. t._emitFunctionFromInclude("helperFunctions", W),
  110064. t._emitFunctionFromInclude("importanceSampling", W),
  110065. t._emitFunctionFromInclude("pbrHelperFunctions", W),
  110066. t._emitFunctionFromInclude("imageProcessingDeclaration", W),
  110067. t._emitFunctionFromInclude("imageProcessingFunctions", W),
  110068. t._emitFunctionFromInclude("shadowsFragmentFunctions", W, {
  110069. replaceStrings: [{
  110070. search: /vPositionW/g,
  110071. replace: H + ".xyz"
  110072. }]
  110073. }),
  110074. t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", W, {
  110075. replaceStrings: [{
  110076. search: /vPositionW/g,
  110077. replace: H + ".xyz"
  110078. }]
  110079. }),
  110080. t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", W),
  110081. t._emitFunctionFromInclude("pbrBRDFFunctions", W, {
  110082. replaceStrings: [{
  110083. search: /REFLECTIONMAP_SKYBOX/g,
  110084. replace: null !== (n = null == z ? void 0 : z._defineSkyboxName) && void 0 !== n ? n : "REFLECTIONMAP_SKYBOX"
  110085. }]
  110086. }),
  110087. t._emitFunctionFromInclude("hdrFilteringFunctions", W),
  110088. t._emitFunctionFromInclude("pbrDirectLightingFunctions", W, {
  110089. replaceStrings: [{
  110090. search: /vPositionW/g,
  110091. replace: H + ".xyz"
  110092. }]
  110093. }),
  110094. t._emitFunctionFromInclude("pbrIBLFunctions", W),
  110095. t._emitFunctionFromInclude("pbrBlockAlbedoOpacity", W),
  110096. t._emitFunctionFromInclude("pbrBlockReflectivity", W),
  110097. t._emitFunctionFromInclude("pbrBlockAmbientOcclusion", W),
  110098. t._emitFunctionFromInclude("pbrBlockAlphaFresnel", W),
  110099. t._emitFunctionFromInclude("pbrBlockAnisotropic", W),
  110100. t._emitUniformFromString("vLightingIntensity", "vec4"),
  110101. this._vNormalWName = t._getFreeVariableName("vNormalW"),
  110102. t.compilationString += "vec4 ".concat(this._vNormalWName, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
  110103. t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(H, ".xyz);\r\n")),
  110104. t.compilationString += "vec3 geometricNormalW = ".concat(this._vNormalWName, ".xyz;\r\n"),
  110105. t.compilationString += "vec3 normalW = ".concat(X.isConnected ? "normalize(" + X.associatedVariableName + ".xyz)" : "geometricNormalW", ";\r\n"),
  110106. this._invertNormalName = t._getFreeVariableName("invertNormal"),
  110107. t._emitUniformFromString(this._invertNormalName, "float"),
  110108. t.compilationString += t._emitCodeFromInclude("pbrBlockNormalFinal", W, {
  110109. replaceStrings: [{
  110110. search: /vPositionW/g,
  110111. replace: H + ".xyz"
  110112. }, {
  110113. search: /vEyePosition.w/g,
  110114. replace: this._invertNormalName
  110115. }]
  110116. }),
  110117. t.compilationString += this._getAlbedoOpacityCode(),
  110118. t.compilationString += t._emitCodeFromInclude("depthPrePass", W),
  110119. t.compilationString += this._getAmbientOcclusionCode(),
  110120. t.compilationString += t._emitCodeFromInclude("pbrBlockLightmapInit", W),
  110121. t.compilationString += "#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\r\n",
  110122. t.compilationString += this._getReflectivityCode(t),
  110123. t.compilationString += t._emitCodeFromInclude("pbrBlockGeometryInfo", W, {
  110124. replaceStrings: [{
  110125. search: /REFLECTIONMAP_SKYBOX/g,
  110126. replace: null !== (r = null == z ? void 0 : z._defineSkyboxName) && void 0 !== r ? r : "REFLECTIONMAP_SKYBOX"
  110127. }, {
  110128. search: /REFLECTIONMAP_3D/g,
  110129. replace: null !== (o = null == z ? void 0 : z._define3DName) && void 0 !== o ? o : "REFLECTIONMAP_3D"
  110130. }]
  110131. });
  110132. var j = this.anisotropy.isConnected ? null === (a = this.anisotropy.connectedPoint) || void 0 === a ? void 0 : a.ownerBlock : null;
  110133. j && (j.worldPositionConnectionPoint = this.worldPosition,
  110134. j.worldNormalConnectionPoint = this.worldNormal,
  110135. t.compilationString += j.getCode(t, !this.perturbedNormal.isConnected)),
  110136. z && z.hasTexture && (t.compilationString += z.getCode(t, j ? "anisotropicOut.anisotropicNormal" : "normalW")),
  110137. t._emitFunctionFromInclude("pbrBlockReflection", W, {
  110138. replaceStrings: [{
  110139. search: /computeReflectionCoords/g,
  110140. replace: "computeReflectionCoordsPBR"
  110141. }, {
  110142. search: /REFLECTIONMAP_3D/g,
  110143. replace: null !== (s = null == z ? void 0 : z._define3DName) && void 0 !== s ? s : "REFLECTIONMAP_3D"
  110144. }, {
  110145. search: /REFLECTIONMAP_OPPOSITEZ/g,
  110146. replace: null !== (l = null == z ? void 0 : z._defineOppositeZ) && void 0 !== l ? l : "REFLECTIONMAP_OPPOSITEZ"
  110147. }, {
  110148. search: /REFLECTIONMAP_PROJECTION/g,
  110149. replace: null !== (c = null == z ? void 0 : z._defineProjectionName) && void 0 !== c ? c : "REFLECTIONMAP_PROJECTION"
  110150. }, {
  110151. search: /REFLECTIONMAP_SKYBOX/g,
  110152. replace: null !== (u = null == z ? void 0 : z._defineSkyboxName) && void 0 !== u ? u : "REFLECTIONMAP_SKYBOX"
  110153. }, {
  110154. search: /LODINREFLECTIONALPHA/g,
  110155. replace: null !== (h = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== h ? h : "LODINREFLECTIONALPHA"
  110156. }, {
  110157. search: /LINEARSPECULARREFLECTION/g,
  110158. replace: null !== (d = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== d ? d : "LINEARSPECULARREFLECTION"
  110159. }, {
  110160. search: /vReflectionFilteringInfo/g,
  110161. replace: null !== (p = null == z ? void 0 : z._vReflectionFilteringInfoName) && void 0 !== p ? p : "vReflectionFilteringInfo"
  110162. }]
  110163. }),
  110164. t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance0", W, {
  110165. replaceStrings: [{
  110166. search: /metallicReflectanceFactors/g,
  110167. replace: this._vMetallicReflectanceFactorsName
  110168. }]
  110169. });
  110170. var Y = this.sheen.isConnected ? null === (f = this.sheen.connectedPoint) || void 0 === f ? void 0 : f.ownerBlock : null;
  110171. Y && (t.compilationString += Y.getCode(z)),
  110172. t._emitFunctionFromInclude("pbrBlockSheen", W, {
  110173. replaceStrings: [{
  110174. search: /REFLECTIONMAP_3D/g,
  110175. replace: null !== (_ = null == z ? void 0 : z._define3DName) && void 0 !== _ ? _ : "REFLECTIONMAP_3D"
  110176. }, {
  110177. search: /REFLECTIONMAP_SKYBOX/g,
  110178. replace: null !== (m = null == z ? void 0 : z._defineSkyboxName) && void 0 !== m ? m : "REFLECTIONMAP_SKYBOX"
  110179. }, {
  110180. search: /LODINREFLECTIONALPHA/g,
  110181. replace: null !== (g = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== g ? g : "LODINREFLECTIONALPHA"
  110182. }, {
  110183. search: /LINEARSPECULARREFLECTION/g,
  110184. replace: null !== (v = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== v ? v : "LINEARSPECULARREFLECTION"
  110185. }]
  110186. });
  110187. var K = this.clearcoat.isConnected ? null === (y = this.clearcoat.connectedPoint) || void 0 === y ? void 0 : y.ownerBlock : null
  110188. , Q = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected
  110189. , q = this.perturbedNormal.isConnected && (null === (T = (null === (b = this.perturbedNormal.connectedPoint) || void 0 === b ? void 0 : b.ownerBlock).worldTangent) || void 0 === T ? void 0 : T.isConnected)
  110190. , Z = this.anisotropy.isConnected && (null === (E = this.anisotropy.connectedPoint) || void 0 === E ? void 0 : E.ownerBlock).worldTangent.isConnected
  110191. , J = q || !this.perturbedNormal.isConnected && Z;
  110192. t.compilationString += Ng.GetCode(t, K, z, H, Q, J, this.worldNormal.associatedVariableName),
  110193. Q && (J = null !== (S = null == K ? void 0 : K.worldTangent.isConnected) && void 0 !== S && S),
  110194. t._emitFunctionFromInclude("pbrBlockClearcoat", W, {
  110195. replaceStrings: [{
  110196. search: /computeReflectionCoords/g,
  110197. replace: "computeReflectionCoordsPBR"
  110198. }, {
  110199. search: /REFLECTIONMAP_3D/g,
  110200. replace: null !== (A = null == z ? void 0 : z._define3DName) && void 0 !== A ? A : "REFLECTIONMAP_3D"
  110201. }, {
  110202. search: /REFLECTIONMAP_OPPOSITEZ/g,
  110203. replace: null !== (x = null == z ? void 0 : z._defineOppositeZ) && void 0 !== x ? x : "REFLECTIONMAP_OPPOSITEZ"
  110204. }, {
  110205. search: /REFLECTIONMAP_PROJECTION/g,
  110206. replace: null !== (R = null == z ? void 0 : z._defineProjectionName) && void 0 !== R ? R : "REFLECTIONMAP_PROJECTION"
  110207. }, {
  110208. search: /REFLECTIONMAP_SKYBOX/g,
  110209. replace: null !== (C = null == z ? void 0 : z._defineSkyboxName) && void 0 !== C ? C : "REFLECTIONMAP_SKYBOX"
  110210. }, {
  110211. search: /LODINREFLECTIONALPHA/g,
  110212. replace: null !== (P = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== P ? P : "LODINREFLECTIONALPHA"
  110213. }, {
  110214. search: /LINEARSPECULARREFLECTION/g,
  110215. replace: null !== (M = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== M ? M : "LINEARSPECULARREFLECTION"
  110216. }, {
  110217. search: /defined\(TANGENT\)/g,
  110218. replace: J ? "defined(TANGENT)" : "defined(IGNORE)"
  110219. }]
  110220. }),
  110221. t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance", W, {
  110222. replaceStrings: [{
  110223. search: /REFLECTIONMAP_SKYBOX/g,
  110224. replace: null !== (I = null == z ? void 0 : z._defineSkyboxName) && void 0 !== I ? I : "REFLECTIONMAP_SKYBOX"
  110225. }, {
  110226. search: /REFLECTIONMAP_3D/g,
  110227. replace: null !== (O = null == z ? void 0 : z._define3DName) && void 0 !== O ? O : "REFLECTIONMAP_3D"
  110228. }]
  110229. });
  110230. var $ = this.subsurface.isConnected ? null === (D = this.subsurface.connectedPoint) || void 0 === D ? void 0 : D.ownerBlock : null
  110231. , ee = this.subsurface.isConnected ? null === (L = (null === (N = this.subsurface.connectedPoint) || void 0 === N ? void 0 : N.ownerBlock).refraction.connectedPoint) || void 0 === L ? void 0 : L.ownerBlock : null;
  110232. ee && (ee.viewConnectionPoint = this.view,
  110233. ee.indexOfRefractionConnectionPoint = this.indexOfRefraction),
  110234. t.compilationString += Fg.GetCode(t, $, z, H),
  110235. t._emitFunctionFromInclude("pbrBlockSubSurface", W, {
  110236. replaceStrings: [{
  110237. search: /REFLECTIONMAP_3D/g,
  110238. replace: null !== (F = null == z ? void 0 : z._define3DName) && void 0 !== F ? F : "REFLECTIONMAP_3D"
  110239. }, {
  110240. search: /REFLECTIONMAP_OPPOSITEZ/g,
  110241. replace: null !== (w = null == z ? void 0 : z._defineOppositeZ) && void 0 !== w ? w : "REFLECTIONMAP_OPPOSITEZ"
  110242. }, {
  110243. search: /REFLECTIONMAP_PROJECTION/g,
  110244. replace: null !== (B = null == z ? void 0 : z._defineProjectionName) && void 0 !== B ? B : "REFLECTIONMAP_PROJECTION"
  110245. }, {
  110246. search: /SS_REFRACTIONMAP_3D/g,
  110247. replace: null !== (U = null == ee ? void 0 : ee._define3DName) && void 0 !== U ? U : "SS_REFRACTIONMAP_3D"
  110248. }, {
  110249. search: /SS_LODINREFRACTIONALPHA/g,
  110250. replace: null !== (V = null == ee ? void 0 : ee._defineLODRefractionAlpha) && void 0 !== V ? V : "SS_LODINREFRACTIONALPHA"
  110251. }, {
  110252. search: /SS_LINEARSPECULARREFRACTION/g,
  110253. replace: null !== (k = null == ee ? void 0 : ee._defineLinearSpecularRefraction) && void 0 !== k ? k : "SS_LINEARSPECULARREFRACTION"
  110254. }, {
  110255. search: /SS_REFRACTIONMAP_OPPOSITEZ/g,
  110256. replace: null !== (G = null == ee ? void 0 : ee._defineOppositeZ) && void 0 !== G ? G : "SS_REFRACTIONMAP_OPPOSITEZ"
  110257. }]
  110258. }),
  110259. t.compilationString += t._emitCodeFromInclude("pbrBlockDirectLighting", W),
  110260. this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
  110261. replaceStrings: [{
  110262. search: /{X}/g,
  110263. replace: this._lightId.toString()
  110264. }]
  110265. }) : t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
  110266. repeatKey: "maxSimultaneousLights"
  110267. }),
  110268. t.compilationString += t._emitCodeFromInclude("pbrBlockFinalLitComponents", W),
  110269. t.compilationString += "#endif\r\n";
  110270. var te = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)"
  110271. , ie = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
  110272. -1 === ie.indexOf(".") && (ie += "."),
  110273. t.compilationString += t._emitCodeFromInclude("pbrBlockFinalUnlitComponents", W, {
  110274. replaceStrings: [{
  110275. search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,
  110276. replace: ""
  110277. }, {
  110278. search: /vAmbientColor/g,
  110279. replace: te + " * ambientFromScene"
  110280. }, {
  110281. search: /vAmbientInfos\.w/g,
  110282. replace: ie
  110283. }]
  110284. }),
  110285. t.compilationString += t._emitCodeFromInclude("pbrBlockFinalColorComposition", W, {
  110286. replaceStrings: [{
  110287. search: /finalEmissive/g,
  110288. replace: "vec3(0.)"
  110289. }]
  110290. }),
  110291. t.compilationString += t._emitCodeFromInclude("pbrBlockImageProcessing", W, {
  110292. replaceStrings: [{
  110293. search: /visibility/g,
  110294. replace: "1."
  110295. }]
  110296. }),
  110297. t.compilationString += t._emitCodeFromInclude("pbrDebug", W, {
  110298. replaceStrings: [{
  110299. search: /vNormalW/g,
  110300. replace: this._vNormalWName
  110301. }, {
  110302. search: /vPositionW/g,
  110303. replace: H
  110304. }, {
  110305. search: /albedoTexture\.rgb;/g,
  110306. replace: "vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"
  110307. }]
  110308. });
  110309. for (var ne = 0, re = this._outputs; ne < re.length; ne++) {
  110310. var oe = re[ne];
  110311. if (oe.hasEndpoints) {
  110312. var ae = wg[oe.name];
  110313. if (ae) {
  110314. var se = ae[0]
  110315. , le = ae[1];
  110316. le && (t.compilationString += "#if ".concat(le, "\r\n")),
  110317. t.compilationString += "".concat(this._declareOutput(oe, t), " = ").concat(se, ";\r\n"),
  110318. le && (t.compilationString += "#else\r\n",
  110319. t.compilationString += "".concat(this._declareOutput(oe, t), " = vec3(0.);\r\n"),
  110320. t.compilationString += "#endif\r\n")
  110321. } else
  110322. console.error("There's no remapping for the ".concat(oe.name, " end point! No code generated"))
  110323. }
  110324. }
  110325. return this
  110326. }
  110327. ,
  110328. t.prototype._dumpPropertiesCode = function() {
  110329. var t = e.prototype._dumpPropertiesCode.call(this);
  110330. return t += "".concat(this._codeVariableName, ".lightFalloff = ").concat(this.lightFalloff, ";\r\n"),
  110331. t += "".concat(this._codeVariableName, ".useAlphaTest = ").concat(this.useAlphaTest, ";\r\n"),
  110332. t += "".concat(this._codeVariableName, ".alphaTestCutoff = ").concat(this.alphaTestCutoff, ";\r\n"),
  110333. t += "".concat(this._codeVariableName, ".useAlphaBlending = ").concat(this.useAlphaBlending, ";\r\n"),
  110334. t += "".concat(this._codeVariableName, ".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha, ";\r\n"),
  110335. t += "".concat(this._codeVariableName, ".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha, ";\r\n"),
  110336. t += "".concat(this._codeVariableName, ".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing, ";\r\n"),
  110337. t += "".concat(this._codeVariableName, ".realTimeFiltering = ").concat(this.realTimeFiltering, ";\r\n"),
  110338. t += "".concat(this._codeVariableName, ".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality, ";\r\n"),
  110339. t += "".concat(this._codeVariableName, ".useEnergyConservation = ").concat(this.useEnergyConservation, ";\r\n"),
  110340. t += "".concat(this._codeVariableName, ".useRadianceOcclusion = ").concat(this.useRadianceOcclusion, ";\r\n"),
  110341. t += "".concat(this._codeVariableName, ".useHorizonOcclusion = ").concat(this.useHorizonOcclusion, ";\r\n"),
  110342. t += "".concat(this._codeVariableName, ".unlit = ").concat(this.unlit, ";\r\n"),
  110343. t += "".concat(this._codeVariableName, ".forceNormalForward = ").concat(this.forceNormalForward, ";\r\n"),
  110344. t += "".concat(this._codeVariableName, ".debugMode = ").concat(this.debugMode, ";\r\n"),
  110345. (t += "".concat(this._codeVariableName, ".debugLimit = ").concat(this.debugLimit, ";\r\n")) + "".concat(this._codeVariableName, ".debugFactor = ").concat(this.debugFactor, ";\r\n")
  110346. }
  110347. ,
  110348. t.prototype.serialize = function() {
  110349. var t = e.prototype.serialize.call(this);
  110350. return this.light && (t.lightId = this.light.id),
  110351. t.lightFalloff = this.lightFalloff,
  110352. t.useAlphaTest = this.useAlphaTest,
  110353. t.alphaTestCutoff = this.alphaTestCutoff,
  110354. t.useAlphaBlending = this.useAlphaBlending,
  110355. t.useRadianceOverAlpha = this.useRadianceOverAlpha,
  110356. t.useSpecularOverAlpha = this.useSpecularOverAlpha,
  110357. t.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing,
  110358. t.realTimeFiltering = this.realTimeFiltering,
  110359. t.realTimeFilteringQuality = this.realTimeFilteringQuality,
  110360. t.useEnergyConservation = this.useEnergyConservation,
  110361. t.useRadianceOcclusion = this.useRadianceOcclusion,
  110362. t.useHorizonOcclusion = this.useHorizonOcclusion,
  110363. t.unlit = this.unlit,
  110364. t.forceNormalForward = this.forceNormalForward,
  110365. t.debugMode = this.debugMode,
  110366. t.debugLimit = this.debugLimit,
  110367. t.debugFactor = this.debugFactor,
  110368. t
  110369. }
  110370. ,
  110371. t.prototype._deserialize = function(t, i, n) {
  110372. var r, o;
  110373. e.prototype._deserialize.call(this, t, i, n),
  110374. t.lightId && (this.light = i.getLightById(t.lightId)),
  110375. this.lightFalloff = null !== (r = t.lightFalloff) && void 0 !== r ? r : 0,
  110376. this.useAlphaTest = t.useAlphaTest,
  110377. this.alphaTestCutoff = t.alphaTestCutoff,
  110378. this.useAlphaBlending = t.useAlphaBlending,
  110379. this.useRadianceOverAlpha = t.useRadianceOverAlpha,
  110380. this.useSpecularOverAlpha = t.useSpecularOverAlpha,
  110381. this.enableSpecularAntiAliasing = t.enableSpecularAntiAliasing,
  110382. this.realTimeFiltering = !!t.realTimeFiltering,
  110383. this.realTimeFilteringQuality = null !== (o = t.realTimeFilteringQuality) && void 0 !== o ? o : a.TEXTURE_FILTERING_QUALITY_LOW,
  110384. this.useEnergyConservation = t.useEnergyConservation,
  110385. this.useRadianceOcclusion = t.useRadianceOcclusion,
  110386. this.useHorizonOcclusion = t.useHorizonOcclusion,
  110387. this.unlit = t.unlit,
  110388. this.forceNormalForward = !!t.forceNormalForward,
  110389. this.debugMode = t.debugMode,
  110390. this.debugLimit = t.debugLimit,
  110391. this.debugFactor = t.debugFactor
  110392. }
  110393. ,
  110394. k([Yp("Direct lights", Xp.Float, "INTENSITY", {
  110395. min: 0,
  110396. max: 1,
  110397. notifiers: {
  110398. update: !0
  110399. }
  110400. })], t.prototype, "directIntensity", void 0),
  110401. k([Yp("Environment lights", Xp.Float, "INTENSITY", {
  110402. min: 0,
  110403. max: 1,
  110404. notifiers: {
  110405. update: !0
  110406. }
  110407. })], t.prototype, "environmentIntensity", void 0),
  110408. k([Yp("Specular highlights", Xp.Float, "INTENSITY", {
  110409. min: 0,
  110410. max: 1,
  110411. notifiers: {
  110412. update: !0
  110413. }
  110414. })], t.prototype, "specularIntensity", void 0),
  110415. k([Yp("Light falloff", Xp.List, "LIGHTING & COLORS", {
  110416. notifiers: {
  110417. update: !0
  110418. },
  110419. options: [{
  110420. label: "Physical",
  110421. value: rp.LIGHTFALLOFF_PHYSICAL
  110422. }, {
  110423. label: "GLTF",
  110424. value: rp.LIGHTFALLOFF_GLTF
  110425. }, {
  110426. label: "Standard",
  110427. value: rp.LIGHTFALLOFF_STANDARD
  110428. }]
  110429. })], t.prototype, "lightFalloff", void 0),
  110430. k([Yp("Alpha Testing", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0),
  110431. k([Yp("Alpha CutOff", Xp.Float, "OPACITY", {
  110432. min: 0,
  110433. max: 1,
  110434. notifiers: {
  110435. update: !0
  110436. }
  110437. })], t.prototype, "alphaTestCutoff", void 0),
  110438. k([Yp("Alpha blending", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0),
  110439. k([Yp("Radiance over alpha", Xp.Boolean, "RENDERING", {
  110440. notifiers: {
  110441. update: !0
  110442. }
  110443. })], t.prototype, "useRadianceOverAlpha", void 0),
  110444. k([Yp("Specular over alpha", Xp.Boolean, "RENDERING", {
  110445. notifiers: {
  110446. update: !0
  110447. }
  110448. })], t.prototype, "useSpecularOverAlpha", void 0),
  110449. k([Yp("Specular anti-aliasing", Xp.Boolean, "RENDERING", {
  110450. notifiers: {
  110451. update: !0
  110452. }
  110453. })], t.prototype, "enableSpecularAntiAliasing", void 0),
  110454. k([Yp("Realtime filtering", Xp.Boolean, "RENDERING", {
  110455. notifiers: {
  110456. update: !0
  110457. }
  110458. })], t.prototype, "realTimeFiltering", void 0),
  110459. k([Yp("Realtime filtering quality", Xp.List, "RENDERING", {
  110460. notifiers: {
  110461. update: !0
  110462. },
  110463. options: [{
  110464. label: "Low",
  110465. value: a.TEXTURE_FILTERING_QUALITY_LOW
  110466. }, {
  110467. label: "Medium",
  110468. value: a.TEXTURE_FILTERING_QUALITY_MEDIUM
  110469. }, {
  110470. label: "High",
  110471. value: a.TEXTURE_FILTERING_QUALITY_HIGH
  110472. }]
  110473. })], t.prototype, "realTimeFilteringQuality", void 0),
  110474. k([Yp("Energy Conservation", Xp.Boolean, "ADVANCED", {
  110475. notifiers: {
  110476. update: !0
  110477. }
  110478. })], t.prototype, "useEnergyConservation", void 0),
  110479. k([Yp("Radiance occlusion", Xp.Boolean, "ADVANCED", {
  110480. notifiers: {
  110481. update: !0
  110482. }
  110483. })], t.prototype, "useRadianceOcclusion", void 0),
  110484. k([Yp("Horizon occlusion", Xp.Boolean, "ADVANCED", {
  110485. notifiers: {
  110486. update: !0
  110487. }
  110488. })], t.prototype, "useHorizonOcclusion", void 0),
  110489. k([Yp("Unlit", Xp.Boolean, "ADVANCED", {
  110490. notifiers: {
  110491. update: !0
  110492. }
  110493. })], t.prototype, "unlit", void 0),
  110494. k([Yp("Force normal forward", Xp.Boolean, "ADVANCED", {
  110495. notifiers: {
  110496. update: !0
  110497. }
  110498. })], t.prototype, "forceNormalForward", void 0),
  110499. k([Yp("Debug mode", Xp.List, "DEBUG", {
  110500. notifiers: {
  110501. update: !0
  110502. },
  110503. options: [{
  110504. label: "None",
  110505. value: 0
  110506. }, {
  110507. label: "Normalized position",
  110508. value: 1
  110509. }, {
  110510. label: "Normals",
  110511. value: 2
  110512. }, {
  110513. label: "Tangents",
  110514. value: 3
  110515. }, {
  110516. label: "Bitangents",
  110517. value: 4
  110518. }, {
  110519. label: "Bump Normals",
  110520. value: 5
  110521. }, {
  110522. label: "ClearCoat Normals",
  110523. value: 8
  110524. }, {
  110525. label: "ClearCoat Tangents",
  110526. value: 9
  110527. }, {
  110528. label: "ClearCoat Bitangents",
  110529. value: 10
  110530. }, {
  110531. label: "Anisotropic Normals",
  110532. value: 11
  110533. }, {
  110534. label: "Anisotropic Tangents",
  110535. value: 12
  110536. }, {
  110537. label: "Anisotropic Bitangents",
  110538. value: 13
  110539. }, {
  110540. label: "Env Refraction",
  110541. value: 40
  110542. }, {
  110543. label: "Env Reflection",
  110544. value: 41
  110545. }, {
  110546. label: "Env Clear Coat",
  110547. value: 42
  110548. }, {
  110549. label: "Direct Diffuse",
  110550. value: 50
  110551. }, {
  110552. label: "Direct Specular",
  110553. value: 51
  110554. }, {
  110555. label: "Direct Clear Coat",
  110556. value: 52
  110557. }, {
  110558. label: "Direct Sheen",
  110559. value: 53
  110560. }, {
  110561. label: "Env Irradiance",
  110562. value: 54
  110563. }, {
  110564. label: "Surface Albedo",
  110565. value: 60
  110566. }, {
  110567. label: "Reflectance 0",
  110568. value: 61
  110569. }, {
  110570. label: "Metallic",
  110571. value: 62
  110572. }, {
  110573. label: "Metallic F0",
  110574. value: 71
  110575. }, {
  110576. label: "Roughness",
  110577. value: 63
  110578. }, {
  110579. label: "AlphaG",
  110580. value: 64
  110581. }, {
  110582. label: "NdotV",
  110583. value: 65
  110584. }, {
  110585. label: "ClearCoat Color",
  110586. value: 66
  110587. }, {
  110588. label: "ClearCoat Roughness",
  110589. value: 67
  110590. }, {
  110591. label: "ClearCoat NdotV",
  110592. value: 68
  110593. }, {
  110594. label: "Transmittance",
  110595. value: 69
  110596. }, {
  110597. label: "Refraction Transmittance",
  110598. value: 70
  110599. }, {
  110600. label: "SEO",
  110601. value: 80
  110602. }, {
  110603. label: "EHO",
  110604. value: 81
  110605. }, {
  110606. label: "Energy Factor",
  110607. value: 82
  110608. }, {
  110609. label: "Specular Reflectance",
  110610. value: 83
  110611. }, {
  110612. label: "Clear Coat Reflectance",
  110613. value: 84
  110614. }, {
  110615. label: "Sheen Reflectance",
  110616. value: 85
  110617. }, {
  110618. label: "Luminance Over Alpha",
  110619. value: 86
  110620. }, {
  110621. label: "Alpha",
  110622. value: 87
  110623. }]
  110624. })], t.prototype, "debugMode", void 0),
  110625. k([Yp("Split position", Xp.Float, "DEBUG", {
  110626. min: -1,
  110627. max: 1,
  110628. notifiers: {
  110629. update: !0
  110630. }
  110631. })], t.prototype, "debugLimit", void 0),
  110632. k([Yp("Output factor", Xp.Float, "DEBUG", {
  110633. min: 0,
  110634. max: 5,
  110635. notifiers: {
  110636. update: !0
  110637. }
  110638. })], t.prototype, "debugFactor", void 0),
  110639. t
  110640. }(Wp);
  110641. y("BABYLON.PBRMetallicRoughnessBlock", Bg);
  110642. var Ug = function(e) {
  110643. function t(t) {
  110644. var i = e.call(this, t, Dp.Neutral) || this;
  110645. return i.registerInput("left", Op.AutoDetect),
  110646. i.registerInput("right", Op.AutoDetect),
  110647. i.registerOutput("output", Op.BasedOnInput),
  110648. i._outputs[0]._typeConnectionSource = i._inputs[0],
  110649. i._linkConnectionTypes(0, 1),
  110650. i
  110651. }
  110652. return U(t, e),
  110653. t.prototype.getClassName = function() {
  110654. return "ModBlock"
  110655. }
  110656. ,
  110657. Object.defineProperty(t.prototype, "left", {
  110658. get: function() {
  110659. return this._inputs[0]
  110660. },
  110661. enumerable: !1,
  110662. configurable: !0
  110663. }),
  110664. Object.defineProperty(t.prototype, "right", {
  110665. get: function() {
  110666. return this._inputs[1]
  110667. },
  110668. enumerable: !1,
  110669. configurable: !0
  110670. }),
  110671. Object.defineProperty(t.prototype, "output", {
  110672. get: function() {
  110673. return this._outputs[0]
  110674. },
  110675. enumerable: !1,
  110676. configurable: !0
  110677. }),
  110678. t.prototype._buildBlock = function(t) {
  110679. e.prototype._buildBlock.call(this, t);
  110680. var i = this._outputs[0];
  110681. return t.compilationString += this._declareOutput(i, t) + " = mod(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
  110682. this
  110683. }
  110684. ,
  110685. t
  110686. }(Wp);
  110687. y("BABYLON.ModBlock", Ug);
  110688. var Vg, kg = function(e) {
  110689. function t(t) {
  110690. var i = e.call(this, t, Dp.Neutral) || this;
  110691. return i.registerInput("row0", Op.Vector4),
  110692. i.registerInput("row1", Op.Vector4),
  110693. i.registerInput("row2", Op.Vector4),
  110694. i.registerInput("row3", Op.Vector4),
  110695. i.registerOutput("output", Op.Matrix),
  110696. i
  110697. }
  110698. return U(t, e),
  110699. t.prototype.getClassName = function() {
  110700. return "MatrixBuilder"
  110701. }
  110702. ,
  110703. Object.defineProperty(t.prototype, "row0", {
  110704. get: function() {
  110705. return this._inputs[0]
  110706. },
  110707. enumerable: !1,
  110708. configurable: !0
  110709. }),
  110710. Object.defineProperty(t.prototype, "row1", {
  110711. get: function() {
  110712. return this._inputs[1]
  110713. },
  110714. enumerable: !1,
  110715. configurable: !0
  110716. }),
  110717. Object.defineProperty(t.prototype, "row2", {
  110718. get: function() {
  110719. return this._inputs[2]
  110720. },
  110721. enumerable: !1,
  110722. configurable: !0
  110723. }),
  110724. Object.defineProperty(t.prototype, "row3", {
  110725. get: function() {
  110726. return this._inputs[3]
  110727. },
  110728. enumerable: !1,
  110729. configurable: !0
  110730. }),
  110731. Object.defineProperty(t.prototype, "output", {
  110732. get: function() {
  110733. return this._outputs[0]
  110734. },
  110735. enumerable: !1,
  110736. configurable: !0
  110737. }),
  110738. t.prototype.autoConfigure = function() {
  110739. if (!this.row0.isConnected) {
  110740. var e = new tf("row0");
  110741. e.value = new R(1,0,0,0),
  110742. e.output.connectTo(this.row0)
  110743. }
  110744. if (!this.row1.isConnected) {
  110745. var t = new tf("row1");
  110746. t.value = new R(0,1,0,0),
  110747. t.output.connectTo(this.row1)
  110748. }
  110749. if (!this.row2.isConnected) {
  110750. var i = new tf("row2");
  110751. i.value = new R(0,0,1,0),
  110752. i.output.connectTo(this.row2)
  110753. }
  110754. if (!this.row3.isConnected) {
  110755. var n = new tf("row3");
  110756. n.value = new R(0,0,0,1),
  110757. n.output.connectTo(this.row3)
  110758. }
  110759. }
  110760. ,
  110761. t.prototype._buildBlock = function(t) {
  110762. e.prototype._buildBlock.call(this, t);
  110763. var i = this._outputs[0]
  110764. , n = this.row0
  110765. , r = this.row1
  110766. , o = this.row2
  110767. , a = this.row3;
  110768. return t.compilationString += this._declareOutput(i, t) + " = mat4(".concat(n.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ");\r\n"),
  110769. this
  110770. }
  110771. ,
  110772. t
  110773. }(Wp);
  110774. y("BABYLON.MatrixBuilder", kg),
  110775. function(e) {
  110776. e[e.Equal = 0] = "Equal",
  110777. e[e.NotEqual = 1] = "NotEqual",
  110778. e[e.LessThan = 2] = "LessThan",
  110779. e[e.GreaterThan = 3] = "GreaterThan",
  110780. e[e.LessOrEqual = 4] = "LessOrEqual",
  110781. e[e.GreaterOrEqual = 5] = "GreaterOrEqual",
  110782. e[e.Xor = 6] = "Xor",
  110783. e[e.Or = 7] = "Or",
  110784. e[e.And = 8] = "And"
  110785. }(Vg || (Vg = {}));
  110786. var Gg = function(e) {
  110787. function t(t) {
  110788. var i = e.call(this, t, Dp.Neutral) || this;
  110789. return i.condition = Vg.LessThan,
  110790. i.registerInput("a", Op.Float),
  110791. i.registerInput("b", Op.Float),
  110792. i.registerInput("true", Op.AutoDetect, !0),
  110793. i.registerInput("false", Op.AutoDetect, !0),
  110794. i.registerOutput("output", Op.BasedOnInput),
  110795. i._linkConnectionTypes(2, 3),
  110796. i._outputs[0]._typeConnectionSource = i._inputs[2],
  110797. i._outputs[0]._defaultConnectionPointType = Op.Float,
  110798. i
  110799. }
  110800. return U(t, e),
  110801. t.prototype.getClassName = function() {
  110802. return "ConditionalBlock"
  110803. }
  110804. ,
  110805. Object.defineProperty(t.prototype, "a", {
  110806. get: function() {
  110807. return this._inputs[0]
  110808. },
  110809. enumerable: !1,
  110810. configurable: !0
  110811. }),
  110812. Object.defineProperty(t.prototype, "b", {
  110813. get: function() {
  110814. return this._inputs[1]
  110815. },
  110816. enumerable: !1,
  110817. configurable: !0
  110818. }),
  110819. Object.defineProperty(t.prototype, "true", {
  110820. get: function() {
  110821. return this._inputs[2]
  110822. },
  110823. enumerable: !1,
  110824. configurable: !0
  110825. }),
  110826. Object.defineProperty(t.prototype, "false", {
  110827. get: function() {
  110828. return this._inputs[3]
  110829. },
  110830. enumerable: !1,
  110831. configurable: !0
  110832. }),
  110833. Object.defineProperty(t.prototype, "output", {
  110834. get: function() {
  110835. return this._outputs[0]
  110836. },
  110837. enumerable: !1,
  110838. configurable: !0
  110839. }),
  110840. t.prototype._buildBlock = function(t) {
  110841. e.prototype._buildBlock.call(this, t);
  110842. var i = this._outputs[0]
  110843. , n = this.true.isConnected ? this.true.associatedVariableName : "1.0"
  110844. , r = this.false.isConnected ? this.false.associatedVariableName : "0.0";
  110845. switch (this.condition) {
  110846. case Vg.Equal:
  110847. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " == ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110848. break;
  110849. case Vg.NotEqual:
  110850. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " != ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110851. break;
  110852. case Vg.LessThan:
  110853. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " < ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110854. break;
  110855. case Vg.LessOrEqual:
  110856. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " <= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110857. break;
  110858. case Vg.GreaterThan:
  110859. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " > ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110860. break;
  110861. case Vg.GreaterOrEqual:
  110862. t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " >= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
  110863. break;
  110864. case Vg.Xor:
  110865. t.compilationString += this._declareOutput(i, t) + " = (mod(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 2.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
  110866. break;
  110867. case Vg.Or:
  110868. t.compilationString += this._declareOutput(i, t) + " = (min(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 1.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
  110869. break;
  110870. case Vg.And:
  110871. t.compilationString += this._declareOutput(i, t) + " = (".concat(this.a.associatedVariableName, " * ").concat(this.b.associatedVariableName, " > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n")
  110872. }
  110873. return this
  110874. }
  110875. ,
  110876. t.prototype.serialize = function() {
  110877. var t = e.prototype.serialize.call(this);
  110878. return t.condition = this.condition,
  110879. t
  110880. }
  110881. ,
  110882. t.prototype._deserialize = function(t, i, n) {
  110883. e.prototype._deserialize.call(this, t, i, n),
  110884. this.condition = t.condition
  110885. }
  110886. ,
  110887. t.prototype._dumpPropertiesCode = function() {
  110888. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".condition = BABYLON.ConditionalBlockConditions.").concat(Vg[this.condition], ";\r\n")
  110889. }
  110890. ,
  110891. t
  110892. }(Wp);
  110893. y("BABYLON.ConditionalBlock", Gg);
  110894. var zg = function(e) {
  110895. function t(t) {
  110896. var i = e.call(this, t, Dp.Neutral) || this;
  110897. return i.octaves = 6,
  110898. i.registerInput("seed", Op.AutoDetect),
  110899. i.registerInput("chaos", Op.AutoDetect, !0),
  110900. i.registerInput("offsetX", Op.Float, !0),
  110901. i.registerInput("offsetY", Op.Float, !0),
  110902. i.registerInput("offsetZ", Op.Float, !0),
  110903. i.registerOutput("output", Op.Float),
  110904. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
  110905. i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
  110906. i._linkConnectionTypes(0, 1),
  110907. i
  110908. }
  110909. return U(t, e),
  110910. t.prototype.getClassName = function() {
  110911. return "CloudBlock"
  110912. }
  110913. ,
  110914. Object.defineProperty(t.prototype, "seed", {
  110915. get: function() {
  110916. return this._inputs[0]
  110917. },
  110918. enumerable: !1,
  110919. configurable: !0
  110920. }),
  110921. Object.defineProperty(t.prototype, "chaos", {
  110922. get: function() {
  110923. return this._inputs[1]
  110924. },
  110925. enumerable: !1,
  110926. configurable: !0
  110927. }),
  110928. Object.defineProperty(t.prototype, "offsetX", {
  110929. get: function() {
  110930. return this._inputs[2]
  110931. },
  110932. enumerable: !1,
  110933. configurable: !0
  110934. }),
  110935. Object.defineProperty(t.prototype, "offsetY", {
  110936. get: function() {
  110937. return this._inputs[3]
  110938. },
  110939. enumerable: !1,
  110940. configurable: !0
  110941. }),
  110942. Object.defineProperty(t.prototype, "offsetZ", {
  110943. get: function() {
  110944. return this._inputs[4]
  110945. },
  110946. enumerable: !1,
  110947. configurable: !0
  110948. }),
  110949. Object.defineProperty(t.prototype, "output", {
  110950. get: function() {
  110951. return this._outputs[0]
  110952. },
  110953. enumerable: !1,
  110954. configurable: !0
  110955. }),
  110956. t.prototype._buildBlock = function(t) {
  110957. var i, n;
  110958. if (e.prototype._buildBlock.call(this, t),
  110959. this.seed.isConnected && this._outputs[0].hasEndpoints) {
  110960. var r = "fbm".concat(this.octaves);
  110961. t._emitFunction("CloudBlockCode", "\n\n float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }\n\n // Based on Morgan McGuire @morgan3d\n // https://www.shadertoy.com/view/4dS3Wd\n float cloudNoise(in vec2 x, in vec2 chaos) {\n vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);\n\n vec2 i = floor(x);\n vec2 f = fract(x);\n\n float n = dot(i, step);\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),\n mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),\n u.y\n );\n }\n\n float cloudNoise(in vec3 x, in vec3 chaos) {\n vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);\n\n vec3 i = floor(x);\n vec3 f = fract(x);\n\n float n = dot(i, step);\n\n vec3 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n }", "// CloudBlockCode"),
  110962. t._emitFunction("CloudBlockCodeFBM" + this.octaves, "\n float fbm(in vec2 st, in vec2 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = .5;\n float frequency = 0.;\n\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitude * cloudNoise(st, chaos);\n st *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n }\n\n float fbm(in vec3 x, in vec3 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < OCTAVES; ++i) {\n value += amplitude * cloudNoise(x, chaos);\n x = x * 2.0;\n amplitude *= 0.5;\n }\n return value;\n }".replace(/fbm/gi, r).replace(/OCTAVES/gi, (0 | this.octaves).toString()), "// CloudBlockCode FBM");
  110963. var o = t._getFreeVariableName("st")
  110964. , a = (null === (i = this.seed.connectedPoint) || void 0 === i ? void 0 : i.type) === Op.Vector2 ? "vec2" : "vec3";
  110965. t.compilationString += "".concat(a, " ").concat(o, " = ").concat(this.seed.associatedVariableName, ";\r\n"),
  110966. this.offsetX.isConnected && (t.compilationString += "".concat(o, ".x += 0.1 * ").concat(this.offsetX.associatedVariableName, ";\r\n")),
  110967. this.offsetY.isConnected && (t.compilationString += "".concat(o, ".y += 0.1 * ").concat(this.offsetY.associatedVariableName, ";\r\n")),
  110968. this.offsetZ.isConnected && "vec3" === a && (t.compilationString += "".concat(o, ".z += 0.1 * ").concat(this.offsetZ.associatedVariableName, ";\r\n"));
  110969. var s;
  110970. return s = this.chaos.isConnected ? this.chaos.associatedVariableName : (null === (n = this.seed.connectedPoint) || void 0 === n ? void 0 : n.type) === Op.Vector2 ? "vec2(0., 0.)" : "vec3(0., 0., 0.)",
  110971. t.compilationString += this._declareOutput(this._outputs[0], t) + " = ".concat(r, "(").concat(o, ", ").concat(s, ");\r\n"),
  110972. this
  110973. }
  110974. }
  110975. ,
  110976. t.prototype._dumpPropertiesCode = function() {
  110977. return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".octaves = ").concat(this.octaves, ";\r\n")
  110978. }
  110979. ,
  110980. t.prototype.serialize = function() {
  110981. var t = e.prototype.serialize.call(this);
  110982. return t.octaves = this.octaves,
  110983. t
  110984. }
  110985. ,
  110986. t.prototype._deserialize = function(t, i, n) {
  110987. e.prototype._deserialize.call(this, t, i, n),
  110988. this.octaves = t.octaves
  110989. }
  110990. ,
  110991. k([Yp("Octaves", Xp.Int)], t.prototype, "octaves", void 0),
  110992. t
  110993. }(Wp);
  110994. y("BABYLON.CloudBlock", zg);
  110995. var Wg = function(e) {
  110996. function t(t) {
  110997. var i = e.call(this, t, Dp.Neutral) || this;
  110998. return i.registerInput("seed", Op.Vector2),
  110999. i.registerInput("offset", Op.Float),
  111000. i.registerInput("density", Op.Float),
  111001. i.registerOutput("output", Op.Float),
  111002. i.registerOutput("cells", Op.Float),
  111003. i
  111004. }
  111005. return U(t, e),
  111006. t.prototype.getClassName = function() {
  111007. return "VoronoiNoiseBlock"
  111008. }
  111009. ,
  111010. Object.defineProperty(t.prototype, "seed", {
  111011. get: function() {
  111012. return this._inputs[0]
  111013. },
  111014. enumerable: !1,
  111015. configurable: !0
  111016. }),
  111017. Object.defineProperty(t.prototype, "offset", {
  111018. get: function() {
  111019. return this._inputs[1]
  111020. },
  111021. enumerable: !1,
  111022. configurable: !0
  111023. }),
  111024. Object.defineProperty(t.prototype, "density", {
  111025. get: function() {
  111026. return this._inputs[2]
  111027. },
  111028. enumerable: !1,
  111029. configurable: !0
  111030. }),
  111031. Object.defineProperty(t.prototype, "output", {
  111032. get: function() {
  111033. return this._outputs[0]
  111034. },
  111035. enumerable: !1,
  111036. configurable: !0
  111037. }),
  111038. Object.defineProperty(t.prototype, "cells", {
  111039. get: function() {
  111040. return this._outputs[1]
  111041. },
  111042. enumerable: !1,
  111043. configurable: !0
  111044. }),
  111045. t.prototype._buildBlock = function(t) {
  111046. if (e.prototype._buildBlock.call(this, t),
  111047. this.seed.isConnected) {
  111048. var i = "vec2 voronoiRandom(vec2 seed, float offset){\n mat2 m = mat2(15.27, 47.63, 99.41, 89.98);\n vec2 uv = fract(sin(m * seed) * 46839.32);\n return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);\n }\n ";
  111049. t._emitFunction("voronoiRandom", i, "// Voronoi random generator"),
  111050. i = "void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){\n vec2 g = floor(seed * density);\n vec2 f = fract(seed * density);\n float t = 8.0;\n vec3 res = vec3(8.0, 0.0, 0.0);\n\n for(int y=-1; y<=1; y++)\n {\n for(int x=-1; x<=1; x++)\n {\n vec2 lattice = vec2(x,y);\n vec2 randomOffset = voronoiRandom(lattice + g, offset);\n float d = distance(lattice + randomOffset, f);\n if(d < res.x)\n {\n res = vec3(d, randomOffset.x, randomOffset.y);\n outValue = res.x;\n cells = res.y;\n }\n }\n }\n }\n ",
  111051. t._emitFunction("voronoi", i, "// Voronoi");
  111052. var n = t._getFreeVariableName("tempOutput")
  111053. , r = t._getFreeVariableName("tempCells");
  111054. return t.compilationString += "float ".concat(n, " = 0.0;\r\n"),
  111055. t.compilationString += "float ".concat(r, " = 0.0;\r\n"),
  111056. t.compilationString += "voronoi(".concat(this.seed.associatedVariableName, ", ").concat(this.offset.associatedVariableName, ", ").concat(this.density.associatedVariableName, ", ").concat(n, ", ").concat(r, ");\r\n"),
  111057. this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(n, ";\r\n")),
  111058. this.cells.hasEndpoints && (t.compilationString += this._declareOutput(this.cells, t) + " = ".concat(r, ";\r\n")),
  111059. this
  111060. }
  111061. }
  111062. ,
  111063. t
  111064. }(Wp);
  111065. y("BABYLON.VoronoiNoiseBlock", Wg);
  111066. var Hg = function(e) {
  111067. function t(t) {
  111068. var i = e.call(this, t, Dp.Neutral) || this;
  111069. return i.registerInput("input", Op.AutoDetect),
  111070. i.registerOutput("output", Op.BasedOnInput),
  111071. i._outputs[0]._typeConnectionSource = i._inputs[0],
  111072. i
  111073. }
  111074. return U(t, e),
  111075. t.prototype.getClassName = function() {
  111076. return "ElbowBlock"
  111077. }
  111078. ,
  111079. Object.defineProperty(t.prototype, "input", {
  111080. get: function() {
  111081. return this._inputs[0]
  111082. },
  111083. enumerable: !1,
  111084. configurable: !0
  111085. }),
  111086. Object.defineProperty(t.prototype, "output", {
  111087. get: function() {
  111088. return this._outputs[0]
  111089. },
  111090. enumerable: !1,
  111091. configurable: !0
  111092. }),
  111093. Object.defineProperty(t.prototype, "target", {
  111094. get: function() {
  111095. var e = this._inputs[0];
  111096. return e.isConnected && e.connectedPoint.ownerBlock.isInput ? Dp.Vertex : this._target
  111097. },
  111098. set: function(e) {
  111099. 0 == (this._target & e) && (this._target = e)
  111100. },
  111101. enumerable: !1,
  111102. configurable: !0
  111103. }),
  111104. t.prototype._buildBlock = function(t) {
  111105. e.prototype._buildBlock.call(this, t);
  111106. var i = this._outputs[0]
  111107. , n = this._inputs[0];
  111108. return t.compilationString += this._declareOutput(i, t) + " = ".concat(n.associatedVariableName, ";\r\n"),
  111109. this
  111110. }
  111111. ,
  111112. t
  111113. }(Wp);
  111114. y("BABYLON.ElbowBlock", Hg);
  111115. var Xg = function() {
  111116. function e() {}
  111117. return e.prototype.optimize = function(e, t) {}
  111118. ,
  111119. e
  111120. }()
  111121. , jg = function() {
  111122. function e() {
  111123. this.mm = new Map
  111124. }
  111125. return e.prototype.get = function(e, t) {
  111126. var i = this.mm.get(e);
  111127. if (void 0 !== i)
  111128. return i.get(t)
  111129. }
  111130. ,
  111131. e.prototype.set = function(e, t, i) {
  111132. var n = this.mm.get(e);
  111133. void 0 === n && this.mm.set(e, n = new Map),
  111134. n.set(t, i)
  111135. }
  111136. ,
  111137. e
  111138. }()
  111139. , Yg = function() {
  111140. function e(e, t, i) {
  111141. var n = this;
  111142. this._baseMaterial = e,
  111143. this._scene = null != t ? t : E.LastCreatedScene,
  111144. this._options = i,
  111145. this._subMeshToEffect = new Map,
  111146. this._subMeshToDepthWrapper = new jg,
  111147. this._meshes = new Map,
  111148. this._onEffectCreatedObserver = this._baseMaterial.onEffectCreatedObservable.add((function(e) {
  111149. var t, i = null === (t = e.subMesh) || void 0 === t ? void 0 : t.getMesh();
  111150. i && !n._meshes.has(i) && n._meshes.set(i, i.onDisposeObservable.add((function(e) {
  111151. for (var t = n._subMeshToEffect.keys(), i = t.next(); !0 !== i.done; i = t.next()) {
  111152. var r = i.value;
  111153. (null == r ? void 0 : r.getMesh()) === e && (n._subMeshToEffect.delete(r),
  111154. n._subMeshToDepthWrapper.mm.delete(r))
  111155. }
  111156. }
  111157. ))),
  111158. n._subMeshToEffect.set(e.subMesh, [e.effect, n._scene.getEngine().currentRenderPassId]),
  111159. n._subMeshToDepthWrapper.mm.delete(e.subMesh)
  111160. }
  111161. ))
  111162. }
  111163. return Object.defineProperty(e.prototype, "standalone", {
  111164. get: function() {
  111165. var e, t;
  111166. return null !== (t = null === (e = this._options) || void 0 === e ? void 0 : e.standalone) && void 0 !== t && t
  111167. },
  111168. enumerable: !1,
  111169. configurable: !0
  111170. }),
  111171. Object.defineProperty(e.prototype, "baseMaterial", {
  111172. get: function() {
  111173. return this._baseMaterial
  111174. },
  111175. enumerable: !1,
  111176. configurable: !0
  111177. }),
  111178. e.prototype.getEffect = function(e, t, i) {
  111179. var n, r = null === (n = this._subMeshToDepthWrapper.mm.get(e)) || void 0 === n ? void 0 : n.get(t);
  111180. if (!r)
  111181. return null;
  111182. var o = r.drawWrapper[i];
  111183. return o || (o = r.drawWrapper[i] = new Gt(this._scene.getEngine())).setEffect(r.mainDrawWrapper.effect, r.mainDrawWrapper.defines),
  111184. o
  111185. }
  111186. ,
  111187. e.prototype.isReadyForSubMesh = function(e, t, i, n, r) {
  111188. var o, a;
  111189. return !(this.standalone && !this._baseMaterial.isReadyForSubMesh(e.getMesh(), e, n)) && null !== (a = null === (o = this._makeEffect(e, t, i, r)) || void 0 === o ? void 0 : o.isReady()) && void 0 !== a && a
  111190. }
  111191. ,
  111192. e.prototype.dispose = function() {
  111193. this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),
  111194. this._onEffectCreatedObserver = null;
  111195. for (var e = this._meshes.entries(), t = e.next(); !0 !== t.done; t = e.next()) {
  111196. var i = t.value
  111197. , n = i[0]
  111198. , r = i[1];
  111199. n.onDisposeObservable.remove(r)
  111200. }
  111201. }
  111202. ,
  111203. e.prototype._makeEffect = function(e, t, i, n) {
  111204. var r, o, a, s = this._scene.getEngine(), l = this._subMeshToEffect.get(e);
  111205. if (!l)
  111206. return null;
  111207. var c = l[0]
  111208. , u = l[1]
  111209. , h = this._subMeshToDepthWrapper.get(e, i);
  111210. if (!h) {
  111211. var d = new Gt(s);
  111212. d.defines = null !== (o = null === (r = e._getDrawWrapper(u)) || void 0 === r ? void 0 : r.defines) && void 0 !== o ? o : null,
  111213. (h = {
  111214. drawWrapper: [],
  111215. mainDrawWrapper: d,
  111216. depthDefines: "",
  111217. token: fi()
  111218. }).drawWrapper[n] = d,
  111219. this._subMeshToDepthWrapper.set(e, i, h)
  111220. }
  111221. var p = t.join("\n");
  111222. if (h.mainDrawWrapper.effect && p === h.depthDefines)
  111223. return h.mainDrawWrapper.effect;
  111224. h.depthDefines = p;
  111225. var f = c.rawVertexSourceCode
  111226. , _ = c.rawFragmentSourceCode
  111227. , m = this._options && this._options.remappedVariables ? "#include<shadowMapVertexNormalBias>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexNormalBias
  111228. , g = this._options && this._options.remappedVariables ? "#include<shadowMapVertexMetric>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexMetric
  111229. , v = this._options && this._options.remappedVariables ? "#include<shadowMapFragmentSoftTransparentShadow>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow
  111230. , y = Mt.IncludesShadersStore.shadowMapFragment;
  111231. f = (f = -1 !== (f = (f = f.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapVertexExtraDeclaration + "\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, m)).indexOf("#define SHADOWDEPTH_METRIC") ? f.replace(/#define SHADOWDEPTH_METRIC/g, g) : f.replace(/}\s*$/g, g + "\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
  111232. var b = _.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW") >= 0 || _.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG") >= 0
  111233. , T = -1 !== _.indexOf("#define SHADOWDEPTH_FRAGMENT")
  111234. , E = "";
  111235. b ? _ = _.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g, v) : E = v + "\r\n",
  111236. _ = _.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapFragmentExtraDeclaration + "\r\nvoid main"),
  111237. T ? _ = _.replace(/#define SHADOWDEPTH_FRAGMENT/g, y) : E += y + "\r\n",
  111238. E && (_ = _.replace(/}\s*$/g, E + "}")),
  111239. _ = _.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
  111240. var S = c.getUniformNames().slice();
  111241. S.push("biasAndScaleSM", "depthValuesSM", "lightDataSM", "softTransparentShadowSM"),
  111242. h.mainDrawWrapper.effect = s.createEffect({
  111243. vertexSource: f,
  111244. fragmentSource: _,
  111245. vertexToken: h.token,
  111246. fragmentToken: h.token
  111247. }, {
  111248. attributes: c.getAttributesNames(),
  111249. uniformsNames: S,
  111250. uniformBuffersNames: c.getUniformBuffersNames(),
  111251. samplers: c.getSamplers(),
  111252. defines: p + "\n" + c.defines.replace("#define SHADOWS", "").replace(/#define SHADOW\d/g, ""),
  111253. indexParameters: c.getIndexParameters()
  111254. }, s);
  111255. for (var A = 0; A < h.drawWrapper.length; ++A)
  111256. A !== n && (null === (a = h.drawWrapper[A]) || void 0 === a || a.setEffect(h.mainDrawWrapper.effect, h.mainDrawWrapper.defines));
  111257. return h.mainDrawWrapper.effect
  111258. }
  111259. ,
  111260. e
  111261. }();
  111262. function Kg(e) {
  111263. return e instanceof rp ? new Zd(e) : null
  111264. }
  111265. function Qg(e) {
  111266. return e instanceof rp ? new Yd(e) : null
  111267. }
  111268. function qg(e) {
  111269. return e instanceof rp ? new Qd(e) : null
  111270. }
  111271. function Zg(e) {
  111272. return e instanceof rp ? new $d(e) : null
  111273. }
  111274. function Jg(e) {
  111275. return e instanceof rp ? new tp(e) : null
  111276. }
  111277. function $g(e) {
  111278. return e instanceof rp || e instanceof Os ? new Ps(e) : null
  111279. }
  111280. function ev(e, t, i, n, r, o) {
  111281. var a = new e.DecoderBuffer;
  111282. a.Init(t, t.byteLength);
  111283. var s, l, c = new e.Decoder;
  111284. try {
  111285. var u = c.GetEncodedGeometryType(a);
  111286. switch (u) {
  111287. case e.TRIANGULAR_MESH:
  111288. s = new e.Mesh,
  111289. l = c.DecodeBufferToMesh(a, s);
  111290. break;
  111291. case e.POINT_CLOUD:
  111292. s = new e.PointCloud,
  111293. l = c.DecodeBufferToPointCloud(a, s);
  111294. break;
  111295. default:
  111296. throw new Error("Invalid geometry type ".concat(u))
  111297. }
  111298. if (!l.ok() || !s.ptr)
  111299. throw new Error(l.error_msg());
  111300. if (u === e.TRIANGULAR_MESH) {
  111301. var h = 3 * s.num_faces()
  111302. , d = 4 * h
  111303. , p = e._malloc(d);
  111304. try {
  111305. c.GetTrianglesUInt32Array(s, d, p);
  111306. var f = new Uint32Array(h);
  111307. f.set(new Uint32Array(e.HEAPF32.buffer,p,h)),
  111308. n(f)
  111309. } finally {
  111310. e._free(p)
  111311. }
  111312. }
  111313. var _ = function(t, i, n) {
  111314. void 0 === n && (n = 1);
  111315. var o = i.num_components()
  111316. , a = s.num_points()
  111317. , l = a * o
  111318. , u = l * Float32Array.BYTES_PER_ELEMENT
  111319. , h = e._malloc(u);
  111320. try {
  111321. c.GetAttributeDataArrayForAllPoints(s, i, e.DT_FLOAT32, u, h);
  111322. var d = new Float32Array(e.HEAPF32.buffer,h,l);
  111323. if ("color" === t && 3 === o) {
  111324. for (var p = new Float32Array(4 * a), f = 0, _ = 0; f < p.length; f += 4,
  111325. _ += o)
  111326. p[f + 0] = d[_ + 0],
  111327. p[f + 1] = d[_ + 1],
  111328. p[f + 2] = d[_ + 2],
  111329. p[f + 3] = 1;
  111330. r(t, p)
  111331. } else {
  111332. if ((p = new Float32Array(l)).set(new Float32Array(e.HEAPF32.buffer,h,l)),
  111333. 1 !== n)
  111334. for (f = 0; f < p.length; f++)
  111335. p[f] = p[f] / n;
  111336. r(t, p)
  111337. }
  111338. } finally {
  111339. e._free(h)
  111340. }
  111341. };
  111342. if (i)
  111343. for (var m in i) {
  111344. var g = i[m];
  111345. _(m, c.GetAttributeByUniqueId(s, g), o && o[m] || 1)
  111346. }
  111347. else {
  111348. var v = {
  111349. position: "POSITION",
  111350. normal: "NORMAL",
  111351. color: "COLOR",
  111352. uv: "TEX_COORD"
  111353. };
  111354. for (var m in v)
  111355. -1 !== (g = c.GetAttributeId(s, e[v[m]])) && _(m, c.GetAttribute(s, g))
  111356. }
  111357. } finally {
  111358. s && e.destroy(s),
  111359. e.destroy(c),
  111360. e.destroy(a)
  111361. }
  111362. }
  111363. function tv() {
  111364. var e;
  111365. onmessage = function(t) {
  111366. var i = t.data;
  111367. switch (i.id) {
  111368. case "init":
  111369. var n = i.decoder;
  111370. n.url && (importScripts(n.url),
  111371. e = DracoDecoderModule({
  111372. wasmBinary: n.wasmBinary
  111373. })),
  111374. postMessage("done");
  111375. break;
  111376. case "decodeMesh":
  111377. if (!e)
  111378. throw new Error("Draco decoder module is not available");
  111379. e.then((function(e) {
  111380. ev(e, i.dataView, i.attributes, (function(e) {
  111381. postMessage({
  111382. id: "indices",
  111383. value: e
  111384. }, [e.buffer])
  111385. }
  111386. ), (function(e, t) {
  111387. postMessage({
  111388. id: e,
  111389. value: t
  111390. }, [t.buffer])
  111391. }
  111392. )),
  111393. postMessage("done")
  111394. }
  111395. ))
  111396. }
  111397. }
  111398. }
  111399. var iv = function() {
  111400. function e(t) {
  111401. void 0 === t && (t = e.DefaultNumWorkers);
  111402. var i = e.Configuration.decoder
  111403. , n = i.wasmUrl && i.wasmBinaryUrl && "object" == typeof WebAssembly ? {
  111404. url: gi.GetAbsoluteUrl(i.wasmUrl),
  111405. wasmBinaryPromise: gi.LoadFileAsync(gi.GetAbsoluteUrl(i.wasmBinaryUrl))
  111406. } : {
  111407. url: gi.GetAbsoluteUrl(i.fallbackUrl),
  111408. wasmBinaryPromise: Promise.resolve(void 0)
  111409. };
  111410. t && "function" == typeof Worker ? this._workerPoolPromise = n.wasmBinaryPromise.then((function(e) {
  111411. var i = "".concat(ev, "(").concat(tv, ")()")
  111412. , r = URL.createObjectURL(new Blob([i],{
  111413. type: "application/javascript"
  111414. }));
  111415. return new vp(t,(function() {
  111416. return new Promise((function(t, i) {
  111417. var o = new Worker(r)
  111418. , a = function(e) {
  111419. o.removeEventListener("error", a),
  111420. o.removeEventListener("message", s),
  111421. i(e)
  111422. }
  111423. , s = function(e) {
  111424. "done" === e.data && (o.removeEventListener("error", a),
  111425. o.removeEventListener("message", s),
  111426. t(o))
  111427. };
  111428. o.addEventListener("error", a),
  111429. o.addEventListener("message", s),
  111430. o.postMessage({
  111431. id: "init",
  111432. decoder: {
  111433. url: n.url,
  111434. wasmBinary: e
  111435. }
  111436. })
  111437. }
  111438. ))
  111439. }
  111440. ))
  111441. }
  111442. )) : this._decoderModulePromise = n.wasmBinaryPromise.then((function(e) {
  111443. if (!n.url)
  111444. throw new Error("Draco decoder module is not available");
  111445. return gi.LoadScriptAsync(n.url).then((function() {
  111446. return t = e,
  111447. new Promise((function(e) {
  111448. DracoDecoderModule({
  111449. wasmBinary: t
  111450. }).then((function(t) {
  111451. e({
  111452. module: t
  111453. })
  111454. }
  111455. ))
  111456. }
  111457. ));
  111458. var t
  111459. }
  111460. ))
  111461. }
  111462. ))
  111463. }
  111464. return Object.defineProperty(e, "DecoderAvailable", {
  111465. get: function() {
  111466. var t = e.Configuration.decoder;
  111467. return !!(t.wasmUrl && t.wasmBinaryUrl && "object" == typeof WebAssembly || t.fallbackUrl)
  111468. },
  111469. enumerable: !1,
  111470. configurable: !0
  111471. }),
  111472. e.GetDefaultNumWorkers = function() {
  111473. return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1
  111474. }
  111475. ,
  111476. Object.defineProperty(e, "Default", {
  111477. get: function() {
  111478. return e._Default || (e._Default = new e),
  111479. e._Default
  111480. },
  111481. enumerable: !1,
  111482. configurable: !0
  111483. }),
  111484. e.prototype.dispose = function() {
  111485. this._workerPoolPromise && this._workerPoolPromise.then((function(e) {
  111486. e.dispose()
  111487. }
  111488. )),
  111489. delete this._workerPoolPromise,
  111490. delete this._decoderModulePromise
  111491. }
  111492. ,
  111493. e.prototype.whenReadyAsync = function() {
  111494. return this._workerPoolPromise ? this._workerPoolPromise.then((function() {}
  111495. )) : this._decoderModulePromise ? this._decoderModulePromise.then((function() {}
  111496. )) : Promise.resolve()
  111497. }
  111498. ,
  111499. e.prototype.decodeMeshAsync = function(e, t, i) {
  111500. var n = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
  111501. if (this._workerPoolPromise)
  111502. return this._workerPoolPromise.then((function(e) {
  111503. return new Promise((function(r, o) {
  111504. e.push((function(e, a) {
  111505. var s = new $n
  111506. , l = function(t) {
  111507. e.removeEventListener("error", l),
  111508. e.removeEventListener("message", c),
  111509. o(t),
  111510. a()
  111511. }
  111512. , c = function(t) {
  111513. if ("done" === t.data)
  111514. e.removeEventListener("error", l),
  111515. e.removeEventListener("message", c),
  111516. r(s),
  111517. a();
  111518. else if ("indices" === t.data.id)
  111519. s.indices = t.data.value;
  111520. else {
  111521. var n = i && i[t.data.id] ? i[t.data.id] : 1;
  111522. if (1 !== n)
  111523. for (var o = 0; o < t.data.value.length; o++)
  111524. t.data.value[o] = t.data.value[o] / n;
  111525. s.set(t.data.value, t.data.id)
  111526. }
  111527. };
  111528. e.addEventListener("error", l),
  111529. e.addEventListener("message", c);
  111530. var u = new Uint8Array(n.byteLength);
  111531. u.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),
  111532. e.postMessage({
  111533. id: "decodeMesh",
  111534. dataView: u,
  111535. attributes: t
  111536. }, [u.buffer])
  111537. }
  111538. ))
  111539. }
  111540. ))
  111541. }
  111542. ));
  111543. if (this._decoderModulePromise)
  111544. return this._decoderModulePromise.then((function(e) {
  111545. var r = new $n;
  111546. return ev(e.module, n, t, (function(e) {
  111547. r.indices = e
  111548. }
  111549. ), (function(e, t) {
  111550. r.set(t, e)
  111551. }
  111552. ), i),
  111553. r
  111554. }
  111555. ));
  111556. throw new Error("Draco decoder module is not available")
  111557. }
  111558. ,
  111559. e.Configuration = {
  111560. decoder: {
  111561. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  111562. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  111563. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  111564. }
  111565. },
  111566. e.DefaultNumWorkers = e.GetDefaultNumWorkers(),
  111567. e._Default = null,
  111568. e
  111569. }()
  111570. , nv = function() {
  111571. function e() {
  111572. var t = e.Configuration.decoder;
  111573. this._decoderModulePromise = gi.LoadScriptAsync(gi.GetAbsoluteUrl(t.url)).then((function() {
  111574. return MeshoptDecoder.ready
  111575. }
  111576. ))
  111577. }
  111578. return Object.defineProperty(e, "Default", {
  111579. get: function() {
  111580. return e._Default || (e._Default = new e),
  111581. e._Default
  111582. },
  111583. enumerable: !1,
  111584. configurable: !0
  111585. }),
  111586. e.prototype.dispose = function() {
  111587. delete this._decoderModulePromise
  111588. }
  111589. ,
  111590. e.prototype.decodeGltfBufferAsync = function(e, t, i, n, r) {
  111591. return this._decoderModulePromise.then((function() {
  111592. var o = new Uint8Array(t * i);
  111593. return MeshoptDecoder.decodeGltfBuffer(o, t, i, e, n, r),
  111594. o
  111595. }
  111596. ))
  111597. }
  111598. ,
  111599. e.Configuration = {
  111600. decoder: {
  111601. url: "https://preview.babylonjs.com/meshopt_decoder.js"
  111602. }
  111603. },
  111604. e._Default = null,
  111605. e
  111606. }()
  111607. , rv = 0
  111608. , ov = function() {
  111609. function e(e, t, i, n) {
  111610. this.pos = e,
  111611. this.normal = t,
  111612. this.uv = i,
  111613. this.vertColor = n
  111614. }
  111615. return e.prototype.clone = function() {
  111616. var t, i;
  111617. return new e(this.pos.clone(),this.normal.clone(),null === (t = this.uv) || void 0 === t ? void 0 : t.clone(),null === (i = this.vertColor) || void 0 === i ? void 0 : i.clone())
  111618. }
  111619. ,
  111620. e.prototype.flip = function() {
  111621. this.normal = this.normal.scale(-1)
  111622. }
  111623. ,
  111624. e.prototype.interpolate = function(t, i) {
  111625. return new e(x.Lerp(this.pos, t.pos, i),x.Lerp(this.normal, t.normal, i),this.uv && t.uv ? A.Lerp(this.uv, t.uv, i) : void 0,this.vertColor && t.vertColor ? N.Lerp(this.vertColor, t.vertColor, i) : void 0)
  111626. }
  111627. ,
  111628. e
  111629. }()
  111630. , av = function() {
  111631. function e(e, t) {
  111632. this.normal = e,
  111633. this.w = t
  111634. }
  111635. return e.FromPoints = function(t, i, n) {
  111636. var r = n.subtract(t)
  111637. , o = i.subtract(t);
  111638. if (0 === r.lengthSquared() || 0 === o.lengthSquared())
  111639. return null;
  111640. var a = x.Normalize(x.Cross(r, o));
  111641. return new e(a,x.Dot(a, t))
  111642. }
  111643. ,
  111644. e.prototype.clone = function() {
  111645. return new e(this.normal.clone(),this.w)
  111646. }
  111647. ,
  111648. e.prototype.flip = function() {
  111649. this.normal.scaleInPlace(-1),
  111650. this.w = -this.w
  111651. }
  111652. ,
  111653. e.prototype.splitPolygon = function(t, i, n, r, o) {
  111654. var a, s, l = 0, c = [];
  111655. for (a = 0; a < t.vertices.length; a++) {
  111656. var u = (s = x.Dot(this.normal, t.vertices[a].pos) - this.w) < -e.EPSILON ? 2 : s > e.EPSILON ? 1 : 0;
  111657. l |= u,
  111658. c.push(u)
  111659. }
  111660. switch (l) {
  111661. case 0:
  111662. (x.Dot(this.normal, t.plane.normal) > 0 ? i : n).push(t);
  111663. break;
  111664. case 1:
  111665. r.push(t);
  111666. break;
  111667. case 2:
  111668. o.push(t);
  111669. break;
  111670. case 3:
  111671. var h = []
  111672. , d = [];
  111673. for (a = 0; a < t.vertices.length; a++) {
  111674. var p = (a + 1) % t.vertices.length
  111675. , f = c[a]
  111676. , _ = c[p]
  111677. , m = t.vertices[a]
  111678. , g = t.vertices[p];
  111679. if (2 !== f && h.push(m),
  111680. 1 !== f && d.push(2 !== f ? m.clone() : m),
  111681. 3 == (f | _)) {
  111682. s = (this.w - x.Dot(this.normal, m.pos)) / x.Dot(this.normal, g.pos.subtract(m.pos));
  111683. var v = m.interpolate(g, s);
  111684. h.push(v),
  111685. d.push(v.clone())
  111686. }
  111687. }
  111688. var y = void 0;
  111689. h.length >= 3 && (y = new sv(h,t.shared)).plane && r.push(y),
  111690. d.length >= 3 && (y = new sv(d,t.shared)).plane && o.push(y)
  111691. }
  111692. }
  111693. ,
  111694. e.EPSILON = 1e-5,
  111695. e
  111696. }()
  111697. , sv = function() {
  111698. function e(e, t) {
  111699. this.vertices = e,
  111700. this.shared = t,
  111701. this.plane = av.FromPoints(e[0].pos, e[1].pos, e[2].pos)
  111702. }
  111703. return e.prototype.clone = function() {
  111704. return new e(this.vertices.map((function(e) {
  111705. return e.clone()
  111706. }
  111707. )),this.shared)
  111708. }
  111709. ,
  111710. e.prototype.flip = function() {
  111711. this.vertices.reverse().map((function(e) {
  111712. e.flip()
  111713. }
  111714. )),
  111715. this.plane.flip()
  111716. }
  111717. ,
  111718. e
  111719. }()
  111720. , lv = function() {
  111721. function e(e) {
  111722. this._plane = null,
  111723. this._front = null,
  111724. this._back = null,
  111725. this._polygons = new Array,
  111726. e && this.build(e)
  111727. }
  111728. return e.prototype.clone = function() {
  111729. var t = new e;
  111730. return t._plane = this._plane && this._plane.clone(),
  111731. t._front = this._front && this._front.clone(),
  111732. t._back = this._back && this._back.clone(),
  111733. t._polygons = this._polygons.map((function(e) {
  111734. return e.clone()
  111735. }
  111736. )),
  111737. t
  111738. }
  111739. ,
  111740. e.prototype.invert = function() {
  111741. for (var e = 0; e < this._polygons.length; e++)
  111742. this._polygons[e].flip();
  111743. this._plane && this._plane.flip(),
  111744. this._front && this._front.invert(),
  111745. this._back && this._back.invert();
  111746. var t = this._front;
  111747. this._front = this._back,
  111748. this._back = t
  111749. }
  111750. ,
  111751. e.prototype.clipPolygons = function(e) {
  111752. if (!this._plane)
  111753. return e.slice();
  111754. for (var t = new Array, i = new Array, n = 0; n < e.length; n++)
  111755. this._plane.splitPolygon(e[n], t, i, t, i);
  111756. return this._front && (t = this._front.clipPolygons(t)),
  111757. i = this._back ? this._back.clipPolygons(i) : [],
  111758. t.concat(i)
  111759. }
  111760. ,
  111761. e.prototype.clipTo = function(e) {
  111762. this._polygons = e.clipPolygons(this._polygons),
  111763. this._front && this._front.clipTo(e),
  111764. this._back && this._back.clipTo(e)
  111765. }
  111766. ,
  111767. e.prototype.allPolygons = function() {
  111768. var e = this._polygons.slice();
  111769. return this._front && (e = e.concat(this._front.allPolygons())),
  111770. this._back && (e = e.concat(this._back.allPolygons())),
  111771. e
  111772. }
  111773. ,
  111774. e.prototype.build = function(t) {
  111775. if (t.length) {
  111776. this._plane || (this._plane = t[0].plane.clone());
  111777. for (var i = new Array, n = new Array, r = 0; r < t.length; r++)
  111778. this._plane.splitPolygon(t[r], this._polygons, this._polygons, i, n);
  111779. i.length && (this._front || (this._front = new e),
  111780. this._front.build(i)),
  111781. n.length && (this._back || (this._back = new e),
  111782. this._back.build(n))
  111783. }
  111784. }
  111785. ,
  111786. e
  111787. }()
  111788. , cv = function() {
  111789. function e() {
  111790. this._polygons = new Array
  111791. }
  111792. return e.FromMesh = function(t, i) {
  111793. void 0 === i && (i = !1);
  111794. var n, r, o, s, l, c, u, h, d, p = void 0, f = void 0, _ = new Array, m = null, g = !1;
  111795. if (!(t instanceof Vr))
  111796. throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";
  111797. t.computeWorldMatrix(!0),
  111798. c = t.getWorldMatrix(),
  111799. u = t.position.clone(),
  111800. h = t.rotation.clone(),
  111801. t.rotationQuaternion && (m = t.rotationQuaternion.clone()),
  111802. d = t.scaling.clone(),
  111803. t.material && i && (g = t.material.sideOrientation === a.MATERIAL_ClockWiseSideOrientation);
  111804. for (var v = t.getIndices(), y = t.getVerticesData(Bi.PositionKind), b = t.getVerticesData(Bi.NormalKind), T = t.getVerticesData(Bi.UVKind), E = t.getVerticesData(Bi.ColorKind), S = t.subMeshes, R = 0, M = S.length; R < M; R++)
  111805. for (var I = S[R].indexStart, O = S[R].indexCount + S[R].indexStart; I < O; I += 3) {
  111806. l = [];
  111807. for (var D = 0; D < 3; D++) {
  111808. var L = 0 === D ? I + D : g ? I + 3 - D : I + D
  111809. , F = new x(b[3 * v[L]],b[3 * v[L] + 1],b[3 * v[L] + 2]);
  111810. T && (p = new A(T[2 * v[L]],T[2 * v[L] + 1])),
  111811. E && (f = new N(E[4 * v[L]],E[4 * v[L] + 1],E[4 * v[L] + 2],E[4 * v[L] + 3]));
  111812. var w = new x(y[3 * v[L]],y[3 * v[L] + 1],y[3 * v[L] + 2]);
  111813. o = x.TransformCoordinates(w, c),
  111814. r = x.TransformNormal(F, c),
  111815. n = new ov(o,r,p,f),
  111816. l.push(n)
  111817. }
  111818. (s = new sv(l,{
  111819. subMeshId: R,
  111820. meshId: rv,
  111821. materialIndex: S[R].materialIndex
  111822. })).plane && _.push(s)
  111823. }
  111824. var B = e._FromPolygons(_);
  111825. return B.matrix = i ? P.Identity() : c,
  111826. B.position = i ? x.Zero() : u,
  111827. B.rotation = i ? x.Zero() : h,
  111828. B.scaling = i ? x.One() : d,
  111829. B.rotationQuaternion = i && m ? C.Identity() : m,
  111830. rv++,
  111831. B
  111832. }
  111833. ,
  111834. e._FromPolygons = function(t) {
  111835. var i = new e;
  111836. return i._polygons = t,
  111837. i
  111838. }
  111839. ,
  111840. e.prototype.clone = function() {
  111841. var t = new e;
  111842. return t._polygons = this._polygons.map((function(e) {
  111843. return e.clone()
  111844. }
  111845. )),
  111846. t.copyTransformAttributes(this),
  111847. t
  111848. }
  111849. ,
  111850. e.prototype.union = function(t) {
  111851. var i = new lv(this.clone()._polygons)
  111852. , n = new lv(t.clone()._polygons);
  111853. return i.clipTo(n),
  111854. n.clipTo(i),
  111855. n.invert(),
  111856. n.clipTo(i),
  111857. n.invert(),
  111858. i.build(n.allPolygons()),
  111859. e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
  111860. }
  111861. ,
  111862. e.prototype.unionInPlace = function(e) {
  111863. var t = new lv(this._polygons)
  111864. , i = new lv(e._polygons);
  111865. t.clipTo(i),
  111866. i.clipTo(t),
  111867. i.invert(),
  111868. i.clipTo(t),
  111869. i.invert(),
  111870. t.build(i.allPolygons()),
  111871. this._polygons = t.allPolygons()
  111872. }
  111873. ,
  111874. e.prototype.subtract = function(t) {
  111875. var i = new lv(this.clone()._polygons)
  111876. , n = new lv(t.clone()._polygons);
  111877. return i.invert(),
  111878. i.clipTo(n),
  111879. n.clipTo(i),
  111880. n.invert(),
  111881. n.clipTo(i),
  111882. n.invert(),
  111883. i.build(n.allPolygons()),
  111884. i.invert(),
  111885. e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
  111886. }
  111887. ,
  111888. e.prototype.subtractInPlace = function(e) {
  111889. var t = new lv(this._polygons)
  111890. , i = new lv(e._polygons);
  111891. t.invert(),
  111892. t.clipTo(i),
  111893. i.clipTo(t),
  111894. i.invert(),
  111895. i.clipTo(t),
  111896. i.invert(),
  111897. t.build(i.allPolygons()),
  111898. t.invert(),
  111899. this._polygons = t.allPolygons()
  111900. }
  111901. ,
  111902. e.prototype.intersect = function(t) {
  111903. var i = new lv(this.clone()._polygons)
  111904. , n = new lv(t.clone()._polygons);
  111905. return i.invert(),
  111906. n.clipTo(i),
  111907. n.invert(),
  111908. i.clipTo(n),
  111909. n.clipTo(i),
  111910. i.build(n.allPolygons()),
  111911. i.invert(),
  111912. e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
  111913. }
  111914. ,
  111915. e.prototype.intersectInPlace = function(e) {
  111916. var t = new lv(this._polygons)
  111917. , i = new lv(e._polygons);
  111918. t.invert(),
  111919. i.clipTo(t),
  111920. i.invert(),
  111921. t.clipTo(i),
  111922. i.clipTo(t),
  111923. t.build(i.allPolygons()),
  111924. t.invert(),
  111925. this._polygons = t.allPolygons()
  111926. }
  111927. ,
  111928. e.prototype.inverse = function() {
  111929. var e = this.clone();
  111930. return e.inverseInPlace(),
  111931. e
  111932. }
  111933. ,
  111934. e.prototype.inverseInPlace = function() {
  111935. this._polygons.map((function(e) {
  111936. e.flip()
  111937. }
  111938. ))
  111939. }
  111940. ,
  111941. e.prototype.copyTransformAttributes = function(e) {
  111942. return this.matrix = e.matrix,
  111943. this.position = e.position,
  111944. this.rotation = e.rotation,
  111945. this.scaling = e.scaling,
  111946. this.rotationQuaternion = e.rotationQuaternion,
  111947. this
  111948. }
  111949. ,
  111950. e.prototype.buildMeshGeometry = function(e, t, i) {
  111951. var n = this.matrix.clone();
  111952. n.invert();
  111953. var r, o, a, s = new Vr(e,t), l = [], c = [], u = [], h = null, d = null, p = x.Zero(), f = x.Zero(), _ = A.Zero(), m = new N(0,0,0,0), g = this._polygons, v = [0, 0, 0], y = {}, b = 0, T = {};
  111954. i && g.sort((function(e, t) {
  111955. return e.shared.meshId === t.shared.meshId ? e.shared.subMeshId - t.shared.subMeshId : e.shared.meshId - t.shared.meshId
  111956. }
  111957. ));
  111958. for (var E = 0, S = g.length; E < S; E++) {
  111959. T[(r = g[E]).shared.meshId] || (T[r.shared.meshId] = {}),
  111960. T[r.shared.meshId][r.shared.subMeshId] || (T[r.shared.meshId][r.shared.subMeshId] = {
  111961. indexStart: 1 / 0,
  111962. indexEnd: -1 / 0,
  111963. materialIndex: r.shared.materialIndex
  111964. }),
  111965. a = T[r.shared.meshId][r.shared.subMeshId];
  111966. for (var R = 2, C = r.vertices.length; R < C; R++) {
  111967. v[0] = 0,
  111968. v[1] = R - 1,
  111969. v[2] = R;
  111970. for (var P = 0; P < 3; P++) {
  111971. p.copyFrom(r.vertices[v[P]].pos),
  111972. f.copyFrom(r.vertices[v[P]].normal),
  111973. r.vertices[v[P]].uv && (h || (h = []),
  111974. _.copyFrom(r.vertices[v[P]].uv)),
  111975. r.vertices[v[P]].vertColor && (d || (d = []),
  111976. m.copyFrom(r.vertices[v[P]].vertColor));
  111977. var M = x.TransformCoordinates(p, n)
  111978. , I = x.TransformNormal(f, n);
  111979. o = y[M.x + "," + M.y + "," + M.z];
  111980. var O = !1;
  111981. h && h[2 * o] !== _.x && h[2 * o + 1] !== _.y && (O = !0);
  111982. var D = !1;
  111983. d && d[4 * o] !== m.r && d[4 * o + 1] !== m.g && d[4 * o + 2] !== m.b && d[4 * o + 3] !== m.a && (D = !0),
  111984. (void 0 === o || u[3 * o] !== I.x || u[3 * o + 1] !== I.y || u[3 * o + 2] !== I.z || O || D) && (l.push(M.x, M.y, M.z),
  111985. h && h.push(_.x, _.y),
  111986. u.push(f.x, f.y, f.z),
  111987. d && d.push(m.r, m.g, m.b, m.a),
  111988. o = y[M.x + "," + M.y + "," + M.z] = l.length / 3 - 1),
  111989. c.push(o),
  111990. a.indexStart = Math.min(b, a.indexStart),
  111991. a.indexEnd = Math.max(b, a.indexEnd),
  111992. b++
  111993. }
  111994. }
  111995. }
  111996. if (s.setVerticesData(Bi.PositionKind, l),
  111997. s.setVerticesData(Bi.NormalKind, u),
  111998. h && s.setVerticesData(Bi.UVKind, h),
  111999. d && s.setVerticesData(Bi.ColorKind, d),
  112000. s.setIndices(c, null),
  112001. i) {
  112002. var L = 0
  112003. , F = void 0;
  112004. for (var w in s.subMeshes = new Array,
  112005. T) {
  112006. for (var B in F = -1,
  112007. T[w])
  112008. a = T[w][B],
  112009. hr.CreateFromIndices(a.materialIndex + L, a.indexStart, a.indexEnd - a.indexStart + 1, s),
  112010. F = Math.max(a.materialIndex, F);
  112011. L += ++F
  112012. }
  112013. }
  112014. return s
  112015. }
  112016. ,
  112017. e.prototype.toMesh = function(e, t, i, n) {
  112018. void 0 === t && (t = null);
  112019. var r = this.buildMeshGeometry(e, i, n);
  112020. return r.material = t,
  112021. r.position.copyFrom(this.position),
  112022. r.rotation.copyFrom(this.rotation),
  112023. this.rotationQuaternion && (r.rotationQuaternion = this.rotationQuaternion.clone()),
  112024. r.scaling.copyFrom(this.scaling),
  112025. r.computeWorldMatrix(!0),
  112026. r
  112027. }
  112028. ,
  112029. e
  112030. }();
  112031. Vr._GoldbergMeshParser = function(e, t) {
  112032. return uv.Parse(e, t)
  112033. }
  112034. ;
  112035. var uv = function(e) {
  112036. function t() {
  112037. var t = null !== e && e.apply(this, arguments) || this;
  112038. return t.goldbergData = {
  112039. faceColors: [],
  112040. faceCenters: [],
  112041. faceZaxis: [],
  112042. faceXaxis: [],
  112043. faceYaxis: [],
  112044. nbSharedFaces: 0,
  112045. nbUnsharedFaces: 0,
  112046. nbFaces: 0,
  112047. nbFacesAtPole: 0,
  112048. adjacentFaces: []
  112049. },
  112050. t
  112051. }
  112052. return U(t, e),
  112053. t.prototype.relatedGoldbergFace = function(e, t) {
  112054. return void 0 === t ? (e > this.goldbergData.nbUnsharedFaces - 1 && (K.Warn("Maximum number of unshared faces used"),
  112055. e = this.goldbergData.nbUnsharedFaces - 1),
  112056. this.goldbergData.nbUnsharedFaces + e) : (e > 11 && (K.Warn("Last pole used"),
  112057. e = 11),
  112058. t > this.goldbergData.nbFacesAtPole - 1 && (K.Warn("Maximum number of faces at a pole used"),
  112059. t = this.goldbergData.nbFacesAtPole - 1),
  112060. 12 + e * this.goldbergData.nbFacesAtPole + t)
  112061. }
  112062. ,
  112063. t.prototype._changeGoldbergFaceColors = function(e) {
  112064. for (var t = 0; t < e.length; t++)
  112065. for (var i = e[t][0], n = e[t][1], r = e[t][2], o = i; o < n + 1; o++)
  112066. this.goldbergData.faceColors[o] = r;
  112067. var a = [];
  112068. for (o = 0; o < 12; o++)
  112069. for (t = 0; t < 5; t++)
  112070. a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a);
  112071. for (o = 12; o < this.goldbergData.faceColors.length; o++)
  112072. for (t = 0; t < 6; t++)
  112073. a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a);
  112074. return a
  112075. }
  112076. ,
  112077. t.prototype.setGoldbergFaceColors = function(e) {
  112078. var t = this._changeGoldbergFaceColors(e);
  112079. this.setVerticesData(Bi.ColorKind, t)
  112080. }
  112081. ,
  112082. t.prototype.updateGoldbergFaceColors = function(e) {
  112083. var t = this._changeGoldbergFaceColors(e);
  112084. this.updateVerticesData(Bi.ColorKind, t)
  112085. }
  112086. ,
  112087. t.prototype._changeGoldbergFaceUVs = function(e) {
  112088. for (var t = this.getVerticesData(Bi.UVKind), i = 0; i < e.length; i++) {
  112089. for (var n = e[i][0], r = e[i][1], o = e[i][2], a = e[i][3], s = e[i][4], l = [], c = [], u = void 0, h = void 0, d = 0; d < 5; d++)
  112090. u = o.x + a * Math.cos(s + d * Math.PI / 2.5),
  112091. h = o.y + a * Math.sin(s + d * Math.PI / 2.5),
  112092. u < 0 && (u = 0),
  112093. u > 1 && (u = 1),
  112094. l.push(u, h);
  112095. for (d = 0; d < 6; d++)
  112096. u = o.x + a * Math.cos(s + d * Math.PI / 3),
  112097. h = o.y + a * Math.sin(s + d * Math.PI / 3),
  112098. u < 0 && (u = 0),
  112099. u > 1 && (u = 1),
  112100. c.push(u, h);
  112101. for (var p = n; p < Math.min(12, r + 1); p++)
  112102. for (d = 0; d < 5; d++)
  112103. t[10 * p + 2 * d] = l[2 * d],
  112104. t[10 * p + 2 * d + 1] = l[2 * d + 1];
  112105. for (p = Math.max(12, n); p < r + 1; p++)
  112106. for (d = 0; d < 6; d++)
  112107. t[12 * p - 24 + 2 * d] = c[2 * d],
  112108. t[12 * p - 23 + 2 * d] = c[2 * d + 1]
  112109. }
  112110. return t
  112111. }
  112112. ,
  112113. t.prototype.setGoldbergFaceUVs = function(e) {
  112114. var t = this._changeGoldbergFaceUVs(e);
  112115. this.setVerticesData(Bi.UVKind, t)
  112116. }
  112117. ,
  112118. t.prototype.updateGoldbergFaceUVs = function(e) {
  112119. var t = this._changeGoldbergFaceUVs(e);
  112120. this.updateVerticesData(Bi.UVKind, t)
  112121. }
  112122. ,
  112123. t.prototype.placeOnGoldbergFaceAt = function(e, t, i) {
  112124. var n = x.RotationFromAxis(this.goldbergData.faceXaxis[t], this.goldbergData.faceYaxis[t], this.goldbergData.faceZaxis[t]);
  112125. e.rotation = n,
  112126. e.position = this.goldbergData.faceCenters[t].add(this.goldbergData.faceXaxis[t].scale(i.x)).add(this.goldbergData.faceYaxis[t].scale(i.y)).add(this.goldbergData.faceZaxis[t].scale(i.z))
  112127. }
  112128. ,
  112129. t.prototype.serialize = function(t) {
  112130. e.prototype.serialize.call(this, t),
  112131. t.type = "GoldbergMesh";
  112132. var i = {};
  112133. if (i.adjacentFaces = this.goldbergData.adjacentFaces,
  112134. i.nbSharedFaces = this.goldbergData.nbSharedFaces,
  112135. i.nbUnsharedFaces = this.goldbergData.nbUnsharedFaces,
  112136. i.nbFaces = this.goldbergData.nbFaces,
  112137. i.nbFacesAtPole = this.goldbergData.nbFacesAtPole,
  112138. this.goldbergData.faceColors) {
  112139. i.faceColors = [];
  112140. for (var n = 0, r = this.goldbergData.faceColors; n < r.length; n++) {
  112141. var o = r[n];
  112142. i.faceColors.push(o.asArray())
  112143. }
  112144. }
  112145. if (this.goldbergData.faceCenters) {
  112146. i.faceCenters = [];
  112147. for (var a = 0, s = this.goldbergData.faceCenters; a < s.length; a++) {
  112148. var l = s[a];
  112149. i.faceCenters.push(l.asArray())
  112150. }
  112151. }
  112152. if (this.goldbergData.faceZaxis) {
  112153. i.faceZaxis = [];
  112154. for (var c = 0, u = this.goldbergData.faceZaxis; c < u.length; c++)
  112155. l = u[c],
  112156. i.faceZaxis.push(l.asArray())
  112157. }
  112158. if (this.goldbergData.faceYaxis) {
  112159. i.faceYaxis = [];
  112160. for (var h = 0, d = this.goldbergData.faceYaxis; h < d.length; h++)
  112161. l = d[h],
  112162. i.faceYaxis.push(l.asArray())
  112163. }
  112164. if (this.goldbergData.faceXaxis) {
  112165. i.faceXaxis = [];
  112166. for (var p = 0, f = this.goldbergData.faceXaxis; p < f.length; p++)
  112167. l = f[p],
  112168. i.faceXaxis.push(l.asArray())
  112169. }
  112170. t.goldbergData = i
  112171. }
  112172. ,
  112173. t.Parse = function(e, i) {
  112174. var n = e.goldbergData;
  112175. n.faceColors = n.faceColors.map((function(e) {
  112176. return N.FromArray(e)
  112177. }
  112178. )),
  112179. n.faceCenters = n.faceCenters.map((function(e) {
  112180. return x.FromArray(e)
  112181. }
  112182. )),
  112183. n.faceZaxis = n.faceZaxis.map((function(e) {
  112184. return x.FromArray(e)
  112185. }
  112186. )),
  112187. n.faceXaxis = n.faceXaxis.map((function(e) {
  112188. return x.FromArray(e)
  112189. }
  112190. )),
  112191. n.faceYaxis = n.faceYaxis.map((function(e) {
  112192. return x.FromArray(e)
  112193. }
  112194. ));
  112195. var r = new t(e.name,i);
  112196. return r.goldbergData = n,
  112197. r
  112198. }
  112199. ,
  112200. t
  112201. }(Vr)
  112202. , hv = function(e) {
  112203. function t(t, i, n, r, o, a) {
  112204. void 0 === r && (r = 1),
  112205. void 0 === o && (o = 60),
  112206. void 0 === a && (a = !0);
  112207. var s = e.call(this, t, n) || this;
  112208. s._sectionPolygonPointsCount = 4,
  112209. s._running = !1,
  112210. s._autoStart = a,
  112211. s._generator = i,
  112212. s._diameter = r,
  112213. s._length = o,
  112214. s._sectionVectors = [],
  112215. s._sectionNormalVectors = [];
  112216. for (var l = 0; l < s._sectionPolygonPointsCount; l++)
  112217. s._sectionVectors[l] = x.Zero(),
  112218. s._sectionNormalVectors[l] = x.Zero();
  112219. return s._createMesh(),
  112220. s
  112221. }
  112222. return U(t, e),
  112223. t.prototype.getClassName = function() {
  112224. return "TrailMesh"
  112225. }
  112226. ,
  112227. t.prototype._createMesh = function() {
  112228. var e = new $n
  112229. , t = []
  112230. , i = []
  112231. , n = []
  112232. , r = x.Zero();
  112233. r = this._generator instanceof Sr && this._generator.hasBoundingInfo ? this._generator.getBoundingInfo().boundingBox.centerWorld : this._generator.position;
  112234. for (var o = 2 * Math.PI / this._sectionPolygonPointsCount, a = 0; a < this._sectionPolygonPointsCount; a++)
  112235. t.push(r.x + Math.cos(a * o) * this._diameter, r.y + Math.sin(a * o) * this._diameter, r.z);
  112236. for (a = 1; a <= this._length; a++) {
  112237. for (var s = 0; s < this._sectionPolygonPointsCount; s++)
  112238. t.push(r.x + Math.cos(s * o) * this._diameter, r.y + Math.sin(s * o) * this._diameter, r.z);
  112239. var l = t.length / 3 - 2 * this._sectionPolygonPointsCount;
  112240. for (s = 0; s < this._sectionPolygonPointsCount - 1; s++)
  112241. n.push(l + s, l + s + this._sectionPolygonPointsCount, l + s + this._sectionPolygonPointsCount + 1),
  112242. n.push(l + s, l + s + this._sectionPolygonPointsCount + 1, l + s + 1);
  112243. n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount),
  112244. n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l)
  112245. }
  112246. $n.ComputeNormals(t, n, i),
  112247. e.positions = t,
  112248. e.normals = i,
  112249. e.indices = n,
  112250. e.applyToMesh(this, !0),
  112251. this._autoStart && this.start()
  112252. }
  112253. ,
  112254. t.prototype.start = function() {
  112255. var e = this;
  112256. this._running || (this._running = !0,
  112257. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add((function() {
  112258. e.update()
  112259. }
  112260. )))
  112261. }
  112262. ,
  112263. t.prototype.stop = function() {
  112264. this._beforeRenderObserver && this._running && (this._running = !1,
  112265. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))
  112266. }
  112267. ,
  112268. t.prototype.update = function() {
  112269. var e = this.getVerticesData(Bi.PositionKind)
  112270. , t = this.getVerticesData(Bi.NormalKind)
  112271. , i = this._generator.getWorldMatrix();
  112272. if (e && t) {
  112273. for (var n = 3 * this._sectionPolygonPointsCount; n < e.length; n++)
  112274. e[n - 3 * this._sectionPolygonPointsCount] = e[n] - t[n] / this._length * this._diameter;
  112275. for (n = 3 * this._sectionPolygonPointsCount; n < t.length; n++)
  112276. t[n - 3 * this._sectionPolygonPointsCount] = t[n];
  112277. var r = e.length - 3 * this._sectionPolygonPointsCount
  112278. , o = 2 * Math.PI / this._sectionPolygonPointsCount;
  112279. for (n = 0; n < this._sectionPolygonPointsCount; n++)
  112280. this._sectionVectors[n].copyFromFloats(Math.cos(n * o) * this._diameter, Math.sin(n * o) * this._diameter, 0),
  112281. this._sectionNormalVectors[n].copyFromFloats(Math.cos(n * o), Math.sin(n * o), 0),
  112282. x.TransformCoordinatesToRef(this._sectionVectors[n], i, this._sectionVectors[n]),
  112283. x.TransformNormalToRef(this._sectionNormalVectors[n], i, this._sectionNormalVectors[n]);
  112284. for (n = 0; n < this._sectionPolygonPointsCount; n++)
  112285. e[r + 3 * n] = this._sectionVectors[n].x,
  112286. e[r + 3 * n + 1] = this._sectionVectors[n].y,
  112287. e[r + 3 * n + 2] = this._sectionVectors[n].z,
  112288. t[r + 3 * n] = this._sectionNormalVectors[n].x,
  112289. t[r + 3 * n + 1] = this._sectionNormalVectors[n].y,
  112290. t[r + 3 * n + 2] = this._sectionNormalVectors[n].z;
  112291. this.updateVerticesData(Bi.PositionKind, e, !0, !1),
  112292. this.updateVerticesData(Bi.NormalKind, t, !0, !1)
  112293. }
  112294. }
  112295. ,
  112296. t.prototype.clone = function(e, i) {
  112297. return void 0 === e && (e = ""),
  112298. new t(e,void 0 === i ? this._generator : i,this.getScene(),this._diameter,this._length,this._autoStart)
  112299. }
  112300. ,
  112301. t.prototype.serialize = function(t) {
  112302. e.prototype.serialize.call(this, t)
  112303. }
  112304. ,
  112305. t.Parse = function(e, i) {
  112306. return new t(e.name,e._generator,i,e._diameter,e._length,e._autoStart)
  112307. }
  112308. ,
  112309. t
  112310. }(Vr);
  112311. function dv(e) {
  112312. var t = e.pattern || Vr.NO_FLIP
  112313. , i = e.tileWidth || e.tileSize || 1
  112314. , n = e.tileHeight || e.tileSize || 1
  112315. , r = e.alignHorizontal || 0
  112316. , o = e.alignVertical || 0
  112317. , a = e.width || e.size || 1
  112318. , s = Math.floor(a / i)
  112319. , l = a - s * i
  112320. , c = e.height || e.size || 1
  112321. , u = Math.floor(c / n)
  112322. , h = c - u * n
  112323. , d = i * s / 2
  112324. , p = n * u / 2
  112325. , f = 0
  112326. , _ = 0
  112327. , m = 0
  112328. , g = 0
  112329. , v = 0
  112330. , y = 0;
  112331. if (l > 0 || h > 0) {
  112332. switch (m = -d,
  112333. g = -p,
  112334. v = d,
  112335. y = p,
  112336. r) {
  112337. case Vr.CENTER:
  112338. m -= l /= 2,
  112339. v += l;
  112340. break;
  112341. case Vr.LEFT:
  112342. v += l,
  112343. f = -l / 2;
  112344. break;
  112345. case Vr.RIGHT:
  112346. m -= l,
  112347. f = l / 2
  112348. }
  112349. switch (o) {
  112350. case Vr.CENTER:
  112351. g -= h /= 2,
  112352. y += h;
  112353. break;
  112354. case Vr.BOTTOM:
  112355. y += h,
  112356. _ = -h / 2;
  112357. break;
  112358. case Vr.TOP:
  112359. g -= h,
  112360. _ = h / 2
  112361. }
  112362. }
  112363. var b = []
  112364. , T = []
  112365. , E = [];
  112366. E[0] = [0, 0, 1, 0, 1, 1, 0, 1],
  112367. E[1] = [0, 0, 1, 0, 1, 1, 0, 1],
  112368. t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (E[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
  112369. t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (E[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
  112370. t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (E[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
  112371. for (var S = [], A = [], x = [], R = 0, C = 0; C < u; C++)
  112372. for (var P = 0; P < s; P++)
  112373. b.push(P * i - d + f, C * n - p + _, 0),
  112374. b.push((P + 1) * i - d + f, C * n - p + _, 0),
  112375. b.push((P + 1) * i - d + f, (C + 1) * n - p + _, 0),
  112376. b.push(P * i - d + f, (C + 1) * n - p + _, 0),
  112377. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112378. S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(E[(P % 2 + C % 2) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(E[C % 2]) : S.concat(E[0]),
  112379. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112380. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1),
  112381. R += 4;
  112382. if (l > 0 || h > 0) {
  112383. var M = h > 0 && (o === Vr.CENTER || o === Vr.TOP)
  112384. , I = h > 0 && (o === Vr.CENTER || o === Vr.BOTTOM)
  112385. , O = l > 0 && (r === Vr.CENTER || r === Vr.RIGHT)
  112386. , D = l > 0 && (r === Vr.CENTER || r === Vr.LEFT)
  112387. , N = []
  112388. , L = void 0
  112389. , F = void 0
  112390. , w = void 0
  112391. , B = void 0;
  112392. if (M && O && (b.push(m + f, g + _, 0),
  112393. b.push(-d + f, g + _, 0),
  112394. b.push(-d + f, g + h + _, 0),
  112395. b.push(m + f, g + h + _, 0),
  112396. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112397. R += 4,
  112398. N = [L = 1 - l / i, F = 1 - h / n, w = 1, F, w, B = 1, L, B],
  112399. t === Vr.ROTATE_ROW && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112400. t === Vr.FLIP_ROW && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112401. t === Vr.FLIP_N_ROTATE_ROW && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112402. S = S.concat(N),
  112403. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112404. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  112405. M && D && (b.push(d + f, g + _, 0),
  112406. b.push(v + f, g + _, 0),
  112407. b.push(v + f, g + h + _, 0),
  112408. b.push(d + f, g + h + _, 0),
  112409. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112410. R += 4,
  112411. N = [L = 0, F = 1 - h / n, w = l / i, F, w, B = 1, L, B],
  112412. (t === Vr.ROTATE_ROW || t === Vr.ROTATE_TILE && s % 2 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112413. (t === Vr.FLIP_ROW || t === Vr.FLIP_TILE && s % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112414. (t === Vr.FLIP_N_ROTATE_ROW || t === Vr.FLIP_N_ROTATE_TILE && s % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112415. S = S.concat(N),
  112416. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112417. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  112418. I && O && (b.push(m + f, p + _, 0),
  112419. b.push(-d + f, p + _, 0),
  112420. b.push(-d + f, y + _, 0),
  112421. b.push(m + f, y + _, 0),
  112422. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112423. R += 4,
  112424. N = [L = 1 - l / i, F = 0, w = 1, F, w, B = h / n, L, B],
  112425. (t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && u % 1 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112426. (t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && u % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112427. (t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && u % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112428. S = S.concat(N),
  112429. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112430. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  112431. I && D && (b.push(d + f, p + _, 0),
  112432. b.push(v + f, p + _, 0),
  112433. b.push(v + f, y + _, 0),
  112434. b.push(d + f, y + _, 0),
  112435. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112436. R += 4,
  112437. N = [L = 0, F = 0, w = l / i, F, w, B = h / n, L, B],
  112438. (t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && (u + s) % 2 == 1) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112439. (t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && (u + s) % 2 == 1) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112440. (t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && (u + s) % 2 == 1) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112441. S = S.concat(N),
  112442. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112443. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
  112444. M) {
  112445. var U = [];
  112446. for (L = 0,
  112447. F = 1 - h / n,
  112448. w = 1,
  112449. B = 1,
  112450. U[0] = [L, F, w, F, w, B, L, B],
  112451. U[1] = [L, F, w, F, w, B, L, B],
  112452. t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (U[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112453. t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (U[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112454. t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (U[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112455. P = 0; P < s; P++)
  112456. b.push(P * i - d + f, g + _, 0),
  112457. b.push((P + 1) * i - d + f, g + _, 0),
  112458. b.push((P + 1) * i - d + f, g + h + _, 0),
  112459. b.push(P * i - d + f, g + h + _, 0),
  112460. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112461. R += 4,
  112462. S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(U[(P + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(U[1]) : S.concat(U[0]),
  112463. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112464. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  112465. }
  112466. if (I) {
  112467. var V = [];
  112468. for (L = 0,
  112469. F = 0,
  112470. w = 1,
  112471. B = h / n,
  112472. V[0] = [L, F, w, F, w, B, L, B],
  112473. V[1] = [L, F, w, F, w, B, L, B],
  112474. t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (V[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112475. t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (V[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112476. t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (V[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112477. P = 0; P < s; P++)
  112478. b.push(P * i - d + f, y - h + _, 0),
  112479. b.push((P + 1) * i - d + f, y - h + _, 0),
  112480. b.push((P + 1) * i - d + f, y + _, 0),
  112481. b.push(P * i - d + f, y + _, 0),
  112482. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112483. R += 4,
  112484. S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(V[(P + u) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(V[u % 2]) : S.concat(V[0]),
  112485. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112486. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  112487. }
  112488. if (O) {
  112489. var k = [];
  112490. for (L = 1 - l / i,
  112491. F = 0,
  112492. w = 1,
  112493. B = 1,
  112494. k[0] = [L, F, w, F, w, B, L, B],
  112495. k[1] = [L, F, w, F, w, B, L, B],
  112496. t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (k[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112497. t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (k[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112498. t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (k[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112499. C = 0; C < u; C++)
  112500. b.push(m + f, C * n - p + _, 0),
  112501. b.push(m + l + f, C * n - p + _, 0),
  112502. b.push(m + l + f, (C + 1) * n - p + _, 0),
  112503. b.push(m + f, (C + 1) * n - p + _, 0),
  112504. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112505. R += 4,
  112506. S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(k[(C + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(k[C % 2]) : S.concat(k[0]),
  112507. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112508. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  112509. }
  112510. if (D) {
  112511. var G = [];
  112512. for (L = 0,
  112513. F = 0,
  112514. w = l / n,
  112515. B = 1,
  112516. G[0] = [L, F, w, F, w, B, L, B],
  112517. G[1] = [L, F, w, F, w, B, L, B],
  112518. t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (G[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
  112519. t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (G[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
  112520. t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (G[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
  112521. C = 0; C < u; C++)
  112522. b.push(v - l + f, C * n - p + _, 0),
  112523. b.push(v + f, C * n - p + _, 0),
  112524. b.push(v + f, (C + 1) * n - p + _, 0),
  112525. b.push(v - l + f, (C + 1) * n - p + _, 0),
  112526. x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
  112527. R += 4,
  112528. S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(G[(C + s) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(G[C % 2]) : S.concat(G[0]),
  112529. A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  112530. T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
  112531. }
  112532. }
  112533. var z = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE;
  112534. $n._ComputeSides(z, b, x, T, S, e.frontUVs, e.backUVs);
  112535. var W = new $n;
  112536. W.indices = x,
  112537. W.positions = b,
  112538. W.normals = T,
  112539. W.uvs = S;
  112540. var H = z === $n.DOUBLESIDE ? A.concat(A) : A;
  112541. return W.colors = H,
  112542. W
  112543. }
  112544. function pv(e, t, i) {
  112545. void 0 === i && (i = null);
  112546. var n = new Vr(e,i);
  112547. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  112548. n._originalBuilderSideOrientation = t.sideOrientation,
  112549. dv(t).applyToMesh(n, t.updatable),
  112550. n
  112551. }
  112552. var fv = {
  112553. CreateTiledPlane: pv
  112554. };
  112555. function _v(e) {
  112556. for (var t = e.faceUV || new Array(6), i = e.faceColors, n = e.pattern || Vr.NO_FLIP, r = e.width || e.size || 1, o = e.height || e.size || 1, a = e.depth || e.size || 1, s = e.tileWidth || e.tileSize || 1, l = e.tileHeight || e.tileSize || 1, c = e.alignHorizontal || 0, u = e.alignVertical || 0, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = 0; d < 6; d++)
  112557. void 0 === t[d] && (t[d] = new R(0,0,1,1)),
  112558. i && void 0 === i[d] && (i[d] = new N(1,1,1,1));
  112559. var p = r / 2
  112560. , f = o / 2
  112561. , _ = a / 2
  112562. , m = [];
  112563. for (d = 0; d < 2; d++)
  112564. m[d] = dv({
  112565. pattern: n,
  112566. tileWidth: s,
  112567. tileHeight: l,
  112568. width: r,
  112569. height: o,
  112570. alignVertical: u,
  112571. alignHorizontal: c,
  112572. sideOrientation: h
  112573. });
  112574. for (d = 2; d < 4; d++)
  112575. m[d] = dv({
  112576. pattern: n,
  112577. tileWidth: s,
  112578. tileHeight: l,
  112579. width: a,
  112580. height: o,
  112581. alignVertical: u,
  112582. alignHorizontal: c,
  112583. sideOrientation: h
  112584. });
  112585. var g = u;
  112586. for (u === Vr.BOTTOM ? g = Vr.TOP : u === Vr.TOP && (g = Vr.BOTTOM),
  112587. d = 4; d < 6; d++)
  112588. m[d] = dv({
  112589. pattern: n,
  112590. tileWidth: s,
  112591. tileHeight: l,
  112592. width: r,
  112593. height: a,
  112594. alignVertical: g,
  112595. alignHorizontal: c,
  112596. sideOrientation: h
  112597. });
  112598. var v = []
  112599. , y = []
  112600. , b = []
  112601. , T = []
  112602. , E = []
  112603. , S = []
  112604. , A = []
  112605. , C = []
  112606. , M = 0
  112607. , I = 0;
  112608. for (d = 0; d < 6; d++) {
  112609. var O = m[d].positions.length;
  112610. S[d] = [],
  112611. A[d] = [];
  112612. for (var D = 0; D < O / 3; D++)
  112613. S[d].push(new x(m[d].positions[3 * D],m[d].positions[3 * D + 1],m[d].positions[3 * D + 2])),
  112614. A[d].push(new x(m[d].normals[3 * D],m[d].normals[3 * D + 1],m[d].normals[3 * D + 2]));
  112615. M = m[d].uvs.length,
  112616. C[d] = [];
  112617. for (var L = 0; L < M; L += 2)
  112618. C[d][L] = t[d].x + (t[d].z - t[d].x) * m[d].uvs[L],
  112619. C[d][L + 1] = t[d].y + (t[d].w - t[d].y) * m[d].uvs[L + 1],
  112620. pr.UseOpenGLOrientationForUV && (C[d][L + 1] = 1 - C[d][L + 1]);
  112621. if (b = b.concat(C[d]),
  112622. T = T.concat(m[d].indices.map((function(e) {
  112623. return e + I
  112624. }
  112625. ))),
  112626. I += S[d].length,
  112627. i)
  112628. for (var F = 0; F < 4; F++)
  112629. E.push(i[d].r, i[d].g, i[d].b, i[d].a)
  112630. }
  112631. var w = new x(0,0,_)
  112632. , B = P.RotationY(Math.PI);
  112633. v = S[0].map((function(e) {
  112634. return x.TransformNormal(e, B).add(w)
  112635. }
  112636. )).map((function(e) {
  112637. return [e.x, e.y, e.z]
  112638. }
  112639. )).reduce((function(e, t) {
  112640. return e.concat(t)
  112641. }
  112642. ), []),
  112643. y = A[0].map((function(e) {
  112644. return x.TransformNormal(e, B)
  112645. }
  112646. )).map((function(e) {
  112647. return [e.x, e.y, e.z]
  112648. }
  112649. )).reduce((function(e, t) {
  112650. return e.concat(t)
  112651. }
  112652. ), []),
  112653. v = v.concat(S[1].map((function(e) {
  112654. return e.subtract(w)
  112655. }
  112656. )).map((function(e) {
  112657. return [e.x, e.y, e.z]
  112658. }
  112659. )).reduce((function(e, t) {
  112660. return e.concat(t)
  112661. }
  112662. ), [])),
  112663. y = y.concat(A[1].map((function(e) {
  112664. return [e.x, e.y, e.z]
  112665. }
  112666. )).reduce((function(e, t) {
  112667. return e.concat(t)
  112668. }
  112669. ), []));
  112670. var U = new x(p,0,0)
  112671. , V = P.RotationY(-Math.PI / 2);
  112672. v = v.concat(S[2].map((function(e) {
  112673. return x.TransformNormal(e, V).add(U)
  112674. }
  112675. )).map((function(e) {
  112676. return [e.x, e.y, e.z]
  112677. }
  112678. )).reduce((function(e, t) {
  112679. return e.concat(t)
  112680. }
  112681. ), [])),
  112682. y = y.concat(A[2].map((function(e) {
  112683. return x.TransformNormal(e, V)
  112684. }
  112685. )).map((function(e) {
  112686. return [e.x, e.y, e.z]
  112687. }
  112688. )).reduce((function(e, t) {
  112689. return e.concat(t)
  112690. }
  112691. ), []));
  112692. var k = P.RotationY(Math.PI / 2);
  112693. v = v.concat(S[3].map((function(e) {
  112694. return x.TransformNormal(e, k).subtract(U)
  112695. }
  112696. )).map((function(e) {
  112697. return [e.x, e.y, e.z]
  112698. }
  112699. )).reduce((function(e, t) {
  112700. return e.concat(t)
  112701. }
  112702. ), [])),
  112703. y = y.concat(A[3].map((function(e) {
  112704. return x.TransformNormal(e, k)
  112705. }
  112706. )).map((function(e) {
  112707. return [e.x, e.y, e.z]
  112708. }
  112709. )).reduce((function(e, t) {
  112710. return e.concat(t)
  112711. }
  112712. ), []));
  112713. var G = new x(0,f,0)
  112714. , z = P.RotationX(Math.PI / 2);
  112715. v = v.concat(S[4].map((function(e) {
  112716. return x.TransformNormal(e, z).add(G)
  112717. }
  112718. )).map((function(e) {
  112719. return [e.x, e.y, e.z]
  112720. }
  112721. )).reduce((function(e, t) {
  112722. return e.concat(t)
  112723. }
  112724. ), [])),
  112725. y = y.concat(A[4].map((function(e) {
  112726. return x.TransformNormal(e, z)
  112727. }
  112728. )).map((function(e) {
  112729. return [e.x, e.y, e.z]
  112730. }
  112731. )).reduce((function(e, t) {
  112732. return e.concat(t)
  112733. }
  112734. ), []));
  112735. var W = P.RotationX(-Math.PI / 2);
  112736. v = v.concat(S[5].map((function(e) {
  112737. return x.TransformNormal(e, W).subtract(G)
  112738. }
  112739. )).map((function(e) {
  112740. return [e.x, e.y, e.z]
  112741. }
  112742. )).reduce((function(e, t) {
  112743. return e.concat(t)
  112744. }
  112745. ), [])),
  112746. y = y.concat(A[5].map((function(e) {
  112747. return x.TransformNormal(e, W)
  112748. }
  112749. )).map((function(e) {
  112750. return [e.x, e.y, e.z]
  112751. }
  112752. )).reduce((function(e, t) {
  112753. return e.concat(t)
  112754. }
  112755. ), [])),
  112756. $n._ComputeSides(h, v, T, y, b);
  112757. var H = new $n;
  112758. if (H.indices = T,
  112759. H.positions = v,
  112760. H.normals = y,
  112761. H.uvs = b,
  112762. i) {
  112763. var X = h === $n.DOUBLESIDE ? E.concat(E) : E;
  112764. H.colors = X
  112765. }
  112766. return H
  112767. }
  112768. function mv(e, t, i) {
  112769. void 0 === i && (i = null);
  112770. var n = new Vr(e,i);
  112771. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  112772. n._originalBuilderSideOrientation = t.sideOrientation,
  112773. _v(t).applyToMesh(n, t.updatable),
  112774. n
  112775. }
  112776. $n.CreateTiledPlane = dv;
  112777. var gv = {
  112778. CreateTiledBox: mv
  112779. };
  112780. function vv(e) {
  112781. var t, i, n = new Array, r = new Array, o = new Array, a = new Array, s = e.radius || 2, l = e.tube || .5, c = e.radialSegments || 32, u = e.tubularSegments || 32, h = e.p || 2, d = e.q || 3, p = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, f = function(e) {
  112782. var t = Math.cos(e)
  112783. , i = Math.sin(e)
  112784. , n = d / h * e
  112785. , r = Math.cos(n)
  112786. , o = s * (2 + r) * .5 * t
  112787. , a = s * (2 + r) * i * .5
  112788. , l = s * Math.sin(n) * .5;
  112789. return new x(o,a,l)
  112790. };
  112791. for (t = 0; t <= c; t++) {
  112792. var _ = t % c / c * 2 * h * Math.PI
  112793. , m = f(_)
  112794. , g = f(_ + .01)
  112795. , v = g.subtract(m)
  112796. , y = g.add(m)
  112797. , b = x.Cross(v, y);
  112798. for (y = x.Cross(b, v),
  112799. b.normalize(),
  112800. y.normalize(),
  112801. i = 0; i < u; i++) {
  112802. var T = i % u / u * 2 * Math.PI
  112803. , E = -l * Math.cos(T)
  112804. , S = l * Math.sin(T);
  112805. r.push(m.x + E * y.x + S * b.x),
  112806. r.push(m.y + E * y.y + S * b.y),
  112807. r.push(m.z + E * y.z + S * b.z),
  112808. a.push(t / c),
  112809. a.push(pr.UseOpenGLOrientationForUV ? 1 - i / u : i / u)
  112810. }
  112811. }
  112812. for (t = 0; t < c; t++)
  112813. for (i = 0; i < u; i++) {
  112814. var A = (i + 1) % u
  112815. , R = t * u + i
  112816. , C = (t + 1) * u + i
  112817. , P = (t + 1) * u + A
  112818. , M = t * u + A;
  112819. n.push(M),
  112820. n.push(C),
  112821. n.push(R),
  112822. n.push(M),
  112823. n.push(P),
  112824. n.push(C)
  112825. }
  112826. $n.ComputeNormals(r, n, o),
  112827. $n._ComputeSides(p, r, n, o, a, e.frontUVs, e.backUVs);
  112828. var I = new $n;
  112829. return I.indices = n,
  112830. I.positions = r,
  112831. I.normals = o,
  112832. I.uvs = a,
  112833. I
  112834. }
  112835. function yv(e, t, i) {
  112836. void 0 === t && (t = {});
  112837. var n = new Vr(e,i);
  112838. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  112839. n._originalBuilderSideOrientation = t.sideOrientation,
  112840. vv(t).applyToMesh(n, t.updatable),
  112841. n
  112842. }
  112843. $n.CreateTiledBox = _v;
  112844. var bv = {
  112845. CreateTorusKnot: yv
  112846. };
  112847. $n.CreateTorusKnot = vv,
  112848. Vr.CreateTorusKnot = function(e, t, i, n, r, o, a, s, l, c) {
  112849. return yv(e, {
  112850. radius: t,
  112851. tube: i,
  112852. radialSegments: n,
  112853. tubularSegments: r,
  112854. p: o,
  112855. q: a,
  112856. sideOrientation: c,
  112857. updatable: l
  112858. }, s)
  112859. }
  112860. ;
  112861. var Tv = function(e) {
  112862. function t(t, i) {
  112863. var n = e.call(this, t.x, t.y) || this;
  112864. return n.index = i,
  112865. n
  112866. }
  112867. return U(t, e),
  112868. t
  112869. }(A)
  112870. , Ev = function() {
  112871. function e() {
  112872. this.elements = new Array
  112873. }
  112874. return e.prototype.add = function(e) {
  112875. var t = this
  112876. , i = new Array;
  112877. return e.forEach((function(e) {
  112878. var n = new Tv(e,t.elements.length);
  112879. i.push(n),
  112880. t.elements.push(n)
  112881. }
  112882. )),
  112883. i
  112884. }
  112885. ,
  112886. e.prototype.computeBounds = function() {
  112887. var e = new A(this.elements[0].x,this.elements[0].y)
  112888. , t = new A(this.elements[0].x,this.elements[0].y);
  112889. return this.elements.forEach((function(i) {
  112890. i.x < e.x ? e.x = i.x : i.x > t.x && (t.x = i.x),
  112891. i.y < e.y ? e.y = i.y : i.y > t.y && (t.y = i.y)
  112892. }
  112893. )),
  112894. {
  112895. min: e,
  112896. max: t,
  112897. width: t.x - e.x,
  112898. height: t.y - e.y
  112899. }
  112900. }
  112901. ,
  112902. e
  112903. }()
  112904. , Sv = function() {
  112905. function e() {}
  112906. return e.Rectangle = function(e, t, i, n) {
  112907. return [new A(e,t), new A(i,t), new A(i,n), new A(e,n)]
  112908. }
  112909. ,
  112910. e.Circle = function(e, t, i, n) {
  112911. void 0 === t && (t = 0),
  112912. void 0 === i && (i = 0),
  112913. void 0 === n && (n = 32);
  112914. for (var r = new Array, o = 0, a = 2 * Math.PI / n, s = 0; s < n; s++)
  112915. r.push(new A(t + Math.cos(o) * e,i + Math.sin(o) * e)),
  112916. o -= a;
  112917. return r
  112918. }
  112919. ,
  112920. e.Parse = function(e) {
  112921. var t, i = e.split(/[^-+eE.\d]+/).map(parseFloat).filter((function(e) {
  112922. return !isNaN(e)
  112923. }
  112924. )), n = [];
  112925. for (t = 0; t < (2147483646 & i.length); t += 2)
  112926. n.push(new A(i[t],i[t + 1]));
  112927. return n
  112928. }
  112929. ,
  112930. e.StartingAt = function(e, t) {
  112931. return Rn.StartingAt(e, t)
  112932. }
  112933. ,
  112934. e
  112935. }()
  112936. , Av = function() {
  112937. function e(e, t, i, n) {
  112938. var r;
  112939. void 0 === n && (n = earcut),
  112940. this._points = new Ev,
  112941. this._outlinepoints = new Ev,
  112942. this._holes = new Array,
  112943. this._epoints = new Array,
  112944. this._eholes = new Array,
  112945. this.bjsEarcut = n,
  112946. this._name = e,
  112947. this._scene = i || E.LastCreatedScene,
  112948. r = t instanceof Rn ? t.getPoints() : t,
  112949. this._addToepoint(r),
  112950. this._points.add(r),
  112951. this._outlinepoints.add(r),
  112952. void 0 === this.bjsEarcut && K.Warn("Earcut was not found, the polygon will not be built.")
  112953. }
  112954. return e.prototype._addToepoint = function(e) {
  112955. for (var t = 0, i = e; t < i.length; t++) {
  112956. var n = i[t];
  112957. this._epoints.push(n.x, n.y)
  112958. }
  112959. }
  112960. ,
  112961. e.prototype.addHole = function(e) {
  112962. this._points.add(e);
  112963. var t = new Ev;
  112964. return t.add(e),
  112965. this._holes.push(t),
  112966. this._eholes.push(this._epoints.length / 2),
  112967. this._addToepoint(e),
  112968. this
  112969. }
  112970. ,
  112971. e.prototype.build = function(e, t, i) {
  112972. void 0 === e && (e = !1),
  112973. void 0 === t && (t = 0),
  112974. void 0 === i && (i = 2);
  112975. var n = new Vr(this._name,this._scene)
  112976. , r = this.buildVertexData(t, i);
  112977. return n.setVerticesData(Bi.PositionKind, r.positions, e),
  112978. n.setVerticesData(Bi.NormalKind, r.normals, e),
  112979. n.setVerticesData(Bi.UVKind, r.uvs, e),
  112980. n.setIndices(r.indices),
  112981. n
  112982. }
  112983. ,
  112984. e.prototype.buildVertexData = function(e, t) {
  112985. var i = this;
  112986. void 0 === e && (e = 0),
  112987. void 0 === t && (t = 2);
  112988. var n = new $n
  112989. , r = new Array
  112990. , o = new Array
  112991. , a = new Array
  112992. , s = this._points.computeBounds();
  112993. this._points.elements.forEach((function(e) {
  112994. r.push(0, 1, 0),
  112995. o.push(e.x, 0, e.y),
  112996. a.push((e.x - s.min.x) / s.width, (e.y - s.min.y) / s.height)
  112997. }
  112998. ));
  112999. for (var l = new Array, c = this.bjsEarcut(this._epoints, this._eholes, 2), u = 0; u < c.length; u++)
  113000. l.push(c[u]);
  113001. if (e > 0) {
  113002. var h = o.length / 3;
  113003. this._points.elements.forEach((function(t) {
  113004. r.push(0, -1, 0),
  113005. o.push(t.x, -e, t.y),
  113006. a.push(1 - (t.x - s.min.x) / s.width, 1 - (t.y - s.min.y) / s.height)
  113007. }
  113008. ));
  113009. var d = l.length;
  113010. for (u = 0; u < d; u += 3) {
  113011. var p = l[u + 0]
  113012. , f = l[u + 1]
  113013. , _ = l[u + 2];
  113014. l.push(_ + h),
  113015. l.push(f + h),
  113016. l.push(p + h)
  113017. }
  113018. this._addSide(o, r, a, l, s, this._outlinepoints, e, !1, t),
  113019. this._holes.forEach((function(n) {
  113020. i._addSide(o, r, a, l, s, n, e, !0, t)
  113021. }
  113022. ))
  113023. }
  113024. return n.indices = l,
  113025. n.positions = o,
  113026. n.normals = r,
  113027. n.uvs = a,
  113028. n
  113029. }
  113030. ,
  113031. e.prototype._addSide = function(e, t, i, n, r, o, a, s, l) {
  113032. for (var c = e.length / 3, u = 0, h = 0; h < o.elements.length; h++) {
  113033. var d = o.elements[h]
  113034. , p = o.elements[(h + 1) % o.elements.length];
  113035. e.push(d.x, 0, d.y),
  113036. e.push(d.x, -a, d.y),
  113037. e.push(p.x, 0, p.y),
  113038. e.push(p.x, -a, p.y);
  113039. var f = o.elements[(h + o.elements.length - 1) % o.elements.length]
  113040. , _ = o.elements[(h + 2) % o.elements.length]
  113041. , g = new x(-(p.y - d.y),0,p.x - d.x)
  113042. , v = new x(-(d.y - f.y),0,d.x - f.x)
  113043. , y = new x(-(_.y - p.y),0,_.x - p.x);
  113044. s || (g = g.scale(-1),
  113045. v = v.scale(-1),
  113046. y = y.scale(-1));
  113047. var b = g.normalizeToNew()
  113048. , T = v.normalizeToNew()
  113049. , E = y.normalizeToNew()
  113050. , S = x.Dot(T, b);
  113051. T = S > l ? S < m - 1 ? new x(d.x,0,d.y).subtract(new x(p.x,0,p.y)).normalize() : v.add(g).normalize() : b;
  113052. var A = x.Dot(y, g);
  113053. E = A > l ? A < m - 1 ? new x(p.x,0,p.y).subtract(new x(d.x,0,d.y)).normalize() : y.add(g).normalize() : b,
  113054. i.push(u / r.width, 0),
  113055. i.push(u / r.width, 1),
  113056. u += g.length(),
  113057. i.push(u / r.width, 0),
  113058. i.push(u / r.width, 1),
  113059. t.push(T.x, T.y, T.z),
  113060. t.push(T.x, T.y, T.z),
  113061. t.push(E.x, E.y, E.z),
  113062. t.push(E.x, E.y, E.z),
  113063. s ? (n.push(c),
  113064. n.push(c + 2),
  113065. n.push(c + 1),
  113066. n.push(c + 1),
  113067. n.push(c + 2),
  113068. n.push(c + 3)) : (n.push(c),
  113069. n.push(c + 1),
  113070. n.push(c + 2),
  113071. n.push(c + 1),
  113072. n.push(c + 3),
  113073. n.push(c + 2)),
  113074. c += 4
  113075. }
  113076. }
  113077. ,
  113078. e
  113079. }();
  113080. function xv(e, t, i, n, r, o, a) {
  113081. for (var s = i || new Array(3), l = n, c = [], u = a || !1, h = 0; h < 3; h++)
  113082. void 0 === s[h] && (s[h] = new R(0,0,1,1)),
  113083. l && void 0 === l[h] && (l[h] = new N(1,1,1,1));
  113084. var d = e.getVerticesData(Bi.PositionKind)
  113085. , p = e.getVerticesData(Bi.NormalKind)
  113086. , f = e.getVerticesData(Bi.UVKind)
  113087. , _ = e.getIndices()
  113088. , m = d.length / 9
  113089. , g = 0
  113090. , v = 0
  113091. , y = 0
  113092. , b = 0
  113093. , T = [0];
  113094. if (u)
  113095. for (var E = m; E < d.length / 3; E += 4)
  113096. v = d[3 * (E + 2)] - d[3 * E],
  113097. y = d[3 * (E + 2) + 2] - d[3 * E + 2],
  113098. b += Math.sqrt(v * v + y * y),
  113099. T.push(b);
  113100. for (var S = 0, A = 0, x = 0; x < p.length; x += 3)
  113101. Math.abs(p[x + 1]) < .001 && (A = 1),
  113102. Math.abs(p[x + 1] - 1) < .001 && (A = 0),
  113103. Math.abs(p[x + 1] + 1) < .001 && (A = 2),
  113104. S = x / 3,
  113105. 1 === A ? (g = S - m,
  113106. f[2 * S] = g % 4 < 1.5 ? u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4)] / b : s[A].x : u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4) + 1] / b : s[A].z,
  113107. f[2 * S + 1] = g % 2 == 0 ? pr.UseOpenGLOrientationForUV ? 1 - s[A].w : s[A].w : pr.UseOpenGLOrientationForUV ? 1 - s[A].y : s[A].y) : (f[2 * S] = (1 - f[2 * S]) * s[A].x + f[2 * S] * s[A].z,
  113108. f[2 * S + 1] = (1 - f[2 * S + 1]) * s[A].y + f[2 * S + 1] * s[A].w,
  113109. pr.UseOpenGLOrientationForUV && (f[2 * S + 1] = 1 - f[2 * S + 1])),
  113110. l && c.push(l[A].r, l[A].g, l[A].b, l[A].a);
  113111. $n._ComputeSides(t, d, _, p, f, r, o);
  113112. var C = new $n;
  113113. if (C.indices = _,
  113114. C.positions = d,
  113115. C.normals = p,
  113116. C.uvs = f,
  113117. l) {
  113118. var P = t === $n.DOUBLESIDE ? c.concat(c) : c;
  113119. C.colors = P
  113120. }
  113121. return C
  113122. }
  113123. function Rv(e, t, i, n) {
  113124. void 0 === i && (i = null),
  113125. void 0 === n && (n = earcut),
  113126. t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation);
  113127. for (var r = t.shape, o = t.holes || [], a = t.depth || 0, s = t.smoothingThreshold || 2, l = [], c = [], u = 0; u < r.length; u++)
  113128. l[u] = new A(r[u].x,r[u].z);
  113129. l[0].equalsWithEpsilon(l[l.length - 1], 1e-8) && l.pop();
  113130. for (var h = new Av(e,l,i || E.LastCreatedScene,n), d = 0; d < o.length; d++) {
  113131. c = [];
  113132. for (var p = 0; p < o[d].length; p++)
  113133. c.push(new A(o[d][p].x,o[d][p].z));
  113134. h.addHole(c)
  113135. }
  113136. var f = h.build(!1, a, s);
  113137. return f._originalBuilderSideOrientation = t.sideOrientation,
  113138. xv(f, t.sideOrientation, t.faceUV, t.faceColors, t.frontUVs, t.backUVs, t.wrap).applyToMesh(f, t.updatable),
  113139. f
  113140. }
  113141. function Cv(e, t, i, n) {
  113142. return void 0 === i && (i = null),
  113143. void 0 === n && (n = earcut),
  113144. Rv(e, t, i, n)
  113145. }
  113146. var Pv = {
  113147. ExtrudePolygon: Cv,
  113148. CreatePolygon: Rv
  113149. };
  113150. function Mv(e, t, i) {
  113151. void 0 === i && (i = null);
  113152. var n, r, o = t.arc ? t.arc <= 0 || t.arc > 1 ? 1 : t.arc : 1, a = void 0 === t.closed || t.closed, s = t.shape, l = t.radius || 1, c = t.tessellation || 64, u = t.clip || 0, h = t.updatable, d = Vr._GetDefaultSideOrientation(t.sideOrientation), p = t.cap || Vr.NO_CAP, f = 2 * Math.PI, _ = new Array, m = t.invertUV || !1, g = 0, v = 0, y = f / c * o;
  113153. for (g = 0; g <= c - u; g++) {
  113154. for (r = [],
  113155. p != Vr.CAP_START && p != Vr.CAP_ALL || (r.push(new x(0,s[0].y,0)),
  113156. r.push(new x(Math.cos(g * y) * s[0].x * l,s[0].y,Math.sin(g * y) * s[0].x * l))),
  113157. v = 0; v < s.length; v++)
  113158. n = new x(Math.cos(g * y) * s[v].x * l,s[v].y,Math.sin(g * y) * s[v].x * l),
  113159. r.push(n);
  113160. p != Vr.CAP_END && p != Vr.CAP_ALL || (r.push(new x(Math.cos(g * y) * s[s.length - 1].x * l,s[s.length - 1].y,Math.sin(g * y) * s[s.length - 1].x * l)),
  113161. r.push(new x(0,s[s.length - 1].y,0))),
  113162. _.push(r)
  113163. }
  113164. return nc(e, {
  113165. pathArray: _,
  113166. closeArray: a,
  113167. sideOrientation: d,
  113168. updatable: h,
  113169. invertUV: m,
  113170. frontUVs: t.frontUVs,
  113171. backUVs: t.backUVs
  113172. }, i)
  113173. }
  113174. $n.CreatePolygon = xv,
  113175. Vr.CreatePolygon = function(e, t, i, n, r, o, a) {
  113176. return void 0 === a && (a = earcut),
  113177. Rv(e, {
  113178. shape: t,
  113179. holes: n,
  113180. updatable: r,
  113181. sideOrientation: o
  113182. }, i, a)
  113183. }
  113184. ,
  113185. Vr.ExtrudePolygon = function(e, t, i, n, r, o, a, s) {
  113186. return void 0 === s && (s = earcut),
  113187. Cv(e, {
  113188. shape: t,
  113189. holes: r,
  113190. depth: i,
  113191. updatable: o,
  113192. sideOrientation: a
  113193. }, n, s)
  113194. }
  113195. ;
  113196. var Iv = {
  113197. CreateLathe: Mv
  113198. };
  113199. function Ov(e, t, i) {
  113200. void 0 === i && (i = null);
  113201. var n = t.path
  113202. , r = t.instance
  113203. , o = 1;
  113204. void 0 !== t.radius ? o = t.radius : r && (o = r._creationDataStorage.radius);
  113205. var a = t.tessellation || 64
  113206. , s = t.radiusFunction || null
  113207. , l = t.cap || Vr.NO_CAP
  113208. , c = t.invertUV || !1
  113209. , u = t.updatable
  113210. , h = Vr._GetDefaultSideOrientation(t.sideOrientation);
  113211. t.arc = t.arc && (t.arc <= 0 || t.arc > 1) ? 1 : t.arc || 1;
  113212. var d, p, f = function(e, t, i, n, r, o, a, s) {
  113213. for (var l, c, u, h, d = t.getTangents(), p = t.getNormals(), f = t.getDistances(), _ = 2 * Math.PI / r * s, m = o || function() {
  113214. return n
  113215. }
  113216. , g = I.Matrix[0], v = a === Vr.NO_CAP || a === Vr.CAP_END ? 0 : 2, y = 0; y < e.length; y++) {
  113217. c = m(y, f[y]),
  113218. l = Array(),
  113219. u = p[y];
  113220. for (var b = 0; b < r; b++)
  113221. P.RotationAxisToRef(d[y], _ * b, g),
  113222. h = l[b] ? l[b] : x.Zero(),
  113223. x.TransformCoordinatesToRef(u, g, h),
  113224. h.scaleInPlace(c).addInPlace(e[y]),
  113225. l[b] = h;
  113226. i[v] = l,
  113227. v++
  113228. }
  113229. var T = function(t, i) {
  113230. for (var n = Array(), r = 0; r < t; r++)
  113231. n.push(e[i]);
  113232. return n
  113233. };
  113234. switch (a) {
  113235. case Vr.NO_CAP:
  113236. break;
  113237. case Vr.CAP_START:
  113238. i[0] = T(r, 0),
  113239. i[1] = i[2].slice(0);
  113240. break;
  113241. case Vr.CAP_END:
  113242. i[v] = i[v - 1].slice(0),
  113243. i[v + 1] = T(r, e.length - 1);
  113244. break;
  113245. case Vr.CAP_ALL:
  113246. i[0] = T(r, 0),
  113247. i[1] = i[2].slice(0),
  113248. i[v] = i[v - 1].slice(0),
  113249. i[v + 1] = T(r, e.length - 1)
  113250. }
  113251. return i
  113252. };
  113253. if (r) {
  113254. var _ = r._creationDataStorage
  113255. , m = t.arc || _.arc;
  113256. return r = nc("", {
  113257. pathArray: p = f(n, d = _.path3D.update(n), _.pathArray, o, _.tessellation, s, _.cap, m),
  113258. instance: r
  113259. }),
  113260. _.path3D = d,
  113261. _.pathArray = p,
  113262. _.arc = m,
  113263. _.radius = o,
  113264. r
  113265. }
  113266. l = l < 0 || l > 3 ? 0 : l;
  113267. var g = nc(e, {
  113268. pathArray: p = f(n, d = new Cn(n), new Array, o, a, s, l, t.arc),
  113269. closePath: !0,
  113270. closeArray: !1,
  113271. updatable: u,
  113272. sideOrientation: h,
  113273. invertUV: c,
  113274. frontUVs: t.frontUVs,
  113275. backUVs: t.backUVs
  113276. }, i);
  113277. return g._creationDataStorage.pathArray = p,
  113278. g._creationDataStorage.path3D = d,
  113279. g._creationDataStorage.tessellation = a,
  113280. g._creationDataStorage.cap = l,
  113281. g._creationDataStorage.arc = t.arc,
  113282. g._creationDataStorage.radius = o,
  113283. g
  113284. }
  113285. Vr.CreateLathe = function(e, t, i, n, r, o, a) {
  113286. return Mv(e, {
  113287. shape: t,
  113288. radius: i,
  113289. tessellation: n,
  113290. sideOrientation: a,
  113291. updatable: o
  113292. }, r)
  113293. }
  113294. ;
  113295. var Dv = {
  113296. CreateTube: Ov
  113297. };
  113298. function Nv(e) {
  113299. var t, i = e.sideOrientation || $n.DEFAULTSIDE, n = e.radius || 1, r = void 0 === e.flat || e.flat, o = e.subdivisions || 4, a = e.radiusX || n, s = e.radiusY || n, l = e.radiusZ || n, c = (1 + Math.sqrt(5)) / 2, u = [-1, c, -0, 1, c, 0, -1, -c, 0, 1, -c, 0, 0, -1, -c, 0, 1, -c, 0, -1, c, 0, 1, c, c, 0, 1, c, 0, -1, -c, 0, 1, -c, 0, -1], h = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], d = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], p = [5, 1, 3, 1, 6, 4, 0, 0, 5, 3, 4, 2, 2, 2, 4, 0, 2, 0, 1, 1, 6, 0, 6, 2, 0, 4, 3, 3, 4, 4, 3, 1, 4, 2, 4, 4, 0, 2, 1, 1, 2, 2, 3, 3, 1, 3, 2, 4], f = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], _ = new Array, m = new Array, g = new Array, v = new Array, y = 0, b = new Array(3), T = new Array(3);
  113300. for (t = 0; t < 3; t++)
  113301. b[t] = x.Zero(),
  113302. T[t] = A.Zero();
  113303. for (var E = 0; E < 20; E++) {
  113304. for (t = 0; t < 3; t++) {
  113305. var S = h[3 * E + t];
  113306. b[t].copyFromFloats(u[3 * d[S]], u[3 * d[S] + 1], u[3 * d[S] + 2]),
  113307. b[t].normalize().scaleInPlace(n),
  113308. T[t].copyFromFloats(.134765625 * p[2 * S] + .05859375 + -.0390625 * f[E], .2333984375 * p[2 * S + 1] + .025390625 + .01953125 * f[E])
  113309. }
  113310. for (var R = function(e, t, i, n) {
  113311. var c, u = x.Lerp(b[0], b[2], t / o), h = x.Lerp(b[1], b[2], t / o), d = o === t ? b[2] : x.Lerp(u, h, e / (o - t));
  113312. if (d.normalize(),
  113313. r) {
  113314. var p = x.Lerp(b[0], b[2], n / o)
  113315. , f = x.Lerp(b[1], b[2], n / o);
  113316. c = x.Lerp(p, f, i / (o - n))
  113317. } else
  113318. c = new x(d.x,d.y,d.z);
  113319. c.x /= a,
  113320. c.y /= s,
  113321. c.z /= l,
  113322. c.normalize();
  113323. var E = A.Lerp(T[0], T[2], t / o)
  113324. , S = A.Lerp(T[1], T[2], t / o)
  113325. , R = o === t ? T[2] : A.Lerp(E, S, e / (o - t));
  113326. m.push(d.x * a, d.y * s, d.z * l),
  113327. g.push(c.x, c.y, c.z),
  113328. v.push(R.x, pr.UseOpenGLOrientationForUV ? 1 - R.y : R.y),
  113329. _.push(y),
  113330. y++
  113331. }, C = 0; C < o; C++)
  113332. for (var P = 0; P + C < o; P++)
  113333. R(P, C, P + 1 / 3, C + 1 / 3),
  113334. R(P + 1, C, P + 1 / 3, C + 1 / 3),
  113335. R(P, C + 1, P + 1 / 3, C + 1 / 3),
  113336. P + C + 1 < o && (R(P + 1, C, P + 2 / 3, C + 2 / 3),
  113337. R(P + 1, C + 1, P + 2 / 3, C + 2 / 3),
  113338. R(P, C + 1, P + 2 / 3, C + 2 / 3))
  113339. }
  113340. $n._ComputeSides(i, m, _, g, v, e.frontUVs, e.backUVs);
  113341. var M = new $n;
  113342. return M.indices = _,
  113343. M.positions = m,
  113344. M.normals = g,
  113345. M.uvs = v,
  113346. M
  113347. }
  113348. function Lv(e, t, i) {
  113349. void 0 === t && (t = {}),
  113350. void 0 === i && (i = null);
  113351. var n = new Vr(e,i);
  113352. return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  113353. n._originalBuilderSideOrientation = t.sideOrientation,
  113354. Nv(t).applyToMesh(n, t.updatable),
  113355. n
  113356. }
  113357. Vr.CreateTube = function(e, t, i, n, r, o, a, s, l, c) {
  113358. return Ov(e, {
  113359. path: t,
  113360. radius: i,
  113361. tessellation: n,
  113362. radiusFunction: r,
  113363. arc: 1,
  113364. cap: o,
  113365. updatable: s,
  113366. sideOrientation: l,
  113367. instance: c
  113368. }, a)
  113369. }
  113370. ;
  113371. var Fv = {
  113372. CreateIcoSphere: Lv
  113373. };
  113374. function wv(e, t, i) {
  113375. var n = t.getIndices()
  113376. , r = t.getVerticesData(Bi.PositionKind)
  113377. , o = t.getVerticesData(Bi.NormalKind)
  113378. , a = t.getVerticesData(Bi.UVKind)
  113379. , s = i.position || x.Zero()
  113380. , l = i.normal || x.Up()
  113381. , c = i.size || x.One()
  113382. , u = i.angle || 0;
  113383. if (!l) {
  113384. var h = new x(0,0,1)
  113385. , d = t.getScene().activeCamera
  113386. , p = x.TransformCoordinates(h, d.getWorldMatrix());
  113387. l = d.globalPosition.subtract(p)
  113388. }
  113389. var f = -Math.atan2(l.z, l.x) - Math.PI / 2
  113390. , _ = Math.sqrt(l.x * l.x + l.z * l.z)
  113391. , m = Math.atan2(l.y, _)
  113392. , g = P.RotationYawPitchRoll(f, m, u).multiply(P.Translation(s.x, s.y, s.z))
  113393. , v = P.Invert(g)
  113394. , y = t.getWorldMatrix().multiply(v)
  113395. , b = new $n;
  113396. b.indices = [],
  113397. b.positions = [],
  113398. b.normals = [],
  113399. b.uvs = [];
  113400. for (var T = 0, E = function(e) {
  113401. var t = new Ec;
  113402. if (!n || !r || !o)
  113403. return t;
  113404. var s = n[e];
  113405. if (t.position = new x(r[3 * s],r[3 * s + 1],r[3 * s + 2]),
  113406. t.position = x.TransformCoordinates(t.position, y),
  113407. t.normal = new x(o[3 * s],o[3 * s + 1],o[3 * s + 2]),
  113408. t.normal = x.TransformNormal(t.normal, y),
  113409. i.captureUVS && a) {
  113410. var l = a[2 * s + 1];
  113411. t.uv = new A(a[2 * s],pr.UseOpenGLOrientationForUV ? 1 - l : l)
  113412. }
  113413. return t
  113414. }, S = function(e, t) {
  113415. if (0 === e.length)
  113416. return e;
  113417. for (var i = .5 * Math.abs(x.Dot(c, t)), n = function(e, n) {
  113418. var r = x.GetClipFactor(e.position, n.position, t, i);
  113419. return new Ec(x.Lerp(e.position, n.position, r),x.Lerp(e.normal, n.normal, r))
  113420. }, r = new Array, o = 0; o < e.length; o += 3) {
  113421. var a = null
  113422. , s = null
  113423. , l = null
  113424. , u = null
  113425. , h = x.Dot(e[o].position, t) - i > 0
  113426. , d = x.Dot(e[o + 1].position, t) - i > 0
  113427. , p = x.Dot(e[o + 2].position, t) - i > 0;
  113428. switch ((h ? 1 : 0) + (d ? 1 : 0) + (p ? 1 : 0)) {
  113429. case 0:
  113430. r.push(e[o]),
  113431. r.push(e[o + 1]),
  113432. r.push(e[o + 2]);
  113433. break;
  113434. case 1:
  113435. if (h && (a = e[o + 1],
  113436. s = e[o + 2],
  113437. l = n(e[o], a),
  113438. u = n(e[o], s)),
  113439. d) {
  113440. a = e[o],
  113441. s = e[o + 2],
  113442. l = n(e[o + 1], a),
  113443. u = n(e[o + 1], s),
  113444. r.push(l),
  113445. r.push(s.clone()),
  113446. r.push(a.clone()),
  113447. r.push(s.clone()),
  113448. r.push(l.clone()),
  113449. r.push(u);
  113450. break
  113451. }
  113452. p && (a = e[o],
  113453. s = e[o + 1],
  113454. l = n(e[o + 2], a),
  113455. u = n(e[o + 2], s)),
  113456. a && s && l && u && (r.push(a.clone()),
  113457. r.push(s.clone()),
  113458. r.push(l),
  113459. r.push(u),
  113460. r.push(l.clone()),
  113461. r.push(s.clone()));
  113462. break;
  113463. case 2:
  113464. h || (s = n(a = e[o].clone(), e[o + 1]),
  113465. l = n(a, e[o + 2]),
  113466. r.push(a),
  113467. r.push(s),
  113468. r.push(l)),
  113469. d || (s = n(a = e[o + 1].clone(), e[o + 2]),
  113470. l = n(a, e[o]),
  113471. r.push(a),
  113472. r.push(s),
  113473. r.push(l)),
  113474. p || (s = n(a = e[o + 2].clone(), e[o]),
  113475. l = n(a, e[o + 1]),
  113476. r.push(a),
  113477. r.push(s),
  113478. r.push(l))
  113479. }
  113480. }
  113481. return r
  113482. }, R = 0; R < n.length; R += 3) {
  113483. var C = new Array;
  113484. if (C.push(E(R)),
  113485. C.push(E(R + 1)),
  113486. C.push(E(R + 2)),
  113487. C = S(C, new x(1,0,0)),
  113488. C = S(C, new x(-1,0,0)),
  113489. C = S(C, new x(0,1,0)),
  113490. C = S(C, new x(0,-1,0)),
  113491. C = S(C, new x(0,0,1)),
  113492. 0 !== (C = S(C, new x(0,0,-1))).length)
  113493. for (var M = 0; M < C.length; M++) {
  113494. var I = C[M];
  113495. if (b.indices.push(T),
  113496. I.position.toArray(b.positions, 3 * T),
  113497. I.normal.toArray(b.normals, 3 * T),
  113498. i.captureUVS)
  113499. I.uv.toArray(b.uvs, 2 * T);
  113500. else {
  113501. b.uvs.push(.5 + I.position.x / c.x);
  113502. var O = .5 + I.position.y / c.y;
  113503. b.uvs.push(pr.UseOpenGLOrientationForUV ? 1 - O : O)
  113504. }
  113505. T++
  113506. }
  113507. }
  113508. var D = new Vr(e,t.getScene());
  113509. return b.applyToMesh(D),
  113510. D.position = s.clone(),
  113511. D.rotation = new x(m,f,u),
  113512. D
  113513. }
  113514. $n.CreateIcoSphere = Nv,
  113515. Vr.CreateIcoSphere = function(e, t, i) {
  113516. return Lv(e, t, i)
  113517. }
  113518. ;
  113519. var Bv = {
  113520. CreateDecal: wv
  113521. };
  113522. Vr.CreateDecal = function(e, t, i, n, r, o) {
  113523. return wv(e, t, {
  113524. position: i,
  113525. normal: n,
  113526. size: r,
  113527. angle: o
  113528. })
  113529. }
  113530. ;
  113531. var Uv = function() {
  113532. function e(e, t) {
  113533. void 0 === e && (e = 0),
  113534. void 0 === t && (t = 0),
  113535. this.x = e,
  113536. this.y = t,
  113537. e !== Math.floor(e) && (Math.floor(e),
  113538. K.Warn("x is not an integer, floor(x) used")),
  113539. t !== Math.floor(t) && (Math.floor(t),
  113540. K.Warn("y is not an integer, floor(y) used"))
  113541. }
  113542. return e.prototype.clone = function() {
  113543. return new e(this.x,this.y)
  113544. }
  113545. ,
  113546. e.prototype.rotate60About = function(e) {
  113547. var t = this.x;
  113548. return this.x = e.x + e.y - this.y,
  113549. this.y = t + this.y - e.x,
  113550. this
  113551. }
  113552. ,
  113553. e.prototype.rotateNeg60About = function(e) {
  113554. var t = this.x;
  113555. return this.x = t + this.y - e.y,
  113556. this.y = e.x + e.y - t,
  113557. this
  113558. }
  113559. ,
  113560. e.prototype.rotate120 = function(e, t) {
  113561. e !== Math.floor(e) && (Math.floor(e),
  113562. K.Warn("m not an integer only floor(m) used")),
  113563. t !== Math.floor(t) && (Math.floor(t),
  113564. K.Warn("n not an integer only floor(n) used"));
  113565. var i = this.x;
  113566. return this.x = e - i - this.y,
  113567. this.y = t + i,
  113568. this
  113569. }
  113570. ,
  113571. e.prototype.rotateNeg120 = function(e, t) {
  113572. e !== Math.floor(e) && (Math.floor(e),
  113573. K.Warn("m is not an integer, floor(m) used")),
  113574. t !== Math.floor(t) && (Math.floor(t),
  113575. K.Warn("n is not an integer, floor(n) used"));
  113576. var i = this.x;
  113577. return this.x = this.y - t,
  113578. this.y = e + t - i - this.y,
  113579. this
  113580. }
  113581. ,
  113582. e.prototype.toCartesianOrigin = function(e, t) {
  113583. var i = x.Zero();
  113584. return i.x = e.x + 2 * this.x * t + this.y * t,
  113585. i.y = e.y + Math.sqrt(3) * this.y * t,
  113586. i
  113587. }
  113588. ,
  113589. e.Zero = function() {
  113590. return new e(0,0)
  113591. }
  113592. ,
  113593. e
  113594. }()
  113595. , Vv = function() {
  113596. function e() {
  113597. this.cartesian = [],
  113598. this.vertices = [],
  113599. this.max = [],
  113600. this.min = [],
  113601. this.closestTo = [],
  113602. this.innerFacets = [],
  113603. this.isoVecsABOB = [],
  113604. this.isoVecsOBOA = [],
  113605. this.isoVecsBAOA = [],
  113606. this.vertexTypes = [],
  113607. this.IDATA = new kv("icosahedron","Regular",[[0, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 1]],[[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5], [7, 6, 1], [8, 7, 2], [9, 8, 3], [10, 9, 4], [6, 10, 5], [2, 7, 1], [3, 8, 2], [4, 9, 3], [5, 10, 4], [1, 6, 5], [11, 6, 7], [11, 7, 8], [11, 8, 9], [11, 9, 10], [11, 10, 6]])
  113608. }
  113609. return e.prototype.setIndices = function() {
  113610. var e, t, i, n, r, o, a, s = 12, l = {}, c = this.m, u = this.n, h = c;
  113611. 0 !== u && (h = d.HCF(c, u)),
  113612. e = c / h,
  113613. t = u / h;
  113614. var p, f, _, m = Uv.Zero(), g = new Uv(c,u), v = new Uv(-u,c + u), y = Uv.Zero(), b = Uv.Zero(), T = Uv.Zero(), E = [], S = [], A = this.vertByDist, x = function(e, t, i, n) {
  113615. f = t + "|" + n,
  113616. (p = e + "|" + i)in l || f in l ? p in l && !(f in l) ? l[f] = l[p] : f in l && !(p in l) && (l[p] = l[f]) : (l[p] = s,
  113617. l[f] = s,
  113618. s++),
  113619. A[i][0] > 2 ? S[l[p]] = [-A[i][0], A[i][1], l[p]] : S[l[p]] = [E[A[i][0]], A[i][1], l[p]]
  113620. };
  113621. this.IDATA.edgematch = [[1, "B"], [2, "B"], [3, "B"], [4, "B"], [0, "B"], [10, "O", 14, "A"], [11, "O", 10, "A"], [12, "O", 11, "A"], [13, "O", 12, "A"], [14, "O", 13, "A"], [0, "O"], [1, "O"], [2, "O"], [3, "O"], [4, "O"], [19, "B", 5, "A"], [15, "B", 6, "A"], [16, "B", 7, "A"], [17, "B", 8, "A"], [18, "B", 9, "A"]];
  113622. for (var R = 0; R < 20; R++) {
  113623. if (r = (E = this.IDATA.face[R])[2],
  113624. o = E[1],
  113625. a = E[0],
  113626. _ = m.x + "|" + m.y,
  113627. (p = R + "|" + _)in l || (l[p] = r,
  113628. S[r] = [E[A[_][0]], A[_][1]]),
  113629. _ = g.x + "|" + g.y,
  113630. (p = R + "|" + _)in l || (l[p] = o,
  113631. S[o] = [E[A[_][0]], A[_][1]]),
  113632. _ = v.x + "|" + v.y,
  113633. (p = R + "|" + _)in l || (l[p] = a,
  113634. S[a] = [E[A[_][0]], A[_][1]]),
  113635. i = this.IDATA.edgematch[R][0],
  113636. "B" === (n = this.IDATA.edgematch[R][1]))
  113637. for (var C = 1; C < h; C++)
  113638. b.x = c - C * (e + t),
  113639. b.y = u + C * e,
  113640. T.x = -C * t,
  113641. T.y = C * (e + t),
  113642. x(R, i, _ = b.x + "|" + b.y, T.x + "|" + T.y);
  113643. if ("O" === n)
  113644. for (C = 1; C < h; C++)
  113645. T.x = -C * t,
  113646. T.y = C * (e + t),
  113647. y.x = C * e,
  113648. y.y = C * t,
  113649. x(R, i, _ = T.x + "|" + T.y, y.x + "|" + y.y);
  113650. if (i = this.IDATA.edgematch[R][2],
  113651. (n = this.IDATA.edgematch[R][3]) && "A" === n)
  113652. for (C = 1; C < h; C++)
  113653. y.x = C * e,
  113654. y.y = C * t,
  113655. b.x = c - (h - C) * (e + t),
  113656. b.y = u + (h - C) * e,
  113657. x(R, i, _ = y.x + "|" + y.y, b.x + "|" + b.y);
  113658. for (C = 0; C < this.vertices.length; C++)
  113659. _ = this.vertices[C].x + "|" + this.vertices[C].y,
  113660. (p = R + "|" + _)in l || (l[p] = s++,
  113661. A[_][0] > 2 ? S[l[p]] = [-A[_][0], A[_][1], l[p]] : S[l[p]] = [E[A[_][0]], A[_][1], l[p]])
  113662. }
  113663. this.closestTo = S,
  113664. this.vecToidx = l
  113665. }
  113666. ,
  113667. e.prototype.calcCoeffs = function() {
  113668. var e = this.m
  113669. , t = this.n
  113670. , i = Math.sqrt(3) / 3
  113671. , n = e * e + t * t + e * t;
  113672. this.coau = (e + t) / n,
  113673. this.cobu = -t / n,
  113674. this.coav = -i * (e - t) / n,
  113675. this.cobv = i * (2 * e + t) / n
  113676. }
  113677. ,
  113678. e.prototype.createInnerFacets = function() {
  113679. for (var e = this.m, t = this.n, i = 0; i < t + e + 1; i++)
  113680. for (var n = this.min[i]; n < this.max[i] + 1; n++)
  113681. n < this.max[i] && n < this.max[i + 1] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + n + "|" + (i + 1), "|" + (n + 1) + "|" + i]),
  113682. i > 0 && n < this.max[i - 1] && n + 1 < this.max[i] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + (n + 1) + "|" + i, "|" + (n + 1) + "|" + (i - 1)])
  113683. }
  113684. ,
  113685. e.prototype.edgeVecsABOB = function() {
  113686. for (var e = this.m, t = this.n, i = new Uv(-t,e + t), n = 1; n < e + t; n++) {
  113687. var r = new Uv(this.min[n],n)
  113688. , o = new Uv(this.min[n - 1],n - 1)
  113689. , a = new Uv(this.min[n + 1],n + 1)
  113690. , s = r.clone()
  113691. , l = o.clone()
  113692. , c = a.clone();
  113693. s.rotate60About(i),
  113694. l.rotate60About(i),
  113695. c.rotate60About(i);
  113696. var u = new Uv(this.max[s.y],s.y)
  113697. , h = new Uv(this.max[s.y - 1],s.y - 1)
  113698. , d = new Uv(this.max[s.y - 1] - 1,s.y - 1);
  113699. s.x === u.x && s.y === u.y || (s.x !== h.x ? (this.vertexTypes.push([1, 0, 0]),
  113700. this.isoVecsABOB.push([r, h, d]),
  113701. this.vertexTypes.push([1, 0, 0]),
  113702. this.isoVecsABOB.push([r, d, u])) : s.y === c.y ? (this.vertexTypes.push([1, 1, 0]),
  113703. this.isoVecsABOB.push([r, o, h]),
  113704. this.vertexTypes.push([1, 0, 1]),
  113705. this.isoVecsABOB.push([r, h, a])) : (this.vertexTypes.push([1, 1, 0]),
  113706. this.isoVecsABOB.push([r, o, h]),
  113707. this.vertexTypes.push([1, 0, 0]),
  113708. this.isoVecsABOB.push([r, h, u])))
  113709. }
  113710. }
  113711. ,
  113712. e.prototype.mapABOBtoOBOA = function() {
  113713. for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
  113714. for (var i = [], n = 0; n < 3; n++)
  113715. e.x = this.isoVecsABOB[t][n].x,
  113716. e.y = this.isoVecsABOB[t][n].y,
  113717. 0 === this.vertexTypes[t][n] && e.rotateNeg120(this.m, this.n),
  113718. i.push(e.clone());
  113719. this.isoVecsOBOA.push(i)
  113720. }
  113721. }
  113722. ,
  113723. e.prototype.mapABOBtoBAOA = function() {
  113724. for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
  113725. for (var i = [], n = 0; n < 3; n++)
  113726. e.x = this.isoVecsABOB[t][n].x,
  113727. e.y = this.isoVecsABOB[t][n].y,
  113728. 1 === this.vertexTypes[t][n] && e.rotate120(this.m, this.n),
  113729. i.push(e.clone());
  113730. this.isoVecsBAOA.push(i)
  113731. }
  113732. }
  113733. ,
  113734. e.prototype.MapToFace = function(e, t) {
  113735. for (var i, n = this.IDATA.face[e], r = n[2], o = n[1], a = n[0], s = x.FromArray(this.IDATA.vertex[r]), l = x.FromArray(this.IDATA.vertex[o]), c = x.FromArray(this.IDATA.vertex[a]), u = l.subtract(s), h = c.subtract(s), d = u.scale(this.coau).add(h.scale(this.cobu)), p = u.scale(this.coav).add(h.scale(this.cobv)), f = [], _ = I.Vector3[0], m = 0; m < this.cartesian.length; m++)
  113736. _ = d.scale(this.cartesian[m].x).add(p.scale(this.cartesian[m].y)).add(s),
  113737. f[m] = [_.x, _.y, _.z],
  113738. i = e + "|" + this.vertices[m].x + "|" + this.vertices[m].y,
  113739. t.vertex[this.vecToidx[i]] = [_.x, _.y, _.z]
  113740. }
  113741. ,
  113742. e.prototype.build = function(e, t) {
  113743. var i = new Array
  113744. , n = Uv.Zero()
  113745. , r = new Uv(e,t)
  113746. , o = new Uv(-t,e + t);
  113747. i.push(n, r, o);
  113748. for (var a = t; a < e + 1; a++)
  113749. for (var s = 0; s < e + 1 - a; s++)
  113750. i.push(new Uv(s,a));
  113751. if (t > 0) {
  113752. for (var l = d.HCF(e, t), c = e / l, u = t / l, h = 1; h < l; h++)
  113753. i.push(new Uv(h * c,h * u)),
  113754. i.push(new Uv(-h * u,h * (c + u))),
  113755. i.push(new Uv(e - h * (c + u),t + h * c));
  113756. for (var p = e / t, f = 1; f < t; f++)
  113757. for (var _ = 0; _ < f * p; _++)
  113758. i.push(new Uv(_,f)),
  113759. i.push(new Uv(_,f).rotate120(e, t)),
  113760. i.push(new Uv(_,f).rotateNeg120(e, t))
  113761. }
  113762. i.sort((function(e, t) {
  113763. return e.x - t.x
  113764. }
  113765. )),
  113766. i.sort((function(e, t) {
  113767. return e.y - t.y
  113768. }
  113769. ));
  113770. var m = new Array(e + t + 1)
  113771. , g = new Array(e + t + 1);
  113772. for (h = 0; h < m.length; h++)
  113773. m[h] = 1 / 0,
  113774. g[h] = -1 / 0;
  113775. var v = 0
  113776. , y = 0
  113777. , b = i.length;
  113778. for (h = 0; h < b; h++)
  113779. y = i[h].x,
  113780. m[v = i[h].y] = Math.min(y, m[v]),
  113781. g[v] = Math.max(y, g[v]);
  113782. var T = function(i, n) {
  113783. var r = i.clone();
  113784. return "A" === n && r.rotateNeg120(e, t),
  113785. "B" === n && r.rotate120(e, t),
  113786. r.x < 0 ? r.y : r.x + r.y
  113787. }
  113788. , E = []
  113789. , S = []
  113790. , A = []
  113791. , x = []
  113792. , R = {}
  113793. , C = []
  113794. , P = -1
  113795. , M = -1;
  113796. for (h = 0; h < b; h++)
  113797. E[h] = i[h].toCartesianOrigin(new Uv(0,0), .5),
  113798. S[h] = T(i[h], "O"),
  113799. A[h] = T(i[h], "A"),
  113800. x[h] = T(i[h], "B"),
  113801. S[h] === A[h] && A[h] === x[h] ? (P = 3,
  113802. M = S[h]) : S[h] === A[h] ? (P = 4,
  113803. M = S[h]) : A[h] === x[h] ? (P = 5,
  113804. M = A[h]) : x[h] === S[h] && (P = 6,
  113805. M = S[h]),
  113806. S[h] < A[h] && S[h] < x[h] && (P = 2,
  113807. M = S[h]),
  113808. A[h] < S[h] && A[h] < x[h] && (P = 1,
  113809. M = A[h]),
  113810. x[h] < A[h] && x[h] < S[h] && (P = 0,
  113811. M = x[h]),
  113812. C.push([P, M, i[h].x, i[h].y]);
  113813. C.sort((function(e, t) {
  113814. return e[2] - t[2]
  113815. }
  113816. )),
  113817. C.sort((function(e, t) {
  113818. return e[3] - t[3]
  113819. }
  113820. )),
  113821. C.sort((function(e, t) {
  113822. return e[1] - t[1]
  113823. }
  113824. )),
  113825. C.sort((function(e, t) {
  113826. return e[0] - t[0]
  113827. }
  113828. ));
  113829. for (var I = 0; I < C.length; I++)
  113830. R[C[I][2] + "|" + C[I][3]] = [C[I][0], C[I][1], I];
  113831. return this.m = e,
  113832. this.n = t,
  113833. this.vertices = i,
  113834. this.vertByDist = R,
  113835. this.cartesian = E,
  113836. this.min = m,
  113837. this.max = g,
  113838. this
  113839. }
  113840. ,
  113841. e
  113842. }()
  113843. , kv = function(e, t, i, n) {
  113844. this.name = e,
  113845. this.category = t,
  113846. this.vertex = i,
  113847. this.face = n
  113848. }
  113849. , Gv = function(e) {
  113850. function t() {
  113851. return null !== e && e.apply(this, arguments) || this
  113852. }
  113853. return U(t, e),
  113854. t.prototype.innerToData = function(e, t) {
  113855. for (var i = 0; i < t.innerFacets.length; i++)
  113856. this.face.push(t.innerFacets[i].map((function(i) {
  113857. return t.vecToidx[e + i]
  113858. }
  113859. )))
  113860. }
  113861. ,
  113862. t.prototype.mapABOBtoDATA = function(e, t) {
  113863. for (var i = t.IDATA.edgematch[e][0], n = 0; n < t.isoVecsABOB.length; n++) {
  113864. for (var r = [], o = 0; o < 3; o++)
  113865. 0 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y) : r.push(i + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y);
  113866. this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
  113867. }
  113868. }
  113869. ,
  113870. t.prototype.mapOBOAtoDATA = function(e, t) {
  113871. for (var i = t.IDATA.edgematch[e][0], n = 0; n < t.isoVecsOBOA.length; n++) {
  113872. for (var r = [], o = 0; o < 3; o++)
  113873. 1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y) : r.push(i + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y);
  113874. this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
  113875. }
  113876. }
  113877. ,
  113878. t.prototype.mapBAOAtoDATA = function(e, t) {
  113879. for (var i = t.IDATA.edgematch[e][2], n = 0; n < t.isoVecsBAOA.length; n++) {
  113880. for (var r = [], o = 0; o < 3; o++)
  113881. 1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y) : r.push(i + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y);
  113882. this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
  113883. }
  113884. }
  113885. ,
  113886. t.prototype.orderData = function(e) {
  113887. for (var t = [], i = 0; i < 13; i++)
  113888. t[i] = [];
  113889. var n = e.closestTo;
  113890. for (i = 0; i < n.length; i++)
  113891. n[i][0] > -1 ? n[i][1] > 0 && t[n[i][0]].push([i, n[i][1]]) : t[12].push([i, n[i][0]]);
  113892. var r = [];
  113893. for (i = 0; i < 12; i++)
  113894. r[i] = i;
  113895. var o = 12;
  113896. for (i = 0; i < 12; i++) {
  113897. t[i].sort((function(e, t) {
  113898. return e[1] - t[1]
  113899. }
  113900. ));
  113901. for (var a = 0; a < t[i].length; a++)
  113902. r[t[i][a][0]] = o++
  113903. }
  113904. for (a = 0; a < t[12].length; a++)
  113905. r[t[12][a][0]] = o++;
  113906. for (i = 0; i < this.vertex.length; i++)
  113907. this.vertex[i].push(r[i]);
  113908. for (this.vertex.sort((function(e, t) {
  113909. return e[3] - t[3]
  113910. }
  113911. )),
  113912. i = 0; i < this.vertex.length; i++)
  113913. this.vertex[i].pop();
  113914. for (i = 0; i < this.face.length; i++)
  113915. for (a = 0; a < this.face[i].length; a++)
  113916. this.face[i][a] = r[this.face[i][a]];
  113917. this.sharedNodes = t[12].length,
  113918. this.poleNodes = this.vertex.length - this.sharedNodes
  113919. }
  113920. ,
  113921. t.prototype.setOrder = function(e, t) {
  113922. var i = []
  113923. , n = []
  113924. , r = t.pop();
  113925. n.push(r);
  113926. var o = this.face[r].indexOf(e);
  113927. o = (o + 2) % 3;
  113928. var a = this.face[r][o];
  113929. i.push(a);
  113930. for (var s = 0; t.length > 0; )
  113931. r = t[s],
  113932. this.face[r].indexOf(a) > -1 ? (o = (this.face[r].indexOf(a) + 1) % 3,
  113933. a = this.face[r][o],
  113934. i.push(a),
  113935. n.push(r),
  113936. t.splice(s, 1),
  113937. s = 0) : s++;
  113938. return this.adjacentFaces.push(i),
  113939. n
  113940. }
  113941. ,
  113942. t.prototype.toGoldbergPolyhedronData = function() {
  113943. var e = this
  113944. , t = new kv("GeoDual","Goldberg",[],[]);
  113945. t.name = "GD dual";
  113946. for (var i = this.vertex.length, n = new Array(i), r = 0; r < i; r++)
  113947. n[r] = [];
  113948. for (var o = 0; o < this.face.length; o++)
  113949. for (var a = 0; a < 3; a++)
  113950. n[this.face[o][a]].push(o);
  113951. var s = 0
  113952. , l = 0
  113953. , c = 0
  113954. , u = []
  113955. , h = [];
  113956. this.adjacentFaces = [];
  113957. for (var d = 0; d < n.length; d++)
  113958. t.face[d] = this.setOrder(d, n[d].concat([])),
  113959. n[d].forEach((function(i) {
  113960. s = 0,
  113961. l = 0,
  113962. c = 0,
  113963. u = e.face[i];
  113964. for (var n = 0; n < 3; n++)
  113965. h = e.vertex[u[n]],
  113966. s += h[0],
  113967. l += h[1],
  113968. c += h[2];
  113969. t.vertex[i] = [s / 3, l / 3, c / 3]
  113970. }
  113971. ));
  113972. return t
  113973. }
  113974. ,
  113975. t.BuildGeodesicData = function(e) {
  113976. var i = new t("Geodesic-m-n","Geodesic",[[0, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 1]],[]);
  113977. e.setIndices(),
  113978. e.calcCoeffs(),
  113979. e.createInnerFacets(),
  113980. e.edgeVecsABOB(),
  113981. e.mapABOBtoOBOA(),
  113982. e.mapABOBtoBAOA();
  113983. for (var n = 0; n < e.IDATA.face.length; n++)
  113984. e.MapToFace(n, i),
  113985. i.innerToData(n, e),
  113986. "B" === e.IDATA.edgematch[n][1] && i.mapABOBtoDATA(n, e),
  113987. "O" === e.IDATA.edgematch[n][1] && i.mapOBOAtoDATA(n, e),
  113988. "A" === e.IDATA.edgematch[n][3] && i.mapBAOAtoDATA(n, e);
  113989. return i.orderData(e),
  113990. i.vertex = i.vertex.map((function(e) {
  113991. var t = e[0]
  113992. , i = e[1]
  113993. , n = e[2]
  113994. , r = Math.sqrt(t * t + i * i + n * n);
  113995. return e[0] *= 1 / r,
  113996. e[1] *= 1 / r,
  113997. e[2] *= 1 / r,
  113998. e
  113999. }
  114000. )),
  114001. i
  114002. }
  114003. ,
  114004. t
  114005. }(kv);
  114006. function zv(e, t, i) {
  114007. void 0 === i && (i = null);
  114008. var n = t.m || 1;
  114009. n !== Math.floor(n) && (Math.floor(n),
  114010. K.Warn("m not an integer only floor(m) used"));
  114011. var r = t.n || 0;
  114012. if (r !== Math.floor(r) && (Math.floor(r),
  114013. K.Warn("n not an integer only floor(n) used")),
  114014. r > n) {
  114015. var o = r;
  114016. r = n,
  114017. n = o,
  114018. K.Warn("n > m therefore m and n swapped")
  114019. }
  114020. var a = new Vv;
  114021. return a.build(n, r),
  114022. Td(e, {
  114023. custom: Gv.BuildGeodesicData(a),
  114024. size: t.size,
  114025. sizeX: t.sizeX,
  114026. sizeY: t.sizeY,
  114027. sizeZ: t.sizeZ,
  114028. faceUV: t.faceUV,
  114029. faceColors: t.faceColors,
  114030. flat: t.flat,
  114031. updatable: t.updatable,
  114032. sideOrientation: t.sideOrientation,
  114033. frontUVs: t.frontUVs,
  114034. backUVs: t.backUVs
  114035. }, i)
  114036. }
  114037. function Wv(e, t) {
  114038. for (var i = e.size, n = e.sizeX || i || 1, r = e.sizeY || i || 1, o = e.sizeZ || i || 1, a = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, s = new Array, l = new Array, c = new Array, u = new Array, h = 1 / 0, d = -1 / 0, p = 1 / 0, f = -1 / 0, _ = 0; _ < t.vertex.length; _++)
  114039. h = Math.min(h, t.vertex[_][0] * n),
  114040. d = Math.max(d, t.vertex[_][0] * n),
  114041. p = Math.min(p, t.vertex[_][1] * r),
  114042. f = Math.max(f, t.vertex[_][1] * r);
  114043. for (var m = 0, g = 0; g < t.face.length; g++) {
  114044. var v = t.face[g]
  114045. , y = x.FromArray(t.vertex[v[0]])
  114046. , b = x.FromArray(t.vertex[v[2]])
  114047. , T = x.FromArray(t.vertex[v[1]])
  114048. , E = b.subtract(y)
  114049. , S = T.subtract(y)
  114050. , A = x.Cross(S, E).normalize();
  114051. for (_ = 0; _ < v.length; _++) {
  114052. c.push(A.x, A.y, A.z);
  114053. var R = t.vertex[v[_]];
  114054. s.push(R[0] * n, R[1] * r, R[2] * o);
  114055. var C = (R[1] * r - p) / (f - p);
  114056. u.push((R[0] * n - h) / (d - h), pr.UseOpenGLOrientationForUV ? 1 - C : C)
  114057. }
  114058. for (_ = 0; _ < v.length - 2; _++)
  114059. l.push(m, m + _ + 2, m + _ + 1);
  114060. m += v.length
  114061. }
  114062. $n._ComputeSides(a, s, l, c, u);
  114063. var P = new $n;
  114064. return P.positions = s,
  114065. P.indices = l,
  114066. P.normals = c,
  114067. P.uvs = u,
  114068. P
  114069. }
  114070. function Hv(e, t, i) {
  114071. void 0 === i && (i = null);
  114072. var n = t.size
  114073. , r = t.sizeX || n || 1
  114074. , o = t.sizeY || n || 1
  114075. , a = t.sizeZ || n || 1
  114076. , s = t.m || 1;
  114077. s !== Math.floor(s) && (Math.floor(s),
  114078. K.Warn("m not an integer only floor(m) used"));
  114079. var l = t.n || 0;
  114080. if (l !== Math.floor(l) && (Math.floor(l),
  114081. K.Warn("n not an integer only floor(n) used")),
  114082. l > s) {
  114083. var c = l;
  114084. l = s,
  114085. s = c,
  114086. K.Warn("n > m therefore m and n swapped")
  114087. }
  114088. var u = new Vv;
  114089. u.build(s, l);
  114090. var h = Gv.BuildGeodesicData(u)
  114091. , d = h.toGoldbergPolyhedronData()
  114092. , p = new uv(e,i);
  114093. t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
  114094. p._originalBuilderSideOrientation = t.sideOrientation,
  114095. Wv(t, d).applyToMesh(p, t.updatable),
  114096. p.goldbergData.nbSharedFaces = h.sharedNodes,
  114097. p.goldbergData.nbUnsharedFaces = h.poleNodes,
  114098. p.goldbergData.adjacentFaces = h.adjacentFaces,
  114099. p.goldbergData.nbFaces = p.goldbergData.nbSharedFaces + p.goldbergData.nbUnsharedFaces,
  114100. p.goldbergData.nbFacesAtPole = (p.goldbergData.nbUnsharedFaces - 12) / 12;
  114101. for (var f = 0; f < h.vertex.length; f++)
  114102. p.goldbergData.faceCenters.push(x.FromArray(h.vertex[f])),
  114103. p.goldbergData.faceCenters[f].x *= r,
  114104. p.goldbergData.faceCenters[f].y *= o,
  114105. p.goldbergData.faceCenters[f].z *= a,
  114106. p.goldbergData.faceColors.push(new N(1,1,1,1));
  114107. for (f = 0; f < d.face.length; f++) {
  114108. var _ = d.face[f]
  114109. , m = x.FromArray(d.vertex[_[0]])
  114110. , g = x.FromArray(d.vertex[_[2]])
  114111. , v = x.FromArray(d.vertex[_[1]])
  114112. , y = g.subtract(m)
  114113. , b = v.subtract(m)
  114114. , T = x.Cross(b, y).normalize()
  114115. , E = x.Cross(b, T).normalize();
  114116. p.goldbergData.faceXaxis.push(b.normalize()),
  114117. p.goldbergData.faceYaxis.push(T),
  114118. p.goldbergData.faceZaxis.push(E)
  114119. }
  114120. return p
  114121. }
  114122. Vr.CreateGoldberg = Hv;
  114123. var Xv, jv = {
  114124. CreateBox: Ml,
  114125. CreateTiledBox: mv,
  114126. CreateSphere: Dl,
  114127. CreateDisc: Pd,
  114128. CreateIcoSphere: Lv,
  114129. CreateRibbon: nc,
  114130. CreateCylinder: Ys,
  114131. CreateTorus: qs,
  114132. CreateTorusKnot: yv,
  114133. CreateLineSystem: Zl,
  114134. CreateLines: Jl,
  114135. CreateDashedLines: $l,
  114136. ExtrudeShape: oc,
  114137. ExtrudeShapeCustom: ac,
  114138. CreateLathe: Mv,
  114139. CreateTiledPlane: pv,
  114140. CreatePlane: vo,
  114141. CreateGround: il,
  114142. CreateTiledGround: nl,
  114143. CreateGroundFromHeightMap: rl,
  114144. CreatePolygon: Rv,
  114145. ExtrudePolygon: Cv,
  114146. CreateTube: Ov,
  114147. CreatePolyhedron: Td,
  114148. CreateGeodesic: zv,
  114149. CreateGoldberg: Hv,
  114150. CreateDecal: wv,
  114151. CreateCapsule: Gl
  114152. }, Yv = function(e, t, i) {
  114153. this.quality = e,
  114154. this.distance = t,
  114155. this.optimizeMesh = i
  114156. }, Kv = function() {
  114157. function e() {
  114158. this.running = !1,
  114159. this._simplificationArray = []
  114160. }
  114161. return e.prototype.addTask = function(e) {
  114162. this._simplificationArray.push(e)
  114163. }
  114164. ,
  114165. e.prototype.executeNext = function() {
  114166. var e = this._simplificationArray.pop();
  114167. e ? (this.running = !0,
  114168. this.runSimplification(e)) : this.running = !1
  114169. }
  114170. ,
  114171. e.prototype.runSimplification = function(e) {
  114172. var t = this;
  114173. if (e.parallelProcessing)
  114174. e.settings.forEach((function(i) {
  114175. t._getSimplifier(e).simplify(i, (function(n) {
  114176. void 0 !== i.distance && e.mesh.addLODLevel(i.distance, n),
  114177. n.isVisible = !0,
  114178. i.quality === e.settings[e.settings.length - 1].quality && e.successCallback && e.successCallback(),
  114179. t.executeNext()
  114180. }
  114181. ))
  114182. }
  114183. ));
  114184. else {
  114185. var i = this._getSimplifier(e);
  114186. yi.Run(e.settings.length, (function(t) {
  114187. var n, r;
  114188. n = e.settings[t.index],
  114189. r = function() {
  114190. t.executeNext()
  114191. }
  114192. ,
  114193. i.simplify(n, (function(t) {
  114194. void 0 !== n.distance && e.mesh.addLODLevel(n.distance, t),
  114195. t.isVisible = !0,
  114196. r()
  114197. }
  114198. ))
  114199. }
  114200. ), (function() {
  114201. e.successCallback && e.successCallback(),
  114202. t.executeNext()
  114203. }
  114204. ))
  114205. }
  114206. }
  114207. ,
  114208. e.prototype._getSimplifier = function(e) {
  114209. return e.simplificationType,
  114210. Xv.QUADRATIC,
  114211. new $v(e.mesh)
  114212. }
  114213. ,
  114214. e
  114215. }();
  114216. !function(e) {
  114217. e[e.QUADRATIC = 0] = "QUADRATIC"
  114218. }(Xv || (Xv = {}));
  114219. var Qv = function(e) {
  114220. this._vertices = e,
  114221. this.error = new Array(4),
  114222. this.deleted = !1,
  114223. this.isDirty = !1,
  114224. this.deletePending = !1,
  114225. this.borderFactor = 0
  114226. }
  114227. , qv = function() {
  114228. function e(e, t) {
  114229. this.position = e,
  114230. this.id = t,
  114231. this.isBorder = !0,
  114232. this.q = new Zv,
  114233. this.triangleCount = 0,
  114234. this.triangleStart = 0,
  114235. this.originalOffsets = []
  114236. }
  114237. return e.prototype.updatePosition = function(e) {
  114238. this.position.copyFrom(e)
  114239. }
  114240. ,
  114241. e
  114242. }()
  114243. , Zv = function() {
  114244. function e(e) {
  114245. this.data = new Array(10);
  114246. for (var t = 0; t < 10; ++t)
  114247. e && e[t] ? this.data[t] = e[t] : this.data[t] = 0
  114248. }
  114249. return e.prototype.det = function(e, t, i, n, r, o, a, s, l) {
  114250. return this.data[e] * this.data[r] * this.data[l] + this.data[i] * this.data[n] * this.data[s] + this.data[t] * this.data[o] * this.data[a] - this.data[i] * this.data[r] * this.data[a] - this.data[e] * this.data[o] * this.data[s] - this.data[t] * this.data[n] * this.data[l]
  114251. }
  114252. ,
  114253. e.prototype.addInPlace = function(e) {
  114254. for (var t = 0; t < 10; ++t)
  114255. this.data[t] += e.data[t]
  114256. }
  114257. ,
  114258. e.prototype.addArrayInPlace = function(e) {
  114259. for (var t = 0; t < 10; ++t)
  114260. this.data[t] += e[t]
  114261. }
  114262. ,
  114263. e.prototype.add = function(t) {
  114264. for (var i = new e, n = 0; n < 10; ++n)
  114265. i.data[n] = this.data[n] + t.data[n];
  114266. return i
  114267. }
  114268. ,
  114269. e.FromData = function(t, i, n, r) {
  114270. return new e(e.DataFromNumbers(t, i, n, r))
  114271. }
  114272. ,
  114273. e.DataFromNumbers = function(e, t, i, n) {
  114274. return [e * e, e * t, e * i, e * n, t * t, t * i, t * n, i * i, i * n, n * n]
  114275. }
  114276. ,
  114277. e
  114278. }()
  114279. , Jv = function(e, t) {
  114280. this.vertexId = e,
  114281. this.triangleId = t
  114282. }
  114283. , $v = function() {
  114284. function e(e) {
  114285. this._mesh = e,
  114286. this.syncIterations = 5e3,
  114287. this.aggressiveness = 7,
  114288. this.decimationIterations = 100,
  114289. this.boundingBoxEpsilon = m
  114290. }
  114291. return e.prototype.simplify = function(e, t) {
  114292. var i = this;
  114293. this._initDecimatedMesh(),
  114294. yi.Run(this._mesh.subMeshes.length, (function(t) {
  114295. i._initWithMesh(t.index, (function() {
  114296. i._runDecimation(e, t.index, (function() {
  114297. t.executeNext()
  114298. }
  114299. ))
  114300. }
  114301. ), e.optimizeMesh)
  114302. }
  114303. ), (function() {
  114304. setTimeout((function() {
  114305. t(i._reconstructedMesh)
  114306. }
  114307. ), 0)
  114308. }
  114309. ))
  114310. }
  114311. ,
  114312. e.prototype._runDecimation = function(e, t, i) {
  114313. var n = this
  114314. , r = ~~(this._triangles.length * e.quality)
  114315. , o = 0
  114316. , a = this._triangles.length;
  114317. yi.Run(this.decimationIterations, (function(e) {
  114318. var t, i;
  114319. a - o <= r ? e.breakLoop() : (t = e.index,
  114320. i = function() {
  114321. e.executeNext()
  114322. }
  114323. ,
  114324. setTimeout((function() {
  114325. t % 5 == 0 && n._updateMesh(0 === t);
  114326. for (var e = 0; e < n._triangles.length; ++e)
  114327. n._triangles[e].isDirty = !1;
  114328. var s = 1e-9 * Math.pow(t + 3, n.aggressiveness);
  114329. yi.SyncAsyncForLoop(n._triangles.length, n.syncIterations, (function(e) {
  114330. var t = ~~((n._triangles.length / 2 + e) % n._triangles.length)
  114331. , i = n._triangles[t];
  114332. if (i && !(i.error[3] > s || i.deleted || i.isDirty))
  114333. for (var r = function(e) {
  114334. if (i.error[e] < s) {
  114335. var t = []
  114336. , r = []
  114337. , a = i._vertices[e]
  114338. , l = i._vertices[(e + 1) % 3];
  114339. if (a.isBorder || l.isBorder)
  114340. return "continue";
  114341. var c = x.Zero();
  114342. n._calculateError(a, l, c);
  114343. var u = new Array;
  114344. if (n._isFlipped(a, l, c, t, u))
  114345. return "continue";
  114346. if (n._isFlipped(l, a, c, r, u))
  114347. return "continue";
  114348. if (t.indexOf(!0) < 0 || r.indexOf(!0) < 0)
  114349. return "continue";
  114350. var h = new Array;
  114351. if (u.forEach((function(e) {
  114352. -1 === h.indexOf(e) && (e.deletePending = !0,
  114353. h.push(e))
  114354. }
  114355. )),
  114356. h.length % 2 != 0)
  114357. return "continue";
  114358. a.q = l.q.add(a.q),
  114359. a.updatePosition(c);
  114360. var d = n._references.length;
  114361. o = n._updateTriangles(a, a, t, o),
  114362. o = n._updateTriangles(a, l, r, o);
  114363. var p = n._references.length - d;
  114364. if (p <= a.triangleCount) {
  114365. if (p)
  114366. for (var f = 0; f < p; f++)
  114367. n._references[a.triangleStart + f] = n._references[d + f]
  114368. } else
  114369. a.triangleStart = d;
  114370. return a.triangleCount = p,
  114371. "break"
  114372. }
  114373. }, a = 0; a < 3 && "break" !== r(a); ++a)
  114374. ;
  114375. }
  114376. ), i, (function() {
  114377. return a - o <= r
  114378. }
  114379. ))
  114380. }
  114381. ), 0))
  114382. }
  114383. ), (function() {
  114384. setTimeout((function() {
  114385. n._reconstructMesh(t),
  114386. i()
  114387. }
  114388. ), 0)
  114389. }
  114390. ))
  114391. }
  114392. ,
  114393. e.prototype._initWithMesh = function(e, t, i) {
  114394. var n = this;
  114395. this._vertices = [],
  114396. this._triangles = [];
  114397. var r = this._mesh.getVerticesData(Bi.PositionKind)
  114398. , o = this._mesh.getIndices()
  114399. , a = this._mesh.subMeshes[e]
  114400. , s = []
  114401. , l = a.verticesCount;
  114402. yi.SyncAsyncForLoop(l, this.syncIterations / 4 >> 0, (function(e) {
  114403. if (r) {
  114404. var t = e + a.verticesStart
  114405. , o = x.FromArray(r, 3 * t)
  114406. , l = function(e) {
  114407. if (i)
  114408. for (var t = 0; t < n._vertices.length; ++t)
  114409. if (n._vertices[t].position.equalsWithEpsilon(e, 1e-4))
  114410. return n._vertices[t];
  114411. return null
  114412. }(o) || new qv(o,n._vertices.length);
  114413. l.originalOffsets.push(t),
  114414. l.id === n._vertices.length && n._vertices.push(l),
  114415. s.push(l.id)
  114416. }
  114417. }
  114418. ), (function() {
  114419. yi.SyncAsyncForLoop(a.indexCount / 3, n.syncIterations, (function(e) {
  114420. if (o) {
  114421. var t = 3 * (a.indexStart / 3 + e)
  114422. , i = o[t + 0]
  114423. , r = o[t + 1]
  114424. , l = o[t + 2]
  114425. , c = n._vertices[s[i - a.verticesStart]]
  114426. , u = n._vertices[s[r - a.verticesStart]]
  114427. , h = n._vertices[s[l - a.verticesStart]]
  114428. , d = new Qv([c, u, h]);
  114429. d.originalOffset = t,
  114430. n._triangles.push(d)
  114431. }
  114432. }
  114433. ), (function() {
  114434. n._init(t)
  114435. }
  114436. ))
  114437. }
  114438. ))
  114439. }
  114440. ,
  114441. e.prototype._init = function(e) {
  114442. var t = this;
  114443. yi.SyncAsyncForLoop(this._triangles.length, this.syncIterations, (function(e) {
  114444. var i = t._triangles[e];
  114445. i.normal = x.Cross(i._vertices[1].position.subtract(i._vertices[0].position), i._vertices[2].position.subtract(i._vertices[0].position)).normalize();
  114446. for (var n = 0; n < 3; n++)
  114447. i._vertices[n].q.addArrayInPlace(Zv.DataFromNumbers(i.normal.x, i.normal.y, i.normal.z, -x.Dot(i.normal, i._vertices[0].position)))
  114448. }
  114449. ), (function() {
  114450. yi.SyncAsyncForLoop(t._triangles.length, t.syncIterations, (function(e) {
  114451. for (var i = t._triangles[e], n = 0; n < 3; ++n)
  114452. i.error[n] = t._calculateError(i._vertices[n], i._vertices[(n + 1) % 3]);
  114453. i.error[3] = Math.min(i.error[0], i.error[1], i.error[2])
  114454. }
  114455. ), (function() {
  114456. e()
  114457. }
  114458. ))
  114459. }
  114460. ))
  114461. }
  114462. ,
  114463. e.prototype._reconstructMesh = function(e) {
  114464. var t, i, n, r = [];
  114465. for (t = 0; t < this._vertices.length; ++t)
  114466. this._vertices[t].triangleCount = 0;
  114467. for (t = 0; t < this._triangles.length; ++t)
  114468. if (!this._triangles[t].deleted) {
  114469. for (i = this._triangles[t],
  114470. n = 0; n < 3; ++n)
  114471. i._vertices[n].triangleCount = 1;
  114472. r.push(i)
  114473. }
  114474. var o = this._reconstructedMesh.getVerticesData(Bi.PositionKind) || []
  114475. , a = this._reconstructedMesh.getVerticesData(Bi.NormalKind) || []
  114476. , s = this._reconstructedMesh.getVerticesData(Bi.UVKind) || []
  114477. , l = this._reconstructedMesh.getVerticesData(Bi.ColorKind) || []
  114478. , c = this._mesh.getVerticesData(Bi.NormalKind)
  114479. , u = this._mesh.getVerticesData(Bi.UVKind)
  114480. , h = this._mesh.getVerticesData(Bi.ColorKind)
  114481. , d = 0
  114482. , p = function() {
  114483. var e = f._vertices[t];
  114484. e.id = d,
  114485. e.triangleCount && e.originalOffsets.forEach((function(t) {
  114486. o.push(e.position.x),
  114487. o.push(e.position.y),
  114488. o.push(e.position.z),
  114489. c && c.length && (a.push(c[3 * t]),
  114490. a.push(c[3 * t + 1]),
  114491. a.push(c[3 * t + 2])),
  114492. u && u.length && (s.push(u[2 * t]),
  114493. s.push(u[2 * t + 1])),
  114494. h && h.length && (l.push(h[4 * t]),
  114495. l.push(h[4 * t + 1]),
  114496. l.push(h[4 * t + 2]),
  114497. l.push(h[4 * t + 3])),
  114498. ++d
  114499. }
  114500. ))
  114501. }
  114502. , f = this;
  114503. for (t = 0; t < this._vertices.length; ++t)
  114504. p();
  114505. var _ = this._reconstructedMesh.getTotalIndices()
  114506. , m = this._reconstructedMesh.getTotalVertices()
  114507. , g = this._reconstructedMesh.subMeshes;
  114508. this._reconstructedMesh.subMeshes = [];
  114509. var v = this._reconstructedMesh.getIndices()
  114510. , y = this._mesh.getIndices();
  114511. for (t = 0; t < r.length; ++t)
  114512. i = r[t],
  114513. [0, 1, 2].forEach((function(e) {
  114514. var t = y[i.originalOffset + e]
  114515. , n = i._vertices[e].originalOffsets.indexOf(t);
  114516. n < 0 && (n = 0),
  114517. v.push(i._vertices[e].id + n + m)
  114518. }
  114519. ));
  114520. this._reconstructedMesh.setIndices(v),
  114521. this._reconstructedMesh.setVerticesData(Bi.PositionKind, o),
  114522. a.length > 0 && this._reconstructedMesh.setVerticesData(Bi.NormalKind, a),
  114523. s.length > 0 && this._reconstructedMesh.setVerticesData(Bi.UVKind, s),
  114524. l.length > 0 && this._reconstructedMesh.setVerticesData(Bi.ColorKind, l);
  114525. var b = this._mesh.subMeshes[e];
  114526. e > 0 && (this._reconstructedMesh.subMeshes = [],
  114527. g.forEach((function(e) {
  114528. hr.AddToMesh(e.materialIndex, e.verticesStart, e.verticesCount, e.indexStart, e.indexCount, e.getMesh())
  114529. }
  114530. )),
  114531. hr.AddToMesh(b.materialIndex, m, d, _, 3 * r.length, this._reconstructedMesh))
  114532. }
  114533. ,
  114534. e.prototype._initDecimatedMesh = function() {
  114535. this._reconstructedMesh = new Vr(this._mesh.name + "Decimated",this._mesh.getScene()),
  114536. this._reconstructedMesh.material = this._mesh.material,
  114537. this._reconstructedMesh.parent = this._mesh.parent,
  114538. this._reconstructedMesh.isVisible = !1,
  114539. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId
  114540. }
  114541. ,
  114542. e.prototype._isFlipped = function(e, t, i, n, r) {
  114543. for (var o = 0; o < e.triangleCount; ++o) {
  114544. var a = this._triangles[this._references[e.triangleStart + o].triangleId];
  114545. if (!a.deleted) {
  114546. var s = this._references[e.triangleStart + o].vertexId
  114547. , l = a._vertices[(s + 1) % 3]
  114548. , c = a._vertices[(s + 2) % 3];
  114549. if (l !== t && c !== t) {
  114550. var u = l.position.subtract(i);
  114551. u = u.normalize();
  114552. var h = c.position.subtract(i);
  114553. if (h = h.normalize(),
  114554. Math.abs(x.Dot(u, h)) > .999)
  114555. return !0;
  114556. var d = x.Cross(u, h).normalize();
  114557. if (n[o] = !1,
  114558. x.Dot(d, a.normal) < .2)
  114559. return !0
  114560. } else
  114561. n[o] = !0,
  114562. r.push(a)
  114563. }
  114564. }
  114565. return !1
  114566. }
  114567. ,
  114568. e.prototype._updateTriangles = function(e, t, i, n) {
  114569. for (var r = n, o = 0; o < t.triangleCount; ++o) {
  114570. var a = this._references[t.triangleStart + o]
  114571. , s = this._triangles[a.triangleId];
  114572. s.deleted || (i[o] && s.deletePending ? (s.deleted = !0,
  114573. r++) : (s._vertices[a.vertexId] = e,
  114574. s.isDirty = !0,
  114575. s.error[0] = this._calculateError(s._vertices[0], s._vertices[1]) + s.borderFactor / 2,
  114576. s.error[1] = this._calculateError(s._vertices[1], s._vertices[2]) + s.borderFactor / 2,
  114577. s.error[2] = this._calculateError(s._vertices[2], s._vertices[0]) + s.borderFactor / 2,
  114578. s.error[3] = Math.min(s.error[0], s.error[1], s.error[2]),
  114579. this._references.push(a)))
  114580. }
  114581. return r
  114582. }
  114583. ,
  114584. e.prototype._identifyBorder = function() {
  114585. for (var e = 0; e < this._vertices.length; ++e) {
  114586. var t = []
  114587. , i = []
  114588. , n = this._vertices[e]
  114589. , r = void 0;
  114590. for (r = 0; r < n.triangleCount; ++r)
  114591. for (var o = this._triangles[this._references[n.triangleStart + r].triangleId], a = 0; a < 3; a++) {
  114592. for (var s = 0, l = o._vertices[a]; s < t.length && i[s] !== l.id; )
  114593. ++s;
  114594. s === t.length ? (t.push(1),
  114595. i.push(l.id)) : t[s]++
  114596. }
  114597. for (r = 0; r < t.length; ++r)
  114598. 1 === t[r] ? this._vertices[i[r]].isBorder = !0 : this._vertices[i[r]].isBorder = !1
  114599. }
  114600. }
  114601. ,
  114602. e.prototype._updateMesh = function(e) {
  114603. var t, i, n, r;
  114604. if (void 0 === e && (e = !1),
  114605. !e) {
  114606. var o = [];
  114607. for (t = 0; t < this._triangles.length; ++t)
  114608. this._triangles[t].deleted || o.push(this._triangles[t]);
  114609. this._triangles = o
  114610. }
  114611. for (t = 0; t < this._vertices.length; ++t)
  114612. this._vertices[t].triangleCount = 0,
  114613. this._vertices[t].triangleStart = 0;
  114614. for (t = 0; t < this._triangles.length; ++t)
  114615. for (i = this._triangles[t],
  114616. n = 0; n < 3; ++n)
  114617. (r = i._vertices[n]).triangleCount++;
  114618. var a = 0;
  114619. for (t = 0; t < this._vertices.length; ++t)
  114620. this._vertices[t].triangleStart = a,
  114621. a += this._vertices[t].triangleCount,
  114622. this._vertices[t].triangleCount = 0;
  114623. var s = new Array(3 * this._triangles.length);
  114624. for (t = 0; t < this._triangles.length; ++t)
  114625. for (i = this._triangles[t],
  114626. n = 0; n < 3; ++n)
  114627. s[(r = i._vertices[n]).triangleStart + r.triangleCount] = new Jv(n,t),
  114628. r.triangleCount++;
  114629. this._references = s,
  114630. e && this._identifyBorder()
  114631. }
  114632. ,
  114633. e.prototype._vertexError = function(e, t) {
  114634. var i = t.x
  114635. , n = t.y
  114636. , r = t.z;
  114637. return e.data[0] * i * i + 2 * e.data[1] * i * n + 2 * e.data[2] * i * r + 2 * e.data[3] * i + e.data[4] * n * n + 2 * e.data[5] * n * r + 2 * e.data[6] * n + e.data[7] * r * r + 2 * e.data[8] * r + e.data[9]
  114638. }
  114639. ,
  114640. e.prototype._calculateError = function(e, t, i) {
  114641. var n = e.q.add(t.q)
  114642. , r = e.isBorder && t.isBorder
  114643. , o = 0
  114644. , a = n.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  114645. if (0 === a || r) {
  114646. var s = e.position.add(t.position).divide(new x(2,2,2))
  114647. , l = this._vertexError(n, e.position)
  114648. , c = this._vertexError(n, t.position)
  114649. , u = this._vertexError(n, s);
  114650. (o = Math.min(l, c, u)) === l ? i && i.copyFrom(e.position) : o === c ? i && i.copyFrom(t.position) : i && i.copyFrom(s)
  114651. } else
  114652. i || (i = x.Zero()),
  114653. i.x = -1 / a * n.det(1, 2, 3, 4, 5, 6, 5, 7, 8),
  114654. i.y = 1 / a * n.det(0, 2, 3, 1, 5, 6, 2, 7, 8),
  114655. i.z = -1 / a * n.det(0, 1, 3, 1, 4, 6, 2, 5, 8),
  114656. o = this._vertexError(n, i);
  114657. return o
  114658. }
  114659. ,
  114660. e
  114661. }();
  114662. Object.defineProperty(mn.prototype, "simplificationQueue", {
  114663. get: function() {
  114664. if (!this._simplificationQueue) {
  114665. this._simplificationQueue = new Kv;
  114666. var e = this._getComponent(Wi.NAME_SIMPLIFICATIONQUEUE);
  114667. e || (e = new ey(this),
  114668. this._addComponent(e))
  114669. }
  114670. return this._simplificationQueue
  114671. },
  114672. set: function(e) {
  114673. this._simplificationQueue = e
  114674. },
  114675. enumerable: !0,
  114676. configurable: !0
  114677. }),
  114678. Vr.prototype.simplify = function(e, t, i, n) {
  114679. return void 0 === t && (t = !0),
  114680. void 0 === i && (i = Xv.QUADRATIC),
  114681. this.getScene().simplificationQueue.addTask({
  114682. settings: e,
  114683. parallelProcessing: t,
  114684. mesh: this,
  114685. simplificationType: i,
  114686. successCallback: n
  114687. }),
  114688. this
  114689. }
  114690. ;
  114691. var ey = function() {
  114692. function e(e) {
  114693. this.name = Wi.NAME_SIMPLIFICATIONQUEUE,
  114694. this.scene = e
  114695. }
  114696. return e.prototype.register = function() {
  114697. this.scene._beforeCameraUpdateStage.registerStep(Wi.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate)
  114698. }
  114699. ,
  114700. e.prototype.rebuild = function() {}
  114701. ,
  114702. e.prototype.dispose = function() {}
  114703. ,
  114704. e.prototype._beforeCameraUpdate = function() {
  114705. this.scene._simplificationQueue && !this.scene._simplificationQueue.running && this.scene._simplificationQueue.executeNext()
  114706. }
  114707. ,
  114708. e
  114709. }();
  114710. Vr.prototype.thinInstanceAdd = function(e, t) {
  114711. void 0 === t && (t = !0),
  114712. this._thinInstanceUpdateBufferSize("matrix", Array.isArray(e) ? e.length : 1);
  114713. var i = this._thinInstanceDataStorage.instancesCount;
  114714. if (Array.isArray(e))
  114715. for (var n = 0; n < e.length; ++n)
  114716. this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e[n], n === e.length - 1 && t);
  114717. else
  114718. this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e, t);
  114719. return i
  114720. }
  114721. ,
  114722. Vr.prototype.thinInstanceAddSelf = function(e) {
  114723. return void 0 === e && (e = !0),
  114724. this.thinInstanceAdd(P.IdentityReadOnly, e)
  114725. }
  114726. ,
  114727. Vr.prototype.thinInstanceRegisterAttribute = function(e, t) {
  114728. this.removeVerticesData(e),
  114729. this._thinInstanceInitializeUserStorage(),
  114730. this._userThinInstanceBuffersStorage.strides[e] = t,
  114731. this._userThinInstanceBuffersStorage.sizes[e] = t * Math.max(32, this._thinInstanceDataStorage.instancesCount),
  114732. this._userThinInstanceBuffersStorage.data[e] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[e]),
  114733. this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),this._userThinInstanceBuffersStorage.data[e],e,!0,!1,t,!0),
  114734. this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])
  114735. }
  114736. ,
  114737. Vr.prototype.thinInstanceSetMatrixAt = function(e, t, i) {
  114738. if (void 0 === i && (i = !0),
  114739. !this._thinInstanceDataStorage.matrixData || e >= this._thinInstanceDataStorage.instancesCount)
  114740. return !1;
  114741. var n = this._thinInstanceDataStorage.matrixData;
  114742. return t.copyToArray(n, 16 * e),
  114743. this._thinInstanceDataStorage.worldMatrices && (this._thinInstanceDataStorage.worldMatrices[e] = t),
  114744. i && (this.thinInstanceBufferUpdated("matrix"),
  114745. this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)),
  114746. !0
  114747. }
  114748. ,
  114749. Vr.prototype.thinInstanceSetAttributeAt = function(e, t, i, n) {
  114750. return void 0 === n && (n = !0),
  114751. !(!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[e] || t >= this._thinInstanceDataStorage.instancesCount || (this._thinInstanceUpdateBufferSize(e, 0),
  114752. this._userThinInstanceBuffersStorage.data[e].set(i, t * this._userThinInstanceBuffersStorage.strides[e]),
  114753. n && this.thinInstanceBufferUpdated(e),
  114754. 0))
  114755. }
  114756. ,
  114757. Object.defineProperty(Vr.prototype, "thinInstanceCount", {
  114758. get: function() {
  114759. return this._thinInstanceDataStorage.instancesCount
  114760. },
  114761. set: function(e) {
  114762. var t, i;
  114763. e <= (null !== (i = null === (t = this._thinInstanceDataStorage.matrixData) || void 0 === t ? void 0 : t.length) && void 0 !== i ? i : 0) / 16 && (this._thinInstanceDataStorage.instancesCount = e)
  114764. },
  114765. enumerable: !0,
  114766. configurable: !0
  114767. }),
  114768. Vr.prototype._thinInstanceCreateMatrixBuffer = function(e, t, i) {
  114769. void 0 === i && (i = !1);
  114770. for (var n = new wi(this.getEngine(),t,!i,16,!1,!0), r = 0; r < 4; r++)
  114771. this.setVerticesBuffer(n.createVertexBuffer(e + r, 4 * r, 4));
  114772. return n
  114773. }
  114774. ,
  114775. Vr.prototype.thinInstanceSetBuffer = function(e, t, i, n) {
  114776. var r, o, a;
  114777. void 0 === i && (i = 0),
  114778. void 0 === n && (n = !1),
  114779. i = i || 16,
  114780. "matrix" === e ? (null === (r = this._thinInstanceDataStorage.matrixBuffer) || void 0 === r || r.dispose(),
  114781. this._thinInstanceDataStorage.matrixBuffer = null,
  114782. this._thinInstanceDataStorage.matrixBufferSize = t ? t.length : 32 * i,
  114783. this._thinInstanceDataStorage.matrixData = t,
  114784. this._thinInstanceDataStorage.worldMatrices = null,
  114785. null !== t ? (this._thinInstanceDataStorage.instancesCount = t.length / i,
  114786. this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", t, n),
  114787. this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)) : (this._thinInstanceDataStorage.instancesCount = 0,
  114788. this.doNotSyncBoundingInfo || this.refreshBoundingInfo())) : "previousMatrix" === e ? (null === (o = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === o || o.dispose(),
  114789. this._thinInstanceDataStorage.previousMatrixBuffer = null,
  114790. this._thinInstanceDataStorage.previousMatrixData = t,
  114791. null !== t && (this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", t, n))) : (e === Bi.ColorKind && (e = Bi.ColorInstanceKind),
  114792. null === t ? (null === (a = this._userThinInstanceBuffersStorage) || void 0 === a ? void 0 : a.data[e]) && (this.removeVerticesData(e),
  114793. delete this._userThinInstanceBuffersStorage.data[e],
  114794. delete this._userThinInstanceBuffersStorage.strides[e],
  114795. delete this._userThinInstanceBuffersStorage.sizes[e],
  114796. delete this._userThinInstanceBuffersStorage.vertexBuffers[e]) : (this._thinInstanceInitializeUserStorage(),
  114797. this._userThinInstanceBuffersStorage.data[e] = t,
  114798. this._userThinInstanceBuffersStorage.strides[e] = i,
  114799. this._userThinInstanceBuffersStorage.sizes[e] = t.length,
  114800. this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),t,e,!n,!1,i,!0),
  114801. this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))
  114802. }
  114803. ,
  114804. Vr.prototype.thinInstanceBufferUpdated = function(e) {
  114805. var t, i, n;
  114806. "matrix" === e ? null === (t = this._thinInstanceDataStorage.matrixBuffer) || void 0 === t || t.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, this._thinInstanceDataStorage.instancesCount) : "previousMatrix" === e ? null === (i = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === i || i.updateDirectly(this._thinInstanceDataStorage.previousMatrixData, 0, this._thinInstanceDataStorage.instancesCount) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e], 0)
  114807. }
  114808. ,
  114809. Vr.prototype.thinInstancePartialBufferUpdate = function(e, t, i) {
  114810. var n;
  114811. "matrix" === e ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, i) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t, i)
  114812. }
  114813. ,
  114814. Vr.prototype.thinInstanceGetWorldMatrices = function() {
  114815. if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer)
  114816. return [];
  114817. var e = this._thinInstanceDataStorage.matrixData;
  114818. if (!this._thinInstanceDataStorage.worldMatrices) {
  114819. this._thinInstanceDataStorage.worldMatrices = new Array;
  114820. for (var t = 0; t < this._thinInstanceDataStorage.instancesCount; ++t)
  114821. this._thinInstanceDataStorage.worldMatrices[t] = P.FromArray(e, 16 * t)
  114822. }
  114823. return this._thinInstanceDataStorage.worldMatrices
  114824. }
  114825. ,
  114826. Vr.prototype.thinInstanceRefreshBoundingInfo = function(e, t, i) {
  114827. if (void 0 === e && (e = !1),
  114828. void 0 === t && (t = !1),
  114829. void 0 === i && (i = !1),
  114830. this._thinInstanceDataStorage.matrixData && this._thinInstanceDataStorage.matrixBuffer) {
  114831. var n = this._thinInstanceDataStorage.boundingVectors;
  114832. e && (n.length = 0,
  114833. this.refreshBoundingInfo(t, i));
  114834. var r = this.getBoundingInfo()
  114835. , o = this._thinInstanceDataStorage.matrixData;
  114836. if (0 === n.length)
  114837. for (var a = 0; a < r.boundingBox.vectors.length; ++a)
  114838. n.push(r.boundingBox.vectors[a].clone());
  114839. I.Vector3[0].setAll(Number.POSITIVE_INFINITY),
  114840. I.Vector3[1].setAll(Number.NEGATIVE_INFINITY);
  114841. for (var s = 0; s < this._thinInstanceDataStorage.instancesCount; ++s)
  114842. for (P.FromArrayToRef(o, 16 * s, I.Matrix[0]),
  114843. a = 0; a < n.length; ++a)
  114844. x.TransformCoordinatesToRef(n[a], I.Matrix[0], I.Vector3[2]),
  114845. I.Vector3[0].minimizeInPlace(I.Vector3[2]),
  114846. I.Vector3[1].maximizeInPlace(I.Vector3[2]);
  114847. r.reConstruct(I.Vector3[0], I.Vector3[1]),
  114848. this._updateBoundingInfo()
  114849. }
  114850. }
  114851. ,
  114852. Vr.prototype._thinInstanceUpdateBufferSize = function(e, t) {
  114853. var i, n, r;
  114854. void 0 === t && (t = 1);
  114855. var o = "matrix" === e;
  114856. if (o || this._userThinInstanceBuffersStorage && this._userThinInstanceBuffersStorage.strides[e]) {
  114857. for (var a = o ? 16 : this._userThinInstanceBuffersStorage.strides[e], s = o ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[e], l = o ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[e], c = (this._thinInstanceDataStorage.instancesCount + t) * a, u = s; u < c; )
  114858. u *= 2;
  114859. if (!l || s != u) {
  114860. if (l) {
  114861. var h = new Float32Array(u);
  114862. h.set(l, 0),
  114863. l = h
  114864. } else
  114865. l = new Float32Array(u);
  114866. o ? (null === (i = this._thinInstanceDataStorage.matrixBuffer) || void 0 === i || i.dispose(),
  114867. this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", l, !1),
  114868. this._thinInstanceDataStorage.matrixData = l,
  114869. this._thinInstanceDataStorage.matrixBufferSize = u,
  114870. this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && (null === (n = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === n || n.dispose(),
  114871. this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", l, !1))) : (null === (r = this._userThinInstanceBuffersStorage.vertexBuffers[e]) || void 0 === r || r.dispose(),
  114872. this._userThinInstanceBuffersStorage.data[e] = l,
  114873. this._userThinInstanceBuffersStorage.sizes[e] = u,
  114874. this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),l,e,!0,!1,a,!0),
  114875. this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))
  114876. }
  114877. }
  114878. }
  114879. ,
  114880. Vr.prototype._thinInstanceInitializeUserStorage = function() {
  114881. this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = {
  114882. data: {},
  114883. sizes: {},
  114884. vertexBuffers: {},
  114885. strides: {}
  114886. })
  114887. }
  114888. ,
  114889. Vr.prototype._disposeThinInstanceSpecificData = function() {
  114890. var e;
  114891. (null === (e = this._thinInstanceDataStorage) || void 0 === e ? void 0 : e.matrixBuffer) && (this._thinInstanceDataStorage.matrixBuffer.dispose(),
  114892. this._thinInstanceDataStorage.matrixBuffer = null)
  114893. }
  114894. ;
  114895. var ty = function() {
  114896. function e(e) {
  114897. void 0 === e && (e = Recast),
  114898. this.bjsRECAST = {},
  114899. this.name = "RecastJSPlugin",
  114900. this._maximumSubStepCount = 10,
  114901. this._timeStep = 1 / 60,
  114902. this._worker = null,
  114903. "function" == typeof e ? K.Error("RecastJS is not ready. Please make sure you await Recast() before using the plugin.") : this.bjsRECAST = e,
  114904. this.isSupported() ? (this.setTimeStep(),
  114905. this._tempVec1 = new this.bjsRECAST.Vec3,
  114906. this._tempVec2 = new this.bjsRECAST.Vec3) : K.Error("RecastJS is not available. Please make sure you included the js file.")
  114907. }
  114908. return e.prototype.setWorkerURL = function(e) {
  114909. return !(!window || !window.Worker || (this._worker = new Worker(e),
  114910. 0))
  114911. }
  114912. ,
  114913. e.prototype.setTimeStep = function(e) {
  114914. void 0 === e && (e = 1 / 60),
  114915. this._timeStep = e
  114916. }
  114917. ,
  114918. e.prototype.getTimeStep = function() {
  114919. return this._timeStep
  114920. }
  114921. ,
  114922. e.prototype.setMaximumSubStepCount = function(e) {
  114923. void 0 === e && (e = 10),
  114924. this._maximumSubStepCount = e
  114925. }
  114926. ,
  114927. e.prototype.getMaximumSubStepCount = function() {
  114928. return this._maximumSubStepCount
  114929. }
  114930. ,
  114931. e.prototype.createNavMesh = function(e, t, i) {
  114932. var n, r, o;
  114933. this._worker && !i ? console.warn("A worker is avaible but no completion callback. Defaulting to blocking navmesh creation") : !this._worker && i && console.warn("A completion callback is avaible but no worker. Defaulting to blocking navmesh creation"),
  114934. this.navMesh = new this.bjsRECAST.NavMesh;
  114935. var a = []
  114936. , s = []
  114937. , l = 0;
  114938. for (n = 0; n < e.length; n++)
  114939. if (e[n]) {
  114940. var c = e[n]
  114941. , u = c.getIndices();
  114942. if (!u)
  114943. continue;
  114944. var h = c.getVerticesData(Bi.PositionKind, !1, !1);
  114945. if (!h)
  114946. continue;
  114947. var d = []
  114948. , p = c.computeWorldMatrix(!0);
  114949. if (c.hasThinInstances)
  114950. for (var f = c.thinInstanceGetWorldMatrices(), _ = 0; _ < f.length; _++) {
  114951. var m = new P;
  114952. f[_].multiplyToRef(p, m),
  114953. d.push(m)
  114954. }
  114955. else
  114956. d.push(p);
  114957. for (var g = 0; g < d.length; g++) {
  114958. var v = d[g];
  114959. for (r = 0; r < u.length; r++)
  114960. a.push(u[r] + l);
  114961. var y = x.Zero()
  114962. , b = x.Zero();
  114963. for (o = 0; o < h.length; o += 3)
  114964. x.FromArrayToRef(h, o, b),
  114965. x.TransformCoordinatesToRef(b, v, y),
  114966. s.push(y.x, y.y, y.z);
  114967. l += h.length / 3
  114968. }
  114969. }
  114970. if (this._worker && i)
  114971. this._worker.postMessage([s, l, a, a.length, t]),
  114972. this._worker.onmessage = function(e) {
  114973. i(e.data)
  114974. }
  114975. ;
  114976. else {
  114977. var T = new this.bjsRECAST.rcConfig;
  114978. T.cs = t.cs,
  114979. T.ch = t.ch,
  114980. T.borderSize = t.borderSize ? t.borderSize : 0,
  114981. T.tileSize = t.tileSize ? t.tileSize : 0,
  114982. T.walkableSlopeAngle = t.walkableSlopeAngle,
  114983. T.walkableHeight = t.walkableHeight,
  114984. T.walkableClimb = t.walkableClimb,
  114985. T.walkableRadius = t.walkableRadius,
  114986. T.maxEdgeLen = t.maxEdgeLen,
  114987. T.maxSimplificationError = t.maxSimplificationError,
  114988. T.minRegionArea = t.minRegionArea,
  114989. T.mergeRegionArea = t.mergeRegionArea,
  114990. T.maxVertsPerPoly = t.maxVertsPerPoly,
  114991. T.detailSampleDist = t.detailSampleDist,
  114992. T.detailSampleMaxError = t.detailSampleMaxError,
  114993. this.navMesh.build(s, l, a, a.length, T)
  114994. }
  114995. }
  114996. ,
  114997. e.prototype.createDebugNavMesh = function(e) {
  114998. var t, i, n = this.navMesh.getDebugNavMesh(), r = n.getTriangleCount(), o = [], a = [];
  114999. for (t = 0; t < 3 * r; t++)
  115000. o.push(t);
  115001. for (t = 0; t < r; t++)
  115002. for (i = 0; i < 3; i++) {
  115003. var s = n.getTriangle(t).getPoint(i);
  115004. a.push(s.x, s.y, s.z)
  115005. }
  115006. var l = new Vr("NavMeshDebug",e)
  115007. , c = new $n;
  115008. return c.indices = o,
  115009. c.positions = a,
  115010. c.applyToMesh(l, !1),
  115011. l
  115012. }
  115013. ,
  115014. e.prototype.getClosestPoint = function(e) {
  115015. this._tempVec1.x = e.x,
  115016. this._tempVec1.y = e.y,
  115017. this._tempVec1.z = e.z;
  115018. var t = this.navMesh.getClosestPoint(this._tempVec1);
  115019. return new x(t.x,t.y,t.z)
  115020. }
  115021. ,
  115022. e.prototype.getClosestPointToRef = function(e, t) {
  115023. this._tempVec1.x = e.x,
  115024. this._tempVec1.y = e.y,
  115025. this._tempVec1.z = e.z;
  115026. var i = this.navMesh.getClosestPoint(this._tempVec1);
  115027. t.set(i.x, i.y, i.z)
  115028. }
  115029. ,
  115030. e.prototype.getRandomPointAround = function(e, t) {
  115031. this._tempVec1.x = e.x,
  115032. this._tempVec1.y = e.y,
  115033. this._tempVec1.z = e.z;
  115034. var i = this.navMesh.getRandomPointAround(this._tempVec1, t);
  115035. return new x(i.x,i.y,i.z)
  115036. }
  115037. ,
  115038. e.prototype.getRandomPointAroundToRef = function(e, t, i) {
  115039. this._tempVec1.x = e.x,
  115040. this._tempVec1.y = e.y,
  115041. this._tempVec1.z = e.z;
  115042. var n = this.navMesh.getRandomPointAround(this._tempVec1, t);
  115043. i.set(n.x, n.y, n.z)
  115044. }
  115045. ,
  115046. e.prototype.moveAlong = function(e, t) {
  115047. this._tempVec1.x = e.x,
  115048. this._tempVec1.y = e.y,
  115049. this._tempVec1.z = e.z,
  115050. this._tempVec2.x = t.x,
  115051. this._tempVec2.y = t.y,
  115052. this._tempVec2.z = t.z;
  115053. var i = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
  115054. return new x(i.x,i.y,i.z)
  115055. }
  115056. ,
  115057. e.prototype.moveAlongToRef = function(e, t, i) {
  115058. this._tempVec1.x = e.x,
  115059. this._tempVec1.y = e.y,
  115060. this._tempVec1.z = e.z,
  115061. this._tempVec2.x = t.x,
  115062. this._tempVec2.y = t.y,
  115063. this._tempVec2.z = t.z;
  115064. var n = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
  115065. i.set(n.x, n.y, n.z)
  115066. }
  115067. ,
  115068. e.prototype.computePath = function(e, t) {
  115069. var i;
  115070. this._tempVec1.x = e.x,
  115071. this._tempVec1.y = e.y,
  115072. this._tempVec1.z = e.z,
  115073. this._tempVec2.x = t.x,
  115074. this._tempVec2.y = t.y,
  115075. this._tempVec2.z = t.z;
  115076. var n = this.navMesh.computePath(this._tempVec1, this._tempVec2)
  115077. , r = n.getPointCount()
  115078. , o = [];
  115079. for (i = 0; i < r; i++) {
  115080. var a = n.getPoint(i);
  115081. o.push(new x(a.x,a.y,a.z))
  115082. }
  115083. return o
  115084. }
  115085. ,
  115086. e.prototype.createCrowd = function(e, t, i) {
  115087. return new iy(this,e,t,i)
  115088. }
  115089. ,
  115090. e.prototype.setDefaultQueryExtent = function(e) {
  115091. this._tempVec1.x = e.x,
  115092. this._tempVec1.y = e.y,
  115093. this._tempVec1.z = e.z,
  115094. this.navMesh.setDefaultQueryExtent(this._tempVec1)
  115095. }
  115096. ,
  115097. e.prototype.getDefaultQueryExtent = function() {
  115098. var e = this.navMesh.getDefaultQueryExtent();
  115099. return new x(e.x,e.y,e.z)
  115100. }
  115101. ,
  115102. e.prototype.buildFromNavmeshData = function(e) {
  115103. var t = e.length * e.BYTES_PER_ELEMENT
  115104. , i = this.bjsRECAST._malloc(t)
  115105. , n = new Uint8Array(this.bjsRECAST.HEAPU8.buffer,i,t);
  115106. n.set(e);
  115107. var r = new this.bjsRECAST.NavmeshData;
  115108. r.dataPointer = n.byteOffset,
  115109. r.size = e.length,
  115110. this.navMesh = new this.bjsRECAST.NavMesh,
  115111. this.navMesh.buildFromNavmeshData(r),
  115112. this.bjsRECAST._free(n.byteOffset)
  115113. }
  115114. ,
  115115. e.prototype.getNavmeshData = function() {
  115116. var e = this.navMesh.getNavmeshData()
  115117. , t = new Uint8Array(this.bjsRECAST.HEAPU8.buffer,e.dataPointer,e.size)
  115118. , i = new Uint8Array(e.size);
  115119. return i.set(t),
  115120. this.navMesh.freeNavmeshData(e),
  115121. i
  115122. }
  115123. ,
  115124. e.prototype.getDefaultQueryExtentToRef = function(e) {
  115125. var t = this.navMesh.getDefaultQueryExtent();
  115126. e.set(t.x, t.y, t.z)
  115127. }
  115128. ,
  115129. e.prototype.dispose = function() {}
  115130. ,
  115131. e.prototype.addCylinderObstacle = function(e, t, i) {
  115132. return this._tempVec1.x = e.x,
  115133. this._tempVec1.y = e.y,
  115134. this._tempVec1.z = e.z,
  115135. this.navMesh.addCylinderObstacle(this._tempVec1, t, i)
  115136. }
  115137. ,
  115138. e.prototype.addBoxObstacle = function(e, t, i) {
  115139. return this._tempVec1.x = e.x,
  115140. this._tempVec1.y = e.y,
  115141. this._tempVec1.z = e.z,
  115142. this._tempVec2.x = t.x,
  115143. this._tempVec2.y = t.y,
  115144. this._tempVec2.z = t.z,
  115145. this.navMesh.addBoxObstacle(this._tempVec1, this._tempVec2, i)
  115146. }
  115147. ,
  115148. e.prototype.removeObstacle = function(e) {
  115149. this.navMesh.removeObstacle(e)
  115150. }
  115151. ,
  115152. e.prototype.isSupported = function() {
  115153. return void 0 !== this.bjsRECAST
  115154. }
  115155. ,
  115156. e
  115157. }()
  115158. , iy = function() {
  115159. function e(e, t, i, n) {
  115160. var r = this;
  115161. this.recastCrowd = {},
  115162. this.transforms = new Array,
  115163. this.agents = new Array,
  115164. this.reachRadii = new Array,
  115165. this._agentDestinationArmed = new Array,
  115166. this._agentDestination = new Array,
  115167. this._onBeforeAnimationsObserver = null,
  115168. this.onReachTargetObservable = new h,
  115169. this.bjsRECASTPlugin = e,
  115170. this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(t,i,this.bjsRECASTPlugin.navMesh.getNavMesh()),
  115171. this._scene = n,
  115172. this._onBeforeAnimationsObserver = n.onBeforeAnimationsObservable.add((function() {
  115173. r.update(.001 * n.getEngine().getDeltaTime())
  115174. }
  115175. ))
  115176. }
  115177. return e.prototype.addAgent = function(e, t, i) {
  115178. var n = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams;
  115179. n.radius = t.radius,
  115180. n.height = t.height,
  115181. n.maxAcceleration = t.maxAcceleration,
  115182. n.maxSpeed = t.maxSpeed,
  115183. n.collisionQueryRange = t.collisionQueryRange,
  115184. n.pathOptimizationRange = t.pathOptimizationRange,
  115185. n.separationWeight = t.separationWeight,
  115186. n.updateFlags = 7,
  115187. n.obstacleAvoidanceType = 0,
  115188. n.queryFilterType = 0,
  115189. n.userData = 0;
  115190. var r = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z), n);
  115191. return this.transforms.push(i),
  115192. this.agents.push(r),
  115193. this.reachRadii.push(t.reachRadius ? t.reachRadius : t.radius),
  115194. this._agentDestinationArmed.push(!1),
  115195. this._agentDestination.push(new x(0,0,0)),
  115196. r
  115197. }
  115198. ,
  115199. e.prototype.getAgentPosition = function(e) {
  115200. var t = this.recastCrowd.getAgentPosition(e);
  115201. return new x(t.x,t.y,t.z)
  115202. }
  115203. ,
  115204. e.prototype.getAgentPositionToRef = function(e, t) {
  115205. var i = this.recastCrowd.getAgentPosition(e);
  115206. t.set(i.x, i.y, i.z)
  115207. }
  115208. ,
  115209. e.prototype.getAgentVelocity = function(e) {
  115210. var t = this.recastCrowd.getAgentVelocity(e);
  115211. return new x(t.x,t.y,t.z)
  115212. }
  115213. ,
  115214. e.prototype.getAgentVelocityToRef = function(e, t) {
  115215. var i = this.recastCrowd.getAgentVelocity(e);
  115216. t.set(i.x, i.y, i.z)
  115217. }
  115218. ,
  115219. e.prototype.getAgentNextTargetPath = function(e) {
  115220. var t = this.recastCrowd.getAgentNextTargetPath(e);
  115221. return new x(t.x,t.y,t.z)
  115222. }
  115223. ,
  115224. e.prototype.getAgentNextTargetPathToRef = function(e, t) {
  115225. var i = this.recastCrowd.getAgentNextTargetPath(e);
  115226. t.set(i.x, i.y, i.z)
  115227. }
  115228. ,
  115229. e.prototype.getAgentState = function(e) {
  115230. return this.recastCrowd.getAgentState(e)
  115231. }
  115232. ,
  115233. e.prototype.overOffmeshConnection = function(e) {
  115234. return this.recastCrowd.overOffmeshConnection(e)
  115235. }
  115236. ,
  115237. e.prototype.agentGoto = function(e, t) {
  115238. this.recastCrowd.agentGoto(e, new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z));
  115239. var i = this.agents.indexOf(e);
  115240. i > -1 && (this._agentDestinationArmed[i] = !0,
  115241. this._agentDestination[i].set(t.x, t.y, t.z))
  115242. }
  115243. ,
  115244. e.prototype.agentTeleport = function(e, t) {
  115245. this.recastCrowd.agentTeleport(e, new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z))
  115246. }
  115247. ,
  115248. e.prototype.updateAgentParameters = function(e, t) {
  115249. var i = this.recastCrowd.getAgentParameters(e);
  115250. void 0 !== t.radius && (i.radius = t.radius),
  115251. void 0 !== t.height && (i.height = t.height),
  115252. void 0 !== t.maxAcceleration && (i.maxAcceleration = t.maxAcceleration),
  115253. void 0 !== t.maxSpeed && (i.maxSpeed = t.maxSpeed),
  115254. void 0 !== t.collisionQueryRange && (i.collisionQueryRange = t.collisionQueryRange),
  115255. void 0 !== t.pathOptimizationRange && (i.pathOptimizationRange = t.pathOptimizationRange),
  115256. void 0 !== t.separationWeight && (i.separationWeight = t.separationWeight),
  115257. this.recastCrowd.setAgentParameters(e, i)
  115258. }
  115259. ,
  115260. e.prototype.removeAgent = function(e) {
  115261. this.recastCrowd.removeAgent(e);
  115262. var t = this.agents.indexOf(e);
  115263. t > -1 && (this.agents.splice(t, 1),
  115264. this.transforms.splice(t, 1),
  115265. this.reachRadii.splice(t, 1),
  115266. this._agentDestinationArmed.splice(t, 1),
  115267. this._agentDestination.splice(t, 1))
  115268. }
  115269. ,
  115270. e.prototype.getAgents = function() {
  115271. return this.agents
  115272. }
  115273. ,
  115274. e.prototype.update = function(e) {
  115275. this.bjsRECASTPlugin.navMesh.update();
  115276. var t = this.bjsRECASTPlugin.getTimeStep()
  115277. , i = this.bjsRECASTPlugin.getMaximumSubStepCount();
  115278. if (t <= m)
  115279. this.recastCrowd.update(e);
  115280. else {
  115281. var n = Math.floor(e / t);
  115282. i && n > i && (n = i),
  115283. n < 1 && (n = 1);
  115284. for (var r = e / n, o = 0; o < n; o++)
  115285. this.recastCrowd.update(r)
  115286. }
  115287. for (var a = 0; a < this.agents.length; a++) {
  115288. var s = this.agents[a]
  115289. , l = this.getAgentPosition(s);
  115290. if (this.transforms[a].position = l,
  115291. this._agentDestinationArmed[a]) {
  115292. var c = l.x - this._agentDestination[a].x
  115293. , u = l.z - this._agentDestination[a].z
  115294. , h = this.reachRadii[a]
  115295. , d = this._agentDestination[a].y - this.reachRadii[a]
  115296. , p = this._agentDestination[a].y + this.reachRadii[a]
  115297. , f = c * c + u * u;
  115298. l.y > d && l.y < p && f < h * h && (this.onReachTargetObservable.notifyObservers({
  115299. agentIndex: s,
  115300. destination: this._agentDestination[a]
  115301. }),
  115302. this._agentDestinationArmed[a] = !1)
  115303. }
  115304. }
  115305. }
  115306. ,
  115307. e.prototype.setDefaultQueryExtent = function(e) {
  115308. var t = new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z);
  115309. this.recastCrowd.setDefaultQueryExtent(t)
  115310. }
  115311. ,
  115312. e.prototype.getDefaultQueryExtent = function() {
  115313. var e = this.recastCrowd.getDefaultQueryExtent();
  115314. return new x(e.x,e.y,e.z)
  115315. }
  115316. ,
  115317. e.prototype.getDefaultQueryExtentToRef = function(e) {
  115318. var t = this.recastCrowd.getDefaultQueryExtent();
  115319. e.set(t.x, t.y, t.z)
  115320. }
  115321. ,
  115322. e.prototype.getCorners = function(e) {
  115323. var t, i = this.recastCrowd.getPath(e), n = i.getPointCount(), r = [];
  115324. for (t = 0; t < n; t++) {
  115325. var o = i.getPoint(t);
  115326. r.push(new x(o.x,o.y,o.z))
  115327. }
  115328. return r
  115329. }
  115330. ,
  115331. e.prototype.dispose = function() {
  115332. this.recastCrowd.destroy(),
  115333. this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
  115334. this._onBeforeAnimationsObserver = null,
  115335. this.onReachTargetObservable.clear()
  115336. }
  115337. ,
  115338. e
  115339. }();
  115340. vr.OfflineProviderFactory = function(e, t, i) {
  115341. return void 0 === i && (i = !1),
  115342. new ny(e,t,i)
  115343. }
  115344. ;
  115345. var ny = function() {
  115346. function e(t, i, n) {
  115347. void 0 === n && (n = !1),
  115348. this._idbFactory = "undefined" != typeof window ? window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB : indexedDB,
  115349. this._currentSceneUrl = e._ReturnFullUrlLocation(t),
  115350. this._db = null,
  115351. this._enableSceneOffline = !1,
  115352. this._enableTexturesOffline = !1,
  115353. this._manifestVersionFound = 0,
  115354. this._mustUpdateRessources = !1,
  115355. this._hasReachedQuota = !1,
  115356. e.IDBStorageEnabled ? n ? (this._enableSceneOffline = !0,
  115357. this._enableTexturesOffline = !0,
  115358. this._manifestVersionFound = 1,
  115359. gi.SetImmediate((function() {
  115360. i(!0)
  115361. }
  115362. ))) : this._checkManifestFile(i) : i(!0)
  115363. }
  115364. return Object.defineProperty(e.prototype, "enableSceneOffline", {
  115365. get: function() {
  115366. return this._enableSceneOffline
  115367. },
  115368. enumerable: !1,
  115369. configurable: !0
  115370. }),
  115371. Object.defineProperty(e.prototype, "enableTexturesOffline", {
  115372. get: function() {
  115373. return this._enableTexturesOffline
  115374. },
  115375. enumerable: !1,
  115376. configurable: !0
  115377. }),
  115378. e.prototype._checkManifestFile = function(t) {
  115379. var i = this
  115380. , n = function() {
  115381. i._enableSceneOffline = !1,
  115382. i._enableTexturesOffline = !1,
  115383. t(!1)
  115384. }
  115385. , r = function() {
  115386. try {
  115387. if ("function" == typeof URL && 0 === i._currentSceneUrl.indexOf("http")) {
  115388. var e = new URL(i._currentSceneUrl);
  115389. return e.pathname += ".manifest",
  115390. e.toString()
  115391. }
  115392. } catch (e) {}
  115393. return "".concat(i._currentSceneUrl, ".manifest")
  115394. }
  115395. , o = !1
  115396. , a = r()
  115397. , s = new Ye;
  115398. navigator.onLine && (o = !0,
  115399. a = a + (null == a.match(/\?/) ? "?" : "&") + Date.now()),
  115400. s.open("GET", a),
  115401. s.addEventListener("load", (function() {
  115402. if (200 === s.status || e._ValidateXHRData(s, 1))
  115403. try {
  115404. var r = JSON.parse(s.response);
  115405. i._enableSceneOffline = r.enableSceneOffline,
  115406. i._enableTexturesOffline = r.enableTexturesOffline && e._IsUASupportingBlobStorage,
  115407. r.version && !isNaN(parseInt(r.version)) && (i._manifestVersionFound = r.version),
  115408. t(!0)
  115409. } catch (e) {
  115410. n()
  115411. }
  115412. else
  115413. n()
  115414. }
  115415. ), !1),
  115416. s.addEventListener("error", (function() {
  115417. if (o) {
  115418. o = !1;
  115419. var e = r();
  115420. s.open("GET", e),
  115421. s.send()
  115422. } else
  115423. n()
  115424. }
  115425. ), !1);
  115426. try {
  115427. s.send()
  115428. } catch (e) {
  115429. K.Error("Error on XHR send request."),
  115430. t(!1)
  115431. }
  115432. }
  115433. ,
  115434. e.prototype.open = function(e, t) {
  115435. var i = this
  115436. , n = function() {
  115437. i._isSupported = !1,
  115438. t && t()
  115439. };
  115440. if (this._idbFactory && (this._enableSceneOffline || this._enableTexturesOffline))
  115441. if (this._db)
  115442. e && e();
  115443. else {
  115444. this._hasReachedQuota = !1,
  115445. this._isSupported = !0;
  115446. var r = this._idbFactory.open("babylonjs", 1);
  115447. r.onerror = function() {
  115448. n()
  115449. }
  115450. ,
  115451. r.onblocked = function() {
  115452. K.Error("IDB request blocked. Please reload the page."),
  115453. n()
  115454. }
  115455. ,
  115456. r.onsuccess = function() {
  115457. i._db = r.result,
  115458. e()
  115459. }
  115460. ,
  115461. r.onupgradeneeded = function(e) {
  115462. if (i._db = e.target.result,
  115463. i._db)
  115464. try {
  115465. i._db.createObjectStore("scenes", {
  115466. keyPath: "sceneUrl"
  115467. }),
  115468. i._db.createObjectStore("versions", {
  115469. keyPath: "sceneUrl"
  115470. }),
  115471. i._db.createObjectStore("textures", {
  115472. keyPath: "textureUrl"
  115473. })
  115474. } catch (e) {
  115475. K.Error("Error while creating object stores. Exception: " + e.message),
  115476. n()
  115477. }
  115478. }
  115479. }
  115480. else
  115481. this._isSupported = !1,
  115482. t && t()
  115483. }
  115484. ,
  115485. e.prototype.loadImage = function(t, i) {
  115486. var n = this
  115487. , r = e._ReturnFullUrlLocation(t)
  115488. , o = function() {
  115489. n._hasReachedQuota || null === n._db ? i.src = t : n._saveImageIntoDBAsync(r, i)
  115490. };
  115491. this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(r, i, o)
  115492. }
  115493. ,
  115494. e.prototype._loadImageFromDBAsync = function(e, t, i) {
  115495. if (this._isSupported && null !== this._db) {
  115496. var n, r = this._db.transaction(["textures"]);
  115497. r.onabort = function() {
  115498. t.src = e
  115499. }
  115500. ,
  115501. r.oncomplete = function() {
  115502. var r;
  115503. if (n) {
  115504. var o = window.URL || window.webkitURL;
  115505. r = o.createObjectURL(n.data),
  115506. t.onerror = function() {
  115507. K.Error("Error loading image from blob URL: " + r + " switching back to web url: " + e),
  115508. t.src = e
  115509. }
  115510. ,
  115511. t.src = r
  115512. } else
  115513. i()
  115514. }
  115515. ;
  115516. var o = r.objectStore("textures").get(e);
  115517. o.onsuccess = function(e) {
  115518. n = e.target.result
  115519. }
  115520. ,
  115521. o.onerror = function() {
  115522. K.Error("Error loading texture " + e + " from DB."),
  115523. t.src = e
  115524. }
  115525. } else
  115526. K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
  115527. t.src = e
  115528. }
  115529. ,
  115530. e.prototype._saveImageIntoDBAsync = function(t, i) {
  115531. var n, r = this;
  115532. if (this._isSupported) {
  115533. var o = function() {
  115534. var e;
  115535. if (n) {
  115536. var t = window.URL || window.webkitURL;
  115537. try {
  115538. e = t.createObjectURL(n)
  115539. } catch (i) {
  115540. e = t.createObjectURL(n)
  115541. }
  115542. }
  115543. e && (i.src = e)
  115544. };
  115545. if (e._IsUASupportingBlobStorage) {
  115546. var a = new Ye;
  115547. a.open("GET", t),
  115548. a.responseType = "blob",
  115549. a.addEventListener("load", (function() {
  115550. if (200 === a.status && r._db) {
  115551. n = a.response;
  115552. var s = r._db.transaction(["textures"], "readwrite");
  115553. s.onabort = function(e) {
  115554. try {
  115555. var t = (e.srcElement || e.target).error;
  115556. t && "QuotaExceededError" === t.name && (r._hasReachedQuota = !0)
  115557. } catch (e) {}
  115558. o()
  115559. }
  115560. ,
  115561. s.oncomplete = function() {
  115562. o()
  115563. }
  115564. ;
  115565. var l = {
  115566. textureUrl: t,
  115567. data: n
  115568. };
  115569. try {
  115570. var c = s.objectStore("textures").put(l);
  115571. c.onsuccess = function() {}
  115572. ,
  115573. c.onerror = function() {
  115574. o()
  115575. }
  115576. } catch (n) {
  115577. 25 === n.code && (e._IsUASupportingBlobStorage = !1,
  115578. r._enableTexturesOffline = !1),
  115579. i.src = t
  115580. }
  115581. } else
  115582. i.src = t
  115583. }
  115584. ), !1),
  115585. a.addEventListener("error", (function() {
  115586. K.Error("Error in XHR request in BABYLON.Database."),
  115587. i.src = t
  115588. }
  115589. ), !1),
  115590. a.send()
  115591. } else
  115592. i.src = t
  115593. } else
  115594. K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
  115595. i.src = t
  115596. }
  115597. ,
  115598. e.prototype._checkVersionFromDB = function(e, t) {
  115599. var i = this;
  115600. this._loadVersionFromDBAsync(e, t, (function() {
  115601. i._saveVersionIntoDBAsync(e, t)
  115602. }
  115603. ))
  115604. }
  115605. ,
  115606. e.prototype._loadVersionFromDBAsync = function(e, t, i) {
  115607. var n, r = this;
  115608. if (this._isSupported && this._db)
  115609. try {
  115610. var o = this._db.transaction(["versions"]);
  115611. o.oncomplete = function() {
  115612. n ? r._manifestVersionFound !== n.data ? (r._mustUpdateRessources = !0,
  115613. i()) : t(n.data) : (r._mustUpdateRessources = !0,
  115614. i())
  115615. }
  115616. ,
  115617. o.onabort = function() {
  115618. t(-1)
  115619. }
  115620. ;
  115621. var a = o.objectStore("versions").get(e);
  115622. a.onsuccess = function(e) {
  115623. n = e.target.result
  115624. }
  115625. ,
  115626. a.onerror = function() {
  115627. K.Error("Error loading version for scene " + e + " from DB."),
  115628. t(-1)
  115629. }
  115630. } catch (e) {
  115631. K.Error("Error while accessing 'versions' object store (READ OP). Exception: " + e.message),
  115632. t(-1)
  115633. }
  115634. else
  115635. K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
  115636. t(-1)
  115637. }
  115638. ,
  115639. e.prototype._saveVersionIntoDBAsync = function(e, t) {
  115640. var i = this;
  115641. if (this._isSupported && !this._hasReachedQuota && this._db)
  115642. try {
  115643. var n = this._db.transaction(["versions"], "readwrite");
  115644. n.onabort = function(e) {
  115645. try {
  115646. var n = e.srcElement.error;
  115647. n && "QuotaExceededError" === n.name && (i._hasReachedQuota = !0)
  115648. } catch (e) {}
  115649. t(-1)
  115650. }
  115651. ,
  115652. n.oncomplete = function() {
  115653. t(i._manifestVersionFound)
  115654. }
  115655. ;
  115656. var r = {
  115657. sceneUrl: e,
  115658. data: this._manifestVersionFound
  115659. }
  115660. , o = n.objectStore("versions").put(r);
  115661. o.onsuccess = function() {}
  115662. ,
  115663. o.onerror = function() {
  115664. K.Error("Error in DB add version request in BABYLON.Database.")
  115665. }
  115666. } catch (e) {
  115667. K.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + e.message),
  115668. t(-1)
  115669. }
  115670. else
  115671. t(-1)
  115672. }
  115673. ,
  115674. e.prototype.loadFile = function(t, i, n, r, o) {
  115675. var a = this
  115676. , s = e._ReturnFullUrlLocation(t)
  115677. , l = function() {
  115678. a._saveFileAsync(s, i, n, o, r)
  115679. };
  115680. this._checkVersionFromDB(s, (function(e) {
  115681. -1 !== e ? a._mustUpdateRessources ? a._saveFileAsync(s, i, n, o, r) : a._loadFileAsync(s, i, l) : r && r()
  115682. }
  115683. ))
  115684. }
  115685. ,
  115686. e.prototype._loadFileAsync = function(e, t, i) {
  115687. if (this._isSupported && this._db) {
  115688. var n, r;
  115689. r = -1 !== e.indexOf(".babylon") ? "scenes" : "textures";
  115690. var o = this._db.transaction([r]);
  115691. o.oncomplete = function() {
  115692. n ? t(n.data) : i()
  115693. }
  115694. ,
  115695. o.onabort = function() {
  115696. i()
  115697. }
  115698. ;
  115699. var a = o.objectStore(r).get(e);
  115700. a.onsuccess = function(e) {
  115701. n = e.target.result
  115702. }
  115703. ,
  115704. a.onerror = function() {
  115705. K.Error("Error loading file " + e + " from DB."),
  115706. i()
  115707. }
  115708. } else
  115709. K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
  115710. t()
  115711. }
  115712. ,
  115713. e.prototype._saveFileAsync = function(t, i, n, r, o) {
  115714. var a = this;
  115715. if (this._isSupported) {
  115716. var s;
  115717. s = -1 !== t.indexOf(".babylon") ? "scenes" : "textures";
  115718. var l, c = new Ye;
  115719. c.open("GET", t + (null == t.match(/\?/) ? "?" : "&") + Date.now()),
  115720. r && (c.responseType = "arraybuffer"),
  115721. n && (c.onprogress = n),
  115722. c.addEventListener("load", (function() {
  115723. if (200 === c.status || c.status < 400 && e._ValidateXHRData(c, r ? 6 : 1))
  115724. if (l = r ? c.response : c.responseText,
  115725. !a._hasReachedQuota && a._db) {
  115726. var n = a._db.transaction([s], "readwrite");
  115727. n.onabort = function(e) {
  115728. try {
  115729. var t = e.srcElement.error;
  115730. t && "QuotaExceededError" === t.name && (a._hasReachedQuota = !0)
  115731. } catch (e) {}
  115732. i(l)
  115733. }
  115734. ,
  115735. n.oncomplete = function() {
  115736. i(l)
  115737. }
  115738. ;
  115739. var u;
  115740. u = "scenes" === s ? {
  115741. sceneUrl: t,
  115742. data: l,
  115743. version: a._manifestVersionFound
  115744. } : {
  115745. textureUrl: t,
  115746. data: l
  115747. };
  115748. try {
  115749. var h = n.objectStore(s).put(u);
  115750. h.onsuccess = function() {}
  115751. ,
  115752. h.onerror = function() {
  115753. K.Error("Error in DB add file request in BABYLON.Database.")
  115754. }
  115755. } catch (e) {
  115756. i(l)
  115757. }
  115758. } else
  115759. i(l);
  115760. else
  115761. c.status >= 400 && o ? o(c) : i()
  115762. }
  115763. ), !1),
  115764. c.addEventListener("error", (function() {
  115765. K.Error("error on XHR request."),
  115766. i()
  115767. }
  115768. ), !1),
  115769. c.send()
  115770. } else
  115771. K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
  115772. i()
  115773. }
  115774. ,
  115775. e._ValidateXHRData = function(e, t) {
  115776. void 0 === t && (t = 7);
  115777. try {
  115778. if (1 & t) {
  115779. if (e.responseText && e.responseText.length > 0)
  115780. return !0;
  115781. if (1 === t)
  115782. return !1
  115783. }
  115784. if (2 & t) {
  115785. var i = q_(e.response);
  115786. if (i.width && i.height && i.width > 0 && i.height > 0)
  115787. return !0;
  115788. if (2 === t)
  115789. return !1
  115790. }
  115791. if (4 & t) {
  115792. var n = new Uint8Array(e.response,0,3);
  115793. return 68 === n[0] && 68 === n[1] && 83 === n[2]
  115794. }
  115795. } catch (e) {}
  115796. return !1
  115797. }
  115798. ,
  115799. e._IsUASupportingBlobStorage = !0,
  115800. e.IDBStorageEnabled = !1,
  115801. e._ParseURL = function(e) {
  115802. document.createElement("a").href = e;
  115803. var t = e.substring(0, e.lastIndexOf("#"))
  115804. , i = e.substring(t.lastIndexOf("/") + 1, e.length);
  115805. return e.substring(0, e.indexOf(i, 0))
  115806. }
  115807. ,
  115808. e._ReturnFullUrlLocation = function(t) {
  115809. return -1 === t.indexOf("http:/") && -1 === t.indexOf("https:/") && "undefined" != typeof window ? e._ParseURL(window.location.href) + t : t
  115810. }
  115811. ,
  115812. e
  115813. }()
  115814. , ry = function() {
  115815. function e(e) {
  115816. this._isUbo(e) ? (this.setMatrix3x3 = e.updateMatrix3x3.bind(e),
  115817. this.setMatrix2x2 = e.updateMatrix2x2.bind(e),
  115818. this.setFloat = e.updateFloat.bind(e),
  115819. this.setFloat2 = e.updateFloat2.bind(e),
  115820. this.setFloat3 = e.updateFloat3.bind(e),
  115821. this.setFloat4 = e.updateFloat4.bind(e),
  115822. this.setFloatArray = e.updateFloatArray.bind(e),
  115823. this.setArray = e.updateArray.bind(e),
  115824. this.setIntArray = e.updateIntArray.bind(e),
  115825. this.setMatrix = e.updateMatrix.bind(e),
  115826. this.setMatrices = e.updateMatrices.bind(e),
  115827. this.setVector3 = e.updateVector3.bind(e),
  115828. this.setVector4 = e.updateVector4.bind(e),
  115829. this.setColor3 = e.updateColor3.bind(e),
  115830. this.setColor4 = e.updateColor4.bind(e),
  115831. this.setDirectColor4 = e.updateDirectColor4.bind(e),
  115832. this.setInt = e.updateInt.bind(e),
  115833. this.setInt2 = e.updateInt2.bind(e),
  115834. this.setInt3 = e.updateInt3.bind(e),
  115835. this.setInt4 = e.updateInt4.bind(e)) : (this.setMatrix3x3 = e.setMatrix3x3.bind(e),
  115836. this.setMatrix2x2 = e.setMatrix2x2.bind(e),
  115837. this.setFloat = e.setFloat.bind(e),
  115838. this.setFloat2 = e.setFloat2.bind(e),
  115839. this.setFloat3 = e.setFloat3.bind(e),
  115840. this.setFloat4 = e.setFloat4.bind(e),
  115841. this.setFloatArray = e.setFloatArray.bind(e),
  115842. this.setArray = e.setArray.bind(e),
  115843. this.setIntArray = e.setIntArray.bind(e),
  115844. this.setMatrix = e.setMatrix.bind(e),
  115845. this.setMatrices = e.setMatrices.bind(e),
  115846. this.setVector3 = e.setVector3.bind(e),
  115847. this.setVector4 = e.setVector4.bind(e),
  115848. this.setColor3 = e.setColor3.bind(e),
  115849. this.setColor4 = e.setColor4.bind(e),
  115850. this.setDirectColor4 = e.setDirectColor4.bind(e),
  115851. this.setInt = e.setInt.bind(e),
  115852. this.setInt2 = e.setInt2.bind(e),
  115853. this.setInt3 = e.setInt3.bind(e),
  115854. this.setInt4 = e.setInt4.bind(e))
  115855. }
  115856. return e.prototype._isUbo = function(e) {
  115857. return void 0 !== e.addUniform
  115858. }
  115859. ,
  115860. e
  115861. }();
  115862. Pt.ShadersStore.gpuUpdateParticlesPixelShader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  115863. Pt.ShadersStore.gpuUpdateParticlesVertexShader = "#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta; \nif (newAge>=life && stopFactor != 0.) {\nvec3 newPosition;\nvec3 newDirection;\nvec4 randoms=getRandomVec4(seed.x);\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=newAge-life;\noutSeed=seed;\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=vec3(0,0,0);\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\nnewDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\nnewDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(direction1+(direction2-direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nnewPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;\nnewDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;\nh=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h *height.x;\nnewPosition=vec3(randX,randY,randZ); \nif (abs(cos(coneAngle))==1.0) {\nnewDirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\nnewDirection=normalize(newPosition+directionRandomizer*randoms3); \n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;\noutInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);\nnewDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD \noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else \nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient; \noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;\nif (cellInfos.w==1.0) {\nratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\n}\nelse {\nratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);\n}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";
  115864. var oy = function() {
  115865. function e(e, t) {
  115866. this._renderVAO = [],
  115867. this._updateVAO = [],
  115868. this.alignDataInBuffer = !1,
  115869. this._parent = e,
  115870. this._engine = t,
  115871. this._updateEffectOptions = {
  115872. attributes: ["position", "initialPosition", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  115873. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower", "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor", "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  115874. uniformBuffersNames: [],
  115875. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  115876. defines: "",
  115877. fallbacks: null,
  115878. onCompiled: null,
  115879. onError: null,
  115880. indexParameters: null,
  115881. maxSimultaneousLights: 0,
  115882. transformFeedbackVaryings: []
  115883. }
  115884. }
  115885. return e.prototype.isUpdateBufferCreated = function() {
  115886. return !!this._updateEffect
  115887. }
  115888. ,
  115889. e.prototype.isUpdateBufferReady = function() {
  115890. var e, t;
  115891. return null !== (t = null === (e = this._updateEffect) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
  115892. }
  115893. ,
  115894. e.prototype.createUpdateBuffer = function(e) {
  115895. return this._updateEffectOptions.transformFeedbackVaryings = ["outPosition"],
  115896. this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),
  115897. this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),
  115898. this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),
  115899. this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),
  115900. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),
  115901. this._parent.particleEmitterType instanceof yf && this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),
  115902. this._parent._colorGradientsTexture || this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),
  115903. this._parent._isBillboardBased || this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),
  115904. this._parent.noiseTexture && (this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),
  115905. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),
  115906. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),
  115907. this._parent.isAnimationSheetEnabled && (this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),
  115908. this._parent.spriteRandomStartCell && this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),
  115909. this._updateEffectOptions.defines = e,
  115910. this._updateEffect = new Mt("gpuUpdateParticles",this._updateEffectOptions,this._engine),
  115911. new ry(this._updateEffect)
  115912. }
  115913. ,
  115914. e.prototype.createVertexBuffers = function(e, t) {
  115915. this._updateVAO.push(this._createUpdateVAO(e)),
  115916. this._renderVAO.push(this._engine.recordVertexArrayObject(t, null, this._parent._getWrapper(this._parent.blendMode).effect)),
  115917. this._engine.bindArrayBuffer(null)
  115918. }
  115919. ,
  115920. e.prototype.createParticleBuffer = function(e) {
  115921. return e
  115922. }
  115923. ,
  115924. e.prototype.bindDrawBuffers = function(e) {
  115925. this._engine.bindVertexArrayObject(this._renderVAO[e], null)
  115926. }
  115927. ,
  115928. e.prototype.preUpdateParticleBuffer = function() {
  115929. var e = this._engine;
  115930. if (this._engine.enableEffect(this._updateEffect),
  115931. !e.setState)
  115932. throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported")
  115933. }
  115934. ,
  115935. e.prototype.updateParticleBuffer = function(e, t, i) {
  115936. this._updateEffect.setTexture("randomSampler", this._parent._randomTexture),
  115937. this._updateEffect.setTexture("randomSampler2", this._parent._randomTexture2),
  115938. this._parent._sizeGradientsTexture && this._updateEffect.setTexture("sizeGradientSampler", this._parent._sizeGradientsTexture),
  115939. this._parent._angularSpeedGradientsTexture && this._updateEffect.setTexture("angularSpeedGradientSampler", this._parent._angularSpeedGradientsTexture),
  115940. this._parent._velocityGradientsTexture && this._updateEffect.setTexture("velocityGradientSampler", this._parent._velocityGradientsTexture),
  115941. this._parent._limitVelocityGradientsTexture && this._updateEffect.setTexture("limitVelocityGradientSampler", this._parent._limitVelocityGradientsTexture),
  115942. this._parent._dragGradientsTexture && this._updateEffect.setTexture("dragGradientSampler", this._parent._dragGradientsTexture),
  115943. this._parent.noiseTexture && this._updateEffect.setTexture("noiseSampler", this._parent.noiseTexture),
  115944. this._engine.bindVertexArrayObject(this._updateVAO[e], null);
  115945. var n = this._engine;
  115946. n.bindTransformFeedbackBuffer(t.getBuffer()),
  115947. n.setRasterizerState(!1),
  115948. n.beginTransformFeedback(!0),
  115949. n.drawArraysType(a.MATERIAL_PointListDrawMode, 0, i),
  115950. n.endTransformFeedback(),
  115951. n.setRasterizerState(!0),
  115952. n.bindTransformFeedbackBuffer(null)
  115953. }
  115954. ,
  115955. e.prototype.releaseBuffers = function() {}
  115956. ,
  115957. e.prototype.releaseVertexBuffers = function() {
  115958. for (var e = 0; e < this._updateVAO.length; e++)
  115959. this._engine.releaseVertexArrayObject(this._updateVAO[e]);
  115960. for (this._updateVAO = [],
  115961. e = 0; e < this._renderVAO.length; e++)
  115962. this._engine.releaseVertexArrayObject(this._renderVAO[e]);
  115963. this._renderVAO = []
  115964. }
  115965. ,
  115966. e.prototype._createUpdateVAO = function(e) {
  115967. var t = {};
  115968. t.position = e.createVertexBuffer("position", 0, 3);
  115969. var i = 3;
  115970. t.age = e.createVertexBuffer("age", i, 1),
  115971. i += 1,
  115972. t.size = e.createVertexBuffer("size", i, 3),
  115973. i += 3,
  115974. t.life = e.createVertexBuffer("life", i, 1),
  115975. i += 1,
  115976. t.seed = e.createVertexBuffer("seed", i, 4),
  115977. i += 4,
  115978. t.direction = e.createVertexBuffer("direction", i, 3),
  115979. i += 3,
  115980. this._parent.particleEmitterType instanceof yf && (t.initialPosition = e.createVertexBuffer("initialPosition", i, 3),
  115981. i += 3),
  115982. this._parent._colorGradientsTexture || (t.color = e.createVertexBuffer("color", i, 4),
  115983. i += 4),
  115984. this._parent._isBillboardBased || (t.initialDirection = e.createVertexBuffer("initialDirection", i, 3),
  115985. i += 3),
  115986. this._parent.noiseTexture && (t.noiseCoordinates1 = e.createVertexBuffer("noiseCoordinates1", i, 3),
  115987. i += 3,
  115988. t.noiseCoordinates2 = e.createVertexBuffer("noiseCoordinates2", i, 3),
  115989. i += 3),
  115990. this._parent._angularSpeedGradientsTexture ? (t.angle = e.createVertexBuffer("angle", i, 1),
  115991. i += 1) : (t.angle = e.createVertexBuffer("angle", i, 2),
  115992. i += 2),
  115993. this._parent._isAnimationSheetEnabled && (t.cellIndex = e.createVertexBuffer("cellIndex", i, 1),
  115994. i += 1,
  115995. this._parent.spriteRandomStartCell && (t.cellStartOffset = e.createVertexBuffer("cellStartOffset", i, 1),
  115996. i += 1));
  115997. var n = this._engine.recordVertexArrayObject(t, null, this._updateEffect);
  115998. return this._engine.bindArrayBuffer(null),
  115999. n
  116000. }
  116001. ,
  116002. e
  116003. }();
  116004. y("BABYLON.WebGL2ParticleSystem", oy);
  116005. Pt.ShadersStoreWGSL.gpuUpdateParticlesComputeShader = "struct Particle {\nposition : vec3<f32>;\nage : f32;\nsize : vec3<f32>;\nlife : f32;\nseed : vec4<f32>;\ndirection : vec3<f32>;\ndummy0: f32;\n#ifdef CUSTOMEMITTER\ninitialPosition : vec3<f32>;\ndummy1: f32;\n#endif\n#ifndef COLORGRADIENTS\ncolor : vec4<f32>;\n#endif\n#ifndef BILLBOARD\ninitialDirection : vec3<f32>;\ndummy2: f32;\n#endif\n#ifdef NOISE\nnoiseCoordinates1 : vec3<f32>;\ndummy3: f32;\nnoiseCoordinates2 : vec3<f32>;\ndummy4: f32;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nangle : f32;\n#else\nangle : vec2<f32>;\n#endif\n#ifdef ANIMATESHEET\ncellIndex : f32;\n#ifdef ANIMATESHEETRANDOMSTART\ncellStartOffset : f32;\n#endif\n#endif\n};\nstruct Particles {\nparticles : array<Particle>;\n};\nstruct SimParams {\ncurrentCount : f32;\ntimeDelta : f32;\nstopFactor : f32;\nrandomTextureSize: i32;\nlifeTime : vec2<f32>;\nemitPower : vec2<f32>;\n#ifndef COLORGRADIENTS\ncolor1 : vec4<f32>;\ncolor2 : vec4<f32>;\n#endif\nsizeRange : vec2<f32>;\nscaleRange : vec4<f32>;\nangleRange : vec4<f32>;\ngravity : vec3<f32>;\n#ifdef LIMITVELOCITYGRADIENTS\nlimitVelocityDamping : f32;\n#endif\n#ifdef ANIMATESHEET\ncellInfos : vec4<f32>;\n#endif\n#ifdef NOISE\nnoiseStrength : vec3<f32>;\n#endif\n#ifndef LOCAL\nemitterWM : mat4x4<f32>;\n#endif\n#ifdef BOXEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\nminEmitBox : vec3<f32>;\nmaxEmitBox : vec3<f32>;\n#endif\n#ifdef CONEEMITTER\nradius : vec2<f32>;\nconeAngle : f32;\nheight : vec2<f32>;\ndirectionRandomizer : f32;\n#endif\n#ifdef CYLINDEREMITTER\nradius : f32;\nheight : f32;\nradiusRange : f32;\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#else\ndirectionRandomizer : f32;\n#endif\n#endif\n#ifdef HEMISPHERICEMITTER\nradius : f32;\nradiusRange : f32;\ndirectionRandomizer : f32;\n#endif\n#ifdef POINTEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#endif\n#ifdef SPHEREEMITTER\nradius : f32;\nradiusRange : f32;\n#ifdef DIRECTEDSPHEREEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#else\ndirectionRandomizer : f32;\n#endif\n#endif\n};\n@binding(0) @group(0) var<uniform> params : SimParams;\n@binding(1) @group(0) var<storage,read> particlesIn : Particles;\n@binding(2) @group(0) var<storage,read_write> particlesOut : Particles;\n@binding(3) @group(0) var randomTexture : texture_2d<f32>;\n@binding(4) @group(0) var randomTexture2 : texture_2d<f32>;\n#ifdef SIZEGRADIENTS\n@binding(0) @group(1) var sizeGradientSampler : sampler;\n@binding(1) @group(1) var sizeGradientTexture : texture_2d<f32>;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\n@binding(2) @group(1) var angularSpeedGradientSampler : sampler;\n@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d<f32>;\n#endif \n#ifdef VELOCITYGRADIENTS\n@binding(4) @group(1) var velocityGradientSampler : sampler;\n@binding(5) @group(1) var velocityGradientTexture : texture_2d<f32>;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\n@binding(6) @group(1) var limitVelocityGradientSampler : sampler;\n@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d<f32>;\n#endif\n#ifdef DRAGGRADIENTS\n@binding(8) @group(1) var dragGradientSampler : sampler;\n@binding(9) @group(1) var dragGradientTexture : texture_2d<f32>;\n#endif\n#ifdef NOISE\n@binding(10) @group(1) var noiseSampler : sampler;\n@binding(11) @group(1) var noiseTexture : texture_2d<f32>;\n#endif\nfn getRandomVec3(offset : f32,vertexID : f32)->vec3<f32> {\nreturn textureLoad(randomTexture2,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;\n}\nfn getRandomVec4(offset : f32,vertexID : f32)->vec4<f32> {\nreturn textureLoad(randomTexture,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);\n}\n@stage(compute) @workgroup_size(64)\nfn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {\nlet index : u32=GlobalInvocationID.x;\nlet vertexID : f32=f32(index);\nif (index>=u32(params.currentCount)) {\nreturn;\n}\nlet PI : f32=3.14159;\nlet timeDelta : f32=params.timeDelta;\nlet newAge : f32=particlesIn.particles[index].age+timeDelta;\nlet life : f32=particlesIn.particles[index].life;\nlet seed : vec4<f32>=particlesIn.particles[index].seed;\nlet direction : vec3<f32>=particlesIn.particles[index].direction;\nif (newAge>=life && params.stopFactor != 0.) {\nvar newPosition : vec3<f32>;\nvar newDirection : vec3<f32>;\nlet randoms : vec4<f32>=getRandomVec4(seed.x,vertexID);\nlet outLife : f32=params.lifeTime.x+(params.lifeTime.y-params.lifeTime.x)*randoms.r;\nparticlesOut.particles[index].life=outLife;\nparticlesOut.particles[index].age=newAge-life;\nparticlesOut.particles[index].seed=seed;\nvar sizex : f32;\n#ifdef SIZEGRADIENTS \nsizex=textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(0.,0.),0.).r;\n#else\nsizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g;\n#endif\nparticlesOut.particles[index].size=vec3<f32>(\nsizex,\nparams.scaleRange.x+(params.scaleRange.y-params.scaleRange.x)*randoms.b,\nparams.scaleRange.z+(params.scaleRange.w-params.scaleRange.z)*randoms.a);\n#ifndef COLORGRADIENTS\nparticlesOut.particles[index].color=params.color1+(params.color2-params.color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \nparticlesOut.particles[index].angle=vec2<f32>(\nparams.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r,\nparams.angleRange.x+(params.angleRange.y-params.angleRange.x)*randoms.a);\n#else\nparticlesOut.particles[index].angle=params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r;\n#endif \n#if defined(POINTEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewPosition=vec3<f32>(0.,0.,0.);\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#elif defined(BOXEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewPosition=params.minEmitBox+(params.maxEmitBox-params.minEmitBox)*randoms2;\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet phi : f32=2.0*PI*randoms2.x;\nlet theta : f32=acos(-1.0+2.0*randoms2.y);\nlet randX : f32=cos(phi)*sin(theta);\nlet randY : f32=cos(theta);\nlet randZ : f32=sin(phi)*sin(theta);\nnewPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,abs(randY),randZ);\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#elif defined(SPHEREEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet phi : f32=2.0*PI*randoms2.x;\nlet theta : f32=acos(-1.0+2.0*randoms2.y);\nlet randX : f32=cos(phi)*sin(theta);\nlet randY : f32=cos(theta);\nlet randZ : f32=sin(phi)*sin(theta);\nnewPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(params.direction1+(params.direction2-params.direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet yPos : f32=(-0.5+randoms2.x)*params.height;\nvar angle : f32=randoms2.y*PI*2.;\nlet inverseRadiusRangeSquared : f32=(1.-params.radiusRange)*(1.-params.radiusRange);\nlet positionRadius : f32=params.radius*sqrt(inverseRadiusRangeSquared+randoms2.z*(1.-inverseRadiusRangeSquared));\nlet xPos : f32=positionRadius*cos(angle);\nlet zPos : f32=positionRadius*sin(angle);\nnewPosition=vec3<f32>(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#else\nangle=angle+(-0.5+randoms3.x)*PI*params.directionRandomizer;\nnewDirection=vec3<f32>(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet s : f32=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nlet h : f32=0.0001;\n#else\nvar h : f32=randoms2.y*params.height.y;\nh=1.-h*h; \n#endif\nvar lRadius : f32=params.radius.x-params.radius.x*randoms2.z*params.radius.y;\nlRadius=lRadius*h;\nlet randX : f32=lRadius*sin(s);\nlet randZ : f32=lRadius*cos(s);\nlet randY : f32=h *params.height.x;\nnewPosition=vec3<f32>(randX,randY,randZ); \nif (abs(cos(params.coneAngle))==1.0) {\nnewDirection=vec3<f32>(0.,1.0,0.);\n} else {\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3); \n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=particlesIn.particles[index].initialPosition;\nparticlesOut.particles[index].initialPosition=newPosition;\n#else \nnewPosition=vec3<f32>(0.,0.,0.);\nnewDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3<f32>(0.5,0.5,0.5));\n#endif\nlet power : f32=params.emitPower.x+(params.emitPower.y-params.emitPower.x)*randoms.a;\n#ifdef LOCAL\nparticlesOut.particles[index].position=newPosition;\n#else\nparticlesOut.particles[index].position=(params.emitterWM*vec4<f32>(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nlet initial : vec3<f32>=newDirection;\n#else \nlet initial : vec3<f32>=(params.emitterWM*vec4<f32>(newDirection,0.)).xyz;\n#endif\nparticlesOut.particles[index].direction=initial*power;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \nparticlesOut.particles[index].cellIndex=params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nparticlesOut.particles[index].cellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\nparticlesOut.particles[index].noiseCoordinates1=particlesIn.particles[index].noiseCoordinates1;\nparticlesOut.particles[index].noiseCoordinates2=particlesIn.particles[index].noiseCoordinates2;\n#endif\n} else {\nvar directionScale : f32=timeDelta;\nparticlesOut.particles[index].age=newAge;\nlet ageGradient : f32=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale=directionScale*textureSampleLevel(velocityGradientTexture,velocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2<f32>(ageGradient,0.),0.).r);\n#endif\nlet position : vec3<f32>=particlesIn.particles[index].position;\n#if defined(CUSTOMEMITTER)\nparticlesOut.particles[index].position=position+(direction-position)*ageGradient; \nparticlesOut.particles[index].initialPosition=particlesIn.particles[index].initialPosition;\n#else\nparticlesOut.particles[index].position=position+direction*directionScale;\n#endif\nparticlesOut.particles[index].life=life;\nparticlesOut.particles[index].seed=seed;\n#ifndef COLORGRADIENTS \nparticlesOut.particles[index].color=particlesIn.particles[index].color;\n#endif\n#ifdef SIZEGRADIENTS\nparticlesOut.particles[index].size=vec3<f32>(\ntextureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(ageGradient,0.),0.).r,\nparticlesIn.particles[index].size.yz);\n#else\nparticlesOut.particles[index].size=particlesIn.particles[index].size;\n#endif \n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=particlesIn.particles[index].initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#else\nvar updatedDirection : vec3<f32>=direction+params.gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nlet limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\nlet currentVelocity : f32=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*params.limitVelocityDamping;\n}\n#endif\nparticlesOut.particles[index].direction=updatedDirection;\n#ifdef NOISE\nlet noiseCoordinates1 : vec3<f32>=particlesIn.particles[index].noiseCoordinates1;\nlet noiseCoordinates2 : vec3<f32>=particlesIn.particles[index].noiseCoordinates2;\nlet fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.x,noiseCoordinates1.y)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.z,noiseCoordinates2.x)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates2.y,noiseCoordinates2.z)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet force : vec3<f32>=vec3<f32>(-1.+2.*fetchedR,-1.+2.*fetchedG,-1.+2.*fetchedB)*params.noiseStrength;\nparticlesOut.particles[index].direction=particlesOut.particles[index].direction+force*timeDelta;\nparticlesOut.particles[index].noiseCoordinates1=noiseCoordinates1;\nparticlesOut.particles[index].noiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nlet angularSpeed : f32=textureSampleLevel(angularSpeedGradientTexture,angularSpeedGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\nparticlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta;\n#else\nlet angle : vec2<f32>=particlesIn.particles[index].angle;\nparticlesOut.particles[index].angle=vec2<f32>(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nvar offsetAge : f32=particlesOut.particles[index].age;\nlet dist : f32=params.cellInfos.y-params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nlet cellStartOffset : f32=particlesIn.particles[index].cellStartOffset;\nparticlesOut.particles[index].cellStartOffset=cellStartOffset;\noffsetAge=offsetAge+cellStartOffset;\n#else\nlet cellStartOffset : f32=0.;\n#endif \nvar ratio : f32;\nif (params.cellInfos.w==1.0) {\nratio=clamp(((cellStartOffset+params.cellInfos.z*offsetAge) % life)/life,0.,1.0);\n}\nelse {\nratio=clamp((cellStartOffset+params.cellInfos.z*offsetAge)/life,0.,1.0);\n}\nparticlesOut.particles[index].cellIndex=f32(i32(params.cellInfos.x+ratio*dist));\n#endif\n}\n}\n";
  116006. var ay = function() {
  116007. function e(e, t) {
  116008. this._bufferComputeShader = [],
  116009. this._renderVertexBuffers = [],
  116010. this.alignDataInBuffer = !0,
  116011. this._parent = e,
  116012. this._engine = t
  116013. }
  116014. return e.prototype.isUpdateBufferCreated = function() {
  116015. return !!this._updateComputeShader
  116016. }
  116017. ,
  116018. e.prototype.isUpdateBufferReady = function() {
  116019. var e, t;
  116020. return null !== (t = null === (e = this._updateComputeShader) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
  116021. }
  116022. ,
  116023. e.prototype.createUpdateBuffer = function(e) {
  116024. var t, i = {
  116025. params: {
  116026. group: 0,
  116027. binding: 0
  116028. },
  116029. particlesIn: {
  116030. group: 0,
  116031. binding: 1
  116032. },
  116033. particlesOut: {
  116034. group: 0,
  116035. binding: 2
  116036. },
  116037. randomTexture: {
  116038. group: 0,
  116039. binding: 3
  116040. },
  116041. randomTexture2: {
  116042. group: 0,
  116043. binding: 4
  116044. }
  116045. };
  116046. return this._parent._sizeGradientsTexture && (i.sizeGradientTexture = {
  116047. group: 1,
  116048. binding: 1
  116049. }),
  116050. this._parent._angularSpeedGradientsTexture && (i.angularSpeedGradientTexture = {
  116051. group: 1,
  116052. binding: 3
  116053. }),
  116054. this._parent._velocityGradientsTexture && (i.velocityGradientTexture = {
  116055. group: 1,
  116056. binding: 5
  116057. }),
  116058. this._parent._limitVelocityGradientsTexture && (i.limitVelocityGradientTexture = {
  116059. group: 1,
  116060. binding: 7
  116061. }),
  116062. this._parent._dragGradientsTexture && (i.dragGradientTexture = {
  116063. group: 1,
  116064. binding: 9
  116065. }),
  116066. this._parent.noiseTexture && (i.noiseTexture = {
  116067. group: 1,
  116068. binding: 11
  116069. }),
  116070. this._updateComputeShader = new gl("updateParticles",this._engine,"gpuUpdateParticles",{
  116071. bindingsMapping: i,
  116072. defines: e.split("\n")
  116073. }),
  116074. null === (t = this._simParamsComputeShader) || void 0 === t || t.dispose(),
  116075. this._simParamsComputeShader = new Fi(this._engine),
  116076. this._simParamsComputeShader.addUniform("currentCount", 1),
  116077. this._simParamsComputeShader.addUniform("timeDelta", 1),
  116078. this._simParamsComputeShader.addUniform("stopFactor", 1),
  116079. this._simParamsComputeShader.addUniform("randomTextureSize", 1),
  116080. this._simParamsComputeShader.addUniform("lifeTime", 2),
  116081. this._simParamsComputeShader.addUniform("emitPower", 2),
  116082. this._parent._colorGradientsTexture || (this._simParamsComputeShader.addUniform("color1", 4),
  116083. this._simParamsComputeShader.addUniform("color2", 4)),
  116084. this._simParamsComputeShader.addUniform("sizeRange", 2),
  116085. this._simParamsComputeShader.addUniform("scaleRange", 4),
  116086. this._simParamsComputeShader.addUniform("angleRange", 4),
  116087. this._simParamsComputeShader.addUniform("gravity", 3),
  116088. this._parent._limitVelocityGradientsTexture && this._simParamsComputeShader.addUniform("limitVelocityDamping", 1),
  116089. this._parent.isAnimationSheetEnabled && this._simParamsComputeShader.addUniform("cellInfos", 4),
  116090. this._parent.noiseTexture && this._simParamsComputeShader.addUniform("noiseStrength", 3),
  116091. this._parent.isLocal || this._simParamsComputeShader.addUniform("emitterWM", 16),
  116092. this._parent.particleEmitterType && this._parent.particleEmitterType.buildUniformLayout(this._simParamsComputeShader),
  116093. this._updateComputeShader.setUniformBuffer("params", this._simParamsComputeShader),
  116094. new ry(this._simParamsComputeShader)
  116095. }
  116096. ,
  116097. e.prototype.createVertexBuffers = function(e, t) {
  116098. this._renderVertexBuffers.push(t)
  116099. }
  116100. ,
  116101. e.prototype.createParticleBuffer = function(e) {
  116102. var t = new wo(this._engine,4 * e.length,a.BUFFER_CREATIONFLAG_READWRITE | a.BUFFER_CREATIONFLAG_VERTEX);
  116103. return t.update(e),
  116104. this._bufferComputeShader.push(t),
  116105. t.getBuffer()
  116106. }
  116107. ,
  116108. e.prototype.bindDrawBuffers = function(e, t) {
  116109. this._engine.bindBuffers(this._renderVertexBuffers[e], null, t)
  116110. }
  116111. ,
  116112. e.prototype.preUpdateParticleBuffer = function() {}
  116113. ,
  116114. e.prototype.updateParticleBuffer = function(e, t, i) {
  116115. this._simParamsComputeShader.update(),
  116116. this._updateComputeShader.setTexture("randomTexture", this._parent._randomTexture, !1),
  116117. this._updateComputeShader.setTexture("randomTexture2", this._parent._randomTexture2, !1),
  116118. this._parent._sizeGradientsTexture && this._updateComputeShader.setTexture("sizeGradientTexture", this._parent._sizeGradientsTexture),
  116119. this._parent._angularSpeedGradientsTexture && this._updateComputeShader.setTexture("angularSpeedGradientTexture", this._parent._angularSpeedGradientsTexture),
  116120. this._parent._velocityGradientsTexture && this._updateComputeShader.setTexture("velocityGradientTexture", this._parent._velocityGradientsTexture),
  116121. this._parent._limitVelocityGradientsTexture && this._updateComputeShader.setTexture("limitVelocityGradientTexture", this._parent._limitVelocityGradientsTexture),
  116122. this._parent._dragGradientsTexture && this._updateComputeShader.setTexture("dragGradientTexture", this._parent._dragGradientsTexture),
  116123. this._parent.noiseTexture && this._updateComputeShader.setTexture("noiseTexture", this._parent.noiseTexture),
  116124. this._updateComputeShader.setStorageBuffer("particlesIn", this._bufferComputeShader[e]),
  116125. this._updateComputeShader.setStorageBuffer("particlesOut", this._bufferComputeShader[1 ^ e]),
  116126. this._updateComputeShader.dispatch(Math.ceil(i / 64))
  116127. }
  116128. ,
  116129. e.prototype.releaseBuffers = function() {
  116130. for (var e, t = 0; t < this._bufferComputeShader.length; ++t)
  116131. this._bufferComputeShader[t].dispose();
  116132. this._bufferComputeShader = [],
  116133. null === (e = this._simParamsComputeShader) || void 0 === e || e.dispose(),
  116134. this._simParamsComputeShader = null,
  116135. this._updateComputeShader = null
  116136. }
  116137. ,
  116138. e.prototype.releaseVertexBuffers = function() {
  116139. this._renderVertexBuffers = []
  116140. }
  116141. ,
  116142. e
  116143. }();
  116144. y("BABYLON.ComputeShaderParticleSystem", ay);
  116145. var sy, ly = function() {
  116146. function e(e, t, i) {
  116147. this.gradient = e,
  116148. this.color1 = t,
  116149. this.color2 = i
  116150. }
  116151. return e.prototype.getColorToRef = function(e) {
  116152. this.color2 ? N.LerpToRef(this.color1, this.color2, Math.random(), e) : e.copyFrom(this.color1)
  116153. }
  116154. ,
  116155. e
  116156. }(), cy = function(e, t) {
  116157. this.gradient = e,
  116158. this.color = t
  116159. }, uy = function() {
  116160. function e(e, t, i) {
  116161. this.gradient = e,
  116162. this.factor1 = t,
  116163. this.factor2 = i
  116164. }
  116165. return e.prototype.getFactor = function() {
  116166. return void 0 === this.factor2 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random()
  116167. }
  116168. ,
  116169. e
  116170. }(), hy = function() {
  116171. function e() {}
  116172. return e.GetCurrentGradient = function(e, t, i) {
  116173. if (t[0].gradient > e)
  116174. i(t[0], t[0], 1);
  116175. else {
  116176. for (var n = 0; n < t.length - 1; n++) {
  116177. var r = t[n]
  116178. , o = t[n + 1];
  116179. if (e >= r.gradient && e <= o.gradient)
  116180. return void i(r, o, (e - r.gradient) / (o.gradient - r.gradient))
  116181. }
  116182. var a = t.length - 1;
  116183. i(t[a], t[a], 1)
  116184. }
  116185. }
  116186. ,
  116187. e
  116188. }(), dy = function() {
  116189. function e(t) {
  116190. this.particleSystem = t,
  116191. this.position = x.Zero(),
  116192. this.direction = x.Zero(),
  116193. this.color = new N(0,0,0,0),
  116194. this.colorStep = new N(0,0,0,0),
  116195. this.lifeTime = 1,
  116196. this.age = 0,
  116197. this.size = 0,
  116198. this.scale = new A(1,1),
  116199. this.angle = 0,
  116200. this.angularSpeed = 0,
  116201. this.cellIndex = 0,
  116202. this._attachedSubEmitters = null,
  116203. this._currentColor1 = new N(0,0,0,0),
  116204. this._currentColor2 = new N(0,0,0,0),
  116205. this._currentSize1 = 0,
  116206. this._currentSize2 = 0,
  116207. this._currentAngularSpeed1 = 0,
  116208. this._currentAngularSpeed2 = 0,
  116209. this._currentVelocity1 = 0,
  116210. this._currentVelocity2 = 0,
  116211. this._currentLimitVelocity1 = 0,
  116212. this._currentLimitVelocity2 = 0,
  116213. this._currentDrag1 = 0,
  116214. this._currentDrag2 = 0,
  116215. this.id = e._Count++,
  116216. this.particleSystem.isAnimationSheetEnabled && this._updateCellInfoFromSystem()
  116217. }
  116218. return e.prototype._updateCellInfoFromSystem = function() {
  116219. this.cellIndex = this.particleSystem.startSpriteCellID
  116220. }
  116221. ,
  116222. e.prototype.updateCellIndex = function() {
  116223. var e = this.age
  116224. , t = this.particleSystem.spriteCellChangeSpeed;
  116225. this.particleSystem.spriteRandomStartCell && (void 0 === this._randomCellOffset && (this._randomCellOffset = Math.random() * this.lifeTime),
  116226. 0 === t ? (t = 1,
  116227. e = this._randomCellOffset) : e += this._randomCellOffset);
  116228. var i, n = this._initialEndSpriteCellID - this._initialStartSpriteCellID;
  116229. i = this._initialSpriteCellLoop ? d.Clamp(e * t % this.lifeTime / this.lifeTime) : d.Clamp(e * t / this.lifeTime),
  116230. this.cellIndex = this._initialStartSpriteCellID + i * n | 0
  116231. }
  116232. ,
  116233. e.prototype._inheritParticleInfoToSubEmitter = function(e) {
  116234. if (e.particleSystem.emitter.position) {
  116235. var t = e.particleSystem.emitter;
  116236. if (t.position.copyFrom(this.position),
  116237. e.inheritDirection) {
  116238. var i = I.Vector3[0];
  116239. this.direction.normalizeToRef(i),
  116240. t.setDirection(i, 0, Math.PI / 2)
  116241. }
  116242. } else
  116243. e.particleSystem.emitter.copyFrom(this.position);
  116244. this.direction.scaleToRef(e.inheritedVelocityAmount / 2, I.Vector3[0]),
  116245. e.particleSystem._inheritedVelocityOffset.copyFrom(I.Vector3[0])
  116246. }
  116247. ,
  116248. e.prototype._inheritParticleInfoToSubEmitters = function() {
  116249. var e = this;
  116250. this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach((function(t) {
  116251. e._inheritParticleInfoToSubEmitter(t)
  116252. }
  116253. ))
  116254. }
  116255. ,
  116256. e.prototype._reset = function() {
  116257. this.age = 0,
  116258. this.id = e._Count++,
  116259. this._currentColorGradient = null,
  116260. this._currentSizeGradient = null,
  116261. this._currentAngularSpeedGradient = null,
  116262. this._currentVelocityGradient = null,
  116263. this._currentLimitVelocityGradient = null,
  116264. this._currentDragGradient = null,
  116265. this.cellIndex = this.particleSystem.startSpriteCellID,
  116266. this._randomCellOffset = void 0
  116267. }
  116268. ,
  116269. e.prototype.copyTo = function(e) {
  116270. e.position.copyFrom(this.position),
  116271. this._initialDirection ? e._initialDirection ? e._initialDirection.copyFrom(this._initialDirection) : e._initialDirection = this._initialDirection.clone() : e._initialDirection = null,
  116272. e.direction.copyFrom(this.direction),
  116273. this._localPosition && (e._localPosition ? e._localPosition.copyFrom(this._localPosition) : e._localPosition = this._localPosition.clone()),
  116274. e.color.copyFrom(this.color),
  116275. e.colorStep.copyFrom(this.colorStep),
  116276. e.lifeTime = this.lifeTime,
  116277. e.age = this.age,
  116278. e._randomCellOffset = this._randomCellOffset,
  116279. e.size = this.size,
  116280. e.scale.copyFrom(this.scale),
  116281. e.angle = this.angle,
  116282. e.angularSpeed = this.angularSpeed,
  116283. e.particleSystem = this.particleSystem,
  116284. e.cellIndex = this.cellIndex,
  116285. e.id = this.id,
  116286. e._attachedSubEmitters = this._attachedSubEmitters,
  116287. this._currentColorGradient && (e._currentColorGradient = this._currentColorGradient,
  116288. e._currentColor1.copyFrom(this._currentColor1),
  116289. e._currentColor2.copyFrom(this._currentColor2)),
  116290. this._currentSizeGradient && (e._currentSizeGradient = this._currentSizeGradient,
  116291. e._currentSize1 = this._currentSize1,
  116292. e._currentSize2 = this._currentSize2),
  116293. this._currentAngularSpeedGradient && (e._currentAngularSpeedGradient = this._currentAngularSpeedGradient,
  116294. e._currentAngularSpeed1 = this._currentAngularSpeed1,
  116295. e._currentAngularSpeed2 = this._currentAngularSpeed2),
  116296. this._currentVelocityGradient && (e._currentVelocityGradient = this._currentVelocityGradient,
  116297. e._currentVelocity1 = this._currentVelocity1,
  116298. e._currentVelocity2 = this._currentVelocity2),
  116299. this._currentLimitVelocityGradient && (e._currentLimitVelocityGradient = this._currentLimitVelocityGradient,
  116300. e._currentLimitVelocity1 = this._currentLimitVelocity1,
  116301. e._currentLimitVelocity2 = this._currentLimitVelocity2),
  116302. this._currentDragGradient && (e._currentDragGradient = this._currentDragGradient,
  116303. e._currentDrag1 = this._currentDrag1,
  116304. e._currentDrag2 = this._currentDrag2),
  116305. this.particleSystem.isAnimationSheetEnabled && (e._initialStartSpriteCellID = this._initialStartSpriteCellID,
  116306. e._initialEndSpriteCellID = this._initialEndSpriteCellID,
  116307. e._initialSpriteCellLoop = this._initialSpriteCellLoop),
  116308. this.particleSystem.useRampGradients && (e.remapData && this.remapData ? e.remapData.copyFrom(this.remapData) : e.remapData = new R(0,0,0,0)),
  116309. this._randomNoiseCoordinates1 && (e._randomNoiseCoordinates1 ? (e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),
  116310. e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)) : (e._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone(),
  116311. e._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone()))
  116312. }
  116313. ,
  116314. e._Count = 0,
  116315. e
  116316. }();
  116317. !function(e) {
  116318. e[e.ATTACHED = 0] = "ATTACHED",
  116319. e[e.END = 1] = "END"
  116320. }(sy || (sy = {}));
  116321. var py = function() {
  116322. function e(e) {
  116323. if (this.particleSystem = e,
  116324. this.type = sy.END,
  116325. this.inheritDirection = !1,
  116326. this.inheritedVelocityAmount = 0,
  116327. !e.emitter || !e.emitter.dispose) {
  116328. var t = b("BABYLON.AbstractMesh");
  116329. e.emitter = new t("SubemitterSystemEmitter",e.getScene()),
  116330. e._disposeEmitterOnDispose = !0
  116331. }
  116332. }
  116333. return e.prototype.clone = function() {
  116334. var t = this.particleSystem.emitter;
  116335. t ? t instanceof x ? t = t.clone() : -1 !== t.getClassName().indexOf("Mesh") && ((t = new (b("BABYLON.Mesh"))("",t.getScene())).isVisible = !1) : t = new x;
  116336. var i = new e(this.particleSystem.clone(this.particleSystem.name, t));
  116337. return i.particleSystem.name += "Clone",
  116338. i.type = this.type,
  116339. i.inheritDirection = this.inheritDirection,
  116340. i.inheritedVelocityAmount = this.inheritedVelocityAmount,
  116341. i.particleSystem._disposeEmitterOnDispose = !0,
  116342. i.particleSystem.disposeOnStop = !0,
  116343. i
  116344. }
  116345. ,
  116346. e.prototype.serialize = function(e) {
  116347. void 0 === e && (e = !1);
  116348. var t = {};
  116349. return t.type = this.type,
  116350. t.inheritDirection = this.inheritDirection,
  116351. t.inheritedVelocityAmount = this.inheritedVelocityAmount,
  116352. t.particleSystem = this.particleSystem.serialize(e),
  116353. t
  116354. }
  116355. ,
  116356. e._ParseParticleSystem = function(e, t, i, n) {
  116357. throw void 0 === n && (n = !1),
  116358. be("ParseParticle")
  116359. }
  116360. ,
  116361. e.Parse = function(t, i, n) {
  116362. var r = t.particleSystem
  116363. , o = new e(e._ParseParticleSystem(r, i, n, !0));
  116364. return o.type = t.type,
  116365. o.inheritDirection = t.inheritDirection,
  116366. o.inheritedVelocityAmount = t.inheritedVelocityAmount,
  116367. o.particleSystem._isSubEmitter = !0,
  116368. o
  116369. }
  116370. ,
  116371. e.prototype.dispose = function() {
  116372. this.particleSystem.dispose()
  116373. }
  116374. ,
  116375. e
  116376. }();
  116377. Pt.ShadersStore.particlesPixelShader = "varying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include<clipPlaneFragmentDeclaration>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  116378. Pt.ShadersStore.particlesVertexShader = "attribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos; \n#endif\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vPositionW;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvPositionW=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\nvPositionW=(invView*vec4(viewPos,1)).xyz;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\ngl_Position=projection*vec4(viewPos,1.0);\n#else\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvPositionW=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(vPositionW,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex*particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset/particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  116379. var fy = function(e) {
  116380. function t(t, i, n, r, o, a) {
  116381. void 0 === r && (r = null),
  116382. void 0 === o && (o = !1),
  116383. void 0 === a && (a = .01);
  116384. var s = e.call(this, t) || this;
  116385. s._emitterInverseWorldMatrix = P.Identity(),
  116386. s._inheritedVelocityOffset = new x,
  116387. s.onDisposeObservable = new h,
  116388. s.onStoppedObservable = new h,
  116389. s._particles = new Array,
  116390. s._stockParticles = new Array,
  116391. s._newPartsExcess = 0,
  116392. s._vertexBuffers = {},
  116393. s._scaledColorStep = new N(0,0,0,0),
  116394. s._colorDiff = new N(0,0,0,0),
  116395. s._scaledDirection = x.Zero(),
  116396. s._scaledGravity = x.Zero(),
  116397. s._currentRenderId = -1,
  116398. s._useInstancing = !1,
  116399. s._started = !1,
  116400. s._stopped = !1,
  116401. s._actualFrame = 0,
  116402. s._currentEmitRate1 = 0,
  116403. s._currentEmitRate2 = 0,
  116404. s._currentStartSize1 = 0,
  116405. s._currentStartSize2 = 0,
  116406. s._rawTextureWidth = 256,
  116407. s._useRampGradients = !1,
  116408. s._disposeEmitterOnDispose = !1,
  116409. s.isLocal = !1,
  116410. s._onBeforeDrawParticlesObservable = null,
  116411. s.recycleParticle = function(e) {
  116412. var t = s._particles.pop();
  116413. t !== e && t.copyTo(e),
  116414. s._stockParticles.push(t)
  116415. }
  116416. ,
  116417. s._createParticle = function() {
  116418. var e;
  116419. if (0 !== s._stockParticles.length ? (e = s._stockParticles.pop())._reset() : e = new dy(s),
  116420. s._subEmitters && s._subEmitters.length > 0) {
  116421. var t = s._subEmitters[Math.floor(Math.random() * s._subEmitters.length)];
  116422. e._attachedSubEmitters = [],
  116423. t.forEach((function(t) {
  116424. if (t.type === sy.ATTACHED) {
  116425. var i = t.clone();
  116426. e._attachedSubEmitters.push(i),
  116427. i.particleSystem.start()
  116428. }
  116429. }
  116430. ))
  116431. }
  116432. return e
  116433. }
  116434. ,
  116435. s._emitFromParticle = function(e) {
  116436. if (s._subEmitters && 0 !== s._subEmitters.length) {
  116437. var t = Math.floor(Math.random() * s._subEmitters.length);
  116438. s._subEmitters[t].forEach((function(t) {
  116439. if (t.type === sy.END) {
  116440. var i = t.clone();
  116441. e._inheritParticleInfoToSubEmitter(i),
  116442. i.particleSystem._rootParticleSystem = s,
  116443. s.activeSubSystems.push(i.particleSystem),
  116444. i.particleSystem.start()
  116445. }
  116446. }
  116447. ))
  116448. }
  116449. }
  116450. ,
  116451. s._capacity = i,
  116452. s._epsilon = a,
  116453. s._isAnimationSheetEnabled = o,
  116454. n && "Scene" !== n.getClassName() ? (s._engine = n,
  116455. s.defaultProjectionMatrix = P.PerspectiveFovLH(.8, 1, .1, 100, s._engine.isNDCHalfZRange)) : (s._scene = n || E.LastCreatedScene,
  116456. s._engine = s._scene.getEngine(),
  116457. s.uniqueId = s._scene.getUniqueId(),
  116458. s._scene.particleSystems.push(s)),
  116459. s._engine.getCaps().vertexArrayObject && (s._vertexArrayObject = null),
  116460. s._attachImageProcessingConfiguration(null),
  116461. s._customWrappers = {
  116462. 0: new Gt(s._engine)
  116463. },
  116464. s._customWrappers[0].effect = r,
  116465. s._drawWrappers = [],
  116466. s._useInstancing = s._engine.getCaps().instancedArrays,
  116467. s._createIndexBuffer(),
  116468. s._createVertexBuffers(),
  116469. s.particleEmitterType = new hf;
  116470. var l = null;
  116471. return s.updateFunction = function(e) {
  116472. var t, i = null;
  116473. s.noiseTexture && (i = s.noiseTexture.getSize(),
  116474. null === (t = s.noiseTexture.getContent()) || void 0 === t || t.then((function(e) {
  116475. l = e
  116476. }
  116477. )));
  116478. for (var n, r = function(t) {
  116479. var r = e[t]
  116480. , o = s._scaledUpdateSpeed
  116481. , a = r.age;
  116482. if (r.age += o,
  116483. r.age > r.lifeTime) {
  116484. var c = r.age - a;
  116485. o = (r.lifeTime - a) * o / c,
  116486. r.age = r.lifeTime
  116487. }
  116488. var u = r.age / r.lifeTime;
  116489. s._colorGradients && s._colorGradients.length > 0 ? hy.GetCurrentGradient(u, s._colorGradients, (function(e, t, i) {
  116490. e !== r._currentColorGradient && (r._currentColor1.copyFrom(r._currentColor2),
  116491. t.getColorToRef(r._currentColor2),
  116492. r._currentColorGradient = e),
  116493. N.LerpToRef(r._currentColor1, r._currentColor2, i, r.color)
  116494. }
  116495. )) : (r.colorStep.scaleToRef(o, s._scaledColorStep),
  116496. r.color.addInPlace(s._scaledColorStep),
  116497. r.color.a < 0 && (r.color.a = 0)),
  116498. s._angularSpeedGradients && s._angularSpeedGradients.length > 0 && hy.GetCurrentGradient(u, s._angularSpeedGradients, (function(e, t, i) {
  116499. e !== r._currentAngularSpeedGradient && (r._currentAngularSpeed1 = r._currentAngularSpeed2,
  116500. r._currentAngularSpeed2 = t.getFactor(),
  116501. r._currentAngularSpeedGradient = e),
  116502. r.angularSpeed = d.Lerp(r._currentAngularSpeed1, r._currentAngularSpeed2, i)
  116503. }
  116504. )),
  116505. r.angle += r.angularSpeed * o;
  116506. var h = o;
  116507. if (s._velocityGradients && s._velocityGradients.length > 0 && hy.GetCurrentGradient(u, s._velocityGradients, (function(e, t, i) {
  116508. e !== r._currentVelocityGradient && (r._currentVelocity1 = r._currentVelocity2,
  116509. r._currentVelocity2 = t.getFactor(),
  116510. r._currentVelocityGradient = e),
  116511. h *= d.Lerp(r._currentVelocity1, r._currentVelocity2, i)
  116512. }
  116513. )),
  116514. r.direction.scaleToRef(h, s._scaledDirection),
  116515. s._limitVelocityGradients && s._limitVelocityGradients.length > 0 && hy.GetCurrentGradient(u, s._limitVelocityGradients, (function(e, t, i) {
  116516. e !== r._currentLimitVelocityGradient && (r._currentLimitVelocity1 = r._currentLimitVelocity2,
  116517. r._currentLimitVelocity2 = t.getFactor(),
  116518. r._currentLimitVelocityGradient = e);
  116519. var n = d.Lerp(r._currentLimitVelocity1, r._currentLimitVelocity2, i);
  116520. r.direction.length() > n && r.direction.scaleInPlace(s.limitVelocityDamping)
  116521. }
  116522. )),
  116523. s._dragGradients && s._dragGradients.length > 0 && hy.GetCurrentGradient(u, s._dragGradients, (function(e, t, i) {
  116524. e !== r._currentDragGradient && (r._currentDrag1 = r._currentDrag2,
  116525. r._currentDrag2 = t.getFactor(),
  116526. r._currentDragGradient = e);
  116527. var n = d.Lerp(r._currentDrag1, r._currentDrag2, i);
  116528. s._scaledDirection.scaleInPlace(1 - n)
  116529. }
  116530. )),
  116531. s.isLocal && r._localPosition ? (r._localPosition.addInPlace(s._scaledDirection),
  116532. x.TransformCoordinatesToRef(r._localPosition, s._emitterWorldMatrix, r.position)) : r.position.addInPlace(s._scaledDirection),
  116533. l && i && r._randomNoiseCoordinates1) {
  116534. var p = s._fetchR(r._randomNoiseCoordinates1.x, r._randomNoiseCoordinates1.y, i.width, i.height, l)
  116535. , f = s._fetchR(r._randomNoiseCoordinates1.z, r._randomNoiseCoordinates2.x, i.width, i.height, l)
  116536. , _ = s._fetchR(r._randomNoiseCoordinates2.y, r._randomNoiseCoordinates2.z, i.width, i.height, l)
  116537. , m = I.Vector3[0]
  116538. , g = I.Vector3[1];
  116539. m.copyFromFloats((2 * p - 1) * s.noiseStrength.x, (2 * f - 1) * s.noiseStrength.y, (2 * _ - 1) * s.noiseStrength.z),
  116540. m.scaleToRef(o, g),
  116541. r.direction.addInPlace(g)
  116542. }
  116543. if (s.gravity.scaleToRef(o, s._scaledGravity),
  116544. r.direction.addInPlace(s._scaledGravity),
  116545. s._sizeGradients && s._sizeGradients.length > 0 && hy.GetCurrentGradient(u, s._sizeGradients, (function(e, t, i) {
  116546. e !== r._currentSizeGradient && (r._currentSize1 = r._currentSize2,
  116547. r._currentSize2 = t.getFactor(),
  116548. r._currentSizeGradient = e),
  116549. r.size = d.Lerp(r._currentSize1, r._currentSize2, i)
  116550. }
  116551. )),
  116552. s._useRampGradients && (s._colorRemapGradients && s._colorRemapGradients.length > 0 && hy.GetCurrentGradient(u, s._colorRemapGradients, (function(e, t, i) {
  116553. var n = d.Lerp(e.factor1, t.factor1, i)
  116554. , o = d.Lerp(e.factor2, t.factor2, i);
  116555. r.remapData.x = n,
  116556. r.remapData.y = o - n
  116557. }
  116558. )),
  116559. s._alphaRemapGradients && s._alphaRemapGradients.length > 0 && hy.GetCurrentGradient(u, s._alphaRemapGradients, (function(e, t, i) {
  116560. var n = d.Lerp(e.factor1, t.factor1, i)
  116561. , o = d.Lerp(e.factor2, t.factor2, i);
  116562. r.remapData.z = n,
  116563. r.remapData.w = o - n
  116564. }
  116565. ))),
  116566. s._isAnimationSheetEnabled && r.updateCellIndex(),
  116567. r._inheritParticleInfoToSubEmitters(),
  116568. r.age >= r.lifeTime)
  116569. return s._emitFromParticle(r),
  116570. r._attachedSubEmitters && (r._attachedSubEmitters.forEach((function(e) {
  116571. e.particleSystem.disposeOnStop = !0,
  116572. e.particleSystem.stop()
  116573. }
  116574. )),
  116575. r._attachedSubEmitters = null),
  116576. s.recycleParticle(r),
  116577. t--,
  116578. n = t,
  116579. "continue";
  116580. n = t
  116581. }, o = 0; o < e.length; o++)
  116582. r(o),
  116583. o = n
  116584. }
  116585. ,
  116586. s
  116587. }
  116588. return U(t, e),
  116589. Object.defineProperty(t.prototype, "onDispose", {
  116590. set: function(e) {
  116591. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  116592. this._onDisposeObserver = this.onDisposeObservable.add(e)
  116593. },
  116594. enumerable: !1,
  116595. configurable: !0
  116596. }),
  116597. Object.defineProperty(t.prototype, "useRampGradients", {
  116598. get: function() {
  116599. return this._useRampGradients
  116600. },
  116601. set: function(e) {
  116602. this._useRampGradients !== e && (this._useRampGradients = e,
  116603. this._resetEffect())
  116604. },
  116605. enumerable: !1,
  116606. configurable: !0
  116607. }),
  116608. Object.defineProperty(t.prototype, "particles", {
  116609. get: function() {
  116610. return this._particles
  116611. },
  116612. enumerable: !1,
  116613. configurable: !0
  116614. }),
  116615. t.prototype.getActiveCount = function() {
  116616. return this._particles.length
  116617. }
  116618. ,
  116619. t.prototype.getClassName = function() {
  116620. return "ParticleSystem"
  116621. }
  116622. ,
  116623. t.prototype.isStopping = function() {
  116624. return this._stopped && this.isAlive()
  116625. }
  116626. ,
  116627. t.prototype.getCustomEffect = function(e) {
  116628. var t, i;
  116629. return void 0 === e && (e = 0),
  116630. null !== (i = null === (t = this._customWrappers[e]) || void 0 === t ? void 0 : t.effect) && void 0 !== i ? i : this._customWrappers[0].effect
  116631. }
  116632. ,
  116633. t.prototype._getCustomDrawWrapper = function(e) {
  116634. var t;
  116635. return void 0 === e && (e = 0),
  116636. null !== (t = this._customWrappers[e]) && void 0 !== t ? t : this._customWrappers[0]
  116637. }
  116638. ,
  116639. t.prototype.setCustomEffect = function(e, t) {
  116640. void 0 === t && (t = 0),
  116641. this._customWrappers[t] = new Gt(this._engine),
  116642. this._customWrappers[t].effect = e,
  116643. this._customWrappers[t].drawContext && (this._customWrappers[t].drawContext.useInstancing = this._useInstancing)
  116644. }
  116645. ,
  116646. Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", {
  116647. get: function() {
  116648. return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new h),
  116649. this._onBeforeDrawParticlesObservable
  116650. },
  116651. enumerable: !1,
  116652. configurable: !0
  116653. }),
  116654. Object.defineProperty(t.prototype, "vertexShaderName", {
  116655. get: function() {
  116656. return "particles"
  116657. },
  116658. enumerable: !1,
  116659. configurable: !0
  116660. }),
  116661. Object.defineProperty(t.prototype, "vertexBuffers", {
  116662. get: function() {
  116663. return this._vertexBuffers
  116664. },
  116665. enumerable: !1,
  116666. configurable: !0
  116667. }),
  116668. Object.defineProperty(t.prototype, "indexBuffer", {
  116669. get: function() {
  116670. return this._indexBuffer
  116671. },
  116672. enumerable: !1,
  116673. configurable: !0
  116674. }),
  116675. t.prototype._addFactorGradient = function(e, t, i, n) {
  116676. var r = new uy(t,i,n);
  116677. e.push(r),
  116678. e.sort((function(e, t) {
  116679. return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
  116680. }
  116681. ))
  116682. }
  116683. ,
  116684. t.prototype._removeFactorGradient = function(e, t) {
  116685. if (e)
  116686. for (var i = 0, n = 0, r = e; n < r.length; n++) {
  116687. if (r[n].gradient === t) {
  116688. e.splice(i, 1);
  116689. break
  116690. }
  116691. i++
  116692. }
  116693. }
  116694. ,
  116695. t.prototype.addLifeTimeGradient = function(e, t, i) {
  116696. return this._lifeTimeGradients || (this._lifeTimeGradients = []),
  116697. this._addFactorGradient(this._lifeTimeGradients, e, t, i),
  116698. this
  116699. }
  116700. ,
  116701. t.prototype.removeLifeTimeGradient = function(e) {
  116702. return this._removeFactorGradient(this._lifeTimeGradients, e),
  116703. this
  116704. }
  116705. ,
  116706. t.prototype.addSizeGradient = function(e, t, i) {
  116707. return this._sizeGradients || (this._sizeGradients = []),
  116708. this._addFactorGradient(this._sizeGradients, e, t, i),
  116709. this
  116710. }
  116711. ,
  116712. t.prototype.removeSizeGradient = function(e) {
  116713. return this._removeFactorGradient(this._sizeGradients, e),
  116714. this
  116715. }
  116716. ,
  116717. t.prototype.addColorRemapGradient = function(e, t, i) {
  116718. return this._colorRemapGradients || (this._colorRemapGradients = []),
  116719. this._addFactorGradient(this._colorRemapGradients, e, t, i),
  116720. this
  116721. }
  116722. ,
  116723. t.prototype.removeColorRemapGradient = function(e) {
  116724. return this._removeFactorGradient(this._colorRemapGradients, e),
  116725. this
  116726. }
  116727. ,
  116728. t.prototype.addAlphaRemapGradient = function(e, t, i) {
  116729. return this._alphaRemapGradients || (this._alphaRemapGradients = []),
  116730. this._addFactorGradient(this._alphaRemapGradients, e, t, i),
  116731. this
  116732. }
  116733. ,
  116734. t.prototype.removeAlphaRemapGradient = function(e) {
  116735. return this._removeFactorGradient(this._alphaRemapGradients, e),
  116736. this
  116737. }
  116738. ,
  116739. t.prototype.addAngularSpeedGradient = function(e, t, i) {
  116740. return this._angularSpeedGradients || (this._angularSpeedGradients = []),
  116741. this._addFactorGradient(this._angularSpeedGradients, e, t, i),
  116742. this
  116743. }
  116744. ,
  116745. t.prototype.removeAngularSpeedGradient = function(e) {
  116746. return this._removeFactorGradient(this._angularSpeedGradients, e),
  116747. this
  116748. }
  116749. ,
  116750. t.prototype.addVelocityGradient = function(e, t, i) {
  116751. return this._velocityGradients || (this._velocityGradients = []),
  116752. this._addFactorGradient(this._velocityGradients, e, t, i),
  116753. this
  116754. }
  116755. ,
  116756. t.prototype.removeVelocityGradient = function(e) {
  116757. return this._removeFactorGradient(this._velocityGradients, e),
  116758. this
  116759. }
  116760. ,
  116761. t.prototype.addLimitVelocityGradient = function(e, t, i) {
  116762. return this._limitVelocityGradients || (this._limitVelocityGradients = []),
  116763. this._addFactorGradient(this._limitVelocityGradients, e, t, i),
  116764. this
  116765. }
  116766. ,
  116767. t.prototype.removeLimitVelocityGradient = function(e) {
  116768. return this._removeFactorGradient(this._limitVelocityGradients, e),
  116769. this
  116770. }
  116771. ,
  116772. t.prototype.addDragGradient = function(e, t, i) {
  116773. return this._dragGradients || (this._dragGradients = []),
  116774. this._addFactorGradient(this._dragGradients, e, t, i),
  116775. this
  116776. }
  116777. ,
  116778. t.prototype.removeDragGradient = function(e) {
  116779. return this._removeFactorGradient(this._dragGradients, e),
  116780. this
  116781. }
  116782. ,
  116783. t.prototype.addEmitRateGradient = function(e, t, i) {
  116784. return this._emitRateGradients || (this._emitRateGradients = []),
  116785. this._addFactorGradient(this._emitRateGradients, e, t, i),
  116786. this
  116787. }
  116788. ,
  116789. t.prototype.removeEmitRateGradient = function(e) {
  116790. return this._removeFactorGradient(this._emitRateGradients, e),
  116791. this
  116792. }
  116793. ,
  116794. t.prototype.addStartSizeGradient = function(e, t, i) {
  116795. return this._startSizeGradients || (this._startSizeGradients = []),
  116796. this._addFactorGradient(this._startSizeGradients, e, t, i),
  116797. this
  116798. }
  116799. ,
  116800. t.prototype.removeStartSizeGradient = function(e) {
  116801. return this._removeFactorGradient(this._startSizeGradients, e),
  116802. this
  116803. }
  116804. ,
  116805. t.prototype._createRampGradientTexture = function() {
  116806. if (this._rampGradients && this._rampGradients.length && !this._rampGradientsTexture && this._scene) {
  116807. for (var e = new Uint8Array(4 * this._rawTextureWidth), t = L.Color3[0], i = function(i) {
  116808. var r = i / n._rawTextureWidth;
  116809. hy.GetCurrentGradient(r, n._rampGradients, (function(n, r, o) {
  116810. D.LerpToRef(n.color, r.color, o, t),
  116811. e[4 * i] = 255 * t.r,
  116812. e[4 * i + 1] = 255 * t.g,
  116813. e[4 * i + 2] = 255 * t.b,
  116814. e[4 * i + 3] = 255
  116815. }
  116816. ))
  116817. }, n = this, r = 0; r < this._rawTextureWidth; r++)
  116818. i(r);
  116819. this._rampGradientsTexture = ao.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
  116820. }
  116821. }
  116822. ,
  116823. t.prototype.getRampGradients = function() {
  116824. return this._rampGradients
  116825. }
  116826. ,
  116827. t.prototype.forceRefreshGradients = function() {
  116828. this._syncRampGradientTexture()
  116829. }
  116830. ,
  116831. t.prototype._syncRampGradientTexture = function() {
  116832. this._rampGradients && (this._rampGradients.sort((function(e, t) {
  116833. return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
  116834. }
  116835. )),
  116836. this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
  116837. this._rampGradientsTexture = null),
  116838. this._createRampGradientTexture())
  116839. }
  116840. ,
  116841. t.prototype.addRampGradient = function(e, t) {
  116842. this._rampGradients || (this._rampGradients = []);
  116843. var i = new cy(e,t);
  116844. return this._rampGradients.push(i),
  116845. this._syncRampGradientTexture(),
  116846. this
  116847. }
  116848. ,
  116849. t.prototype.removeRampGradient = function(e) {
  116850. return this._removeGradientAndTexture(e, this._rampGradients, this._rampGradientsTexture),
  116851. this._rampGradientsTexture = null,
  116852. this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(),
  116853. this
  116854. }
  116855. ,
  116856. t.prototype.addColorGradient = function(e, t, i) {
  116857. this._colorGradients || (this._colorGradients = []);
  116858. var n = new ly(e,t,i);
  116859. return this._colorGradients.push(n),
  116860. this._colorGradients.sort((function(e, t) {
  116861. return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
  116862. }
  116863. )),
  116864. this
  116865. }
  116866. ,
  116867. t.prototype.removeColorGradient = function(e) {
  116868. if (!this._colorGradients)
  116869. return this;
  116870. for (var t = 0, i = 0, n = this._colorGradients; i < n.length; i++) {
  116871. if (n[i].gradient === e) {
  116872. this._colorGradients.splice(t, 1);
  116873. break
  116874. }
  116875. t++
  116876. }
  116877. return this
  116878. }
  116879. ,
  116880. t.prototype.resetDrawCache = function() {
  116881. for (var e = 0, t = this._drawWrappers; e < t.length; e++) {
  116882. var i = t[e];
  116883. if (i)
  116884. for (var n = 0, r = i; n < r.length; n++) {
  116885. var o = r[n];
  116886. null == o || o.dispose()
  116887. }
  116888. }
  116889. this._drawWrappers = []
  116890. }
  116891. ,
  116892. t.prototype._fetchR = function(e, t, i, n, r) {
  116893. return r[4 * (((e = .5 * Math.abs(e) + .5) * i % i | 0) + ((t = .5 * Math.abs(t) + .5) * n % n | 0) * i)] / 255
  116894. }
  116895. ,
  116896. t.prototype._reset = function() {
  116897. this._resetEffect()
  116898. }
  116899. ,
  116900. t.prototype._resetEffect = function() {
  116901. this._vertexBuffer && (this._vertexBuffer.dispose(),
  116902. this._vertexBuffer = null),
  116903. this._spriteBuffer && (this._spriteBuffer.dispose(),
  116904. this._spriteBuffer = null),
  116905. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  116906. this._vertexArrayObject = null),
  116907. this._createVertexBuffers()
  116908. }
  116909. ,
  116910. t.prototype._createVertexBuffers = function() {
  116911. this._vertexBufferSize = this._useInstancing ? 10 : 12,
  116912. this._isAnimationSheetEnabled && (this._vertexBufferSize += 1),
  116913. this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED || (this._vertexBufferSize += 3),
  116914. this._useRampGradients && (this._vertexBufferSize += 4);
  116915. var e = this._engine;
  116916. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
  116917. this._vertexBuffer = new wi(e,this._vertexData,!0,this._vertexBufferSize);
  116918. var i = 0
  116919. , n = this._vertexBuffer.createVertexBuffer(Bi.PositionKind, i, 3, this._vertexBufferSize, this._useInstancing);
  116920. this._vertexBuffers[Bi.PositionKind] = n,
  116921. i += 3;
  116922. var r = this._vertexBuffer.createVertexBuffer(Bi.ColorKind, i, 4, this._vertexBufferSize, this._useInstancing);
  116923. this._vertexBuffers[Bi.ColorKind] = r,
  116924. i += 4;
  116925. var o = this._vertexBuffer.createVertexBuffer("angle", i, 1, this._vertexBufferSize, this._useInstancing);
  116926. this._vertexBuffers.angle = o,
  116927. i += 1;
  116928. var a, s = this._vertexBuffer.createVertexBuffer("size", i, 2, this._vertexBufferSize, this._useInstancing);
  116929. if (this._vertexBuffers.size = s,
  116930. i += 2,
  116931. this._isAnimationSheetEnabled) {
  116932. var l = this._vertexBuffer.createVertexBuffer("cellIndex", i, 1, this._vertexBufferSize, this._useInstancing);
  116933. this._vertexBuffers.cellIndex = l,
  116934. i += 1
  116935. }
  116936. if (!this._isBillboardBased || this.billboardMode === t.BILLBOARDMODE_STRETCHED) {
  116937. var c = this._vertexBuffer.createVertexBuffer("direction", i, 3, this._vertexBufferSize, this._useInstancing);
  116938. this._vertexBuffers.direction = c,
  116939. i += 3
  116940. }
  116941. if (this._useRampGradients) {
  116942. var u = this._vertexBuffer.createVertexBuffer("remapData", i, 4, this._vertexBufferSize, this._useInstancing);
  116943. this._vertexBuffers.remapData = u,
  116944. i += 4
  116945. }
  116946. if (this._useInstancing) {
  116947. var h = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
  116948. this._spriteBuffer = new wi(e,h,!1,2),
  116949. a = this._spriteBuffer.createVertexBuffer("offset", 0, 2)
  116950. } else
  116951. a = this._vertexBuffer.createVertexBuffer("offset", i, 2, this._vertexBufferSize, this._useInstancing),
  116952. i += 2;
  116953. this._vertexBuffers.offset = a,
  116954. this.resetDrawCache()
  116955. }
  116956. ,
  116957. t.prototype._createIndexBuffer = function() {
  116958. if (!this._useInstancing) {
  116959. for (var e = [], t = 0, i = 0; i < this._capacity; i++)
  116960. e.push(t),
  116961. e.push(t + 1),
  116962. e.push(t + 2),
  116963. e.push(t),
  116964. e.push(t + 2),
  116965. e.push(t + 3),
  116966. t += 4;
  116967. this._indexBuffer = this._engine.createIndexBuffer(e)
  116968. }
  116969. }
  116970. ,
  116971. t.prototype.getCapacity = function() {
  116972. return this._capacity
  116973. }
  116974. ,
  116975. t.prototype.isAlive = function() {
  116976. return this._alive
  116977. }
  116978. ,
  116979. t.prototype.isStarted = function() {
  116980. return this._started
  116981. }
  116982. ,
  116983. t.prototype._prepareSubEmitterInternalArray = function() {
  116984. var e = this;
  116985. this._subEmitters = new Array,
  116986. this.subEmitters && this.subEmitters.forEach((function(i) {
  116987. i instanceof t ? e._subEmitters.push([new py(i)]) : i instanceof py ? e._subEmitters.push([i]) : i instanceof Array && e._subEmitters.push(i)
  116988. }
  116989. ))
  116990. }
  116991. ,
  116992. t.prototype.start = function(e) {
  116993. var t, i = this;
  116994. if (void 0 === e && (e = this.startDelay),
  116995. !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
  116996. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  116997. if (e)
  116998. setTimeout((function() {
  116999. i.start(0)
  117000. }
  117001. ), e);
  117002. else {
  117003. if (this._prepareSubEmitterInternalArray(),
  117004. this._started = !0,
  117005. this._stopped = !1,
  117006. this._actualFrame = 0,
  117007. this._subEmitters && 0 != this._subEmitters.length && (this.activeSubSystems = new Array),
  117008. this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0],
  117009. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(),
  117010. this._currentEmitRate2 = this._currentEmitRate1),
  117011. this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())),
  117012. this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0],
  117013. this._currentStartSize1 = this._currentStartSizeGradient.getFactor(),
  117014. this._currentStartSize2 = this._currentStartSize1),
  117015. this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())),
  117016. this.preWarmCycles) {
  117017. -1 !== (null === (t = this.emitter) || void 0 === t ? void 0 : t.getClassName().indexOf("Mesh")) && this.emitter.computeWorldMatrix(!0);
  117018. var n = this.noiseTexture;
  117019. if (n && n.onGeneratedObservable)
  117020. n.onGeneratedObservable.addOnce((function() {
  117021. setTimeout((function() {
  117022. for (var e = 0; e < i.preWarmCycles; e++)
  117023. i.animate(!0),
  117024. n.render()
  117025. }
  117026. ))
  117027. }
  117028. ));
  117029. else
  117030. for (var r = 0; r < this.preWarmCycles; r++)
  117031. this.animate(!0)
  117032. }
  117033. this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
  117034. }
  117035. }
  117036. ,
  117037. t.prototype.stop = function(e) {
  117038. void 0 === e && (e = !0),
  117039. this._stopped || (this.onStoppedObservable.notifyObservers(this),
  117040. this._stopped = !0,
  117041. e && this._stopSubEmitters())
  117042. }
  117043. ,
  117044. t.prototype.reset = function() {
  117045. this._stockParticles = [],
  117046. this._particles = []
  117047. }
  117048. ,
  117049. t.prototype._appendParticleVertex = function(e, i, n, r) {
  117050. var o = e * this._vertexBufferSize;
  117051. if (this._vertexData[o++] = i.position.x + this.worldOffset.x,
  117052. this._vertexData[o++] = i.position.y + this.worldOffset.y,
  117053. this._vertexData[o++] = i.position.z + this.worldOffset.z,
  117054. this._vertexData[o++] = i.color.r,
  117055. this._vertexData[o++] = i.color.g,
  117056. this._vertexData[o++] = i.color.b,
  117057. this._vertexData[o++] = i.color.a,
  117058. this._vertexData[o++] = i.angle,
  117059. this._vertexData[o++] = i.scale.x * i.size,
  117060. this._vertexData[o++] = i.scale.y * i.size,
  117061. this._isAnimationSheetEnabled && (this._vertexData[o++] = i.cellIndex),
  117062. this._isBillboardBased)
  117063. this.billboardMode === t.BILLBOARDMODE_STRETCHED && (this._vertexData[o++] = i.direction.x,
  117064. this._vertexData[o++] = i.direction.y,
  117065. this._vertexData[o++] = i.direction.z);
  117066. else if (i._initialDirection) {
  117067. var a = i._initialDirection;
  117068. this.isLocal && (x.TransformNormalToRef(a, this._emitterWorldMatrix, I.Vector3[0]),
  117069. a = I.Vector3[0]),
  117070. 0 === a.x && 0 === a.z && (a.x = .001),
  117071. this._vertexData[o++] = a.x,
  117072. this._vertexData[o++] = a.y,
  117073. this._vertexData[o++] = a.z
  117074. } else {
  117075. var s = i.direction;
  117076. this.isLocal && (x.TransformNormalToRef(s, this._emitterWorldMatrix, I.Vector3[0]),
  117077. s = I.Vector3[0]),
  117078. 0 === s.x && 0 === s.z && (s.x = .001),
  117079. this._vertexData[o++] = s.x,
  117080. this._vertexData[o++] = s.y,
  117081. this._vertexData[o++] = s.z
  117082. }
  117083. this._useRampGradients && i.remapData && (this._vertexData[o++] = i.remapData.x,
  117084. this._vertexData[o++] = i.remapData.y,
  117085. this._vertexData[o++] = i.remapData.z,
  117086. this._vertexData[o++] = i.remapData.w),
  117087. this._useInstancing || (this._isAnimationSheetEnabled && (0 === n ? n = this._epsilon : 1 === n && (n = 1 - this._epsilon),
  117088. 0 === r ? r = this._epsilon : 1 === r && (r = 1 - this._epsilon)),
  117089. this._vertexData[o++] = n,
  117090. this._vertexData[o++] = r)
  117091. }
  117092. ,
  117093. t.prototype._stopSubEmitters = function() {
  117094. this.activeSubSystems && (this.activeSubSystems.forEach((function(e) {
  117095. e.stop(!0)
  117096. }
  117097. )),
  117098. this.activeSubSystems = new Array)
  117099. }
  117100. ,
  117101. t.prototype._removeFromRoot = function() {
  117102. if (this._rootParticleSystem) {
  117103. var e = this._rootParticleSystem.activeSubSystems.indexOf(this);
  117104. -1 !== e && this._rootParticleSystem.activeSubSystems.splice(e, 1),
  117105. this._rootParticleSystem = null
  117106. }
  117107. }
  117108. ,
  117109. t.prototype._update = function(e) {
  117110. var t, i = this;
  117111. if (this._alive = this._particles.length > 0,
  117112. this.emitter.position) {
  117113. var n = this.emitter;
  117114. this._emitterWorldMatrix = n.getWorldMatrix()
  117115. } else {
  117116. var r = this.emitter;
  117117. this._emitterWorldMatrix = P.Translation(r.x, r.y, r.z)
  117118. }
  117119. this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),
  117120. this.updateFunction(this._particles);
  117121. for (var o = function(e) {
  117122. if (a._particles.length === a._capacity)
  117123. return "break";
  117124. if (t = a._createParticle(),
  117125. a._particles.push(t),
  117126. a.targetStopDuration && a._lifeTimeGradients && a._lifeTimeGradients.length > 0) {
  117127. var n = d.Clamp(a._actualFrame / a.targetStopDuration);
  117128. hy.GetCurrentGradient(n, a._lifeTimeGradients, (function(e, i) {
  117129. var r = e
  117130. , o = i
  117131. , a = r.getFactor()
  117132. , s = o.getFactor()
  117133. , l = (n - r.gradient) / (o.gradient - r.gradient);
  117134. t.lifeTime = d.Lerp(a, s, l)
  117135. }
  117136. ))
  117137. } else
  117138. t.lifeTime = d.RandomRange(a.minLifeTime, a.maxLifeTime);
  117139. var r = d.RandomRange(a.minEmitPower, a.maxEmitPower);
  117140. if (a.startPositionFunction ? a.startPositionFunction(a._emitterWorldMatrix, t.position, t, a.isLocal) : a.particleEmitterType.startPositionFunction(a._emitterWorldMatrix, t.position, t, a.isLocal),
  117141. a.isLocal && (t._localPosition ? t._localPosition.copyFrom(t.position) : t._localPosition = t.position.clone(),
  117142. x.TransformCoordinatesToRef(t._localPosition, a._emitterWorldMatrix, t.position)),
  117143. a.startDirectionFunction ? a.startDirectionFunction(a._emitterWorldMatrix, t.direction, t, a.isLocal) : a.particleEmitterType.startDirectionFunction(a._emitterWorldMatrix, t.direction, t, a.isLocal, a._emitterInverseWorldMatrix),
  117144. 0 === r ? t._initialDirection ? t._initialDirection.copyFrom(t.direction) : t._initialDirection = t.direction.clone() : t._initialDirection = null,
  117145. t.direction.scaleInPlace(r),
  117146. a._sizeGradients && 0 !== a._sizeGradients.length ? (t._currentSizeGradient = a._sizeGradients[0],
  117147. t._currentSize1 = t._currentSizeGradient.getFactor(),
  117148. t.size = t._currentSize1,
  117149. a._sizeGradients.length > 1 ? t._currentSize2 = a._sizeGradients[1].getFactor() : t._currentSize2 = t._currentSize1) : t.size = d.RandomRange(a.minSize, a.maxSize),
  117150. t.scale.copyFromFloats(d.RandomRange(a.minScaleX, a.maxScaleX), d.RandomRange(a.minScaleY, a.maxScaleY)),
  117151. a._startSizeGradients && a._startSizeGradients[0] && a.targetStopDuration) {
  117152. var o = a._actualFrame / a.targetStopDuration;
  117153. hy.GetCurrentGradient(o, a._startSizeGradients, (function(e, n, r) {
  117154. e !== i._currentStartSizeGradient && (i._currentStartSize1 = i._currentStartSize2,
  117155. i._currentStartSize2 = n.getFactor(),
  117156. i._currentStartSizeGradient = e);
  117157. var o = d.Lerp(i._currentStartSize1, i._currentStartSize2, r);
  117158. t.scale.scaleInPlace(o)
  117159. }
  117160. ))
  117161. }
  117162. if (a._angularSpeedGradients && 0 !== a._angularSpeedGradients.length ? (t._currentAngularSpeedGradient = a._angularSpeedGradients[0],
  117163. t.angularSpeed = t._currentAngularSpeedGradient.getFactor(),
  117164. t._currentAngularSpeed1 = t.angularSpeed,
  117165. a._angularSpeedGradients.length > 1 ? t._currentAngularSpeed2 = a._angularSpeedGradients[1].getFactor() : t._currentAngularSpeed2 = t._currentAngularSpeed1) : t.angularSpeed = d.RandomRange(a.minAngularSpeed, a.maxAngularSpeed),
  117166. t.angle = d.RandomRange(a.minInitialRotation, a.maxInitialRotation),
  117167. a._velocityGradients && a._velocityGradients.length > 0 && (t._currentVelocityGradient = a._velocityGradients[0],
  117168. t._currentVelocity1 = t._currentVelocityGradient.getFactor(),
  117169. a._velocityGradients.length > 1 ? t._currentVelocity2 = a._velocityGradients[1].getFactor() : t._currentVelocity2 = t._currentVelocity1),
  117170. a._limitVelocityGradients && a._limitVelocityGradients.length > 0 && (t._currentLimitVelocityGradient = a._limitVelocityGradients[0],
  117171. t._currentLimitVelocity1 = t._currentLimitVelocityGradient.getFactor(),
  117172. a._limitVelocityGradients.length > 1 ? t._currentLimitVelocity2 = a._limitVelocityGradients[1].getFactor() : t._currentLimitVelocity2 = t._currentLimitVelocity1),
  117173. a._dragGradients && a._dragGradients.length > 0 && (t._currentDragGradient = a._dragGradients[0],
  117174. t._currentDrag1 = t._currentDragGradient.getFactor(),
  117175. a._dragGradients.length > 1 ? t._currentDrag2 = a._dragGradients[1].getFactor() : t._currentDrag2 = t._currentDrag1),
  117176. a._colorGradients && 0 !== a._colorGradients.length)
  117177. t._currentColorGradient = a._colorGradients[0],
  117178. t._currentColorGradient.getColorToRef(t.color),
  117179. t._currentColor1.copyFrom(t.color),
  117180. a._colorGradients.length > 1 ? a._colorGradients[1].getColorToRef(t._currentColor2) : t._currentColor2.copyFrom(t.color);
  117181. else {
  117182. var s = d.RandomRange(0, 1);
  117183. N.LerpToRef(a.color1, a.color2, s, t.color),
  117184. a.colorDead.subtractToRef(t.color, a._colorDiff),
  117185. a._colorDiff.scaleToRef(1 / t.lifeTime, t.colorStep)
  117186. }
  117187. a._isAnimationSheetEnabled && (t._initialStartSpriteCellID = a.startSpriteCellID,
  117188. t._initialEndSpriteCellID = a.endSpriteCellID,
  117189. t._initialSpriteCellLoop = a.spriteCellLoop),
  117190. t.direction.addInPlace(a._inheritedVelocityOffset),
  117191. a._useRampGradients && (t.remapData = new R(0,1,0,1)),
  117192. a.noiseTexture && (t._randomNoiseCoordinates1 ? (t._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()),
  117193. t._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (t._randomNoiseCoordinates1 = new x(Math.random(),Math.random(),Math.random()),
  117194. t._randomNoiseCoordinates2 = new x(Math.random(),Math.random(),Math.random()))),
  117195. t._inheritParticleInfoToSubEmitters()
  117196. }, a = this, s = 0; s < e && "break" !== o(); s++)
  117197. ;
  117198. }
  117199. ,
  117200. t._GetAttributeNamesOrOptions = function(e, t, i) {
  117201. void 0 === e && (e = !1),
  117202. void 0 === t && (t = !1),
  117203. void 0 === i && (i = !1);
  117204. var n = [Bi.PositionKind, Bi.ColorKind, "angle", "offset", "size"];
  117205. return e && n.push("cellIndex"),
  117206. t || n.push("direction"),
  117207. i && n.push("remapData"),
  117208. n
  117209. }
  117210. ,
  117211. t._GetEffectCreationOptions = function(e) {
  117212. void 0 === e && (e = !1);
  117213. var t = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
  117214. return e && t.push("particlesInfos"),
  117215. t
  117216. }
  117217. ,
  117218. t.prototype.fillDefines = function(e, i) {
  117219. if (this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"),
  117220. this._scene.clipPlane2 && e.push("#define CLIPPLANE2"),
  117221. this._scene.clipPlane3 && e.push("#define CLIPPLANE3"),
  117222. this._scene.clipPlane4 && e.push("#define CLIPPLANE4"),
  117223. this._scene.clipPlane5 && e.push("#define CLIPPLANE5"),
  117224. this._scene.clipPlane6 && e.push("#define CLIPPLANE6")),
  117225. this._isAnimationSheetEnabled && e.push("#define ANIMATESHEET"),
  117226. i === t.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"),
  117227. this._useRampGradients && e.push("#define RAMPGRADIENT"),
  117228. this._isBillboardBased)
  117229. switch (e.push("#define BILLBOARD"),
  117230. this.billboardMode) {
  117231. case t.BILLBOARDMODE_Y:
  117232. e.push("#define BILLBOARDY");
  117233. break;
  117234. case t.BILLBOARDMODE_STRETCHED:
  117235. e.push("#define BILLBOARDSTRETCHED");
  117236. break;
  117237. case t.BILLBOARDMODE_ALL:
  117238. e.push("#define BILLBOARDMODE_ALL")
  117239. }
  117240. this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
  117241. e.push(this._imageProcessingConfigurationDefines.toString()))
  117242. }
  117243. ,
  117244. t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, n) {
  117245. i.push.apply(i, t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED, this._useRampGradients)),
  117246. e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
  117247. n.push("diffuseSampler", "rampSampler"),
  117248. this._imageProcessingConfiguration && (Ri.PrepareUniforms(e, this._imageProcessingConfigurationDefines),
  117249. Ri.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
  117250. }
  117251. ,
  117252. t.prototype._getWrapper = function(e) {
  117253. var t = this._getCustomDrawWrapper(e);
  117254. if (null == t ? void 0 : t.effect)
  117255. return t;
  117256. var i = [];
  117257. this.fillDefines(i, e);
  117258. var n = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : a.RENDERPASS_MAIN
  117259. , r = this._drawWrappers[n];
  117260. r || (r = this._drawWrappers[n] = []);
  117261. var o = r[e];
  117262. o || ((o = new Gt(this._engine)).drawContext && (o.drawContext.useInstancing = this._useInstancing),
  117263. r[e] = o);
  117264. var s = i.join("\n");
  117265. if (o.defines !== s) {
  117266. var l = []
  117267. , c = []
  117268. , u = [];
  117269. this.fillUniformsAttributesAndSamplerNames(c, l, u),
  117270. o.setEffect(this._engine.createEffect("particles", l, c, u, s), s)
  117271. }
  117272. return o
  117273. }
  117274. ,
  117275. t.prototype.animate = function(e) {
  117276. var t, i = this;
  117277. if (void 0 === e && (e = !1),
  117278. this._started) {
  117279. if (!e && this._scene) {
  117280. if (!this.isReady())
  117281. return;
  117282. if (this._currentRenderId === this._scene.getFrameId())
  117283. return;
  117284. this._currentRenderId = this._scene.getFrameId()
  117285. }
  117286. var n;
  117287. if (this._scaledUpdateSpeed = this.updateSpeed * (e ? this.preWarmStepOffset : (null === (t = this._scene) || void 0 === t ? void 0 : t.getAnimationRatio()) || 1),
  117288. this.manualEmitCount > -1)
  117289. n = this.manualEmitCount,
  117290. this._newPartsExcess = 0,
  117291. this.manualEmitCount = 0;
  117292. else {
  117293. var r = this.emitRate;
  117294. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  117295. var o = this._actualFrame / this.targetStopDuration;
  117296. hy.GetCurrentGradient(o, this._emitRateGradients, (function(e, t, n) {
  117297. e !== i._currentEmitRateGradient && (i._currentEmitRate1 = i._currentEmitRate2,
  117298. i._currentEmitRate2 = t.getFactor(),
  117299. i._currentEmitRateGradient = e),
  117300. r = d.Lerp(i._currentEmitRate1, i._currentEmitRate2, n)
  117301. }
  117302. ))
  117303. }
  117304. n = r * this._scaledUpdateSpeed >> 0,
  117305. this._newPartsExcess += r * this._scaledUpdateSpeed - n
  117306. }
  117307. if (this._newPartsExcess > 1 && (n += this._newPartsExcess >> 0,
  117308. this._newPartsExcess -= this._newPartsExcess >> 0),
  117309. this._alive = !1,
  117310. this._stopped ? n = 0 : (this._actualFrame += this._scaledUpdateSpeed,
  117311. this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()),
  117312. this._update(n),
  117313. this._stopped && (this._alive || (this._started = !1,
  117314. this.onAnimationEnd && this.onAnimationEnd(),
  117315. this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))),
  117316. !e) {
  117317. for (var a = 0, s = 0; s < this._particles.length; s++) {
  117318. var l = this._particles[s];
  117319. this._appendParticleVertices(a, l),
  117320. a += this._useInstancing ? 1 : 4
  117321. }
  117322. this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length)
  117323. }
  117324. 0 === this.manualEmitCount && this.disposeOnStop && this.stop()
  117325. }
  117326. }
  117327. ,
  117328. t.prototype._appendParticleVertices = function(e, t) {
  117329. this._appendParticleVertex(e++, t, 0, 0),
  117330. this._useInstancing || (this._appendParticleVertex(e++, t, 1, 0),
  117331. this._appendParticleVertex(e++, t, 1, 1),
  117332. this._appendParticleVertex(e++, t, 0, 1))
  117333. }
  117334. ,
  117335. t.prototype.rebuild = function() {
  117336. var e, t;
  117337. for (var i in this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null),
  117338. this._createIndexBuffer(),
  117339. null === (e = this._spriteBuffer) || void 0 === e || e._rebuild(),
  117340. null === (t = this._vertexBuffer) || void 0 === t || t._rebuild(),
  117341. this._vertexBuffers)
  117342. this._vertexBuffers[i]._rebuild();
  117343. this.resetDrawCache()
  117344. }
  117345. ,
  117346. t.prototype.isReady = function() {
  117347. if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
  117348. return !1;
  117349. if (this.blendMode !== t.BLENDMODE_MULTIPLYADD) {
  117350. if (!this._getWrapper(this.blendMode).effect.isReady())
  117351. return !1
  117352. } else {
  117353. if (!this._getWrapper(t.BLENDMODE_MULTIPLY).effect.isReady())
  117354. return !1;
  117355. if (!this._getWrapper(t.BLENDMODE_ADD).effect.isReady())
  117356. return !1
  117357. }
  117358. return !0
  117359. }
  117360. ,
  117361. t.prototype._render = function(e) {
  117362. var i, n, r = this._getWrapper(e), o = r.effect, s = this._engine;
  117363. s.enableEffect(r);
  117364. var l = null !== (i = this.defaultViewMatrix) && void 0 !== i ? i : this._scene.getViewMatrix();
  117365. if (o.setTexture("diffuseSampler", this.particleTexture),
  117366. o.setMatrix("view", l),
  117367. o.setMatrix("projection", null !== (n = this.defaultProjectionMatrix) && void 0 !== n ? n : this._scene.getProjectionMatrix()),
  117368. this._isAnimationSheetEnabled && this.particleTexture) {
  117369. var c = this.particleTexture.getBaseSize();
  117370. o.setFloat3("particlesInfos", this.spriteCellWidth / c.width, this.spriteCellHeight / c.height, this.spriteCellWidth / c.width)
  117371. }
  117372. if (o.setVector2("translationPivot", this.translationPivot),
  117373. o.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a),
  117374. this._isBillboardBased && this._scene) {
  117375. var u = this._scene.activeCamera;
  117376. o.setVector3("eyePosition", u.globalPosition)
  117377. }
  117378. this._rampGradientsTexture && (this._rampGradients && this._rampGradients.length || (this._rampGradientsTexture.dispose(),
  117379. this._rampGradientsTexture = null),
  117380. o.setTexture("rampSampler", this._rampGradientsTexture));
  117381. var h = o.defines;
  117382. switch (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && Pr.BindClipPlane(o, this._scene),
  117383. h.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (l.invertToRef(I.Matrix[0]),
  117384. o.setMatrix("invView", I.Matrix[0])),
  117385. void 0 !== this._vertexArrayObject ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, o)),
  117386. this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : s.bindBuffers(this._vertexBuffers, this._indexBuffer, o),
  117387. this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o),
  117388. e) {
  117389. case t.BLENDMODE_ADD:
  117390. s.setAlphaMode(a.ALPHA_ADD);
  117391. break;
  117392. case t.BLENDMODE_ONEONE:
  117393. s.setAlphaMode(a.ALPHA_ONEONE);
  117394. break;
  117395. case t.BLENDMODE_STANDARD:
  117396. s.setAlphaMode(a.ALPHA_COMBINE);
  117397. break;
  117398. case t.BLENDMODE_MULTIPLY:
  117399. s.setAlphaMode(a.ALPHA_MULTIPLY)
  117400. }
  117401. return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o),
  117402. this._useInstancing ? s.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._particles.length) : s.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6 * this._particles.length),
  117403. this._particles.length
  117404. }
  117405. ,
  117406. t.prototype.render = function() {
  117407. if (!this.isReady() || !this._particles.length)
  117408. return 0;
  117409. var e = this._engine;
  117410. e.setState && (e.setState(!1),
  117411. this.forceDepthWrite && e.setDepthWrite(!0));
  117412. var i;
  117413. return i = this.blendMode === t.BLENDMODE_MULTIPLYADD ? this._render(t.BLENDMODE_MULTIPLY) + this._render(t.BLENDMODE_ADD) : this._render(this.blendMode),
  117414. this._engine.unbindInstanceAttributes(),
  117415. this._engine.setAlphaMode(a.ALPHA_DISABLE),
  117416. i
  117417. }
  117418. ,
  117419. t.prototype.dispose = function(e) {
  117420. if (void 0 === e && (e = !0),
  117421. this.resetDrawCache(),
  117422. this._vertexBuffer && (this._vertexBuffer.dispose(),
  117423. this._vertexBuffer = null),
  117424. this._spriteBuffer && (this._spriteBuffer.dispose(),
  117425. this._spriteBuffer = null),
  117426. this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
  117427. this._indexBuffer = null),
  117428. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  117429. this._vertexArrayObject = null),
  117430. e && this.particleTexture && (this.particleTexture.dispose(),
  117431. this.particleTexture = null),
  117432. e && this.noiseTexture && (this.noiseTexture.dispose(),
  117433. this.noiseTexture = null),
  117434. this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
  117435. this._rampGradientsTexture = null),
  117436. this._removeFromRoot(),
  117437. this.subEmitters && !this._subEmitters && this._prepareSubEmitterInternalArray(),
  117438. this._subEmitters && this._subEmitters.length) {
  117439. for (var t = 0; t < this._subEmitters.length; t++)
  117440. for (var i = 0, n = this._subEmitters[t]; i < n.length; i++)
  117441. n[i].dispose();
  117442. this._subEmitters = [],
  117443. this.subEmitters = []
  117444. }
  117445. this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0),
  117446. this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(),
  117447. this._scene && ((t = this._scene.particleSystems.indexOf(this)) > -1 && this._scene.particleSystems.splice(t, 1),
  117448. this._scene._activeParticleSystems.dispose()),
  117449. this.onDisposeObservable.notifyObservers(this),
  117450. this.onDisposeObservable.clear(),
  117451. this.onStoppedObservable.clear(),
  117452. this.reset()
  117453. }
  117454. ,
  117455. t.prototype.clone = function(e, i) {
  117456. var n = V({}, this._customWrappers)
  117457. , r = null
  117458. , o = this._engine;
  117459. if (o.createEffectForParticles && null != this.customShader) {
  117460. var a = (r = this.customShader).shaderOptions.defines.length > 0 ? r.shaderOptions.defines.join("\n") : ""
  117461. , s = o.createEffectForParticles(r.shaderPath.fragmentElement, r.shaderOptions.uniforms, r.shaderOptions.samplers, a);
  117462. n[0] ? n[0].effect = s : this.setCustomEffect(s, 0)
  117463. }
  117464. var l = this.serialize()
  117465. , c = t.Parse(l, this._scene || this._engine, this._rootUrl);
  117466. return c.name = e,
  117467. c.customShader = r,
  117468. c._customWrappers = n,
  117469. void 0 === i && (i = this.emitter),
  117470. this.noiseTexture && (c.noiseTexture = this.noiseTexture.clone()),
  117471. c.emitter = i,
  117472. this.preventAutoStart || c.start(),
  117473. c
  117474. }
  117475. ,
  117476. t.prototype.serialize = function(e) {
  117477. void 0 === e && (e = !1);
  117478. var i = {};
  117479. if (t._Serialize(i, this, e),
  117480. i.textureMask = this.textureMask.asArray(),
  117481. i.customShader = this.customShader,
  117482. i.preventAutoStart = this.preventAutoStart,
  117483. this.subEmitters) {
  117484. i.subEmitters = [],
  117485. this._subEmitters || this._prepareSubEmitterInternalArray();
  117486. for (var n = 0, r = this._subEmitters; n < r.length; n++) {
  117487. for (var o = [], a = 0, s = r[n]; a < s.length; a++) {
  117488. var l = s[a];
  117489. o.push(l.serialize(e))
  117490. }
  117491. i.subEmitters.push(o)
  117492. }
  117493. }
  117494. return i
  117495. }
  117496. ,
  117497. t._Serialize = function(e, t, i) {
  117498. if (e.name = t.name,
  117499. e.id = t.id,
  117500. e.capacity = t.getCapacity(),
  117501. e.disposeOnStop = t.disposeOnStop,
  117502. e.manualEmitCount = t.manualEmitCount,
  117503. t.emitter.position) {
  117504. var n = t.emitter;
  117505. e.emitterId = n.id
  117506. } else {
  117507. var r = t.emitter;
  117508. e.emitter = r.asArray()
  117509. }
  117510. t.particleEmitterType && (e.particleEmitterType = t.particleEmitterType.serialize()),
  117511. t.particleTexture && (i ? e.texture = t.particleTexture.serialize() : (e.textureName = t.particleTexture.name,
  117512. e.invertY = !!t.particleTexture._invertY)),
  117513. e.isLocal = t.isLocal,
  117514. Ge.AppendSerializedAnimations(t, e),
  117515. e.beginAnimationOnStart = t.beginAnimationOnStart,
  117516. e.beginAnimationFrom = t.beginAnimationFrom,
  117517. e.beginAnimationTo = t.beginAnimationTo,
  117518. e.beginAnimationLoop = t.beginAnimationLoop,
  117519. e.startDelay = t.startDelay,
  117520. e.renderingGroupId = t.renderingGroupId,
  117521. e.isBillboardBased = t.isBillboardBased,
  117522. e.billboardMode = t.billboardMode,
  117523. e.minAngularSpeed = t.minAngularSpeed,
  117524. e.maxAngularSpeed = t.maxAngularSpeed,
  117525. e.minSize = t.minSize,
  117526. e.maxSize = t.maxSize,
  117527. e.minScaleX = t.minScaleX,
  117528. e.maxScaleX = t.maxScaleX,
  117529. e.minScaleY = t.minScaleY,
  117530. e.maxScaleY = t.maxScaleY,
  117531. e.minEmitPower = t.minEmitPower,
  117532. e.maxEmitPower = t.maxEmitPower,
  117533. e.minLifeTime = t.minLifeTime,
  117534. e.maxLifeTime = t.maxLifeTime,
  117535. e.emitRate = t.emitRate,
  117536. e.gravity = t.gravity.asArray(),
  117537. e.noiseStrength = t.noiseStrength.asArray(),
  117538. e.color1 = t.color1.asArray(),
  117539. e.color2 = t.color2.asArray(),
  117540. e.colorDead = t.colorDead.asArray(),
  117541. e.updateSpeed = t.updateSpeed,
  117542. e.targetStopDuration = t.targetStopDuration,
  117543. e.blendMode = t.blendMode,
  117544. e.preWarmCycles = t.preWarmCycles,
  117545. e.preWarmStepOffset = t.preWarmStepOffset,
  117546. e.minInitialRotation = t.minInitialRotation,
  117547. e.maxInitialRotation = t.maxInitialRotation,
  117548. e.startSpriteCellID = t.startSpriteCellID,
  117549. e.spriteCellLoop = t.spriteCellLoop,
  117550. e.endSpriteCellID = t.endSpriteCellID,
  117551. e.spriteCellChangeSpeed = t.spriteCellChangeSpeed,
  117552. e.spriteCellWidth = t.spriteCellWidth,
  117553. e.spriteCellHeight = t.spriteCellHeight,
  117554. e.spriteRandomStartCell = t.spriteRandomStartCell,
  117555. e.isAnimationSheetEnabled = t.isAnimationSheetEnabled;
  117556. var o = t.getColorGradients();
  117557. if (o) {
  117558. e.colorGradients = [];
  117559. for (var a = 0, s = o; a < s.length; a++) {
  117560. var l = s[a]
  117561. , c = {
  117562. gradient: l.gradient,
  117563. color1: l.color1.asArray()
  117564. };
  117565. l.color2 ? c.color2 = l.color2.asArray() : c.color2 = l.color1.asArray(),
  117566. e.colorGradients.push(c)
  117567. }
  117568. }
  117569. var u = t.getRampGradients();
  117570. if (u) {
  117571. e.rampGradients = [];
  117572. for (var h = 0, d = u; h < d.length; h++) {
  117573. var p = d[h];
  117574. c = {
  117575. gradient: p.gradient,
  117576. color: p.color.asArray()
  117577. },
  117578. e.rampGradients.push(c)
  117579. }
  117580. e.useRampGradients = t.useRampGradients
  117581. }
  117582. var f = t.getColorRemapGradients();
  117583. if (f) {
  117584. e.colorRemapGradients = [];
  117585. for (var _ = 0, m = f; _ < m.length; _++) {
  117586. var g = m[_];
  117587. c = {
  117588. gradient: g.gradient,
  117589. factor1: g.factor1
  117590. },
  117591. void 0 !== g.factor2 ? c.factor2 = g.factor2 : c.factor2 = g.factor1,
  117592. e.colorRemapGradients.push(c)
  117593. }
  117594. }
  117595. var v = t.getAlphaRemapGradients();
  117596. if (v) {
  117597. e.alphaRemapGradients = [];
  117598. for (var y = 0, b = v; y < b.length; y++) {
  117599. var T = b[y];
  117600. c = {
  117601. gradient: T.gradient,
  117602. factor1: T.factor1
  117603. },
  117604. void 0 !== T.factor2 ? c.factor2 = T.factor2 : c.factor2 = T.factor1,
  117605. e.alphaRemapGradients.push(c)
  117606. }
  117607. }
  117608. var E = t.getSizeGradients();
  117609. if (E) {
  117610. e.sizeGradients = [];
  117611. for (var S = 0, A = E; S < A.length; S++) {
  117612. var x = A[S];
  117613. c = {
  117614. gradient: x.gradient,
  117615. factor1: x.factor1
  117616. },
  117617. void 0 !== x.factor2 ? c.factor2 = x.factor2 : c.factor2 = x.factor1,
  117618. e.sizeGradients.push(c)
  117619. }
  117620. }
  117621. var R = t.getAngularSpeedGradients();
  117622. if (R) {
  117623. e.angularSpeedGradients = [];
  117624. for (var C = 0, P = R; C < P.length; C++) {
  117625. var M = P[C];
  117626. c = {
  117627. gradient: M.gradient,
  117628. factor1: M.factor1
  117629. },
  117630. void 0 !== M.factor2 ? c.factor2 = M.factor2 : c.factor2 = M.factor1,
  117631. e.angularSpeedGradients.push(c)
  117632. }
  117633. }
  117634. var I = t.getVelocityGradients();
  117635. if (I) {
  117636. e.velocityGradients = [];
  117637. for (var O = 0, D = I; O < D.length; O++) {
  117638. var N = D[O];
  117639. c = {
  117640. gradient: N.gradient,
  117641. factor1: N.factor1
  117642. },
  117643. void 0 !== N.factor2 ? c.factor2 = N.factor2 : c.factor2 = N.factor1,
  117644. e.velocityGradients.push(c)
  117645. }
  117646. }
  117647. var L = t.getDragGradients();
  117648. if (L) {
  117649. e.dragGradients = [];
  117650. for (var F = 0, w = L; F < w.length; F++) {
  117651. var B = w[F];
  117652. c = {
  117653. gradient: B.gradient,
  117654. factor1: B.factor1
  117655. },
  117656. void 0 !== B.factor2 ? c.factor2 = B.factor2 : c.factor2 = B.factor1,
  117657. e.dragGradients.push(c)
  117658. }
  117659. }
  117660. var U = t.getEmitRateGradients();
  117661. if (U) {
  117662. e.emitRateGradients = [];
  117663. for (var V = 0, k = U; V < k.length; V++) {
  117664. var G = k[V];
  117665. c = {
  117666. gradient: G.gradient,
  117667. factor1: G.factor1
  117668. },
  117669. void 0 !== G.factor2 ? c.factor2 = G.factor2 : c.factor2 = G.factor1,
  117670. e.emitRateGradients.push(c)
  117671. }
  117672. }
  117673. var z = t.getStartSizeGradients();
  117674. if (z) {
  117675. e.startSizeGradients = [];
  117676. for (var W = 0, H = z; W < H.length; W++) {
  117677. var X = H[W];
  117678. c = {
  117679. gradient: X.gradient,
  117680. factor1: X.factor1
  117681. },
  117682. void 0 !== X.factor2 ? c.factor2 = X.factor2 : c.factor2 = X.factor1,
  117683. e.startSizeGradients.push(c)
  117684. }
  117685. }
  117686. var j = t.getLifeTimeGradients();
  117687. if (j) {
  117688. e.lifeTimeGradients = [];
  117689. for (var Y = 0, K = j; Y < K.length; Y++) {
  117690. var Q = K[Y];
  117691. c = {
  117692. gradient: Q.gradient,
  117693. factor1: Q.factor1
  117694. },
  117695. void 0 !== Q.factor2 ? c.factor2 = Q.factor2 : c.factor2 = Q.factor1,
  117696. e.lifeTimeGradients.push(c)
  117697. }
  117698. }
  117699. var q = t.getLimitVelocityGradients();
  117700. if (q) {
  117701. e.limitVelocityGradients = [];
  117702. for (var Z = 0, J = q; Z < J.length; Z++) {
  117703. var $ = J[Z];
  117704. c = {
  117705. gradient: $.gradient,
  117706. factor1: $.factor1
  117707. },
  117708. void 0 !== $.factor2 ? c.factor2 = $.factor2 : c.factor2 = $.factor1,
  117709. e.limitVelocityGradients.push(c)
  117710. }
  117711. e.limitVelocityDamping = t.limitVelocityDamping
  117712. }
  117713. t.noiseTexture && (e.noiseTexture = t.noiseTexture.serialize())
  117714. }
  117715. ,
  117716. t._Parse = function(e, t, i, n) {
  117717. var r, o, a, s;
  117718. s = i instanceof Ht ? null : i;
  117719. var l, c = b("BABYLON.Texture");
  117720. if (c && s && (e.texture ? t.particleTexture = c.Parse(e.texture, s, n) : e.textureName && (t.particleTexture = new c(n + e.textureName,s,!1,void 0 === e.invertY || e.invertY),
  117721. t.particleTexture.name = e.textureName)),
  117722. e.emitterId || 0 === e.emitterId || void 0 !== e.emitter ? e.emitterId && s ? t.emitter = s.getLastMeshById(e.emitterId) : t.emitter = x.FromArray(e.emitter) : t.emitter = x.Zero(),
  117723. t.isLocal = !!e.isLocal,
  117724. void 0 !== e.renderingGroupId && (t.renderingGroupId = e.renderingGroupId),
  117725. void 0 !== e.isBillboardBased && (t.isBillboardBased = e.isBillboardBased),
  117726. void 0 !== e.billboardMode && (t.billboardMode = e.billboardMode),
  117727. e.animations) {
  117728. for (var u = 0; u < e.animations.length; u++) {
  117729. var h = e.animations[u]
  117730. , d = b("BABYLON.Animation");
  117731. d && t.animations.push(d.Parse(h))
  117732. }
  117733. t.beginAnimationOnStart = e.beginAnimationOnStart,
  117734. t.beginAnimationFrom = e.beginAnimationFrom,
  117735. t.beginAnimationTo = e.beginAnimationTo,
  117736. t.beginAnimationLoop = e.beginAnimationLoop
  117737. }
  117738. if (e.autoAnimate && s && s.beginAnimation(t, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
  117739. t.startDelay = 0 | e.startDelay,
  117740. t.minAngularSpeed = e.minAngularSpeed,
  117741. t.maxAngularSpeed = e.maxAngularSpeed,
  117742. t.minSize = e.minSize,
  117743. t.maxSize = e.maxSize,
  117744. e.minScaleX && (t.minScaleX = e.minScaleX,
  117745. t.maxScaleX = e.maxScaleX,
  117746. t.minScaleY = e.minScaleY,
  117747. t.maxScaleY = e.maxScaleY),
  117748. void 0 !== e.preWarmCycles && (t.preWarmCycles = e.preWarmCycles,
  117749. t.preWarmStepOffset = e.preWarmStepOffset),
  117750. void 0 !== e.minInitialRotation && (t.minInitialRotation = e.minInitialRotation,
  117751. t.maxInitialRotation = e.maxInitialRotation),
  117752. t.minLifeTime = e.minLifeTime,
  117753. t.maxLifeTime = e.maxLifeTime,
  117754. t.minEmitPower = e.minEmitPower,
  117755. t.maxEmitPower = e.maxEmitPower,
  117756. t.emitRate = e.emitRate,
  117757. t.gravity = x.FromArray(e.gravity),
  117758. e.noiseStrength && (t.noiseStrength = x.FromArray(e.noiseStrength)),
  117759. t.color1 = N.FromArray(e.color1),
  117760. t.color2 = N.FromArray(e.color2),
  117761. t.colorDead = N.FromArray(e.colorDead),
  117762. t.updateSpeed = e.updateSpeed,
  117763. t.targetStopDuration = e.targetStopDuration,
  117764. t.blendMode = e.blendMode,
  117765. e.colorGradients)
  117766. for (var p = 0, f = e.colorGradients; p < f.length; p++) {
  117767. var _ = f[p];
  117768. t.addColorGradient(_.gradient, N.FromArray(_.color1), _.color2 ? N.FromArray(_.color2) : void 0)
  117769. }
  117770. if (e.rampGradients) {
  117771. for (var m = 0, g = e.rampGradients; m < g.length; m++) {
  117772. var v = g[m];
  117773. t.addRampGradient(v.gradient, D.FromArray(v.color))
  117774. }
  117775. t.useRampGradients = e.useRampGradients
  117776. }
  117777. if (e.colorRemapGradients)
  117778. for (var y = 0, T = e.colorRemapGradients; y < T.length; y++) {
  117779. var E = T[y];
  117780. t.addColorRemapGradient(E.gradient, void 0 !== E.factor1 ? E.factor1 : E.factor, E.factor2)
  117781. }
  117782. if (e.alphaRemapGradients)
  117783. for (var S = 0, A = e.alphaRemapGradients; S < A.length; S++) {
  117784. var R = A[S];
  117785. t.addAlphaRemapGradient(R.gradient, void 0 !== R.factor1 ? R.factor1 : R.factor, R.factor2)
  117786. }
  117787. if (e.sizeGradients)
  117788. for (var C = 0, P = e.sizeGradients; C < P.length; C++) {
  117789. var M = P[C];
  117790. t.addSizeGradient(M.gradient, void 0 !== M.factor1 ? M.factor1 : M.factor, M.factor2)
  117791. }
  117792. if (e.angularSpeedGradients)
  117793. for (var I = 0, O = e.angularSpeedGradients; I < O.length; I++) {
  117794. var L = O[I];
  117795. t.addAngularSpeedGradient(L.gradient, void 0 !== L.factor1 ? L.factor1 : L.factor, L.factor2)
  117796. }
  117797. if (e.velocityGradients)
  117798. for (var F = 0, w = e.velocityGradients; F < w.length; F++) {
  117799. var B = w[F];
  117800. t.addVelocityGradient(B.gradient, void 0 !== B.factor1 ? B.factor1 : B.factor, B.factor2)
  117801. }
  117802. if (e.dragGradients)
  117803. for (var U = 0, V = e.dragGradients; U < V.length; U++) {
  117804. var k = V[U];
  117805. t.addDragGradient(k.gradient, void 0 !== k.factor1 ? k.factor1 : k.factor, k.factor2)
  117806. }
  117807. if (e.emitRateGradients)
  117808. for (var G = 0, z = e.emitRateGradients; G < z.length; G++) {
  117809. var W = z[G];
  117810. t.addEmitRateGradient(W.gradient, void 0 !== W.factor1 ? W.factor1 : W.factor, W.factor2)
  117811. }
  117812. if (e.startSizeGradients)
  117813. for (var H = 0, X = e.startSizeGradients; H < X.length; H++) {
  117814. var j = X[H];
  117815. t.addStartSizeGradient(j.gradient, void 0 !== j.factor1 ? j.factor1 : j.factor, j.factor2)
  117816. }
  117817. if (e.lifeTimeGradients)
  117818. for (var Y = 0, K = e.lifeTimeGradients; Y < K.length; Y++) {
  117819. var Q = K[Y];
  117820. t.addLifeTimeGradient(Q.gradient, void 0 !== Q.factor1 ? Q.factor1 : Q.factor, Q.factor2)
  117821. }
  117822. if (e.limitVelocityGradients) {
  117823. for (var q = 0, Z = e.limitVelocityGradients; q < Z.length; q++) {
  117824. var J = Z[q];
  117825. t.addLimitVelocityGradient(J.gradient, void 0 !== J.factor1 ? J.factor1 : J.factor, J.factor2)
  117826. }
  117827. t.limitVelocityDamping = e.limitVelocityDamping
  117828. }
  117829. if (e.noiseTexture && s) {
  117830. var $ = b("BABYLON.ProceduralTexture");
  117831. t.noiseTexture = $.Parse(e.noiseTexture, s, n)
  117832. }
  117833. if (e.particleEmitterType) {
  117834. switch (e.particleEmitterType.type) {
  117835. case "SphereParticleEmitter":
  117836. l = new gf;
  117837. break;
  117838. case "SphereDirectedParticleEmitter":
  117839. l = new vf;
  117840. break;
  117841. case "ConeEmitter":
  117842. case "ConeParticleEmitter":
  117843. l = new df;
  117844. break;
  117845. case "CylinderParticleEmitter":
  117846. l = new pf;
  117847. break;
  117848. case "CylinderDirectedParticleEmitter":
  117849. l = new ff;
  117850. break;
  117851. case "HemisphericParticleEmitter":
  117852. l = new _f;
  117853. break;
  117854. case "PointParticleEmitter":
  117855. l = new mf;
  117856. break;
  117857. case "MeshParticleEmitter":
  117858. l = new bf;
  117859. break;
  117860. default:
  117861. l = new hf
  117862. }
  117863. l.parse(e.particleEmitterType, s)
  117864. } else
  117865. (l = new hf).parse(e, s);
  117866. t.particleEmitterType = l,
  117867. t.startSpriteCellID = e.startSpriteCellID,
  117868. t.endSpriteCellID = e.endSpriteCellID,
  117869. t.spriteCellLoop = null === (r = e.spriteCellLoop) || void 0 === r || r,
  117870. t.spriteCellWidth = e.spriteCellWidth,
  117871. t.spriteCellHeight = e.spriteCellHeight,
  117872. t.spriteCellChangeSpeed = e.spriteCellChangeSpeed,
  117873. t.spriteRandomStartCell = e.spriteRandomStartCell,
  117874. t.disposeOnStop = null !== (o = e.disposeOnStop) && void 0 !== o && o,
  117875. t.manualEmitCount = null !== (a = e.manualEmitCount) && void 0 !== a ? a : -1
  117876. }
  117877. ,
  117878. t.Parse = function(e, i, n, r, o) {
  117879. void 0 === r && (r = !1);
  117880. var a, s = e.name, l = null, c = null;
  117881. if (a = i instanceof Ht ? i : i.getEngine(),
  117882. e.customShader && a.createEffectForParticles) {
  117883. var u = (c = e.customShader).shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join("\n") : "";
  117884. l = a.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, u)
  117885. }
  117886. var h = new t(s,o || e.capacity,i,l,e.isAnimationSheetEnabled);
  117887. if (h.customShader = c,
  117888. h._rootUrl = n,
  117889. e.id && (h.id = e.id),
  117890. e.subEmitters) {
  117891. h.subEmitters = [];
  117892. for (var d = 0, p = e.subEmitters; d < p.length; d++) {
  117893. for (var f = [], _ = 0, m = p[d]; _ < m.length; _++) {
  117894. var g = m[_];
  117895. f.push(py.Parse(g, i, n))
  117896. }
  117897. h.subEmitters.push(f)
  117898. }
  117899. }
  117900. return t._Parse(e, h, i, n),
  117901. e.textureMask && (h.textureMask = N.FromArray(e.textureMask)),
  117902. e.preventAutoStart && (h.preventAutoStart = e.preventAutoStart),
  117903. r || h.preventAutoStart || h.start(),
  117904. h
  117905. }
  117906. ,
  117907. t.BILLBOARDMODE_Y = a.PARTICLES_BILLBOARDMODE_Y,
  117908. t.BILLBOARDMODE_ALL = a.PARTICLES_BILLBOARDMODE_ALL,
  117909. t.BILLBOARDMODE_STRETCHED = a.PARTICLES_BILLBOARDMODE_STRETCHED,
  117910. t
  117911. }(Tf);
  117912. py._ParseParticleSystem = fy.Parse;
  117913. Pt.IncludesShadersStore.clipPlaneFragmentDeclaration2 = "#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nin float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nin float fClipDistance6;\n#endif\n";
  117914. Pt.ShadersStore.gpuRenderParticlesPixelShader = "precision highp float;\nuniform sampler2D diffuseSampler;\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<clipPlaneFragmentDeclaration2> \n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment> \nvec4 textureColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\ngl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif \n#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\ngl_FragColor=applyImageProcessing(gl_FragColor);\n#endif\n#endif\n}\n";
  117915. Pt.IncludesShadersStore.clipPlaneVertexDeclaration2 = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nout float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nout float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nout float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nout float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nout float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nout float fClipDistance6;\n#endif\n";
  117916. Pt.ShadersStore.gpuRenderParticlesVertexShader = "precision highp float;\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n#ifdef LOCAL\nuniform mat4 emitterWM;\n#endif\nattribute vec3 position;\nattribute float age;\nattribute float life;\nattribute vec3 size;\n#ifndef BILLBOARD\nattribute vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\nattribute float angle;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\nattribute vec2 offset;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vPositionW;\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nattribute vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture2D(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvPositionW=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n#ifdef LOCAL\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\n#else\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\nvPositionW=(invView*viewPosition).xyz;\n#endif\n#else\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvPositionW=rotate(yaxis,rotatedCorner);\nvec4 viewPosition=view*vec4(vPositionW,1.0);\n#endif\ngl_Position=projection*viewPosition;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n}";
  117917. var _y = function(e) {
  117918. function t(t, i, n, r, o) {
  117919. void 0 === r && (r = null),
  117920. void 0 === o && (o = !1);
  117921. var s = e.call(this, t) || this;
  117922. if (s.layerMask = 268435455,
  117923. s._accumulatedCount = 0,
  117924. s._targetIndex = 0,
  117925. s._currentRenderId = -1,
  117926. s._currentRenderingCameraUniqueId = -1,
  117927. s._started = !1,
  117928. s._stopped = !1,
  117929. s._timeDelta = 0,
  117930. s._actualFrame = 0,
  117931. s._rawTextureWidth = 256,
  117932. s.onDisposeObservable = new h,
  117933. s.onStoppedObservable = new h,
  117934. s.forceDepthWrite = !1,
  117935. s._preWarmDone = !1,
  117936. s.isLocal = !1,
  117937. s._onBeforeDrawParticlesObservable = null,
  117938. n && "Scene" !== n.getClassName() ? (s._engine = n,
  117939. s.defaultProjectionMatrix = P.PerspectiveFovLH(.8, 1, .1, 100, s._engine.isNDCHalfZRange)) : (s._scene = n || E.LastCreatedScene,
  117940. s._engine = s._scene.getEngine(),
  117941. s.uniqueId = s._scene.getUniqueId(),
  117942. s._scene.particleSystems.push(s)),
  117943. s._engine.getCaps().supportComputeShaders) {
  117944. if (!b("BABYLON.ComputeShaderParticleSystem"))
  117945. throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
  117946. s._platform = new (b("BABYLON.ComputeShaderParticleSystem"))(s,s._engine)
  117947. } else {
  117948. if (!b("BABYLON.WebGL2ParticleSystem"))
  117949. throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
  117950. s._platform = new (b("BABYLON.WebGL2ParticleSystem"))(s,s._engine)
  117951. }
  117952. s._customWrappers = {
  117953. 0: new Gt(s._engine)
  117954. },
  117955. s._customWrappers[0].effect = r,
  117956. s._drawWrappers = {
  117957. 0: new Gt(s._engine)
  117958. },
  117959. s._drawWrappers[0].drawContext && (s._drawWrappers[0].drawContext.useInstancing = !0),
  117960. s._attachImageProcessingConfiguration(null),
  117961. (i = null != i ? i : {}).randomTextureSize || delete i.randomTextureSize;
  117962. var l = V({
  117963. capacity: 5e4,
  117964. randomTextureSize: s._engine.getCaps().maxTextureSize
  117965. }, i)
  117966. , c = i;
  117967. isFinite(c) && (l.capacity = c),
  117968. s._capacity = l.capacity,
  117969. s._activeCount = l.capacity,
  117970. s._currentActiveCount = 0,
  117971. s._isAnimationSheetEnabled = o,
  117972. s.particleEmitterType = new hf;
  117973. for (var u = Math.min(s._engine.getCaps().maxTextureSize, l.randomTextureSize), d = [], p = 0; p < u; ++p)
  117974. d.push(Math.random()),
  117975. d.push(Math.random()),
  117976. d.push(Math.random()),
  117977. d.push(Math.random());
  117978. for (s._randomTexture = new ao(new Float32Array(d),u,1,a.TEXTUREFORMAT_RGBA,n,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE,a.TEXTURETYPE_FLOAT),
  117979. s._randomTexture.name = "GPUParticleSystem_random1",
  117980. s._randomTexture.wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
  117981. s._randomTexture.wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
  117982. d = [],
  117983. p = 0; p < u; ++p)
  117984. d.push(Math.random()),
  117985. d.push(Math.random()),
  117986. d.push(Math.random()),
  117987. d.push(Math.random());
  117988. return s._randomTexture2 = new ao(new Float32Array(d),u,1,a.TEXTUREFORMAT_RGBA,n,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE,a.TEXTURETYPE_FLOAT),
  117989. s._randomTexture2.name = "GPUParticleSystem_random2",
  117990. s._randomTexture2.wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
  117991. s._randomTexture2.wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
  117992. s._randomTextureSize = u,
  117993. s
  117994. }
  117995. return U(t, e),
  117996. Object.defineProperty(t, "IsSupported", {
  117997. get: function() {
  117998. if (!E.LastCreatedEngine)
  117999. return !1;
  118000. var e = E.LastCreatedEngine.getCaps();
  118001. return e.supportTransformFeedbacks || e.supportComputeShaders
  118002. },
  118003. enumerable: !1,
  118004. configurable: !0
  118005. }),
  118006. t.prototype.getCapacity = function() {
  118007. return this._capacity
  118008. }
  118009. ,
  118010. Object.defineProperty(t.prototype, "activeParticleCount", {
  118011. get: function() {
  118012. return this._activeCount
  118013. },
  118014. set: function(e) {
  118015. this._activeCount = Math.min(e, this._capacity)
  118016. },
  118017. enumerable: !1,
  118018. configurable: !0
  118019. }),
  118020. t.prototype.isReady = function() {
  118021. if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
  118022. return !1;
  118023. if (this.blendMode !== fy.BLENDMODE_MULTIPLYADD) {
  118024. if (!this._getWrapper(this.blendMode).effect.isReady())
  118025. return !1
  118026. } else {
  118027. if (!this._getWrapper(fy.BLENDMODE_MULTIPLY).effect.isReady())
  118028. return !1;
  118029. if (!this._getWrapper(fy.BLENDMODE_ADD).effect.isReady())
  118030. return !1
  118031. }
  118032. return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(),
  118033. !1)
  118034. }
  118035. ,
  118036. t.prototype.isStarted = function() {
  118037. return this._started
  118038. }
  118039. ,
  118040. t.prototype.isStopped = function() {
  118041. return this._stopped
  118042. }
  118043. ,
  118044. t.prototype.isStopping = function() {
  118045. return !1
  118046. }
  118047. ,
  118048. t.prototype.getActiveCount = function() {
  118049. return this._currentActiveCount
  118050. }
  118051. ,
  118052. t.prototype.start = function(e) {
  118053. var t = this;
  118054. if (void 0 === e && (e = this.startDelay),
  118055. !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
  118056. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  118057. e ? setTimeout((function() {
  118058. t.start(0)
  118059. }
  118060. ), e) : (this._started = !0,
  118061. this._stopped = !1,
  118062. this._preWarmDone = !1,
  118063. this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop))
  118064. }
  118065. ,
  118066. t.prototype.stop = function() {
  118067. this._stopped || (this._stopped = !0)
  118068. }
  118069. ,
  118070. t.prototype.reset = function() {
  118071. this._releaseBuffers(),
  118072. this._platform.releaseVertexBuffers(),
  118073. this._currentActiveCount = 0,
  118074. this._targetIndex = 0
  118075. }
  118076. ,
  118077. t.prototype.getClassName = function() {
  118078. return "GPUParticleSystem"
  118079. }
  118080. ,
  118081. t.prototype.getCustomEffect = function(e) {
  118082. var t, i;
  118083. return void 0 === e && (e = 0),
  118084. null !== (i = null === (t = this._customWrappers[e]) || void 0 === t ? void 0 : t.effect) && void 0 !== i ? i : this._customWrappers[0].effect
  118085. }
  118086. ,
  118087. t.prototype._getCustomDrawWrapper = function(e) {
  118088. var t;
  118089. return void 0 === e && (e = 0),
  118090. null !== (t = this._customWrappers[e]) && void 0 !== t ? t : this._customWrappers[0]
  118091. }
  118092. ,
  118093. t.prototype.setCustomEffect = function(e, t) {
  118094. void 0 === t && (t = 0),
  118095. this._customWrappers[t] = new Gt(this._engine),
  118096. this._customWrappers[t].effect = e
  118097. }
  118098. ,
  118099. Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", {
  118100. get: function() {
  118101. return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new h),
  118102. this._onBeforeDrawParticlesObservable
  118103. },
  118104. enumerable: !1,
  118105. configurable: !0
  118106. }),
  118107. Object.defineProperty(t.prototype, "vertexShaderName", {
  118108. get: function() {
  118109. return "gpuRenderParticles"
  118110. },
  118111. enumerable: !1,
  118112. configurable: !0
  118113. }),
  118114. t.prototype._removeGradientAndTexture = function(t, i, n) {
  118115. return e.prototype._removeGradientAndTexture.call(this, t, i, n),
  118116. this._releaseBuffers(),
  118117. this
  118118. }
  118119. ,
  118120. t.prototype.addColorGradient = function(e, t) {
  118121. this._colorGradients || (this._colorGradients = []);
  118122. var i = new ly(e,t);
  118123. return this._colorGradients.push(i),
  118124. this._refreshColorGradient(!0),
  118125. this._releaseBuffers(),
  118126. this
  118127. }
  118128. ,
  118129. t.prototype._refreshColorGradient = function(e) {
  118130. void 0 === e && (e = !1),
  118131. this._colorGradients && (e && this._colorGradients.sort((function(e, t) {
  118132. return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
  118133. }
  118134. )),
  118135. this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
  118136. this._colorGradientsTexture = null))
  118137. }
  118138. ,
  118139. t.prototype.forceRefreshGradients = function() {
  118140. this._refreshColorGradient(),
  118141. this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture"),
  118142. this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture"),
  118143. this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture"),
  118144. this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture"),
  118145. this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture"),
  118146. this.reset()
  118147. }
  118148. ,
  118149. t.prototype.removeColorGradient = function(e) {
  118150. return this._removeGradientAndTexture(e, this._colorGradients, this._colorGradientsTexture),
  118151. this._colorGradientsTexture = null,
  118152. this
  118153. }
  118154. ,
  118155. t.prototype.resetDrawCache = function() {
  118156. var e;
  118157. for (var t in this._drawWrappers)
  118158. null === (e = this._drawWrappers[t].drawContext) || void 0 === e || e.reset()
  118159. }
  118160. ,
  118161. t.prototype._addFactorGradient = function(e, t, i) {
  118162. var n = new uy(t,i);
  118163. e.push(n),
  118164. this._releaseBuffers()
  118165. }
  118166. ,
  118167. t.prototype.addSizeGradient = function(e, t) {
  118168. return this._sizeGradients || (this._sizeGradients = []),
  118169. this._addFactorGradient(this._sizeGradients, e, t),
  118170. this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0),
  118171. this._releaseBuffers(),
  118172. this
  118173. }
  118174. ,
  118175. t.prototype.removeSizeGradient = function(e) {
  118176. return this._removeGradientAndTexture(e, this._sizeGradients, this._sizeGradientsTexture),
  118177. this._sizeGradientsTexture = null,
  118178. this
  118179. }
  118180. ,
  118181. t.prototype._refreshFactorGradient = function(e, t, i) {
  118182. if (void 0 === i && (i = !1),
  118183. e) {
  118184. i && e.sort((function(e, t) {
  118185. return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
  118186. }
  118187. ));
  118188. var n = this;
  118189. n[t] && (n[t].dispose(),
  118190. n[t] = null)
  118191. }
  118192. }
  118193. ,
  118194. t.prototype.addAngularSpeedGradient = function(e, t) {
  118195. return this._angularSpeedGradients || (this._angularSpeedGradients = []),
  118196. this._addFactorGradient(this._angularSpeedGradients, e, t),
  118197. this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0),
  118198. this._releaseBuffers(),
  118199. this
  118200. }
  118201. ,
  118202. t.prototype.removeAngularSpeedGradient = function(e) {
  118203. return this._removeGradientAndTexture(e, this._angularSpeedGradients, this._angularSpeedGradientsTexture),
  118204. this._angularSpeedGradientsTexture = null,
  118205. this
  118206. }
  118207. ,
  118208. t.prototype.addVelocityGradient = function(e, t) {
  118209. return this._velocityGradients || (this._velocityGradients = []),
  118210. this._addFactorGradient(this._velocityGradients, e, t),
  118211. this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0),
  118212. this._releaseBuffers(),
  118213. this
  118214. }
  118215. ,
  118216. t.prototype.removeVelocityGradient = function(e) {
  118217. return this._removeGradientAndTexture(e, this._velocityGradients, this._velocityGradientsTexture),
  118218. this._velocityGradientsTexture = null,
  118219. this
  118220. }
  118221. ,
  118222. t.prototype.addLimitVelocityGradient = function(e, t) {
  118223. return this._limitVelocityGradients || (this._limitVelocityGradients = []),
  118224. this._addFactorGradient(this._limitVelocityGradients, e, t),
  118225. this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0),
  118226. this._releaseBuffers(),
  118227. this
  118228. }
  118229. ,
  118230. t.prototype.removeLimitVelocityGradient = function(e) {
  118231. return this._removeGradientAndTexture(e, this._limitVelocityGradients, this._limitVelocityGradientsTexture),
  118232. this._limitVelocityGradientsTexture = null,
  118233. this
  118234. }
  118235. ,
  118236. t.prototype.addDragGradient = function(e, t) {
  118237. return this._dragGradients || (this._dragGradients = []),
  118238. this._addFactorGradient(this._dragGradients, e, t),
  118239. this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0),
  118240. this._releaseBuffers(),
  118241. this
  118242. }
  118243. ,
  118244. t.prototype.removeDragGradient = function(e) {
  118245. return this._removeGradientAndTexture(e, this._dragGradients, this._dragGradientsTexture),
  118246. this._dragGradientsTexture = null,
  118247. this
  118248. }
  118249. ,
  118250. t.prototype.addEmitRateGradient = function() {
  118251. return this
  118252. }
  118253. ,
  118254. t.prototype.removeEmitRateGradient = function() {
  118255. return this
  118256. }
  118257. ,
  118258. t.prototype.addStartSizeGradient = function() {
  118259. return this
  118260. }
  118261. ,
  118262. t.prototype.removeStartSizeGradient = function() {
  118263. return this
  118264. }
  118265. ,
  118266. t.prototype.addColorRemapGradient = function() {
  118267. return this
  118268. }
  118269. ,
  118270. t.prototype.removeColorRemapGradient = function() {
  118271. return this
  118272. }
  118273. ,
  118274. t.prototype.addAlphaRemapGradient = function() {
  118275. return this
  118276. }
  118277. ,
  118278. t.prototype.removeAlphaRemapGradient = function() {
  118279. return this
  118280. }
  118281. ,
  118282. t.prototype.addRampGradient = function() {
  118283. return this
  118284. }
  118285. ,
  118286. t.prototype.removeRampGradient = function() {
  118287. return this
  118288. }
  118289. ,
  118290. t.prototype.getRampGradients = function() {
  118291. return null
  118292. }
  118293. ,
  118294. Object.defineProperty(t.prototype, "useRampGradients", {
  118295. get: function() {
  118296. return !1
  118297. },
  118298. set: function(e) {},
  118299. enumerable: !1,
  118300. configurable: !0
  118301. }),
  118302. t.prototype.addLifeTimeGradient = function() {
  118303. return this
  118304. }
  118305. ,
  118306. t.prototype.removeLifeTimeGradient = function() {
  118307. return this
  118308. }
  118309. ,
  118310. t.prototype._reset = function() {
  118311. this._releaseBuffers()
  118312. }
  118313. ,
  118314. t.prototype._createVertexBuffers = function(e, t, i) {
  118315. var n = {};
  118316. n.position = t.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
  118317. var r = 3;
  118318. n.age = t.createVertexBuffer("age", r, 1, this._attributesStrideSize, !0),
  118319. r += 1,
  118320. n.size = t.createVertexBuffer("size", r, 3, this._attributesStrideSize, !0),
  118321. r += 3,
  118322. n.life = t.createVertexBuffer("life", r, 1, this._attributesStrideSize, !0),
  118323. r += 1,
  118324. r += 4,
  118325. this.billboardMode === fy.BILLBOARDMODE_STRETCHED && (n.direction = t.createVertexBuffer("direction", r, 3, this._attributesStrideSize, !0)),
  118326. r += 3,
  118327. this._platform.alignDataInBuffer && (r += 1),
  118328. this.particleEmitterType instanceof yf && (r += 3,
  118329. this._platform.alignDataInBuffer && (r += 1)),
  118330. this._colorGradientsTexture || (n.color = t.createVertexBuffer("color", r, 4, this._attributesStrideSize, !0),
  118331. r += 4),
  118332. this._isBillboardBased || (n.initialDirection = t.createVertexBuffer("initialDirection", r, 3, this._attributesStrideSize, !0),
  118333. r += 3,
  118334. this._platform.alignDataInBuffer && (r += 1)),
  118335. this.noiseTexture && (n.noiseCoordinates1 = t.createVertexBuffer("noiseCoordinates1", r, 3, this._attributesStrideSize, !0),
  118336. r += 3,
  118337. this._platform.alignDataInBuffer && (r += 1),
  118338. n.noiseCoordinates2 = t.createVertexBuffer("noiseCoordinates2", r, 3, this._attributesStrideSize, !0),
  118339. r += 3,
  118340. this._platform.alignDataInBuffer && (r += 1)),
  118341. n.angle = t.createVertexBuffer("angle", r, 1, this._attributesStrideSize, !0),
  118342. this._angularSpeedGradientsTexture ? r++ : r += 2,
  118343. this._isAnimationSheetEnabled && (n.cellIndex = t.createVertexBuffer("cellIndex", r, 1, this._attributesStrideSize, !0),
  118344. r += 1,
  118345. this.spriteRandomStartCell && (n.cellStartOffset = t.createVertexBuffer("cellStartOffset", r, 1, this._attributesStrideSize, !0),
  118346. r += 1)),
  118347. n.offset = i.createVertexBuffer("offset", 0, 2),
  118348. n.uv = i.createVertexBuffer("uv", 2, 2),
  118349. this._platform.createVertexBuffers(e, n),
  118350. this.resetDrawCache()
  118351. }
  118352. ,
  118353. t.prototype._initialize = function(e) {
  118354. if (void 0 === e && (e = !1),
  118355. !this._buffer0 || e) {
  118356. var t = this._engine
  118357. , i = new Array;
  118358. this._attributesStrideSize = 21,
  118359. this._targetIndex = 0,
  118360. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1),
  118361. this.particleEmitterType instanceof yf && (this._attributesStrideSize += 3,
  118362. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
  118363. this.isBillboardBased || (this._attributesStrideSize += 3,
  118364. this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
  118365. this._colorGradientsTexture && (this._attributesStrideSize -= 4),
  118366. this._angularSpeedGradientsTexture && (this._attributesStrideSize -= 1),
  118367. this._isAnimationSheetEnabled && (this._attributesStrideSize += 1,
  118368. this.spriteRandomStartCell && (this._attributesStrideSize += 1)),
  118369. this.noiseTexture && (this._attributesStrideSize += 6,
  118370. this._platform.alignDataInBuffer && (this._attributesStrideSize += 2)),
  118371. this._platform.alignDataInBuffer && (this._attributesStrideSize += 3 - (this._attributesStrideSize + 3 & 3));
  118372. for (var n = this.particleEmitterType instanceof yf, r = I.Vector3[0], o = 0, a = 0; a < this._capacity; a++)
  118373. if (i.push(0),
  118374. i.push(0),
  118375. i.push(0),
  118376. i.push(0),
  118377. i.push(0),
  118378. i.push(0),
  118379. i.push(0),
  118380. i.push(0),
  118381. i.push(Math.random()),
  118382. i.push(Math.random()),
  118383. i.push(Math.random()),
  118384. i.push(Math.random()),
  118385. n ? (this.particleEmitterType.particleDestinationGenerator(a, null, r),
  118386. i.push(r.x),
  118387. i.push(r.y),
  118388. i.push(r.z)) : (i.push(0),
  118389. i.push(0),
  118390. i.push(0)),
  118391. this._platform.alignDataInBuffer && i.push(0),
  118392. o += 16,
  118393. n && (this.particleEmitterType.particlePositionGenerator(a, null, r),
  118394. i.push(r.x),
  118395. i.push(r.y),
  118396. i.push(r.z),
  118397. this._platform.alignDataInBuffer && i.push(0),
  118398. o += 4),
  118399. this._colorGradientsTexture || (i.push(0),
  118400. i.push(0),
  118401. i.push(0),
  118402. i.push(0),
  118403. o += 4),
  118404. this.isBillboardBased || (i.push(0),
  118405. i.push(0),
  118406. i.push(0),
  118407. this._platform.alignDataInBuffer && i.push(0),
  118408. o += 4),
  118409. this.noiseTexture && (i.push(Math.random()),
  118410. i.push(Math.random()),
  118411. i.push(Math.random()),
  118412. this._platform.alignDataInBuffer && i.push(0),
  118413. i.push(Math.random()),
  118414. i.push(Math.random()),
  118415. i.push(Math.random()),
  118416. this._platform.alignDataInBuffer && i.push(0),
  118417. o += 8),
  118418. i.push(0),
  118419. o += 1,
  118420. this._angularSpeedGradientsTexture || (i.push(0),
  118421. o += 1),
  118422. this._isAnimationSheetEnabled && (i.push(0),
  118423. o += 1,
  118424. this.spriteRandomStartCell && (i.push(0),
  118425. o += 1)),
  118426. this._platform.alignDataInBuffer) {
  118427. var s = 3 - (o + 3 & 3);
  118428. for (o += s; s-- > 0; )
  118429. i.push(0)
  118430. }
  118431. var l = new Float32Array([.5, .5, 1, 1, -.5, .5, 0, 1, .5, -.5, 1, 0, -.5, -.5, 0, 0])
  118432. , c = this._platform.createParticleBuffer(i)
  118433. , u = this._platform.createParticleBuffer(i);
  118434. this._buffer0 = new wi(t,c,!1,this._attributesStrideSize),
  118435. this._buffer1 = new wi(t,u,!1,this._attributesStrideSize),
  118436. this._spriteBuffer = new wi(t,l,!1,4),
  118437. this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer),
  118438. this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer),
  118439. this._sourceBuffer = this._buffer0,
  118440. this._targetBuffer = this._buffer1
  118441. }
  118442. }
  118443. ,
  118444. t.prototype._recreateUpdateEffect = function() {
  118445. var e = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  118446. this._isBillboardBased && (e += "\n#define BILLBOARD"),
  118447. this._colorGradientsTexture && (e += "\n#define COLORGRADIENTS"),
  118448. this._sizeGradientsTexture && (e += "\n#define SIZEGRADIENTS"),
  118449. this._angularSpeedGradientsTexture && (e += "\n#define ANGULARSPEEDGRADIENTS"),
  118450. this._velocityGradientsTexture && (e += "\n#define VELOCITYGRADIENTS"),
  118451. this._limitVelocityGradientsTexture && (e += "\n#define LIMITVELOCITYGRADIENTS"),
  118452. this._dragGradientsTexture && (e += "\n#define DRAGGRADIENTS"),
  118453. this.isAnimationSheetEnabled && (e += "\n#define ANIMATESHEET",
  118454. this.spriteRandomStartCell && (e += "\n#define ANIMATESHEETRANDOMSTART")),
  118455. this.noiseTexture && (e += "\n#define NOISE"),
  118456. this.isLocal && (e += "\n#define LOCAL"),
  118457. this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === e || (this._cachedUpdateDefines = e,
  118458. this._updateBuffer = this._platform.createUpdateBuffer(e))
  118459. }
  118460. ,
  118461. t.prototype._getWrapper = function(e) {
  118462. var t = this._getCustomDrawWrapper(e);
  118463. if (null == t ? void 0 : t.effect)
  118464. return t;
  118465. var i = [];
  118466. this.fillDefines(i, e);
  118467. var n = this._drawWrappers[e];
  118468. n || ((n = new Gt(this._engine)).drawContext && (n.drawContext.useInstancing = !0),
  118469. this._drawWrappers[e] = n);
  118470. var r = i.join("\n");
  118471. if (n.defines !== r) {
  118472. var o = []
  118473. , a = []
  118474. , s = [];
  118475. this.fillUniformsAttributesAndSamplerNames(a, o, s),
  118476. n.setEffect(this._engine.createEffect("gpuRenderParticles", o, a, s, r), r)
  118477. }
  118478. return n
  118479. }
  118480. ,
  118481. t._GetAttributeNamesOrOptions = function(e, t, i, n) {
  118482. void 0 === e && (e = !1),
  118483. void 0 === t && (t = !1),
  118484. void 0 === i && (i = !1),
  118485. void 0 === n && (n = !1);
  118486. var r = [Bi.PositionKind, "age", "life", "size", "angle"];
  118487. return e || r.push(Bi.ColorKind),
  118488. t && r.push("cellIndex"),
  118489. i || r.push("initialDirection"),
  118490. n || r.push("direction"),
  118491. r.push("offset", Bi.UVKind),
  118492. r
  118493. }
  118494. ,
  118495. t._GetEffectCreationOptions = function(e) {
  118496. void 0 === e && (e = !1);
  118497. var t = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "translationPivot", "eyePosition"];
  118498. return e && t.push("sheetInfos"),
  118499. t
  118500. }
  118501. ,
  118502. t.prototype.fillDefines = function(e, t) {
  118503. if (void 0 === t && (t = 0),
  118504. this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"),
  118505. this._scene.clipPlane2 && e.push("#define CLIPPLANE2"),
  118506. this._scene.clipPlane3 && e.push("#define CLIPPLANE3"),
  118507. this._scene.clipPlane4 && e.push("#define CLIPPLANE4"),
  118508. this._scene.clipPlane5 && e.push("#define CLIPPLANE5"),
  118509. this._scene.clipPlane6 && e.push("#define CLIPPLANE6")),
  118510. t === fy.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"),
  118511. this.isLocal && e.push("#define LOCAL"),
  118512. this._isBillboardBased)
  118513. switch (e.push("#define BILLBOARD"),
  118514. this.billboardMode) {
  118515. case fy.BILLBOARDMODE_Y:
  118516. e.push("#define BILLBOARDY");
  118517. break;
  118518. case fy.BILLBOARDMODE_STRETCHED:
  118519. e.push("#define BILLBOARDSTRETCHED");
  118520. break;
  118521. case fy.BILLBOARDMODE_ALL:
  118522. e.push("#define BILLBOARDMODE_ALL")
  118523. }
  118524. this._colorGradientsTexture && e.push("#define COLORGRADIENTS"),
  118525. this.isAnimationSheetEnabled && e.push("#define ANIMATESHEET"),
  118526. this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
  118527. e.push("" + this._imageProcessingConfigurationDefines.toString()))
  118528. }
  118529. ,
  118530. t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, n) {
  118531. i.push.apply(i, t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === fy.BILLBOARDMODE_STRETCHED)),
  118532. e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
  118533. n.push("diffuseSampler", "colorGradientSampler"),
  118534. this._imageProcessingConfiguration && (Ri.PrepareUniforms(e, this._imageProcessingConfigurationDefines),
  118535. Ri.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
  118536. }
  118537. ,
  118538. t.prototype.animate = function(e) {
  118539. var t;
  118540. void 0 === e && (e = !1),
  118541. this._timeDelta = this.updateSpeed * (e ? this.preWarmStepOffset : (null === (t = this._scene) || void 0 === t ? void 0 : t.getAnimationRatio()) || 1),
  118542. this._actualFrame += this._timeDelta,
  118543. this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()
  118544. }
  118545. ,
  118546. t.prototype._createFactorGradientTexture = function(e, t) {
  118547. var i = this[t];
  118548. if (e && e.length && !i) {
  118549. for (var n = new Float32Array(this._rawTextureWidth), r = function(t) {
  118550. var i = t / o._rawTextureWidth;
  118551. hy.GetCurrentGradient(i, e, (function(e, i, r) {
  118552. n[t] = d.Lerp(e.factor1, i.factor1, r)
  118553. }
  118554. ))
  118555. }, o = this, s = 0; s < this._rawTextureWidth; s++)
  118556. r(s);
  118557. this[t] = ao.CreateRTexture(n, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
  118558. }
  118559. }
  118560. ,
  118561. t.prototype._createSizeGradientTexture = function() {
  118562. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture")
  118563. }
  118564. ,
  118565. t.prototype._createAngularSpeedGradientTexture = function() {
  118566. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture")
  118567. }
  118568. ,
  118569. t.prototype._createVelocityGradientTexture = function() {
  118570. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture")
  118571. }
  118572. ,
  118573. t.prototype._createLimitVelocityGradientTexture = function() {
  118574. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture")
  118575. }
  118576. ,
  118577. t.prototype._createDragGradientTexture = function() {
  118578. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture")
  118579. }
  118580. ,
  118581. t.prototype._createColorGradientTexture = function() {
  118582. if (this._colorGradients && this._colorGradients.length && !this._colorGradientsTexture) {
  118583. for (var e = new Uint8Array(4 * this._rawTextureWidth), t = L.Color4[0], i = function(i) {
  118584. var r = i / n._rawTextureWidth;
  118585. hy.GetCurrentGradient(r, n._colorGradients, (function(n, r, o) {
  118586. N.LerpToRef(n.color1, r.color1, o, t),
  118587. e[4 * i] = 255 * t.r,
  118588. e[4 * i + 1] = 255 * t.g,
  118589. e[4 * i + 2] = 255 * t.b,
  118590. e[4 * i + 3] = 255 * t.a
  118591. }
  118592. ))
  118593. }, n = this, r = 0; r < this._rawTextureWidth; r++)
  118594. i(r);
  118595. this._colorGradientsTexture = ao.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
  118596. }
  118597. }
  118598. ,
  118599. t.prototype._render = function(e, t) {
  118600. var i, n, r = this._getWrapper(e), o = r.effect;
  118601. this._engine.enableEffect(r);
  118602. var s = (null === (i = this._scene) || void 0 === i ? void 0 : i.getViewMatrix()) || P.IdentityReadOnly;
  118603. if (o.setMatrix("view", s),
  118604. o.setMatrix("projection", null !== (n = this.defaultProjectionMatrix) && void 0 !== n ? n : this._scene.getProjectionMatrix()),
  118605. o.setTexture("diffuseSampler", this.particleTexture),
  118606. o.setVector2("translationPivot", this.translationPivot),
  118607. o.setVector3("worldOffset", this.worldOffset),
  118608. this.isLocal && o.setMatrix("emitterWM", t),
  118609. this._colorGradientsTexture ? o.setTexture("colorGradientSampler", this._colorGradientsTexture) : o.setDirectColor4("colorDead", this.colorDead),
  118610. this._isAnimationSheetEnabled && this.particleTexture) {
  118611. var l = this.particleTexture.getBaseSize();
  118612. o.setFloat3("sheetInfos", this.spriteCellWidth / l.width, this.spriteCellHeight / l.height, l.width / this.spriteCellWidth)
  118613. }
  118614. if (this._isBillboardBased && this._scene) {
  118615. var c = this._scene.activeCamera;
  118616. o.setVector3("eyePosition", c.globalPosition)
  118617. }
  118618. var u = o.defines;
  118619. if (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && Mr.BindClipPlane(o, this._scene),
  118620. u.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
  118621. var h = s.clone();
  118622. h.invert(),
  118623. o.setMatrix("invView", h)
  118624. }
  118625. switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o),
  118626. e) {
  118627. case fy.BLENDMODE_ADD:
  118628. this._engine.setAlphaMode(a.ALPHA_ADD);
  118629. break;
  118630. case fy.BLENDMODE_ONEONE:
  118631. this._engine.setAlphaMode(a.ALPHA_ONEONE);
  118632. break;
  118633. case fy.BLENDMODE_STANDARD:
  118634. this._engine.setAlphaMode(a.ALPHA_COMBINE);
  118635. break;
  118636. case fy.BLENDMODE_MULTIPLY:
  118637. this._engine.setAlphaMode(a.ALPHA_MULTIPLY)
  118638. }
  118639. return this._platform.bindDrawBuffers(this._targetIndex, o),
  118640. this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o),
  118641. this._engine.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._currentActiveCount),
  118642. this._engine.setAlphaMode(a.ALPHA_DISABLE),
  118643. this._currentActiveCount
  118644. }
  118645. ,
  118646. t.prototype.render = function(e, t) {
  118647. if (void 0 === e && (e = !1),
  118648. void 0 === t && (t = !1),
  118649. !this._started)
  118650. return 0;
  118651. if (this._createColorGradientTexture(),
  118652. this._createSizeGradientTexture(),
  118653. this._createAngularSpeedGradientTexture(),
  118654. this._createVelocityGradientTexture(),
  118655. this._createLimitVelocityGradientTexture(),
  118656. this._createDragGradientTexture(),
  118657. this._recreateUpdateEffect(),
  118658. !this.isReady())
  118659. return 0;
  118660. if (!e && this._scene) {
  118661. if (!this._preWarmDone && this.preWarmCycles) {
  118662. for (var i = 0; i < this.preWarmCycles; i++)
  118663. this.animate(!0),
  118664. this.render(!0, !0);
  118665. this._preWarmDone = !0
  118666. }
  118667. if (this._currentRenderId === this._scene.getFrameId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId))
  118668. return 0;
  118669. this._currentRenderId = this._scene.getFrameId(),
  118670. this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId)
  118671. }
  118672. if (this._initialize(),
  118673. this._accumulatedCount += this.emitRate * this._timeDelta,
  118674. this._accumulatedCount > 1) {
  118675. var n = 0 | this._accumulatedCount;
  118676. this._accumulatedCount -= n,
  118677. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + n)
  118678. }
  118679. if (!this._currentActiveCount)
  118680. return 0;
  118681. var r;
  118682. if (this.emitter.position)
  118683. r = this.emitter.getWorldMatrix();
  118684. else {
  118685. var o = this.emitter;
  118686. r = P.Translation(o.x, o.y, o.z)
  118687. }
  118688. var s = this._engine;
  118689. this._platform.preUpdateParticleBuffer(),
  118690. this._updateBuffer.setFloat("currentCount", this._currentActiveCount),
  118691. this._updateBuffer.setFloat("timeDelta", this._timeDelta),
  118692. this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1),
  118693. this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize),
  118694. this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime),
  118695. this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower),
  118696. this._colorGradientsTexture || (this._updateBuffer.setDirectColor4("color1", this.color1),
  118697. this._updateBuffer.setDirectColor4("color2", this.color2)),
  118698. this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize),
  118699. this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY),
  118700. this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation),
  118701. this._updateBuffer.setVector3("gravity", this.gravity),
  118702. this._limitVelocityGradientsTexture && this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping),
  118703. this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateBuffer),
  118704. this._isAnimationSheetEnabled && this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0),
  118705. this.noiseTexture && this._updateBuffer.setVector3("noiseStrength", this.noiseStrength),
  118706. this.isLocal || this._updateBuffer.setMatrix("emitterWM", r),
  118707. this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
  118708. var l = 0;
  118709. e || t || (s.setState(!1),
  118710. this.forceDepthWrite && s.setDepthWrite(!0),
  118711. l = this.blendMode === fy.BLENDMODE_MULTIPLYADD ? this._render(fy.BLENDMODE_MULTIPLY, r) + this._render(fy.BLENDMODE_ADD, r) : this._render(this.blendMode, r),
  118712. this._engine.setAlphaMode(a.ALPHA_DISABLE)),
  118713. this._targetIndex++,
  118714. 2 === this._targetIndex && (this._targetIndex = 0);
  118715. var c = this._sourceBuffer;
  118716. return this._sourceBuffer = this._targetBuffer,
  118717. this._targetBuffer = c,
  118718. l
  118719. }
  118720. ,
  118721. t.prototype.rebuild = function() {
  118722. this._initialize(!0)
  118723. }
  118724. ,
  118725. t.prototype._releaseBuffers = function() {
  118726. this._buffer0 && (this._buffer0.dispose(),
  118727. this._buffer0 = null),
  118728. this._buffer1 && (this._buffer1.dispose(),
  118729. this._buffer1 = null),
  118730. this._spriteBuffer && (this._spriteBuffer.dispose(),
  118731. this._spriteBuffer = null),
  118732. this._platform.releaseBuffers()
  118733. }
  118734. ,
  118735. t.prototype.dispose = function(e) {
  118736. for (var t in void 0 === e && (e = !0),
  118737. this._drawWrappers)
  118738. this._drawWrappers[t].dispose();
  118739. if (this._drawWrappers = {},
  118740. this._scene) {
  118741. var i = this._scene.particleSystems.indexOf(this);
  118742. i > -1 && this._scene.particleSystems.splice(i, 1)
  118743. }
  118744. this._releaseBuffers(),
  118745. this._platform.releaseVertexBuffers(),
  118746. this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
  118747. this._colorGradientsTexture = null),
  118748. this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(),
  118749. this._sizeGradientsTexture = null),
  118750. this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(),
  118751. this._angularSpeedGradientsTexture = null),
  118752. this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(),
  118753. this._velocityGradientsTexture = null),
  118754. this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(),
  118755. this._limitVelocityGradientsTexture = null),
  118756. this._dragGradientsTexture && (this._dragGradientsTexture.dispose(),
  118757. this._dragGradientsTexture = null),
  118758. this._randomTexture && (this._randomTexture.dispose(),
  118759. this._randomTexture = null),
  118760. this._randomTexture2 && (this._randomTexture2.dispose(),
  118761. this._randomTexture2 = null),
  118762. e && this.particleTexture && (this.particleTexture.dispose(),
  118763. this.particleTexture = null),
  118764. e && this.noiseTexture && (this.noiseTexture.dispose(),
  118765. this.noiseTexture = null),
  118766. this.onStoppedObservable.clear(),
  118767. this.onDisposeObservable.notifyObservers(this),
  118768. this.onDisposeObservable.clear()
  118769. }
  118770. ,
  118771. t.prototype.clone = function(e, i) {
  118772. var n = V({}, this._customWrappers)
  118773. , r = null
  118774. , o = this._engine;
  118775. if (o.createEffectForParticles && null != this.customShader) {
  118776. var a = (r = this.customShader).shaderOptions.defines.length > 0 ? r.shaderOptions.defines.join("\n") : "";
  118777. n[0] = o.createEffectForParticles(r.shaderPath.fragmentElement, r.shaderOptions.uniforms, r.shaderOptions.samplers, a, void 0, void 0, void 0, this)
  118778. }
  118779. var s = this.serialize()
  118780. , l = t.Parse(s, this._scene || this._engine, this._rootUrl);
  118781. return l.name = e,
  118782. l.customShader = r,
  118783. l._customWrappers = n,
  118784. void 0 === i && (i = this.emitter),
  118785. this.noiseTexture && (l.noiseTexture = this.noiseTexture.clone()),
  118786. l.emitter = i,
  118787. l
  118788. }
  118789. ,
  118790. t.prototype.serialize = function(e) {
  118791. void 0 === e && (e = !1);
  118792. var t = {};
  118793. return fy._Serialize(t, this, e),
  118794. t.activeParticleCount = this.activeParticleCount,
  118795. t.randomTextureSize = this._randomTextureSize,
  118796. t.customShader = this.customShader,
  118797. t
  118798. }
  118799. ,
  118800. t.Parse = function(e, i, n, r, o) {
  118801. void 0 === r && (r = !1);
  118802. var a, s = e.name;
  118803. a = i instanceof Ht ? i : i.getEngine();
  118804. var l = new t(s,{
  118805. capacity: o || e.capacity,
  118806. randomTextureSize: e.randomTextureSize
  118807. },i,null,e.isAnimationSheetEnabled);
  118808. if (l._rootUrl = n,
  118809. e.customShader && a.createEffectForParticles) {
  118810. var c = e.customShader
  118811. , u = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join("\n") : ""
  118812. , h = a.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, u, void 0, void 0, void 0, l);
  118813. l.setCustomEffect(h, 0),
  118814. l.customShader = c
  118815. }
  118816. return e.id && (l.id = e.id),
  118817. e.activeParticleCount && (l.activeParticleCount = e.activeParticleCount),
  118818. fy._Parse(e, l, i, n),
  118819. e.preventAutoStart && (l.preventAutoStart = e.preventAutoStart),
  118820. r || l.preventAutoStart || l.start(),
  118821. l
  118822. }
  118823. ,
  118824. t
  118825. }(Tf)
  118826. , my = function() {
  118827. function e() {
  118828. this._emitterNodeIsOwned = !0,
  118829. this.systems = new Array
  118830. }
  118831. return Object.defineProperty(e.prototype, "emitterNode", {
  118832. get: function() {
  118833. return this._emitterNode
  118834. },
  118835. set: function(e) {
  118836. this._emitterNodeIsOwned && this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
  118837. this._emitterNodeIsOwned = !1);
  118838. for (var t = 0, i = this.systems; t < i.length; t++)
  118839. i[t].emitter = e;
  118840. this._emitterNode = e
  118841. },
  118842. enumerable: !1,
  118843. configurable: !0
  118844. }),
  118845. e.prototype.setEmitterAsSphere = function(e, t, i) {
  118846. this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(),
  118847. this._emitterNodeIsOwned = !0,
  118848. this._emitterCreationOptions = {
  118849. kind: "Sphere",
  118850. options: e,
  118851. renderingGroupId: t
  118852. };
  118853. var n = Dl("emitterSphere", {
  118854. diameter: e.diameter,
  118855. segments: e.segments
  118856. }, i);
  118857. n.renderingGroupId = t;
  118858. var r = new Os("emitterSphereMaterial",i);
  118859. r.emissiveColor = e.color,
  118860. n.material = r;
  118861. for (var o = 0, a = this.systems; o < a.length; o++)
  118862. a[o].emitter = n;
  118863. this._emitterNode = n
  118864. }
  118865. ,
  118866. e.prototype.start = function(e) {
  118867. for (var t = 0, i = this.systems; t < i.length; t++) {
  118868. var n = i[t];
  118869. e && (n.emitter = e),
  118870. n.start()
  118871. }
  118872. }
  118873. ,
  118874. e.prototype.dispose = function() {
  118875. for (var e = 0, t = this.systems; e < t.length; e++)
  118876. t[e].dispose();
  118877. this.systems = [],
  118878. this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
  118879. this._emitterNode = null)
  118880. }
  118881. ,
  118882. e.prototype.serialize = function(e) {
  118883. void 0 === e && (e = !1);
  118884. for (var t = {
  118885. systems: []
  118886. }, i = 0, n = this.systems; i < n.length; i++) {
  118887. var r = n[i];
  118888. t.systems.push(r.serialize(e))
  118889. }
  118890. return this._emitterNode && (t.emitter = this._emitterCreationOptions),
  118891. t
  118892. }
  118893. ,
  118894. e.Parse = function(t, i, n, r) {
  118895. void 0 === n && (n = !1);
  118896. var o = new e
  118897. , a = this.BaseAssetsUrl + "/textures/";
  118898. i = i || E.LastCreatedScene;
  118899. for (var s = 0, l = t.systems; s < l.length; s++) {
  118900. var c = l[s];
  118901. o.systems.push(n ? _y.Parse(c, i, a, !0, r) : fy.Parse(c, i, a, !0, r))
  118902. }
  118903. if (t.emitter) {
  118904. var u = t.emitter.options;
  118905. "Sphere" === t.emitter.kind && o.setEmitterAsSphere({
  118906. diameter: u.diameter,
  118907. segments: u.segments,
  118908. color: D.FromArray(u.color)
  118909. }, t.emitter.renderingGroupId, i)
  118910. }
  118911. return o
  118912. }
  118913. ,
  118914. e.BaseAssetsUrl = "https://assets.babylonjs.com/particles",
  118915. e
  118916. }()
  118917. , gy = function() {
  118918. function e() {}
  118919. return e.CreateDefault = function(e, t, i, n) {
  118920. var r;
  118921. return void 0 === t && (t = 500),
  118922. void 0 === n && (n = !1),
  118923. (r = n ? new _y("default system",{
  118924. capacity: t
  118925. },i) : new fy("default system",t,i)).emitter = e,
  118926. r.particleTexture = new io("https://www.babylonjs.com/assets/Flare.png",r.getScene()),
  118927. r.createConeEmitter(.1, Math.PI / 4),
  118928. r.color1 = new N(1,1,1,1),
  118929. r.color2 = new N(1,1,1,1),
  118930. r.colorDead = new N(1,1,1,0),
  118931. r.minSize = .1,
  118932. r.maxSize = .1,
  118933. r.minEmitPower = 2,
  118934. r.maxEmitPower = 2,
  118935. r.updateSpeed = 1 / 60,
  118936. r.emitRate = 30,
  118937. r
  118938. }
  118939. ,
  118940. e.CreateAsync = function(t, i, n, r) {
  118941. void 0 === n && (n = !1),
  118942. i || (i = E.LastCreatedScene);
  118943. var o = {};
  118944. return i._addPendingData(o),
  118945. new Promise((function(a, s) {
  118946. if (n && !_y.IsSupported)
  118947. return i._removePendingData(o),
  118948. s("Particle system with GPU is not supported.");
  118949. gi.LoadFile("".concat(e.BaseAssetsUrl, "/systems/").concat(t, ".json"), (function(e) {
  118950. i._removePendingData(o);
  118951. var t = JSON.parse(e.toString());
  118952. return a(my.Parse(t, i, n, r))
  118953. }
  118954. ), void 0, void 0, void 0, (function() {
  118955. return i._removePendingData(o),
  118956. s("An error occurred with the creation of your particle system. Check if your type '".concat(t, "' exists."))
  118957. }
  118958. ))
  118959. }
  118960. ))
  118961. }
  118962. ,
  118963. e.ExportSet = function(e) {
  118964. for (var t = new my, i = 0, n = e; i < n.length; i++) {
  118965. var r = n[i];
  118966. t.systems.push(r)
  118967. }
  118968. return t
  118969. }
  118970. ,
  118971. e.ParseFromFileAsync = function(e, t, i, n, r, o) {
  118972. return void 0 === n && (n = !1),
  118973. void 0 === r && (r = ""),
  118974. new Promise((function(a, s) {
  118975. var l = new Ye;
  118976. l.addEventListener("readystatechange", (function() {
  118977. if (4 == l.readyState)
  118978. if (200 == l.status) {
  118979. var t = JSON.parse(l.responseText)
  118980. , c = void 0;
  118981. c = n ? _y.Parse(t, i, r, !1, o) : fy.Parse(t, i, r, !1, o),
  118982. e && (c.name = e),
  118983. a(c)
  118984. } else
  118985. s("Unable to load the particle system")
  118986. }
  118987. )),
  118988. l.open("GET", t),
  118989. l.send()
  118990. }
  118991. ))
  118992. }
  118993. ,
  118994. e.CreateFromSnippetAsync = function(e, t, i, n, r) {
  118995. var o = this;
  118996. if (void 0 === i && (i = !1),
  118997. void 0 === n && (n = ""),
  118998. "_BLANK" === e) {
  118999. var a = this.CreateDefault(null);
  119000. return a.start(),
  119001. Promise.resolve(a)
  119002. }
  119003. return new Promise((function(a, s) {
  119004. var l = new Ye;
  119005. l.addEventListener("readystatechange", (function() {
  119006. if (4 == l.readyState)
  119007. if (200 == l.status) {
  119008. var o = JSON.parse(JSON.parse(l.responseText).jsonPayload)
  119009. , c = JSON.parse(o.particleSystem)
  119010. , u = void 0;
  119011. (u = i ? _y.Parse(c, t, n, !1, r) : fy.Parse(c, t, n, !1, r)).snippetId = e,
  119012. a(u)
  119013. } else
  119014. s("Unable to load the snippet " + e)
  119015. }
  119016. )),
  119017. l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")),
  119018. l.send()
  119019. }
  119020. ))
  119021. }
  119022. ,
  119023. e.BaseAssetsUrl = my.BaseAssetsUrl,
  119024. e.SnippetUrl = "https://snippet.babylonjs.com",
  119025. e
  119026. }();
  119027. o.AddParser(Wi.NAME_PARTICLESYSTEM, (function(e, t, i, n) {
  119028. var r = o.GetIndividualParser(Wi.NAME_PARTICLESYSTEM);
  119029. if (r && void 0 !== e.particleSystems && null !== e.particleSystems)
  119030. for (var a = 0, s = e.particleSystems.length; a < s; a++) {
  119031. var l = e.particleSystems[a];
  119032. i.particleSystems.push(r(l, t, n))
  119033. }
  119034. }
  119035. )),
  119036. o.AddIndividualParser(Wi.NAME_PARTICLESYSTEM, (function(e, t, i) {
  119037. return e.activeParticleCount ? _y.Parse(e, t, i) : fy.Parse(e, t, i)
  119038. }
  119039. )),
  119040. vr.prototype.createEffectForParticles = function(e, t, i, n, r, o, a, s) {
  119041. var l;
  119042. void 0 === t && (t = []),
  119043. void 0 === i && (i = []),
  119044. void 0 === n && (n = "");
  119045. var c = []
  119046. , u = []
  119047. , h = [];
  119048. return s ? s.fillUniformsAttributesAndSamplerNames(u, c, h) : (c = fy._GetAttributeNamesOrOptions(),
  119049. u = fy._GetEffectCreationOptions()),
  119050. -1 === n.indexOf(" BILLBOARD") && (n += "\n#define BILLBOARD\n"),
  119051. -1 === i.indexOf("diffuseSampler") && i.push("diffuseSampler"),
  119052. this.createEffect({
  119053. vertex: null !== (l = null == s ? void 0 : s.vertexShaderName) && void 0 !== l ? l : "particles",
  119054. fragmentElement: e
  119055. }, c, u.concat(t), h.concat(i), n, r, o, a)
  119056. }
  119057. ,
  119058. Vr.prototype.getEmittedParticleSystems = function() {
  119059. for (var e = new Array, t = 0; t < this.getScene().particleSystems.length; t++) {
  119060. var i = this.getScene().particleSystems[t];
  119061. i.emitter === this && e.push(i)
  119062. }
  119063. return e
  119064. }
  119065. ,
  119066. Vr.prototype.getHierarchyEmittedParticleSystems = function() {
  119067. var e = new Array
  119068. , t = this.getDescendants();
  119069. t.push(this);
  119070. for (var i = 0; i < this.getScene().particleSystems.length; i++) {
  119071. var n = this.getScene().particleSystems[i]
  119072. , r = n.emitter;
  119073. r.position && -1 !== t.indexOf(r) && e.push(n)
  119074. }
  119075. return e
  119076. }
  119077. ;
  119078. var vy, yy = function() {
  119079. function e(e, t, i, n, r, o, a, s, l, c) {
  119080. void 0 === l && (l = null),
  119081. void 0 === c && (c = null),
  119082. this.idx = 0,
  119083. this.id = 0,
  119084. this.color = new N(1,1,1,1),
  119085. this.position = x.Zero(),
  119086. this.rotation = x.Zero(),
  119087. this.scaling = x.One(),
  119088. this.uvs = new R(0,0,1,1),
  119089. this.velocity = x.Zero(),
  119090. this.pivot = x.Zero(),
  119091. this.translateFromPivot = !1,
  119092. this.alive = !0,
  119093. this.isVisible = !0,
  119094. this._pos = 0,
  119095. this._ind = 0,
  119096. this.shapeId = 0,
  119097. this.idxInShape = 0,
  119098. this._stillInvisible = !1,
  119099. this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1],
  119100. this.parentId = null,
  119101. this.materialIndex = null,
  119102. this.props = null,
  119103. this.cullingStrategy = Sr.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
  119104. this._globalPosition = x.Zero(),
  119105. this.idx = e,
  119106. this.id = t,
  119107. this._pos = i,
  119108. this._ind = n,
  119109. this._model = r,
  119110. this.shapeId = o,
  119111. this.idxInShape = a,
  119112. this._sps = s,
  119113. l && (this._modelBoundingInfo = l,
  119114. this._boundingInfo = new sr(l.minimum,l.maximum)),
  119115. null !== c && (this.materialIndex = c)
  119116. }
  119117. return e.prototype.getBoundingInfo = function() {
  119118. return this._boundingInfo
  119119. }
  119120. ,
  119121. Object.defineProperty(e.prototype, "hasBoundingInfo", {
  119122. get: function() {
  119123. return null !== this._boundingInfo
  119124. },
  119125. enumerable: !1,
  119126. configurable: !0
  119127. }),
  119128. e.prototype.copyToRef = function(e) {
  119129. return e.position.copyFrom(this.position),
  119130. e.rotation.copyFrom(this.rotation),
  119131. this.rotationQuaternion && (e.rotationQuaternion ? e.rotationQuaternion.copyFrom(this.rotationQuaternion) : e.rotationQuaternion = this.rotationQuaternion.clone()),
  119132. e.scaling.copyFrom(this.scaling),
  119133. this.color && (e.color ? e.color.copyFrom(this.color) : e.color = this.color.clone()),
  119134. e.uvs.copyFrom(this.uvs),
  119135. e.velocity.copyFrom(this.velocity),
  119136. e.pivot.copyFrom(this.pivot),
  119137. e.translateFromPivot = this.translateFromPivot,
  119138. e.alive = this.alive,
  119139. e.isVisible = this.isVisible,
  119140. e.parentId = this.parentId,
  119141. e.cullingStrategy = this.cullingStrategy,
  119142. null !== this.materialIndex && (e.materialIndex = this.materialIndex),
  119143. this
  119144. }
  119145. ,
  119146. Object.defineProperty(e.prototype, "scale", {
  119147. get: function() {
  119148. return this.scaling
  119149. },
  119150. set: function(e) {
  119151. this.scaling = e
  119152. },
  119153. enumerable: !1,
  119154. configurable: !0
  119155. }),
  119156. Object.defineProperty(e.prototype, "quaternion", {
  119157. get: function() {
  119158. return this.rotationQuaternion
  119159. },
  119160. set: function(e) {
  119161. this.rotationQuaternion = e
  119162. },
  119163. enumerable: !1,
  119164. configurable: !0
  119165. }),
  119166. e.prototype.intersectsMesh = function(e) {
  119167. return !(!this._boundingInfo || !e.hasBoundingInfo) && (this._sps._bSphereOnly ? ir.Intersects(this._boundingInfo.boundingSphere, e.getBoundingInfo().boundingSphere) : this._boundingInfo.intersects(e.getBoundingInfo(), !1))
  119168. }
  119169. ,
  119170. e.prototype.isInFrustum = function(e) {
  119171. return null !== this._boundingInfo && this._boundingInfo.isInFrustum(e, this.cullingStrategy)
  119172. }
  119173. ,
  119174. e.prototype.getRotationMatrix = function(e) {
  119175. var t;
  119176. if (this.rotationQuaternion)
  119177. t = this.rotationQuaternion;
  119178. else {
  119179. t = I.Quaternion[0];
  119180. var i = this.rotation;
  119181. C.RotationYawPitchRollToRef(i.y, i.x, i.z, t)
  119182. }
  119183. t.toRotationMatrix(e)
  119184. }
  119185. ,
  119186. e
  119187. }(), by = function() {
  119188. function e(e, t, i, n, r, o, a, s, l) {
  119189. this._indicesLength = 0,
  119190. this.shapeId = e,
  119191. this._shape = t,
  119192. this._indices = i,
  119193. this._indicesLength = i.length,
  119194. this._shapeUV = o,
  119195. this._shapeColors = r,
  119196. this._normals = n,
  119197. this._positionFunction = a,
  119198. this._vertexFunction = s,
  119199. this._material = l
  119200. }
  119201. return Object.defineProperty(e.prototype, "shapeID", {
  119202. get: function() {
  119203. return this.shapeId
  119204. },
  119205. set: function(e) {
  119206. this.shapeId = e
  119207. },
  119208. enumerable: !1,
  119209. configurable: !0
  119210. }),
  119211. e
  119212. }(), Ty = function(e, t, i, n) {
  119213. this.idx = 0,
  119214. this.ind = 0,
  119215. this.indicesLength = 0,
  119216. this.sqDistance = 0,
  119217. this.materialIndex = 0,
  119218. this.idx = e,
  119219. this.ind = t,
  119220. this.indicesLength = i,
  119221. this.materialIndex = n
  119222. }, Ey = function() {
  119223. function e() {
  119224. this.position = x.Zero(),
  119225. this.color = new N(1,1,1,1),
  119226. this.uv = A.Zero()
  119227. }
  119228. return Object.defineProperty(e.prototype, "x", {
  119229. get: function() {
  119230. return this.position.x
  119231. },
  119232. set: function(e) {
  119233. this.position.x = e
  119234. },
  119235. enumerable: !1,
  119236. configurable: !0
  119237. }),
  119238. Object.defineProperty(e.prototype, "y", {
  119239. get: function() {
  119240. return this.position.y
  119241. },
  119242. set: function(e) {
  119243. this.position.y = e
  119244. },
  119245. enumerable: !1,
  119246. configurable: !0
  119247. }),
  119248. Object.defineProperty(e.prototype, "z", {
  119249. get: function() {
  119250. return this.position.z
  119251. },
  119252. set: function(e) {
  119253. this.position.z = e
  119254. },
  119255. enumerable: !1,
  119256. configurable: !0
  119257. }),
  119258. e
  119259. }(), Sy = function() {
  119260. function e(e, t, i) {
  119261. this.particles = new Array,
  119262. this.nbParticles = 0,
  119263. this.billboard = !1,
  119264. this.recomputeNormals = !1,
  119265. this.counter = 0,
  119266. this.vars = {},
  119267. this._bSphereOnly = !1,
  119268. this._bSphereRadiusFactor = 1,
  119269. this._positions = new Array,
  119270. this._indices = new Array,
  119271. this._normals = new Array,
  119272. this._colors = new Array,
  119273. this._uvs = new Array,
  119274. this._index = 0,
  119275. this._updatable = !0,
  119276. this._pickable = !1,
  119277. this._isVisibilityBoxLocked = !1,
  119278. this._alwaysVisible = !1,
  119279. this._depthSort = !1,
  119280. this._expandable = !1,
  119281. this._shapeCounter = 0,
  119282. this._copy = new yy(0,0,0,0,null,0,0,this),
  119283. this._color = new N(0,0,0,0),
  119284. this._computeParticleColor = !0,
  119285. this._computeParticleTexture = !0,
  119286. this._computeParticleRotation = !0,
  119287. this._computeParticleVertex = !1,
  119288. this._computeBoundingBox = !1,
  119289. this._depthSortParticles = !0,
  119290. this._mustUnrotateFixedNormals = !1,
  119291. this._particlesIntersect = !1,
  119292. this._needs32Bits = !1,
  119293. this._isNotBuilt = !0,
  119294. this._lastParticleId = 0,
  119295. this._idxOfId = [],
  119296. this._multimaterialEnabled = !1,
  119297. this._useModelMaterial = !1,
  119298. this._depthSortFunction = function(e, t) {
  119299. return t.sqDistance - e.sqDistance
  119300. }
  119301. ,
  119302. this._materialSortFunction = function(e, t) {
  119303. return e.materialIndex - t.materialIndex
  119304. }
  119305. ,
  119306. this._autoUpdateSubMeshes = !1,
  119307. this.name = e,
  119308. this._scene = t || E.LastCreatedScene,
  119309. this._camera = t.activeCamera,
  119310. this._pickable = !!i && i.isPickable,
  119311. this._depthSort = !!i && i.enableDepthSort,
  119312. this._multimaterialEnabled = !!i && i.enableMultiMaterial,
  119313. this._useModelMaterial = !!i && i.useModelMaterial,
  119314. this._multimaterialEnabled = !!this._useModelMaterial || this._multimaterialEnabled,
  119315. this._expandable = !!i && i.expandable,
  119316. this._particlesIntersect = !!i && i.particleIntersection,
  119317. this._bSphereOnly = !!i && i.boundingSphereOnly,
  119318. this._bSphereRadiusFactor = i && i.bSphereRadiusFactor ? i.bSphereRadiusFactor : 1,
  119319. i && void 0 !== i.updatable ? this._updatable = i.updatable : this._updatable = !0,
  119320. this._pickable && (this.pickedBySubMesh = [[]],
  119321. this.pickedParticles = this.pickedBySubMesh[0]),
  119322. (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []),
  119323. this._multimaterialEnabled && (this._multimaterial = new Dr(this.name + "MultiMaterial",this._scene),
  119324. this._materials = [],
  119325. this._materialIndexesById = {}),
  119326. this._tmpVertex = new Ey
  119327. }
  119328. return e.prototype.buildMesh = function() {
  119329. if (!this._isNotBuilt && this.mesh)
  119330. return this.mesh;
  119331. if (0 === this.nbParticles && !this.mesh) {
  119332. var e = Pd("", {
  119333. radius: 1,
  119334. tessellation: 3
  119335. }, this._scene);
  119336. this.addShape(e, 1),
  119337. e.dispose()
  119338. }
  119339. if (this._indices32 = this._needs32Bits ? new Uint32Array(this._indices) : new Uint16Array(this._indices),
  119340. this._positions32 = new Float32Array(this._positions),
  119341. this._uvs32 = new Float32Array(this._uvs),
  119342. this._colors32 = new Float32Array(this._colors),
  119343. !this.mesh) {
  119344. var t = new Vr(this.name,this._scene);
  119345. this.mesh = t
  119346. }
  119347. !this._updatable && this._multimaterialEnabled && this._sortParticlesByMaterial(),
  119348. this.recomputeNormals && $n.ComputeNormals(this._positions32, this._indices32, this._normals),
  119349. this._normals32 = new Float32Array(this._normals),
  119350. this._fixedNormal32 = new Float32Array(this._normals),
  119351. this._mustUnrotateFixedNormals && this._unrotateFixedNormals();
  119352. var i = new $n;
  119353. if (i.indices = this._depthSort ? this._indices : this._indices32,
  119354. i.set(this._positions32, Bi.PositionKind),
  119355. i.set(this._normals32, Bi.NormalKind),
  119356. this._uvs32.length > 0 && i.set(this._uvs32, Bi.UVKind),
  119357. this._colors32.length > 0 && i.set(this._colors32, Bi.ColorKind),
  119358. i.applyToMesh(this.mesh, this._updatable),
  119359. this.mesh.isPickable = this._pickable,
  119360. this._pickable)
  119361. for (var n = 0, r = 0; r < this.nbParticles; r++)
  119362. for (var o = this.particles[r], a = o._model._indicesLength, s = 0; s < a; s++)
  119363. if (0 == s % 3) {
  119364. var l = {
  119365. idx: o.idx,
  119366. faceId: n
  119367. };
  119368. this.pickedParticles[n] = l,
  119369. n++
  119370. }
  119371. return this._multimaterialEnabled && this.setMultiMaterial(this._materials),
  119372. this._expandable || (this._depthSort || this._multimaterialEnabled || (this._indices = null),
  119373. this._positions = null,
  119374. this._normals = null,
  119375. this._uvs = null,
  119376. this._colors = null,
  119377. this._updatable || (this.particles.length = 0)),
  119378. this._isNotBuilt = !1,
  119379. this.recomputeNormals = !1,
  119380. this.mesh
  119381. }
  119382. ,
  119383. e.prototype.digest = function(e, t) {
  119384. var i = t && t.facetNb || 1
  119385. , n = t && t.number || 0
  119386. , r = t && t.delta || 0
  119387. , o = e.getVerticesData(Bi.PositionKind)
  119388. , a = e.getIndices()
  119389. , s = e.getVerticesData(Bi.UVKind)
  119390. , l = e.getVerticesData(Bi.ColorKind)
  119391. , c = e.getVerticesData(Bi.NormalKind)
  119392. , u = t && t.storage ? t.storage : null
  119393. , h = 0
  119394. , d = a.length / 3;
  119395. n ? (n = n > d ? d : n,
  119396. i = Math.round(d / n),
  119397. r = 0) : i = i > d ? d : i;
  119398. for (var p = [], f = [], _ = [], m = [], g = [], v = x.Zero(), y = i; h < d; ) {
  119399. h > d - (i = y + Math.floor((1 + r) * Math.random())) && (i = d - h),
  119400. p.length = 0,
  119401. f.length = 0,
  119402. _.length = 0,
  119403. m.length = 0,
  119404. g.length = 0;
  119405. for (var b = 0, T = 3 * h; T < 3 * (h + i); T++) {
  119406. _.push(b);
  119407. var E = a[T]
  119408. , S = 3 * E;
  119409. if (p.push(o[S], o[S + 1], o[S + 2]),
  119410. f.push(c[S], c[S + 1], c[S + 2]),
  119411. s) {
  119412. var A = 2 * E;
  119413. m.push(s[A], s[A + 1])
  119414. }
  119415. if (l) {
  119416. var R = 4 * E;
  119417. g.push(l[R], l[R + 1], l[R + 2], l[R + 3])
  119418. }
  119419. b++
  119420. }
  119421. var C = this.nbParticles
  119422. , P = this._posToShape(p)
  119423. , M = this._uvsToShapeUV(m)
  119424. , I = gi.Slice(_)
  119425. , O = gi.Slice(g)
  119426. , D = gi.Slice(f);
  119427. v.copyFromFloats(0, 0, 0);
  119428. var N = void 0;
  119429. for (N = 0; N < P.length; N++)
  119430. v.addInPlace(P[N]);
  119431. v.scaleInPlace(1 / P.length);
  119432. var L = new x(1 / 0,1 / 0,1 / 0)
  119433. , F = new x(-1 / 0,-1 / 0,-1 / 0);
  119434. for (N = 0; N < P.length; N++)
  119435. P[N].subtractInPlace(v),
  119436. L.minimizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z),
  119437. F.maximizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z);
  119438. var w = void 0;
  119439. this._particlesIntersect && (w = new sr(L,F));
  119440. var B = null;
  119441. this._useModelMaterial && (B = e.material ? e.material : this._setDefaultMaterial());
  119442. var U = new by(this._shapeCounter,P,I,D,O,M,null,null,B)
  119443. , V = this._positions.length
  119444. , k = this._indices.length;
  119445. this._meshBuilder(this._index, k, P, this._positions, I, this._indices, m, this._uvs, O, this._colors, D, this._normals, C, 0, null, U),
  119446. this._addParticle(C, this._lastParticleId, V, k, U, this._shapeCounter, 0, w, u),
  119447. this.particles[this.nbParticles].position.addInPlace(v),
  119448. u || (this._index += P.length,
  119449. C++,
  119450. this.nbParticles++,
  119451. this._lastParticleId++),
  119452. this._shapeCounter++,
  119453. h += i
  119454. }
  119455. return this._isNotBuilt = !0,
  119456. this
  119457. }
  119458. ,
  119459. e.prototype._unrotateFixedNormals = function() {
  119460. for (var e = 0, t = 0, i = I.Vector3[0], n = I.Quaternion[0], r = I.Matrix[0], o = 0; o < this.particles.length; o++) {
  119461. var a = this.particles[o]
  119462. , s = a._model._shape;
  119463. if (a.rotationQuaternion)
  119464. a.rotationQuaternion.conjugateToRef(n);
  119465. else {
  119466. var l = a.rotation;
  119467. C.RotationYawPitchRollToRef(l.y, l.x, l.z, n),
  119468. n.conjugateInPlace()
  119469. }
  119470. n.toRotationMatrix(r);
  119471. for (var c = 0; c < s.length; c++)
  119472. t = e + 3 * c,
  119473. x.TransformNormalFromFloatsToRef(this._normals32[t], this._normals32[t + 1], this._normals32[t + 2], r, i),
  119474. i.toArray(this._fixedNormal32, t);
  119475. e = t + 3
  119476. }
  119477. }
  119478. ,
  119479. e.prototype._resetCopy = function() {
  119480. var e = this._copy;
  119481. e.position.setAll(0),
  119482. e.rotation.setAll(0),
  119483. e.rotationQuaternion = null,
  119484. e.scaling.setAll(1),
  119485. e.uvs.copyFromFloats(0, 0, 1, 1),
  119486. e.color = null,
  119487. e.translateFromPivot = !1,
  119488. e.shapeId = 0,
  119489. e.materialIndex = null
  119490. }
  119491. ,
  119492. e.prototype._meshBuilder = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _) {
  119493. var m, g = 0, v = 0, y = 0;
  119494. this._resetCopy();
  119495. var b = this._copy
  119496. , T = !(!f || !f.storage);
  119497. if (b.idx = d,
  119498. b.idxInShape = p,
  119499. b.shapeId = _.shapeId,
  119500. this._useModelMaterial) {
  119501. var E = _._material.uniqueId
  119502. , S = this._materialIndexesById;
  119503. Object.prototype.hasOwnProperty.call(S, E) || (S[E] = this._materials.length,
  119504. this._materials.push(_._material));
  119505. var A = S[E];
  119506. b.materialIndex = A
  119507. }
  119508. if (f && f.positionFunction && (f.positionFunction(b, d, p),
  119509. this._mustUnrotateFixedNormals = !0),
  119510. T)
  119511. return b;
  119512. var R = I.Matrix[0]
  119513. , C = this._tmpVertex
  119514. , M = C.position
  119515. , O = C.color
  119516. , D = C.uv
  119517. , N = I.Vector3[1]
  119518. , L = I.Vector3[2]
  119519. , F = I.Vector3[3];
  119520. P.IdentityToRef(R),
  119521. b.getRotationMatrix(R),
  119522. b.pivot.multiplyToRef(b.scaling, F),
  119523. b.translateFromPivot ? L.setAll(0) : L.copyFrom(F);
  119524. var w = f && f.vertexFunction;
  119525. for (m = 0; m < i.length; m++) {
  119526. if (M.copyFrom(i[m]),
  119527. b.color && O.copyFrom(b.color),
  119528. a && D.copyFromFloats(a[g], a[g + 1]),
  119529. w && f.vertexFunction(b, C, m),
  119530. M.multiplyInPlace(b.scaling).subtractInPlace(F),
  119531. x.TransformCoordinatesToRef(M, R, N),
  119532. N.addInPlace(L).addInPlace(b.position),
  119533. n.push(N.x, N.y, N.z),
  119534. a) {
  119535. var B = b.uvs;
  119536. s.push((B.z - B.x) * D.x + B.x, (B.w - B.y) * D.y + B.y),
  119537. g += 2
  119538. }
  119539. if (b.color)
  119540. this._color.copyFrom(O);
  119541. else {
  119542. var U = this._color;
  119543. l && void 0 !== l[v] ? (U.r = l[v],
  119544. U.g = l[v + 1],
  119545. U.b = l[v + 2],
  119546. U.a = l[v + 3]) : (U.r = 1,
  119547. U.g = 1,
  119548. U.b = 1,
  119549. U.a = 1)
  119550. }
  119551. c.push(this._color.r, this._color.g, this._color.b, this._color.a),
  119552. v += 4,
  119553. !this.recomputeNormals && u && (x.TransformNormalFromFloatsToRef(u[y], u[y + 1], u[y + 2], R, M),
  119554. h.push(M.x, M.y, M.z),
  119555. y += 3)
  119556. }
  119557. for (m = 0; m < r.length; m++) {
  119558. var V = e + r[m];
  119559. o.push(V),
  119560. V > 65535 && (this._needs32Bits = !0)
  119561. }
  119562. if (this._depthSort || this._multimaterialEnabled) {
  119563. var k = null !== b.materialIndex ? b.materialIndex : 0;
  119564. this.depthSortedParticles.push(new Ty(d,t,r.length,k))
  119565. }
  119566. return b
  119567. }
  119568. ,
  119569. e.prototype._posToShape = function(e) {
  119570. for (var t = [], i = 0; i < e.length; i += 3)
  119571. t.push(x.FromArray(e, i));
  119572. return t
  119573. }
  119574. ,
  119575. e.prototype._uvsToShapeUV = function(e) {
  119576. var t = [];
  119577. if (e)
  119578. for (var i = 0; i < e.length; i++)
  119579. t.push(e[i]);
  119580. return t
  119581. }
  119582. ,
  119583. e.prototype._addParticle = function(e, t, i, n, r, o, a, s, l) {
  119584. void 0 === s && (s = null),
  119585. void 0 === l && (l = null);
  119586. var c = new yy(e,t,i,n,r,o,a,this,s);
  119587. return (l || this.particles).push(c),
  119588. c
  119589. }
  119590. ,
  119591. e.prototype.addShape = function(e, t, i) {
  119592. var n = e.getVerticesData(Bi.PositionKind)
  119593. , r = e.getIndices()
  119594. , o = e.getVerticesData(Bi.UVKind)
  119595. , a = e.getVerticesData(Bi.ColorKind)
  119596. , s = e.getVerticesData(Bi.NormalKind);
  119597. this.recomputeNormals = !s;
  119598. var l = gi.SliceToArray(r)
  119599. , c = gi.SliceToArray(s)
  119600. , u = a ? gi.SliceToArray(a) : []
  119601. , h = i && i.storage ? i.storage : null
  119602. , d = null;
  119603. this._particlesIntersect && (d = e.getBoundingInfo());
  119604. var p = this._posToShape(n)
  119605. , f = this._uvsToShapeUV(o)
  119606. , _ = i ? i.positionFunction : null
  119607. , m = i ? i.vertexFunction : null
  119608. , g = null;
  119609. this._useModelMaterial && (g = e.material ? e.material : this._setDefaultMaterial());
  119610. for (var v = new by(this._shapeCounter,p,l,c,u,f,_,m,g), y = 0; y < t; y++)
  119611. this._insertNewParticle(this.nbParticles, y, v, p, r, o, a, s, d, h, i);
  119612. return this._shapeCounter++,
  119613. this._isNotBuilt = !0,
  119614. this._shapeCounter - 1
  119615. }
  119616. ,
  119617. e.prototype._rebuildParticle = function(e, t) {
  119618. void 0 === t && (t = !1),
  119619. this._resetCopy();
  119620. var i = this._copy;
  119621. e._model._positionFunction && e._model._positionFunction(i, e.idx, e.idxInShape);
  119622. var n = I.Matrix[0]
  119623. , r = I.Vector3[0]
  119624. , o = I.Vector3[1]
  119625. , a = I.Vector3[2]
  119626. , s = I.Vector3[3];
  119627. i.getRotationMatrix(n),
  119628. e.pivot.multiplyToRef(e.scaling, s),
  119629. i.translateFromPivot ? a.copyFromFloats(0, 0, 0) : a.copyFrom(s);
  119630. for (var l = e._model._shape, c = 0; c < l.length; c++)
  119631. r.copyFrom(l[c]),
  119632. e._model._vertexFunction && e._model._vertexFunction(i, r, c),
  119633. r.multiplyInPlace(i.scaling).subtractInPlace(s),
  119634. x.TransformCoordinatesToRef(r, n, o),
  119635. o.addInPlace(a).addInPlace(i.position).toArray(this._positions32, e._pos + 3 * c);
  119636. t && (e.position.setAll(0),
  119637. e.rotation.setAll(0),
  119638. e.rotationQuaternion = null,
  119639. e.scaling.setAll(1),
  119640. e.uvs.setAll(0),
  119641. e.pivot.setAll(0),
  119642. e.translateFromPivot = !1,
  119643. e.parentId = null)
  119644. }
  119645. ,
  119646. e.prototype.rebuildMesh = function(e) {
  119647. void 0 === e && (e = !1);
  119648. for (var t = 0; t < this.particles.length; t++)
  119649. this._rebuildParticle(this.particles[t], e);
  119650. return this.mesh.updateVerticesData(Bi.PositionKind, this._positions32, !1, !1),
  119651. this
  119652. }
  119653. ,
  119654. e.prototype.removeParticles = function(e, t) {
  119655. var i = t - e + 1;
  119656. if (!this._expandable || i <= 0 || i >= this.nbParticles || !this._updatable)
  119657. return [];
  119658. var n = this.particles
  119659. , r = this.nbParticles;
  119660. if (t < r - 1)
  119661. for (var o = t + 1, a = n[o]._pos - n[e]._pos, s = n[o]._ind - n[e]._ind, l = o; l < r; l++) {
  119662. var c = n[l];
  119663. c._pos -= a,
  119664. c._ind -= s
  119665. }
  119666. var u = n.splice(e, i);
  119667. this._positions.length = 0,
  119668. this._indices.length = 0,
  119669. this._colors.length = 0,
  119670. this._uvs.length = 0,
  119671. this._normals.length = 0,
  119672. this._index = 0,
  119673. this._idxOfId.length = 0,
  119674. (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []);
  119675. for (var h = 0, d = n.length, p = 0; p < d; p++) {
  119676. var f = n[p]
  119677. , _ = f._model
  119678. , m = _._shape
  119679. , g = _._indices
  119680. , v = _._normals
  119681. , y = _._shapeColors
  119682. , b = _._shapeUV;
  119683. f.idx = p,
  119684. this._idxOfId[f.id] = p,
  119685. this._meshBuilder(this._index, h, m, this._positions, g, this._indices, b, this._uvs, y, this._colors, v, this._normals, f.idx, f.idxInShape, null, _),
  119686. this._index += m.length,
  119687. h += g.length
  119688. }
  119689. return this.nbParticles -= i,
  119690. this._isNotBuilt = !0,
  119691. u
  119692. }
  119693. ,
  119694. e.prototype.insertParticlesFromArray = function(e) {
  119695. if (!this._expandable)
  119696. return this;
  119697. for (var t = 0, i = e[0].shapeId, n = e.length, r = 0; r < n; r++) {
  119698. var o = e[r]
  119699. , a = o._model
  119700. , s = a._shape
  119701. , l = a._indices
  119702. , c = a._shapeUV
  119703. , u = a._shapeColors
  119704. , h = a._normals
  119705. , d = !h;
  119706. this.recomputeNormals = d || this.recomputeNormals;
  119707. var p = o.getBoundingInfo()
  119708. , f = this._insertNewParticle(this.nbParticles, t, a, s, l, c, u, h, p, null, null);
  119709. o.copyToRef(f),
  119710. t++,
  119711. i != o.shapeId && (i = o.shapeId,
  119712. t = 0)
  119713. }
  119714. return this._isNotBuilt = !0,
  119715. this
  119716. }
  119717. ,
  119718. e.prototype._insertNewParticle = function(e, t, i, n, r, o, a, s, l, c, u) {
  119719. var h = this._positions.length
  119720. , d = this._indices.length
  119721. , p = this._meshBuilder(this._index, d, n, this._positions, r, this._indices, o, this._uvs, a, this._colors, s, this._normals, e, t, u, i)
  119722. , f = null;
  119723. return this._updatable && ((f = this._addParticle(this.nbParticles, this._lastParticleId, h, d, i, this._shapeCounter, t, l, c)).position.copyFrom(p.position),
  119724. f.rotation.copyFrom(p.rotation),
  119725. p.rotationQuaternion && (f.rotationQuaternion ? f.rotationQuaternion.copyFrom(p.rotationQuaternion) : f.rotationQuaternion = p.rotationQuaternion.clone()),
  119726. p.color && (f.color ? f.color.copyFrom(p.color) : f.color = p.color.clone()),
  119727. f.scaling.copyFrom(p.scaling),
  119728. f.uvs.copyFrom(p.uvs),
  119729. null !== p.materialIndex && (f.materialIndex = p.materialIndex),
  119730. this.expandable && (this._idxOfId[f.id] = f.idx)),
  119731. c || (this._index += n.length,
  119732. this.nbParticles++,
  119733. this._lastParticleId++),
  119734. f
  119735. }
  119736. ,
  119737. e.prototype.setParticles = function(e, t, i) {
  119738. if (void 0 === e && (e = 0),
  119739. void 0 === t && (t = this.nbParticles - 1),
  119740. void 0 === i && (i = !0),
  119741. !this._updatable || this._isNotBuilt)
  119742. return this;
  119743. this.beforeUpdateParticles(e, t, i);
  119744. var n = I.Matrix[0]
  119745. , r = I.Matrix[1]
  119746. , o = this.mesh
  119747. , a = this._colors32
  119748. , s = this._positions32
  119749. , l = this._normals32
  119750. , c = this._uvs32
  119751. , u = this._indices32
  119752. , h = this._indices
  119753. , d = this._fixedNormal32
  119754. , p = I.Vector3
  119755. , f = p[5].copyFromFloats(1, 0, 0)
  119756. , _ = p[6].copyFromFloats(0, 1, 0)
  119757. , m = p[7].copyFromFloats(0, 0, 1)
  119758. , g = p[8].setAll(Number.MAX_VALUE)
  119759. , v = p[9].setAll(-Number.MAX_VALUE)
  119760. , y = p[10].setAll(0)
  119761. , b = this._tmpVertex
  119762. , T = b.position
  119763. , E = b.color
  119764. , S = b.uv;
  119765. if ((this.billboard || this._depthSort) && (this.mesh.computeWorldMatrix(!0),
  119766. this.mesh._worldMatrix.invertToRef(r)),
  119767. this.billboard) {
  119768. var A = p[0];
  119769. this._camera.getDirectionToRef(vn.Z, A),
  119770. x.TransformNormalToRef(A, r, m),
  119771. m.normalize();
  119772. var R = this._camera.getViewMatrix(!0);
  119773. x.TransformNormalFromFloatsToRef(R.m[1], R.m[5], R.m[9], r, _),
  119774. x.CrossToRef(_, m, f),
  119775. _.normalize(),
  119776. f.normalize()
  119777. }
  119778. this._depthSort && x.TransformCoordinatesToRef(this._camera.globalPosition, r, y),
  119779. P.IdentityToRef(n);
  119780. var C = 0
  119781. , M = 0
  119782. , O = 0
  119783. , D = 0
  119784. , N = 0
  119785. , L = 0
  119786. , F = 0;
  119787. if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0),
  119788. t = t >= this.nbParticles ? this.nbParticles - 1 : t,
  119789. this._computeBoundingBox && (0 != e || t != this.nbParticles - 1)) {
  119790. var w = this.mesh.getBoundingInfo();
  119791. w && (g.copyFrom(w.minimum),
  119792. v.copyFrom(w.maximum))
  119793. }
  119794. var B = (M = this.particles[e]._pos) / 3 | 0;
  119795. D = 4 * B,
  119796. L = 2 * B;
  119797. for (var U = e; U <= t; U++) {
  119798. var V = this.particles[U];
  119799. this.updateParticle(V);
  119800. var k = V._model._shape
  119801. , G = V._model._shapeUV
  119802. , z = V._rotationMatrix
  119803. , W = V.position
  119804. , H = V.rotation
  119805. , X = V.scaling
  119806. , j = V._globalPosition;
  119807. if (this._depthSort && this._depthSortParticles) {
  119808. var Y = this.depthSortedParticles[U];
  119809. Y.idx = V.idx,
  119810. Y.ind = V._ind,
  119811. Y.indicesLength = V._model._indicesLength,
  119812. Y.sqDistance = x.DistanceSquared(V.position, y)
  119813. }
  119814. if (!V.alive || V._stillInvisible && !V.isVisible)
  119815. M += 3 * (F = k.length),
  119816. D += 4 * F,
  119817. L += 2 * F;
  119818. else {
  119819. if (V.isVisible) {
  119820. V._stillInvisible = !1;
  119821. var K = p[12];
  119822. if (V.pivot.multiplyToRef(X, K),
  119823. this.billboard && (H.x = 0,
  119824. H.y = 0),
  119825. (this._computeParticleRotation || this.billboard) && V.getRotationMatrix(n),
  119826. null !== V.parentId) {
  119827. var Q = this.getParticleById(V.parentId);
  119828. if (Q) {
  119829. var q = Q._rotationMatrix
  119830. , Z = Q._globalPosition
  119831. , J = W.x * q[1] + W.y * q[4] + W.z * q[7]
  119832. , $ = W.x * q[0] + W.y * q[3] + W.z * q[6]
  119833. , ee = W.x * q[2] + W.y * q[5] + W.z * q[8];
  119834. if (j.x = Z.x + $,
  119835. j.y = Z.y + J,
  119836. j.z = Z.z + ee,
  119837. this._computeParticleRotation || this.billboard) {
  119838. var te = n.m;
  119839. z[0] = te[0] * q[0] + te[1] * q[3] + te[2] * q[6],
  119840. z[1] = te[0] * q[1] + te[1] * q[4] + te[2] * q[7],
  119841. z[2] = te[0] * q[2] + te[1] * q[5] + te[2] * q[8],
  119842. z[3] = te[4] * q[0] + te[5] * q[3] + te[6] * q[6],
  119843. z[4] = te[4] * q[1] + te[5] * q[4] + te[6] * q[7],
  119844. z[5] = te[4] * q[2] + te[5] * q[5] + te[6] * q[8],
  119845. z[6] = te[8] * q[0] + te[9] * q[3] + te[10] * q[6],
  119846. z[7] = te[8] * q[1] + te[9] * q[4] + te[10] * q[7],
  119847. z[8] = te[8] * q[2] + te[9] * q[5] + te[10] * q[8]
  119848. }
  119849. } else
  119850. V.parentId = null
  119851. } else
  119852. j.x = W.x,
  119853. j.y = W.y,
  119854. j.z = W.z,
  119855. (this._computeParticleRotation || this.billboard) && (te = n.m,
  119856. z[0] = te[0],
  119857. z[1] = te[1],
  119858. z[2] = te[2],
  119859. z[3] = te[4],
  119860. z[4] = te[5],
  119861. z[5] = te[6],
  119862. z[6] = te[8],
  119863. z[7] = te[9],
  119864. z[8] = te[10]);
  119865. var ie = p[11];
  119866. for (V.translateFromPivot ? ie.setAll(0) : ie.copyFrom(K),
  119867. F = 0; F < k.length; F++) {
  119868. C = M + 3 * F,
  119869. O = D + 4 * F,
  119870. N = L + 2 * F;
  119871. var ne = 2 * F
  119872. , re = ne + 1;
  119873. T.copyFrom(k[F]),
  119874. this._computeParticleColor && V.color && E.copyFrom(V.color),
  119875. this._computeParticleTexture && S.copyFromFloats(G[ne], G[re]),
  119876. this._computeParticleVertex && this.updateParticleVertex(V, b, F);
  119877. var oe = T.x * X.x - K.x
  119878. , ae = T.y * X.y - K.y
  119879. , se = T.z * X.z - K.z;
  119880. $ = oe * z[0] + ae * z[3] + se * z[6],
  119881. J = oe * z[1] + ae * z[4] + se * z[7],
  119882. ee = oe * z[2] + ae * z[5] + se * z[8],
  119883. $ += ie.x,
  119884. J += ie.y,
  119885. ee += ie.z;
  119886. var le = s[C] = j.x + f.x * $ + _.x * J + m.x * ee
  119887. , ce = s[C + 1] = j.y + f.y * $ + _.y * J + m.y * ee
  119888. , ue = s[C + 2] = j.z + f.z * $ + _.z * J + m.z * ee;
  119889. if (this._computeBoundingBox && (g.minimizeInPlaceFromFloats(le, ce, ue),
  119890. v.maximizeInPlaceFromFloats(le, ce, ue)),
  119891. !this._computeParticleVertex) {
  119892. var he = d[C]
  119893. , de = d[C + 1]
  119894. , pe = d[C + 2]
  119895. , fe = he * z[0] + de * z[3] + pe * z[6]
  119896. , _e = he * z[1] + de * z[4] + pe * z[7]
  119897. , me = he * z[2] + de * z[5] + pe * z[8];
  119898. l[C] = f.x * fe + _.x * _e + m.x * me,
  119899. l[C + 1] = f.y * fe + _.y * _e + m.y * me,
  119900. l[C + 2] = f.z * fe + _.z * _e + m.z * me
  119901. }
  119902. if (this._computeParticleColor && V.color) {
  119903. var ge = this._colors32;
  119904. ge[O] = E.r,
  119905. ge[O + 1] = E.g,
  119906. ge[O + 2] = E.b,
  119907. ge[O + 3] = E.a
  119908. }
  119909. if (this._computeParticleTexture) {
  119910. var ve = V.uvs;
  119911. c[N] = S.x * (ve.z - ve.x) + ve.x,
  119912. c[N + 1] = S.y * (ve.w - ve.y) + ve.y
  119913. }
  119914. }
  119915. } else
  119916. for (V._stillInvisible = !0,
  119917. F = 0; F < k.length; F++) {
  119918. if (O = D + 4 * F,
  119919. N = L + 2 * F,
  119920. s[C = M + 3 * F] = s[C + 1] = s[C + 2] = 0,
  119921. l[C] = l[C + 1] = l[C + 2] = 0,
  119922. this._computeParticleColor && V.color) {
  119923. var ye = V.color;
  119924. a[O] = ye.r,
  119925. a[O + 1] = ye.g,
  119926. a[O + 2] = ye.b,
  119927. a[O + 3] = ye.a
  119928. }
  119929. this._computeParticleTexture && (ve = V.uvs,
  119930. c[N] = G[2 * F] * (ve.z - ve.x) + ve.x,
  119931. c[N + 1] = G[2 * F + 1] * (ve.w - ve.y) + ve.y)
  119932. }
  119933. if (this._particlesIntersect) {
  119934. var be = V.getBoundingInfo()
  119935. , Te = be.boundingBox
  119936. , Ee = be.boundingSphere
  119937. , Se = V._modelBoundingInfo;
  119938. if (!this._bSphereOnly) {
  119939. var Ae = Se.boundingBox.vectors
  119940. , xe = p[1]
  119941. , Re = p[2];
  119942. xe.setAll(Number.MAX_VALUE),
  119943. Re.setAll(-Number.MAX_VALUE);
  119944. for (var Ce = 0; Ce < 8; Ce++) {
  119945. var Pe = Ae[Ce].x * X.x
  119946. , Me = Ae[Ce].y * X.y
  119947. , Ie = Ae[Ce].z * X.z
  119948. , Oe = ($ = Pe * z[0] + Me * z[3] + Ie * z[6],
  119949. J = Pe * z[1] + Me * z[4] + Ie * z[7],
  119950. ee = Pe * z[2] + Me * z[5] + Ie * z[8],
  119951. W.x + f.x * $ + _.x * J + m.x * ee)
  119952. , De = W.y + f.y * $ + _.y * J + m.y * ee
  119953. , Ne = W.z + f.z * $ + _.z * J + m.z * ee;
  119954. xe.minimizeInPlaceFromFloats(Oe, De, Ne),
  119955. Re.maximizeInPlaceFromFloats(Oe, De, Ne)
  119956. }
  119957. Te.reConstruct(xe, Re, o._worldMatrix)
  119958. }
  119959. var Le = Se.minimum.multiplyToRef(X, p[1])
  119960. , Fe = Se.maximum.multiplyToRef(X, p[2])
  119961. , we = Fe.addToRef(Le, p[3]).scaleInPlace(.5).addInPlace(j)
  119962. , Be = Fe.subtractToRef(Le, p[4]).scaleInPlace(.5 * this._bSphereRadiusFactor)
  119963. , Ue = we.subtractToRef(Be, p[1])
  119964. , Ve = we.addToRef(Be, p[2]);
  119965. Ee.reConstruct(Ue, Ve, o._worldMatrix)
  119966. }
  119967. M = C + 3,
  119968. D = O + 4,
  119969. L = N + 2
  119970. }
  119971. }
  119972. if (i) {
  119973. this._computeParticleColor && ((We = o.getVertexBuffer(Bi.ColorKind)) && !o.isPickable ? We.updateDirectly(a, 0) : o.updateVerticesData(Bi.ColorKind, a, !1, !1)),
  119974. this._computeParticleTexture && ((We = o.getVertexBuffer(Bi.UVKind)) && !o.isPickable ? We.updateDirectly(c, 0) : o.updateVerticesData(Bi.UVKind, c, !1, !1));
  119975. var ke = o.getVertexBuffer(Bi.PositionKind);
  119976. if (ke && !o.isPickable ? ke.updateDirectly(s, 0) : o.updateVerticesData(Bi.PositionKind, s, !1, !1),
  119977. !o.areNormalsFrozen || o.isFacetDataEnabled) {
  119978. if (this._computeParticleVertex || o.isFacetDataEnabled) {
  119979. var Ge = o.isFacetDataEnabled ? o.getFacetDataParameters() : null;
  119980. $n.ComputeNormals(s, u, l, Ge);
  119981. for (var ze = 0; ze < l.length; ze++)
  119982. d[ze] = l[ze]
  119983. }
  119984. var We;
  119985. o.areNormalsFrozen || ((We = o.getVertexBuffer(Bi.NormalKind)) && !o.isPickable ? We.updateDirectly(l, 0) : o.updateVerticesData(Bi.NormalKind, l, !1, !1))
  119986. }
  119987. if (this._depthSort && this._depthSortParticles) {
  119988. var He = this.depthSortedParticles;
  119989. He.sort(this._depthSortFunction);
  119990. for (var Xe = He.length, je = 0, Ye = 0, Ke = 0; Ke < Xe; Ke++) {
  119991. var Qe = He[Ke]
  119992. , qe = Qe.indicesLength
  119993. , Ze = Qe.ind;
  119994. for (ze = 0; ze < qe; ze++)
  119995. if (u[je] = h[Ze + ze],
  119996. je++,
  119997. this._pickable && 0 == ze % 3) {
  119998. var Je = this.pickedParticles[Ye];
  119999. Je.idx = Qe.idx,
  120000. Je.faceId = Ye,
  120001. Ye++
  120002. }
  120003. }
  120004. o.updateIndices(u)
  120005. }
  120006. }
  120007. return this._computeBoundingBox && (o.hasBoundingInfo ? o.getBoundingInfo().reConstruct(g, v, o._worldMatrix) : o.buildBoundingInfo(g, v, o._worldMatrix)),
  120008. this._autoUpdateSubMeshes && this.computeSubMeshes(),
  120009. this.afterUpdateParticles(e, t, i),
  120010. this
  120011. }
  120012. ,
  120013. e.prototype.dispose = function() {
  120014. this.mesh.dispose(),
  120015. this.vars = null,
  120016. this._positions = null,
  120017. this._indices = null,
  120018. this._normals = null,
  120019. this._uvs = null,
  120020. this._colors = null,
  120021. this._indices32 = null,
  120022. this._positions32 = null,
  120023. this._normals32 = null,
  120024. this._fixedNormal32 = null,
  120025. this._uvs32 = null,
  120026. this._colors32 = null,
  120027. this.pickedParticles = null,
  120028. this.pickedBySubMesh = null,
  120029. this._materials = null,
  120030. this._materialIndexes = null,
  120031. this._indicesByMaterial = null,
  120032. this._idxOfId = null
  120033. }
  120034. ,
  120035. e.prototype.pickedParticle = function(e) {
  120036. if (e.hit) {
  120037. var t = e.subMeshId
  120038. , i = e.faceId - this.mesh.subMeshes[t].indexStart / 3
  120039. , n = this.pickedBySubMesh;
  120040. if (n[t] && n[t][i])
  120041. return n[t][i]
  120042. }
  120043. return null
  120044. }
  120045. ,
  120046. e.prototype.getParticleById = function(e) {
  120047. var t = this.particles[e];
  120048. if (t && t.id == e)
  120049. return t;
  120050. var i = this.particles
  120051. , n = this._idxOfId[e];
  120052. if (void 0 !== n)
  120053. return i[n];
  120054. for (var r = 0, o = this.nbParticles; r < o; ) {
  120055. var a = i[r];
  120056. if (a.id == e)
  120057. return a;
  120058. r++
  120059. }
  120060. return null
  120061. }
  120062. ,
  120063. e.prototype.getParticlesByShapeId = function(e) {
  120064. var t = [];
  120065. return this.getParticlesByShapeIdToRef(e, t),
  120066. t
  120067. }
  120068. ,
  120069. e.prototype.getParticlesByShapeIdToRef = function(e, t) {
  120070. t.length = 0;
  120071. for (var i = 0; i < this.nbParticles; i++) {
  120072. var n = this.particles[i];
  120073. n.shapeId == e && t.push(n)
  120074. }
  120075. return this
  120076. }
  120077. ,
  120078. e.prototype.computeSubMeshes = function() {
  120079. if (!this.mesh || !this._multimaterialEnabled)
  120080. return this;
  120081. var e = this.depthSortedParticles;
  120082. if (this.particles.length > 0)
  120083. for (var t = 0; t < this.particles.length; t++) {
  120084. var i = this.particles[t];
  120085. i.materialIndex || (i.materialIndex = 0);
  120086. var n = e[t];
  120087. n.materialIndex = i.materialIndex,
  120088. n.ind = i._ind,
  120089. n.indicesLength = i._model._indicesLength,
  120090. n.idx = i.idx
  120091. }
  120092. this._sortParticlesByMaterial();
  120093. var r = this._indicesByMaterial
  120094. , o = this._materialIndexes
  120095. , a = this.mesh;
  120096. a.subMeshes = [];
  120097. for (var s = a.getTotalVertices(), l = 0; l < o.length; l++) {
  120098. var c = r[l]
  120099. , u = r[l + 1] - c
  120100. , h = o[l];
  120101. new hr(h,0,s,c,u,a)
  120102. }
  120103. return this
  120104. }
  120105. ,
  120106. e.prototype._sortParticlesByMaterial = function() {
  120107. var e = [0];
  120108. this._indicesByMaterial = e;
  120109. var t = [];
  120110. this._materialIndexes = t;
  120111. var i = this.depthSortedParticles;
  120112. i.sort(this._materialSortFunction);
  120113. var n = i.length
  120114. , r = this._indices32
  120115. , o = this._indices
  120116. , a = 0
  120117. , s = 0
  120118. , l = 0
  120119. , c = i[0].materialIndex;
  120120. t.push(c),
  120121. this._pickable && (this.pickedBySubMesh = [[]],
  120122. this.pickedParticles = this.pickedBySubMesh[0]);
  120123. for (var u = 0; u < n; u++) {
  120124. var h = i[u]
  120125. , d = h.indicesLength
  120126. , p = h.ind;
  120127. h.materialIndex !== c && (c = h.materialIndex,
  120128. e.push(l),
  120129. t.push(c),
  120130. this._pickable && (a++,
  120131. this.pickedBySubMesh[a] = [],
  120132. s = 0));
  120133. for (var f = 0, _ = 0; _ < d; _++) {
  120134. if (r[l] = o[p + _],
  120135. this._pickable && 0 == _ % 3) {
  120136. var m = this.pickedBySubMesh[a][s];
  120137. m ? (m.idx = h.idx,
  120138. m.faceId = f) : this.pickedBySubMesh[a][s] = {
  120139. idx: h.idx,
  120140. faceId: f
  120141. },
  120142. s++,
  120143. f++
  120144. }
  120145. l++
  120146. }
  120147. }
  120148. return e.push(r.length),
  120149. this._updatable && this.mesh.updateIndices(r),
  120150. this
  120151. }
  120152. ,
  120153. e.prototype._setMaterialIndexesById = function() {
  120154. this._materialIndexesById = {};
  120155. for (var e = 0; e < this._materials.length; e++) {
  120156. var t = this._materials[e].uniqueId;
  120157. this._materialIndexesById[t] = e
  120158. }
  120159. }
  120160. ,
  120161. e.prototype._filterUniqueMaterialId = function(e) {
  120162. return e.filter((function(e, t, i) {
  120163. return i.indexOf(e) === t
  120164. }
  120165. ))
  120166. }
  120167. ,
  120168. e.prototype._setDefaultMaterial = function() {
  120169. return this._defaultMaterial || (this._defaultMaterial = new Os(this.name + "DefaultMaterial",this._scene)),
  120170. this._defaultMaterial
  120171. }
  120172. ,
  120173. e.prototype.refreshVisibleSize = function() {
  120174. return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(),
  120175. this
  120176. }
  120177. ,
  120178. e.prototype.setVisibilityBox = function(e) {
  120179. var t = e / 2;
  120180. this.mesh.buildBoundingInfo(new x(-t,-t,-t), new x(t,t,t))
  120181. }
  120182. ,
  120183. Object.defineProperty(e.prototype, "isAlwaysVisible", {
  120184. get: function() {
  120185. return this._alwaysVisible
  120186. },
  120187. set: function(e) {
  120188. this._alwaysVisible = e,
  120189. this.mesh.alwaysSelectAsActiveMesh = e
  120190. },
  120191. enumerable: !1,
  120192. configurable: !0
  120193. }),
  120194. Object.defineProperty(e.prototype, "isVisibilityBoxLocked", {
  120195. get: function() {
  120196. return this._isVisibilityBoxLocked
  120197. },
  120198. set: function(e) {
  120199. this._isVisibilityBoxLocked = e,
  120200. this.mesh.getBoundingInfo().isLocked = e
  120201. },
  120202. enumerable: !1,
  120203. configurable: !0
  120204. }),
  120205. Object.defineProperty(e.prototype, "computeParticleRotation", {
  120206. get: function() {
  120207. return this._computeParticleRotation
  120208. },
  120209. set: function(e) {
  120210. this._computeParticleRotation = e
  120211. },
  120212. enumerable: !1,
  120213. configurable: !0
  120214. }),
  120215. Object.defineProperty(e.prototype, "computeParticleColor", {
  120216. get: function() {
  120217. return this._computeParticleColor
  120218. },
  120219. set: function(e) {
  120220. this._computeParticleColor = e
  120221. },
  120222. enumerable: !1,
  120223. configurable: !0
  120224. }),
  120225. Object.defineProperty(e.prototype, "computeParticleTexture", {
  120226. get: function() {
  120227. return this._computeParticleTexture
  120228. },
  120229. set: function(e) {
  120230. this._computeParticleTexture = e
  120231. },
  120232. enumerable: !1,
  120233. configurable: !0
  120234. }),
  120235. Object.defineProperty(e.prototype, "computeParticleVertex", {
  120236. get: function() {
  120237. return this._computeParticleVertex
  120238. },
  120239. set: function(e) {
  120240. this._computeParticleVertex = e
  120241. },
  120242. enumerable: !1,
  120243. configurable: !0
  120244. }),
  120245. Object.defineProperty(e.prototype, "computeBoundingBox", {
  120246. get: function() {
  120247. return this._computeBoundingBox
  120248. },
  120249. set: function(e) {
  120250. this._computeBoundingBox = e
  120251. },
  120252. enumerable: !1,
  120253. configurable: !0
  120254. }),
  120255. Object.defineProperty(e.prototype, "depthSortParticles", {
  120256. get: function() {
  120257. return this._depthSortParticles
  120258. },
  120259. set: function(e) {
  120260. this._depthSortParticles = e
  120261. },
  120262. enumerable: !1,
  120263. configurable: !0
  120264. }),
  120265. Object.defineProperty(e.prototype, "expandable", {
  120266. get: function() {
  120267. return this._expandable
  120268. },
  120269. enumerable: !1,
  120270. configurable: !0
  120271. }),
  120272. Object.defineProperty(e.prototype, "multimaterialEnabled", {
  120273. get: function() {
  120274. return this._multimaterialEnabled
  120275. },
  120276. enumerable: !1,
  120277. configurable: !0
  120278. }),
  120279. Object.defineProperty(e.prototype, "useModelMaterial", {
  120280. get: function() {
  120281. return this._useModelMaterial
  120282. },
  120283. enumerable: !1,
  120284. configurable: !0
  120285. }),
  120286. Object.defineProperty(e.prototype, "materials", {
  120287. get: function() {
  120288. return this._materials
  120289. },
  120290. enumerable: !1,
  120291. configurable: !0
  120292. }),
  120293. e.prototype.setMultiMaterial = function(e) {
  120294. this._materials = this._filterUniqueMaterialId(e),
  120295. this._setMaterialIndexesById(),
  120296. this._multimaterial && this._multimaterial.dispose(),
  120297. this._multimaterial = new Dr(this.name + "MultiMaterial",this._scene);
  120298. for (var t = 0; t < this._materials.length; t++)
  120299. this._multimaterial.subMaterials.push(this._materials[t]);
  120300. this.computeSubMeshes(),
  120301. this.mesh.material = this._multimaterial
  120302. }
  120303. ,
  120304. Object.defineProperty(e.prototype, "multimaterial", {
  120305. get: function() {
  120306. return this._multimaterial
  120307. },
  120308. set: function(e) {
  120309. this._multimaterial = e
  120310. },
  120311. enumerable: !1,
  120312. configurable: !0
  120313. }),
  120314. Object.defineProperty(e.prototype, "autoUpdateSubMeshes", {
  120315. get: function() {
  120316. return this._autoUpdateSubMeshes
  120317. },
  120318. set: function(e) {
  120319. this._autoUpdateSubMeshes = e
  120320. },
  120321. enumerable: !1,
  120322. configurable: !0
  120323. }),
  120324. e.prototype.initParticles = function() {}
  120325. ,
  120326. e.prototype.recycleParticle = function(e) {
  120327. return e
  120328. }
  120329. ,
  120330. e.prototype.updateParticle = function(e) {
  120331. return e
  120332. }
  120333. ,
  120334. e.prototype.updateParticleVertex = function(e, t, i) {
  120335. return this
  120336. }
  120337. ,
  120338. e.prototype.beforeUpdateParticles = function(e, t, i) {}
  120339. ,
  120340. e.prototype.afterUpdateParticles = function(e, t, i) {}
  120341. ,
  120342. e
  120343. }(), Ay = function() {
  120344. function e(e, t, i, n, r) {
  120345. this.idx = 0,
  120346. this.color = new N(1,1,1,1),
  120347. this.position = x.Zero(),
  120348. this.rotation = x.Zero(),
  120349. this.uv = new A(0,0),
  120350. this.velocity = x.Zero(),
  120351. this.pivot = x.Zero(),
  120352. this.translateFromPivot = !1,
  120353. this._pos = 0,
  120354. this._ind = 0,
  120355. this.groupId = 0,
  120356. this.idxInGroup = 0,
  120357. this._stillInvisible = !1,
  120358. this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1],
  120359. this.parentId = null,
  120360. this._globalPosition = x.Zero(),
  120361. this.idx = e,
  120362. this._group = t,
  120363. this.groupId = i,
  120364. this.idxInGroup = n,
  120365. this._pcs = r
  120366. }
  120367. return Object.defineProperty(e.prototype, "size", {
  120368. get: function() {
  120369. return this.size
  120370. },
  120371. set: function(e) {
  120372. this.size = e
  120373. },
  120374. enumerable: !1,
  120375. configurable: !0
  120376. }),
  120377. Object.defineProperty(e.prototype, "quaternion", {
  120378. get: function() {
  120379. return this.rotationQuaternion
  120380. },
  120381. set: function(e) {
  120382. this.rotationQuaternion = e
  120383. },
  120384. enumerable: !1,
  120385. configurable: !0
  120386. }),
  120387. e.prototype.intersectsMesh = function(e, t) {
  120388. if (!e.hasBoundingInfo)
  120389. return !1;
  120390. if (t = t || !1)
  120391. return e.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));
  120392. var i, n, r, o, a, s;
  120393. i = e.getBoundingInfo().boundingBox.maximumWorld.x,
  120394. n = e.getBoundingInfo().boundingBox.minimumWorld.x,
  120395. r = e.getBoundingInfo().boundingBox.maximumWorld.y,
  120396. o = e.getBoundingInfo().boundingBox.minimumWorld.y,
  120397. a = e.getBoundingInfo().boundingBox.maximumWorld.z,
  120398. s = e.getBoundingInfo().boundingBox.minimumWorld.z;
  120399. var l = this.position.x + this._pcs.mesh.position.x
  120400. , c = this.position.y + this._pcs.mesh.position.y
  120401. , u = this.position.z + this._pcs.mesh.position.z;
  120402. return n <= l && l <= i && o <= c && c <= r && s <= u && u <= a
  120403. }
  120404. ,
  120405. e.prototype.getRotationMatrix = function(e) {
  120406. var t;
  120407. if (this.rotationQuaternion)
  120408. t = this.rotationQuaternion;
  120409. else {
  120410. t = I.Quaternion[0];
  120411. var i = this.rotation;
  120412. C.RotationYawPitchRollToRef(i.y, i.x, i.z, t)
  120413. }
  120414. t.toRotationMatrix(e)
  120415. }
  120416. ,
  120417. e
  120418. }(), xy = function() {
  120419. function e(e, t) {
  120420. this.groupId = e,
  120421. this._positionFunction = t
  120422. }
  120423. return Object.defineProperty(e.prototype, "groupID", {
  120424. get: function() {
  120425. return this.groupId
  120426. },
  120427. set: function(e) {
  120428. this.groupId = e
  120429. },
  120430. enumerable: !1,
  120431. configurable: !0
  120432. }),
  120433. e
  120434. }();
  120435. !function(e) {
  120436. e[e.Color = 2] = "Color",
  120437. e[e.UV = 1] = "UV",
  120438. e[e.Random = 0] = "Random",
  120439. e[e.Stated = 3] = "Stated"
  120440. }(vy || (vy = {}));
  120441. var Ry = function() {
  120442. function e(e, t, i, n) {
  120443. this.particles = new Array,
  120444. this.nbParticles = 0,
  120445. this.counter = 0,
  120446. this.vars = {},
  120447. this._promises = [],
  120448. this._positions = new Array,
  120449. this._indices = new Array,
  120450. this._normals = new Array,
  120451. this._colors = new Array,
  120452. this._uvs = new Array,
  120453. this._updatable = !0,
  120454. this._isVisibilityBoxLocked = !1,
  120455. this._alwaysVisible = !1,
  120456. this._groups = new Array,
  120457. this._groupCounter = 0,
  120458. this._computeParticleColor = !0,
  120459. this._computeParticleTexture = !0,
  120460. this._computeParticleRotation = !0,
  120461. this._computeBoundingBox = !1,
  120462. this._isReady = !1,
  120463. this.name = e,
  120464. this._size = t,
  120465. this._scene = i || E.LastCreatedScene,
  120466. n && void 0 !== n.updatable ? this._updatable = n.updatable : this._updatable = !0
  120467. }
  120468. return e.prototype.buildMeshAsync = function(e) {
  120469. var t = this;
  120470. return Promise.all(this._promises).then((function() {
  120471. return t._isReady = !0,
  120472. t._buildMesh(e)
  120473. }
  120474. ))
  120475. }
  120476. ,
  120477. e.prototype._buildMesh = function(e) {
  120478. 0 === this.nbParticles && this.addPoints(1),
  120479. this._positions32 = new Float32Array(this._positions),
  120480. this._uvs32 = new Float32Array(this._uvs),
  120481. this._colors32 = new Float32Array(this._colors);
  120482. var t = new $n;
  120483. t.set(this._positions32, Bi.PositionKind),
  120484. this._uvs32.length > 0 && t.set(this._uvs32, Bi.UVKind);
  120485. var i = 0;
  120486. this._colors32.length > 0 && (i = 1,
  120487. t.set(this._colors32, Bi.ColorKind));
  120488. var n = new Vr(this.name,this._scene);
  120489. t.applyToMesh(n, this._updatable),
  120490. this.mesh = n,
  120491. this._positions = null,
  120492. this._uvs = null,
  120493. this._colors = null,
  120494. this._updatable || (this.particles.length = 0);
  120495. var r = e;
  120496. return r || ((r = new Os("point cloud material",this._scene)).emissiveColor = new D(i,i,i),
  120497. r.disableLighting = !0,
  120498. r.pointsCloud = !0,
  120499. r.pointSize = this._size),
  120500. n.material = r,
  120501. new Promise((function(e) {
  120502. return e(n)
  120503. }
  120504. ))
  120505. }
  120506. ,
  120507. e.prototype._addParticle = function(e, t, i, n) {
  120508. var r = new Ay(e,t,i,n,this);
  120509. return this.particles.push(r),
  120510. r
  120511. }
  120512. ,
  120513. e.prototype._randomUnitVector = function(e) {
  120514. e.position = new x(Math.random(),Math.random(),Math.random()),
  120515. e.color = new N(1,1,1,1)
  120516. }
  120517. ,
  120518. e.prototype._getColorIndicesForCoord = function(e, t, i, n) {
  120519. var r = e._groupImageData
  120520. , o = i * (4 * n) + 4 * t
  120521. , a = [o, o + 1, o + 2, o + 3]
  120522. , s = a[1]
  120523. , l = a[2]
  120524. , c = a[3]
  120525. , u = r[a[0]]
  120526. , h = r[s]
  120527. , d = r[l]
  120528. , p = r[c];
  120529. return new N(u / 255,h / 255,d / 255,p)
  120530. }
  120531. ,
  120532. e.prototype._setPointsColorOrUV = function(e, t, i, n, r, o, a) {
  120533. i && e.updateFacetData();
  120534. var s = 2 * e.getBoundingInfo().boundingSphere.radius
  120535. , l = e.getVerticesData(Bi.PositionKind)
  120536. , c = e.getIndices()
  120537. , u = e.getVerticesData(Bi.UVKind)
  120538. , h = e.getVerticesData(Bi.ColorKind)
  120539. , p = x.Zero();
  120540. e.computeWorldMatrix();
  120541. var f = e.getWorldMatrix();
  120542. if (!f.isIdentity()) {
  120543. l = l.slice(0);
  120544. for (var _ = 0; _ < l.length / 3; _++)
  120545. x.TransformCoordinatesFromFloatsToRef(l[3 * _], l[3 * _ + 1], l[3 * _ + 2], f, p),
  120546. l[3 * _] = p.x,
  120547. l[3 * _ + 1] = p.y,
  120548. l[3 * _ + 2] = p.z
  120549. }
  120550. var m, g, v = 0, y = 0, b = 0, T = 0, E = 0, S = 0, C = 0, P = 0, M = 0, I = 0, O = 0, L = 0, F = 0, w = x.Zero(), B = x.Zero(), U = x.Zero(), V = x.Zero(), k = x.Zero(), G = 0, z = 0, W = 0, H = 0, X = 0, j = 0, Y = A.Zero(), K = A.Zero(), Q = A.Zero(), q = A.Zero(), Z = A.Zero(), J = 0, $ = 0, ee = 0, te = 0, ie = 0, ne = 0, re = 0, oe = 0, ae = 0, se = 0, le = 0, ce = 0, ue = R.Zero(), he = R.Zero(), de = R.Zero(), pe = R.Zero(), fe = R.Zero(), _e = 0, me = 0;
  120551. a = a || 0;
  120552. for (var ge, ve = new R(0,0,0,0), ye = x.Zero(), be = x.Zero(), Te = x.Zero(), Ee = 0, Se = x.Zero(), Ae = 0, xe = 0, Re = new _o(x.Zero(),new x(1,0,0)), Ce = x.Zero(), Pe = 0; Pe < c.length / 3; Pe++) {
  120553. y = c[3 * Pe],
  120554. b = c[3 * Pe + 1],
  120555. T = c[3 * Pe + 2],
  120556. E = l[3 * y],
  120557. S = l[3 * y + 1],
  120558. C = l[3 * y + 2],
  120559. P = l[3 * b],
  120560. M = l[3 * b + 1],
  120561. I = l[3 * b + 2],
  120562. O = l[3 * T],
  120563. L = l[3 * T + 1],
  120564. F = l[3 * T + 2],
  120565. w.set(E, S, C),
  120566. B.set(P, M, I),
  120567. U.set(O, L, F),
  120568. B.subtractToRef(w, V),
  120569. U.subtractToRef(B, k),
  120570. u && (G = u[2 * y],
  120571. z = u[2 * y + 1],
  120572. W = u[2 * b],
  120573. H = u[2 * b + 1],
  120574. X = u[2 * T],
  120575. j = u[2 * T + 1],
  120576. Y.set(G, z),
  120577. K.set(W, H),
  120578. Q.set(X, j),
  120579. K.subtractToRef(Y, q),
  120580. Q.subtractToRef(K, Z)),
  120581. h && n && (J = h[4 * y],
  120582. $ = h[4 * y + 1],
  120583. ee = h[4 * y + 2],
  120584. te = h[4 * y + 3],
  120585. ie = h[4 * b],
  120586. ne = h[4 * b + 1],
  120587. re = h[4 * b + 2],
  120588. oe = h[4 * b + 3],
  120589. ae = h[4 * T],
  120590. se = h[4 * T + 1],
  120591. le = h[4 * T + 2],
  120592. ce = h[4 * T + 3],
  120593. ue.set(J, $, ee, te),
  120594. he.set(ie, ne, re, oe),
  120595. de.set(ae, se, le, ce),
  120596. he.subtractToRef(ue, pe),
  120597. de.subtractToRef(he, fe));
  120598. for (var Me = void 0, Ie = void 0, Oe = void 0, De = void 0, Ne = void 0, Le = void 0, Fe = void 0, we = void 0, Be = new D(0,0,0), Ue = new D(0,0,0), Ve = void 0, ke = void 0, Ge = 0; Ge < t._groupDensity[Pe]; Ge++)
  120599. v = this.particles.length,
  120600. this._addParticle(v, t, this._groupCounter, Pe + Ge),
  120601. ke = this.particles[v],
  120602. _e = d.RandomRange(0, 1),
  120603. me = d.RandomRange(0, 1),
  120604. m = w.add(V.scale(_e)).add(k.scale(_e * me)),
  120605. i && (ye = e.getFacetNormal(Pe).normalize().scale(-1),
  120606. be = V.clone().normalize(),
  120607. Te = x.Cross(ye, be),
  120608. Ee = d.RandomRange(0, 2 * Math.PI),
  120609. Se = be.scale(Math.cos(Ee)).add(Te.scale(Math.sin(Ee))),
  120610. Ee = d.RandomRange(.1, Math.PI / 2),
  120611. Ce = Se.scale(Math.cos(Ee)).add(ye.scale(Math.sin(Ee))),
  120612. Re.origin = m.add(Ce.scale(1e-5)),
  120613. Re.direction = Ce,
  120614. Re.length = s,
  120615. (ge = Re.intersectsMesh(e)).hit && (xe = ge.pickedPoint.subtract(m).length(),
  120616. Ae = d.RandomRange(0, 1) * xe,
  120617. m.addInPlace(Ce.scale(Ae)))),
  120618. ke.position = m.clone(),
  120619. this._positions.push(ke.position.x, ke.position.y, ke.position.z),
  120620. void 0 !== n ? u && (g = Y.add(q.scale(_e)).add(Z.scale(_e * me)),
  120621. n ? r && null !== t._groupImageData ? (Me = t._groupImgWidth,
  120622. Ie = t._groupImgHeight,
  120623. Ve = this._getColorIndicesForCoord(t, Math.round(g.x * Me), Math.round(g.y * Ie), Me),
  120624. ke.color = Ve,
  120625. this._colors.push(Ve.r, Ve.g, Ve.b, Ve.a)) : h ? (ve = ue.add(pe.scale(_e)).add(fe.scale(_e * me)),
  120626. ke.color = new N(ve.x,ve.y,ve.z,ve.w),
  120627. this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ve = ue.set(Math.random(), Math.random(), Math.random(), 1),
  120628. ke.color = new N(ve.x,ve.y,ve.z,ve.w),
  120629. this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ke.uv = g.clone(),
  120630. this._uvs.push(ke.uv.x, ke.uv.y))) : (o ? (Be.set(o.r, o.g, o.b),
  120631. Oe = d.RandomRange(-a, a),
  120632. De = d.RandomRange(-a, a),
  120633. Ne = (we = Be.toHSV()).r,
  120634. (Le = we.g + Oe) < 0 && (Le = 0),
  120635. Le > 1 && (Le = 1),
  120636. (Fe = we.b + De) < 0 && (Fe = 0),
  120637. Fe > 1 && (Fe = 1),
  120638. D.HSVtoRGBToRef(Ne, Le, Fe, Ue),
  120639. ve.set(Ue.r, Ue.g, Ue.b, 1)) : ve = ue.set(Math.random(), Math.random(), Math.random(), 1),
  120640. ke.color = new N(ve.x,ve.y,ve.z,ve.w),
  120641. this._colors.push(ve.x, ve.y, ve.z, ve.w))
  120642. }
  120643. }
  120644. ,
  120645. e.prototype._colorFromTexture = function(e, t, i) {
  120646. var n = this;
  120647. if (null === e.material)
  120648. return K.Warn(e.name + "has no material."),
  120649. t._groupImageData = null,
  120650. void this._setPointsColorOrUV(e, t, i, !0, !1);
  120651. var r = e.material.getActiveTextures();
  120652. if (0 === r.length)
  120653. return K.Warn(e.name + "has no usable texture."),
  120654. t._groupImageData = null,
  120655. void this._setPointsColorOrUV(e, t, i, !0, !1);
  120656. var o = e.clone();
  120657. o.setEnabled(!1),
  120658. this._promises.push(new Promise((function(e) {
  120659. Zr.WhenAllReady(r, (function() {
  120660. var a = t._textureNb;
  120661. a < 0 && (a = 0),
  120662. a > r.length - 1 && (a = r.length - 1);
  120663. var s = function() {
  120664. t._groupImgWidth = r[a].getSize().width,
  120665. t._groupImgHeight = r[a].getSize().height,
  120666. n._setPointsColorOrUV(o, t, i, !0, !0),
  120667. o.dispose(),
  120668. e()
  120669. };
  120670. t._groupImageData = null;
  120671. var l = r[a].readPixels();
  120672. l ? l.then((function(e) {
  120673. t._groupImageData = e,
  120674. s()
  120675. }
  120676. )) : s()
  120677. }
  120678. ))
  120679. }
  120680. )))
  120681. }
  120682. ,
  120683. e.prototype._calculateDensity = function(e, t, i) {
  120684. for (var n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b = new Array, T = x.Zero(), E = x.Zero(), S = x.Zero(), A = x.Zero(), R = x.Zero(), C = x.Zero(), P = new Array, M = 0, I = i.length / 3, O = 0; O < I; O++)
  120685. n = i[3 * O],
  120686. r = i[3 * O + 1],
  120687. o = i[3 * O + 2],
  120688. a = t[3 * n],
  120689. s = t[3 * n + 1],
  120690. l = t[3 * n + 2],
  120691. c = t[3 * r],
  120692. u = t[3 * r + 1],
  120693. h = t[3 * r + 2],
  120694. d = t[3 * o],
  120695. p = t[3 * o + 1],
  120696. f = t[3 * o + 2],
  120697. T.set(a, s, l),
  120698. E.set(c, u, h),
  120699. S.set(d, p, f),
  120700. E.subtractToRef(T, A),
  120701. S.subtractToRef(E, R),
  120702. S.subtractToRef(T, C),
  120703. v = ((_ = A.length()) + (m = R.length()) + (g = C.length())) / 2,
  120704. M += y = Math.sqrt(v * (v - _) * (v - m) * (v - g)),
  120705. P[O] = y;
  120706. var D = 0;
  120707. for (O = 0; O < I; O++)
  120708. b[O] = Math.floor(e * P[O] / M),
  120709. D += b[O];
  120710. var N = e - D
  120711. , L = Math.floor(N / I)
  120712. , F = N % I;
  120713. for (L > 0 && (b = b.map((function(e) {
  120714. return e + L
  120715. }
  120716. ))),
  120717. O = 0; O < F; O++)
  120718. b[O] += 1;
  120719. return b
  120720. }
  120721. ,
  120722. e.prototype.addPoints = function(e, t) {
  120723. void 0 === t && (t = this._randomUnitVector);
  120724. for (var i, n = new xy(this._groupCounter,t), r = this.nbParticles, o = 0; o < e; o++)
  120725. i = this._addParticle(r, n, this._groupCounter, o),
  120726. n && n._positionFunction && n._positionFunction(i, r, o),
  120727. this._positions.push(i.position.x, i.position.y, i.position.z),
  120728. i.color && this._colors.push(i.color.r, i.color.g, i.color.b, i.color.a),
  120729. i.uv && this._uvs.push(i.uv.x, i.uv.y),
  120730. r++;
  120731. return this.nbParticles += e,
  120732. this._groupCounter++,
  120733. this._groupCounter
  120734. }
  120735. ,
  120736. e.prototype.addSurfacePoints = function(e, t, i, n, r) {
  120737. var o = i || vy.Random;
  120738. (isNaN(o) || o < 0 || o > 3) && (o = vy.Random);
  120739. var a = e.getVerticesData(Bi.PositionKind)
  120740. , s = e.getIndices();
  120741. this._groups.push(this._groupCounter);
  120742. var l = new xy(this._groupCounter,null);
  120743. switch (l._groupDensity = this._calculateDensity(t, a, s),
  120744. o === vy.Color ? l._textureNb = n || 0 : n = n || new N(1,1,1,1),
  120745. o) {
  120746. case vy.Color:
  120747. this._colorFromTexture(e, l, !1);
  120748. break;
  120749. case vy.UV:
  120750. this._setPointsColorOrUV(e, l, !1, !1, !1);
  120751. break;
  120752. case vy.Random:
  120753. this._setPointsColorOrUV(e, l, !1);
  120754. break;
  120755. case vy.Stated:
  120756. this._setPointsColorOrUV(e, l, !1, void 0, void 0, n, r)
  120757. }
  120758. return this.nbParticles += t,
  120759. this._groupCounter++,
  120760. this._groupCounter - 1
  120761. }
  120762. ,
  120763. e.prototype.addVolumePoints = function(e, t, i, n, r) {
  120764. var o = i || vy.Random;
  120765. (isNaN(o) || o < 0 || o > 3) && (o = vy.Random);
  120766. var a = e.getVerticesData(Bi.PositionKind)
  120767. , s = e.getIndices();
  120768. this._groups.push(this._groupCounter);
  120769. var l = new xy(this._groupCounter,null);
  120770. switch (l._groupDensity = this._calculateDensity(t, a, s),
  120771. o === vy.Color ? l._textureNb = n || 0 : n = n || new N(1,1,1,1),
  120772. o) {
  120773. case vy.Color:
  120774. this._colorFromTexture(e, l, !0);
  120775. break;
  120776. case vy.UV:
  120777. this._setPointsColorOrUV(e, l, !0, !1, !1);
  120778. break;
  120779. case vy.Random:
  120780. this._setPointsColorOrUV(e, l, !0);
  120781. break;
  120782. case vy.Stated:
  120783. this._setPointsColorOrUV(e, l, !0, void 0, void 0, n, r)
  120784. }
  120785. return this.nbParticles += t,
  120786. this._groupCounter++,
  120787. this._groupCounter - 1
  120788. }
  120789. ,
  120790. e.prototype.setParticles = function(e, t, i) {
  120791. if (void 0 === e && (e = 0),
  120792. void 0 === t && (t = this.nbParticles - 1),
  120793. void 0 === i && (i = !0),
  120794. !this._updatable || !this._isReady)
  120795. return this;
  120796. this.beforeUpdateParticles(e, t, i);
  120797. var n = I.Matrix[0]
  120798. , r = this.mesh
  120799. , o = this._colors32
  120800. , a = this._positions32
  120801. , s = this._uvs32
  120802. , l = I.Vector3
  120803. , c = l[5].copyFromFloats(1, 0, 0)
  120804. , u = l[6].copyFromFloats(0, 1, 0)
  120805. , h = l[7].copyFromFloats(0, 0, 1)
  120806. , d = l[8].setAll(Number.MAX_VALUE)
  120807. , p = l[9].setAll(-Number.MAX_VALUE);
  120808. P.IdentityToRef(n);
  120809. var f = 0;
  120810. if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0),
  120811. t = t >= this.nbParticles ? this.nbParticles - 1 : t,
  120812. this._computeBoundingBox && (0 != e || t != this.nbParticles - 1)) {
  120813. var _ = this.mesh.getBoundingInfo();
  120814. _ && (d.copyFrom(_.minimum),
  120815. p.copyFrom(_.maximum))
  120816. }
  120817. f = 0;
  120818. for (var m = 0, g = 0, v = 0, y = e; y <= t; y++) {
  120819. var b = this.particles[y];
  120820. m = 3 * (f = b.idx),
  120821. g = 4 * f,
  120822. v = 2 * f,
  120823. this.updateParticle(b);
  120824. var T = b._rotationMatrix
  120825. , E = b.position
  120826. , S = b._globalPosition;
  120827. if (this._computeParticleRotation && b.getRotationMatrix(n),
  120828. null !== b.parentId) {
  120829. var A = this.particles[b.parentId]
  120830. , x = A._rotationMatrix
  120831. , R = A._globalPosition
  120832. , C = E.x * x[1] + E.y * x[4] + E.z * x[7]
  120833. , M = E.x * x[0] + E.y * x[3] + E.z * x[6]
  120834. , O = E.x * x[2] + E.y * x[5] + E.z * x[8];
  120835. if (S.x = R.x + M,
  120836. S.y = R.y + C,
  120837. S.z = R.z + O,
  120838. this._computeParticleRotation) {
  120839. var D = n.m;
  120840. T[0] = D[0] * x[0] + D[1] * x[3] + D[2] * x[6],
  120841. T[1] = D[0] * x[1] + D[1] * x[4] + D[2] * x[7],
  120842. T[2] = D[0] * x[2] + D[1] * x[5] + D[2] * x[8],
  120843. T[3] = D[4] * x[0] + D[5] * x[3] + D[6] * x[6],
  120844. T[4] = D[4] * x[1] + D[5] * x[4] + D[6] * x[7],
  120845. T[5] = D[4] * x[2] + D[5] * x[5] + D[6] * x[8],
  120846. T[6] = D[8] * x[0] + D[9] * x[3] + D[10] * x[6],
  120847. T[7] = D[8] * x[1] + D[9] * x[4] + D[10] * x[7],
  120848. T[8] = D[8] * x[2] + D[9] * x[5] + D[10] * x[8]
  120849. }
  120850. } else
  120851. S.x = 0,
  120852. S.y = 0,
  120853. S.z = 0,
  120854. this._computeParticleRotation && (D = n.m,
  120855. T[0] = D[0],
  120856. T[1] = D[1],
  120857. T[2] = D[2],
  120858. T[3] = D[4],
  120859. T[4] = D[5],
  120860. T[5] = D[6],
  120861. T[6] = D[8],
  120862. T[7] = D[9],
  120863. T[8] = D[10]);
  120864. var N = l[11];
  120865. b.translateFromPivot ? N.setAll(0) : N.copyFrom(b.pivot);
  120866. var L = l[0];
  120867. L.copyFrom(b.position);
  120868. var F = L.x - b.pivot.x
  120869. , w = L.y - b.pivot.y
  120870. , B = L.z - b.pivot.z
  120871. , U = F * T[0] + w * T[3] + B * T[6]
  120872. , V = F * T[1] + w * T[4] + B * T[7]
  120873. , k = F * T[2] + w * T[5] + B * T[8];
  120874. U += N.x,
  120875. V += N.y,
  120876. k += N.z;
  120877. var G = a[m] = S.x + c.x * U + u.x * V + h.x * k
  120878. , z = a[m + 1] = S.y + c.y * U + u.y * V + h.y * k
  120879. , W = a[m + 2] = S.z + c.z * U + u.z * V + h.z * k;
  120880. if (this._computeBoundingBox && (d.minimizeInPlaceFromFloats(G, z, W),
  120881. p.maximizeInPlaceFromFloats(G, z, W)),
  120882. this._computeParticleColor && b.color) {
  120883. var H = b.color
  120884. , X = this._colors32;
  120885. X[g] = H.r,
  120886. X[g + 1] = H.g,
  120887. X[g + 2] = H.b,
  120888. X[g + 3] = H.a
  120889. }
  120890. if (this._computeParticleTexture && b.uv) {
  120891. var j = b.uv
  120892. , Y = this._uvs32;
  120893. Y[v] = j.x,
  120894. Y[v + 1] = j.y
  120895. }
  120896. }
  120897. return i && (this._computeParticleColor && r.updateVerticesData(Bi.ColorKind, o, !1, !1),
  120898. this._computeParticleTexture && r.updateVerticesData(Bi.UVKind, s, !1, !1),
  120899. r.updateVerticesData(Bi.PositionKind, a, !1, !1)),
  120900. this._computeBoundingBox && (r.hasBoundingInfo ? r.getBoundingInfo().reConstruct(d, p, r._worldMatrix) : r.buildBoundingInfo(d, p, r._worldMatrix)),
  120901. this.afterUpdateParticles(e, t, i),
  120902. this
  120903. }
  120904. ,
  120905. e.prototype.dispose = function() {
  120906. this.mesh.dispose(),
  120907. this.vars = null,
  120908. this._positions = null,
  120909. this._indices = null,
  120910. this._normals = null,
  120911. this._uvs = null,
  120912. this._colors = null,
  120913. this._indices32 = null,
  120914. this._positions32 = null,
  120915. this._uvs32 = null,
  120916. this._colors32 = null
  120917. }
  120918. ,
  120919. e.prototype.refreshVisibleSize = function() {
  120920. return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(),
  120921. this
  120922. }
  120923. ,
  120924. e.prototype.setVisibilityBox = function(e) {
  120925. var t = e / 2;
  120926. this.mesh.buildBoundingInfo(new x(-t,-t,-t), new x(t,t,t))
  120927. }
  120928. ,
  120929. Object.defineProperty(e.prototype, "isAlwaysVisible", {
  120930. get: function() {
  120931. return this._alwaysVisible
  120932. },
  120933. set: function(e) {
  120934. this._alwaysVisible = e,
  120935. this.mesh.alwaysSelectAsActiveMesh = e
  120936. },
  120937. enumerable: !1,
  120938. configurable: !0
  120939. }),
  120940. Object.defineProperty(e.prototype, "computeParticleRotation", {
  120941. set: function(e) {
  120942. this._computeParticleRotation = e
  120943. },
  120944. enumerable: !1,
  120945. configurable: !0
  120946. }),
  120947. Object.defineProperty(e.prototype, "computeParticleColor", {
  120948. get: function() {
  120949. return this._computeParticleColor
  120950. },
  120951. set: function(e) {
  120952. this._computeParticleColor = e
  120953. },
  120954. enumerable: !1,
  120955. configurable: !0
  120956. }),
  120957. Object.defineProperty(e.prototype, "computeParticleTexture", {
  120958. get: function() {
  120959. return this._computeParticleTexture
  120960. },
  120961. set: function(e) {
  120962. this._computeParticleTexture = e
  120963. },
  120964. enumerable: !1,
  120965. configurable: !0
  120966. }),
  120967. Object.defineProperty(e.prototype, "computeBoundingBox", {
  120968. get: function() {
  120969. return this._computeBoundingBox
  120970. },
  120971. set: function(e) {
  120972. this._computeBoundingBox = e
  120973. },
  120974. enumerable: !1,
  120975. configurable: !0
  120976. }),
  120977. e.prototype.initParticles = function() {}
  120978. ,
  120979. e.prototype.recycleParticle = function(e) {
  120980. return e
  120981. }
  120982. ,
  120983. e.prototype.updateParticle = function(e) {
  120984. return e
  120985. }
  120986. ,
  120987. e.prototype.beforeUpdateParticles = function(e, t, i) {}
  120988. ,
  120989. e.prototype.afterUpdateParticles = function(e, t, i) {}
  120990. ,
  120991. e
  120992. }();
  120993. mn.prototype.getPhysicsEngine = function() {
  120994. return this._physicsEngine
  120995. }
  120996. ,
  120997. mn.prototype.enablePhysics = function(e, t) {
  120998. if (void 0 === e && (e = null),
  120999. this._physicsEngine)
  121000. return !0;
  121001. var i = this._getComponent(Wi.NAME_PHYSICSENGINE);
  121002. i || (i = new My(this),
  121003. this._addComponent(i));
  121004. try {
  121005. return this._physicsEngine = new R_(e,t),
  121006. this._physicsTimeAccumulator = 0,
  121007. !0
  121008. } catch (e) {
  121009. return K.Error(e.message),
  121010. !1
  121011. }
  121012. }
  121013. ,
  121014. mn.prototype.disablePhysicsEngine = function() {
  121015. this._physicsEngine && (this._physicsEngine.dispose(),
  121016. this._physicsEngine = null)
  121017. }
  121018. ,
  121019. mn.prototype.isPhysicsEnabled = function() {
  121020. return void 0 !== this._physicsEngine
  121021. }
  121022. ,
  121023. mn.prototype.deleteCompoundImpostor = function(e) {
  121024. var t = e.parts[0].mesh;
  121025. t.physicsImpostor && (t.physicsImpostor.dispose(),
  121026. t.physicsImpostor = null)
  121027. }
  121028. ,
  121029. mn.prototype._advancePhysicsEngineStep = function(e) {
  121030. if (this._physicsEngine) {
  121031. var t = this._physicsEngine.getSubTimeStep();
  121032. if (t > 0)
  121033. for (this._physicsTimeAccumulator += e; this._physicsTimeAccumulator > t; )
  121034. this.onBeforePhysicsObservable.notifyObservers(this),
  121035. this._physicsEngine._step(t / 1e3),
  121036. this.onAfterPhysicsObservable.notifyObservers(this),
  121037. this._physicsTimeAccumulator -= t;
  121038. else
  121039. this.onBeforePhysicsObservable.notifyObservers(this),
  121040. this._physicsEngine._step(e / 1e3),
  121041. this.onAfterPhysicsObservable.notifyObservers(this)
  121042. }
  121043. }
  121044. ,
  121045. Object.defineProperty(Sr.prototype, "physicsImpostor", {
  121046. get: function() {
  121047. return this._physicsImpostor
  121048. },
  121049. set: function(e) {
  121050. var t = this;
  121051. this._physicsImpostor !== e && (this._disposePhysicsObserver && this.onDisposeObservable.remove(this._disposePhysicsObserver),
  121052. this._physicsImpostor = e,
  121053. e && (this._disposePhysicsObserver = this.onDisposeObservable.add((function() {
  121054. t.physicsImpostor && (t.physicsImpostor.dispose(),
  121055. t.physicsImpostor = null)
  121056. }
  121057. ))))
  121058. },
  121059. enumerable: !0,
  121060. configurable: !0
  121061. }),
  121062. Sr.prototype.getPhysicsImpostor = function() {
  121063. return this.physicsImpostor
  121064. }
  121065. ,
  121066. Sr.prototype.applyImpulse = function(e, t) {
  121067. return this.physicsImpostor ? (this.physicsImpostor.applyImpulse(e, t),
  121068. this) : this
  121069. }
  121070. ,
  121071. Sr.prototype.setPhysicsLinkWith = function(e, t, i, n) {
  121072. return this.physicsImpostor && e.physicsImpostor ? (this.physicsImpostor.createJoint(e.physicsImpostor, Ll.HingeJoint, {
  121073. mainPivot: t,
  121074. connectedPivot: i,
  121075. nativeParams: n
  121076. }),
  121077. this) : this
  121078. }
  121079. ;
  121080. var Cy, Py, My = function() {
  121081. function e(e) {
  121082. var t = this;
  121083. this.name = Wi.NAME_PHYSICSENGINE,
  121084. this.scene = e,
  121085. this.scene.onBeforePhysicsObservable = new h,
  121086. this.scene.onAfterPhysicsObservable = new h,
  121087. this.scene.getDeterministicFrameTime = function() {
  121088. return t.scene._physicsEngine ? 1e3 * t.scene._physicsEngine.getTimeStep() : 1e3 / 60
  121089. }
  121090. }
  121091. return e.prototype.register = function() {}
  121092. ,
  121093. e.prototype.rebuild = function() {}
  121094. ,
  121095. e.prototype.dispose = function() {
  121096. this.scene.onBeforePhysicsObservable.clear(),
  121097. this.scene.onAfterPhysicsObservable.clear(),
  121098. this.scene._physicsEngine && this.scene.disablePhysicsEngine()
  121099. }
  121100. ,
  121101. e
  121102. }(), Iy = function() {
  121103. function e(e) {
  121104. this._scene = e,
  121105. this._physicsEngine = this._scene.getPhysicsEngine(),
  121106. this._physicsEngine || K.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")
  121107. }
  121108. return e.prototype.applyRadialExplosionImpulse = function(e, t, i, n) {
  121109. if (!this._physicsEngine)
  121110. return K.Warn("Physics engine not enabled. Please enable the physics before you call this method."),
  121111. null;
  121112. var r = this._physicsEngine.getImpostors();
  121113. if (0 === r.length)
  121114. return null;
  121115. "number" == typeof t && ((t = new Fy).radius = t,
  121116. t.strength = i || t.strength,
  121117. t.falloff = n || t.falloff);
  121118. var o = new Oy(this._scene,t)
  121119. , a = Array();
  121120. return r.forEach((function(t) {
  121121. var i = o.getImpostorHitData(t, e);
  121122. i && (t.applyImpulse(i.force, i.contactPoint),
  121123. a.push({
  121124. impostor: t,
  121125. hitData: i
  121126. }))
  121127. }
  121128. )),
  121129. o.triggerAffectedImpostorsCallback(a),
  121130. o.dispose(!1),
  121131. o
  121132. }
  121133. ,
  121134. e.prototype.applyRadialExplosionForce = function(e, t, i, n) {
  121135. if (!this._physicsEngine)
  121136. return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
  121137. null;
  121138. var r = this._physicsEngine.getImpostors();
  121139. if (0 === r.length)
  121140. return null;
  121141. "number" == typeof t && ((t = new Fy).radius = t,
  121142. t.strength = i || t.strength,
  121143. t.falloff = n || t.falloff);
  121144. var o = new Oy(this._scene,t)
  121145. , a = Array();
  121146. return r.forEach((function(t) {
  121147. var i = o.getImpostorHitData(t, e);
  121148. i && (t.applyForce(i.force, i.contactPoint),
  121149. a.push({
  121150. impostor: t,
  121151. hitData: i
  121152. }))
  121153. }
  121154. )),
  121155. o.triggerAffectedImpostorsCallback(a),
  121156. o.dispose(!1),
  121157. o
  121158. }
  121159. ,
  121160. e.prototype.gravitationalField = function(e, t, i, n) {
  121161. if (!this._physicsEngine)
  121162. return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
  121163. null;
  121164. if (0 === this._physicsEngine.getImpostors().length)
  121165. return null;
  121166. "number" == typeof t && ((t = new Fy).radius = t,
  121167. t.strength = i || t.strength,
  121168. t.falloff = n || t.falloff);
  121169. var r = new Dy(this,this._scene,e,t);
  121170. return r.dispose(!1),
  121171. r
  121172. }
  121173. ,
  121174. e.prototype.updraft = function(e, t, i, n, r) {
  121175. if (!this._physicsEngine)
  121176. return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
  121177. null;
  121178. if (0 === this._physicsEngine.getImpostors().length)
  121179. return null;
  121180. "number" == typeof t && ((t = new wy).radius = t,
  121181. t.strength = i || t.strength,
  121182. t.height = n || t.height,
  121183. t.updraftMode = r || t.updraftMode);
  121184. var o = new Ny(this._scene,e,t);
  121185. return o.dispose(!1),
  121186. o
  121187. }
  121188. ,
  121189. e.prototype.vortex = function(e, t, i, n) {
  121190. if (!this._physicsEngine)
  121191. return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
  121192. null;
  121193. if (0 === this._physicsEngine.getImpostors().length)
  121194. return null;
  121195. "number" == typeof t && ((t = new By).radius = t,
  121196. t.strength = i || t.strength,
  121197. t.height = n || t.height);
  121198. var r = new Ly(this._scene,e,t);
  121199. return r.dispose(!1),
  121200. r
  121201. }
  121202. ,
  121203. e
  121204. }(), Oy = function() {
  121205. function e(e, t) {
  121206. this._scene = e,
  121207. this._options = t,
  121208. this._dataFetched = !1,
  121209. this._options = V(V({}, new Fy), this._options)
  121210. }
  121211. return e.prototype.getData = function() {
  121212. return this._dataFetched = !0,
  121213. {
  121214. sphere: this._sphere
  121215. }
  121216. }
  121217. ,
  121218. e.prototype.getImpostorHitData = function(e, t) {
  121219. if (0 === e.mass)
  121220. return null;
  121221. if (!this._intersectsWithSphere(e, t, this._options.radius))
  121222. return null;
  121223. if ("Mesh" !== e.object.getClassName() && "InstancedMesh" !== e.object.getClassName())
  121224. return null;
  121225. var i = e.getObjectCenter().subtract(t)
  121226. , n = new _o(t,i,this._options.radius).intersectsMesh(e.object).pickedPoint;
  121227. if (!n)
  121228. return null;
  121229. var r = x.Distance(t, n);
  121230. if (r > this._options.radius)
  121231. return null;
  121232. var o = this._options.falloff === Cy.Constant ? this._options.strength : this._options.strength * (1 - r / this._options.radius);
  121233. return {
  121234. force: i.multiplyByFloats(o, o, o),
  121235. contactPoint: n,
  121236. distanceFromOrigin: r
  121237. }
  121238. }
  121239. ,
  121240. e.prototype.triggerAffectedImpostorsCallback = function(e) {
  121241. this._options.affectedImpostorsCallback && this._options.affectedImpostorsCallback(e)
  121242. }
  121243. ,
  121244. e.prototype.dispose = function(e) {
  121245. var t = this;
  121246. void 0 === e && (e = !0),
  121247. e ? this._sphere.dispose() : setTimeout((function() {
  121248. t._dataFetched || t._sphere.dispose()
  121249. }
  121250. ), 0)
  121251. }
  121252. ,
  121253. e.prototype._prepareSphere = function() {
  121254. this._sphere || (this._sphere = Dl("radialExplosionEventSphere", this._options.sphere, this._scene),
  121255. this._sphere.isVisible = !1)
  121256. }
  121257. ,
  121258. e.prototype._intersectsWithSphere = function(e, t, i) {
  121259. var n = e.object;
  121260. return this._prepareSphere(),
  121261. this._sphere.position = t,
  121262. this._sphere.scaling = new x(2 * i,2 * i,2 * i),
  121263. this._sphere._updateBoundingInfo(),
  121264. this._sphere.computeWorldMatrix(!0),
  121265. this._sphere.intersectsMesh(n, !0)
  121266. }
  121267. ,
  121268. e
  121269. }(), Dy = function() {
  121270. function e(e, t, i, n) {
  121271. this._physicsHelper = e,
  121272. this._scene = t,
  121273. this._origin = i,
  121274. this._options = n,
  121275. this._dataFetched = !1,
  121276. this._options = V(V({}, new Fy), this._options),
  121277. this._tickCallback = this._tick.bind(this),
  121278. this._options.strength = -1 * this._options.strength
  121279. }
  121280. return e.prototype.getData = function() {
  121281. return this._dataFetched = !0,
  121282. {
  121283. sphere: this._sphere
  121284. }
  121285. }
  121286. ,
  121287. e.prototype.enable = function() {
  121288. this._tickCallback.call(this),
  121289. this._scene.registerBeforeRender(this._tickCallback)
  121290. }
  121291. ,
  121292. e.prototype.disable = function() {
  121293. this._scene.unregisterBeforeRender(this._tickCallback)
  121294. }
  121295. ,
  121296. e.prototype.dispose = function(e) {
  121297. var t = this;
  121298. void 0 === e && (e = !0),
  121299. e ? this._sphere.dispose() : setTimeout((function() {
  121300. t._dataFetched || t._sphere.dispose()
  121301. }
  121302. ), 0)
  121303. }
  121304. ,
  121305. e.prototype._tick = function() {
  121306. if (this._sphere)
  121307. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  121308. else {
  121309. var e = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  121310. e && (this._sphere = e.getData().sphere.clone("radialExplosionEventSphereClone"))
  121311. }
  121312. }
  121313. ,
  121314. e
  121315. }(), Ny = function() {
  121316. function e(e, t, i) {
  121317. this._scene = e,
  121318. this._origin = t,
  121319. this._options = i,
  121320. this._originTop = x.Zero(),
  121321. this._originDirection = x.Zero(),
  121322. this._cylinderPosition = x.Zero(),
  121323. this._dataFetched = !1,
  121324. this._physicsEngine = this._scene.getPhysicsEngine(),
  121325. this._options = V(V({}, new wy), this._options),
  121326. this._origin.addToRef(new x(0,this._options.height / 2,0), this._cylinderPosition),
  121327. this._origin.addToRef(new x(0,this._options.height,0), this._originTop),
  121328. this._options.updraftMode === Py.Perpendicular && (this._originDirection = this._origin.subtract(this._originTop).normalize()),
  121329. this._tickCallback = this._tick.bind(this),
  121330. this._prepareCylinder()
  121331. }
  121332. return e.prototype.getData = function() {
  121333. return this._dataFetched = !0,
  121334. {
  121335. cylinder: this._cylinder
  121336. }
  121337. }
  121338. ,
  121339. e.prototype.enable = function() {
  121340. this._tickCallback.call(this),
  121341. this._scene.registerBeforeRender(this._tickCallback)
  121342. }
  121343. ,
  121344. e.prototype.disable = function() {
  121345. this._scene.unregisterBeforeRender(this._tickCallback)
  121346. }
  121347. ,
  121348. e.prototype.dispose = function(e) {
  121349. var t = this;
  121350. void 0 === e && (e = !0),
  121351. this._cylinder && (e ? this._cylinder.dispose() : setTimeout((function() {
  121352. t._dataFetched || t._cylinder.dispose()
  121353. }
  121354. ), 0))
  121355. }
  121356. ,
  121357. e.prototype._getImpostorHitData = function(e) {
  121358. if (0 === e.mass)
  121359. return null;
  121360. if (!this._intersectsWithCylinder(e))
  121361. return null;
  121362. var t, i = e.getObjectCenter();
  121363. t = this._options.updraftMode === Py.Perpendicular ? this._originDirection : i.subtract(this._originTop);
  121364. var n = x.Distance(this._origin, i)
  121365. , r = -1 * this._options.strength;
  121366. return {
  121367. force: t.multiplyByFloats(r, r, r),
  121368. contactPoint: i,
  121369. distanceFromOrigin: n
  121370. }
  121371. }
  121372. ,
  121373. e.prototype._tick = function() {
  121374. var e = this;
  121375. this._physicsEngine.getImpostors().forEach((function(t) {
  121376. var i = e._getImpostorHitData(t);
  121377. i && t.applyForce(i.force, i.contactPoint)
  121378. }
  121379. ))
  121380. }
  121381. ,
  121382. e.prototype._prepareCylinder = function() {
  121383. this._cylinder || (this._cylinder = Ys("updraftEventCylinder", {
  121384. height: this._options.height,
  121385. diameter: 2 * this._options.radius
  121386. }, this._scene),
  121387. this._cylinder.isVisible = !1)
  121388. }
  121389. ,
  121390. e.prototype._intersectsWithCylinder = function(e) {
  121391. var t = e.object;
  121392. return this._cylinder.position = this._cylinderPosition,
  121393. this._cylinder.intersectsMesh(t, !0)
  121394. }
  121395. ,
  121396. e
  121397. }(), Ly = function() {
  121398. function e(e, t, i) {
  121399. this._scene = e,
  121400. this._origin = t,
  121401. this._options = i,
  121402. this._originTop = x.Zero(),
  121403. this._cylinderPosition = x.Zero(),
  121404. this._dataFetched = !1,
  121405. this._physicsEngine = this._scene.getPhysicsEngine(),
  121406. this._options = V(V({}, new By), this._options),
  121407. this._origin.addToRef(new x(0,this._options.height / 2,0), this._cylinderPosition),
  121408. this._origin.addToRef(new x(0,this._options.height,0), this._originTop),
  121409. this._tickCallback = this._tick.bind(this),
  121410. this._prepareCylinder()
  121411. }
  121412. return e.prototype.getData = function() {
  121413. return this._dataFetched = !0,
  121414. {
  121415. cylinder: this._cylinder
  121416. }
  121417. }
  121418. ,
  121419. e.prototype.enable = function() {
  121420. this._tickCallback.call(this),
  121421. this._scene.registerBeforeRender(this._tickCallback)
  121422. }
  121423. ,
  121424. e.prototype.disable = function() {
  121425. this._scene.unregisterBeforeRender(this._tickCallback)
  121426. }
  121427. ,
  121428. e.prototype.dispose = function(e) {
  121429. var t = this;
  121430. void 0 === e && (e = !0),
  121431. e ? this._cylinder.dispose() : setTimeout((function() {
  121432. t._dataFetched || t._cylinder.dispose()
  121433. }
  121434. ), 0)
  121435. }
  121436. ,
  121437. e.prototype._getImpostorHitData = function(e) {
  121438. if (0 === e.mass)
  121439. return null;
  121440. if (!this._intersectsWithCylinder(e))
  121441. return null;
  121442. if ("Mesh" !== e.object.getClassName() && "InstancedMesh" !== e.object.getClassName())
  121443. return null;
  121444. var t = e.getObjectCenter()
  121445. , i = new x(this._origin.x,t.y,this._origin.z)
  121446. , n = t.subtract(i)
  121447. , r = new _o(i,n,this._options.radius).intersectsMesh(e.object)
  121448. , o = r.pickedPoint;
  121449. if (!o)
  121450. return null;
  121451. var a, s, l, c = r.distance / this._options.radius, u = o.normalize();
  121452. if (c > this._options.centripetalForceThreshold && (u = u.negate()),
  121453. c > this._options.centripetalForceThreshold)
  121454. a = u.x * this._options.centripetalForceMultiplier,
  121455. s = u.y * this._options.updraftForceMultiplier,
  121456. l = u.z * this._options.centripetalForceMultiplier;
  121457. else {
  121458. var h = x.Cross(i, t).normalize();
  121459. a = (h.x + u.x) * this._options.centrifugalForceMultiplier,
  121460. s = this._originTop.y * this._options.updraftForceMultiplier,
  121461. l = (h.z + u.z) * this._options.centrifugalForceMultiplier
  121462. }
  121463. var d = new x(a,s,l);
  121464. return {
  121465. force: d = d.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength),
  121466. contactPoint: t,
  121467. distanceFromOrigin: c
  121468. }
  121469. }
  121470. ,
  121471. e.prototype._tick = function() {
  121472. var e = this;
  121473. this._physicsEngine.getImpostors().forEach((function(t) {
  121474. var i = e._getImpostorHitData(t);
  121475. i && t.applyForce(i.force, i.contactPoint)
  121476. }
  121477. ))
  121478. }
  121479. ,
  121480. e.prototype._prepareCylinder = function() {
  121481. this._cylinder || (this._cylinder = Ys("vortexEventCylinder", {
  121482. height: this._options.height,
  121483. diameter: 2 * this._options.radius
  121484. }, this._scene),
  121485. this._cylinder.isVisible = !1)
  121486. }
  121487. ,
  121488. e.prototype._intersectsWithCylinder = function(e) {
  121489. var t = e.object;
  121490. return this._cylinder.position = this._cylinderPosition,
  121491. this._cylinder.intersectsMesh(t, !0)
  121492. }
  121493. ,
  121494. e
  121495. }(), Fy = function() {
  121496. this.radius = 5,
  121497. this.strength = 10,
  121498. this.falloff = Cy.Constant,
  121499. this.sphere = {
  121500. segments: 32,
  121501. diameter: 1
  121502. }
  121503. }, wy = function() {
  121504. this.radius = 5,
  121505. this.strength = 10,
  121506. this.height = 10,
  121507. this.updraftMode = Py.Center
  121508. }, By = function() {
  121509. this.radius = 5,
  121510. this.strength = 10,
  121511. this.height = 10,
  121512. this.centripetalForceThreshold = .7,
  121513. this.centripetalForceMultiplier = 5,
  121514. this.centrifugalForceMultiplier = .5,
  121515. this.updraftForceMultiplier = .02
  121516. };
  121517. !function(e) {
  121518. e[e.Constant = 0] = "Constant",
  121519. e[e.Linear = 1] = "Linear"
  121520. }(Cy || (Cy = {})),
  121521. function(e) {
  121522. e[e.Center = 0] = "Center",
  121523. e[e.Perpendicular = 1] = "Perpendicular"
  121524. }(Py || (Py = {}));
  121525. Pt.ShadersStore.blackAndWhitePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11)); \nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";
  121526. var Uy = function(e) {
  121527. function t(t, i, n, r, o, a) {
  121528. var s = e.call(this, t, "blackAndWhite", ["degree"], null, i, n, r, o, a) || this;
  121529. return s.degree = 1,
  121530. s.onApplyObservable.add((function(e) {
  121531. e.setFloat("degree", s.degree)
  121532. }
  121533. )),
  121534. s
  121535. }
  121536. return U(t, e),
  121537. t.prototype.getClassName = function() {
  121538. return "BlackAndWhitePostProcess"
  121539. }
  121540. ,
  121541. t._Parse = function(e, i, n, r) {
  121542. return Ge.Parse((function() {
  121543. return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  121544. }
  121545. ), e, n, r)
  121546. }
  121547. ,
  121548. k([Ce()], t.prototype, "degree", void 0),
  121549. t
  121550. }(Ba);
  121551. y("BABYLON.BlackAndWhitePostProcess", Uy);
  121552. var Vy = function() {
  121553. function e(e, t, i, n) {
  121554. this._name = t,
  121555. this._singleInstance = n || !0,
  121556. this._getPostProcesses = i,
  121557. this._cameras = {},
  121558. this._indicesForCamera = {},
  121559. this._postProcesses = {}
  121560. }
  121561. return Object.defineProperty(e.prototype, "isSupported", {
  121562. get: function() {
  121563. for (var e in this._postProcesses)
  121564. if (Object.prototype.hasOwnProperty.call(this._postProcesses, e))
  121565. for (var t = this._postProcesses[e], i = 0; i < t.length; i++)
  121566. if (!t[i].isSupported)
  121567. return !1;
  121568. return !0
  121569. },
  121570. enumerable: !1,
  121571. configurable: !0
  121572. }),
  121573. e.prototype._update = function() {}
  121574. ,
  121575. e.prototype._attachCameras = function(e) {
  121576. var t, i = this, n = gi.MakeArray(e || this._cameras);
  121577. if (n)
  121578. for (var r = function(e) {
  121579. var r = n[e];
  121580. if (!r)
  121581. return "continue";
  121582. var a = r.name;
  121583. if (t = o._singleInstance ? 0 : a,
  121584. !o._postProcesses[t]) {
  121585. var s = o._getPostProcesses();
  121586. s && (o._postProcesses[t] = Array.isArray(s) ? s : [s])
  121587. }
  121588. o._indicesForCamera[a] || (o._indicesForCamera[a] = []),
  121589. o._postProcesses[t].forEach((function(e) {
  121590. var t = r.attachPostProcess(e);
  121591. i._indicesForCamera[a].push(t)
  121592. }
  121593. )),
  121594. o._cameras[a] || (o._cameras[a] = r)
  121595. }, o = this, a = 0; a < n.length; a++)
  121596. r(a)
  121597. }
  121598. ,
  121599. e.prototype._detachCameras = function(e) {
  121600. var t = gi.MakeArray(e || this._cameras);
  121601. if (t)
  121602. for (var i = function(e) {
  121603. var i = t[e]
  121604. , r = i.name
  121605. , o = n._postProcesses[n._singleInstance ? 0 : r];
  121606. o && o.forEach((function(e) {
  121607. i.detachPostProcess(e)
  121608. }
  121609. )),
  121610. n._cameras[r] && (n._cameras[r] = null)
  121611. }, n = this, r = 0; r < t.length; r++)
  121612. i(r)
  121613. }
  121614. ,
  121615. e.prototype._enable = function(e) {
  121616. var t = this
  121617. , i = gi.MakeArray(e || this._cameras);
  121618. if (i)
  121619. for (var n = function(e) {
  121620. for (var n = i[e], o = n.name, a = function(a) {
  121621. void 0 !== n._postProcesses[r._indicesForCamera[o][a]] && null !== n._postProcesses[r._indicesForCamera[o][a]] || r._postProcesses[r._singleInstance ? 0 : o].forEach((function(n) {
  121622. i[e].attachPostProcess(n, t._indicesForCamera[o][a])
  121623. }
  121624. ))
  121625. }, s = 0; s < r._indicesForCamera[o].length; s++)
  121626. a(s)
  121627. }, r = this, o = 0; o < i.length; o++)
  121628. n(o)
  121629. }
  121630. ,
  121631. e.prototype._disable = function(e) {
  121632. var t = gi.MakeArray(e || this._cameras);
  121633. if (t)
  121634. for (var i = function(e) {
  121635. var i = t[e]
  121636. , r = i.name;
  121637. n._postProcesses[n._singleInstance ? 0 : r].forEach((function(e) {
  121638. i.detachPostProcess(e)
  121639. }
  121640. ))
  121641. }, n = this, r = 0; r < t.length; r++)
  121642. i(r)
  121643. }
  121644. ,
  121645. e.prototype.getPostProcesses = function(e) {
  121646. return this._singleInstance ? this._postProcesses[0] : e ? this._postProcesses[e.name] : null
  121647. }
  121648. ,
  121649. e
  121650. }();
  121651. Pt.ShadersStore.extractHighlightsPixelShader = "#include<helperFunctions>\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\n}";
  121652. var ky = function(e) {
  121653. function t(t, i, n, r, o, s, l, c) {
  121654. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  121655. void 0 === c && (c = !1);
  121656. var u = e.call(this, t, "extractHighlights", ["threshold", "exposure"], null, i, n, r, o, s, null, l, void 0, null, c) || this;
  121657. return u.threshold = .9,
  121658. u._exposure = 1,
  121659. u._inputPostProcess = null,
  121660. u.onApplyObservable.add((function(e) {
  121661. u.externalTextureSamplerBinding = !!u._inputPostProcess,
  121662. u._inputPostProcess && e.setTextureFromPostProcess("textureSampler", u._inputPostProcess),
  121663. e.setFloat("threshold", Math.pow(u.threshold, p)),
  121664. e.setFloat("exposure", u._exposure)
  121665. }
  121666. )),
  121667. u
  121668. }
  121669. return U(t, e),
  121670. t.prototype.getClassName = function() {
  121671. return "ExtractHighlightsPostProcess"
  121672. }
  121673. ,
  121674. k([Ce()], t.prototype, "threshold", void 0),
  121675. t
  121676. }(Ba);
  121677. y("BABYLON.ExtractHighlightsPostProcess", ky);
  121678. Pt.ShadersStore.bloomMergePixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); \n}\n";
  121679. var Gy = function(e) {
  121680. function t(t, i, n, r, o, s, l, c, u, h, d) {
  121681. void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT),
  121682. void 0 === d && (d = !1);
  121683. var p = e.call(this, t, "bloomMerge", ["bloomWeight"], ["bloomBlur"], o, s, l, c, u, null, h, void 0, null, !0) || this;
  121684. return p.weight = 1,
  121685. p.weight = r,
  121686. p.externalTextureSamplerBinding = !0,
  121687. p.onApplyObservable.add((function(e) {
  121688. e.setTextureFromPostProcess("textureSampler", i),
  121689. e.setTextureFromPostProcessOutput("bloomBlur", n),
  121690. e.setFloat("bloomWeight", p.weight)
  121691. }
  121692. )),
  121693. d || p.updateEffect(),
  121694. p
  121695. }
  121696. return U(t, e),
  121697. t.prototype.getClassName = function() {
  121698. return "BloomMergePostProcess"
  121699. }
  121700. ,
  121701. k([Ce()], t.prototype, "weight", void 0),
  121702. t
  121703. }(Ba);
  121704. y("BABYLON.BloomMergePostProcess", Gy);
  121705. var zy = function(e) {
  121706. function t(t, i, n, r, o, a) {
  121707. void 0 === o && (o = 0),
  121708. void 0 === a && (a = !1);
  121709. var s = e.call(this, t.getEngine(), "bloom", (function() {
  121710. return s._effects
  121711. }
  121712. ), !0) || this;
  121713. return s._bloomScale = i,
  121714. s._effects = [],
  121715. s._downscale = new ky("highlights",1,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,a),
  121716. s._blurX = new Fd("horizontal blur",new A(1,0),10,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,a),
  121717. s._blurX.alwaysForcePOT = !0,
  121718. s._blurX.autoClear = !1,
  121719. s._blurY = new Fd("vertical blur",new A(0,1),10,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,a),
  121720. s._blurY.alwaysForcePOT = !0,
  121721. s._blurY.autoClear = !1,
  121722. s.kernel = r,
  121723. s._effects = [s._downscale, s._blurX, s._blurY],
  121724. s._merge = new Gy("bloomMerge",s._downscale,s._blurY,n,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,a),
  121725. s._merge.autoClear = !1,
  121726. s._effects.push(s._merge),
  121727. s
  121728. }
  121729. return U(t, e),
  121730. Object.defineProperty(t.prototype, "threshold", {
  121731. get: function() {
  121732. return this._downscale.threshold
  121733. },
  121734. set: function(e) {
  121735. this._downscale.threshold = e
  121736. },
  121737. enumerable: !1,
  121738. configurable: !0
  121739. }),
  121740. Object.defineProperty(t.prototype, "weight", {
  121741. get: function() {
  121742. return this._merge.weight
  121743. },
  121744. set: function(e) {
  121745. this._merge.weight = e
  121746. },
  121747. enumerable: !1,
  121748. configurable: !0
  121749. }),
  121750. Object.defineProperty(t.prototype, "kernel", {
  121751. get: function() {
  121752. return this._blurX.kernel / this._bloomScale
  121753. },
  121754. set: function(e) {
  121755. this._blurX.kernel = e * this._bloomScale,
  121756. this._blurY.kernel = e * this._bloomScale
  121757. },
  121758. enumerable: !1,
  121759. configurable: !0
  121760. }),
  121761. t.prototype.disposeEffects = function(e) {
  121762. for (var t = 0; t < this._effects.length; t++)
  121763. this._effects[t].dispose(e)
  121764. }
  121765. ,
  121766. t.prototype._updateEffects = function() {
  121767. for (var e = 0; e < this._effects.length; e++)
  121768. this._effects[e].updateEffect()
  121769. }
  121770. ,
  121771. t.prototype._isReady = function() {
  121772. for (var e = 0; e < this._effects.length; e++)
  121773. if (!this._effects[e].isReady())
  121774. return !1;
  121775. return !0
  121776. }
  121777. ,
  121778. t
  121779. }(Vy);
  121780. Pt.ShadersStore.chromaticAberrationPixelShader = "uniform sampler2D textureSampler; \nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);\nvec2 directionOfEffect=direction;\nif(directionOfEffect.x==0. && directionOfEffect.y==0.){\ndirectionOfEffect=normalize(centered_screen_pos);\n}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+ centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;\nfloat ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\noriginal.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);\ngl_FragColor=original;\n}";
  121781. var Wy = function(e) {
  121782. function t(t, i, n, r, o, s, l, c, u, h) {
  121783. void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
  121784. void 0 === h && (h = !1);
  121785. var d = e.call(this, t, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], r, o, s, l, c, null, u, void 0, null, h) || this;
  121786. return d.aberrationAmount = 30,
  121787. d.radialIntensity = 0,
  121788. d.direction = new A(.707,.707),
  121789. d.centerPosition = new A(.5,.5),
  121790. d.screenWidth = i,
  121791. d.screenHeight = n,
  121792. d.onApplyObservable.add((function(e) {
  121793. e.setFloat("chromatic_aberration", d.aberrationAmount),
  121794. e.setFloat("screen_width", i),
  121795. e.setFloat("screen_height", n),
  121796. e.setFloat("radialIntensity", d.radialIntensity),
  121797. e.setFloat2("direction", d.direction.x, d.direction.y),
  121798. e.setFloat2("centerPosition", d.centerPosition.x, d.centerPosition.y)
  121799. }
  121800. )),
  121801. d
  121802. }
  121803. return U(t, e),
  121804. t.prototype.getClassName = function() {
  121805. return "ChromaticAberrationPostProcess"
  121806. }
  121807. ,
  121808. t._Parse = function(e, i, n, r) {
  121809. return Ge.Parse((function() {
  121810. return new t(e.name,e.screenWidth,e.screenHeight,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)
  121811. }
  121812. ), e, n, r)
  121813. }
  121814. ,
  121815. k([Ce()], t.prototype, "aberrationAmount", void 0),
  121816. k([Ce()], t.prototype, "radialIntensity", void 0),
  121817. k([Ce()], t.prototype, "direction", void 0),
  121818. k([Ce()], t.prototype, "centerPosition", void 0),
  121819. k([Ce()], t.prototype, "screenWidth", void 0),
  121820. k([Ce()], t.prototype, "screenHeight", void 0),
  121821. t
  121822. }(Ba);
  121823. y("BABYLON.ChromaticAberrationPostProcess", Wy);
  121824. Pt.ShadersStore.circleOfConfusionPixelShader = "uniform sampler2D depthSampler;\nvarying vec2 vUV;\nuniform vec2 cameraMinMaxZ;\nuniform float focusDistance;\nuniform float cocPrecalculation;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0; \nfloat coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));\ncoc=clamp(coc,0.0,1.0);\ngl_FragColor=vec4(coc,depth,coc,1.0);\n}\n";
  121825. var Hy = function(e) {
  121826. function t(t, i, n, r, o, s, l, c, u) {
  121827. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  121828. void 0 === u && (u = !1);
  121829. var h = e.call(this, t, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], n, r, o, s, l, null, c, void 0, null, u) || this;
  121830. return h.lensSize = 50,
  121831. h.fStop = 1.4,
  121832. h.focusDistance = 2e3,
  121833. h.focalLength = 50,
  121834. h._depthTexture = null,
  121835. h._depthTexture = i,
  121836. h.onApplyObservable.add((function(e) {
  121837. if (h._depthTexture) {
  121838. e.setTexture("depthSampler", h._depthTexture);
  121839. var t = h.lensSize / h.fStop * h.focalLength / (h.focusDistance - h.focalLength);
  121840. e.setFloat("focusDistance", h.focusDistance),
  121841. e.setFloat("cocPrecalculation", t),
  121842. e.setFloat2("cameraMinMaxZ", h._depthTexture.activeCamera.minZ, h._depthTexture.activeCamera.maxZ)
  121843. } else
  121844. K.Warn("No depth texture set on CircleOfConfusionPostProcess")
  121845. }
  121846. )),
  121847. h
  121848. }
  121849. return U(t, e),
  121850. t.prototype.getClassName = function() {
  121851. return "CircleOfConfusionPostProcess"
  121852. }
  121853. ,
  121854. Object.defineProperty(t.prototype, "depthTexture", {
  121855. set: function(e) {
  121856. this._depthTexture = e
  121857. },
  121858. enumerable: !1,
  121859. configurable: !0
  121860. }),
  121861. k([Ce()], t.prototype, "lensSize", void 0),
  121862. k([Ce()], t.prototype, "fStop", void 0),
  121863. k([Ce()], t.prototype, "focusDistance", void 0),
  121864. k([Ce()], t.prototype, "focalLength", void 0),
  121865. t
  121866. }(Ba);
  121867. y("BABYLON.CircleOfConfusionPostProcess", Hy);
  121868. Pt.ShadersStore.colorCorrectionPixelShader = "uniform sampler2D textureSampler; \nuniform sampler2D colorTable; \nvarying vec2 vUV;\nconst float SLICE_COUNT=16.0; \nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {\nfloat sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}";
  121869. var Xy = function(e) {
  121870. function t(t, i, n, r, o, a, s) {
  121871. var l = e.call(this, t, "colorCorrection", null, ["colorTable"], n, r, o, a, s) || this;
  121872. return l._colorTableTexture = new io(i,r.getScene(),!0,!1,io.TRILINEAR_SAMPLINGMODE),
  121873. l._colorTableTexture.anisotropicFilteringLevel = 1,
  121874. l._colorTableTexture.wrapU = io.CLAMP_ADDRESSMODE,
  121875. l._colorTableTexture.wrapV = io.CLAMP_ADDRESSMODE,
  121876. l.colorTableUrl = i,
  121877. l.onApply = function(e) {
  121878. e.setTexture("colorTable", l._colorTableTexture)
  121879. }
  121880. ,
  121881. l
  121882. }
  121883. return U(t, e),
  121884. t.prototype.getClassName = function() {
  121885. return "ColorCorrectionPostProcess"
  121886. }
  121887. ,
  121888. t._Parse = function(e, i, n, r) {
  121889. return Ge.Parse((function() {
  121890. return new t(e.name,e.colorTableUrl,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  121891. }
  121892. ), e, n, r)
  121893. }
  121894. ,
  121895. k([Ce()], t.prototype, "colorTableUrl", void 0),
  121896. t
  121897. }(Ba);
  121898. y("BABYLON.ColorCorrectionPostProcess", Xy);
  121899. Pt.ShadersStore.convolutionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}";
  121900. var jy = function(e) {
  121901. function t(t, i, n, r, o, s, l, c) {
  121902. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
  121903. var u = e.call(this, t, "convolution", ["kernel", "screenSize"], null, n, r, o, s, l, null, c) || this;
  121904. return u.kernel = i,
  121905. u.onApply = function(e) {
  121906. e.setFloat2("screenSize", u.width, u.height),
  121907. e.setArray("kernel", u.kernel)
  121908. }
  121909. ,
  121910. u
  121911. }
  121912. return U(t, e),
  121913. t.prototype.getClassName = function() {
  121914. return "ConvolutionPostProcess"
  121915. }
  121916. ,
  121917. t._Parse = function(e, i, n, r) {
  121918. return Ge.Parse((function() {
  121919. return new t(e.name,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType)
  121920. }
  121921. ), e, n, r)
  121922. }
  121923. ,
  121924. t.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1],
  121925. t.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0],
  121926. t.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1],
  121927. t.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0],
  121928. t.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2],
  121929. t.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0],
  121930. k([Ce()], t.prototype, "kernel", void 0),
  121931. t
  121932. }(Ba);
  121933. y("BABYLON.ConvolutionPostProcess", jy);
  121934. var Yy = function(e) {
  121935. function t(t, i, n, r, o, s, l, c, u, h, d, p, f) {
  121936. void 0 === c && (c = null),
  121937. void 0 === u && (u = io.BILINEAR_SAMPLINGMODE),
  121938. void 0 === p && (p = a.TEXTURETYPE_UNSIGNED_INT),
  121939. void 0 === f && (f = !1);
  121940. var _ = e.call(this, t, n, r, o, s, u = a.TEXTURE_BILINEAR_SAMPLINGMODE, h, d, p = a.TEXTURETYPE_UNSIGNED_INT, "#define DOF 1\r\n", f) || this;
  121941. return _.direction = n,
  121942. _.externalTextureSamplerBinding = !!c,
  121943. _.onApplyObservable.add((function(e) {
  121944. null != c && e.setTextureFromPostProcess("textureSampler", c),
  121945. e.setTextureFromPostProcessOutput("circleOfConfusionSampler", l),
  121946. i.activeCamera && e.setFloat2("cameraMinMaxZ", i.activeCamera.minZ, i.activeCamera.maxZ)
  121947. }
  121948. )),
  121949. _
  121950. }
  121951. return U(t, e),
  121952. t.prototype.getClassName = function() {
  121953. return "DepthOfFieldBlurPostProcess"
  121954. }
  121955. ,
  121956. k([Ce()], t.prototype, "direction", void 0),
  121957. t
  121958. }(Fd);
  121959. y("BABYLON.DepthOfFieldBlurPostProcess", Yy);
  121960. Pt.ShadersStore.depthOfFieldMergePixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\nuniform sampler2D circleOfConfusionSampler;\nuniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\n#if BLUR_LEVEL==0\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred0=texture2D(blurStep0,vUV);\ngl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(original,blurred1,coc/0.5);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV); \nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\n}\n#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(original,blurred2,coc/0.33);\n}else if(coc<0.66){\nvec4 blurred1=texture2D(blurStep1,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\n}\n#endif\n}\n";
  121961. var Ky, Qy = function() {}, qy = function(e) {
  121962. function t(t, i, n, r, o, s, l, c, u, h, d) {
  121963. void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT),
  121964. void 0 === d && (d = !1);
  121965. var p = e.call(this, t, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], o, s, l, c, u, null, h, void 0, null, !0) || this;
  121966. return p._blurSteps = r,
  121967. p.externalTextureSamplerBinding = !0,
  121968. p.onApplyObservable.add((function(e) {
  121969. e.setTextureFromPostProcess("textureSampler", i),
  121970. e.setTextureFromPostProcessOutput("circleOfConfusionSampler", n),
  121971. r.forEach((function(t, i) {
  121972. e.setTextureFromPostProcessOutput("blurStep" + (r.length - i - 1), t)
  121973. }
  121974. ))
  121975. }
  121976. )),
  121977. d || p.updateEffect(),
  121978. p
  121979. }
  121980. return U(t, e),
  121981. t.prototype.getClassName = function() {
  121982. return "DepthOfFieldMergePostProcess"
  121983. }
  121984. ,
  121985. t.prototype.updateEffect = function(t, i, n, r, o, a) {
  121986. void 0 === t && (t = null),
  121987. void 0 === i && (i = null),
  121988. void 0 === n && (n = null),
  121989. t || (t = "",
  121990. t += "#define BLUR_LEVEL " + (this._blurSteps.length - 1) + "\n"),
  121991. e.prototype.updateEffect.call(this, t, i, n, r, o, a)
  121992. }
  121993. ,
  121994. t
  121995. }(Ba);
  121996. !function(e) {
  121997. e[e.Low = 0] = "Low",
  121998. e[e.Medium = 1] = "Medium",
  121999. e[e.High = 2] = "High"
  122000. }(Ky || (Ky = {}));
  122001. var Zy = function(e) {
  122002. function t(t, i, n, r, o) {
  122003. void 0 === n && (n = Ky.Low),
  122004. void 0 === r && (r = 0),
  122005. void 0 === o && (o = !1);
  122006. var a = e.call(this, t.getEngine(), "depth of field", (function() {
  122007. return a._effects
  122008. }
  122009. ), !0) || this;
  122010. a._effects = [],
  122011. a._circleOfConfusion = new Hy("circleOfConfusion",i,1,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),
  122012. a._depthOfFieldBlurY = [],
  122013. a._depthOfFieldBlurX = [];
  122014. var s = 1
  122015. , l = 15;
  122016. switch (n) {
  122017. case Ky.High:
  122018. s = 3,
  122019. l = 51;
  122020. break;
  122021. case Ky.Medium:
  122022. s = 2,
  122023. l = 31;
  122024. break;
  122025. default:
  122026. l = 15,
  122027. s = 1
  122028. }
  122029. for (var c = l / Math.pow(2, s - 1), u = 1, h = 0; h < s; h++) {
  122030. var d = new Yy("vertical blur",t,new A(0,1),c,u,null,a._circleOfConfusion,0 == h ? a._circleOfConfusion : null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);
  122031. d.autoClear = !1,
  122032. u = .75 / Math.pow(2, h);
  122033. var p = new Yy("horizontal blur",t,new A(1,0),c,u,null,a._circleOfConfusion,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);
  122034. p.autoClear = !1,
  122035. a._depthOfFieldBlurY.push(d),
  122036. a._depthOfFieldBlurX.push(p)
  122037. }
  122038. for (a._effects = [a._circleOfConfusion],
  122039. h = 0; h < a._depthOfFieldBlurX.length; h++)
  122040. a._effects.push(a._depthOfFieldBlurY[h]),
  122041. a._effects.push(a._depthOfFieldBlurX[h]);
  122042. return a._dofMerge = new qy("dofMerge",a._circleOfConfusion,a._circleOfConfusion,a._depthOfFieldBlurX,u,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),
  122043. a._dofMerge.autoClear = !1,
  122044. a._effects.push(a._dofMerge),
  122045. a
  122046. }
  122047. return U(t, e),
  122048. Object.defineProperty(t.prototype, "focalLength", {
  122049. get: function() {
  122050. return this._circleOfConfusion.focalLength
  122051. },
  122052. set: function(e) {
  122053. this._circleOfConfusion.focalLength = e
  122054. },
  122055. enumerable: !1,
  122056. configurable: !0
  122057. }),
  122058. Object.defineProperty(t.prototype, "fStop", {
  122059. get: function() {
  122060. return this._circleOfConfusion.fStop
  122061. },
  122062. set: function(e) {
  122063. this._circleOfConfusion.fStop = e
  122064. },
  122065. enumerable: !1,
  122066. configurable: !0
  122067. }),
  122068. Object.defineProperty(t.prototype, "focusDistance", {
  122069. get: function() {
  122070. return this._circleOfConfusion.focusDistance
  122071. },
  122072. set: function(e) {
  122073. this._circleOfConfusion.focusDistance = e
  122074. },
  122075. enumerable: !1,
  122076. configurable: !0
  122077. }),
  122078. Object.defineProperty(t.prototype, "lensSize", {
  122079. get: function() {
  122080. return this._circleOfConfusion.lensSize
  122081. },
  122082. set: function(e) {
  122083. this._circleOfConfusion.lensSize = e
  122084. },
  122085. enumerable: !1,
  122086. configurable: !0
  122087. }),
  122088. t.prototype.getClassName = function() {
  122089. return "DepthOfFieldEffect"
  122090. }
  122091. ,
  122092. Object.defineProperty(t.prototype, "depthTexture", {
  122093. set: function(e) {
  122094. this._circleOfConfusion.depthTexture = e
  122095. },
  122096. enumerable: !1,
  122097. configurable: !0
  122098. }),
  122099. t.prototype.disposeEffects = function(e) {
  122100. for (var t = 0; t < this._effects.length; t++)
  122101. this._effects[t].dispose(e)
  122102. }
  122103. ,
  122104. t.prototype._updateEffects = function() {
  122105. for (var e = 0; e < this._effects.length; e++)
  122106. this._effects[e].updateEffect()
  122107. }
  122108. ,
  122109. t.prototype._isReady = function() {
  122110. for (var e = 0; e < this._effects.length; e++)
  122111. if (!this._effects[e].isReady())
  122112. return !1;
  122113. return !0
  122114. }
  122115. ,
  122116. t
  122117. }(Vy);
  122118. Pt.ShadersStore.displayPassPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  122119. var Jy = function(e) {
  122120. function t(t, i, n, r, o, a) {
  122121. return e.call(this, t, "displayPass", ["passSampler"], ["passSampler"], i, n, r, o, a) || this
  122122. }
  122123. return U(t, e),
  122124. t.prototype.getClassName = function() {
  122125. return "DisplayPassPostProcess"
  122126. }
  122127. ,
  122128. t._Parse = function(e, i, n, r) {
  122129. return Ge.Parse((function() {
  122130. return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  122131. }
  122132. ), e, n, r)
  122133. }
  122134. ,
  122135. t
  122136. }(Ba);
  122137. y("BABYLON.DisplayPassPostProcess", Jy);
  122138. Pt.ShadersStore.filterPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}";
  122139. var $y = function(e) {
  122140. function t(t, i, n, r, o, a, s) {
  122141. var l = e.call(this, t, "filter", ["kernelMatrix"], null, n, r, o, a, s) || this;
  122142. return l.kernelMatrix = i,
  122143. l.onApply = function(e) {
  122144. e.setMatrix("kernelMatrix", l.kernelMatrix)
  122145. }
  122146. ,
  122147. l
  122148. }
  122149. return U(t, e),
  122150. t.prototype.getClassName = function() {
  122151. return "FilterPostProcess"
  122152. }
  122153. ,
  122154. t._Parse = function(e, i, n, r) {
  122155. return Ge.Parse((function() {
  122156. return new t(e.name,e.kernelMatrix,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  122157. }
  122158. ), e, n, r)
  122159. }
  122160. ,
  122161. k([Ue()], t.prototype, "kernelMatrix", void 0),
  122162. t
  122163. }(Ba);
  122164. y("BABYLON.FilterPostProcess", $y);
  122165. Pt.ShadersStore.fxaaPixelShader = "uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\nreturn;\n}\n#endif\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\n#ifdef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\n}\nelse\n{\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}\n#else\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n#endif\n}";
  122166. Pt.ShadersStore.fxaaVertexShader = "attribute vec2 position;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
  122167. var eb = function(e) {
  122168. function t(t, i, n, r, o, s, l) {
  122169. void 0 === n && (n = null),
  122170. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
  122171. var c = e.call(this, t, "fxaa", ["texelSize"], null, i, n, r || io.BILINEAR_SAMPLINGMODE, o, s, null, l, "fxaa", void 0, !0) || this
  122172. , u = c._getDefines();
  122173. return c.updateEffect(u),
  122174. c.onApplyObservable.add((function(e) {
  122175. var t = c.texelSize;
  122176. e.setFloat2("texelSize", t.x, t.y)
  122177. }
  122178. )),
  122179. c
  122180. }
  122181. return U(t, e),
  122182. t.prototype.getClassName = function() {
  122183. return "FxaaPostProcess"
  122184. }
  122185. ,
  122186. t.prototype._getDefines = function() {
  122187. var e = this.getEngine();
  122188. if (!e)
  122189. return null;
  122190. var t = e.getGlInfo();
  122191. return t && t.renderer && t.renderer.toLowerCase().indexOf("mali") > -1 ? "#define MALI 1\n" : null
  122192. }
  122193. ,
  122194. t._Parse = function(e, i, n, r) {
  122195. return Ge.Parse((function() {
  122196. return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  122197. }
  122198. ), e, n, r)
  122199. }
  122200. ,
  122201. t
  122202. }(Ba);
  122203. y("BABYLON.FxaaPostProcess", eb);
  122204. Pt.ShadersStore.grainPixelShader = "#include<helperFunctions>\nuniform sampler2D textureSampler; \nuniform float intensity;\nuniform float animatedSeed;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";
  122205. var tb = function(e) {
  122206. function t(t, i, n, r, o, s, l, c) {
  122207. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  122208. void 0 === c && (c = !1);
  122209. var u = e.call(this, t, "grain", ["intensity", "animatedSeed"], [], i, n, r, o, s, null, l, void 0, null, c) || this;
  122210. return u.intensity = 30,
  122211. u.animated = !1,
  122212. u.onApplyObservable.add((function(e) {
  122213. e.setFloat("intensity", u.intensity),
  122214. e.setFloat("animatedSeed", u.animated ? Math.random() + 1 : 1)
  122215. }
  122216. )),
  122217. u
  122218. }
  122219. return U(t, e),
  122220. t.prototype.getClassName = function() {
  122221. return "GrainPostProcess"
  122222. }
  122223. ,
  122224. t._Parse = function(e, i, n, r) {
  122225. return Ge.Parse((function() {
  122226. return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  122227. }
  122228. ), e, n, r)
  122229. }
  122230. ,
  122231. k([Ce()], t.prototype, "intensity", void 0),
  122232. k([Ce()], t.prototype, "animated", void 0),
  122233. t
  122234. }(Ba);
  122235. y("BABYLON.GrainPostProcess", tb);
  122236. Pt.ShadersStore.highlightsPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); \n}";
  122237. var ib = function(e) {
  122238. function t(t, i, n, r, o, s, l) {
  122239. return void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  122240. e.call(this, t, "highlights", null, null, i, n, r, o, s, null, l) || this
  122241. }
  122242. return U(t, e),
  122243. t.prototype.getClassName = function() {
  122244. return "HighlightsPostProcess"
  122245. }
  122246. ,
  122247. t
  122248. }(Ba);
  122249. Pt.IncludesShadersStore.mrtFragmentDeclaration = "#if defined(WEBGL2) || defined(WEBGPU)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  122250. Pt.ShadersStore.geometryPixelShader = "#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY) && (defined(HAS_SPECULAR) || defined(HAS_REFLECTIVITY))\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#else\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\ngl_FragData[1]=vec4(normalOutput,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\n#ifdef HAS_SPECULAR\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#elif HAS_REFLECTIVITY\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\n#else\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}\n";
  122251. Pt.IncludesShadersStore.geometryVertexDeclaration = "uniform mat4 viewProjection;\nuniform mat4 view;";
  122252. Pt.IncludesShadersStore.geometryUboDeclaration = "#include<sceneUboDeclaration>\n";
  122253. Pt.ShadersStore.geometryVertexShader = "precision highp float;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\n#include<__decl__geometryVertex>\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;\nvarying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;\nvarying vec2 vReflectivityUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;\nvNormalW=normalUpdated;\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef NEED_UV\n#ifdef UV1\n#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include<bumpVertex>\n}\n";
  122254. var nb = function() {
  122255. function e(t, i) {
  122256. void 0 === i && (i = 1),
  122257. this._previousTransformationMatrices = {},
  122258. this._previousBonesTransformationMatrices = {},
  122259. this.excludedSkinnedMeshesFromVelocity = [],
  122260. this.renderTransparentMeshes = !0,
  122261. this._resizeObserver = null,
  122262. this._enablePosition = !1,
  122263. this._enableVelocity = !1,
  122264. this._enableReflectivity = !1,
  122265. this._positionIndex = -1,
  122266. this._velocityIndex = -1,
  122267. this._reflectivityIndex = -1,
  122268. this._depthIndex = -1,
  122269. this._normalIndex = -1,
  122270. this._linkedWithPrePass = !1,
  122271. this._scene = t,
  122272. this._ratio = i,
  122273. this._useUbo = t.getEngine().supportsUniformBuffers,
  122274. e._SceneComponentInitialization(this._scene),
  122275. this._createRenderTargets()
  122276. }
  122277. return e.prototype._linkPrePassRenderer = function(e) {
  122278. this._linkedWithPrePass = !0,
  122279. this._prePassRenderer = e,
  122280. this._multiRenderTarget && (this._multiRenderTarget.onClearObservable.clear(),
  122281. this._multiRenderTarget.onClearObservable.add((function() {}
  122282. )))
  122283. }
  122284. ,
  122285. e.prototype._unlinkPrePassRenderer = function() {
  122286. this._linkedWithPrePass = !1,
  122287. this._createRenderTargets()
  122288. }
  122289. ,
  122290. e.prototype._resetLayout = function() {
  122291. this._enablePosition = !1,
  122292. this._enableReflectivity = !1,
  122293. this._enableVelocity = !1,
  122294. this._attachments = []
  122295. }
  122296. ,
  122297. e.prototype._forceTextureType = function(t, i) {
  122298. t === e.POSITION_TEXTURE_TYPE ? (this._positionIndex = i,
  122299. this._enablePosition = !0) : t === e.VELOCITY_TEXTURE_TYPE ? (this._velocityIndex = i,
  122300. this._enableVelocity = !0) : t === e.REFLECTIVITY_TEXTURE_TYPE ? (this._reflectivityIndex = i,
  122301. this._enableReflectivity = !0) : t === e.DEPTH_TEXTURE_TYPE ? this._depthIndex = i : t === e.NORMAL_TEXTURE_TYPE && (this._normalIndex = i)
  122302. }
  122303. ,
  122304. e.prototype._setAttachments = function(e) {
  122305. this._attachments = e
  122306. }
  122307. ,
  122308. e.prototype._linkInternalTexture = function(e) {
  122309. this._multiRenderTarget.setInternalTexture(e, 0, !1)
  122310. }
  122311. ,
  122312. Object.defineProperty(e.prototype, "renderList", {
  122313. get: function() {
  122314. return this._multiRenderTarget.renderList
  122315. },
  122316. set: function(e) {
  122317. this._multiRenderTarget.renderList = e
  122318. },
  122319. enumerable: !1,
  122320. configurable: !0
  122321. }),
  122322. Object.defineProperty(e.prototype, "isSupported", {
  122323. get: function() {
  122324. return this._multiRenderTarget.isSupported
  122325. },
  122326. enumerable: !1,
  122327. configurable: !0
  122328. }),
  122329. e.prototype.getTextureIndex = function(t) {
  122330. switch (t) {
  122331. case e.POSITION_TEXTURE_TYPE:
  122332. return this._positionIndex;
  122333. case e.VELOCITY_TEXTURE_TYPE:
  122334. return this._velocityIndex;
  122335. case e.REFLECTIVITY_TEXTURE_TYPE:
  122336. return this._reflectivityIndex;
  122337. default:
  122338. return -1
  122339. }
  122340. }
  122341. ,
  122342. Object.defineProperty(e.prototype, "enablePosition", {
  122343. get: function() {
  122344. return this._enablePosition
  122345. },
  122346. set: function(e) {
  122347. this._enablePosition = e,
  122348. this._linkedWithPrePass || (this.dispose(),
  122349. this._createRenderTargets())
  122350. },
  122351. enumerable: !1,
  122352. configurable: !0
  122353. }),
  122354. Object.defineProperty(e.prototype, "enableVelocity", {
  122355. get: function() {
  122356. return this._enableVelocity
  122357. },
  122358. set: function(e) {
  122359. this._enableVelocity = e,
  122360. e || (this._previousTransformationMatrices = {}),
  122361. this._linkedWithPrePass || (this.dispose(),
  122362. this._createRenderTargets()),
  122363. this._scene.needsPreviousWorldMatrices = e
  122364. },
  122365. enumerable: !1,
  122366. configurable: !0
  122367. }),
  122368. Object.defineProperty(e.prototype, "enableReflectivity", {
  122369. get: function() {
  122370. return this._enableReflectivity
  122371. },
  122372. set: function(e) {
  122373. this._enableReflectivity = e,
  122374. this._linkedWithPrePass || (this.dispose(),
  122375. this._createRenderTargets())
  122376. },
  122377. enumerable: !1,
  122378. configurable: !0
  122379. }),
  122380. Object.defineProperty(e.prototype, "scene", {
  122381. get: function() {
  122382. return this._scene
  122383. },
  122384. enumerable: !1,
  122385. configurable: !0
  122386. }),
  122387. Object.defineProperty(e.prototype, "ratio", {
  122388. get: function() {
  122389. return this._ratio
  122390. },
  122391. enumerable: !1,
  122392. configurable: !0
  122393. }),
  122394. e.prototype.isReady = function(e, t) {
  122395. var i = e.getMaterial();
  122396. if (i && i.disableDepthWrite)
  122397. return !1;
  122398. var n = []
  122399. , r = [Bi.PositionKind, Bi.NormalKind]
  122400. , o = e.getMesh();
  122401. if (i) {
  122402. var a = !1;
  122403. i.needAlphaTesting() && i.getAlphaTestTexture() && (n.push("#define ALPHATEST"),
  122404. n.push("#define ALPHATEST_UV".concat(i.getAlphaTestTexture().coordinatesIndex + 1)),
  122405. a = !0),
  122406. i.bumpTexture && vs.BumpTextureEnabled && (n.push("#define BUMP"),
  122407. n.push("#define BUMP_UV".concat(i.bumpTexture.coordinatesIndex + 1)),
  122408. a = !0),
  122409. this._enableReflectivity && (i.specularTexture ? (n.push("#define HAS_SPECULAR"),
  122410. n.push("#define REFLECTIVITY_UV".concat(i.specularTexture.coordinatesIndex + 1)),
  122411. a = !0) : i.reflectivityTexture && (n.push("#define HAS_REFLECTIVITY"),
  122412. n.push("#define REFLECTIVITY_UV".concat(i.reflectivityTexture.coordinatesIndex + 1)),
  122413. a = !0)),
  122414. a && (n.push("#define NEED_UV"),
  122415. o.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
  122416. n.push("#define UV1")),
  122417. o.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
  122418. n.push("#define UV2")))
  122419. }
  122420. this._linkedWithPrePass && (n.push("#define PREPASS"),
  122421. -1 !== this._depthIndex && (n.push("#define DEPTH_INDEX " + this._depthIndex),
  122422. n.push("#define PREPASS_DEPTH")),
  122423. -1 !== this._normalIndex && (n.push("#define NORMAL_INDEX " + this._normalIndex),
  122424. n.push("#define PREPASS_NORMAL"))),
  122425. this._enablePosition && (n.push("#define POSITION"),
  122426. n.push("#define POSITION_INDEX " + this._positionIndex)),
  122427. this._enableVelocity && (n.push("#define VELOCITY"),
  122428. n.push("#define VELOCITY_INDEX " + this._velocityIndex),
  122429. -1 === this.excludedSkinnedMeshesFromVelocity.indexOf(o) && n.push("#define BONES_VELOCITY_ENABLED")),
  122430. this._enableReflectivity && (n.push("#define REFLECTIVITY"),
  122431. n.push("#define REFLECTIVITY_INDEX " + this._reflectivityIndex)),
  122432. o.useBones && o.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
  122433. r.push(Bi.MatricesWeightsKind),
  122434. o.numBoneInfluencers > 4 && (r.push(Bi.MatricesIndicesExtraKind),
  122435. r.push(Bi.MatricesWeightsExtraKind)),
  122436. n.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers),
  122437. n.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0");
  122438. var s = o.morphTargetManager
  122439. , l = 0;
  122440. s && s.numInfluencers > 0 && (l = s.numInfluencers,
  122441. n.push("#define MORPHTARGETS"),
  122442. n.push("#define NUM_MORPH_INFLUENCERS " + l),
  122443. s.isUsingTextureForTargets && n.push("#define MORPHTARGETS_TEXTURE"),
  122444. Mr.PrepareAttributesForMorphTargetsInfluencers(r, o, l)),
  122445. t && (n.push("#define INSTANCES"),
  122446. Mr.PushAttributesForInstances(r, this._enableVelocity),
  122447. e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES")),
  122448. this._linkedWithPrePass ? n.push("#define RENDER_TARGET_COUNT " + this._attachments.length) : n.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  122449. var c = e._getDrawWrapper(void 0, !0)
  122450. , u = c.defines
  122451. , h = n.join("\n");
  122452. return u !== h && c.setEffect(this._scene.getEngine().createEffect("geometry", {
  122453. attributes: r,
  122454. uniformsNames: ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "bumpMatrix", "reflectivityMatrix", "vTangentSpaceParams", "vBumpInfos", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"],
  122455. samplers: ["diffuseSampler", "bumpSampler", "reflectivitySampler", "morphTargets"],
  122456. defines: h,
  122457. onCompiled: null,
  122458. fallbacks: null,
  122459. onError: null,
  122460. uniformBuffersNames: ["Scene"],
  122461. indexParameters: {
  122462. buffersCount: this._multiRenderTarget.textures.length - 1,
  122463. maxSimultaneousMorphTargets: l
  122464. }
  122465. }, this._scene.getEngine()), h),
  122466. c.effect.isReady()
  122467. }
  122468. ,
  122469. e.prototype.getGBuffer = function() {
  122470. return this._multiRenderTarget
  122471. }
  122472. ,
  122473. Object.defineProperty(e.prototype, "samples", {
  122474. get: function() {
  122475. return this._multiRenderTarget.samples
  122476. },
  122477. set: function(e) {
  122478. this._multiRenderTarget.samples = e
  122479. },
  122480. enumerable: !1,
  122481. configurable: !0
  122482. }),
  122483. e.prototype.dispose = function() {
  122484. this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),
  122485. this._resizeObserver = null),
  122486. this.getGBuffer().dispose()
  122487. }
  122488. ,
  122489. e.prototype._assignRenderTargetIndices = function() {
  122490. var e = []
  122491. , t = 2;
  122492. return e.push("gBuffer_Depth", "gBuffer_Normal"),
  122493. this._enablePosition && (this._positionIndex = t,
  122494. t++,
  122495. e.push("gBuffer_Position")),
  122496. this._enableVelocity && (this._velocityIndex = t,
  122497. t++,
  122498. e.push("gBuffer_Velocity")),
  122499. this._enableReflectivity && (this._reflectivityIndex = t,
  122500. t++,
  122501. e.push("gBuffer_Reflectivity")),
  122502. [t, e]
  122503. }
  122504. ,
  122505. e.prototype._createRenderTargets = function() {
  122506. var e = this
  122507. , t = this._scene.getEngine()
  122508. , i = this._assignRenderTargetIndices()
  122509. , n = i[0]
  122510. , r = i[1]
  122511. , o = a.TEXTURETYPE_UNSIGNED_BYTE;
  122512. if (t._caps.textureFloat && t._caps.textureFloatLinearFiltering ? o = a.TEXTURETYPE_FLOAT : t._caps.textureHalfFloat && t._caps.textureHalfFloatLinearFiltering && (o = a.TEXTURETYPE_HALF_FLOAT),
  122513. this._multiRenderTarget = new pm("gBuffer",{
  122514. width: t.getRenderWidth() * this._ratio,
  122515. height: t.getRenderHeight() * this._ratio
  122516. },n,this._scene,{
  122517. generateMipMaps: !1,
  122518. generateDepthTexture: !0,
  122519. defaultType: o
  122520. },r.concat("gBuffer_DepthBuffer")),
  122521. this.isSupported) {
  122522. this._multiRenderTarget.wrapU = io.CLAMP_ADDRESSMODE,
  122523. this._multiRenderTarget.wrapV = io.CLAMP_ADDRESSMODE,
  122524. this._multiRenderTarget.refreshRate = 1,
  122525. this._multiRenderTarget.renderParticles = !1,
  122526. this._multiRenderTarget.renderList = null,
  122527. this._multiRenderTarget.onClearObservable.add((function(e) {
  122528. e.clear(new N(0,0,0,0), !0, !0, !0)
  122529. }
  122530. )),
  122531. this._resizeObserver = t.onResizeObservable.add((function() {
  122532. e._multiRenderTarget && e._multiRenderTarget.resize({
  122533. width: t.getRenderWidth() * e._ratio,
  122534. height: t.getRenderHeight() * e._ratio
  122535. })
  122536. }
  122537. ));
  122538. var s = function(t) {
  122539. var i = t.getRenderingMesh()
  122540. , n = t.getEffectiveMesh()
  122541. , r = e._scene
  122542. , o = r.getEngine()
  122543. , a = t.getMaterial();
  122544. if (a) {
  122545. if (n._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
  122546. e._enableVelocity && !e._previousTransformationMatrices[n.uniqueId] && (e._previousTransformationMatrices[n.uniqueId] = {
  122547. world: P.Identity(),
  122548. viewProjection: r.getTransformMatrix()
  122549. },
  122550. i.skeleton)) {
  122551. var s = i.skeleton.getTransformMatrices(i);
  122552. e._previousBonesTransformationMatrices[i.uniqueId] = e._copyBonesTransformationMatrices(s, new Float32Array(s.length))
  122553. }
  122554. var l = i._getInstancesRenderList(t._id, !!t.getReplacementMesh());
  122555. if (!l.mustReturn) {
  122556. var c = o.getCaps().instancedArrays && (null !== l.visibleInstances[t._id] || i.hasThinInstances)
  122557. , u = n.getWorldMatrix();
  122558. if (e.isReady(t, c)) {
  122559. var h = t._getDrawWrapper();
  122560. if (!h)
  122561. return;
  122562. var d = h.effect;
  122563. if (o.enableEffect(h),
  122564. c || i._bind(t, d, a.fillMode),
  122565. e._useUbo ? (Mr.BindSceneUniformBuffer(d, e._scene.getSceneUniformBuffer()),
  122566. e._scene.finalizeSceneUbo()) : (d.setMatrix("viewProjection", r.getTransformMatrix()),
  122567. d.setMatrix("view", r.getViewMatrix())),
  122568. a) {
  122569. var p = void 0
  122570. , f = i._instanceDataStorage;
  122571. if (f.isFrozen || !a.backFaceCulling && null === i.overrideMaterialSideOrientation)
  122572. p = f.sideOrientation;
  122573. else {
  122574. var _ = n._getWorldMatrixDeterminant();
  122575. null === (p = i.overrideMaterialSideOrientation) && (p = a.sideOrientation),
  122576. _ < 0 && (p = p === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation)
  122577. }
  122578. if (a._preBind(h, p),
  122579. a.needAlphaTesting()) {
  122580. var m = a.getAlphaTestTexture();
  122581. m && (d.setTexture("diffuseSampler", m),
  122582. d.setMatrix("diffuseMatrix", m.getTextureMatrix()))
  122583. }
  122584. a.bumpTexture && r.getEngine().getCaps().standardDerivatives && vs.BumpTextureEnabled && (d.setFloat3("vBumpInfos", a.bumpTexture.coordinatesIndex, 1 / a.bumpTexture.level, a.parallaxScaleBias),
  122585. d.setMatrix("bumpMatrix", a.bumpTexture.getTextureMatrix()),
  122586. d.setTexture("bumpSampler", a.bumpTexture),
  122587. d.setFloat2("vTangentSpaceParams", a.invertNormalMapX ? -1 : 1, a.invertNormalMapY ? -1 : 1)),
  122588. e._enableReflectivity && (a.specularTexture ? (d.setMatrix("reflectivityMatrix", a.specularTexture.getTextureMatrix()),
  122589. d.setTexture("reflectivitySampler", a.specularTexture)) : a.reflectivityTexture && (d.setMatrix("reflectivityMatrix", a.reflectivityTexture.getTextureMatrix()),
  122590. d.setTexture("reflectivitySampler", a.reflectivityTexture)))
  122591. }
  122592. i.useBones && i.computeBonesUsingShaders && i.skeleton && (d.setMatrices("mBones", i.skeleton.getTransformMatrices(i)),
  122593. e._enableVelocity && d.setMatrices("mPreviousBones", e._previousBonesTransformationMatrices[i.uniqueId])),
  122594. Mr.BindMorphTargetParameters(i, d),
  122595. i.morphTargetManager && i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(d),
  122596. e._enableVelocity && (d.setMatrix("previousWorld", e._previousTransformationMatrices[n.uniqueId].world),
  122597. d.setMatrix("previousViewProjection", e._previousTransformationMatrices[n.uniqueId].viewProjection)),
  122598. c && i.hasThinInstances && d.setMatrix("world", u),
  122599. i._processRendering(n, t, d, a.fillMode, l, c, (function(e, t) {
  122600. e || d.setMatrix("world", t)
  122601. }
  122602. ))
  122603. }
  122604. e._enableVelocity && (e._previousTransformationMatrices[n.uniqueId].world = u.clone(),
  122605. e._previousTransformationMatrices[n.uniqueId].viewProjection = e._scene.getTransformMatrix().clone(),
  122606. i.skeleton && e._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i), e._previousBonesTransformationMatrices[n.uniqueId]))
  122607. }
  122608. }
  122609. };
  122610. this._multiRenderTarget.customIsReadyFunction = function(i, n) {
  122611. if (!i.isReady(!1))
  122612. return !1;
  122613. if (0 === n && i.subMeshes)
  122614. for (var r = 0; r < i.subMeshes.length; ++r) {
  122615. var o = i.subMeshes[r]
  122616. , a = o.getMaterial()
  122617. , s = o.getRenderingMesh();
  122618. if (a) {
  122619. var l = s._getInstancesRenderList(o._id, !!o.getReplacementMesh())
  122620. , c = t.getCaps().instancedArrays && (null !== l.visibleInstances[o._id] || s.hasThinInstances);
  122621. if (!e.isReady(o, c))
  122622. return !1
  122623. }
  122624. }
  122625. return !0
  122626. }
  122627. ,
  122628. this._multiRenderTarget.customRenderFunction = function(i, n, r, o) {
  122629. var a;
  122630. if (e._linkedWithPrePass) {
  122631. if (!e._prePassRenderer.enabled)
  122632. return;
  122633. e._scene.getEngine().bindAttachments(e._attachments)
  122634. }
  122635. if (o.length) {
  122636. for (t.setColorWrite(!1),
  122637. a = 0; a < o.length; a++)
  122638. s(o.data[a]);
  122639. t.setColorWrite(!0)
  122640. }
  122641. for (a = 0; a < i.length; a++)
  122642. s(i.data[a]);
  122643. for (t.setDepthWrite(!1),
  122644. a = 0; a < n.length; a++)
  122645. s(n.data[a]);
  122646. if (e.renderTransparentMeshes)
  122647. for (a = 0; a < r.length; a++)
  122648. s(r.data[a]);
  122649. t.setDepthWrite(!0)
  122650. }
  122651. }
  122652. }
  122653. ,
  122654. e.prototype._copyBonesTransformationMatrices = function(e, t) {
  122655. for (var i = 0; i < e.length; i++)
  122656. t[i] = e[i];
  122657. return t
  122658. }
  122659. ,
  122660. e.DEPTH_TEXTURE_TYPE = 0,
  122661. e.NORMAL_TEXTURE_TYPE = 1,
  122662. e.POSITION_TEXTURE_TYPE = 2,
  122663. e.VELOCITY_TEXTURE_TYPE = 3,
  122664. e.REFLECTIVITY_TEXTURE_TYPE = 4,
  122665. e._SceneComponentInitialization = function(e) {
  122666. throw be("GeometryBufferRendererSceneComponent")
  122667. }
  122668. ,
  122669. e
  122670. }()
  122671. , rb = function() {
  122672. this.enabled = !1,
  122673. this.name = "motionBlur",
  122674. this.texturesRequired = [a.PREPASS_VELOCITY_TEXTURE_TYPE]
  122675. };
  122676. Object.defineProperty(mn.prototype, "geometryBufferRenderer", {
  122677. get: function() {
  122678. return this._geometryBufferRenderer
  122679. },
  122680. set: function(e) {
  122681. e && e.isSupported && (this._geometryBufferRenderer = e)
  122682. },
  122683. enumerable: !0,
  122684. configurable: !0
  122685. }),
  122686. mn.prototype.enableGeometryBufferRenderer = function(e) {
  122687. return void 0 === e && (e = 1),
  122688. this._geometryBufferRenderer || (this._geometryBufferRenderer = new nb(this,e),
  122689. this._geometryBufferRenderer.isSupported || (this._geometryBufferRenderer = null)),
  122690. this._geometryBufferRenderer
  122691. }
  122692. ,
  122693. mn.prototype.disableGeometryBufferRenderer = function() {
  122694. this._geometryBufferRenderer && (this._geometryBufferRenderer.dispose(),
  122695. this._geometryBufferRenderer = null)
  122696. }
  122697. ;
  122698. var ob = function() {
  122699. function e(e) {
  122700. this.name = Wi.NAME_GEOMETRYBUFFERRENDERER,
  122701. this.scene = e
  122702. }
  122703. return e.prototype.register = function() {
  122704. this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets)
  122705. }
  122706. ,
  122707. e.prototype.rebuild = function() {}
  122708. ,
  122709. e.prototype.dispose = function() {}
  122710. ,
  122711. e.prototype._gatherRenderTargets = function(e) {
  122712. this.scene._geometryBufferRenderer && e.push(this.scene._geometryBufferRenderer.getGBuffer())
  122713. }
  122714. ,
  122715. e
  122716. }();
  122717. nb._SceneComponentInitialization = function(e) {
  122718. var t = e._getComponent(Wi.NAME_GEOMETRYBUFFERRENDERER);
  122719. t || (t = new ob(e),
  122720. e._addComponent(t))
  122721. }
  122722. ;
  122723. Pt.ShadersStore.motionBlurPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\n#ifdef OBJECT_BASED\nuniform sampler2D velocitySampler;\n#else\nuniform sampler2D depthSampler;\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\n#ifdef OBJECT_BASED\nvec2 texelSize=1.0/screenSize;\nvec4 velocityColor=texture2D(velocitySampler,vUV);\nvelocityColor.rg=velocityColor.rg*2.0-vec2(1.0);\nvec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;\nvelocity*=motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint samplesCount=int(clamp(speed,1.0,SAMPLES));\nvelocity=normalize(velocity)*texelSize;\nfloat hlim=float(-samplesCount)*0.5+0.5;\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i)\n{\nif (i>=samplesCount)\nbreak;\nvec2 offset=vUV+velocity*(hlim+float(i));\nresult+=texture2D(textureSampler,offset);\n}\ngl_FragColor=result/float(samplesCount);\ngl_FragColor.a=1.0;\n#else\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n#endif\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  122724. var ab = function(e) {
  122725. function t(t, i, n, r, o, s, l, c, u, h) {
  122726. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  122727. void 0 === u && (u = !1),
  122728. void 0 === h && (h = !1);
  122729. var d = e.call(this, t, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection"], ["velocitySampler"], n, r, o, s, l, "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED", c, void 0, null, u) || this;
  122730. return d.motionStrength = 1,
  122731. d._motionBlurSamples = 32,
  122732. d._isObjectBased = !0,
  122733. d._forceGeometryBuffer = !1,
  122734. d._invViewProjection = null,
  122735. d._previousViewProjection = null,
  122736. d._forceGeometryBuffer = h,
  122737. d._forceGeometryBuffer ? (i.enableGeometryBufferRenderer(),
  122738. d._geometryBufferRenderer && (d._geometryBufferRenderer.enableVelocity = !0)) : (i.enablePrePassRenderer(),
  122739. d._prePassRenderer && (d._prePassRenderer.markAsDirty(),
  122740. d._prePassEffectConfiguration = new rb)),
  122741. d._applyMode(),
  122742. d
  122743. }
  122744. return U(t, e),
  122745. Object.defineProperty(t.prototype, "motionBlurSamples", {
  122746. get: function() {
  122747. return this._motionBlurSamples
  122748. },
  122749. set: function(e) {
  122750. this._motionBlurSamples = e,
  122751. this._updateEffect()
  122752. },
  122753. enumerable: !1,
  122754. configurable: !0
  122755. }),
  122756. Object.defineProperty(t.prototype, "isObjectBased", {
  122757. get: function() {
  122758. return this._isObjectBased
  122759. },
  122760. set: function(e) {
  122761. this._isObjectBased !== e && (this._isObjectBased = e,
  122762. this._applyMode())
  122763. },
  122764. enumerable: !1,
  122765. configurable: !0
  122766. }),
  122767. Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
  122768. get: function() {
  122769. return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
  122770. },
  122771. enumerable: !1,
  122772. configurable: !0
  122773. }),
  122774. Object.defineProperty(t.prototype, "_prePassRenderer", {
  122775. get: function() {
  122776. return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
  122777. },
  122778. enumerable: !1,
  122779. configurable: !0
  122780. }),
  122781. t.prototype.getClassName = function() {
  122782. return "MotionBlurPostProcess"
  122783. }
  122784. ,
  122785. t.prototype.excludeSkinnedMesh = function(e) {
  122786. if (e.skeleton) {
  122787. var t = void 0;
  122788. if (this._geometryBufferRenderer)
  122789. t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
  122790. else {
  122791. if (!this._prePassRenderer)
  122792. return;
  122793. t = this._prePassRenderer.excludedSkinnedMesh
  122794. }
  122795. t.push(e)
  122796. }
  122797. }
  122798. ,
  122799. t.prototype.removeExcludedSkinnedMesh = function(e) {
  122800. if (e.skeleton) {
  122801. var t = void 0;
  122802. if (this._geometryBufferRenderer)
  122803. t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
  122804. else {
  122805. if (!this._prePassRenderer)
  122806. return;
  122807. t = this._prePassRenderer.excludedSkinnedMesh
  122808. }
  122809. var i = t.indexOf(e);
  122810. -1 !== i && t.splice(i, 1)
  122811. }
  122812. }
  122813. ,
  122814. t.prototype.dispose = function(t) {
  122815. this._geometryBufferRenderer && (this._geometryBufferRenderer._previousTransformationMatrices = {},
  122816. this._geometryBufferRenderer._previousBonesTransformationMatrices = {},
  122817. this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = []),
  122818. e.prototype.dispose.call(this, t)
  122819. }
  122820. ,
  122821. t.prototype._applyMode = function() {
  122822. var e = this;
  122823. if (!this._geometryBufferRenderer && !this._prePassRenderer)
  122824. return K.Warn("Multiple Render Target support needed to compute object based motion blur"),
  122825. this.updateEffect();
  122826. this._updateEffect(),
  122827. this._invViewProjection = null,
  122828. this._previousViewProjection = null,
  122829. this.isObjectBased ? (this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_VELOCITY_TEXTURE_TYPE),
  122830. this.onApply = function(t) {
  122831. return e._onApplyObjectBased(t)
  122832. }
  122833. ) : (this._invViewProjection = P.Identity(),
  122834. this._previousViewProjection = P.Identity(),
  122835. this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_DEPTH_TEXTURE_TYPE),
  122836. this.onApply = function(t) {
  122837. return e._onApplyScreenBased(t)
  122838. }
  122839. )
  122840. }
  122841. ,
  122842. t.prototype._onApplyObjectBased = function(e) {
  122843. if (e.setVector2("screenSize", new A(this.width,this.height)),
  122844. e.setFloat("motionScale", this._scene.getAnimationRatio()),
  122845. e.setFloat("motionStrength", this.motionStrength),
  122846. this._geometryBufferRenderer) {
  122847. var t = this._geometryBufferRenderer.getTextureIndex(nb.VELOCITY_TEXTURE_TYPE);
  122848. e.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[t])
  122849. } else
  122850. this._prePassRenderer && (t = this._prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE),
  122851. e.setTexture("velocitySampler", this._prePassRenderer.getRenderTarget().textures[t]))
  122852. }
  122853. ,
  122854. t.prototype._onApplyScreenBased = function(e) {
  122855. var t = this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());
  122856. if (t.invertToRef(this._invViewProjection),
  122857. e.setMatrix("inverseViewProjection", this._invViewProjection),
  122858. e.setMatrix("prevViewProjection", this._previousViewProjection),
  122859. this._previousViewProjection = t,
  122860. e.setVector2("screenSize", new A(this.width,this.height)),
  122861. e.setFloat("motionScale", this._scene.getAnimationRatio()),
  122862. e.setFloat("motionStrength", this.motionStrength),
  122863. this._geometryBufferRenderer) {
  122864. var i = this._geometryBufferRenderer.getTextureIndex(nb.DEPTH_TEXTURE_TYPE);
  122865. e.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[i])
  122866. } else
  122867. this._prePassRenderer && (i = this._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE),
  122868. e.setTexture("depthSampler", this._prePassRenderer.getRenderTarget().textures[i]))
  122869. }
  122870. ,
  122871. t.prototype._updateEffect = function() {
  122872. if (this._geometryBufferRenderer || this._prePassRenderer) {
  122873. var e = ["#define GEOMETRY_SUPPORTED", "#define SAMPLES " + this._motionBlurSamples.toFixed(1), this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED"];
  122874. this.updateEffect(e.join("\n"))
  122875. }
  122876. }
  122877. ,
  122878. t._Parse = function(e, i, n, r) {
  122879. return Ge.Parse((function() {
  122880. return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)
  122881. }
  122882. ), e, n, r)
  122883. }
  122884. ,
  122885. k([Ce()], t.prototype, "motionStrength", void 0),
  122886. k([Ce()], t.prototype, "motionBlurSamples", null),
  122887. k([Ce()], t.prototype, "isObjectBased", null),
  122888. t
  122889. }(Ba);
  122890. y("BABYLON.MotionBlurPostProcess", ab);
  122891. Pt.ShadersStore.refractionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}";
  122892. var sb = function(e) {
  122893. function t(t, i, n, r, o, a, s, l, c, u) {
  122894. var h = e.call(this, t, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], a, s, l, c, u) || this;
  122895. return h._ownRefractionTexture = !0,
  122896. h.color = n,
  122897. h.depth = r,
  122898. h.colorLevel = o,
  122899. h.refractionTextureUrl = i,
  122900. h.onActivateObservable.add((function(e) {
  122901. h._refTexture = h._refTexture || new io(i,e.getScene())
  122902. }
  122903. )),
  122904. h.onApplyObservable.add((function(e) {
  122905. e.setColor3("baseColor", h.color),
  122906. e.setFloat("depth", h.depth),
  122907. e.setFloat("colorLevel", h.colorLevel),
  122908. e.setTexture("refractionSampler", h._refTexture)
  122909. }
  122910. )),
  122911. h
  122912. }
  122913. return U(t, e),
  122914. Object.defineProperty(t.prototype, "refractionTexture", {
  122915. get: function() {
  122916. return this._refTexture
  122917. },
  122918. set: function(e) {
  122919. this._refTexture && this._ownRefractionTexture && this._refTexture.dispose(),
  122920. this._refTexture = e,
  122921. this._ownRefractionTexture = !1
  122922. },
  122923. enumerable: !1,
  122924. configurable: !0
  122925. }),
  122926. t.prototype.getClassName = function() {
  122927. return "RefractionPostProcess"
  122928. }
  122929. ,
  122930. t.prototype.dispose = function(t) {
  122931. this._refTexture && this._ownRefractionTexture && (this._refTexture.dispose(),
  122932. this._refTexture = null),
  122933. e.prototype.dispose.call(this, t)
  122934. }
  122935. ,
  122936. t._Parse = function(e, i, n, r) {
  122937. return Ge.Parse((function() {
  122938. return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
  122939. }
  122940. ), e, n, r)
  122941. }
  122942. ,
  122943. k([Ce()], t.prototype, "color", void 0),
  122944. k([Ce()], t.prototype, "depth", void 0),
  122945. k([Ce()], t.prototype, "colorLevel", void 0),
  122946. k([Ce()], t.prototype, "refractionTextureUrl", void 0),
  122947. t
  122948. }(Ba);
  122949. y("BABYLON.RefractionPostProcess", sb);
  122950. Pt.ShadersStore.sharpenPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 color=texture2D(textureSampler,vUV);\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\n}";
  122951. var lb = function(e) {
  122952. function t(t, i, n, r, o, s, l, c) {
  122953. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
  122954. void 0 === c && (c = !1);
  122955. var u = e.call(this, t, "sharpen", ["sharpnessAmounts", "screenSize"], null, i, n, r, o, s, null, l, void 0, null, c) || this;
  122956. return u.colorAmount = 1,
  122957. u.edgeAmount = .3,
  122958. u.onApply = function(e) {
  122959. e.setFloat2("screenSize", u.width, u.height),
  122960. e.setFloat2("sharpnessAmounts", u.edgeAmount, u.colorAmount)
  122961. }
  122962. ,
  122963. u
  122964. }
  122965. return U(t, e),
  122966. t.prototype.getClassName = function() {
  122967. return "SharpenPostProcess"
  122968. }
  122969. ,
  122970. t._Parse = function(e, i, n, r) {
  122971. return Ge.Parse((function() {
  122972. return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
  122973. }
  122974. ), e, n, r)
  122975. }
  122976. ,
  122977. k([Ce()], t.prototype, "colorAmount", void 0),
  122978. k([Ce()], t.prototype, "edgeAmount", void 0),
  122979. t
  122980. }(Ba);
  122981. y("BABYLON.SharpenPostProcess", lb);
  122982. var cb = function() {
  122983. function e(e, t) {
  122984. this._engine = e,
  122985. this._name = t,
  122986. this._renderEffects = {},
  122987. this._renderEffectsForIsolatedPass = new Array,
  122988. this._cameras = []
  122989. }
  122990. return Object.defineProperty(e.prototype, "name", {
  122991. get: function() {
  122992. return this._name
  122993. },
  122994. enumerable: !1,
  122995. configurable: !0
  122996. }),
  122997. Object.defineProperty(e.prototype, "cameras", {
  122998. get: function() {
  122999. return this._cameras
  123000. },
  123001. enumerable: !1,
  123002. configurable: !0
  123003. }),
  123004. e.prototype.getClassName = function() {
  123005. return "PostProcessRenderPipeline"
  123006. }
  123007. ,
  123008. Object.defineProperty(e.prototype, "isSupported", {
  123009. get: function() {
  123010. for (var e in this._renderEffects)
  123011. if (Object.prototype.hasOwnProperty.call(this._renderEffects, e) && !this._renderEffects[e].isSupported)
  123012. return !1;
  123013. return !0
  123014. },
  123015. enumerable: !1,
  123016. configurable: !0
  123017. }),
  123018. e.prototype.addEffect = function(e) {
  123019. this._renderEffects[e._name] = e
  123020. }
  123021. ,
  123022. e.prototype._rebuild = function() {}
  123023. ,
  123024. e.prototype._enableEffect = function(e, t) {
  123025. var i = this._renderEffects[e];
  123026. i && i._enable(gi.MakeArray(t || this._cameras))
  123027. }
  123028. ,
  123029. e.prototype._disableEffect = function(e, t) {
  123030. var i = this._renderEffects[e];
  123031. i && i._disable(gi.MakeArray(t || this._cameras))
  123032. }
  123033. ,
  123034. e.prototype._attachCameras = function(e, t) {
  123035. var i = gi.MakeArray(e || this._cameras);
  123036. if (i) {
  123037. var n, r = [];
  123038. for (n = 0; n < i.length; n++) {
  123039. var o = i[n];
  123040. if (o) {
  123041. var a = o.name;
  123042. -1 === this._cameras.indexOf(o) ? this._cameras[a] = o : t && r.push(n)
  123043. }
  123044. }
  123045. for (n = 0; n < r.length; n++)
  123046. i.splice(r[n], 1);
  123047. for (var s in this._renderEffects)
  123048. Object.prototype.hasOwnProperty.call(this._renderEffects, s) && this._renderEffects[s]._attachCameras(i)
  123049. }
  123050. }
  123051. ,
  123052. e.prototype._detachCameras = function(e) {
  123053. var t = gi.MakeArray(e || this._cameras);
  123054. if (t) {
  123055. for (var i in this._renderEffects)
  123056. Object.prototype.hasOwnProperty.call(this._renderEffects, i) && this._renderEffects[i]._detachCameras(t);
  123057. for (var n = 0; n < t.length; n++)
  123058. this._cameras.splice(this._cameras.indexOf(t[n]), 1)
  123059. }
  123060. }
  123061. ,
  123062. e.prototype._update = function() {
  123063. for (var e in this._renderEffects)
  123064. Object.prototype.hasOwnProperty.call(this._renderEffects, e) && this._renderEffects[e]._update();
  123065. for (var t = 0; t < this._cameras.length; t++)
  123066. if (this._cameras[t]) {
  123067. var i = this._cameras[t].name;
  123068. this._renderEffectsForIsolatedPass[i] && this._renderEffectsForIsolatedPass[i]._update()
  123069. }
  123070. }
  123071. ,
  123072. e.prototype._reset = function() {
  123073. this._renderEffects = {},
  123074. this._renderEffectsForIsolatedPass = new Array
  123075. }
  123076. ,
  123077. e.prototype._enableMSAAOnFirstPostProcess = function(e) {
  123078. if (!this._engine._features.supportMSAA)
  123079. return !1;
  123080. var t = Object.keys(this._renderEffects);
  123081. if (t.length > 0) {
  123082. var i = this._renderEffects[t[0]].getPostProcesses();
  123083. i && (i[0].samples = e)
  123084. }
  123085. return !0
  123086. }
  123087. ,
  123088. e.prototype.setPrePassRenderer = function(e) {
  123089. return !1
  123090. }
  123091. ,
  123092. e.prototype.dispose = function() {}
  123093. ,
  123094. k([Ce()], e.prototype, "_name", void 0),
  123095. e
  123096. }()
  123097. , ub = function() {
  123098. function e() {
  123099. this._renderPipelines = {}
  123100. }
  123101. return Object.defineProperty(e.prototype, "supportedPipelines", {
  123102. get: function() {
  123103. var e = [];
  123104. for (var t in this._renderPipelines)
  123105. if (Object.prototype.hasOwnProperty.call(this._renderPipelines, t)) {
  123106. var i = this._renderPipelines[t];
  123107. i.isSupported && e.push(i)
  123108. }
  123109. return e
  123110. },
  123111. enumerable: !1,
  123112. configurable: !0
  123113. }),
  123114. e.prototype.addPipeline = function(e) {
  123115. this._renderPipelines[e._name] = e
  123116. }
  123117. ,
  123118. e.prototype.attachCamerasToRenderPipeline = function(e, t, i) {
  123119. void 0 === i && (i = !1);
  123120. var n = this._renderPipelines[e];
  123121. n && n._attachCameras(t, i)
  123122. }
  123123. ,
  123124. e.prototype.detachCamerasFromRenderPipeline = function(e, t) {
  123125. var i = this._renderPipelines[e];
  123126. i && i._detachCameras(t)
  123127. }
  123128. ,
  123129. e.prototype.enableEffectInPipeline = function(e, t, i) {
  123130. var n = this._renderPipelines[e];
  123131. n && n._enableEffect(t, i)
  123132. }
  123133. ,
  123134. e.prototype.disableEffectInPipeline = function(e, t, i) {
  123135. var n = this._renderPipelines[e];
  123136. n && n._disableEffect(t, i)
  123137. }
  123138. ,
  123139. e.prototype.update = function() {
  123140. for (var e in this._renderPipelines)
  123141. if (Object.prototype.hasOwnProperty.call(this._renderPipelines, e)) {
  123142. var t = this._renderPipelines[e];
  123143. t.isSupported ? t._update() : (t.dispose(),
  123144. delete this._renderPipelines[e])
  123145. }
  123146. }
  123147. ,
  123148. e.prototype._rebuild = function() {
  123149. for (var e in this._renderPipelines)
  123150. Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e]._rebuild()
  123151. }
  123152. ,
  123153. e.prototype.dispose = function() {
  123154. for (var e in this._renderPipelines)
  123155. Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e].dispose()
  123156. }
  123157. ,
  123158. e
  123159. }();
  123160. Object.defineProperty(mn.prototype, "postProcessRenderPipelineManager", {
  123161. get: function() {
  123162. if (!this._postProcessRenderPipelineManager) {
  123163. var e = this._getComponent(Wi.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  123164. e || (e = new hb(this),
  123165. this._addComponent(e)),
  123166. this._postProcessRenderPipelineManager = new ub
  123167. }
  123168. return this._postProcessRenderPipelineManager
  123169. },
  123170. enumerable: !0,
  123171. configurable: !0
  123172. });
  123173. var hb = function() {
  123174. function e(e) {
  123175. this.name = Wi.NAME_POSTPROCESSRENDERPIPELINEMANAGER,
  123176. this.scene = e
  123177. }
  123178. return e.prototype.register = function() {
  123179. this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets)
  123180. }
  123181. ,
  123182. e.prototype.rebuild = function() {
  123183. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild()
  123184. }
  123185. ,
  123186. e.prototype.dispose = function() {
  123187. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose()
  123188. }
  123189. ,
  123190. e.prototype._gatherRenderTargets = function() {
  123191. this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update()
  123192. }
  123193. ,
  123194. e
  123195. }()
  123196. , db = function(e) {
  123197. function t(t, i, n, r, o) {
  123198. void 0 === t && (t = ""),
  123199. void 0 === i && (i = !0),
  123200. void 0 === n && (n = E.LastCreatedScene),
  123201. void 0 === o && (o = !0);
  123202. var s = e.call(this, n.getEngine(), t) || this;
  123203. s._camerasToBeAttached = [],
  123204. s.SharpenPostProcessId = "SharpenPostProcessEffect",
  123205. s.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect",
  123206. s.FxaaPostProcessId = "FxaaPostProcessEffect",
  123207. s.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect",
  123208. s.GrainPostProcessId = "GrainPostProcessEffect",
  123209. s._glowLayer = null,
  123210. s.animations = [],
  123211. s._imageProcessingConfigurationObserver = null,
  123212. s._sharpenEnabled = !1,
  123213. s._bloomEnabled = !1,
  123214. s._depthOfFieldEnabled = !1,
  123215. s._depthOfFieldBlurLevel = Ky.Low,
  123216. s._fxaaEnabled = !1,
  123217. s._imageProcessingEnabled = !0,
  123218. s._bloomScale = .5,
  123219. s._chromaticAberrationEnabled = !1,
  123220. s._grainEnabled = !1,
  123221. s._buildAllowed = !0,
  123222. s.onBuildObservable = new h,
  123223. s._resizeObserver = null,
  123224. s._hardwareScaleLevel = 1,
  123225. s._bloomKernel = 64,
  123226. s._bloomWeight = .15,
  123227. s._bloomThreshold = .9,
  123228. s._samples = 1,
  123229. s._hasCleared = !1,
  123230. s._prevPostProcess = null,
  123231. s._prevPrevPostProcess = null,
  123232. s._depthOfFieldSceneObserver = null,
  123233. s._cameras = r || n.cameras,
  123234. s._cameras = s._cameras.slice(),
  123235. s._camerasToBeAttached = s._cameras.slice(),
  123236. s._buildAllowed = o,
  123237. s._scene = n;
  123238. var l = s._scene.getEngine().getCaps();
  123239. s._hdr = i && (l.textureHalfFloatRender || l.textureFloatRender),
  123240. s._hdr ? l.textureHalfFloatRender ? s._defaultPipelineTextureType = a.TEXTURETYPE_HALF_FLOAT : l.textureFloatRender && (s._defaultPipelineTextureType = a.TEXTURETYPE_FLOAT) : s._defaultPipelineTextureType = a.TEXTURETYPE_UNSIGNED_INT,
  123241. n.postProcessRenderPipelineManager.addPipeline(s);
  123242. var c = s._scene.getEngine();
  123243. return s.sharpen = new lb("sharpen",1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
  123244. s._sharpenEffect = new Vy(c,s.SharpenPostProcessId,(function() {
  123245. return s.sharpen
  123246. }
  123247. ),!0),
  123248. s.depthOfField = new Zy(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),
  123249. s.bloom = new zy(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),
  123250. s.chromaticAberration = new Wy("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
  123251. s._chromaticAberrationEffect = new Vy(c,s.ChromaticAberrationPostProcessId,(function() {
  123252. return s.chromaticAberration
  123253. }
  123254. ),!0),
  123255. s.grain = new tb("Grain",1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
  123256. s._grainEffect = new Vy(c,s.GrainPostProcessId,(function() {
  123257. return s.grain
  123258. }
  123259. ),!0),
  123260. s._resizeObserver = c.onResizeObservable.add((function() {
  123261. s._hardwareScaleLevel = c.getHardwareScalingLevel(),
  123262. s.bloomKernel = s._bloomKernel
  123263. }
  123264. )),
  123265. s._imageProcessingConfigurationObserver = s._scene.imageProcessingConfiguration.onUpdateParameters.add((function() {
  123266. s.bloom._downscale._exposure = s._scene.imageProcessingConfiguration.exposure,
  123267. s.imageProcessingEnabled !== s._scene.imageProcessingConfiguration.isEnabled && (s._imageProcessingEnabled = s._scene.imageProcessingConfiguration.isEnabled,
  123268. s._buildPipeline())
  123269. }
  123270. )),
  123271. s._buildPipeline(),
  123272. s
  123273. }
  123274. return U(t, e),
  123275. Object.defineProperty(t.prototype, "scene", {
  123276. get: function() {
  123277. return this._scene
  123278. },
  123279. enumerable: !1,
  123280. configurable: !0
  123281. }),
  123282. Object.defineProperty(t.prototype, "sharpenEnabled", {
  123283. get: function() {
  123284. return this._sharpenEnabled
  123285. },
  123286. set: function(e) {
  123287. this._sharpenEnabled !== e && (this._sharpenEnabled = e,
  123288. this._buildPipeline())
  123289. },
  123290. enumerable: !1,
  123291. configurable: !0
  123292. }),
  123293. Object.defineProperty(t.prototype, "bloomKernel", {
  123294. get: function() {
  123295. return this._bloomKernel
  123296. },
  123297. set: function(e) {
  123298. this._bloomKernel = e,
  123299. this.bloom.kernel = e / this._hardwareScaleLevel
  123300. },
  123301. enumerable: !1,
  123302. configurable: !0
  123303. }),
  123304. Object.defineProperty(t.prototype, "bloomWeight", {
  123305. get: function() {
  123306. return this._bloomWeight
  123307. },
  123308. set: function(e) {
  123309. this._bloomWeight !== e && (this.bloom.weight = e,
  123310. this._bloomWeight = e)
  123311. },
  123312. enumerable: !1,
  123313. configurable: !0
  123314. }),
  123315. Object.defineProperty(t.prototype, "bloomThreshold", {
  123316. get: function() {
  123317. return this._bloomThreshold
  123318. },
  123319. set: function(e) {
  123320. this._bloomThreshold !== e && (this.bloom.threshold = e,
  123321. this._bloomThreshold = e)
  123322. },
  123323. enumerable: !1,
  123324. configurable: !0
  123325. }),
  123326. Object.defineProperty(t.prototype, "bloomScale", {
  123327. get: function() {
  123328. return this._bloomScale
  123329. },
  123330. set: function(e) {
  123331. this._bloomScale !== e && (this._bloomScale = e,
  123332. this._rebuildBloom(),
  123333. this._buildPipeline())
  123334. },
  123335. enumerable: !1,
  123336. configurable: !0
  123337. }),
  123338. Object.defineProperty(t.prototype, "bloomEnabled", {
  123339. get: function() {
  123340. return this._bloomEnabled
  123341. },
  123342. set: function(e) {
  123343. this._bloomEnabled !== e && (this._bloomEnabled = e,
  123344. this._buildPipeline())
  123345. },
  123346. enumerable: !1,
  123347. configurable: !0
  123348. }),
  123349. t.prototype._rebuildBloom = function() {
  123350. var e = this.bloom;
  123351. this.bloom = new zy(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),
  123352. this.bloom.threshold = e.threshold;
  123353. for (var t = 0; t < this._cameras.length; t++)
  123354. e.disposeEffects(this._cameras[t])
  123355. }
  123356. ,
  123357. Object.defineProperty(t.prototype, "depthOfFieldEnabled", {
  123358. get: function() {
  123359. return this._depthOfFieldEnabled
  123360. },
  123361. set: function(e) {
  123362. this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e,
  123363. this._buildPipeline())
  123364. },
  123365. enumerable: !1,
  123366. configurable: !0
  123367. }),
  123368. Object.defineProperty(t.prototype, "depthOfFieldBlurLevel", {
  123369. get: function() {
  123370. return this._depthOfFieldBlurLevel
  123371. },
  123372. set: function(e) {
  123373. if (this._depthOfFieldBlurLevel !== e) {
  123374. this._depthOfFieldBlurLevel = e;
  123375. var t = this.depthOfField;
  123376. this.depthOfField = new Zy(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),
  123377. this.depthOfField.focalLength = t.focalLength,
  123378. this.depthOfField.focusDistance = t.focusDistance,
  123379. this.depthOfField.fStop = t.fStop,
  123380. this.depthOfField.lensSize = t.lensSize;
  123381. for (var i = 0; i < this._cameras.length; i++)
  123382. t.disposeEffects(this._cameras[i]);
  123383. this._buildPipeline()
  123384. }
  123385. },
  123386. enumerable: !1,
  123387. configurable: !0
  123388. }),
  123389. Object.defineProperty(t.prototype, "fxaaEnabled", {
  123390. get: function() {
  123391. return this._fxaaEnabled
  123392. },
  123393. set: function(e) {
  123394. this._fxaaEnabled !== e && (this._fxaaEnabled = e,
  123395. this._buildPipeline())
  123396. },
  123397. enumerable: !1,
  123398. configurable: !0
  123399. }),
  123400. Object.defineProperty(t.prototype, "samples", {
  123401. get: function() {
  123402. return this._samples
  123403. },
  123404. set: function(e) {
  123405. this._samples !== e && (this._samples = e,
  123406. this._buildPipeline())
  123407. },
  123408. enumerable: !1,
  123409. configurable: !0
  123410. }),
  123411. Object.defineProperty(t.prototype, "imageProcessingEnabled", {
  123412. get: function() {
  123413. return this._imageProcessingEnabled
  123414. },
  123415. set: function(e) {
  123416. this._imageProcessingEnabled !== e && (this._scene.imageProcessingConfiguration.isEnabled = e)
  123417. },
  123418. enumerable: !1,
  123419. configurable: !0
  123420. }),
  123421. Object.defineProperty(t.prototype, "glowLayerEnabled", {
  123422. get: function() {
  123423. return null != this._glowLayer
  123424. },
  123425. set: function(e) {
  123426. e && !this._glowLayer ? this._glowLayer = new qf("",this._scene) : !e && this._glowLayer && (this._glowLayer.dispose(),
  123427. this._glowLayer = null)
  123428. },
  123429. enumerable: !1,
  123430. configurable: !0
  123431. }),
  123432. Object.defineProperty(t.prototype, "glowLayer", {
  123433. get: function() {
  123434. return this._glowLayer
  123435. },
  123436. enumerable: !1,
  123437. configurable: !0
  123438. }),
  123439. Object.defineProperty(t.prototype, "chromaticAberrationEnabled", {
  123440. get: function() {
  123441. return this._chromaticAberrationEnabled
  123442. },
  123443. set: function(e) {
  123444. this._chromaticAberrationEnabled !== e && (this._chromaticAberrationEnabled = e,
  123445. this._buildPipeline())
  123446. },
  123447. enumerable: !1,
  123448. configurable: !0
  123449. }),
  123450. Object.defineProperty(t.prototype, "grainEnabled", {
  123451. get: function() {
  123452. return this._grainEnabled
  123453. },
  123454. set: function(e) {
  123455. this._grainEnabled !== e && (this._grainEnabled = e,
  123456. this._buildPipeline())
  123457. },
  123458. enumerable: !1,
  123459. configurable: !0
  123460. }),
  123461. t.prototype.getClassName = function() {
  123462. return "DefaultRenderingPipeline"
  123463. }
  123464. ,
  123465. t.prototype.prepare = function() {
  123466. var e = this._buildAllowed;
  123467. this._buildAllowed = !0,
  123468. this._buildPipeline(),
  123469. this._buildAllowed = e
  123470. }
  123471. ,
  123472. t.prototype._setAutoClearAndTextureSharing = function(e, t) {
  123473. void 0 === t && (t = !1),
  123474. this._hasCleared ? e.autoClear = !1 : (e.autoClear = !0,
  123475. this._scene.autoClear = !1,
  123476. this._hasCleared = !0),
  123477. t || (this._prevPrevPostProcess ? e.shareOutputWith(this._prevPrevPostProcess) : e.useOwnOutput(),
  123478. this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess),
  123479. this._prevPostProcess = e)
  123480. }
  123481. ,
  123482. t.prototype._buildPipeline = function() {
  123483. var e = this;
  123484. if (this._buildAllowed) {
  123485. this._scene.autoClear = !0;
  123486. var t = this._scene.getEngine();
  123487. if (this._disposePostProcesses(),
  123488. null !== this._cameras && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  123489. this._cameras = this._camerasToBeAttached.slice()),
  123490. this._reset(),
  123491. this._prevPostProcess = null,
  123492. this._prevPrevPostProcess = null,
  123493. this._hasCleared = !1,
  123494. this.depthOfFieldEnabled) {
  123495. if (this._cameras.length > 1) {
  123496. for (var i = 0, n = this._cameras; i < n.length; i++) {
  123497. var r = n[i];
  123498. (o = this._scene.enableDepthRenderer(r)).useOnlyInActiveCamera = !0
  123499. }
  123500. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add((function(t) {
  123501. e._cameras.indexOf(t.activeCamera) > -1 && (e.depthOfField.depthTexture = t.enableDepthRenderer(t.activeCamera).getDepthMap())
  123502. }
  123503. ))
  123504. } else {
  123505. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  123506. var o = this._scene.enableDepthRenderer(this._cameras[0]);
  123507. this.depthOfField.depthTexture = o.getDepthMap()
  123508. }
  123509. this.depthOfField._isReady() || this.depthOfField._updateEffects(),
  123510. this.addEffect(this.depthOfField),
  123511. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], !0)
  123512. } else
  123513. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  123514. this.bloomEnabled && (this.bloom._isReady() || this.bloom._updateEffects(),
  123515. this.addEffect(this.bloom),
  123516. this._setAutoClearAndTextureSharing(this.bloom._effects[0], !0)),
  123517. this._imageProcessingEnabled && (this.imageProcessing = new Fs("imageProcessing",1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),
  123518. this._hdr ? (this.addEffect(new Vy(t,this.ImageProcessingPostProcessId,(function() {
  123519. return e.imageProcessing
  123520. }
  123521. ),!0)),
  123522. this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
  123523. this.cameras && 0 !== this.cameras.length || (this._scene.imageProcessingConfiguration.applyByPostProcess = !1),
  123524. this.imageProcessing.getEffect() || this.imageProcessing._updateParameters()),
  123525. this.sharpenEnabled && (this.sharpen.isReady() || this.sharpen.updateEffect(),
  123526. this.addEffect(this._sharpenEffect),
  123527. this._setAutoClearAndTextureSharing(this.sharpen)),
  123528. this.grainEnabled && (this.grain.isReady() || this.grain.updateEffect(),
  123529. this.addEffect(this._grainEffect),
  123530. this._setAutoClearAndTextureSharing(this.grain)),
  123531. this.chromaticAberrationEnabled && (this.chromaticAberration.isReady() || this.chromaticAberration.updateEffect(),
  123532. this.addEffect(this._chromaticAberrationEffect),
  123533. this._setAutoClearAndTextureSharing(this.chromaticAberration)),
  123534. this.fxaaEnabled && (this.fxaa = new eb("fxaa",1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),
  123535. this.addEffect(new Vy(t,this.FxaaPostProcessId,(function() {
  123536. return e.fxaa
  123537. }
  123538. ),!0)),
  123539. this._setAutoClearAndTextureSharing(this.fxaa, !0)),
  123540. null !== this._cameras && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras),
  123541. this._scene.activeCameras && this._scene.activeCameras.length > 1 && (this._scene.autoClear = !0),
  123542. !this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1 && K.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),
  123543. this.onBuildObservable.notifyObservers(this)
  123544. }
  123545. }
  123546. ,
  123547. t.prototype._disposePostProcesses = function(e) {
  123548. void 0 === e && (e = !1);
  123549. for (var t = 0; t < this._cameras.length; t++) {
  123550. var i = this._cameras[t];
  123551. this.imageProcessing && this.imageProcessing.dispose(i),
  123552. this.fxaa && this.fxaa.dispose(i),
  123553. e && (this.sharpen && this.sharpen.dispose(i),
  123554. this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),
  123555. this.depthOfField.disposeEffects(i)),
  123556. this.bloom && this.bloom.disposeEffects(i),
  123557. this.chromaticAberration && this.chromaticAberration.dispose(i),
  123558. this.grain && this.grain.dispose(i),
  123559. this._glowLayer && this._glowLayer.dispose())
  123560. }
  123561. this.imageProcessing = null,
  123562. this.fxaa = null,
  123563. e && (this.sharpen = null,
  123564. this._sharpenEffect = null,
  123565. this.depthOfField = null,
  123566. this.bloom = null,
  123567. this.chromaticAberration = null,
  123568. this._chromaticAberrationEffect = null,
  123569. this.grain = null,
  123570. this._grainEffect = null,
  123571. this._glowLayer = null)
  123572. }
  123573. ,
  123574. t.prototype.addCamera = function(e) {
  123575. this._camerasToBeAttached.push(e),
  123576. this._buildPipeline()
  123577. }
  123578. ,
  123579. t.prototype.removeCamera = function(e) {
  123580. var t = this._camerasToBeAttached.indexOf(e);
  123581. this._camerasToBeAttached.splice(t, 1),
  123582. this._buildPipeline()
  123583. }
  123584. ,
  123585. t.prototype.dispose = function() {
  123586. this.onBuildObservable.clear(),
  123587. this._disposePostProcesses(!0),
  123588. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  123589. this._scene.autoClear = !0,
  123590. this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),
  123591. this._resizeObserver = null),
  123592. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),
  123593. e.prototype.dispose.call(this)
  123594. }
  123595. ,
  123596. t.prototype.serialize = function() {
  123597. var e = Ge.Serialize(this);
  123598. return e.customType = "DefaultRenderingPipeline",
  123599. e
  123600. }
  123601. ,
  123602. t.Parse = function(e, i, n) {
  123603. return Ge.Parse((function() {
  123604. return new t(e._name,e._name._hdr,i)
  123605. }
  123606. ), e, i, n)
  123607. }
  123608. ,
  123609. k([Ce()], t.prototype, "sharpenEnabled", null),
  123610. k([Ce()], t.prototype, "bloomKernel", null),
  123611. k([Ce()], t.prototype, "_bloomWeight", void 0),
  123612. k([Ce()], t.prototype, "_bloomThreshold", void 0),
  123613. k([Ce()], t.prototype, "_hdr", void 0),
  123614. k([Ce()], t.prototype, "bloomWeight", null),
  123615. k([Ce()], t.prototype, "bloomThreshold", null),
  123616. k([Ce()], t.prototype, "bloomScale", null),
  123617. k([Ce()], t.prototype, "bloomEnabled", null),
  123618. k([Ce()], t.prototype, "depthOfFieldEnabled", null),
  123619. k([Ce()], t.prototype, "depthOfFieldBlurLevel", null),
  123620. k([Ce()], t.prototype, "fxaaEnabled", null),
  123621. k([Ce()], t.prototype, "samples", null),
  123622. k([Ce()], t.prototype, "imageProcessingEnabled", null),
  123623. k([Ce()], t.prototype, "glowLayerEnabled", null),
  123624. k([Ce()], t.prototype, "chromaticAberrationEnabled", null),
  123625. k([Ce()], t.prototype, "grainEnabled", null),
  123626. t
  123627. }(cb);
  123628. y("BABYLON.DefaultRenderingPipeline", db);
  123629. Pt.ShadersStore.lensHighlightsPixelShader = "uniform sampler2D textureSampler; \nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\nvarying vec2 vUV;\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\nif (gain==-1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n}";
  123630. Pt.ShadersStore.depthOfFieldPixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\nuniform float near;\nuniform float far;\nvarying vec2 vUV;\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion==0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\nfloat sampleScreen(inout vec4 color,in vec2 offset,in float weight) {\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\nreturn col;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\nif (dof_enabled==false || coc<0.07) { coc=0.0; }\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\nfloat blur_amount=max(edge_blur_amount,coc);\nif (blur_amount==0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\ngl_FragColor=getBlurColor(blur_amount*1.7);\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n";
  123631. var pb = function(e) {
  123632. function t(t, i, n, r, o) {
  123633. void 0 === r && (r = 1);
  123634. var a = e.call(this, n.getEngine(), t) || this;
  123635. return a.LensChromaticAberrationEffect = "LensChromaticAberrationEffect",
  123636. a.HighlightsEnhancingEffect = "HighlightsEnhancingEffect",
  123637. a.LensDepthOfFieldEffect = "LensDepthOfFieldEffect",
  123638. a._pentagonBokehIsEnabled = !1,
  123639. a._scene = n,
  123640. a._depthTexture = n.enableDepthRenderer().getDepthMap(),
  123641. i.grain_texture ? a._grainTexture = i.grain_texture : a._createGrainTexture(),
  123642. a._edgeBlur = i.edge_blur ? i.edge_blur : 0,
  123643. a._grainAmount = i.grain_amount ? i.grain_amount : 0,
  123644. a._chromaticAberration = i.chromatic_aberration ? i.chromatic_aberration : 0,
  123645. a._distortion = i.distortion ? i.distortion : 0,
  123646. a._highlightsGain = void 0 !== i.dof_gain ? i.dof_gain : -1,
  123647. a._highlightsThreshold = i.dof_threshold ? i.dof_threshold : 1,
  123648. a._dofDistance = void 0 !== i.dof_focus_distance ? i.dof_focus_distance : -1,
  123649. a._dofAperture = i.dof_aperture ? i.dof_aperture : 1,
  123650. a._dofDarken = i.dof_darken ? i.dof_darken : 0,
  123651. a._dofPentagon = void 0 === i.dof_pentagon || i.dof_pentagon,
  123652. a._blurNoise = void 0 === i.blur_noise || i.blur_noise,
  123653. a._createChromaticAberrationPostProcess(r),
  123654. a._createHighlightsPostProcess(r),
  123655. a._createDepthOfFieldPostProcess(r / 4),
  123656. a.addEffect(new Vy(n.getEngine(),a.LensChromaticAberrationEffect,(function() {
  123657. return a._chromaticAberrationPostProcess
  123658. }
  123659. ),!0)),
  123660. a.addEffect(new Vy(n.getEngine(),a.HighlightsEnhancingEffect,(function() {
  123661. return a._highlightsPostProcess
  123662. }
  123663. ),!0)),
  123664. a.addEffect(new Vy(n.getEngine(),a.LensDepthOfFieldEffect,(function() {
  123665. return a._depthOfFieldPostProcess
  123666. }
  123667. ),!0)),
  123668. -1 === a._highlightsGain && a._disableEffect(a.HighlightsEnhancingEffect, null),
  123669. n.postProcessRenderPipelineManager.addPipeline(a),
  123670. o && n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, o),
  123671. a
  123672. }
  123673. return U(t, e),
  123674. t.prototype.getClassName = function() {
  123675. return "LensRenderingPipeline"
  123676. }
  123677. ,
  123678. Object.defineProperty(t.prototype, "scene", {
  123679. get: function() {
  123680. return this._scene
  123681. },
  123682. enumerable: !1,
  123683. configurable: !0
  123684. }),
  123685. Object.defineProperty(t.prototype, "edgeBlur", {
  123686. get: function() {
  123687. return this._edgeBlur
  123688. },
  123689. set: function(e) {
  123690. this.setEdgeBlur(e)
  123691. },
  123692. enumerable: !1,
  123693. configurable: !0
  123694. }),
  123695. Object.defineProperty(t.prototype, "grainAmount", {
  123696. get: function() {
  123697. return this._grainAmount
  123698. },
  123699. set: function(e) {
  123700. this.setGrainAmount(e)
  123701. },
  123702. enumerable: !1,
  123703. configurable: !0
  123704. }),
  123705. Object.defineProperty(t.prototype, "chromaticAberration", {
  123706. get: function() {
  123707. return this._chromaticAberration
  123708. },
  123709. set: function(e) {
  123710. this.setChromaticAberration(e)
  123711. },
  123712. enumerable: !1,
  123713. configurable: !0
  123714. }),
  123715. Object.defineProperty(t.prototype, "dofAperture", {
  123716. get: function() {
  123717. return this._dofAperture
  123718. },
  123719. set: function(e) {
  123720. this.setAperture(e)
  123721. },
  123722. enumerable: !1,
  123723. configurable: !0
  123724. }),
  123725. Object.defineProperty(t.prototype, "edgeDistortion", {
  123726. get: function() {
  123727. return this._distortion
  123728. },
  123729. set: function(e) {
  123730. this.setEdgeDistortion(e)
  123731. },
  123732. enumerable: !1,
  123733. configurable: !0
  123734. }),
  123735. Object.defineProperty(t.prototype, "dofDistortion", {
  123736. get: function() {
  123737. return this._dofDistance
  123738. },
  123739. set: function(e) {
  123740. this.setFocusDistance(e)
  123741. },
  123742. enumerable: !1,
  123743. configurable: !0
  123744. }),
  123745. Object.defineProperty(t.prototype, "darkenOutOfFocus", {
  123746. get: function() {
  123747. return this._dofDarken
  123748. },
  123749. set: function(e) {
  123750. this.setDarkenOutOfFocus(e)
  123751. },
  123752. enumerable: !1,
  123753. configurable: !0
  123754. }),
  123755. Object.defineProperty(t.prototype, "blurNoise", {
  123756. get: function() {
  123757. return this._blurNoise
  123758. },
  123759. set: function(e) {
  123760. this._blurNoise = e
  123761. },
  123762. enumerable: !1,
  123763. configurable: !0
  123764. }),
  123765. Object.defineProperty(t.prototype, "pentagonBokeh", {
  123766. get: function() {
  123767. return this._pentagonBokehIsEnabled
  123768. },
  123769. set: function(e) {
  123770. e ? this.enablePentagonBokeh() : this.disablePentagonBokeh()
  123771. },
  123772. enumerable: !1,
  123773. configurable: !0
  123774. }),
  123775. Object.defineProperty(t.prototype, "highlightsGain", {
  123776. get: function() {
  123777. return this._highlightsGain
  123778. },
  123779. set: function(e) {
  123780. this.setHighlightsGain(e)
  123781. },
  123782. enumerable: !1,
  123783. configurable: !0
  123784. }),
  123785. Object.defineProperty(t.prototype, "highlightsThreshold", {
  123786. get: function() {
  123787. return this._highlightsThreshold
  123788. },
  123789. set: function(e) {
  123790. this.setHighlightsThreshold(e)
  123791. },
  123792. enumerable: !1,
  123793. configurable: !0
  123794. }),
  123795. t.prototype.setEdgeBlur = function(e) {
  123796. this._edgeBlur = e
  123797. }
  123798. ,
  123799. t.prototype.disableEdgeBlur = function() {
  123800. this._edgeBlur = 0
  123801. }
  123802. ,
  123803. t.prototype.setGrainAmount = function(e) {
  123804. this._grainAmount = e
  123805. }
  123806. ,
  123807. t.prototype.disableGrain = function() {
  123808. this._grainAmount = 0
  123809. }
  123810. ,
  123811. t.prototype.setChromaticAberration = function(e) {
  123812. this._chromaticAberration = e
  123813. }
  123814. ,
  123815. t.prototype.disableChromaticAberration = function() {
  123816. this._chromaticAberration = 0
  123817. }
  123818. ,
  123819. t.prototype.setEdgeDistortion = function(e) {
  123820. this._distortion = e
  123821. }
  123822. ,
  123823. t.prototype.disableEdgeDistortion = function() {
  123824. this._distortion = 0
  123825. }
  123826. ,
  123827. t.prototype.setFocusDistance = function(e) {
  123828. this._dofDistance = e
  123829. }
  123830. ,
  123831. t.prototype.disableDepthOfField = function() {
  123832. this._dofDistance = -1
  123833. }
  123834. ,
  123835. t.prototype.setAperture = function(e) {
  123836. this._dofAperture = e
  123837. }
  123838. ,
  123839. t.prototype.setDarkenOutOfFocus = function(e) {
  123840. this._dofDarken = e
  123841. }
  123842. ,
  123843. t.prototype.enablePentagonBokeh = function() {
  123844. this._highlightsPostProcess.updateEffect("#define PENTAGON\n"),
  123845. this._pentagonBokehIsEnabled = !0
  123846. }
  123847. ,
  123848. t.prototype.disablePentagonBokeh = function() {
  123849. this._pentagonBokehIsEnabled = !1,
  123850. this._highlightsPostProcess.updateEffect()
  123851. }
  123852. ,
  123853. t.prototype.enableNoiseBlur = function() {
  123854. this._blurNoise = !0
  123855. }
  123856. ,
  123857. t.prototype.disableNoiseBlur = function() {
  123858. this._blurNoise = !1
  123859. }
  123860. ,
  123861. t.prototype.setHighlightsGain = function(e) {
  123862. this._highlightsGain = e
  123863. }
  123864. ,
  123865. t.prototype.setHighlightsThreshold = function(e) {
  123866. -1 === this._highlightsGain && (this._highlightsGain = 1),
  123867. this._highlightsThreshold = e
  123868. }
  123869. ,
  123870. t.prototype.disableHighlights = function() {
  123871. this._highlightsGain = -1
  123872. }
  123873. ,
  123874. t.prototype.dispose = function(e) {
  123875. void 0 === e && (e = !1),
  123876. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
  123877. this._chromaticAberrationPostProcess = null,
  123878. this._highlightsPostProcess = null,
  123879. this._depthOfFieldPostProcess = null,
  123880. this._grainTexture.dispose(),
  123881. e && this._scene.disableDepthRenderer()
  123882. }
  123883. ,
  123884. t.prototype._createChromaticAberrationPostProcess = function(e) {
  123885. var t = this;
  123886. this._chromaticAberrationPostProcess = new Ba("LensChromaticAberration","chromaticAberration",["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"],[],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
  123887. this._chromaticAberrationPostProcess.onApply = function(e) {
  123888. e.setFloat("chromatic_aberration", t._chromaticAberration),
  123889. e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
  123890. e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()),
  123891. e.setFloat("radialIntensity", 1),
  123892. e.setFloat2("direction", 17, 17),
  123893. e.setFloat2("centerPosition", .5, .5)
  123894. }
  123895. }
  123896. ,
  123897. t.prototype._createHighlightsPostProcess = function(e) {
  123898. var t = this;
  123899. this._highlightsPostProcess = new Ba("LensHighlights","lensHighlights",["gain", "threshold", "screen_width", "screen_height"],[],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon ? "#define PENTAGON\n" : ""),
  123900. this._highlightsPostProcess.externalTextureSamplerBinding = !0,
  123901. this._highlightsPostProcess.onApply = function(e) {
  123902. e.setFloat("gain", t._highlightsGain),
  123903. e.setFloat("threshold", t._highlightsThreshold),
  123904. e.setTextureFromPostProcess("textureSampler", t._chromaticAberrationPostProcess),
  123905. e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
  123906. e.setFloat("screen_height", t._scene.getEngine().getRenderHeight())
  123907. }
  123908. }
  123909. ,
  123910. t.prototype._createDepthOfFieldPostProcess = function(e) {
  123911. var t = this;
  123912. this._depthOfFieldPostProcess = new Ba("LensDepthOfField","depthOfField",["grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled", "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"],["depthSampler", "grainSampler", "highlightsSampler"],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
  123913. this._depthOfFieldPostProcess.externalTextureSamplerBinding = !0,
  123914. this._depthOfFieldPostProcess.onApply = function(e) {
  123915. e.setTexture("depthSampler", t._depthTexture),
  123916. e.setTexture("grainSampler", t._grainTexture),
  123917. e.setTextureFromPostProcess("textureSampler", t._highlightsPostProcess),
  123918. e.setTextureFromPostProcess("highlightsSampler", t._depthOfFieldPostProcess),
  123919. e.setFloat("grain_amount", t._grainAmount),
  123920. e.setBool("blur_noise", t._blurNoise),
  123921. e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
  123922. e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()),
  123923. e.setFloat("distortion", t._distortion),
  123924. e.setBool("dof_enabled", -1 !== t._dofDistance),
  123925. e.setFloat("screen_distance", 1 / (.1 - 1 / t._dofDistance)),
  123926. e.setFloat("aperture", t._dofAperture),
  123927. e.setFloat("darken", t._dofDarken),
  123928. e.setFloat("edge_blur", t._edgeBlur),
  123929. e.setBool("highlights", -1 !== t._highlightsGain),
  123930. t._scene.activeCamera && (e.setFloat("near", t._scene.activeCamera.minZ),
  123931. e.setFloat("far", t._scene.activeCamera.maxZ))
  123932. }
  123933. }
  123934. ,
  123935. t.prototype._createGrainTexture = function() {
  123936. this._grainTexture = new Ds("LensNoiseTexture",512,this._scene,!1,io.BILINEAR_SAMPLINGMODE),
  123937. this._grainTexture.wrapU = io.WRAP_ADDRESSMODE,
  123938. this._grainTexture.wrapV = io.WRAP_ADDRESSMODE;
  123939. for (var e, t = this._grainTexture.getContext(), i = 0; i < 512; i++)
  123940. for (var n = 0; n < 512; n++)
  123941. e = Math.floor(255 * (.42,
  123942. .58,
  123943. Math.random() * (.58 - .42) + .42)),
  123944. t.fillStyle = "rgb(" + e + ", " + e + ", " + e + ")",
  123945. t.fillRect(i, n, 1, 1);
  123946. this._grainTexture.update(!1)
  123947. }
  123948. ,
  123949. t
  123950. }(cb)
  123951. , fb = function() {
  123952. this.enabled = !1,
  123953. this.name = "ssao2",
  123954. this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_DEPTH_TEXTURE_TYPE]
  123955. };
  123956. Pt.ShadersStore.ssao2PixelShader = "precision highp float;\nuniform sampler2D textureSampler;\nuniform float near;\nuniform float far;\nuniform float radius;\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);\nvarying vec2 vUV;\nfloat perspectiveDepthToViewZ(in float invClipZ,in float near,in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( in float viewZ,in float near,in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( in float viewZ,in float near,in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D normalSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float base;\nuniform float xViewport;\nuniform float yViewport;\nuniform mat3 depthProjection;\nuniform float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\nvec3 normal=texture2D(normalSampler,vUV).rgb;\nfloat occlusion=0.0;\nfloat correctedRadius=min(radius,minZAspect*depth/near);\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\nvec3 vDepthFactor=depthProjection*vec3(1.0,1.0,depth);\nvec3 origin=vViewRay*vDepthFactor;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\nfloat dotProduct=dot(rvec,normal);\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i<SAMPLES; ++i) {\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\nvec4 offset=vec4(samplePosition,1.0);\noffset=projection*offset;\noffset.xyz/=offset.w;\noffset.xy=offset.xy*0.5+0.5;\nif (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {\ncontinue;\n}\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+= weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+= weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 direction=vec2(0.0,1.0);\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=abs(texture2D(depthSampler,samplePos).r);\nfloat weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n#else\nvec4 color;\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#else\nvec2 direction=vec2(0.0,1.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#endif\ngl_FragColor.rgb=vec3(color.r);\ngl_FragColor.a=1.0;\n#endif\n}\n#endif\n";
  123957. Pt.ShadersStore.ssaoCombinePixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
  123958. var _b = function(e) {
  123959. function t(t, i, n, r, o, s) {
  123960. void 0 === o && (o = !1),
  123961. void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT);
  123962. var l = e.call(this, i.getEngine(), t) || this;
  123963. if (l.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect",
  123964. l.SSAORenderEffect = "SSAORenderEffect",
  123965. l.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect",
  123966. l.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect",
  123967. l.SSAOCombineRenderEffect = "SSAOCombineRenderEffect",
  123968. l.totalStrength = 1,
  123969. l.maxZ = 100,
  123970. l.minZAspect = .2,
  123971. l._samples = 8,
  123972. l._textureSamples = 1,
  123973. l._forceGeometryBuffer = !1,
  123974. l._expensiveBlur = !0,
  123975. l.radius = 2,
  123976. l.base = 0,
  123977. l._bits = new Uint32Array(1),
  123978. l._scene = i,
  123979. l._ratio = n,
  123980. l._forceGeometryBuffer = o,
  123981. !l.isSupported)
  123982. return K.Error("The current engine does not support SSAO 2."),
  123983. l;
  123984. var c = l._ratio.ssaoRatio || n
  123985. , u = l._ratio.blurRatio || n;
  123986. return l._forceGeometryBuffer ? i.enableGeometryBufferRenderer() : i.enablePrePassRenderer(),
  123987. l._createRandomTexture(),
  123988. l._originalColorPostProcess = new Ua("SSAOOriginalSceneColor",1,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),void 0,s),
  123989. l._originalColorPostProcess.samples = l.textureSamples,
  123990. l._createSSAOPostProcess(1, s),
  123991. l._createBlurPostProcess(c, u, s),
  123992. l._createSSAOCombinePostProcess(u, s),
  123993. l.addEffect(new Vy(i.getEngine(),l.SSAOOriginalSceneColorEffect,(function() {
  123994. return l._originalColorPostProcess
  123995. }
  123996. ),!0)),
  123997. l.addEffect(new Vy(i.getEngine(),l.SSAORenderEffect,(function() {
  123998. return l._ssaoPostProcess
  123999. }
  124000. ),!0)),
  124001. l.addEffect(new Vy(i.getEngine(),l.SSAOBlurHRenderEffect,(function() {
  124002. return l._blurHPostProcess
  124003. }
  124004. ),!0)),
  124005. l.addEffect(new Vy(i.getEngine(),l.SSAOBlurVRenderEffect,(function() {
  124006. return l._blurVPostProcess
  124007. }
  124008. ),!0)),
  124009. l.addEffect(new Vy(i.getEngine(),l.SSAOCombineRenderEffect,(function() {
  124010. return l._ssaoCombinePostProcess
  124011. }
  124012. ),!0)),
  124013. i.postProcessRenderPipelineManager.addPipeline(l),
  124014. r && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, r),
  124015. l
  124016. }
  124017. return U(t, e),
  124018. Object.defineProperty(t.prototype, "samples", {
  124019. get: function() {
  124020. return this._samples
  124021. },
  124022. set: function(e) {
  124023. this._samples = e,
  124024. this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),
  124025. this._sampleSphere = this._generateHemisphere()
  124026. },
  124027. enumerable: !1,
  124028. configurable: !0
  124029. }),
  124030. Object.defineProperty(t.prototype, "textureSamples", {
  124031. get: function() {
  124032. return this._textureSamples
  124033. },
  124034. set: function(e) {
  124035. this._textureSamples = e,
  124036. this._prePassRenderer ? this._prePassRenderer.samples = e : this._originalColorPostProcess.samples = e
  124037. },
  124038. enumerable: !1,
  124039. configurable: !0
  124040. }),
  124041. Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
  124042. get: function() {
  124043. return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
  124044. },
  124045. enumerable: !1,
  124046. configurable: !0
  124047. }),
  124048. Object.defineProperty(t.prototype, "_prePassRenderer", {
  124049. get: function() {
  124050. return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
  124051. },
  124052. enumerable: !1,
  124053. configurable: !0
  124054. }),
  124055. Object.defineProperty(t.prototype, "expensiveBlur", {
  124056. get: function() {
  124057. return this._expensiveBlur
  124058. },
  124059. set: function(e) {
  124060. this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (e ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]),
  124061. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (e ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]),
  124062. this._expensiveBlur = e
  124063. },
  124064. enumerable: !1,
  124065. configurable: !0
  124066. }),
  124067. Object.defineProperty(t, "IsSupported", {
  124068. get: function() {
  124069. var e = E.LastCreatedEngine;
  124070. return !!e && e._features.supportSSAO2
  124071. },
  124072. enumerable: !1,
  124073. configurable: !0
  124074. }),
  124075. Object.defineProperty(t.prototype, "scene", {
  124076. get: function() {
  124077. return this._scene
  124078. },
  124079. enumerable: !1,
  124080. configurable: !0
  124081. }),
  124082. t.prototype.getClassName = function() {
  124083. return "SSAO2RenderingPipeline"
  124084. }
  124085. ,
  124086. t.prototype.dispose = function(t) {
  124087. void 0 === t && (t = !1);
  124088. for (var i = 0; i < this._scene.cameras.length; i++) {
  124089. var n = this._scene.cameras[i];
  124090. this._originalColorPostProcess.dispose(n),
  124091. this._ssaoPostProcess.dispose(n),
  124092. this._blurHPostProcess.dispose(n),
  124093. this._blurVPostProcess.dispose(n),
  124094. this._ssaoCombinePostProcess.dispose(n)
  124095. }
  124096. this._randomTexture.dispose(),
  124097. t && this._scene.disableGeometryBufferRenderer(),
  124098. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
  124099. e.prototype.dispose.call(this)
  124100. }
  124101. ,
  124102. t.prototype._createBlurPostProcess = function(e, t, i) {
  124103. var n = this;
  124104. this._samplerOffsets = [];
  124105. for (var r = this.expensiveBlur, o = -8; o < 8; o++)
  124106. this._samplerOffsets.push(2 * o + .5);
  124107. this._blurHPostProcess = new Ba("BlurH","ssao2",["outSize", "samplerOffsets", "near", "far", "radius"],["depthSampler"],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (r ? "1" : "0") + "\n",i),
  124108. this._blurHPostProcess.onApply = function(e) {
  124109. n._scene.activeCamera && (e.setFloat("outSize", n._ssaoCombinePostProcess.width > 0 ? n._ssaoCombinePostProcess.width : n._originalColorPostProcess.width),
  124110. e.setFloat("near", n._scene.activeCamera.minZ),
  124111. e.setFloat("far", n._scene.activeCamera.maxZ),
  124112. e.setFloat("radius", n.radius),
  124113. n._geometryBufferRenderer ? e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]) : n._prePassRenderer && e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
  124114. e.setArray("samplerOffsets", n._samplerOffsets))
  124115. }
  124116. ,
  124117. this._blurVPostProcess = new Ba("BlurV","ssao2",["outSize", "samplerOffsets", "near", "far", "radius"],["depthSampler"],t,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE " + (r ? "1" : "0") + "\n",i),
  124118. this._blurVPostProcess.onApply = function(e) {
  124119. n._scene.activeCamera && (e.setFloat("outSize", n._ssaoCombinePostProcess.height > 0 ? n._ssaoCombinePostProcess.height : n._originalColorPostProcess.height),
  124120. e.setFloat("near", n._scene.activeCamera.minZ),
  124121. e.setFloat("far", n._scene.activeCamera.maxZ),
  124122. e.setFloat("radius", n.radius),
  124123. n._geometryBufferRenderer ? e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]) : n._prePassRenderer && e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
  124124. e.setArray("samplerOffsets", n._samplerOffsets))
  124125. }
  124126. ,
  124127. this._blurHPostProcess.samples = this.textureSamples,
  124128. this._blurVPostProcess.samples = this.textureSamples
  124129. }
  124130. ,
  124131. t.prototype._rebuild = function() {
  124132. e.prototype._rebuild.call(this)
  124133. }
  124134. ,
  124135. t.prototype._radicalInverse_VdC = function(e) {
  124136. return this._bits[0] = e,
  124137. this._bits[0] = (this._bits[0] << 16 | this._bits[0] >> 16) >>> 0,
  124138. this._bits[0] = (1431655765 & this._bits[0]) << 1 | (2863311530 & this._bits[0]) >>> 1 >>> 0,
  124139. this._bits[0] = (858993459 & this._bits[0]) << 2 | (3435973836 & this._bits[0]) >>> 2 >>> 0,
  124140. this._bits[0] = (252645135 & this._bits[0]) << 4 | (4042322160 & this._bits[0]) >>> 4 >>> 0,
  124141. this._bits[0] = (16711935 & this._bits[0]) << 8 | (4278255360 & this._bits[0]) >>> 8 >>> 0,
  124142. 2.3283064365386963e-10 * this._bits[0]
  124143. }
  124144. ,
  124145. t.prototype._hammersley = function(e, t) {
  124146. return [e / t, this._radicalInverse_VdC(e)]
  124147. }
  124148. ,
  124149. t.prototype._hemisphereSample_uniform = function(e, t) {
  124150. var i = 2 * t * Math.PI
  124151. , n = 1 - (.85 * e + .15)
  124152. , r = Math.sqrt(1 - n * n);
  124153. return new x(Math.cos(i) * r,Math.sin(i) * r,n)
  124154. }
  124155. ,
  124156. t.prototype._generateHemisphere = function() {
  124157. for (var e, t = this.samples, i = [], n = 0; n < t; ) {
  124158. if (t < 16)
  124159. e = this._hemisphereSample_uniform(Math.random(), Math.random());
  124160. else {
  124161. var r = this._hammersley(n, t);
  124162. e = this._hemisphereSample_uniform(r[0], r[1])
  124163. }
  124164. i.push(e.x, e.y, e.z),
  124165. n++
  124166. }
  124167. return i
  124168. }
  124169. ,
  124170. t.prototype._getDefinesForSSAO = function() {
  124171. return "#define SAMPLES " + this.samples + "\n#define SSAO"
  124172. }
  124173. ,
  124174. t.prototype._createSSAOPostProcess = function(e, i) {
  124175. var n = this;
  124176. this._sampleSphere = this._generateHemisphere();
  124177. var r = this._getDefinesForSSAO();
  124178. this._ssaoPostProcess = new Ba("ssao2","ssao2",["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "base", "range", "projection", "near", "far", "texelSize", "xViewport", "yViewport", "maxZ", "minZAspect", "depthProjection"],["randomSampler", "depthSampler", "normalSampler"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r,i),
  124179. this._ssaoPostProcess.onApply = function(e) {
  124180. var i, r, o, s;
  124181. if (n._scene.activeCamera) {
  124182. if (e.setArray3("sampleSphere", n._sampleSphere),
  124183. e.setFloat("randTextureTiles", 32),
  124184. e.setFloat("samplesFactor", 1 / n.samples),
  124185. e.setFloat("totalStrength", n.totalStrength),
  124186. e.setFloat2("texelSize", 1 / n._ssaoPostProcess.width, 1 / n._ssaoPostProcess.height),
  124187. e.setFloat("radius", n.radius),
  124188. e.setFloat("maxZ", n.maxZ),
  124189. e.setFloat("minZAspect", n.minZAspect),
  124190. e.setFloat("base", n.base),
  124191. e.setFloat("near", n._scene.activeCamera.minZ),
  124192. e.setFloat("far", n._scene.activeCamera.maxZ),
  124193. n._scene.activeCamera.mode === Rr.PERSPECTIVE_CAMERA)
  124194. e.setMatrix3x3("depthProjection", t.PERSPECTIVE_DEPTH_PROJECTION),
  124195. e.setFloat("xViewport", Math.tan(n._scene.activeCamera.fov / 2) * n._scene.getEngine().getAspectRatio(n._scene.activeCamera, !0)),
  124196. e.setFloat("yViewport", Math.tan(n._scene.activeCamera.fov / 2));
  124197. else {
  124198. var l = n._scene.getEngine().getRenderWidth() / 2
  124199. , c = n._scene.getEngine().getRenderHeight() / 2
  124200. , u = null !== (i = n._scene.activeCamera.orthoLeft) && void 0 !== i ? i : -l
  124201. , h = null !== (r = n._scene.activeCamera.orthoRight) && void 0 !== r ? r : l
  124202. , d = null !== (o = n._scene.activeCamera.orthoBottom) && void 0 !== o ? o : -c
  124203. , p = null !== (s = n._scene.activeCamera.orthoTop) && void 0 !== s ? s : c;
  124204. e.setMatrix3x3("depthProjection", t.ORTHO_DEPTH_PROJECTION),
  124205. e.setFloat("xViewport", .5 * (h - u)),
  124206. e.setFloat("yViewport", .5 * (p - d))
  124207. }
  124208. e.setMatrix("projection", n._scene.getProjectionMatrix()),
  124209. n._geometryBufferRenderer ? (e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]),
  124210. e.setTexture("normalSampler", n._geometryBufferRenderer.getGBuffer().textures[1])) : n._prePassRenderer && (e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
  124211. e.setTexture("normalSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE)])),
  124212. e.setTexture("randomSampler", n._randomTexture)
  124213. }
  124214. }
  124215. ,
  124216. this._ssaoPostProcess.samples = this.textureSamples
  124217. }
  124218. ,
  124219. t.prototype._createSSAOCombinePostProcess = function(e, t) {
  124220. var i = this;
  124221. this._ssaoCombinePostProcess = new Ba("ssaoCombine","ssaoCombine",[],["originalColor", "viewport"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,void 0,t),
  124222. this._ssaoCombinePostProcess.onApply = function(e) {
  124223. var t = i._scene.activeCamera.viewport;
  124224. e.setVector4("viewport", I.Vector4[0].copyFromFloats(t.x, t.y, t.width, t.height)),
  124225. e.setTextureFromPostProcessOutput("originalColor", i._originalColorPostProcess)
  124226. }
  124227. ,
  124228. this._ssaoCombinePostProcess.samples = this.textureSamples,
  124229. this._forceGeometryBuffer || (this._ssaoCombinePostProcess._prePassEffectConfiguration = new fb)
  124230. }
  124231. ,
  124232. t.prototype._createRandomTexture = function() {
  124233. this._randomTexture = new Ds("SSAORandomTexture",128,this._scene,!1,io.TRILINEAR_SAMPLINGMODE),
  124234. this._randomTexture.wrapU = io.WRAP_ADDRESSMODE,
  124235. this._randomTexture.wrapV = io.WRAP_ADDRESSMODE;
  124236. for (var e = this._randomTexture.getContext(), t = function(e, t) {
  124237. return Math.random() * (t - e) + e
  124238. }, i = x.Zero(), n = 0; n < 128; n++)
  124239. for (var r = 0; r < 128; r++)
  124240. i.x = t(0, 1),
  124241. i.y = t(0, 1),
  124242. i.z = 0,
  124243. i.normalize(),
  124244. i.scaleInPlace(255),
  124245. i.x = Math.floor(i.x),
  124246. i.y = Math.floor(i.y),
  124247. e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")",
  124248. e.fillRect(n, r, 1, 1);
  124249. this._randomTexture.update(!1)
  124250. }
  124251. ,
  124252. t.prototype.serialize = function() {
  124253. var e = Ge.Serialize(this);
  124254. return e.customType = "SSAO2RenderingPipeline",
  124255. e
  124256. }
  124257. ,
  124258. t.Parse = function(e, i, n) {
  124259. return Ge.Parse((function() {
  124260. return new t(e._name,i,e._ratio)
  124261. }
  124262. ), e, i, n)
  124263. }
  124264. ,
  124265. t.ORTHO_DEPTH_PROJECTION = [1, 0, 0, 0, 1, 0, 0, 0, 1],
  124266. t.PERSPECTIVE_DEPTH_PROJECTION = [0, 0, 0, 0, 0, 0, 1, 1, 1],
  124267. k([Ce()], t.prototype, "totalStrength", void 0),
  124268. k([Ce()], t.prototype, "maxZ", void 0),
  124269. k([Ce()], t.prototype, "minZAspect", void 0),
  124270. k([Ce("samples")], t.prototype, "_samples", void 0),
  124271. k([Ce("textureSamples")], t.prototype, "_textureSamples", void 0),
  124272. k([Ce()], t.prototype, "_ratio", void 0),
  124273. k([Ce("expensiveBlur")], t.prototype, "_expensiveBlur", void 0),
  124274. k([Ce()], t.prototype, "radius", void 0),
  124275. k([Ce()], t.prototype, "base", void 0),
  124276. t
  124277. }(cb);
  124278. y("BABYLON.SSAO2RenderingPipeline", _b);
  124279. Pt.ShadersStore.ssaoPixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n";
  124280. var mb = function(e) {
  124281. function t(t, i, n, r) {
  124282. var o = e.call(this, i.getEngine(), t) || this;
  124283. o.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect",
  124284. o.SSAORenderEffect = "SSAORenderEffect",
  124285. o.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect",
  124286. o.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect",
  124287. o.SSAOCombineRenderEffect = "SSAOCombineRenderEffect",
  124288. o.totalStrength = 1,
  124289. o.radius = 1e-4,
  124290. o.area = .0075,
  124291. o.fallOff = 1e-6,
  124292. o.base = .5,
  124293. o._firstUpdate = !0,
  124294. o._scene = i,
  124295. o._createRandomTexture(),
  124296. o._depthTexture = i.enableDepthRenderer().getDepthMap();
  124297. var a = n.ssaoRatio || n
  124298. , s = n.combineRatio || n;
  124299. return o._originalColorPostProcess = new Ua("SSAOOriginalSceneColor",s,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),
  124300. o._createSSAOPostProcess(a),
  124301. o._createBlurPostProcess(a),
  124302. o._createSSAOCombinePostProcess(s),
  124303. o.addEffect(new Vy(i.getEngine(),o.SSAOOriginalSceneColorEffect,(function() {
  124304. return o._originalColorPostProcess
  124305. }
  124306. ),!0)),
  124307. o.addEffect(new Vy(i.getEngine(),o.SSAORenderEffect,(function() {
  124308. return o._ssaoPostProcess
  124309. }
  124310. ),!0)),
  124311. o.addEffect(new Vy(i.getEngine(),o.SSAOBlurHRenderEffect,(function() {
  124312. return o._blurHPostProcess
  124313. }
  124314. ),!0)),
  124315. o.addEffect(new Vy(i.getEngine(),o.SSAOBlurVRenderEffect,(function() {
  124316. return o._blurVPostProcess
  124317. }
  124318. ),!0)),
  124319. o.addEffect(new Vy(i.getEngine(),o.SSAOCombineRenderEffect,(function() {
  124320. return o._ssaoCombinePostProcess
  124321. }
  124322. ),!0)),
  124323. i.postProcessRenderPipelineManager.addPipeline(o),
  124324. r && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, r),
  124325. o
  124326. }
  124327. return U(t, e),
  124328. Object.defineProperty(t.prototype, "scene", {
  124329. get: function() {
  124330. return this._scene
  124331. },
  124332. enumerable: !1,
  124333. configurable: !0
  124334. }),
  124335. t.prototype.getClassName = function() {
  124336. return "SSAORenderingPipeline"
  124337. }
  124338. ,
  124339. t.prototype.dispose = function(t) {
  124340. void 0 === t && (t = !1);
  124341. for (var i = 0; i < this._scene.cameras.length; i++) {
  124342. var n = this._scene.cameras[i];
  124343. this._originalColorPostProcess.dispose(n),
  124344. this._ssaoPostProcess.dispose(n),
  124345. this._blurHPostProcess.dispose(n),
  124346. this._blurVPostProcess.dispose(n),
  124347. this._ssaoCombinePostProcess.dispose(n)
  124348. }
  124349. this._randomTexture.dispose(),
  124350. t && this._scene.disableDepthRenderer(),
  124351. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
  124352. e.prototype.dispose.call(this)
  124353. }
  124354. ,
  124355. t.prototype._createBlurPostProcess = function(e) {
  124356. var t = this;
  124357. this._blurHPostProcess = new Fd("BlurH",new A(1,0),16,e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
  124358. this._blurVPostProcess = new Fd("BlurV",new A(0,1),16,e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
  124359. this._blurHPostProcess.onActivateObservable.add((function() {
  124360. var e = t._blurHPostProcess.width / t._scene.getEngine().getRenderWidth();
  124361. t._blurHPostProcess.kernel = 16 * e
  124362. }
  124363. )),
  124364. this._blurVPostProcess.onActivateObservable.add((function() {
  124365. var e = t._blurVPostProcess.height / t._scene.getEngine().getRenderHeight();
  124366. t._blurVPostProcess.kernel = 16 * e
  124367. }
  124368. ))
  124369. }
  124370. ,
  124371. t.prototype._rebuild = function() {
  124372. this._firstUpdate = !0,
  124373. e.prototype._rebuild.call(this)
  124374. }
  124375. ,
  124376. t.prototype._createSSAOPostProcess = function(e) {
  124377. var t = this
  124378. , i = [.5381, .1856, -.4319, .1379, .2486, .443, .3371, .5679, -.0057, -.6999, -.0451, -.0019, .0689, -.1598, -.8547, .056, .0069, -.1843, -.0146, .1402, .0762, .01, -.1924, -.0344, -.3577, -.5301, -.4358, -.3169, .1063, .0158, .0103, -.5869, .0046, -.0897, -.494, .3287, .7119, -.0154, -.0918, -.0533, .0596, -.5411, .0352, -.0631, .546, -.4776, .2847, -.0271];
  124379. this._ssaoPostProcess = new Ba("ssao","ssao",["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "area", "fallOff", "base", "range", "viewport"],["randomSampler"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES 16\n#define SSAO"),
  124380. this._ssaoPostProcess.externalTextureSamplerBinding = !0,
  124381. this._ssaoPostProcess.onApply = function(e) {
  124382. t._firstUpdate && (e.setArray3("sampleSphere", i),
  124383. e.setFloat("samplesFactor", .0625),
  124384. e.setFloat("randTextureTiles", 4)),
  124385. e.setFloat("totalStrength", t.totalStrength),
  124386. e.setFloat("radius", t.radius),
  124387. e.setFloat("area", t.area),
  124388. e.setFloat("fallOff", t.fallOff),
  124389. e.setFloat("base", t.base),
  124390. e.setTexture("textureSampler", t._depthTexture),
  124391. e.setTexture("randomSampler", t._randomTexture)
  124392. }
  124393. }
  124394. ,
  124395. t.prototype._createSSAOCombinePostProcess = function(e) {
  124396. var t = this;
  124397. this._ssaoCombinePostProcess = new Ba("ssaoCombine","ssaoCombine",[],["originalColor", "viewport"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
  124398. this._ssaoCombinePostProcess.onApply = function(e) {
  124399. e.setVector4("viewport", I.Vector4[0].copyFromFloats(0, 0, 1, 1)),
  124400. e.setTextureFromPostProcess("originalColor", t._originalColorPostProcess)
  124401. }
  124402. }
  124403. ,
  124404. t.prototype._createRandomTexture = function() {
  124405. this._randomTexture = new Ds("SSAORandomTexture",512,this._scene,!1,io.TRILINEAR_SAMPLINGMODE),
  124406. this._randomTexture.wrapU = io.WRAP_ADDRESSMODE,
  124407. this._randomTexture.wrapV = io.WRAP_ADDRESSMODE;
  124408. for (var e = this._randomTexture.getContext(), t = function(e, t) {
  124409. return Math.random() * (t - e) + e
  124410. }, i = x.Zero(), n = 0; n < 512; n++)
  124411. for (var r = 0; r < 512; r++)
  124412. i.x = Math.floor(255 * t(-1, 1)),
  124413. i.y = Math.floor(255 * t(-1, 1)),
  124414. i.z = Math.floor(255 * t(-1, 1)),
  124415. e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")",
  124416. e.fillRect(n, r, 1, 1);
  124417. this._randomTexture.update(!1)
  124418. }
  124419. ,
  124420. k([Ce()], t.prototype, "totalStrength", void 0),
  124421. k([Ce()], t.prototype, "radius", void 0),
  124422. k([Ce()], t.prototype, "area", void 0),
  124423. k([Ce()], t.prototype, "fallOff", void 0),
  124424. k([Ce()], t.prototype, "base", void 0),
  124425. t
  124426. }(cb)
  124427. , gb = function() {
  124428. this.enabled = !1,
  124429. this.name = "screenSpaceReflections",
  124430. this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, a.PREPASS_POSITION_TEXTURE_TYPE]
  124431. };
  124432. Pt.ShadersStore.screenSpaceReflectionPixelShader = "uniform sampler2D textureSampler;\n#ifdef SSR_SUPPORTED\nuniform sampler2D reflectivitySampler;\nuniform sampler2D normalSampler;\nuniform sampler2D positionSampler;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform float stepSize;\nuniform float strength;\nuniform float threshold;\nuniform float roughnessFactor;\nuniform float reflectionSpecularFalloffExponent;\nvarying vec2 vUV;\n#ifdef SSR_SUPPORTED\nstruct ReflectionInfo {\nvec3 color;\nvec4 coords;\n};\n/**\n* According to specular,see https:\n*/\nvec3 fresnelSchlick(float cosTheta,vec3 F0)\n{\nreturn F0+(1.0-F0)*pow(1.0-cosTheta,5.0);\n}\n/**\n* Once the pixel's coordinates has been found,let's adjust (smooth) a little bit\n* by sampling multiple reflection pixels.\n*/\nReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\ninfo.color=vec3(0.0);\nvec4 projectedCoord;\nfloat sampledDepth;\nfor(int i=0; i<SMOOTH_STEPS; i++)\n{\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\ndir*=0.5;\nif(depth>0.0)\nhitCoord-=dir;\nelse\nhitCoord+=dir;\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\n}\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,1.0);\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.color/=float(SMOOTH_STEPS+1);\nreturn info;\n}\n/**\n* Tests the given world position (hitCoord) according to the given reflection vector (dir)\n* until it finds a collision (means that depth is enough close to say \"it's the pixel to sample!\").\n*/\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\nvec4 projectedCoord;\nfloat sampledDepth;\ndir*=stepSize;\nfor(int i=0; i<REFLECTION_SAMPLES; i++)\n{\nhitCoord+=dir;\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\n#ifdef RIGHT_HANDED_SCENE\ndepth*=-1.0;\n#endif\nif(((depth-dir.z)<threshold) && depth<=0.0)\n{\n#ifdef ENABLE_SMOOTH_REFLECTIONS\nreturn smoothReflectionInfo(dir,hitCoord);\n#else\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n#endif\n}\n}\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n}\nvec3 hash(vec3 a)\n{\na=fract(a*0.8);\na+=dot(a,a.yxz+19.19);\nreturn fract((a.xxy+a.yxx)*a.zyx);\n}\n#endif\nvoid main()\n{\n#ifdef SSR_SUPPORTED\nvec4 albedoFull=texture2D(textureSampler,vUV);\nvec3 albedo=albedoFull.rgb;\nfloat spec=texture2D(reflectivitySampler,vUV).r;\nif (spec==0.0) {\ngl_FragColor=albedoFull;\nreturn;\n}\nvec3 normal=(texture2D(normalSampler,vUV)).xyz;\nvec3 position=(view*texture2D(positionSampler,vUV)).xyz;\nvec3 reflected=normalize(reflect(normalize(position),normalize(normal)));\nfloat roughness=1.0-texture2D(reflectivitySampler,vUV).a;\nvec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;\nReflectionInfo info=getReflectionInfo(jitt+reflected,position);\nvec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));\nfloat screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);\nvec3 F0=vec3(0.04);\nF0 =mix(F0,albedo,spec);\nvec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0),F0);\n#ifdef RIGHT_HANDED_SCENE\nreflected.z*=-1.0;\n#endif\nfloat reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);\nfloat albedoMultiplier=1.0-reflectionMultiplier;\nvec3 SSR=info.color*fresnel;\ngl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  124433. var vb = function(e) {
  124434. function t(t, i, n, r, o, s, l, c, u, h) {
  124435. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  124436. void 0 === u && (u = !1),
  124437. void 0 === h && (h = !1);
  124438. var d = e.call(this, t, "screenSpaceReflection", ["projection", "view", "threshold", "reflectionSpecularFalloffExponent", "strength", "stepSize", "roughnessFactor"], ["textureSampler", "normalSampler", "positionSampler", "reflectivitySampler"], n, r, o, s, l, "#define SSR_SUPPORTED\n#define REFLECTION_SAMPLES 64\n#define SMOOTH_STEPS 5\n", c, void 0, null, u) || this;
  124439. if (d.threshold = 1.2,
  124440. d.strength = 1,
  124441. d.reflectionSpecularFalloffExponent = 3,
  124442. d.step = 1,
  124443. d.roughnessFactor = .2,
  124444. d._forceGeometryBuffer = !1,
  124445. d._enableSmoothReflections = !1,
  124446. d._reflectionSamples = 64,
  124447. d._smoothSteps = 5,
  124448. d._forceGeometryBuffer = h,
  124449. d._forceGeometryBuffer) {
  124450. var p = i.enableGeometryBufferRenderer();
  124451. p && p.isSupported && (p.enablePosition = !0,
  124452. p.enableReflectivity = !0)
  124453. } else {
  124454. var f = i.enablePrePassRenderer();
  124455. null == f || f.markAsDirty(),
  124456. d._prePassEffectConfiguration = new gb
  124457. }
  124458. return d._updateEffectDefines(),
  124459. d.onApply = function(e) {
  124460. var t = d._geometryBufferRenderer
  124461. , n = d._prePassRenderer;
  124462. if (n || t) {
  124463. if (t) {
  124464. var r = t.getTextureIndex(nb.POSITION_TEXTURE_TYPE)
  124465. , o = t.getTextureIndex(nb.REFLECTIVITY_TEXTURE_TYPE);
  124466. e.setTexture("normalSampler", t.getGBuffer().textures[1]),
  124467. e.setTexture("positionSampler", t.getGBuffer().textures[r]),
  124468. e.setTexture("reflectivitySampler", t.getGBuffer().textures[o])
  124469. } else if (n) {
  124470. r = n.getIndex(a.PREPASS_POSITION_TEXTURE_TYPE),
  124471. o = n.getIndex(a.PREPASS_REFLECTIVITY_TEXTURE_TYPE);
  124472. var s = n.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE);
  124473. e.setTexture("normalSampler", n.getRenderTarget().textures[s]),
  124474. e.setTexture("positionSampler", n.getRenderTarget().textures[r]),
  124475. e.setTexture("reflectivitySampler", n.getRenderTarget().textures[o])
  124476. }
  124477. var l = i.activeCamera;
  124478. if (l) {
  124479. var c = l.getViewMatrix(!0)
  124480. , u = l.getProjectionMatrix(!0);
  124481. e.setMatrix("projection", u),
  124482. e.setMatrix("view", c),
  124483. e.setFloat("threshold", d.threshold),
  124484. e.setFloat("reflectionSpecularFalloffExponent", d.reflectionSpecularFalloffExponent),
  124485. e.setFloat("strength", d.strength),
  124486. e.setFloat("stepSize", d.step),
  124487. e.setFloat("roughnessFactor", d.roughnessFactor)
  124488. }
  124489. }
  124490. }
  124491. ,
  124492. d._isSceneRightHanded = i.useRightHandedSystem,
  124493. d
  124494. }
  124495. return U(t, e),
  124496. Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
  124497. get: function() {
  124498. return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
  124499. },
  124500. enumerable: !1,
  124501. configurable: !0
  124502. }),
  124503. Object.defineProperty(t.prototype, "_prePassRenderer", {
  124504. get: function() {
  124505. return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
  124506. },
  124507. enumerable: !1,
  124508. configurable: !0
  124509. }),
  124510. t.prototype.getClassName = function() {
  124511. return "ScreenSpaceReflectionPostProcess"
  124512. }
  124513. ,
  124514. Object.defineProperty(t.prototype, "enableSmoothReflections", {
  124515. get: function() {
  124516. return this._enableSmoothReflections
  124517. },
  124518. set: function(e) {
  124519. e !== this._enableSmoothReflections && (this._enableSmoothReflections = e,
  124520. this._updateEffectDefines())
  124521. },
  124522. enumerable: !1,
  124523. configurable: !0
  124524. }),
  124525. Object.defineProperty(t.prototype, "reflectionSamples", {
  124526. get: function() {
  124527. return this._reflectionSamples
  124528. },
  124529. set: function(e) {
  124530. e !== this._reflectionSamples && (this._reflectionSamples = e,
  124531. this._updateEffectDefines())
  124532. },
  124533. enumerable: !1,
  124534. configurable: !0
  124535. }),
  124536. Object.defineProperty(t.prototype, "smoothSteps", {
  124537. get: function() {
  124538. return this._smoothSteps
  124539. },
  124540. set: function(e) {
  124541. e !== this._smoothSteps && (this._smoothSteps = e,
  124542. this._updateEffectDefines())
  124543. },
  124544. enumerable: !1,
  124545. configurable: !0
  124546. }),
  124547. t.prototype._updateEffectDefines = function() {
  124548. var e = [];
  124549. (this._geometryBufferRenderer || this._prePassRenderer) && e.push("#define SSR_SUPPORTED"),
  124550. this._enableSmoothReflections && e.push("#define ENABLE_SMOOTH_REFLECTIONS"),
  124551. this._isSceneRightHanded && e.push("#define RIGHT_HANDED_SCENE"),
  124552. e.push("#define REFLECTION_SAMPLES " + (this._reflectionSamples >> 0)),
  124553. e.push("#define SMOOTH_STEPS " + (this._smoothSteps >> 0)),
  124554. this.updateEffect(e.join("\n"))
  124555. }
  124556. ,
  124557. t._Parse = function(e, i, n, r) {
  124558. return Ge.Parse((function() {
  124559. return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
  124560. }
  124561. ), e, n, r)
  124562. }
  124563. ,
  124564. k([Ce()], t.prototype, "threshold", void 0),
  124565. k([Ce()], t.prototype, "strength", void 0),
  124566. k([Ce()], t.prototype, "reflectionSpecularFalloffExponent", void 0),
  124567. k([Ce()], t.prototype, "step", void 0),
  124568. k([Ce()], t.prototype, "roughnessFactor", void 0),
  124569. k([Ce()], t.prototype, "enableSmoothReflections", null),
  124570. k([Ce()], t.prototype, "reflectionSamples", null),
  124571. k([Ce()], t.prototype, "smoothSteps", null),
  124572. t
  124573. }(Ba);
  124574. y("BABYLON.ScreenSpaceReflectionPostProcess", vb);
  124575. Pt.ShadersStore.standardPixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric= (worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\n#include<packingFunctions>\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV/*lensFlareCoords*/);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
  124576. var yb = function(e) {
  124577. function t(t, i, n, r, o) {
  124578. void 0 === r && (r = null);
  124579. var s = e.call(this, i.getEngine(), t) || this;
  124580. return s.downSampleX4PostProcess = null,
  124581. s.brightPassPostProcess = null,
  124582. s.blurHPostProcesses = [],
  124583. s.blurVPostProcesses = [],
  124584. s.textureAdderPostProcess = null,
  124585. s.volumetricLightPostProcess = null,
  124586. s.volumetricLightSmoothXPostProcess = null,
  124587. s.volumetricLightSmoothYPostProcess = null,
  124588. s.volumetricLightMergePostProces = null,
  124589. s.volumetricLightFinalPostProcess = null,
  124590. s.luminancePostProcess = null,
  124591. s.luminanceDownSamplePostProcesses = [],
  124592. s.hdrPostProcess = null,
  124593. s.textureAdderFinalPostProcess = null,
  124594. s.lensFlareFinalPostProcess = null,
  124595. s.hdrFinalPostProcess = null,
  124596. s.lensFlarePostProcess = null,
  124597. s.lensFlareComposePostProcess = null,
  124598. s.motionBlurPostProcess = null,
  124599. s.depthOfFieldPostProcess = null,
  124600. s.fxaaPostProcess = null,
  124601. s.screenSpaceReflectionPostProcess = null,
  124602. s.brightThreshold = 1,
  124603. s.blurWidth = 512,
  124604. s.horizontalBlur = !1,
  124605. s.lensTexture = null,
  124606. s.volumetricLightCoefficient = .2,
  124607. s.volumetricLightPower = 4,
  124608. s.volumetricLightBlurScale = 64,
  124609. s.sourceLight = null,
  124610. s.hdrMinimumLuminance = 1,
  124611. s.hdrDecreaseRate = .5,
  124612. s.hdrIncreaseRate = .5,
  124613. s.lensColorTexture = null,
  124614. s.lensFlareStrength = 20,
  124615. s.lensFlareGhostDispersal = 1.4,
  124616. s.lensFlareHaloWidth = .7,
  124617. s.lensFlareDistortionStrength = 16,
  124618. s.lensFlareBlurWidth = 512,
  124619. s.lensStarTexture = null,
  124620. s.lensFlareDirtTexture = null,
  124621. s.depthOfFieldDistance = 10,
  124622. s.depthOfFieldBlurWidth = 64,
  124623. s.animations = [],
  124624. s._currentDepthOfFieldSource = null,
  124625. s._fixedExposure = 1,
  124626. s._currentExposure = 1,
  124627. s._hdrAutoExposure = !1,
  124628. s._hdrCurrentLuminance = 1,
  124629. s._motionStrength = 1,
  124630. s._isObjectBasedMotionBlur = !1,
  124631. s._camerasToBeAttached = [],
  124632. s._bloomEnabled = !1,
  124633. s._depthOfFieldEnabled = !1,
  124634. s._vlsEnabled = !1,
  124635. s._lensFlareEnabled = !1,
  124636. s._hdrEnabled = !1,
  124637. s._motionBlurEnabled = !1,
  124638. s._fxaaEnabled = !1,
  124639. s._screenSpaceReflectionsEnabled = !1,
  124640. s._motionBlurSamples = 64,
  124641. s._volumetricLightStepsCount = 50,
  124642. s._samples = 1,
  124643. s._cameras = o || i.cameras,
  124644. s._cameras = s._cameras.slice(),
  124645. s._camerasToBeAttached = s._cameras.slice(),
  124646. s._scene = i,
  124647. s._basePostProcess = r,
  124648. s._ratio = n,
  124649. s._floatTextureType = i.getEngine().getCaps().textureFloatRender ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT,
  124650. i.postProcessRenderPipelineManager.addPipeline(s),
  124651. s._buildPipeline(),
  124652. s
  124653. }
  124654. return U(t, e),
  124655. Object.defineProperty(t.prototype, "exposure", {
  124656. get: function() {
  124657. return this._fixedExposure
  124658. },
  124659. set: function(e) {
  124660. this._fixedExposure = e,
  124661. this._currentExposure = e
  124662. },
  124663. enumerable: !1,
  124664. configurable: !0
  124665. }),
  124666. Object.defineProperty(t.prototype, "hdrAutoExposure", {
  124667. get: function() {
  124668. return this._hdrAutoExposure
  124669. },
  124670. set: function(e) {
  124671. if (this._hdrAutoExposure = e,
  124672. this.hdrPostProcess) {
  124673. var t = ["#define HDR"];
  124674. e && t.push("#define AUTO_EXPOSURE"),
  124675. this.hdrPostProcess.updateEffect(t.join("\n"))
  124676. }
  124677. },
  124678. enumerable: !1,
  124679. configurable: !0
  124680. }),
  124681. Object.defineProperty(t.prototype, "motionStrength", {
  124682. get: function() {
  124683. return this._motionStrength
  124684. },
  124685. set: function(e) {
  124686. this._motionStrength = e,
  124687. this._isObjectBasedMotionBlur && this.motionBlurPostProcess && (this.motionBlurPostProcess.motionStrength = e)
  124688. },
  124689. enumerable: !1,
  124690. configurable: !0
  124691. }),
  124692. Object.defineProperty(t.prototype, "objectBasedMotionBlur", {
  124693. get: function() {
  124694. return this._isObjectBasedMotionBlur
  124695. },
  124696. set: function(e) {
  124697. var t = this._isObjectBasedMotionBlur !== e;
  124698. this._isObjectBasedMotionBlur = e,
  124699. t && this._buildPipeline()
  124700. },
  124701. enumerable: !1,
  124702. configurable: !0
  124703. }),
  124704. Object.defineProperty(t.prototype, "BloomEnabled", {
  124705. get: function() {
  124706. return this._bloomEnabled
  124707. },
  124708. set: function(e) {
  124709. this._bloomEnabled !== e && (this._bloomEnabled = e,
  124710. this._buildPipeline())
  124711. },
  124712. enumerable: !1,
  124713. configurable: !0
  124714. }),
  124715. Object.defineProperty(t.prototype, "DepthOfFieldEnabled", {
  124716. get: function() {
  124717. return this._depthOfFieldEnabled
  124718. },
  124719. set: function(e) {
  124720. this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e,
  124721. this._buildPipeline())
  124722. },
  124723. enumerable: !1,
  124724. configurable: !0
  124725. }),
  124726. Object.defineProperty(t.prototype, "LensFlareEnabled", {
  124727. get: function() {
  124728. return this._lensFlareEnabled
  124729. },
  124730. set: function(e) {
  124731. this._lensFlareEnabled !== e && (this._lensFlareEnabled = e,
  124732. this._buildPipeline())
  124733. },
  124734. enumerable: !1,
  124735. configurable: !0
  124736. }),
  124737. Object.defineProperty(t.prototype, "HDREnabled", {
  124738. get: function() {
  124739. return this._hdrEnabled
  124740. },
  124741. set: function(e) {
  124742. this._hdrEnabled !== e && (this._hdrEnabled = e,
  124743. this._buildPipeline())
  124744. },
  124745. enumerable: !1,
  124746. configurable: !0
  124747. }),
  124748. Object.defineProperty(t.prototype, "VLSEnabled", {
  124749. get: function() {
  124750. return this._vlsEnabled
  124751. },
  124752. set: function(e) {
  124753. if (this._vlsEnabled !== e) {
  124754. if (e && !this._scene.enableGeometryBufferRenderer())
  124755. return void K.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  124756. this._vlsEnabled = e,
  124757. this._buildPipeline()
  124758. }
  124759. },
  124760. enumerable: !1,
  124761. configurable: !0
  124762. }),
  124763. Object.defineProperty(t.prototype, "MotionBlurEnabled", {
  124764. get: function() {
  124765. return this._motionBlurEnabled
  124766. },
  124767. set: function(e) {
  124768. this._motionBlurEnabled !== e && (this._motionBlurEnabled = e,
  124769. this._buildPipeline())
  124770. },
  124771. enumerable: !1,
  124772. configurable: !0
  124773. }),
  124774. Object.defineProperty(t.prototype, "fxaaEnabled", {
  124775. get: function() {
  124776. return this._fxaaEnabled
  124777. },
  124778. set: function(e) {
  124779. this._fxaaEnabled !== e && (this._fxaaEnabled = e,
  124780. this._buildPipeline())
  124781. },
  124782. enumerable: !1,
  124783. configurable: !0
  124784. }),
  124785. Object.defineProperty(t.prototype, "screenSpaceReflectionsEnabled", {
  124786. get: function() {
  124787. return this._screenSpaceReflectionsEnabled
  124788. },
  124789. set: function(e) {
  124790. this._screenSpaceReflectionsEnabled !== e && (this._screenSpaceReflectionsEnabled = e,
  124791. this._buildPipeline())
  124792. },
  124793. enumerable: !1,
  124794. configurable: !0
  124795. }),
  124796. Object.defineProperty(t.prototype, "volumetricLightStepsCount", {
  124797. get: function() {
  124798. return this._volumetricLightStepsCount
  124799. },
  124800. set: function(e) {
  124801. this.volumetricLightPostProcess && this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + e.toFixed(1)),
  124802. this._volumetricLightStepsCount = e
  124803. },
  124804. enumerable: !1,
  124805. configurable: !0
  124806. }),
  124807. Object.defineProperty(t.prototype, "motionBlurSamples", {
  124808. get: function() {
  124809. return this._motionBlurSamples
  124810. },
  124811. set: function(e) {
  124812. this.motionBlurPostProcess && (this._isObjectBasedMotionBlur ? this.motionBlurPostProcess.motionBlurSamples = e : this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + e.toFixed(1))),
  124813. this._motionBlurSamples = e
  124814. },
  124815. enumerable: !1,
  124816. configurable: !0
  124817. }),
  124818. Object.defineProperty(t.prototype, "samples", {
  124819. get: function() {
  124820. return this._samples
  124821. },
  124822. set: function(e) {
  124823. this._samples !== e && (this._samples = e,
  124824. this._buildPipeline())
  124825. },
  124826. enumerable: !1,
  124827. configurable: !0
  124828. }),
  124829. t.prototype._buildPipeline = function() {
  124830. var e = this
  124831. , t = this._ratio
  124832. , i = this._scene;
  124833. this._disposePostProcesses(),
  124834. null !== this._cameras && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  124835. this._cameras = this._camerasToBeAttached.slice()),
  124836. this._reset(),
  124837. this._screenSpaceReflectionsEnabled && (this.screenSpaceReflectionPostProcess = new vb("HDRPass",i,t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),
  124838. this.screenSpaceReflectionPostProcess.onApplyObservable.add((function() {
  124839. e._currentDepthOfFieldSource = e.screenSpaceReflectionPostProcess
  124840. }
  124841. )),
  124842. this.addEffect(new Vy(i.getEngine(),"HDRScreenSpaceReflections",(function() {
  124843. return e.screenSpaceReflectionPostProcess
  124844. }
  124845. ),!0))),
  124846. this._basePostProcess ? this.originalPostProcess = this._basePostProcess : this.originalPostProcess = new Ba("HDRPass","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),
  124847. this.originalPostProcess.autoClear = !this.screenSpaceReflectionPostProcess,
  124848. this.originalPostProcess.onApplyObservable.add((function() {
  124849. e._currentDepthOfFieldSource = e.originalPostProcess
  124850. }
  124851. )),
  124852. this.addEffect(new Vy(i.getEngine(),"HDRPassPostProcess",(function() {
  124853. return e.originalPostProcess
  124854. }
  124855. ),!0)),
  124856. this._bloomEnabled && (this._createDownSampleX4PostProcess(i, t / 4),
  124857. this._createBrightPassPostProcess(i, t / 4),
  124858. this._createBlurPostProcesses(i, t / 4, 1),
  124859. this._createTextureAdderPostProcess(i, t),
  124860. this.textureAdderFinalPostProcess = new Ba("HDRDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
  124861. this.addEffect(new Vy(i.getEngine(),"HDRBaseDepthOfFieldSource",(function() {
  124862. return e.textureAdderFinalPostProcess
  124863. }
  124864. ),!0))),
  124865. this._vlsEnabled && (this._createVolumetricLightPostProcess(i, t),
  124866. this.volumetricLightFinalPostProcess = new Ba("HDRVLSFinal","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
  124867. this.addEffect(new Vy(i.getEngine(),"HDRVLSFinal",(function() {
  124868. return e.volumetricLightFinalPostProcess
  124869. }
  124870. ),!0))),
  124871. this._lensFlareEnabled && (this._createLensFlarePostProcess(i, t),
  124872. this.lensFlareFinalPostProcess = new Ba("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
  124873. this.addEffect(new Vy(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function() {
  124874. return e.lensFlareFinalPostProcess
  124875. }
  124876. ),!0))),
  124877. this._hdrEnabled && (this._createLuminancePostProcesses(i, this._floatTextureType),
  124878. this._createHdrPostProcess(i, t),
  124879. this.hdrFinalPostProcess = new Ba("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
  124880. this.addEffect(new Vy(i.getEngine(),"HDRPostHDReDepthOfFieldSource",(function() {
  124881. return e.hdrFinalPostProcess
  124882. }
  124883. ),!0))),
  124884. this._depthOfFieldEnabled && (this._createBlurPostProcesses(i, t / 2, 3, "depthOfFieldBlurWidth"),
  124885. this._createDepthOfFieldPostProcess(i, t)),
  124886. this._motionBlurEnabled && this._createMotionBlurPostProcess(i, t),
  124887. this._fxaaEnabled && (this.fxaaPostProcess = new eb("fxaa",1,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
  124888. this.addEffect(new Vy(i.getEngine(),"HDRFxaa",(function() {
  124889. return e.fxaaPostProcess
  124890. }
  124891. ),!0))),
  124892. null !== this._cameras && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras),
  124893. !this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1 && K.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")
  124894. }
  124895. ,
  124896. t.prototype._createDownSampleX4PostProcess = function(e, t) {
  124897. var i = this
  124898. , n = new Array(32);
  124899. this.downSampleX4PostProcess = new Ba("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),
  124900. this.downSampleX4PostProcess.onApply = function(e) {
  124901. for (var t = 0, r = i.downSampleX4PostProcess.width, o = i.downSampleX4PostProcess.height, a = -2; a < 2; a++)
  124902. for (var s = -2; s < 2; s++)
  124903. n[t] = (a + .5) * (1 / r),
  124904. n[t + 1] = (s + .5) * (1 / o),
  124905. t += 2;
  124906. e.setArray2("dsOffsets", n)
  124907. }
  124908. ,
  124909. this.addEffect(new Vy(e.getEngine(),"HDRDownSampleX4",(function() {
  124910. return i.downSampleX4PostProcess
  124911. }
  124912. ),!0))
  124913. }
  124914. ,
  124915. t.prototype._createBrightPassPostProcess = function(e, t) {
  124916. var i = this
  124917. , n = new Array(8);
  124918. this.brightPassPostProcess = new Ba("HDRBrightPass","standard",["dsOffsets", "brightThreshold"],[],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),
  124919. this.brightPassPostProcess.onApply = function(e) {
  124920. var t = 1 / i.brightPassPostProcess.width
  124921. , r = 1 / i.brightPassPostProcess.height;
  124922. n[0] = -.5 * t,
  124923. n[1] = .5 * r,
  124924. n[2] = .5 * t,
  124925. n[3] = .5 * r,
  124926. n[4] = -.5 * t,
  124927. n[5] = -.5 * r,
  124928. n[6] = .5 * t,
  124929. n[7] = -.5 * r,
  124930. e.setArray2("dsOffsets", n),
  124931. e.setFloat("brightThreshold", i.brightThreshold)
  124932. }
  124933. ,
  124934. this.addEffect(new Vy(e.getEngine(),"HDRBrightPass",(function() {
  124935. return i.brightPassPostProcess
  124936. }
  124937. ),!0))
  124938. }
  124939. ,
  124940. t.prototype._createBlurPostProcesses = function(e, t, i, n) {
  124941. var r = this;
  124942. void 0 === n && (n = "blurWidth");
  124943. var o = e.getEngine()
  124944. , a = new Fd("HDRBlurH_" + i,new A(1,0),this[n],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType)
  124945. , s = new Fd("HDRBlurV_" + i,new A(0,1),this[n],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);
  124946. a.onActivateObservable.add((function() {
  124947. var e = a.width / o.getRenderWidth();
  124948. a.kernel = r[n] * e
  124949. }
  124950. )),
  124951. s.onActivateObservable.add((function() {
  124952. var e = s.height / o.getRenderHeight();
  124953. s.kernel = r.horizontalBlur ? 64 * e : r[n] * e
  124954. }
  124955. )),
  124956. this.addEffect(new Vy(e.getEngine(),"HDRBlurH" + i,(function() {
  124957. return a
  124958. }
  124959. ),!0)),
  124960. this.addEffect(new Vy(e.getEngine(),"HDRBlurV" + i,(function() {
  124961. return s
  124962. }
  124963. ),!0)),
  124964. this.blurHPostProcesses.push(a),
  124965. this.blurVPostProcesses.push(s)
  124966. }
  124967. ,
  124968. t.prototype._createTextureAdderPostProcess = function(e, t) {
  124969. var i = this;
  124970. this.textureAdderPostProcess = new Ba("HDRTextureAdder","standard",["exposure"],["otherSampler", "lensSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),
  124971. this.textureAdderPostProcess.onApply = function(e) {
  124972. e.setTextureFromPostProcess("otherSampler", i._vlsEnabled ? i._currentDepthOfFieldSource : i.originalPostProcess),
  124973. e.setTexture("lensSampler", i.lensTexture),
  124974. e.setFloat("exposure", i._currentExposure),
  124975. i._currentDepthOfFieldSource = i.textureAdderFinalPostProcess
  124976. }
  124977. ,
  124978. this.addEffect(new Vy(e.getEngine(),"HDRTextureAdder",(function() {
  124979. return i.textureAdderPostProcess
  124980. }
  124981. ),!0))
  124982. }
  124983. ,
  124984. t.prototype._createVolumetricLightPostProcess = function(e, t) {
  124985. var i = this
  124986. , n = e.enableGeometryBufferRenderer();
  124987. n.enablePosition = !0;
  124988. var r = n.getGBuffer();
  124989. this.volumetricLightPostProcess = new Ba("HDRVLS","standard",["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"],["shadowMapSampler", "positionSampler"],t / 8,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS " + this._volumetricLightStepsCount.toFixed(1));
  124990. var o = A.Zero();
  124991. this.volumetricLightPostProcess.onApply = function(e) {
  124992. if (i.sourceLight && i.sourceLight.getShadowGenerator() && i._scene.activeCamera) {
  124993. var t = i.sourceLight.getShadowGenerator();
  124994. e.setTexture("shadowMapSampler", t.getShadowMap()),
  124995. e.setTexture("positionSampler", r.textures[2]),
  124996. e.setColor3("sunColor", i.sourceLight.diffuse),
  124997. e.setVector3("sunDirection", i.sourceLight.getShadowDirection()),
  124998. e.setVector3("cameraPosition", i._scene.activeCamera.globalPosition),
  124999. e.setMatrix("shadowViewProjection", t.getTransformMatrix()),
  125000. e.setFloat("scatteringCoefficient", i.volumetricLightCoefficient),
  125001. e.setFloat("scatteringPower", i.volumetricLightPower),
  125002. o.x = i.sourceLight.getDepthMinZ(i._scene.activeCamera),
  125003. o.y = i.sourceLight.getDepthMaxZ(i._scene.activeCamera),
  125004. e.setVector2("depthValues", o)
  125005. }
  125006. }
  125007. ,
  125008. this.addEffect(new Vy(e.getEngine(),"HDRVLS",(function() {
  125009. return i.volumetricLightPostProcess
  125010. }
  125011. ),!0)),
  125012. this._createBlurPostProcesses(e, t / 4, 0, "volumetricLightBlurScale"),
  125013. this.volumetricLightMergePostProces = new Ba("HDRVLSMerge","standard",[],["originalSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),
  125014. this.volumetricLightMergePostProces.onApply = function(e) {
  125015. e.setTextureFromPostProcess("originalSampler", i._bloomEnabled ? i.textureAdderFinalPostProcess : i.originalPostProcess),
  125016. i._currentDepthOfFieldSource = i.volumetricLightFinalPostProcess
  125017. }
  125018. ,
  125019. this.addEffect(new Vy(e.getEngine(),"HDRVLSMerge",(function() {
  125020. return i.volumetricLightMergePostProces
  125021. }
  125022. ),!0))
  125023. }
  125024. ,
  125025. t.prototype._createLuminancePostProcesses = function(e, i) {
  125026. var n = this
  125027. , r = Math.pow(3, t.LuminanceSteps);
  125028. this.luminancePostProcess = new Ba("HDRLuminance","standard",["lumOffsets"],[],{
  125029. width: r,
  125030. height: r
  125031. },null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);
  125032. var o = [];
  125033. this.luminancePostProcess.onApply = function(e) {
  125034. var t = 1 / n.luminancePostProcess.width
  125035. , i = 1 / n.luminancePostProcess.height;
  125036. o[0] = -.5 * t,
  125037. o[1] = .5 * i,
  125038. o[2] = .5 * t,
  125039. o[3] = .5 * i,
  125040. o[4] = -.5 * t,
  125041. o[5] = -.5 * i,
  125042. o[6] = .5 * t,
  125043. o[7] = -.5 * i,
  125044. e.setArray2("lumOffsets", o)
  125045. }
  125046. ,
  125047. this.addEffect(new Vy(e.getEngine(),"HDRLuminance",(function() {
  125048. return n.luminancePostProcess
  125049. }
  125050. ),!0));
  125051. for (var a = t.LuminanceSteps - 1; a >= 0; a--) {
  125052. r = Math.pow(3, a);
  125053. var s = "#define LUMINANCE_DOWN_SAMPLE\n";
  125054. 0 === a && (s += "#define FINAL_DOWN_SAMPLER");
  125055. var l = new Ba("HDRLuminanceDownSample" + a,"standard",["dsOffsets", "halfDestPixelSize"],[],{
  125056. width: r,
  125057. height: r
  125058. },null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,s,i);
  125059. this.luminanceDownSamplePostProcesses.push(l)
  125060. }
  125061. var c = this.luminancePostProcess;
  125062. this.luminanceDownSamplePostProcesses.forEach((function(t, i) {
  125063. var r = new Array(18);
  125064. t.onApply = function(e) {
  125065. if (c) {
  125066. for (var o = 0, a = -1; a < 2; a++)
  125067. for (var s = -1; s < 2; s++)
  125068. r[o] = a / c.width,
  125069. r[o + 1] = s / c.height,
  125070. o += 2;
  125071. e.setArray2("dsOffsets", r),
  125072. e.setFloat("halfDestPixelSize", .5 / c.width),
  125073. c = i === n.luminanceDownSamplePostProcesses.length - 1 ? n.luminancePostProcess : t
  125074. }
  125075. }
  125076. ,
  125077. i === n.luminanceDownSamplePostProcesses.length - 1 && (t.onAfterRender = function() {
  125078. var t = e.getEngine().readPixels(0, 0, 1, 1)
  125079. , i = new R(1 / 16581375,1 / 65025,1 / 255,1);
  125080. t.then((function(e) {
  125081. var t = new Uint8Array(e.buffer);
  125082. n._hdrCurrentLuminance = (t[0] * i.x + t[1] * i.y + t[2] * i.z + t[3] * i.w) / 100
  125083. }
  125084. ))
  125085. }
  125086. ),
  125087. n.addEffect(new Vy(e.getEngine(),"HDRLuminanceDownSample" + i,(function() {
  125088. return t
  125089. }
  125090. ),!0))
  125091. }
  125092. ))
  125093. }
  125094. ,
  125095. t.prototype._createHdrPostProcess = function(e, t) {
  125096. var i = this
  125097. , n = ["#define HDR"];
  125098. this._hdrAutoExposure && n.push("#define AUTO_EXPOSURE"),
  125099. this.hdrPostProcess = new Ba("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n.join("\n"),a.TEXTURETYPE_UNSIGNED_INT);
  125100. var r = 1
  125101. , o = 0
  125102. , s = 0;
  125103. this.hdrPostProcess.onApply = function(t) {
  125104. if (t.setTextureFromPostProcess("textureAdderSampler", i._currentDepthOfFieldSource),
  125105. o += e.getEngine().getDeltaTime(),
  125106. r < 0)
  125107. r = i._hdrCurrentLuminance;
  125108. else {
  125109. var n = (s - o) / 1e3;
  125110. i._hdrCurrentLuminance < r + i.hdrDecreaseRate * n ? r += i.hdrDecreaseRate * n : i._hdrCurrentLuminance > r - i.hdrIncreaseRate * n ? r -= i.hdrIncreaseRate * n : r = i._hdrCurrentLuminance
  125111. }
  125112. i.hdrAutoExposure ? i._currentExposure = i._fixedExposure / r : (r = d.Clamp(r, i.hdrMinimumLuminance, 1e20),
  125113. t.setFloat("averageLuminance", r)),
  125114. s = o,
  125115. i._currentDepthOfFieldSource = i.hdrFinalPostProcess
  125116. }
  125117. ,
  125118. this.addEffect(new Vy(e.getEngine(),"HDR",(function() {
  125119. return i.hdrPostProcess
  125120. }
  125121. ),!0))
  125122. }
  125123. ,
  125124. t.prototype._createLensFlarePostProcess = function(e, t) {
  125125. var i = this;
  125126. this.lensFlarePostProcess = new Ba("HDRLensFlare","standard",["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"],["lensColorSampler"],t / 2,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",a.TEXTURETYPE_UNSIGNED_INT),
  125127. this.addEffect(new Vy(e.getEngine(),"HDRLensFlare",(function() {
  125128. return i.lensFlarePostProcess
  125129. }
  125130. ),!0)),
  125131. this._createBlurPostProcesses(e, t / 4, 2, "lensFlareBlurWidth"),
  125132. this.lensFlareComposePostProcess = new Ba("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler", "lensDirtSampler", "lensStarSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",a.TEXTURETYPE_UNSIGNED_INT),
  125133. this.addEffect(new Vy(e.getEngine(),"HDRLensFlareCompose",(function() {
  125134. return i.lensFlareComposePostProcess
  125135. }
  125136. ),!0));
  125137. var n = new A(0,0);
  125138. this.lensFlarePostProcess.externalTextureSamplerBinding = !0,
  125139. this.lensFlarePostProcess.onApply = function(e) {
  125140. e.setTextureFromPostProcess("textureSampler", i._bloomEnabled ? i.blurHPostProcesses[0] : i.originalPostProcess),
  125141. e.setTexture("lensColorSampler", i.lensColorTexture),
  125142. e.setFloat("strength", i.lensFlareStrength),
  125143. e.setFloat("ghostDispersal", i.lensFlareGhostDispersal),
  125144. e.setFloat("haloWidth", i.lensFlareHaloWidth),
  125145. n.x = i.lensFlarePostProcess.width,
  125146. n.y = i.lensFlarePostProcess.height,
  125147. e.setVector2("resolution", n),
  125148. e.setFloat("distortionStrength", i.lensFlareDistortionStrength)
  125149. }
  125150. ;
  125151. var r = P.FromValues(2, 0, -1, 0, 0, 2, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1)
  125152. , o = P.FromValues(.5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1, 0, 0, 0, 0, 1);
  125153. this.lensFlareComposePostProcess.onApply = function(e) {
  125154. if (i._scene.activeCamera) {
  125155. e.setTextureFromPostProcess("otherSampler", i.lensFlarePostProcess),
  125156. e.setTexture("lensDirtSampler", i.lensFlareDirtTexture),
  125157. e.setTexture("lensStarSampler", i.lensStarTexture);
  125158. var t = i._scene.activeCamera.getViewMatrix().getRow(0)
  125159. , n = i._scene.activeCamera.getViewMatrix().getRow(2)
  125160. , a = x.Dot(t.toVector3(), new x(1,0,0)) + x.Dot(n.toVector3(), new x(0,0,1));
  125161. a *= 4;
  125162. var s = P.FromValues(.5 * Math.cos(a), -Math.sin(a), 0, 0, Math.sin(a), .5 * Math.cos(a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
  125163. , l = o.multiply(s).multiply(r);
  125164. e.setMatrix("lensStarMatrix", l),
  125165. i._currentDepthOfFieldSource = i.lensFlareFinalPostProcess
  125166. }
  125167. }
  125168. }
  125169. ,
  125170. t.prototype._createDepthOfFieldPostProcess = function(e, t) {
  125171. var i = this;
  125172. this.depthOfFieldPostProcess = new Ba("HDRDepthOfField","standard",["distance"],["otherSampler", "depthSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",a.TEXTURETYPE_UNSIGNED_INT),
  125173. this.depthOfFieldPostProcess.onApply = function(e) {
  125174. e.setTextureFromPostProcess("otherSampler", i._currentDepthOfFieldSource),
  125175. e.setTexture("depthSampler", i._getDepthTexture()),
  125176. e.setFloat("distance", i.depthOfFieldDistance)
  125177. }
  125178. ,
  125179. this.addEffect(new Vy(e.getEngine(),"HDRDepthOfField",(function() {
  125180. return i.depthOfFieldPostProcess
  125181. }
  125182. ),!0))
  125183. }
  125184. ,
  125185. t.prototype._createMotionBlurPostProcess = function(e, t) {
  125186. var i = this;
  125187. if (this._isObjectBasedMotionBlur) {
  125188. var n = new ab("HDRMotionBlur",e,t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT);
  125189. n.motionStrength = this.motionStrength,
  125190. n.motionBlurSamples = this.motionBlurSamples,
  125191. this.motionBlurPostProcess = n
  125192. } else {
  125193. this.motionBlurPostProcess = new Ba("HDRMotionBlur","standard",["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"],["depthSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + this.motionBlurSamples.toFixed(1),a.TEXTURETYPE_UNSIGNED_INT);
  125194. var r = 0
  125195. , o = P.Identity()
  125196. , s = P.Identity()
  125197. , l = P.Identity()
  125198. , c = A.Zero();
  125199. this.motionBlurPostProcess.onApply = function(t) {
  125200. (l = e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),
  125201. t.setMatrix("inverseViewProjection", s),
  125202. t.setMatrix("prevViewProjection", o),
  125203. o = l,
  125204. c.x = i.motionBlurPostProcess.width,
  125205. c.y = i.motionBlurPostProcess.height,
  125206. t.setVector2("screenSize", c),
  125207. r = e.getEngine().getFps() / 60,
  125208. t.setFloat("motionScale", r),
  125209. t.setFloat("motionStrength", i.motionStrength),
  125210. t.setTexture("depthSampler", i._getDepthTexture())
  125211. }
  125212. }
  125213. this.addEffect(new Vy(e.getEngine(),"HDRMotionBlur",(function() {
  125214. return i.motionBlurPostProcess
  125215. }
  125216. ),!0))
  125217. }
  125218. ,
  125219. t.prototype._getDepthTexture = function() {
  125220. return this._scene.getEngine().getCaps().drawBuffersExtension ? this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0] : this._scene.enableDepthRenderer().getDepthMap()
  125221. }
  125222. ,
  125223. t.prototype._disposePostProcesses = function() {
  125224. for (var e = 0; e < this._cameras.length; e++) {
  125225. var t = this._cameras[e];
  125226. this.originalPostProcess && this.originalPostProcess.dispose(t),
  125227. this.screenSpaceReflectionPostProcess && this.screenSpaceReflectionPostProcess.dispose(t),
  125228. this.downSampleX4PostProcess && this.downSampleX4PostProcess.dispose(t),
  125229. this.brightPassPostProcess && this.brightPassPostProcess.dispose(t),
  125230. this.textureAdderPostProcess && this.textureAdderPostProcess.dispose(t),
  125231. this.volumetricLightPostProcess && this.volumetricLightPostProcess.dispose(t),
  125232. this.volumetricLightSmoothXPostProcess && this.volumetricLightSmoothXPostProcess.dispose(t),
  125233. this.volumetricLightSmoothYPostProcess && this.volumetricLightSmoothYPostProcess.dispose(t),
  125234. this.volumetricLightMergePostProces && this.volumetricLightMergePostProces.dispose(t),
  125235. this.volumetricLightFinalPostProcess && this.volumetricLightFinalPostProcess.dispose(t),
  125236. this.lensFlarePostProcess && this.lensFlarePostProcess.dispose(t),
  125237. this.lensFlareComposePostProcess && this.lensFlareComposePostProcess.dispose(t);
  125238. for (var i = 0; i < this.luminanceDownSamplePostProcesses.length; i++)
  125239. this.luminanceDownSamplePostProcesses[i].dispose(t);
  125240. for (this.luminancePostProcess && this.luminancePostProcess.dispose(t),
  125241. this.hdrPostProcess && this.hdrPostProcess.dispose(t),
  125242. this.hdrFinalPostProcess && this.hdrFinalPostProcess.dispose(t),
  125243. this.depthOfFieldPostProcess && this.depthOfFieldPostProcess.dispose(t),
  125244. this.motionBlurPostProcess && this.motionBlurPostProcess.dispose(t),
  125245. this.fxaaPostProcess && this.fxaaPostProcess.dispose(t),
  125246. i = 0; i < this.blurHPostProcesses.length; i++)
  125247. this.blurHPostProcesses[i].dispose(t);
  125248. for (i = 0; i < this.blurVPostProcesses.length; i++)
  125249. this.blurVPostProcesses[i].dispose(t)
  125250. }
  125251. this.originalPostProcess = null,
  125252. this.downSampleX4PostProcess = null,
  125253. this.brightPassPostProcess = null,
  125254. this.textureAdderPostProcess = null,
  125255. this.textureAdderFinalPostProcess = null,
  125256. this.volumetricLightPostProcess = null,
  125257. this.volumetricLightSmoothXPostProcess = null,
  125258. this.volumetricLightSmoothYPostProcess = null,
  125259. this.volumetricLightMergePostProces = null,
  125260. this.volumetricLightFinalPostProcess = null,
  125261. this.lensFlarePostProcess = null,
  125262. this.lensFlareComposePostProcess = null,
  125263. this.luminancePostProcess = null,
  125264. this.hdrPostProcess = null,
  125265. this.hdrFinalPostProcess = null,
  125266. this.depthOfFieldPostProcess = null,
  125267. this.motionBlurPostProcess = null,
  125268. this.fxaaPostProcess = null,
  125269. this.screenSpaceReflectionPostProcess = null,
  125270. this.luminanceDownSamplePostProcesses = [],
  125271. this.blurHPostProcesses = [],
  125272. this.blurVPostProcesses = []
  125273. }
  125274. ,
  125275. t.prototype.dispose = function() {
  125276. this._disposePostProcesses(),
  125277. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
  125278. e.prototype.dispose.call(this)
  125279. }
  125280. ,
  125281. t.prototype.serialize = function() {
  125282. var e = Ge.Serialize(this);
  125283. return this.sourceLight && (e.sourceLightId = this.sourceLight.id),
  125284. this.screenSpaceReflectionPostProcess && (e.screenSpaceReflectionPostProcess = Ge.Serialize(this.screenSpaceReflectionPostProcess)),
  125285. e.customType = "StandardRenderingPipeline",
  125286. e
  125287. }
  125288. ,
  125289. t.Parse = function(e, i, n) {
  125290. var r = Ge.Parse((function() {
  125291. return new t(e._name,i,e._ratio)
  125292. }
  125293. ), e, i, n);
  125294. return e.sourceLightId && (r.sourceLight = i.getLightById(e.sourceLightId)),
  125295. e.screenSpaceReflectionPostProcess && Ge.Parse((function() {
  125296. return r.screenSpaceReflectionPostProcess
  125297. }
  125298. ), e.screenSpaceReflectionPostProcess, i, n),
  125299. r
  125300. }
  125301. ,
  125302. t.LuminanceSteps = 6,
  125303. k([Ce()], t.prototype, "brightThreshold", void 0),
  125304. k([Ce()], t.prototype, "blurWidth", void 0),
  125305. k([Ce()], t.prototype, "horizontalBlur", void 0),
  125306. k([Ce()], t.prototype, "exposure", null),
  125307. k([Pe("lensTexture")], t.prototype, "lensTexture", void 0),
  125308. k([Ce()], t.prototype, "volumetricLightCoefficient", void 0),
  125309. k([Ce()], t.prototype, "volumetricLightPower", void 0),
  125310. k([Ce()], t.prototype, "volumetricLightBlurScale", void 0),
  125311. k([Ce()], t.prototype, "hdrMinimumLuminance", void 0),
  125312. k([Ce()], t.prototype, "hdrDecreaseRate", void 0),
  125313. k([Ce()], t.prototype, "hdrIncreaseRate", void 0),
  125314. k([Ce()], t.prototype, "hdrAutoExposure", null),
  125315. k([Pe("lensColorTexture")], t.prototype, "lensColorTexture", void 0),
  125316. k([Ce()], t.prototype, "lensFlareStrength", void 0),
  125317. k([Ce()], t.prototype, "lensFlareGhostDispersal", void 0),
  125318. k([Ce()], t.prototype, "lensFlareHaloWidth", void 0),
  125319. k([Ce()], t.prototype, "lensFlareDistortionStrength", void 0),
  125320. k([Ce()], t.prototype, "lensFlareBlurWidth", void 0),
  125321. k([Pe("lensStarTexture")], t.prototype, "lensStarTexture", void 0),
  125322. k([Pe("lensFlareDirtTexture")], t.prototype, "lensFlareDirtTexture", void 0),
  125323. k([Ce()], t.prototype, "depthOfFieldDistance", void 0),
  125324. k([Ce()], t.prototype, "depthOfFieldBlurWidth", void 0),
  125325. k([Ce()], t.prototype, "motionStrength", null),
  125326. k([Ce()], t.prototype, "objectBasedMotionBlur", null),
  125327. k([Ce()], t.prototype, "_ratio", void 0),
  125328. k([Ce()], t.prototype, "BloomEnabled", null),
  125329. k([Ce()], t.prototype, "DepthOfFieldEnabled", null),
  125330. k([Ce()], t.prototype, "LensFlareEnabled", null),
  125331. k([Ce()], t.prototype, "HDREnabled", null),
  125332. k([Ce()], t.prototype, "VLSEnabled", null),
  125333. k([Ce()], t.prototype, "MotionBlurEnabled", null),
  125334. k([Ce()], t.prototype, "fxaaEnabled", null),
  125335. k([Ce()], t.prototype, "screenSpaceReflectionsEnabled", null),
  125336. k([Ce()], t.prototype, "volumetricLightStepsCount", null),
  125337. k([Ce()], t.prototype, "motionBlurSamples", null),
  125338. k([Ce()], t.prototype, "samples", null),
  125339. t
  125340. }(cb);
  125341. y("BABYLON.StandardRenderingPipeline", yb);
  125342. var bb;
  125343. Pt.ShadersStore.tonemapPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour= vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}",
  125344. function(e) {
  125345. e[e.Hable = 0] = "Hable",
  125346. e[e.Reinhard = 1] = "Reinhard",
  125347. e[e.HejiDawson = 2] = "HejiDawson",
  125348. e[e.Photographic = 3] = "Photographic"
  125349. }(bb || (bb = {}));
  125350. var Tb = function(e) {
  125351. function t(t, i, n, r, o, s, l, c) {
  125352. void 0 === o && (o = a.TEXTURE_BILINEAR_SAMPLINGMODE),
  125353. void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
  125354. var u = e.call(this, t, "tonemap", ["_ExposureAdjustment"], null, 1, r, o, s, c, null, l) || this;
  125355. u._operator = i,
  125356. u.exposureAdjustment = n;
  125357. var h = "#define ";
  125358. return u._operator === bb.Hable ? h += "HABLE_TONEMAPPING" : u._operator === bb.Reinhard ? h += "REINHARD_TONEMAPPING" : u._operator === bb.HejiDawson ? h += "OPTIMIZED_HEJIDAWSON_TONEMAPPING" : u._operator === bb.Photographic && (h += "PHOTOGRAPHIC_TONEMAPPING"),
  125359. u.updateEffect(h),
  125360. u.onApply = function(e) {
  125361. e.setFloat("_ExposureAdjustment", u.exposureAdjustment)
  125362. }
  125363. ,
  125364. u
  125365. }
  125366. return U(t, e),
  125367. t.prototype.getClassName = function() {
  125368. return "TonemapPostProcess"
  125369. }
  125370. ,
  125371. t
  125372. }(Ba);
  125373. Pt.ShadersStore.volumetricLightScatteringPixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;\ndataSample*=illuminationDecay*weight;\ncolor+=dataSample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
  125374. Pt.ShadersStore.volumetricLightScatteringPassVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
  125375. Pt.ShadersStore.volumetricLightScatteringPassPixelShader = "#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n";
  125376. var Eb = function(e) {
  125377. function t(i, n, r, o, a, s, l, c, u) {
  125378. void 0 === a && (a = 100),
  125379. void 0 === s && (s = io.BILINEAR_SAMPLINGMODE);
  125380. var h, d = this;
  125381. return (d = e.call(this, i, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], n.postProcessRatio || n, r, s, l, c, "#define NUM_SAMPLES " + a) || this)._screenCoordinates = A.Zero(),
  125382. d.customMeshPosition = x.Zero(),
  125383. d.useCustomMeshPosition = !1,
  125384. d.invert = !0,
  125385. d.excludedMeshes = new Array,
  125386. d.exposure = .3,
  125387. d.decay = .96815,
  125388. d.weight = .58767,
  125389. d.density = .926,
  125390. l = (u = null !== (h = null == r ? void 0 : r.getScene()) && void 0 !== h ? h : u).getEngine(),
  125391. d._viewPort = new xr(0,0,1,1).toGlobal(l.getRenderWidth(), l.getRenderHeight()),
  125392. d.mesh = null != o ? o : t.CreateDefaultMesh("VolumetricLightScatteringMesh", u),
  125393. d._volumetricLightScatteringPass = new Gt(l),
  125394. d._createPass(u, n.passRatio || n),
  125395. d.onActivate = function(e) {
  125396. d.isSupported || d.dispose(e),
  125397. d.onActivate = null
  125398. }
  125399. ,
  125400. d.onApplyObservable.add((function(e) {
  125401. d._updateMeshScreenCoordinates(u),
  125402. e.setTexture("lightScatteringSampler", d._volumetricLightScatteringRTT),
  125403. e.setFloat("exposure", d.exposure),
  125404. e.setFloat("decay", d.decay),
  125405. e.setFloat("weight", d.weight),
  125406. e.setFloat("density", d.density),
  125407. e.setVector2("meshPositionOnScreen", d._screenCoordinates)
  125408. }
  125409. )),
  125410. d
  125411. }
  125412. return U(t, e),
  125413. Object.defineProperty(t.prototype, "useDiffuseColor", {
  125414. get: function() {
  125415. return K.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),
  125416. !1
  125417. },
  125418. set: function(e) {
  125419. K.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")
  125420. },
  125421. enumerable: !1,
  125422. configurable: !0
  125423. }),
  125424. t.prototype.getClassName = function() {
  125425. return "VolumetricLightScatteringPostProcess"
  125426. }
  125427. ,
  125428. t.prototype._isReady = function(e, t) {
  125429. var i = e.getMesh();
  125430. if (i === this.mesh && i.material)
  125431. return i.material.isReady(i);
  125432. var n = []
  125433. , r = [Bi.PositionKind]
  125434. , o = e.getMaterial();
  125435. o && (o.needAlphaTesting() && n.push("#define ALPHATEST"),
  125436. i.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
  125437. n.push("#define UV1")),
  125438. i.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
  125439. n.push("#define UV2"))),
  125440. i.useBones && i.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
  125441. r.push(Bi.MatricesWeightsKind),
  125442. n.push("#define NUM_BONE_INFLUENCERS " + i.numBoneInfluencers),
  125443. n.push("#define BonesPerMesh " + (i.skeleton ? i.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0"),
  125444. t && (n.push("#define INSTANCES"),
  125445. Mr.PushAttributesForInstances(r),
  125446. e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES"));
  125447. var a = n.join("\n");
  125448. return this._cachedDefines !== a && (this._cachedDefines = a,
  125449. this._volumetricLightScatteringPass.effect = i.getScene().getEngine().createEffect("volumetricLightScatteringPass", r, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], a, void 0, void 0, void 0, {
  125450. maxSimultaneousMorphTargets: i.numBoneInfluencers
  125451. })),
  125452. this._volumetricLightScatteringPass.effect.isReady()
  125453. }
  125454. ,
  125455. t.prototype.setCustomMeshPosition = function(e) {
  125456. this.customMeshPosition = e
  125457. }
  125458. ,
  125459. t.prototype.getCustomMeshPosition = function() {
  125460. return this.customMeshPosition
  125461. }
  125462. ,
  125463. t.prototype.dispose = function(t) {
  125464. var i = t.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  125465. -1 !== i && t.getScene().customRenderTargets.splice(i, 1),
  125466. this._volumetricLightScatteringRTT.dispose(),
  125467. e.prototype.dispose.call(this, t)
  125468. }
  125469. ,
  125470. t.prototype.getPass = function() {
  125471. return this._volumetricLightScatteringRTT
  125472. }
  125473. ,
  125474. t.prototype._meshExcluded = function(e) {
  125475. return this.excludedMeshes.length > 0 && -1 !== this.excludedMeshes.indexOf(e)
  125476. }
  125477. ,
  125478. t.prototype._createPass = function(e, t) {
  125479. var i = this
  125480. , n = e.getEngine();
  125481. this._volumetricLightScatteringRTT = new ns("volumetricLightScatteringMap",{
  125482. width: n.getRenderWidth() * t,
  125483. height: n.getRenderHeight() * t
  125484. },e,!1,!0,a.TEXTURETYPE_UNSIGNED_INT),
  125485. this._volumetricLightScatteringRTT.wrapU = io.CLAMP_ADDRESSMODE,
  125486. this._volumetricLightScatteringRTT.wrapV = io.CLAMP_ADDRESSMODE,
  125487. this._volumetricLightScatteringRTT.renderList = null,
  125488. this._volumetricLightScatteringRTT.renderParticles = !1,
  125489. this._volumetricLightScatteringRTT.ignoreCameraViewport = !0;
  125490. var r = this.getCamera();
  125491. r ? r.customRenderTargets.push(this._volumetricLightScatteringRTT) : e.customRenderTargets.push(this._volumetricLightScatteringRTT);
  125492. var o, s = function(e) {
  125493. var t = e.getRenderingMesh()
  125494. , n = e.getEffectiveMesh();
  125495. if (!i._meshExcluded(t)) {
  125496. n._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
  125497. var r = e.getMaterial();
  125498. if (r) {
  125499. var o = t.getScene()
  125500. , a = o.getEngine();
  125501. a.setState(r.backFaceCulling, void 0, void 0, void 0, r.cullBackFaces);
  125502. var s = t._getInstancesRenderList(e._id, !!e.getReplacementMesh());
  125503. if (!s.mustReturn) {
  125504. var l = a.getCaps().instancedArrays && (null !== s.visibleInstances[e._id] || t.hasThinInstances);
  125505. if (i._isReady(e, l)) {
  125506. var c = i._volumetricLightScatteringPass;
  125507. t === i.mesh && (c = e.effect ? e._drawWrapper : r._getDrawWrapper());
  125508. var u = c.effect;
  125509. if (a.enableEffect(c),
  125510. l || t._bind(e, u, r.fillMode),
  125511. t === i.mesh)
  125512. r.bind(n.getWorldMatrix(), t);
  125513. else {
  125514. if (u.setMatrix("viewProjection", o.getTransformMatrix()),
  125515. r && r.needAlphaTesting()) {
  125516. var h = r.getAlphaTestTexture();
  125517. u.setTexture("diffuseSampler", h),
  125518. h && u.setMatrix("diffuseMatrix", h.getTextureMatrix())
  125519. }
  125520. t.useBones && t.computeBonesUsingShaders && t.skeleton && u.setMatrices("mBones", t.skeleton.getTransformMatrices(t))
  125521. }
  125522. t._processRendering(n, e, u, Or.TriangleFillMode, s, l, (function(e, t) {
  125523. return u.setMatrix("world", t)
  125524. }
  125525. ))
  125526. }
  125527. }
  125528. }
  125529. }
  125530. }, l = new N(0,0,0,1);
  125531. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function() {
  125532. o = e.clearColor,
  125533. e.clearColor = l
  125534. }
  125535. )),
  125536. this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function() {
  125537. e.clearColor = o
  125538. }
  125539. )),
  125540. this._volumetricLightScatteringRTT.customIsReadyFunction = function(e, t) {
  125541. if (!e.isReady(!1))
  125542. return !1;
  125543. if (0 === t && e.subMeshes)
  125544. for (var r = 0; r < e.subMeshes.length; ++r) {
  125545. var o = e.subMeshes[r]
  125546. , a = o.getMaterial()
  125547. , s = o.getRenderingMesh();
  125548. if (a) {
  125549. var l = s._getInstancesRenderList(o._id, !!o.getReplacementMesh())
  125550. , c = n.getCaps().instancedArrays && (null !== l.visibleInstances[o._id] || s.hasThinInstances);
  125551. if (!i._isReady(o, c))
  125552. return !1
  125553. }
  125554. }
  125555. return !0
  125556. }
  125557. ,
  125558. this._volumetricLightScatteringRTT.customRenderFunction = function(t, i, n, r) {
  125559. var o, l = e.getEngine();
  125560. if (r.length) {
  125561. for (l.setColorWrite(!1),
  125562. o = 0; o < r.length; o++)
  125563. s(r.data[o]);
  125564. l.setColorWrite(!0)
  125565. }
  125566. for (o = 0; o < t.length; o++)
  125567. s(t.data[o]);
  125568. for (o = 0; o < i.length; o++)
  125569. s(i.data[o]);
  125570. if (n.length) {
  125571. for (o = 0; o < n.length; o++) {
  125572. var c = n.data[o]
  125573. , u = c.getBoundingInfo();
  125574. u && e.activeCamera && (c._alphaIndex = c.getMesh().alphaIndex,
  125575. c._distanceToCamera = u.boundingSphere.centerWorld.subtract(e.activeCamera.position).length())
  125576. }
  125577. var h = n.data.slice(0, n.length);
  125578. for (h.sort((function(e, t) {
  125579. return e._alphaIndex > t._alphaIndex ? 1 : e._alphaIndex < t._alphaIndex ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0
  125580. }
  125581. )),
  125582. l.setAlphaMode(a.ALPHA_COMBINE),
  125583. o = 0; o < h.length; o++)
  125584. s(h[o]);
  125585. l.setAlphaMode(a.ALPHA_DISABLE)
  125586. }
  125587. }
  125588. }
  125589. ,
  125590. t.prototype._updateMeshScreenCoordinates = function(e) {
  125591. var t, i = e.getTransformMatrix();
  125592. t = this.useCustomMeshPosition ? this.customMeshPosition : this.attachedNode ? this.attachedNode.position : this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  125593. var n = x.Project(t, P.Identity(), i, this._viewPort);
  125594. this._screenCoordinates.x = n.x / this._viewPort.width,
  125595. this._screenCoordinates.y = n.y / this._viewPort.height,
  125596. this.invert && (this._screenCoordinates.y = 1 - this._screenCoordinates.y)
  125597. }
  125598. ,
  125599. t.CreateDefaultMesh = function(e, t) {
  125600. var i = vo(e, {
  125601. size: 1
  125602. }, t);
  125603. i.billboardMode = Sr.BILLBOARDMODE_ALL;
  125604. var n = new Os(e + "Material",t);
  125605. return n.emissiveColor = new D(1,1,1),
  125606. i.material = n,
  125607. i
  125608. }
  125609. ,
  125610. k([De()], t.prototype, "customMeshPosition", void 0),
  125611. k([Ce()], t.prototype, "useCustomMeshPosition", void 0),
  125612. k([Ce()], t.prototype, "invert", void 0),
  125613. k([Ne()], t.prototype, "mesh", void 0),
  125614. k([Ce()], t.prototype, "excludedMeshes", void 0),
  125615. k([Ce()], t.prototype, "exposure", void 0),
  125616. k([Ce()], t.prototype, "decay", void 0),
  125617. k([Ce()], t.prototype, "weight", void 0),
  125618. k([Ce()], t.prototype, "density", void 0),
  125619. t
  125620. }(Ba);
  125621. y("BABYLON.VolumetricLightScatteringPostProcess", Eb);
  125622. Pt.ShadersStore.screenSpaceCurvaturePixelShader = "precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D normalSampler;\nuniform float curvature_ridge;\nuniform float curvature_valley;\n#ifndef CURVATURE_OFFSET\n#define CURVATURE_OFFSET 1\n#endif\nfloat curvature_soft_clamp(float curvature,float control)\n{\nif (curvature<0.5/control)\nreturn curvature*(1.0-curvature*control);\nreturn 0.25/control;\n}\nfloat calculate_curvature(ivec2 texel,float ridge,float valley)\n{\nvec2 normal_up =texelFetch(normalSampler,texel+ivec2(0, CURVATURE_OFFSET),0).rb;\nvec2 normal_down =texelFetch(normalSampler,texel+ivec2(0,-CURVATURE_OFFSET),0).rb;\nvec2 normal_left =texelFetch(normalSampler,texel+ivec2(-CURVATURE_OFFSET,0),0).rb;\nvec2 normal_right=texelFetch(normalSampler,texel+ivec2( CURVATURE_OFFSET,0),0).rb;\nfloat normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));\nif (normal_diff<0.0)\nreturn -2.0*curvature_soft_clamp(-normal_diff,valley);\nreturn 2.0*curvature_soft_clamp(normal_diff,ridge);\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nivec2 texel=ivec2(gl_FragCoord.xy);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);\nbaseColor.rgb*=curvature+1.0;\ngl_FragColor=baseColor;\n}";
  125623. var Sb = function(e) {
  125624. function t(t, i, n, r, o, s, l, c, u) {
  125625. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
  125626. void 0 === u && (u = !1);
  125627. var h = e.call(this, t, "screenSpaceCurvature", ["curvature_ridge", "curvature_valley"], ["textureSampler", "normalSampler"], n, r, o, s, l, void 0, c, void 0, null, u) || this;
  125628. return h.ridge = 1,
  125629. h.valley = 1,
  125630. h._geometryBufferRenderer = i.enableGeometryBufferRenderer(),
  125631. h._geometryBufferRenderer ? h.onApply = function(e) {
  125632. e.setFloat("curvature_ridge", .5 / Math.max(h.ridge * h.ridge, 1e-4)),
  125633. e.setFloat("curvature_valley", .7 / Math.max(h.valley * h.valley, 1e-4));
  125634. var t = h._geometryBufferRenderer.getGBuffer().textures[1];
  125635. e.setTexture("normalSampler", t)
  125636. }
  125637. : K.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."),
  125638. h
  125639. }
  125640. return U(t, e),
  125641. t.prototype.getClassName = function() {
  125642. return "ScreenSpaceCurvaturePostProcess"
  125643. }
  125644. ,
  125645. Object.defineProperty(t, "IsSupported", {
  125646. get: function() {
  125647. var e = E.LastCreatedEngine;
  125648. return !!e && e.getCaps().drawBuffersExtension
  125649. },
  125650. enumerable: !1,
  125651. configurable: !0
  125652. }),
  125653. t._Parse = function(e, i, n, r) {
  125654. return Ge.Parse((function() {
  125655. return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
  125656. }
  125657. ), e, n, r)
  125658. }
  125659. ,
  125660. k([Ce()], t.prototype, "ridge", void 0),
  125661. k([Ce()], t.prototype, "valley", void 0),
  125662. t
  125663. }(Ba);
  125664. y("BABYLON.ScreenSpaceCurvaturePostProcess", Sb);
  125665. Pt.IncludesShadersStore.boundingBoxRendererFragmentDeclaration = "uniform vec4 color;\n";
  125666. Pt.IncludesShadersStore.boundingBoxRendererUboDeclaration = "layout(std140,column_major) uniform;\nuniform BoundingBoxRenderer {\nvec4 color;\nmat4 world;\nmat4 viewProjection;\nmat4 viewProjectionR;\n};\n";
  125667. Pt.ShadersStore.boundingBoxRendererPixelShader = "#include<__decl__boundingBoxRendererFragment>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  125668. Pt.IncludesShadersStore.boundingBoxRendererVertexDeclaration = "uniform mat4 world;\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n";
  125669. Pt.ShadersStore.boundingBoxRendererVertexShader = "attribute vec3 position;\n#include<__decl__boundingBoxRendererVertex>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n",
  125670. Object.defineProperty(mn.prototype, "forceShowBoundingBoxes", {
  125671. get: function() {
  125672. return this._forceShowBoundingBoxes || !1
  125673. },
  125674. set: function(e) {
  125675. this._forceShowBoundingBoxes = e,
  125676. e && this.getBoundingBoxRenderer()
  125677. },
  125678. enumerable: !0,
  125679. configurable: !0
  125680. }),
  125681. mn.prototype.getBoundingBoxRenderer = function() {
  125682. return this._boundingBoxRenderer || (this._boundingBoxRenderer = new Ab(this)),
  125683. this._boundingBoxRenderer
  125684. }
  125685. ,
  125686. Object.defineProperty(Sr.prototype, "showBoundingBox", {
  125687. get: function() {
  125688. return this._showBoundingBox || !1
  125689. },
  125690. set: function(e) {
  125691. this._showBoundingBox = e,
  125692. e && this.getScene().getBoundingBoxRenderer()
  125693. },
  125694. enumerable: !0,
  125695. configurable: !0
  125696. });
  125697. var Ab = function() {
  125698. function e(e) {
  125699. this.name = Wi.NAME_BOUNDINGBOXRENDERER,
  125700. this.frontColor = new D(1,1,1),
  125701. this.backColor = new D(.1,.1,.1),
  125702. this.showBackLines = !0,
  125703. this.onBeforeBoxRenderingObservable = new h,
  125704. this.onAfterBoxRenderingObservable = new h,
  125705. this.onResourcesReadyObservable = new h,
  125706. this.enabled = !0,
  125707. this.renderList = new bi(32),
  125708. this._vertexBuffers = {},
  125709. this._fillIndexBuffer = null,
  125710. this._fillIndexData = null,
  125711. this.scene = e,
  125712. e._addComponent(this),
  125713. this._uniformBufferFront = new Fi(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront"),
  125714. this._buildUniformLayout(this._uniformBufferFront),
  125715. this._uniformBufferBack = new Fi(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack"),
  125716. this._buildUniformLayout(this._uniformBufferBack)
  125717. }
  125718. return e.prototype._buildUniformLayout = function(e) {
  125719. e.addUniform("color", 4),
  125720. e.addUniform("world", 16),
  125721. e.addUniform("viewProjection", 16),
  125722. e.addUniform("viewProjectionR", 16),
  125723. e.create()
  125724. }
  125725. ,
  125726. e.prototype.register = function() {
  125727. this.scene._beforeEvaluateActiveMeshStage.registerStep(Wi.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset),
  125728. this.scene._preActiveMeshStage.registerStep(Wi.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh),
  125729. this.scene._evaluateSubMeshStage.registerStep(Wi.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh),
  125730. this.scene._afterRenderingGroupDrawStage.registerStep(Wi.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render)
  125731. }
  125732. ,
  125733. e.prototype._evaluateSubMesh = function(e, t) {
  125734. if (e.showSubMeshesBoundingBox) {
  125735. var i = t.getBoundingInfo();
  125736. null != i && (i.boundingBox._tag = e.renderingGroupId,
  125737. this.renderList.push(i.boundingBox))
  125738. }
  125739. }
  125740. ,
  125741. e.prototype._preActiveMesh = function(e) {
  125742. if (e.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  125743. var t = e.getBoundingInfo();
  125744. t.boundingBox._tag = e.renderingGroupId,
  125745. this.renderList.push(t.boundingBox)
  125746. }
  125747. }
  125748. ,
  125749. e.prototype._prepareResources = function() {
  125750. if (!this._colorShader) {
  125751. this._colorShader = new jl("colorShader",this.scene,"boundingBoxRenderer",{
  125752. attributes: [Bi.PositionKind],
  125753. uniforms: ["world", "viewProjection", "color"],
  125754. uniformBuffers: ["BoundingBoxRenderer"]
  125755. },!1),
  125756. this._colorShader.reservedDataStore = {
  125757. hidden: !0
  125758. },
  125759. this._colorShaderForOcclusionQuery = new jl("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{
  125760. attributes: [Bi.PositionKind],
  125761. uniforms: ["world", "viewProjection", "color"],
  125762. uniformBuffers: ["BoundingBoxRenderer"]
  125763. },!0),
  125764. this._colorShaderForOcclusionQuery.reservedDataStore = {
  125765. hidden: !0
  125766. };
  125767. var e = this.scene.getEngine()
  125768. , t = Pl({
  125769. size: 1
  125770. });
  125771. this._vertexBuffers[Bi.PositionKind] = new Bi(e,t.positions,Bi.PositionKind,!1),
  125772. this._createIndexBuffer(),
  125773. this._fillIndexData = t.indices,
  125774. this.onResourcesReadyObservable.notifyObservers(this)
  125775. }
  125776. }
  125777. ,
  125778. e.prototype._createIndexBuffer = function() {
  125779. var e = this.scene.getEngine();
  125780. this._indexBuffer = e.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4])
  125781. }
  125782. ,
  125783. e.prototype.rebuild = function() {
  125784. var e = this._vertexBuffers[Bi.PositionKind];
  125785. e && e._rebuild(),
  125786. this._createIndexBuffer()
  125787. }
  125788. ,
  125789. e.prototype.reset = function() {
  125790. this.renderList.reset()
  125791. }
  125792. ,
  125793. e.prototype.render = function(e) {
  125794. var t, i;
  125795. if (0 !== this.renderList.length && this.enabled && (this._prepareResources(),
  125796. this._colorShader.isReady())) {
  125797. var n = this.scene.getEngine();
  125798. n.setDepthWrite(!1);
  125799. for (var r = this.frontColor.toColor4(), o = this.backColor.toColor4(), a = this.scene.getTransformMatrix(), s = 0; s < this.renderList.length; s++) {
  125800. var l = this.renderList.data[s];
  125801. if (l._tag === e) {
  125802. this._createWrappersForBoundingBox(l),
  125803. this.onBeforeBoxRenderingObservable.notifyObservers(l);
  125804. var c = l.minimum
  125805. , u = l.maximum.subtract(c)
  125806. , h = c.add(u.scale(.5))
  125807. , d = P.Scaling(u.x, u.y, u.z).multiply(P.Translation(h.x, h.y, h.z)).multiply(l.getWorldMatrix())
  125808. , p = n.useReverseDepthBuffer;
  125809. if (this.showBackLines) {
  125810. var f = null !== (t = l._drawWrapperBack) && void 0 !== t ? t : this._colorShader._getDrawWrapper();
  125811. this._colorShader._preBind(f),
  125812. n.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
  125813. p ? n.setDepthFunctionToLessOrEqual() : n.setDepthFunctionToGreaterOrEqual(),
  125814. this._uniformBufferBack.bindToEffect(f.effect, "BoundingBoxRenderer"),
  125815. this._uniformBufferBack.updateDirectColor4("color", o),
  125816. this._uniformBufferBack.updateMatrix("world", d),
  125817. this._uniformBufferBack.updateMatrix("viewProjection", a),
  125818. this._uniformBufferBack.update(),
  125819. n.drawElementsType(Or.LineListDrawMode, 0, 24)
  125820. }
  125821. var _ = null !== (i = l._drawWrapperFront) && void 0 !== i ? i : this._colorShader._getDrawWrapper();
  125822. this._colorShader._preBind(_),
  125823. n.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
  125824. p ? n.setDepthFunctionToGreater() : n.setDepthFunctionToLess(),
  125825. this._uniformBufferFront.bindToEffect(_.effect, "BoundingBoxRenderer"),
  125826. this._uniformBufferFront.updateDirectColor4("color", r),
  125827. this._uniformBufferFront.updateMatrix("world", d),
  125828. this._uniformBufferFront.updateMatrix("viewProjection", a),
  125829. this._uniformBufferFront.update(),
  125830. n.drawElementsType(Or.LineListDrawMode, 0, 24),
  125831. this.onAfterBoxRenderingObservable.notifyObservers(l)
  125832. }
  125833. }
  125834. this._colorShader.unbind(),
  125835. n.setDepthFunctionToLessOrEqual(),
  125836. n.setDepthWrite(!0)
  125837. }
  125838. }
  125839. ,
  125840. e.prototype._createWrappersForBoundingBox = function(e) {
  125841. if (!e._drawWrapperFront) {
  125842. var t = this.scene.getEngine();
  125843. e._drawWrapperFront = new Gt(t),
  125844. e._drawWrapperBack = new Gt(t),
  125845. e._drawWrapperFront.setEffect(this._colorShader.getEffect()),
  125846. e._drawWrapperBack.setEffect(this._colorShader.getEffect())
  125847. }
  125848. }
  125849. ,
  125850. e.prototype.renderOcclusionBoundingBox = function(e) {
  125851. var t = this.scene.getEngine();
  125852. void 0 === this._renderPassIdForOcclusionQuery && (this._renderPassIdForOcclusionQuery = t.createRenderPassId("Render pass for occlusion query"));
  125853. var i = t.currentRenderPassId;
  125854. t.currentRenderPassId = this._renderPassIdForOcclusionQuery,
  125855. this._prepareResources();
  125856. var n = e.subMeshes[0];
  125857. if (this._colorShaderForOcclusionQuery.isReady(e, void 0, n) && e.hasBoundingInfo) {
  125858. this._fillIndexBuffer || (this._fillIndexBuffer = t.createIndexBuffer(this._fillIndexData));
  125859. var r = t.useReverseDepthBuffer;
  125860. t.setDepthWrite(!1),
  125861. t.setColorWrite(!1);
  125862. var o = e.getBoundingInfo().boundingBox
  125863. , a = o.minimum
  125864. , s = o.maximum.subtract(a)
  125865. , l = a.add(s.scale(.5))
  125866. , c = P.Scaling(s.x, s.y, s.z).multiply(P.Translation(l.x, l.y, l.z)).multiply(o.getWorldMatrix())
  125867. , u = n._drawWrapper;
  125868. this._colorShaderForOcclusionQuery._preBind(u),
  125869. t.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, u.effect),
  125870. r ? t.setDepthFunctionToGreater() : t.setDepthFunctionToLess(),
  125871. this.scene.resetCachedMaterial(),
  125872. this._uniformBufferFront.bindToEffect(u.effect, "BoundingBoxRenderer"),
  125873. this._uniformBufferFront.updateMatrix("world", c),
  125874. this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()),
  125875. this._uniformBufferFront.update(),
  125876. t.drawElementsType(Or.TriangleFillMode, 0, 36),
  125877. this._colorShaderForOcclusionQuery.unbind(),
  125878. t.setDepthFunctionToLessOrEqual(),
  125879. t.setDepthWrite(!0),
  125880. t.setColorWrite(!0),
  125881. t.currentRenderPassId = i
  125882. } else
  125883. t.currentRenderPassId = i
  125884. }
  125885. ,
  125886. e.prototype.dispose = function() {
  125887. if (void 0 !== this._renderPassIdForOcclusionQuery && (this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),
  125888. this._renderPassIdForOcclusionQuery = void 0),
  125889. this._colorShader) {
  125890. this.onBeforeBoxRenderingObservable.clear(),
  125891. this.onAfterBoxRenderingObservable.clear(),
  125892. this.onResourcesReadyObservable.clear(),
  125893. this.renderList.dispose(),
  125894. this._colorShader.dispose(),
  125895. this._colorShaderForOcclusionQuery.dispose(),
  125896. this._uniformBufferFront.dispose(),
  125897. this._uniformBufferBack.dispose();
  125898. var e = this._vertexBuffers[Bi.PositionKind];
  125899. e && (e.dispose(),
  125900. this._vertexBuffers[Bi.PositionKind] = null),
  125901. this.scene.getEngine()._releaseBuffer(this._indexBuffer),
  125902. this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),
  125903. this._fillIndexBuffer = null)
  125904. }
  125905. }
  125906. ,
  125907. e
  125908. }();
  125909. mn.prototype.enableDepthRenderer = function(e, t, i) {
  125910. if (void 0 === t && (t = !1),
  125911. void 0 === i && (i = !1),
  125912. !(e = e || this.activeCamera))
  125913. throw "No camera available to enable depth renderer";
  125914. if (this._depthRenderer || (this._depthRenderer = {}),
  125915. !this._depthRenderer[e.id]) {
  125916. var n, r = !!this.getEngine().getCaps().textureFloatRender;
  125917. n = !this.getEngine().getCaps().textureHalfFloatRender || i && r ? r ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE : a.TEXTURETYPE_HALF_FLOAT,
  125918. this._depthRenderer[e.id] = new o_(this,n,e,t)
  125919. }
  125920. return this._depthRenderer[e.id]
  125921. }
  125922. ,
  125923. mn.prototype.disableDepthRenderer = function(e) {
  125924. (e = e || this.activeCamera) && this._depthRenderer && this._depthRenderer[e.id] && this._depthRenderer[e.id].dispose()
  125925. }
  125926. ;
  125927. var xb = function() {
  125928. function e(e) {
  125929. this.name = Wi.NAME_DEPTHRENDERER,
  125930. this.scene = e
  125931. }
  125932. return e.prototype.register = function() {
  125933. this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets),
  125934. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Wi.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets)
  125935. }
  125936. ,
  125937. e.prototype.rebuild = function() {}
  125938. ,
  125939. e.prototype.dispose = function() {
  125940. for (var e in this.scene._depthRenderer)
  125941. this.scene._depthRenderer[e].dispose()
  125942. }
  125943. ,
  125944. e.prototype._gatherRenderTargets = function(e) {
  125945. if (this.scene._depthRenderer)
  125946. for (var t in this.scene._depthRenderer) {
  125947. var i = this.scene._depthRenderer[t];
  125948. i.enabled && !i.useOnlyInActiveCamera && e.push(i.getDepthMap())
  125949. }
  125950. }
  125951. ,
  125952. e.prototype._gatherActiveCameraRenderTargets = function(e) {
  125953. if (this.scene._depthRenderer)
  125954. for (var t in this.scene._depthRenderer) {
  125955. var i = this.scene._depthRenderer[t];
  125956. i.enabled && i.useOnlyInActiveCamera && this.scene.activeCamera.id === t && e.push(i.getDepthMap())
  125957. }
  125958. }
  125959. ,
  125960. e
  125961. }();
  125962. o_._SceneComponentInitialization = function(e) {
  125963. var t = e._getComponent(Wi.NAME_DEPTHRENDERER);
  125964. t || (t = new xb(e),
  125965. e._addComponent(t))
  125966. }
  125967. ;
  125968. Pt.ShadersStore.oitFinalPixelShader = "precision highp float;\nuniform sampler2D uFrontColor;\nuniform sampler2D uBackColor;\nvoid main() {\nivec2 fragCoord=ivec2(gl_FragCoord.xy);\nvec4 frontColor=texelFetch(uFrontColor,fragCoord,0);\nvec4 backColor=texelFetch(uBackColor,fragCoord,0);\nfloat alphaMultiplier=1.0-frontColor.a;\nglFragColor=vec4(\nfrontColor.rgb+alphaMultiplier*backColor.rgb,\nfrontColor.a+backColor.a\n);\n}";
  125969. Pt.ShadersStore.oitBackBlendPixelShader = "precision highp float;\nuniform sampler2D uBackColor;\nvoid main() {\nglFragColor=texelFetch(uBackColor,ivec2(gl_FragCoord.xy),0);\nif (glFragColor.a==0.0) { \ndiscard;\n}\n}";
  125970. var Rb = function() {
  125971. this.enabled = !0,
  125972. this.name = "depthPeeling",
  125973. this.texturesRequired = [a.PREPASS_COLOR_TEXTURE_TYPE]
  125974. }
  125975. , Cb = function() {
  125976. function e(t, i) {
  125977. if (void 0 === i && (i = 5),
  125978. this._thinTextures = [],
  125979. this._currentPingPongState = 0,
  125980. this._layoutCacheFormat = [[!0], [!0, !0], [!0, !0, !0]],
  125981. this._layoutCache = [],
  125982. this._candidateSubMeshes = new bi(10),
  125983. this._excludedSubMeshes = new bi(10),
  125984. this._colorCache = [new N(e._DEPTH_CLEAR_VALUE,e._DEPTH_CLEAR_VALUE,0,0), new N(-e._MIN_DEPTH,e._MAX_DEPTH,0,0), new N(0,0,0,0)],
  125985. this._scene = t,
  125986. this._engine = t.getEngine(),
  125987. this._passCount = i,
  125988. t.enablePrePassRenderer()) {
  125989. for (var n = 0; n < this._layoutCacheFormat.length; ++n)
  125990. this._layoutCache[n] = this._engine.buildTextureLayout(this._layoutCacheFormat[n]);
  125991. this._renderPassIds = [],
  125992. this.useRenderPasses = !1,
  125993. this._prePassEffectConfiguration = new Rb,
  125994. this._createTextures(),
  125995. this._createEffects()
  125996. } else
  125997. K.Warn("Depth peeling for order independant transparency could not enable PrePass, aborting.")
  125998. }
  125999. return Object.defineProperty(e.prototype, "passCount", {
  126000. get: function() {
  126001. return this._passCount
  126002. },
  126003. set: function(e) {
  126004. this._passCount !== e && (this._passCount = e,
  126005. this._createRenderPassIds())
  126006. },
  126007. enumerable: !1,
  126008. configurable: !0
  126009. }),
  126010. Object.defineProperty(e.prototype, "useRenderPasses", {
  126011. get: function() {
  126012. return this._useRenderPasses
  126013. },
  126014. set: function(e) {
  126015. this._useRenderPasses !== e && (this._useRenderPasses = e,
  126016. this._createRenderPassIds())
  126017. },
  126018. enumerable: !1,
  126019. configurable: !0
  126020. }),
  126021. e.prototype._createRenderPassIds = function() {
  126022. if (this._releaseRenderPassIds(),
  126023. this._useRenderPasses)
  126024. for (var e = 0; e < this._passCount + 1; ++e)
  126025. this._renderPassIds[e] || (this._renderPassIds[e] = this._engine.createRenderPassId("DepthPeelingRenderer - pass #".concat(e)))
  126026. }
  126027. ,
  126028. e.prototype._releaseRenderPassIds = function() {
  126029. for (var e = 0; e < this._renderPassIds.length; ++e)
  126030. this._engine.releaseRenderPassId(this._renderPassIds[e]);
  126031. this._renderPassIds = []
  126032. }
  126033. ,
  126034. e.prototype._createTextures = function() {
  126035. var e = {
  126036. width: this._engine.getRenderWidth(),
  126037. height: this._engine.getRenderHeight()
  126038. };
  126039. this._depthMrts = [new pm("depthPeelingDepth0",e,1,this._scene), new pm("depthPeelingDepth1",e,1,this._scene)],
  126040. this._colorMrts = [new pm("depthPeelingColor0",e,1,this._scene,{
  126041. generateDepthBuffer: !1
  126042. }), new pm("depthPeelingColor1",e,1,this._scene,{
  126043. generateDepthBuffer: !1
  126044. })],
  126045. this._blendBackMrt = new pm("depthPeelingBack",e,1,this._scene,{
  126046. generateDepthBuffer: !1
  126047. });
  126048. for (var t = [{
  126049. format: a.TEXTUREFORMAT_RG,
  126050. samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE,
  126051. type: this._engine.getCaps().textureFloatLinearFiltering ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT
  126052. }, {
  126053. format: a.TEXTUREFORMAT_RGBA,
  126054. samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE,
  126055. type: a.TEXTURETYPE_HALF_FLOAT
  126056. }], i = 0; i < 2; i++) {
  126057. var n = this._engine._createInternalTexture(e, t[0], !1)
  126058. , r = this._engine._createInternalTexture(e, t[1], !1)
  126059. , o = this._engine._createInternalTexture(e, t[1], !1);
  126060. this._depthMrts[i].setInternalTexture(n, 0),
  126061. this._depthMrts[i].setInternalTexture(r, 1),
  126062. this._depthMrts[i].setInternalTexture(o, 2),
  126063. this._colorMrts[i].setInternalTexture(r, 0),
  126064. this._colorMrts[i].setInternalTexture(o, 1),
  126065. this._thinTextures.push(new qr(n), new qr(r), new qr(o))
  126066. }
  126067. }
  126068. ,
  126069. e.prototype._disposeTextures = function() {
  126070. for (var e = 0; e < this._thinTextures.length; e++)
  126071. 6 !== e && this._thinTextures[e].dispose();
  126072. for (e = 0; e < 2; e++)
  126073. this._depthMrts[e].dispose(!0),
  126074. this._colorMrts[e].dispose(!0),
  126075. this._blendBackMrt.dispose(!0);
  126076. this._thinTextures = [],
  126077. this._colorMrts = [],
  126078. this._depthMrts = []
  126079. }
  126080. ,
  126081. e.prototype._updateTextures = function() {
  126082. return this._depthMrts[0].getSize().width === this._engine.getRenderWidth() && this._depthMrts[0].getSize().height === this._engine.getRenderHeight() || (this._disposeTextures(),
  126083. this._createTextures()),
  126084. this._updateTextureReferences()
  126085. }
  126086. ,
  126087. e.prototype._updateTextureReferences = function() {
  126088. var e, t = this._scene.prePassRenderer;
  126089. if (!t)
  126090. return !1;
  126091. var i = t.getIndex(a.PREPASS_COLOR_TEXTURE_TYPE)
  126092. , n = (null === (e = t.defaultRT.textures) || void 0 === e ? void 0 : e.length) ? t.defaultRT.textures[i].getInternalTexture() : null;
  126093. return !!n && (this._blendBackTexture !== n && (this._blendBackTexture = n,
  126094. this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0),
  126095. this._thinTextures[6] && this._thinTextures[6].dispose(),
  126096. this._thinTextures[6] = new qr(this._blendBackTexture),
  126097. t.defaultRT.renderTarget._shareDepth(this._depthMrts[0].renderTarget)),
  126098. !0)
  126099. }
  126100. ,
  126101. e.prototype._createEffects = function() {
  126102. this._blendBackEffectWrapper = new b_({
  126103. fragmentShader: "oitBackBlend",
  126104. useShaderStore: !0,
  126105. engine: this._engine,
  126106. samplerNames: ["uBackColor"],
  126107. uniformNames: []
  126108. }),
  126109. this._blendBackEffectWrapperPingPong = new b_({
  126110. fragmentShader: "oitBackBlend",
  126111. useShaderStore: !0,
  126112. engine: this._engine,
  126113. samplerNames: ["uBackColor"],
  126114. uniformNames: []
  126115. }),
  126116. this._finalEffectWrapper = new b_({
  126117. fragmentShader: "oitFinal",
  126118. useShaderStore: !0,
  126119. engine: this._engine,
  126120. samplerNames: ["uFrontColor", "uBackColor"],
  126121. uniformNames: []
  126122. }),
  126123. this._effectRenderer = new y_(this._engine)
  126124. }
  126125. ,
  126126. e.prototype.setPrePassRenderer = function(e) {
  126127. e.addEffectConfiguration(this._prePassEffectConfiguration)
  126128. }
  126129. ,
  126130. e.prototype.bind = function(e) {
  126131. e.setTexture("oitDepthSampler", this._thinTextures[3 * this._currentPingPongState]),
  126132. e.setTexture("oitFrontColorSampler", this._thinTextures[3 * this._currentPingPongState + 1])
  126133. }
  126134. ,
  126135. e.prototype._renderSubMeshes = function(e) {
  126136. var t;
  126137. this._useRenderPasses && (t = {});
  126138. for (var i = 0; i < e.length; i++) {
  126139. var n = e.data[i].getMaterial()
  126140. , r = !0
  126141. , o = !1
  126142. , a = e.data[i]
  126143. , s = void 0
  126144. , l = !1;
  126145. if (this._useRenderPasses && (l = !(s = a._getDrawWrapper())),
  126146. n && (r = n.allowShaderHotSwapping,
  126147. o = n.backFaceCulling,
  126148. n.allowShaderHotSwapping = !1,
  126149. n.backFaceCulling = !1),
  126150. a.render(!1),
  126151. l && (s = a._getDrawWrapper()).materialContext) {
  126152. var c = t[s.materialContext.uniqueId];
  126153. c || (c = t[s.materialContext.uniqueId] = this._engine.createMaterialContext()),
  126154. a._getDrawWrapper().materialContext = c
  126155. }
  126156. n && (n.allowShaderHotSwapping = r,
  126157. n.backFaceCulling = o)
  126158. }
  126159. }
  126160. ,
  126161. e.prototype._finalCompose = function(e) {
  126162. this._engine.restoreDefaultFramebuffer(),
  126163. this._engine.setAlphaMode(a.ALPHA_DISABLE),
  126164. this._engine.applyStates(),
  126165. this._engine.enableEffect(this._finalEffectWrapper._drawWrapper),
  126166. this._finalEffectWrapper.effect.setTexture("uFrontColor", this._thinTextures[3 * e + 1]),
  126167. this._finalEffectWrapper.effect.setTexture("uBackColor", this._thinTextures[6]),
  126168. this._effectRenderer.render(this._finalEffectWrapper)
  126169. }
  126170. ,
  126171. e.prototype.render = function(e) {
  126172. if (this._candidateSubMeshes.length = 0,
  126173. this._excludedSubMeshes.length = 0,
  126174. !(this._blendBackEffectWrapper.effect.isReady() && this._blendBackEffectWrapperPingPong.effect.isReady() && this._finalEffectWrapper.effect.isReady() && this._updateTextures()))
  126175. return this._excludedSubMeshes;
  126176. for (var t = 0; t < e.length; t++) {
  126177. var i = e.data[t].getMaterial();
  126178. !i || i.fillMode !== Or.TriangleFanDrawMode && i.fillMode !== Or.TriangleFillMode && i.fillMode !== Or.TriangleStripDrawMode ? this._excludedSubMeshes.push(e.data[t]) : this._candidateSubMeshes.push(e.data[t])
  126179. }
  126180. if (!this._candidateSubMeshes.length)
  126181. return this._finalCompose(1),
  126182. this._excludedSubMeshes;
  126183. var n = this._engine.currentRenderPassId;
  126184. this._scene.prePassRenderer._enabled = !1,
  126185. this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[0]),
  126186. this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),
  126187. this._engine.bindAttachments(this._layoutCache[0]),
  126188. this._engine.clear(this._colorCache[0], !0, !1, !1),
  126189. this._engine.bindFramebuffer(this._depthMrts[1].renderTarget),
  126190. this._engine.bindAttachments(this._layoutCache[0]),
  126191. this._engine.clear(this._colorCache[1], !0, !1, !1),
  126192. this._engine.bindFramebuffer(this._colorMrts[0].renderTarget),
  126193. this._engine.bindAttachments(this._layoutCache[1]),
  126194. this._engine.clear(this._colorCache[2], !0, !1, !1),
  126195. this._engine.bindFramebuffer(this._colorMrts[1].renderTarget),
  126196. this._engine.bindAttachments(this._layoutCache[1]),
  126197. this._engine.clear(this._colorCache[2], !0, !1, !1),
  126198. this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),
  126199. this._engine.bindAttachments(this._layoutCache[0]),
  126200. this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE),
  126201. this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX),
  126202. this._engine.depthCullingState.depthMask = !1,
  126203. this._engine.depthCullingState.depthTest = !0,
  126204. this._engine.applyStates(),
  126205. this._currentPingPongState = 1,
  126206. this._renderSubMeshes(this._candidateSubMeshes),
  126207. this._scene.resetCachedMaterial();
  126208. var r = 0
  126209. , o = 0;
  126210. for (t = 0; t < this._passCount; t++) {
  126211. o = 1 - (r = t % 2),
  126212. this._currentPingPongState = r,
  126213. this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[t + 1]),
  126214. this._engine.bindFramebuffer(this._depthMrts[o].renderTarget),
  126215. this._engine.bindAttachments(this._layoutCache[0]),
  126216. this._engine.clear(this._colorCache[0], !0, !1, !1),
  126217. this._engine.bindFramebuffer(this._colorMrts[o].renderTarget),
  126218. this._engine.bindAttachments(this._layoutCache[1]),
  126219. this._engine.clear(this._colorCache[2], !0, !1, !1),
  126220. this._engine.bindFramebuffer(this._depthMrts[o].renderTarget),
  126221. this._engine.bindAttachments(this._layoutCache[2]),
  126222. this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE),
  126223. this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX),
  126224. this._engine.depthCullingState.depthTest = !1,
  126225. this._engine.applyStates(),
  126226. this._renderSubMeshes(this._candidateSubMeshes),
  126227. this._scene.resetCachedMaterial(),
  126228. this._engine.bindFramebuffer(this._blendBackMrt.renderTarget),
  126229. this._engine.bindAttachments(this._layoutCache[0]),
  126230. this._engine.setAlphaEquation(a.ALPHA_EQUATION_ADD),
  126231. this._engine.setAlphaMode(a.ALPHA_LAYER_ACCUMULATE),
  126232. this._engine.applyStates();
  126233. var s = 0 !== o && this._useRenderPasses ? this._blendBackEffectWrapperPingPong : this._blendBackEffectWrapper;
  126234. this._engine.enableEffect(s._drawWrapper),
  126235. s.effect.setTexture("uBackColor", this._thinTextures[3 * o + 2]),
  126236. this._effectRenderer.render(s)
  126237. }
  126238. return this._engine.currentRenderPassId = n,
  126239. this._finalCompose(o),
  126240. this._scene.prePassRenderer._enabled = !0,
  126241. this._engine.depthCullingState.depthMask = !0,
  126242. this._engine.depthCullingState.depthTest = !0,
  126243. this._excludedSubMeshes
  126244. }
  126245. ,
  126246. e.prototype.dispose = function() {
  126247. this._disposeTextures(),
  126248. this._blendBackEffectWrapper.dispose(),
  126249. this._finalEffectWrapper.dispose(),
  126250. this._effectRenderer.dispose(),
  126251. this._releaseRenderPassIds()
  126252. }
  126253. ,
  126254. e._DEPTH_CLEAR_VALUE = -99999,
  126255. e._MIN_DEPTH = 0,
  126256. e._MAX_DEPTH = 1,
  126257. e
  126258. }();
  126259. Object.defineProperty(mn.prototype, "depthPeelingRenderer", {
  126260. get: function() {
  126261. if (!this._depthPeelingRenderer) {
  126262. var e = this._getComponent(Wi.NAME_DEPTHPEELINGRENDERER);
  126263. e || (e = new Pb(this),
  126264. this._addComponent(e))
  126265. }
  126266. return this._depthPeelingRenderer
  126267. },
  126268. set: function(e) {
  126269. this._depthPeelingRenderer = e
  126270. },
  126271. enumerable: !0,
  126272. configurable: !0
  126273. }),
  126274. Object.defineProperty(mn.prototype, "useOrderIndependentTransparency", {
  126275. get: function() {
  126276. return this._useOrderIndependentTransparency
  126277. },
  126278. set: function(e) {
  126279. var t;
  126280. this._useOrderIndependentTransparency !== e && (this._useOrderIndependentTransparency = e,
  126281. this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag),
  126282. null === (t = this.prePassRenderer) || void 0 === t || t.markAsDirty())
  126283. },
  126284. enumerable: !0,
  126285. configurable: !0
  126286. });
  126287. var Pb = function() {
  126288. function e(e) {
  126289. this.name = Wi.NAME_DEPTHPEELINGRENDERER,
  126290. this.scene = e,
  126291. e.depthPeelingRenderer = new Cb(e)
  126292. }
  126293. return e.prototype.register = function() {}
  126294. ,
  126295. e.prototype.rebuild = function() {}
  126296. ,
  126297. e.prototype.dispose = function() {
  126298. var e;
  126299. null === (e = this.scene.depthPeelingRenderer) || void 0 === e || e.dispose(),
  126300. this.scene.depthPeelingRenderer = null
  126301. }
  126302. ,
  126303. e
  126304. }();
  126305. Pt.ShadersStore.linePixelShader = "#include<clipPlaneFragmentDeclaration>\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  126306. Pt.ShadersStore.lineVertexShader = "#include<instancesDeclaration>\n#include<clipPlaneVertexDeclaration>\nattribute vec3 position;\nattribute vec4 normal;\nuniform mat4 viewProjection;\nuniform float width;\nuniform float aspectRatio;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\nmat4 worldViewProjection=viewProjection*finalWorld;\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<clipPlaneVertex>\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}",
  126307. Sr.prototype.disableEdgesRendering = function() {
  126308. return this._edgesRenderer && (this._edgesRenderer.dispose(),
  126309. this._edgesRenderer = null),
  126310. this
  126311. }
  126312. ,
  126313. Sr.prototype.enableEdgesRendering = function(e, t, i) {
  126314. return void 0 === e && (e = .95),
  126315. void 0 === t && (t = !1),
  126316. this.disableEdgesRendering(),
  126317. this._edgesRenderer = new Ib(this,e,t,!0,i),
  126318. this
  126319. }
  126320. ,
  126321. Object.defineProperty(Sr.prototype, "edgesRenderer", {
  126322. get: function() {
  126323. return this._edgesRenderer
  126324. },
  126325. enumerable: !0,
  126326. configurable: !0
  126327. }),
  126328. Yl.prototype.enableEdgesRendering = function(e, t) {
  126329. return void 0 === e && (e = .95),
  126330. void 0 === t && (t = !1),
  126331. this.disableEdgesRendering(),
  126332. this._edgesRenderer = new Ob(this,e,t),
  126333. this
  126334. }
  126335. ,
  126336. Kl.prototype.enableEdgesRendering = function(e, t) {
  126337. return void 0 === e && (e = .95),
  126338. void 0 === t && (t = !1),
  126339. Yl.prototype.enableEdgesRendering.apply(this, arguments),
  126340. this
  126341. }
  126342. ;
  126343. var Mb = function() {
  126344. this.edges = new Array,
  126345. this.edgesConnectedCount = 0
  126346. }
  126347. , Ib = function() {
  126348. function e(e, t, i, n, r) {
  126349. void 0 === t && (t = .95),
  126350. void 0 === i && (i = !1),
  126351. void 0 === n && (n = !0);
  126352. var o, a = this;
  126353. this.edgesWidthScalerForOrthographic = 1e3,
  126354. this.edgesWidthScalerForPerspective = 50,
  126355. this._linesPositions = new Array,
  126356. this._linesNormals = new Array,
  126357. this._linesIndices = new Array,
  126358. this._buffers = {},
  126359. this._buffersForInstances = {},
  126360. this._checkVerticesInsteadOfIndices = !1,
  126361. this.isEnabled = !0,
  126362. this.customInstances = new bi(32),
  126363. this._source = e,
  126364. this._checkVerticesInsteadOfIndices = i,
  126365. this._options = null != r ? r : null,
  126366. this._epsilon = t,
  126367. this._source.getScene().getEngine().isWebGPU && (this._drawWrapper = new Gt(e.getEngine())),
  126368. this._prepareRessources(),
  126369. n && (null === (o = null == r ? void 0 : r.useAlternateEdgeFinder) || void 0 === o || o ? this._generateEdgesLinesAlternate() : this._generateEdgesLines()),
  126370. this._meshRebuildObserver = this._source.onRebuildObservable.add((function() {
  126371. a._rebuild()
  126372. }
  126373. )),
  126374. this._meshDisposeObserver = this._source.onDisposeObservable.add((function() {
  126375. a.dispose()
  126376. }
  126377. ))
  126378. }
  126379. return Object.defineProperty(e.prototype, "linesPositions", {
  126380. get: function() {
  126381. return this._linesPositions
  126382. },
  126383. enumerable: !1,
  126384. configurable: !0
  126385. }),
  126386. Object.defineProperty(e.prototype, "linesNormals", {
  126387. get: function() {
  126388. return this._linesNormals
  126389. },
  126390. enumerable: !1,
  126391. configurable: !0
  126392. }),
  126393. Object.defineProperty(e.prototype, "linesIndices", {
  126394. get: function() {
  126395. return this._linesIndices
  126396. },
  126397. enumerable: !1,
  126398. configurable: !0
  126399. }),
  126400. Object.defineProperty(e.prototype, "lineShader", {
  126401. get: function() {
  126402. return this._lineShader
  126403. },
  126404. set: function(e) {
  126405. this._lineShader = e
  126406. },
  126407. enumerable: !1,
  126408. configurable: !0
  126409. }),
  126410. e._GetShader = function(e) {
  126411. if (!e._edgeRenderLineShader) {
  126412. var t = new jl("lineShader",e,"line",{
  126413. attributes: ["position", "normal"],
  126414. uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"]
  126415. },!1);
  126416. t.disableDepthWrite = !0,
  126417. t.backFaceCulling = !1,
  126418. t.checkReadyOnEveryCall = e.getEngine().isWebGPU,
  126419. e._edgeRenderLineShader = t
  126420. }
  126421. return e._edgeRenderLineShader
  126422. }
  126423. ,
  126424. e.prototype._prepareRessources = function() {
  126425. this._lineShader || (this._lineShader = e._GetShader(this._source.getScene()))
  126426. }
  126427. ,
  126428. e.prototype._rebuild = function() {
  126429. var e = this._buffers[Bi.PositionKind];
  126430. e && e._rebuild(),
  126431. (e = this._buffers[Bi.NormalKind]) && e._rebuild();
  126432. var t = this._source.getScene().getEngine();
  126433. this._ib = t.createIndexBuffer(this._linesIndices)
  126434. }
  126435. ,
  126436. e.prototype.dispose = function() {
  126437. var e;
  126438. this._source.onRebuildObservable.remove(this._meshRebuildObserver),
  126439. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  126440. var t = this._buffers[Bi.PositionKind];
  126441. t && (t.dispose(),
  126442. this._buffers[Bi.PositionKind] = null),
  126443. (t = this._buffers[Bi.NormalKind]) && (t.dispose(),
  126444. this._buffers[Bi.NormalKind] = null),
  126445. this._ib && this._source.getScene().getEngine()._releaseBuffer(this._ib),
  126446. this._lineShader.dispose(),
  126447. null === (e = this._drawWrapper) || void 0 === e || e.dispose()
  126448. }
  126449. ,
  126450. e.prototype._processEdgeForAdjacencies = function(e, t, i, n, r) {
  126451. return e === i && t === n || e === n && t === i ? 0 : e === n && t === r || e === r && t === n ? 1 : e === r && t === i || e === i && t === r ? 2 : -1
  126452. }
  126453. ,
  126454. e.prototype._processEdgeForAdjacenciesWithVertices = function(e, t, i, n, r) {
  126455. var o = 1e-10;
  126456. return e.equalsWithEpsilon(i, o) && t.equalsWithEpsilon(n, o) || e.equalsWithEpsilon(n, o) && t.equalsWithEpsilon(i, o) ? 0 : e.equalsWithEpsilon(n, o) && t.equalsWithEpsilon(r, o) || e.equalsWithEpsilon(r, o) && t.equalsWithEpsilon(n, o) ? 1 : e.equalsWithEpsilon(r, o) && t.equalsWithEpsilon(i, o) || e.equalsWithEpsilon(i, o) && t.equalsWithEpsilon(r, o) ? 2 : -1
  126457. }
  126458. ,
  126459. e.prototype._checkEdge = function(e, t, i, n, r) {
  126460. (void 0 === t || x.Dot(i[e], i[t]) < this._epsilon) && this.createLine(n, r, this._linesPositions.length / 3)
  126461. }
  126462. ,
  126463. e.prototype.createLine = function(e, t, i) {
  126464. this._linesPositions.push(e.x, e.y, e.z, e.x, e.y, e.z, t.x, t.y, t.z, t.x, t.y, t.z),
  126465. this._linesNormals.push(t.x, t.y, t.z, -1, t.x, t.y, t.z, 1, e.x, e.y, e.z, -1, e.x, e.y, e.z, 1),
  126466. this._linesIndices.push(i, i + 1, i + 2, i, i + 2, i + 3)
  126467. }
  126468. ,
  126469. e.prototype._tessellateTriangle = function(e, t, i, n) {
  126470. var r = function(e, t, i) {
  126471. i >= 0 && t.push(i);
  126472. for (var n = 0; n < e.length; ++n)
  126473. t.push(e[n][0])
  126474. }
  126475. , o = 0;
  126476. e[1].length >= e[0].length && e[1].length >= e[2].length ? o = 1 : e[2].length >= e[0].length && e[2].length >= e[1].length && (o = 2);
  126477. for (var a = 0; a < 3; ++a)
  126478. a === o ? e[a].sort((function(e, t) {
  126479. return e[1] < t[1] ? -1 : e[1] > t[1] ? 1 : 0
  126480. }
  126481. )) : e[a].sort((function(e, t) {
  126482. return e[1] > t[1] ? -1 : e[1] < t[1] ? 1 : 0
  126483. }
  126484. ));
  126485. var s = []
  126486. , l = [];
  126487. r(e[o], s, -1);
  126488. for (var c = s.length, u = o + 2; u >= o + 1; --u)
  126489. r(e[u % 3], l, u !== o + 2 ? n[i[t + (u + 1) % 3]] : -1);
  126490. var h = l.length;
  126491. i.push(n[i[t + o]], s[0], l[0]),
  126492. i.push(n[i[t + (o + 1) % 3]], l[h - 1], s[c - 1]);
  126493. for (var d = c <= h, p = d ? c : h, f = d ? h : c, _ = d ? c - 1 : h - 1, m = d ? 0 : 1, g = c + h - 2, v = 0, y = 0, b = d ? s : l, T = d ? l : s, E = 0; g-- > 0; ) {
  126494. m ? i.push(b[v], T[y]) : i.push(T[y], b[v]);
  126495. var S = void 0;
  126496. (E += p) >= f && v < _ ? (S = b[++v],
  126497. E -= f) : S = T[++y],
  126498. i.push(S)
  126499. }
  126500. i[t + 0] = i[i.length - 3],
  126501. i[t + 1] = i[i.length - 2],
  126502. i[t + 2] = i[i.length - 1],
  126503. i.length = i.length - 3
  126504. }
  126505. ,
  126506. e.prototype._generateEdgesLinesAlternate = function() {
  126507. var e, t, i, n, r, o, a, s, l, c, u = this._source.getVerticesData(Bi.PositionKind), h = this._source.getIndices();
  126508. if (h && u) {
  126509. Array.isArray(h) || (h = gi.SliceToArray(h));
  126510. var d = null === (t = null === (e = this._options) || void 0 === e ? void 0 : e.useFastVertexMerger) || void 0 === t || t
  126511. , p = d ? Math.round(-Math.log(null !== (n = null === (i = this._options) || void 0 === i ? void 0 : i.epsilonVertexMerge) && void 0 !== n ? n : 1e-6) / Math.log(10)) : null !== (o = null === (r = this._options) || void 0 === r ? void 0 : r.epsilonVertexMerge) && void 0 !== o ? o : 1e-6
  126512. , f = []
  126513. , _ = [];
  126514. if (d)
  126515. for (var m = {}, g = 0; g < u.length; g += 3) {
  126516. var v = u[g + 0]
  126517. , y = u[g + 1]
  126518. , b = u[g + 2];
  126519. if (void 0 !== m[ie = v.toFixed(p) + "|" + y.toFixed(p) + "|" + b.toFixed(p)])
  126520. f.push(m[ie]);
  126521. else {
  126522. var T = g / 3;
  126523. m[ie] = T,
  126524. f.push(T),
  126525. _.push(T)
  126526. }
  126527. }
  126528. else
  126529. for (g = 0; g < u.length; g += 3) {
  126530. v = u[g + 0],
  126531. y = u[g + 1],
  126532. b = u[g + 2];
  126533. for (var E = !1, S = 0; S < g && !E; S += 3) {
  126534. var A = u[S + 0]
  126535. , R = u[S + 1]
  126536. , C = u[S + 2];
  126537. if (Math.abs(v - A) < p && Math.abs(y - R) < p && Math.abs(b - C) < p) {
  126538. f.push(S / 3),
  126539. E = !0;
  126540. break
  126541. }
  126542. }
  126543. E || (f.push(g / 3),
  126544. _.push(g / 3))
  126545. }
  126546. if (null === (a = this._options) || void 0 === a ? void 0 : a.applyTessellation) {
  126547. for (var P = null !== (l = null === (s = this._options) || void 0 === s ? void 0 : s.epsilonVertexAligned) && void 0 !== l ? l : 1e-6, M = [], O = 0; O < h.length; O += 3)
  126548. for (var D = void 0, N = 0; N < 3; ++N) {
  126549. var L = f[h[O + N]]
  126550. , F = f[h[O + (N + 1) % 3]]
  126551. , w = f[h[O + (N + 2) % 3]];
  126552. if (L !== F)
  126553. for (var B = u[3 * L + 0], U = u[3 * L + 1], V = u[3 * L + 2], k = u[3 * F + 0], G = u[3 * F + 1], z = u[3 * F + 2], W = Math.sqrt((k - B) * (k - B) + (G - U) * (G - U) + (z - V) * (z - V)), H = 0; H < _.length - 1; H++) {
  126554. var X = _[H];
  126555. if (X !== L && X !== F && X !== w) {
  126556. var j = u[3 * X + 0]
  126557. , Y = u[3 * X + 1]
  126558. , K = u[3 * X + 2]
  126559. , Q = Math.sqrt((j - B) * (j - B) + (Y - U) * (Y - U) + (K - V) * (K - V))
  126560. , q = Math.sqrt((j - k) * (j - k) + (Y - G) * (Y - G) + (K - z) * (K - z));
  126561. Math.abs(Q + q - W) < P && (D || (D = {
  126562. index: O,
  126563. edgesPoints: [[], [], []]
  126564. },
  126565. M.push(D)),
  126566. D.edgesPoints[N].push([X, Q]))
  126567. }
  126568. }
  126569. }
  126570. for (var Z = 0; Z < M.length; ++Z) {
  126571. var J = M[Z];
  126572. this._tessellateTriangle(J.edgesPoints, J.index, h, f)
  126573. }
  126574. M = null
  126575. }
  126576. var $ = {};
  126577. for (O = 0; O < h.length; O += 3) {
  126578. var ee = void 0;
  126579. for (N = 0; N < 3; ++N)
  126580. if (L = f[h[O + N]],
  126581. F = f[h[O + (N + 1) % 3]],
  126582. w = f[h[O + (N + 2) % 3]],
  126583. L !== F && (L !== w && F !== w || !(null === (c = this._options) || void 0 === c ? void 0 : c.removeDegeneratedTriangles))) {
  126584. if (I.Vector3[0].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]),
  126585. I.Vector3[1].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]),
  126586. I.Vector3[2].copyFromFloats(u[3 * w + 0], u[3 * w + 1], u[3 * w + 2]),
  126587. ee || (I.Vector3[1].subtractToRef(I.Vector3[0], I.Vector3[3]),
  126588. I.Vector3[2].subtractToRef(I.Vector3[1], I.Vector3[4]),
  126589. (ee = x.Cross(I.Vector3[3], I.Vector3[4])).normalize()),
  126590. L > F) {
  126591. var te = L;
  126592. L = F,
  126593. F = te
  126594. }
  126595. (ne = $[ie = L + "_" + F]) ? ne.done || (x.Dot(ee, ne.normal) < this._epsilon && this.createLine(I.Vector3[0], I.Vector3[1], this._linesPositions.length / 3),
  126596. ne.done = !0) : $[ie] = {
  126597. normal: ee,
  126598. done: !1,
  126599. index: O,
  126600. i: N
  126601. }
  126602. }
  126603. }
  126604. for (var ie in $) {
  126605. var ne;
  126606. (ne = $[ie]).done || (L = f[h[ne.index + ne.i]],
  126607. F = f[h[ne.index + (ne.i + 1) % 3]],
  126608. I.Vector3[0].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]),
  126609. I.Vector3[1].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]),
  126610. this.createLine(I.Vector3[0], I.Vector3[1], this._linesPositions.length / 3))
  126611. }
  126612. var re = this._source.getScene().getEngine();
  126613. this._buffers[Bi.PositionKind] = new Bi(re,this._linesPositions,Bi.PositionKind,!1),
  126614. this._buffers[Bi.NormalKind] = new Bi(re,this._linesNormals,Bi.NormalKind,!1,!1,4),
  126615. this._buffersForInstances[Bi.PositionKind] = this._buffers[Bi.PositionKind],
  126616. this._buffersForInstances[Bi.NormalKind] = this._buffers[Bi.NormalKind],
  126617. this._ib = re.createIndexBuffer(this._linesIndices),
  126618. this._indicesCount = this._linesIndices.length
  126619. }
  126620. }
  126621. ,
  126622. e.prototype._generateEdgesLines = function() {
  126623. var e = this._source.getVerticesData(Bi.PositionKind)
  126624. , t = this._source.getIndices();
  126625. if (t && e) {
  126626. var i, n, r = new Array, o = new Array;
  126627. for (i = 0; i < t.length; i += 3) {
  126628. n = new Mb;
  126629. var a = t[i]
  126630. , s = t[i + 1]
  126631. , l = t[i + 2];
  126632. n.p0 = new x(e[3 * a],e[3 * a + 1],e[3 * a + 2]),
  126633. n.p1 = new x(e[3 * s],e[3 * s + 1],e[3 * s + 2]),
  126634. n.p2 = new x(e[3 * l],e[3 * l + 1],e[3 * l + 2]);
  126635. var c = x.Cross(n.p1.subtract(n.p0), n.p2.subtract(n.p1));
  126636. c.normalize(),
  126637. o.push(c),
  126638. r.push(n)
  126639. }
  126640. for (i = 0; i < r.length; i++) {
  126641. n = r[i];
  126642. for (var u = i + 1; u < r.length; u++) {
  126643. var h = r[u];
  126644. if (3 === n.edgesConnectedCount)
  126645. break;
  126646. if (3 !== h.edgesConnectedCount)
  126647. for (var d = t[3 * u], p = t[3 * u + 1], f = t[3 * u + 2], _ = 0; _ < 3; _++) {
  126648. var m = 0;
  126649. if (void 0 === n.edges[_]) {
  126650. switch (_) {
  126651. case 0:
  126652. m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p0, n.p1, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i], t[3 * i + 1], d, p, f);
  126653. break;
  126654. case 1:
  126655. m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p1, n.p2, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 1], t[3 * i + 2], d, p, f);
  126656. break;
  126657. case 2:
  126658. m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p2, n.p0, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 2], t[3 * i], d, p, f)
  126659. }
  126660. if (-1 !== m && (n.edges[_] = u,
  126661. h.edges[m] = i,
  126662. n.edgesConnectedCount++,
  126663. h.edgesConnectedCount++,
  126664. 3 === n.edgesConnectedCount))
  126665. break
  126666. }
  126667. }
  126668. }
  126669. }
  126670. for (i = 0; i < r.length; i++) {
  126671. var g = r[i];
  126672. this._checkEdge(i, g.edges[0], o, g.p0, g.p1),
  126673. this._checkEdge(i, g.edges[1], o, g.p1, g.p2),
  126674. this._checkEdge(i, g.edges[2], o, g.p2, g.p0)
  126675. }
  126676. var v = this._source.getScene().getEngine();
  126677. this._buffers[Bi.PositionKind] = new Bi(v,this._linesPositions,Bi.PositionKind,!1),
  126678. this._buffers[Bi.NormalKind] = new Bi(v,this._linesNormals,Bi.NormalKind,!1,!1,4),
  126679. this._buffersForInstances[Bi.PositionKind] = this._buffers[Bi.PositionKind],
  126680. this._buffersForInstances[Bi.NormalKind] = this._buffers[Bi.NormalKind],
  126681. this._ib = v.createIndexBuffer(this._linesIndices),
  126682. this._indicesCount = this._linesIndices.length
  126683. }
  126684. }
  126685. ,
  126686. e.prototype.isReady = function() {
  126687. return this._lineShader.isReady(this._source, this._source.hasInstances && this.customInstances.length > 0 || this._source.hasThinInstances)
  126688. }
  126689. ,
  126690. e.prototype.render = function() {
  126691. var e = this._source.getScene()
  126692. , t = this._lineShader._getDrawWrapper();
  126693. if (this._drawWrapper && this._lineShader._setDrawWrapper(this._drawWrapper),
  126694. this.isReady() && e.activeCamera) {
  126695. var i = this._source.hasInstances && this.customInstances.length > 0
  126696. , n = i || this._source.hasThinInstances
  126697. , r = 0;
  126698. if (n)
  126699. if (this._buffersForInstances.world0 = this._source.getVertexBuffer("world0"),
  126700. this._buffersForInstances.world1 = this._source.getVertexBuffer("world1"),
  126701. this._buffersForInstances.world2 = this._source.getVertexBuffer("world2"),
  126702. this._buffersForInstances.world3 = this._source.getVertexBuffer("world3"),
  126703. i) {
  126704. var o = this._source._instanceDataStorage;
  126705. if (r = this.customInstances.length,
  126706. !o.instancesData)
  126707. return void (this._source.getScene()._activeMeshesFrozen || this.customInstances.reset());
  126708. if (!o.isFrozen) {
  126709. for (var s = 0, l = 0; l < r; ++l)
  126710. this.customInstances.data[l].copyToArray(o.instancesData, s),
  126711. s += 16;
  126712. o.instancesBuffer.updateDirectly(o.instancesData, 0, r)
  126713. }
  126714. } else
  126715. r = this._source.thinInstanceCount;
  126716. var c = e.getEngine();
  126717. this._lineShader._preBind(),
  126718. 1 !== this._source.edgesColor.a ? c.setAlphaMode(a.ALPHA_COMBINE) : c.setAlphaMode(a.ALPHA_DISABLE),
  126719. c.bindBuffers(n ? this._buffersForInstances : this._buffers, this._ib, this._lineShader.getEffect()),
  126720. e.resetCachedMaterial(),
  126721. this._lineShader.setColor4("color", this._source.edgesColor),
  126722. e.activeCamera.mode === Rr.ORTHOGRAPHIC_CAMERA ? this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic) : this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective),
  126723. this._lineShader.setFloat("aspectRatio", c.getAspectRatio(e.activeCamera)),
  126724. this._lineShader.bind(this._source.getWorldMatrix()),
  126725. c.drawElementsType(Or.TriangleFillMode, 0, this._indicesCount, r),
  126726. this._lineShader.unbind(),
  126727. n && c.unbindInstanceAttributes(),
  126728. this._source.getScene()._activeMeshesFrozen || this.customInstances.reset(),
  126729. this._lineShader._setDrawWrapper(t)
  126730. } else
  126731. this._lineShader._setDrawWrapper(t)
  126732. }
  126733. ,
  126734. e
  126735. }()
  126736. , Ob = function(e) {
  126737. function t(t, i, n) {
  126738. void 0 === i && (i = .95),
  126739. void 0 === n && (n = !1);
  126740. var r = e.call(this, t, i, n, !1) || this;
  126741. return r._generateEdgesLines(),
  126742. r
  126743. }
  126744. return U(t, e),
  126745. t.prototype._generateEdgesLines = function() {
  126746. var e = this._source.getVerticesData(Bi.PositionKind)
  126747. , t = this._source.getIndices();
  126748. if (t && e) {
  126749. for (var i = I.Vector3[0], n = I.Vector3[1], r = t.length - 1, o = 0, a = 0; o < r; o += 2,
  126750. a += 4)
  126751. x.FromArrayToRef(e, 3 * t[o], i),
  126752. x.FromArrayToRef(e, 3 * t[o + 1], n),
  126753. this.createLine(i, n, a);
  126754. var s = this._source.getScene().getEngine();
  126755. this._buffers[Bi.PositionKind] = new Bi(s,this._linesPositions,Bi.PositionKind,!1),
  126756. this._buffers[Bi.NormalKind] = new Bi(s,this._linesNormals,Bi.NormalKind,!1,!1,4),
  126757. this._ib = s.createIndexBuffer(this._linesIndices),
  126758. this._indicesCount = this._linesIndices.length
  126759. }
  126760. }
  126761. ,
  126762. t
  126763. }(Ib)
  126764. , Db = function(e) {
  126765. function t(t, i, n, r, o, a) {
  126766. var s = e.call(this, t, n, r, o, a) || this;
  126767. return s._beforeCompositionPostProcesses = [],
  126768. s._internalTextureDirty = !1,
  126769. s.enabled = !1,
  126770. s.renderTargetTexture = null,
  126771. s.renderTargetTexture = i,
  126772. s
  126773. }
  126774. return U(t, e),
  126775. t.prototype._createCompositionEffect = function() {
  126776. this.imageProcessingPostProcess = new Fs("prePassComposition",1,null,void 0,this._engine),
  126777. this.imageProcessingPostProcess._updateParameters()
  126778. }
  126779. ,
  126780. t.prototype._checkSize = function() {
  126781. var e = this._engine.getRenderWidth(!0)
  126782. , t = this._engine.getRenderHeight(!0)
  126783. , i = this.getRenderWidth()
  126784. , n = this.getRenderHeight();
  126785. i === e && n === t || (this.resize({
  126786. width: e,
  126787. height: t
  126788. }),
  126789. this._internalTextureDirty = !0)
  126790. }
  126791. ,
  126792. t.prototype.updateCount = function(t, i, n) {
  126793. e.prototype.updateCount.call(this, t, i, n),
  126794. this._internalTextureDirty = !0
  126795. }
  126796. ,
  126797. t.prototype._resetPostProcessChain = function() {
  126798. this._beforeCompositionPostProcesses = []
  126799. }
  126800. ,
  126801. t.prototype.dispose = function() {
  126802. var t = this._scene;
  126803. if (e.prototype.dispose.call(this),
  126804. t && t.prePassRenderer) {
  126805. var i = t.prePassRenderer.renderTargets.indexOf(this);
  126806. -1 !== i && t.prePassRenderer.renderTargets.splice(i, 1)
  126807. }
  126808. this.imageProcessingPostProcess && this.imageProcessingPostProcess.dispose(),
  126809. this.renderTargetTexture && (this.renderTargetTexture._prePassRenderTarget = null),
  126810. this._outputPostProcess && (this._outputPostProcess.autoClear = !0,
  126811. this._outputPostProcess.restoreDefaultInputTexture())
  126812. }
  126813. ,
  126814. t
  126815. }(pm)
  126816. , Nb = function() {
  126817. function e(t) {
  126818. this.excludedSkinnedMesh = [],
  126819. this.excludedMaterials = [],
  126820. this.mrtCount = 0,
  126821. this._mrtFormats = [],
  126822. this._mrtLayout = [],
  126823. this._mrtNames = [],
  126824. this._textureIndices = [],
  126825. this._isDirty = !0,
  126826. this._effectConfigurations = [],
  126827. this.doNotUseGeometryRendererFallback = !0,
  126828. this.renderTargets = [],
  126829. this._clearColor = new N(0,0,0,0),
  126830. this._enabled = !1,
  126831. this._needsCompositionForThisPass = !1,
  126832. this.disableGammaTransform = !1,
  126833. this._scene = t,
  126834. this._engine = t.getEngine(),
  126835. e._SceneComponentInitialization(this._scene),
  126836. this.defaultRT = this._createRenderTarget("sceneprePassRT", null),
  126837. this._currentTarget = this.defaultRT
  126838. }
  126839. return e.prototype.getIndex = function(e) {
  126840. return this._textureIndices[e]
  126841. }
  126842. ,
  126843. Object.defineProperty(e.prototype, "samples", {
  126844. get: function() {
  126845. return this.defaultRT.samples
  126846. },
  126847. set: function(e) {
  126848. this.defaultRT.samples = e
  126849. },
  126850. enumerable: !1,
  126851. configurable: !0
  126852. }),
  126853. e.prototype.getRenderTarget = function() {
  126854. return this._currentTarget
  126855. }
  126856. ,
  126857. e.prototype._setRenderTarget = function(e) {
  126858. this._currentTarget = e || this.defaultRT,
  126859. this._engine.currentRenderPassId = this._currentTarget.renderPassId
  126860. }
  126861. ,
  126862. Object.defineProperty(e.prototype, "currentRTisSceneRT", {
  126863. get: function() {
  126864. return this._currentTarget === this.defaultRT
  126865. },
  126866. enumerable: !1,
  126867. configurable: !0
  126868. }),
  126869. e.prototype._refreshGeometryBufferRendererLink = function() {
  126870. if (this.doNotUseGeometryRendererFallback)
  126871. this._geometryBuffer && this._geometryBuffer._unlinkPrePassRenderer(),
  126872. this._geometryBuffer = null,
  126873. this._scene.disableGeometryBufferRenderer();
  126874. else {
  126875. if (this._geometryBuffer = this._scene.enableGeometryBufferRenderer(),
  126876. !this._geometryBuffer)
  126877. return void (this.doNotUseGeometryRendererFallback = !0);
  126878. this._geometryBuffer._linkPrePassRenderer(this)
  126879. }
  126880. }
  126881. ,
  126882. Object.defineProperty(e.prototype, "enabled", {
  126883. get: function() {
  126884. return this._enabled
  126885. },
  126886. enumerable: !1,
  126887. configurable: !0
  126888. }),
  126889. e.prototype._createRenderTarget = function(e, t) {
  126890. var i = new Db(e,t,{
  126891. width: this._engine.getRenderWidth(),
  126892. height: this._engine.getRenderHeight()
  126893. },0,this._scene,{
  126894. generateMipMaps: !1,
  126895. generateStencilBuffer: this._engine.isStencilEnable,
  126896. defaultType: a.TEXTURETYPE_UNSIGNED_INT,
  126897. types: [],
  126898. drawOnlyOnFirstAttachmentByDefault: !0
  126899. });
  126900. return this.renderTargets.push(i),
  126901. i
  126902. }
  126903. ,
  126904. Object.defineProperty(e.prototype, "isSupported", {
  126905. get: function() {
  126906. return this._scene.getEngine().getCaps().drawBuffersExtension
  126907. },
  126908. enumerable: !1,
  126909. configurable: !0
  126910. }),
  126911. e.prototype.bindAttachmentsForEffect = function(e, t) {
  126912. var i = t.getMaterial()
  126913. , n = i && i.isPrePassCapable
  126914. , r = i && -1 !== this.excludedMaterials.indexOf(i);
  126915. this.enabled && this._currentTarget.enabled && (e._multiTarget && n && !r ? this._engine.bindAttachments(this._multiRenderAttachments) : (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment(),
  126916. this._geometryBuffer && this.currentRTisSceneRT && !r && this._geometryBuffer.renderList.push(t.getRenderingMesh())))
  126917. }
  126918. ,
  126919. e.prototype._reinitializeAttachments = function() {
  126920. for (var e = [], t = [!1], i = [!0], n = 0; n < this.mrtCount; n++)
  126921. e.push(!0),
  126922. n > 0 && (t.push(!0),
  126923. i.push(!1));
  126924. this._multiRenderAttachments = this._engine.buildTextureLayout(e),
  126925. this._clearAttachments = this._engine.buildTextureLayout(t),
  126926. this._defaultAttachments = this._engine.buildTextureLayout(i)
  126927. }
  126928. ,
  126929. e.prototype._resetLayout = function() {
  126930. for (var t = 0; t < e._TextureFormats.length; t++)
  126931. this._textureIndices[e._TextureFormats[t].type] = -1;
  126932. this._textureIndices[a.PREPASS_COLOR_TEXTURE_TYPE] = 0,
  126933. this._mrtLayout = [a.PREPASS_COLOR_TEXTURE_TYPE],
  126934. this._mrtFormats = [e._TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].format],
  126935. this._mrtNames = [e._TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].name],
  126936. this.mrtCount = 1
  126937. }
  126938. ,
  126939. e.prototype._updateGeometryBufferLayout = function() {
  126940. if (this._refreshGeometryBufferRendererLink(),
  126941. this._geometryBuffer) {
  126942. this._geometryBuffer._resetLayout();
  126943. for (var e = [], t = 0; t < this._mrtLayout.length; t++)
  126944. e.push(!1);
  126945. this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture());
  126946. var i = [{
  126947. prePassConstant: a.PREPASS_DEPTH_TEXTURE_TYPE,
  126948. geometryBufferConstant: nb.DEPTH_TEXTURE_TYPE
  126949. }, {
  126950. prePassConstant: a.PREPASS_NORMAL_TEXTURE_TYPE,
  126951. geometryBufferConstant: nb.NORMAL_TEXTURE_TYPE
  126952. }, {
  126953. prePassConstant: a.PREPASS_POSITION_TEXTURE_TYPE,
  126954. geometryBufferConstant: nb.POSITION_TEXTURE_TYPE
  126955. }, {
  126956. prePassConstant: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
  126957. geometryBufferConstant: nb.REFLECTIVITY_TEXTURE_TYPE
  126958. }, {
  126959. prePassConstant: a.PREPASS_VELOCITY_TEXTURE_TYPE,
  126960. geometryBufferConstant: nb.VELOCITY_TEXTURE_TYPE
  126961. }];
  126962. for (t = 0; t < i.length; t++) {
  126963. var n = this._mrtLayout.indexOf(i[t].prePassConstant);
  126964. -1 !== n && (this._geometryBuffer._forceTextureType(i[t].geometryBufferConstant, n),
  126965. e[n] = !0)
  126966. }
  126967. this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(e))
  126968. }
  126969. }
  126970. ,
  126971. e.prototype.restoreAttachments = function() {
  126972. this.enabled && this._currentTarget.enabled && this._defaultAttachments && (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment())
  126973. }
  126974. ,
  126975. e.prototype._beforeDraw = function(e, t, i) {
  126976. this._isDirty && this._update(),
  126977. this._enabled && this._currentTarget.enabled && (this._geometryBuffer && (this._geometryBuffer.renderList = []),
  126978. this._setupOutputForThisPass(this._currentTarget, e))
  126979. }
  126980. ,
  126981. e.prototype._prepareFrame = function(e, t, i) {
  126982. e.renderTargetTexture ? e.renderTargetTexture._prepareFrame(this._scene, t, i, e.renderTargetTexture.useCameraPostProcesses) : this._postProcessesSourceForThisPass.length ? this._scene.postProcessManager._prepareFrame() : this._engine.restoreDefaultFramebuffer()
  126983. }
  126984. ,
  126985. e.prototype._renderPostProcesses = function(e, t) {
  126986. var i, n = this._postProcessesSourceForThisPass[0], r = n ? n.inputTexture : e.renderTargetTexture ? e.renderTargetTexture.renderTarget : null, o = this._currentTarget._beforeCompositionPostProcesses;
  126987. this._needsCompositionForThisPass && (o = o.concat([this._currentTarget.imageProcessingPostProcess])),
  126988. o.length && (this._scene.postProcessManager._prepareFrame(null === (i = this._currentTarget.renderTarget) || void 0 === i ? void 0 : i.texture, o),
  126989. this._scene.postProcessManager.directRender(o, r, !1, t))
  126990. }
  126991. ,
  126992. e.prototype._afterDraw = function(e, t) {
  126993. this._enabled && this._currentTarget.enabled && (this._prepareFrame(this._currentTarget, e, t),
  126994. this._renderPostProcesses(this._currentTarget, e))
  126995. }
  126996. ,
  126997. e.prototype._clear = function() {
  126998. this._enabled && this._currentTarget.enabled && (this._bindFrameBuffer(this._currentTarget),
  126999. this._engine.bindAttachments(this._clearAttachments),
  127000. this._engine.clear(this._clearColor, !0, !1, !1),
  127001. this._engine.bindAttachments(this._defaultAttachments))
  127002. }
  127003. ,
  127004. e.prototype._bindFrameBuffer = function(e) {
  127005. if (this._enabled && this._currentTarget.enabled) {
  127006. this._currentTarget._checkSize();
  127007. var t = this._currentTarget.renderTarget;
  127008. t && this._engine.bindFramebuffer(t)
  127009. }
  127010. }
  127011. ,
  127012. e.prototype._setEnabled = function(e) {
  127013. this._enabled = e
  127014. }
  127015. ,
  127016. e.prototype._setRenderTargetEnabled = function(e, t) {
  127017. e.enabled = t,
  127018. t || this._unlinkInternalTexture(e)
  127019. }
  127020. ,
  127021. e.prototype.addEffectConfiguration = function(e) {
  127022. for (var t = 0; t < this._effectConfigurations.length; t++)
  127023. if (this._effectConfigurations[t].name === e.name)
  127024. return this._effectConfigurations[t];
  127025. return this._effectConfigurations.push(e),
  127026. e
  127027. }
  127028. ,
  127029. e.prototype._enable = function() {
  127030. for (var e = this.mrtCount, t = 0; t < this._effectConfigurations.length; t++)
  127031. this._effectConfigurations[t].enabled && this._enableTextures(this._effectConfigurations[t].texturesRequired);
  127032. for (t = 0; t < this.renderTargets.length; t++) {
  127033. this.mrtCount === e && this.renderTargets[t].count === this.mrtCount || this.renderTargets[t].updateCount(this.mrtCount, {
  127034. types: this._mrtFormats
  127035. }, this._mrtNames.concat("prePass_DepthBuffer")),
  127036. this.renderTargets[t]._resetPostProcessChain();
  127037. for (var i = 0; i < this._effectConfigurations.length; i++)
  127038. this._effectConfigurations[i].enabled && (!this._effectConfigurations[i].postProcess && this._effectConfigurations[i].createPostProcess && this._effectConfigurations[i].createPostProcess(),
  127039. this._effectConfigurations[i].postProcess && this.renderTargets[t]._beforeCompositionPostProcesses.push(this._effectConfigurations[i].postProcess))
  127040. }
  127041. this._reinitializeAttachments(),
  127042. this._setEnabled(!0),
  127043. this._updateGeometryBufferLayout()
  127044. }
  127045. ,
  127046. e.prototype._disable = function() {
  127047. this._setEnabled(!1);
  127048. for (var e = 0; e < this.renderTargets.length; e++)
  127049. this._setRenderTargetEnabled(this.renderTargets[e], !1);
  127050. for (this._resetLayout(),
  127051. e = 0; e < this._effectConfigurations.length; e++)
  127052. this._effectConfigurations[e].enabled = !1
  127053. }
  127054. ,
  127055. e.prototype._getPostProcessesSource = function(e, t) {
  127056. if (t)
  127057. return t._postProcesses;
  127058. if (e.renderTargetTexture) {
  127059. if (e.renderTargetTexture.useCameraPostProcesses) {
  127060. var i = e.renderTargetTexture.activeCamera ? e.renderTargetTexture.activeCamera : this._scene.activeCamera;
  127061. return i ? i._postProcesses : []
  127062. }
  127063. return e.renderTargetTexture.postProcesses ? e.renderTargetTexture.postProcesses : []
  127064. }
  127065. return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : []
  127066. }
  127067. ,
  127068. e.prototype._setupOutputForThisPass = function(e, t) {
  127069. var i = t && this._scene.activeCameras && !!this._scene.activeCameras.length && 0 !== this._scene.activeCameras.indexOf(t);
  127070. this._postProcessesSourceForThisPass = this._getPostProcessesSource(e, t),
  127071. this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter((function(e) {
  127072. return null != e
  127073. }
  127074. )),
  127075. this._scene.autoClear = !0;
  127076. var n = this._hasImageProcessing(this._postProcessesSourceForThisPass);
  127077. this._needsCompositionForThisPass = !n && !this.disableGammaTransform && this._needsImageProcessing() && !i;
  127078. var r = this._getFirstPostProcess(this._postProcessesSourceForThisPass)
  127079. , o = e._beforeCompositionPostProcesses && e._beforeCompositionPostProcesses[0]
  127080. , a = null;
  127081. this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || n,
  127082. this._needsCompositionForThisPass && !e.imageProcessingPostProcess && e._createCompositionEffect(),
  127083. o ? a = o : this._needsCompositionForThisPass ? a = e.imageProcessingPostProcess : r && (a = r),
  127084. this._bindFrameBuffer(e),
  127085. this._linkInternalTexture(e, a)
  127086. }
  127087. ,
  127088. e.prototype._linkInternalTexture = function(e, t) {
  127089. t && (t.autoClear = !1,
  127090. t.inputTexture = e.renderTarget),
  127091. e._outputPostProcess !== t && (e._outputPostProcess && this._unlinkInternalTexture(e),
  127092. e._outputPostProcess = t),
  127093. e._internalTextureDirty && (this._updateGeometryBufferLayout(),
  127094. e._internalTextureDirty = !1)
  127095. }
  127096. ,
  127097. e.prototype._unlinkInternalTexture = function(e) {
  127098. e._outputPostProcess && (e._outputPostProcess.autoClear = !0,
  127099. e._outputPostProcess.restoreDefaultInputTexture(),
  127100. e._outputPostProcess = null)
  127101. }
  127102. ,
  127103. e.prototype._needsImageProcessing = function() {
  127104. for (var e = 0; e < this._effectConfigurations.length; e++)
  127105. if (this._effectConfigurations[e].enabled && this._effectConfigurations[e].needsImageProcessing)
  127106. return !0;
  127107. return !1
  127108. }
  127109. ,
  127110. e.prototype._hasImageProcessing = function(e) {
  127111. var t, i = !1;
  127112. if (e)
  127113. for (var n = 0; n < e.length; n++)
  127114. if ("ImageProcessingPostProcess" === (null === (t = e[n]) || void 0 === t ? void 0 : t.getClassName())) {
  127115. i = !0;
  127116. break
  127117. }
  127118. return i
  127119. }
  127120. ,
  127121. e.prototype._getFirstPostProcess = function(e) {
  127122. for (var t = 0; t < e.length; t++)
  127123. if (null !== e[t])
  127124. return e[t];
  127125. return null
  127126. }
  127127. ,
  127128. e.prototype.markAsDirty = function() {
  127129. this._isDirty = !0
  127130. }
  127131. ,
  127132. e.prototype._enableTextures = function(t) {
  127133. this._scene.needsPreviousWorldMatrices = !1;
  127134. for (var i = 0; i < t.length; i++) {
  127135. var n = t[i];
  127136. -1 === this._textureIndices[n] && (this._textureIndices[n] = this._mrtLayout.length,
  127137. this._mrtLayout.push(n),
  127138. this._mrtFormats.push(e._TextureFormats[n].format),
  127139. this._mrtNames.push(e._TextureFormats[n].name),
  127140. this.mrtCount++),
  127141. n === a.PREPASS_VELOCITY_TEXTURE_TYPE && (this._scene.needsPreviousWorldMatrices = !0)
  127142. }
  127143. }
  127144. ,
  127145. e.prototype._update = function() {
  127146. this._disable();
  127147. var e, t = !1;
  127148. this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
  127149. this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency && (this._scene._depthPeelingRenderer.setPrePassRenderer(this),
  127150. t = !0);
  127151. for (var i = 0; i < this._scene.materials.length; i++)
  127152. this._scene.materials[i].setPrePassRenderer(this) && (t = !0);
  127153. for (t && this._setRenderTargetEnabled(this.defaultRT, !0),
  127154. i = 0; i < this.renderTargets.length; i++) {
  127155. if (this.renderTargets[i].renderTargetTexture)
  127156. e = this._getPostProcessesSource(this.renderTargets[i]);
  127157. else {
  127158. var n = this._scene.activeCamera;
  127159. if (!n)
  127160. continue;
  127161. e = n._postProcesses
  127162. }
  127163. if (e && (e = e.filter((function(e) {
  127164. return null != e
  127165. }
  127166. )))) {
  127167. for (var r = 0; r < e.length; r++)
  127168. e[r].setPrePassRenderer(this) && (this._setRenderTargetEnabled(this.renderTargets[i], !0),
  127169. t = !0);
  127170. this._hasImageProcessing(e) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !0)
  127171. }
  127172. }
  127173. this._markAllMaterialsAsPrePassDirty(),
  127174. this._isDirty = !1,
  127175. t && this._enable()
  127176. }
  127177. ,
  127178. e.prototype._markAllMaterialsAsPrePassDirty = function() {
  127179. for (var e = this._scene.materials, t = 0; t < e.length; t++)
  127180. e[t].markAsDirty(Or.PrePassDirtyFlag)
  127181. }
  127182. ,
  127183. e.prototype.dispose = function() {
  127184. for (var e = this.renderTargets.length - 1; e >= 0; e--)
  127185. this.renderTargets[e].dispose();
  127186. for (e = 0; e < this._effectConfigurations.length; e++)
  127187. this._effectConfigurations[e].dispose && this._effectConfigurations[e].dispose()
  127188. }
  127189. ,
  127190. e._SceneComponentInitialization = function(e) {
  127191. throw be("PrePassRendererSceneComponent")
  127192. }
  127193. ,
  127194. e._TextureFormats = [{
  127195. type: a.PREPASS_IRRADIANCE_TEXTURE_TYPE,
  127196. format: a.TEXTURETYPE_HALF_FLOAT,
  127197. name: "prePass_Irradiance"
  127198. }, {
  127199. type: a.PREPASS_POSITION_TEXTURE_TYPE,
  127200. format: a.TEXTURETYPE_HALF_FLOAT,
  127201. name: "prePass_Position"
  127202. }, {
  127203. type: a.PREPASS_VELOCITY_TEXTURE_TYPE,
  127204. format: a.TEXTURETYPE_UNSIGNED_INT,
  127205. name: "prePass_Velocity"
  127206. }, {
  127207. type: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
  127208. format: a.TEXTURETYPE_UNSIGNED_INT,
  127209. name: "prePass_Reflectivity"
  127210. }, {
  127211. type: a.PREPASS_COLOR_TEXTURE_TYPE,
  127212. format: a.TEXTURETYPE_HALF_FLOAT,
  127213. name: "prePass_Color"
  127214. }, {
  127215. type: a.PREPASS_DEPTH_TEXTURE_TYPE,
  127216. format: a.TEXTURETYPE_HALF_FLOAT,
  127217. name: "prePass_Depth"
  127218. }, {
  127219. type: a.PREPASS_NORMAL_TEXTURE_TYPE,
  127220. format: a.TEXTURETYPE_HALF_FLOAT,
  127221. name: "prePass_Normal"
  127222. }, {
  127223. type: a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,
  127224. format: a.TEXTURETYPE_UNSIGNED_INT,
  127225. name: "prePass_Albedo"
  127226. }],
  127227. e
  127228. }();
  127229. Object.defineProperty(mn.prototype, "prePassRenderer", {
  127230. get: function() {
  127231. return this._prePassRenderer
  127232. },
  127233. set: function(e) {
  127234. e && e.isSupported && (this._prePassRenderer = e)
  127235. },
  127236. enumerable: !0,
  127237. configurable: !0
  127238. }),
  127239. mn.prototype.enablePrePassRenderer = function() {
  127240. return this._prePassRenderer || (this._prePassRenderer = new Nb(this),
  127241. this._prePassRenderer.isSupported || (this._prePassRenderer = null,
  127242. K.Error("PrePassRenderer needs WebGL 2 support.\nMaybe you tried to use the following features that need the PrePassRenderer :\n + Subsurface Scattering"))),
  127243. this._prePassRenderer
  127244. }
  127245. ,
  127246. mn.prototype.disablePrePassRenderer = function() {
  127247. this._prePassRenderer && (this._prePassRenderer.dispose(),
  127248. this._prePassRenderer = null)
  127249. }
  127250. ;
  127251. var Lb = function() {
  127252. function e(e) {
  127253. this.name = Wi.NAME_PREPASSRENDERER,
  127254. this.scene = e
  127255. }
  127256. return e.prototype.register = function() {
  127257. this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_PREPASS, this, this._beforeCameraDraw),
  127258. this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterCameraDraw),
  127259. this.scene._beforeRenderTargetDrawStage.registerStep(Wi.STEP_BEFORERENDERTARGETDRAW_PREPASS, this, this._beforeRenderTargetDraw),
  127260. this.scene._afterRenderTargetDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterRenderTargetDraw),
  127261. this.scene._beforeClearStage.registerStep(Wi.STEP_BEFORECLEARSTAGE_PREPASS, this, this._beforeClearStage),
  127262. this.scene._beforeRenderTargetClearStage.registerStep(Wi.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS, this, this._beforeRenderTargetClearStage),
  127263. this.scene._beforeRenderingMeshStage.registerStep(Wi.STEP_BEFORERENDERINGMESH_PREPASS, this, this._beforeRenderingMeshStage),
  127264. this.scene._afterRenderingMeshStage.registerStep(Wi.STEP_AFTERRENDERINGMESH_PREPASS, this, this._afterRenderingMeshStage)
  127265. }
  127266. ,
  127267. e.prototype._beforeRenderTargetDraw = function(e, t, i) {
  127268. this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget),
  127269. this.scene.prePassRenderer._beforeDraw(void 0, t, i))
  127270. }
  127271. ,
  127272. e.prototype._afterRenderTargetDraw = function(e, t, i) {
  127273. this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw(t, i)
  127274. }
  127275. ,
  127276. e.prototype._beforeRenderTargetClearStage = function(e) {
  127277. this.scene.prePassRenderer && (e._prePassRenderTarget || (e._prePassRenderTarget = this.scene.prePassRenderer._createRenderTarget(e.name + "_prePassRTT", e)),
  127278. this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget),
  127279. this.scene.prePassRenderer._clear())
  127280. }
  127281. ,
  127282. e.prototype._beforeCameraDraw = function(e) {
  127283. this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null),
  127284. this.scene.prePassRenderer._beforeDraw(e))
  127285. }
  127286. ,
  127287. e.prototype._afterCameraDraw = function() {
  127288. this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw()
  127289. }
  127290. ,
  127291. e.prototype._beforeClearStage = function() {
  127292. this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null),
  127293. this.scene.prePassRenderer._clear())
  127294. }
  127295. ,
  127296. e.prototype._beforeRenderingMeshStage = function(e, t, i, n) {
  127297. if (n) {
  127298. var r = e.getScene();
  127299. r.prePassRenderer && r.prePassRenderer.bindAttachmentsForEffect(n, t)
  127300. }
  127301. }
  127302. ,
  127303. e.prototype._afterRenderingMeshStage = function(e) {
  127304. var t = e.getScene();
  127305. t.prePassRenderer && t.prePassRenderer.restoreAttachments()
  127306. }
  127307. ,
  127308. e.prototype.rebuild = function() {
  127309. this.scene.disablePrePassRenderer(),
  127310. this.scene.enablePrePassRenderer()
  127311. }
  127312. ,
  127313. e.prototype.dispose = function() {
  127314. this.scene.disablePrePassRenderer()
  127315. }
  127316. ,
  127317. e
  127318. }();
  127319. Nb._SceneComponentInitialization = function(e) {
  127320. var t = e._getComponent(Wi.NAME_PREPASSRENDERER);
  127321. t || (t = new Lb(e),
  127322. e._addComponent(t))
  127323. }
  127324. ;
  127325. Pt.IncludesShadersStore.fibonacci = "#define rcp(x) 1./x\n#define GOLDEN_RATIO 1.618033988749895\n#define TWO_PI 6.2831855\nvec2 Golden2dSeq(int i,float n)\n{\nreturn vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));\n}\nvec2 SampleDiskGolden(int i,int sampleCount)\n{\nvec2 f=Golden2dSeq(i,float(sampleCount));\nreturn vec2(sqrt(f.x),TWO_PI*f.y);\n}";
  127326. Pt.IncludesShadersStore.diffusionProfile = "uniform vec3 diffusionS[5];\nuniform float diffusionD[5];\nuniform float filterRadii[5];";
  127327. Pt.ShadersStore.subSurfaceScatteringPixelShader = "#include<fibonacci>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<diffusionProfile>\nvarying vec2 vUV;\nuniform vec2 texelSize;\nuniform sampler2D textureSampler;\nuniform sampler2D irradianceSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D albedoSampler;\nuniform vec2 viewportSize;\nuniform float metersPerUnit;\nconst float LOG2_E=1.4426950408889634;\nconst float SSS_PIXELS_PER_SAMPLE=4.;\nconst int _SssSampleBudget=40;\n#define rcp(x) 1./x\n#define Sq(x) x*x\n#define SSS_BILATERAL_FILTER true\nvec3 EvalBurleyDiffusionProfile(float r,vec3 S)\n{\nvec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S); \nvec3 expSum=exp_13*(1.+exp_13*exp_13); \nreturn (S*rcp(8.*PI))*expSum; \n}\nvec2 SampleBurleyDiffusionProfile(float u,float rcpS)\n{\nu=1.-u; \nfloat g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));\nfloat n=exp2(log2(g)*(-1.0/3.0)); \nfloat p=(g*n)*n; \nfloat c=1.+p+n; \nfloat d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u); \nfloat x=(3./LOG2_E)*log2(c)-d; \nfloat rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));\nfloat r=x*rcpS;\nfloat rcpPdf=(8.*PI*rcpS)*rcpExp; \nreturn vec2(r,rcpPdf);\n}\nvec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)\n{\n#ifndef SSS_BILATERAL_FILTER\nz=0.;\n#endif\nfloat r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));\nfloat area=rcpPdf;\n#if SSS_CLAMP_ARTIFACT\nreturn clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);\n#else\nreturn EvalBurleyDiffusionProfile(r,S)*area;\n#endif\n}\nvoid EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,\nfloat phase,inout vec3 totalIrradiance,inout vec3 totalWeight)\n{\nfloat scale =rcp(float(n));\nfloat offset=rcp(float(n))*0.5;\nfloat sinPhase,cosPhase;\nsinPhase=sin(phase);\ncosPhase=cos(phase);\nvec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);\nfloat r=bdp.x;\nfloat rcpPdf=bdp.y;\nfloat phi=SampleDiskGolden(i,n).y;\nfloat sinPhi,cosPhi;\nsinPhi=sin(phi);\ncosPhi=cos(phi);\nfloat sinPsi=cosPhase*sinPhi+sinPhase*cosPhi; \nfloat cosPsi=cosPhase*cosPhi-sinPhase*sinPhi; \nvec2 vec=r*vec2(cosPsi,sinPsi);\nvec2 position; \nfloat xy2;\nposition=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;\nxy2 =r*r;\nvec4 textureSample=texture2D(irradianceSampler,position);\nfloat viewZ=texture2D(depthSampler,position).r;\nvec3 irradiance =textureSample.rgb;\nif (testLightingForSSS(textureSample.a))\n{\nfloat relZ=viewZ-centerPosVS.z;\nvec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);\ntotalIrradiance+=weight*irradiance;\ntotalWeight +=weight;\n}\nelse\n{\n}\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec4 irradianceAndDiffusionProfile =texture2D(irradianceSampler,vUV);\nvec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;\nint diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));\nfloat centerDepth =0.;\nvec4 inputColor=texture2D(textureSampler,vUV);\nbool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);\nif (passedStencilTest)\n{\ncenterDepth=texture2D(depthSampler,vUV).r;\n}\nif (!passedStencilTest) { \ngl_FragColor=inputColor;\nreturn;\n}\nfloat distScale =1.;\nvec3 S =diffusionS[diffusionProfileIndex];\nfloat d =diffusionD[diffusionProfileIndex];\nfloat filterRadius=filterRadii[diffusionProfileIndex];\nvec2 centerPosNDC=vUV;\nvec2 cornerPosNDC=vUV+0.5*texelSize;\nvec3 centerPosVS =vec3(centerPosNDC*viewportSize,1.0)*centerDepth; \nvec3 cornerPosVS =vec3(cornerPosNDC*viewportSize,1.0)*centerDepth; \nfloat mmPerUnit =1000.*(metersPerUnit*rcp(distScale));\nfloat unitsPerMm=rcp(mmPerUnit);\nfloat unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);\nfloat pixelsPerMm =rcp(unitsPerPixel)*unitsPerMm;\nfloat filterArea =PI*Sq(filterRadius*pixelsPerMm);\nint sampleCount =int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));\nint sampleBudget=_SssSampleBudget;\nint texturingMode=0;\nvec3 albedo =texture2D(albedoSampler,vUV).rgb;\nif (distScale==0. || sampleCount<1)\n{\n#ifdef DEBUG_SSS_SAMPLES\nvec3 green=vec3(0.,1.,0.);\ngl_FragColor=vec4(green,1.0);\nreturn;\n#endif\ngl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);\nreturn;\n}\n#ifdef DEBUG_SSS_SAMPLES\nvec3 red =vec3(1.,0.,0.);\nvec3 blue=vec3(0.,0.,1.);\ngl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);\nreturn;\n#endif\nfloat phase=0.;\nint n=min(sampleCount,sampleBudget);\nvec3 centerWeight =vec3(0.); \nvec3 totalIrradiance=vec3(0.);\nvec3 totalWeight =vec3(0.);\nfor (int i=0; i<n; i++)\n{\nEvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,\nphase,totalIrradiance,totalWeight);\n}\ntotalWeight=max(totalWeight,HALF_MIN);\ngl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);\n}";
  127328. var Fb = function(e) {
  127329. function t(t, i, n, r, o, s, l, c) {
  127330. void 0 === r && (r = null),
  127331. void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
  127332. var u = e.call(this, t, "subSurfaceScattering", ["texelSize", "viewportSize", "metersPerUnit"], ["diffusionS", "diffusionD", "filterRadii", "irradianceSampler", "depthSampler", "albedoSampler"], n, r, o || io.BILINEAR_SAMPLINGMODE, s, l, null, c, "postprocess", void 0, !0) || this;
  127333. return u._scene = i,
  127334. u.updateEffect(),
  127335. u.onApplyObservable.add((function(e) {
  127336. if (i.prePassRenderer && i.subSurfaceConfiguration) {
  127337. var t = u.texelSize;
  127338. e.setFloat("metersPerUnit", i.subSurfaceConfiguration.metersPerUnit),
  127339. e.setFloat2("texelSize", t.x, t.y),
  127340. e.setTexture("irradianceSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_IRRADIANCE_TEXTURE_TYPE)]),
  127341. e.setTexture("depthSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
  127342. e.setTexture("albedoSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE)]),
  127343. e.setFloat2("viewportSize", Math.tan(i.activeCamera.fov / 2) * i.getEngine().getAspectRatio(i.activeCamera, !0), Math.tan(i.activeCamera.fov / 2)),
  127344. e.setArray3("diffusionS", i.subSurfaceConfiguration.ssDiffusionS),
  127345. e.setArray("diffusionD", i.subSurfaceConfiguration.ssDiffusionD),
  127346. e.setArray("filterRadii", i.subSurfaceConfiguration.ssFilterRadii)
  127347. } else
  127348. K.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.")
  127349. }
  127350. )),
  127351. u
  127352. }
  127353. return U(t, e),
  127354. t.prototype.getClassName = function() {
  127355. return "SubSurfaceScatteringPostProcess"
  127356. }
  127357. ,
  127358. t
  127359. }(Ba)
  127360. , wb = function() {
  127361. function e(t) {
  127362. this._ssDiffusionS = [],
  127363. this._ssFilterRadii = [],
  127364. this._ssDiffusionD = [],
  127365. this.enabled = !1,
  127366. this.needsImageProcessing = !0,
  127367. this.name = Wi.NAME_SUBSURFACE,
  127368. this.ssDiffusionProfileColors = [],
  127369. this.metersPerUnit = 1,
  127370. this.texturesRequired = [a.PREPASS_DEPTH_TEXTURE_TYPE, a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, a.PREPASS_COLOR_TEXTURE_TYPE, a.PREPASS_IRRADIANCE_TEXTURE_TYPE],
  127371. this.addDiffusionProfile(new D(1,1,1)),
  127372. this._scene = t,
  127373. e._SceneComponentInitialization(this._scene)
  127374. }
  127375. return Object.defineProperty(e.prototype, "ssDiffusionS", {
  127376. get: function() {
  127377. return this._ssDiffusionS
  127378. },
  127379. enumerable: !1,
  127380. configurable: !0
  127381. }),
  127382. Object.defineProperty(e.prototype, "ssDiffusionD", {
  127383. get: function() {
  127384. return this._ssDiffusionD
  127385. },
  127386. enumerable: !1,
  127387. configurable: !0
  127388. }),
  127389. Object.defineProperty(e.prototype, "ssFilterRadii", {
  127390. get: function() {
  127391. return this._ssFilterRadii
  127392. },
  127393. enumerable: !1,
  127394. configurable: !0
  127395. }),
  127396. e.prototype.addDiffusionProfile = function(e) {
  127397. if (this.ssDiffusionD.length >= 5)
  127398. return K.Error("You already reached the maximum number of diffusion profiles."),
  127399. 0;
  127400. for (var t = 0; t < this._ssDiffusionS.length / 3; t++)
  127401. if (this._ssDiffusionS[3 * t] === e.r && this._ssDiffusionS[3 * t + 1] === e.g && this._ssDiffusionS[3 * t + 2] === e.b)
  127402. return t;
  127403. return this._ssDiffusionS.push(e.r, e.b, e.g),
  127404. this._ssDiffusionD.push(Math.max(Math.max(e.r, e.b), e.g)),
  127405. this._ssFilterRadii.push(this.getDiffusionProfileParameters(e)),
  127406. this.ssDiffusionProfileColors.push(e),
  127407. this._ssDiffusionD.length - 1
  127408. }
  127409. ,
  127410. e.prototype.createPostProcess = function() {
  127411. return this.postProcess = new Fb("subSurfaceScattering",this._scene,1,null,void 0,this._scene.getEngine()),
  127412. this.postProcess.autoClear = !1,
  127413. this.postProcess
  127414. }
  127415. ,
  127416. e.prototype.clearAllDiffusionProfiles = function() {
  127417. this._ssDiffusionD = [],
  127418. this._ssDiffusionS = [],
  127419. this._ssFilterRadii = [],
  127420. this.ssDiffusionProfileColors = []
  127421. }
  127422. ,
  127423. e.prototype.dispose = function() {
  127424. this.clearAllDiffusionProfiles(),
  127425. this.postProcess && this.postProcess.dispose()
  127426. }
  127427. ,
  127428. e.prototype.getDiffusionProfileParameters = function(e) {
  127429. var t = Math.max(e.r, e.g, e.b);
  127430. return this._sampleBurleyDiffusionProfile(.997, t)
  127431. }
  127432. ,
  127433. e.prototype._sampleBurleyDiffusionProfile = function(e, t) {
  127434. var i = 1 + 4 * (e = 1 - e) * (2 * e + Math.sqrt(1 + 4 * e * e))
  127435. , n = Math.pow(i, -1 / 3)
  127436. , r = 1 + i * n * n + n;
  127437. return 3 * Math.log(r / (4 * e)) * t
  127438. }
  127439. ,
  127440. e._SceneComponentInitialization = function(e) {
  127441. throw be("SubSurfaceSceneComponent")
  127442. }
  127443. ,
  127444. e
  127445. }();
  127446. o.AddParser(Wi.NAME_SUBSURFACE, (function(e, t) {
  127447. if (void 0 !== e.ssDiffusionProfileColors && null !== e.ssDiffusionProfileColors && (t.enableSubSurfaceForPrePass(),
  127448. t.subSurfaceConfiguration))
  127449. for (var i = 0, n = e.ssDiffusionProfileColors.length; i < n; i++) {
  127450. var r = e.ssDiffusionProfileColors[i];
  127451. t.subSurfaceConfiguration.addDiffusionProfile(new D(r.r,r.g,r.b))
  127452. }
  127453. }
  127454. )),
  127455. Object.defineProperty(mn.prototype, "subSurfaceConfiguration", {
  127456. get: function() {
  127457. return this._subSurfaceConfiguration
  127458. },
  127459. set: function(e) {
  127460. e && this.enablePrePassRenderer() && (this._subSurfaceConfiguration = e)
  127461. },
  127462. enumerable: !0,
  127463. configurable: !0
  127464. }),
  127465. mn.prototype.enableSubSurfaceForPrePass = function() {
  127466. if (this._subSurfaceConfiguration)
  127467. return this._subSurfaceConfiguration;
  127468. var e = this.enablePrePassRenderer();
  127469. return e ? (this._subSurfaceConfiguration = new wb(this),
  127470. e.addEffectConfiguration(this._subSurfaceConfiguration),
  127471. this._subSurfaceConfiguration) : null
  127472. }
  127473. ,
  127474. mn.prototype.disableSubSurfaceForPrePass = function() {
  127475. this._subSurfaceConfiguration && (this._subSurfaceConfiguration.dispose(),
  127476. this._subSurfaceConfiguration = null)
  127477. }
  127478. ;
  127479. var Bb = function() {
  127480. function e(e) {
  127481. this.name = Wi.NAME_PREPASSRENDERER,
  127482. this.scene = e
  127483. }
  127484. return e.prototype.register = function() {}
  127485. ,
  127486. e.prototype.serialize = function(e) {
  127487. if (this.scene.subSurfaceConfiguration) {
  127488. var t = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;
  127489. e.ssDiffusionProfileColors = [];
  127490. for (var i = 0; i < t.length; i++)
  127491. e.ssDiffusionProfileColors.push({
  127492. r: t[i].r,
  127493. g: t[i].g,
  127494. b: t[i].b
  127495. })
  127496. }
  127497. }
  127498. ,
  127499. e.prototype.addFromContainer = function() {}
  127500. ,
  127501. e.prototype.removeFromContainer = function() {
  127502. this.scene.prePassRenderer && this.scene.subSurfaceConfiguration && this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles()
  127503. }
  127504. ,
  127505. e.prototype.rebuild = function() {}
  127506. ,
  127507. e.prototype.dispose = function() {}
  127508. ,
  127509. e
  127510. }();
  127511. wb._SceneComponentInitialization = function(e) {
  127512. var t = e._getComponent(Wi.NAME_SUBSURFACE);
  127513. t || (t = new Bb(e),
  127514. e._addComponent(t))
  127515. }
  127516. ;
  127517. Pt.ShadersStore.outlinePixelShader = "#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  127518. Pt.ShadersStore.outlineVertexShader = "attribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<clipPlaneVertexDeclaration>\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(offsetPosition,1.0);\ngl_Position=viewProjection*worldPos;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n}\n",
  127519. mn.prototype.getOutlineRenderer = function() {
  127520. return this._outlineRenderer || (this._outlineRenderer = new Ub(this)),
  127521. this._outlineRenderer
  127522. }
  127523. ,
  127524. Object.defineProperty(Vr.prototype, "renderOutline", {
  127525. get: function() {
  127526. return this._renderOutline
  127527. },
  127528. set: function(e) {
  127529. e && this.getScene().getOutlineRenderer(),
  127530. this._renderOutline = e
  127531. },
  127532. enumerable: !0,
  127533. configurable: !0
  127534. }),
  127535. Object.defineProperty(Vr.prototype, "renderOverlay", {
  127536. get: function() {
  127537. return this._renderOverlay
  127538. },
  127539. set: function(e) {
  127540. e && this.getScene().getOutlineRenderer(),
  127541. this._renderOverlay = e
  127542. },
  127543. enumerable: !0,
  127544. configurable: !0
  127545. });
  127546. var Ub = function() {
  127547. function e(e) {
  127548. this.name = Wi.NAME_OUTLINERENDERER,
  127549. this.zOffset = 1,
  127550. this.zOffsetUnits = 4,
  127551. this.scene = e,
  127552. this._engine = e.getEngine(),
  127553. this.scene._addComponent(this),
  127554. this._passIdForDrawWrapper = [];
  127555. for (var t = 0; t < 4; ++t)
  127556. this._passIdForDrawWrapper[t] = this._engine.createRenderPassId("Outline Renderer (".concat(t, ")"))
  127557. }
  127558. return e.prototype.register = function() {
  127559. this.scene._beforeRenderingMeshStage.registerStep(Wi.STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh),
  127560. this.scene._afterRenderingMeshStage.registerStep(Wi.STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh)
  127561. }
  127562. ,
  127563. e.prototype.rebuild = function() {}
  127564. ,
  127565. e.prototype.dispose = function() {
  127566. for (var e = 0; e < this._passIdForDrawWrapper.length; ++e)
  127567. this._engine.releaseRenderPassId(this._passIdForDrawWrapper[e])
  127568. }
  127569. ,
  127570. e.prototype.render = function(e, t, i, n) {
  127571. void 0 === i && (i = !1),
  127572. n = null != n ? n : this._passIdForDrawWrapper[0];
  127573. var r = this.scene
  127574. , o = r.getEngine()
  127575. , a = o.getCaps().instancedArrays && (null !== t.visibleInstances[e._id] && void 0 !== t.visibleInstances[e._id] || e.getRenderingMesh().hasThinInstances);
  127576. if (this.isReady(e, a, n)) {
  127577. var s = e.getMesh()
  127578. , l = s._internalAbstractMeshDataInfo._actAsRegularMesh ? s : null
  127579. , c = e.getRenderingMesh()
  127580. , u = l || c
  127581. , h = e.getMaterial();
  127582. if (h && r.activeCamera) {
  127583. var d = e._getDrawWrapper(n)
  127584. , p = Gt.GetEffect(d);
  127585. if (o.enableEffect(d),
  127586. h.useLogarithmicDepth && p.setFloat("logarithmicDepthConstant", 2 / (Math.log(r.activeCamera.maxZ + 1) / Math.LN2)),
  127587. p.setFloat("offset", i ? 0 : c.outlineWidth),
  127588. p.setColor4("color", i ? c.overlayColor : c.outlineColor, i ? c.overlayAlpha : h.alpha),
  127589. p.setMatrix("viewProjection", r.getTransformMatrix()),
  127590. p.setMatrix("world", u.getWorldMatrix()),
  127591. c.useBones && c.computeBonesUsingShaders && c.skeleton && p.setMatrices("mBones", c.skeleton.getTransformMatrices(c)),
  127592. c.morphTargetManager && c.morphTargetManager.isUsingTextureForTargets && c.morphTargetManager._bind(p),
  127593. Mr.BindMorphTargetParameters(c, p),
  127594. a || c._bind(e, p, h.fillMode),
  127595. h && h.needAlphaTesting()) {
  127596. var f = h.getAlphaTestTexture();
  127597. f && (p.setTexture("diffuseSampler", f),
  127598. p.setMatrix("diffuseMatrix", f.getTextureMatrix()))
  127599. }
  127600. Mr.BindClipPlane(p, r),
  127601. o.setZOffset(-this.zOffset),
  127602. o.setZOffsetUnits(-this.zOffsetUnits),
  127603. c._processRendering(u, e, p, h.fillMode, t, a, (function(e, t) {
  127604. p.setMatrix("world", t)
  127605. }
  127606. )),
  127607. o.setZOffset(0),
  127608. o.setZOffsetUnits(0)
  127609. }
  127610. }
  127611. }
  127612. ,
  127613. e.prototype.isReady = function(e, t, i) {
  127614. i = null != i ? i : this._passIdForDrawWrapper[0];
  127615. var n = []
  127616. , r = [Bi.PositionKind, Bi.NormalKind]
  127617. , o = e.getMesh()
  127618. , a = e.getMaterial()
  127619. , s = o.getScene();
  127620. a && (a.needAlphaTesting() && (n.push("#define ALPHATEST"),
  127621. o.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
  127622. n.push("#define UV1")),
  127623. o.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
  127624. n.push("#define UV2"))),
  127625. a.useLogarithmicDepth && n.push("#define LOGARITHMICDEPTH")),
  127626. o.useBones && o.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
  127627. r.push(Bi.MatricesWeightsKind),
  127628. o.numBoneInfluencers > 4 && (r.push(Bi.MatricesIndicesExtraKind),
  127629. r.push(Bi.MatricesWeightsExtraKind)),
  127630. n.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers),
  127631. n.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0");
  127632. var l = o.morphTargetManager
  127633. , c = 0;
  127634. l && l.numInfluencers > 0 && (c = l.numInfluencers,
  127635. n.push("#define MORPHTARGETS"),
  127636. n.push("#define NUM_MORPH_INFLUENCERS " + c),
  127637. l.isUsingTextureForTargets && n.push("#define MORPHTARGETS_TEXTURE"),
  127638. Mr.PrepareAttributesForMorphTargetsInfluencers(r, o, c)),
  127639. t && (n.push("#define INSTANCES"),
  127640. Mr.PushAttributesForInstances(r),
  127641. e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES")),
  127642. s.clipPlane && n.push("#define CLIPPLANE"),
  127643. s.clipPlane2 && n.push("#define CLIPPLANE2"),
  127644. s.clipPlane3 && n.push("#define CLIPPLANE3"),
  127645. s.clipPlane4 && n.push("#define CLIPPLANE4"),
  127646. s.clipPlane5 && n.push("#define CLIPPLANE5"),
  127647. s.clipPlane6 && n.push("#define CLIPPLANE6");
  127648. var u = e._getDrawWrapper(i, !0)
  127649. , h = u.defines
  127650. , d = n.join("\n");
  127651. return h !== d && u.setEffect(this.scene.getEngine().createEffect("outline", r, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6"], ["diffuseSampler", "morphTargets"], d, void 0, void 0, void 0, {
  127652. maxSimultaneousMorphTargets: c
  127653. }), d),
  127654. u.effect.isReady()
  127655. }
  127656. ,
  127657. e.prototype._beforeRenderingMesh = function(t, i, n) {
  127658. if (this._savedDepthWrite = this._engine.getDepthWrite(),
  127659. t.renderOutline) {
  127660. var r = i.getMaterial();
  127661. r && r.needAlphaBlendingForMesh(t) && (this._engine.cacheStencilState(),
  127662. this._engine.setDepthWrite(!1),
  127663. this._engine.setColorWrite(!1),
  127664. this._engine.setStencilBuffer(!0),
  127665. this._engine.setStencilOperationPass(a.REPLACE),
  127666. this._engine.setStencilFunction(a.ALWAYS),
  127667. this._engine.setStencilMask(e._StencilReference),
  127668. this._engine.setStencilFunctionReference(e._StencilReference),
  127669. this._engine.stencilStateComposer.useStencilGlobalOnly = !0,
  127670. this.render(i, n, !0, this._passIdForDrawWrapper[1]),
  127671. this._engine.setColorWrite(!0),
  127672. this._engine.setStencilFunction(a.NOTEQUAL)),
  127673. this._engine.setDepthWrite(!1),
  127674. this.render(i, n, !1, this._passIdForDrawWrapper[0]),
  127675. this._engine.setDepthWrite(this._savedDepthWrite),
  127676. r && r.needAlphaBlendingForMesh(t) && (this._engine.stencilStateComposer.useStencilGlobalOnly = !1,
  127677. this._engine.restoreStencilState())
  127678. }
  127679. }
  127680. ,
  127681. e.prototype._afterRenderingMesh = function(e, t, i) {
  127682. if (e.renderOverlay) {
  127683. var n = this._engine.getAlphaMode()
  127684. , r = this._engine.alphaState.alphaBlend;
  127685. this._engine.setAlphaMode(a.ALPHA_COMBINE),
  127686. this.render(t, i, !0, this._passIdForDrawWrapper[3]),
  127687. this._engine.setAlphaMode(n),
  127688. this._engine.setDepthWrite(this._savedDepthWrite),
  127689. this._engine.alphaState.alphaBlend = r
  127690. }
  127691. e.renderOutline && this._savedDepthWrite && (this._engine.setDepthWrite(!0),
  127692. this._engine.setColorWrite(!1),
  127693. this.render(t, i, !1, this._passIdForDrawWrapper[2]),
  127694. this._engine.setColorWrite(!0))
  127695. }
  127696. ,
  127697. e._StencilReference = 4,
  127698. e
  127699. }()
  127700. , Vb = function(e) {
  127701. function t(t, i) {
  127702. var n = e.call(this) || this;
  127703. return n.name = t,
  127704. n.animations = new Array,
  127705. n.isPickable = !1,
  127706. n.useAlphaForPicking = !1,
  127707. n.onDisposeObservable = new h,
  127708. n._onAnimationEnd = null,
  127709. n._endAnimation = function() {
  127710. n._onAnimationEnd && n._onAnimationEnd(),
  127711. n.disposeWhenFinishedAnimating && n.dispose()
  127712. }
  127713. ,
  127714. n.color = new N(1,1,1,1),
  127715. n.position = x.Zero(),
  127716. n._manager = i,
  127717. n._manager.sprites.push(n),
  127718. n.uniqueId = n._manager.scene.getUniqueId(),
  127719. n
  127720. }
  127721. return U(t, e),
  127722. Object.defineProperty(t.prototype, "size", {
  127723. get: function() {
  127724. return this.width
  127725. },
  127726. set: function(e) {
  127727. this.width = e,
  127728. this.height = e
  127729. },
  127730. enumerable: !1,
  127731. configurable: !0
  127732. }),
  127733. Object.defineProperty(t.prototype, "manager", {
  127734. get: function() {
  127735. return this._manager
  127736. },
  127737. enumerable: !1,
  127738. configurable: !0
  127739. }),
  127740. t.prototype.getClassName = function() {
  127741. return "Sprite"
  127742. }
  127743. ,
  127744. Object.defineProperty(t.prototype, "fromIndex", {
  127745. get: function() {
  127746. return this._fromIndex
  127747. },
  127748. set: function(e) {
  127749. this.playAnimation(e, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd)
  127750. },
  127751. enumerable: !1,
  127752. configurable: !0
  127753. }),
  127754. Object.defineProperty(t.prototype, "toIndex", {
  127755. get: function() {
  127756. return this._toIndex
  127757. },
  127758. set: function(e) {
  127759. this.playAnimation(this._fromIndex, e, this._loopAnimation, this._delay, this._onAnimationEnd)
  127760. },
  127761. enumerable: !1,
  127762. configurable: !0
  127763. }),
  127764. Object.defineProperty(t.prototype, "loopAnimation", {
  127765. get: function() {
  127766. return this._loopAnimation
  127767. },
  127768. set: function(e) {
  127769. this.playAnimation(this._fromIndex, this._toIndex, e, this._delay, this._onAnimationEnd)
  127770. },
  127771. enumerable: !1,
  127772. configurable: !0
  127773. }),
  127774. Object.defineProperty(t.prototype, "delay", {
  127775. get: function() {
  127776. return Math.max(this._delay, 1)
  127777. },
  127778. set: function(e) {
  127779. this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, e, this._onAnimationEnd)
  127780. },
  127781. enumerable: !1,
  127782. configurable: !0
  127783. }),
  127784. t.prototype.playAnimation = function(t, i, n, r, o) {
  127785. void 0 === o && (o = null),
  127786. this._onAnimationEnd = o,
  127787. e.prototype.playAnimation.call(this, t, i, n, r, this._endAnimation)
  127788. }
  127789. ,
  127790. t.prototype.dispose = function() {
  127791. for (var e = 0; e < this._manager.sprites.length; e++)
  127792. this._manager.sprites[e] == this && this._manager.sprites.splice(e, 1);
  127793. this.onDisposeObservable.notifyObservers(this),
  127794. this.onDisposeObservable.clear()
  127795. }
  127796. ,
  127797. t.prototype.serialize = function() {
  127798. var e = {};
  127799. return e.name = this.name,
  127800. e.position = this.position.asArray(),
  127801. e.color = this.color.asArray(),
  127802. e.width = this.width,
  127803. e.height = this.height,
  127804. e.angle = this.angle,
  127805. e.cellIndex = this.cellIndex,
  127806. e.cellRef = this.cellRef,
  127807. e.invertU = this.invertU,
  127808. e.invertV = this.invertV,
  127809. e.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating,
  127810. e.isPickable = this.isPickable,
  127811. e.isVisible = this.isVisible,
  127812. e.useAlphaForPicking = this.useAlphaForPicking,
  127813. e.animationStarted = this.animationStarted,
  127814. e.fromIndex = this.fromIndex,
  127815. e.toIndex = this.toIndex,
  127816. e.loopAnimation = this.loopAnimation,
  127817. e.delay = this.delay,
  127818. e
  127819. }
  127820. ,
  127821. t.Parse = function(e, i) {
  127822. var n = new t(e.name,i);
  127823. return n.position = x.FromArray(e.position),
  127824. n.color = N.FromArray(e.color),
  127825. n.width = e.width,
  127826. n.height = e.height,
  127827. n.angle = e.angle,
  127828. n.cellIndex = e.cellIndex,
  127829. n.cellRef = e.cellRef,
  127830. n.invertU = e.invertU,
  127831. n.invertV = e.invertV,
  127832. n.disposeWhenFinishedAnimating = e.disposeWhenFinishedAnimating,
  127833. n.isPickable = e.isPickable,
  127834. n.isVisible = e.isVisible,
  127835. n.useAlphaForPicking = e.useAlphaForPicking,
  127836. n.fromIndex = e.fromIndex,
  127837. n.toIndex = e.toIndex,
  127838. n.loopAnimation = e.loopAnimation,
  127839. n.delay = e.delay,
  127840. e.animationStarted && n.playAnimation(n.fromIndex, n.toIndex, n.loopAnimation, n.delay),
  127841. n
  127842. }
  127843. ,
  127844. t
  127845. }(function() {
  127846. function e() {
  127847. this.width = 1,
  127848. this.height = 1,
  127849. this.angle = 0,
  127850. this.invertU = !1,
  127851. this.invertV = !1,
  127852. this.isVisible = !0,
  127853. this._animationStarted = !1,
  127854. this._loopAnimation = !1,
  127855. this._fromIndex = 0,
  127856. this._toIndex = 0,
  127857. this._delay = 0,
  127858. this._direction = 1,
  127859. this._time = 0,
  127860. this._onBaseAnimationEnd = null,
  127861. this.position = {
  127862. x: 1,
  127863. y: 1,
  127864. z: 1
  127865. },
  127866. this.color = {
  127867. r: 1,
  127868. g: 1,
  127869. b: 1,
  127870. a: 1
  127871. }
  127872. }
  127873. return Object.defineProperty(e.prototype, "animationStarted", {
  127874. get: function() {
  127875. return this._animationStarted
  127876. },
  127877. enumerable: !1,
  127878. configurable: !0
  127879. }),
  127880. Object.defineProperty(e.prototype, "fromIndex", {
  127881. get: function() {
  127882. return this._fromIndex
  127883. },
  127884. enumerable: !1,
  127885. configurable: !0
  127886. }),
  127887. Object.defineProperty(e.prototype, "toIndex", {
  127888. get: function() {
  127889. return this._toIndex
  127890. },
  127891. enumerable: !1,
  127892. configurable: !0
  127893. }),
  127894. Object.defineProperty(e.prototype, "loopAnimation", {
  127895. get: function() {
  127896. return this._loopAnimation
  127897. },
  127898. enumerable: !1,
  127899. configurable: !0
  127900. }),
  127901. Object.defineProperty(e.prototype, "delay", {
  127902. get: function() {
  127903. return Math.max(this._delay, 1)
  127904. },
  127905. enumerable: !1,
  127906. configurable: !0
  127907. }),
  127908. e.prototype.playAnimation = function(e, t, i, n, r) {
  127909. this._fromIndex = e,
  127910. this._toIndex = t,
  127911. this._loopAnimation = i,
  127912. this._delay = n || 1,
  127913. this._animationStarted = !0,
  127914. this._onBaseAnimationEnd = r,
  127915. e < t ? this._direction = 1 : (this._direction = -1,
  127916. this._toIndex = e,
  127917. this._fromIndex = t),
  127918. this.cellIndex = e,
  127919. this._time = 0
  127920. }
  127921. ,
  127922. e.prototype.stopAnimation = function() {
  127923. this._animationStarted = !1
  127924. }
  127925. ,
  127926. e.prototype._animate = function(e) {
  127927. this._animationStarted && (this._time += e,
  127928. this._time > this._delay && (this._time = this._time % this._delay,
  127929. this.cellIndex += this._direction,
  127930. (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) && (this._loopAnimation ? this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex : (this.cellIndex = this._toIndex,
  127931. this._animationStarted = !1,
  127932. this._onBaseAnimationEnd && this._onBaseAnimationEnd()))))
  127933. }
  127934. ,
  127935. e
  127936. }());
  127937. mn.prototype._internalPickSprites = function(e, t, i, n) {
  127938. if (!Ui)
  127939. return null;
  127940. var r = null;
  127941. if (!n) {
  127942. if (!this.activeCamera)
  127943. return null;
  127944. n = this.activeCamera
  127945. }
  127946. if (this.spriteManagers.length > 0)
  127947. for (var o = 0; o < this.spriteManagers.length; o++) {
  127948. var a = this.spriteManagers[o];
  127949. if (a.isPickable) {
  127950. var s = a.intersects(e, n, t, i);
  127951. if (s && s.hit && (i || null == r || !(s.distance >= r.distance)) && (r = s,
  127952. i))
  127953. break
  127954. }
  127955. }
  127956. return r || new Ui
  127957. }
  127958. ,
  127959. mn.prototype._internalMultiPickSprites = function(e, t, i) {
  127960. if (!Ui)
  127961. return null;
  127962. var n = new Array;
  127963. if (!i) {
  127964. if (!this.activeCamera)
  127965. return null;
  127966. i = this.activeCamera
  127967. }
  127968. if (this.spriteManagers.length > 0)
  127969. for (var r = 0; r < this.spriteManagers.length; r++) {
  127970. var o = this.spriteManagers[r];
  127971. if (o.isPickable) {
  127972. var a = o.multiIntersects(e, i, t);
  127973. null !== a && (n = n.concat(a))
  127974. }
  127975. }
  127976. return n
  127977. }
  127978. ,
  127979. mn.prototype.pickSprite = function(e, t, i, n, r) {
  127980. if (!this._tempSpritePickingRay)
  127981. return null;
  127982. this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, r);
  127983. var o = this._internalPickSprites(this._tempSpritePickingRay, i, n, r);
  127984. return o && (o.ray = this.createPickingRayInCameraSpace(e, t, r)),
  127985. o
  127986. }
  127987. ,
  127988. mn.prototype.pickSpriteWithRay = function(e, t, i, n) {
  127989. if (!this._tempSpritePickingRay)
  127990. return null;
  127991. if (!n) {
  127992. if (!this.activeCamera)
  127993. return null;
  127994. n = this.activeCamera
  127995. }
  127996. _o.TransformToRef(e, n.getViewMatrix(), this._tempSpritePickingRay);
  127997. var r = this._internalPickSprites(this._tempSpritePickingRay, t, i, n);
  127998. return r && (r.ray = e),
  127999. r
  128000. }
  128001. ,
  128002. mn.prototype.multiPickSprite = function(e, t, i, n) {
  128003. return this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, n),
  128004. this._internalMultiPickSprites(this._tempSpritePickingRay, i, n)
  128005. }
  128006. ,
  128007. mn.prototype.multiPickSpriteWithRay = function(e, t, i) {
  128008. if (!this._tempSpritePickingRay)
  128009. return null;
  128010. if (!i) {
  128011. if (!this.activeCamera)
  128012. return null;
  128013. i = this.activeCamera
  128014. }
  128015. return _o.TransformToRef(e, i.getViewMatrix(), this._tempSpritePickingRay),
  128016. this._internalMultiPickSprites(this._tempSpritePickingRay, t, i)
  128017. }
  128018. ,
  128019. mn.prototype.setPointerOverSprite = function(e) {
  128020. this._pointerOverSprite !== e && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOutTrigger, w.CreateNewFromSprite(this._pointerOverSprite, this)),
  128021. this._pointerOverSprite = e,
  128022. this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOverTrigger, w.CreateNewFromSprite(this._pointerOverSprite, this)))
  128023. }
  128024. ,
  128025. mn.prototype.getPointerOverSprite = function() {
  128026. return this._pointerOverSprite
  128027. }
  128028. ;
  128029. var kb = function() {
  128030. function e(e) {
  128031. this.name = Wi.NAME_SPRITE,
  128032. this.scene = e,
  128033. this.scene.spriteManagers = new Array,
  128034. this.scene._tempSpritePickingRay = _o ? _o.Zero() : null,
  128035. this.scene.onBeforeSpritesRenderingObservable = new h,
  128036. this.scene.onAfterSpritesRenderingObservable = new h,
  128037. this._spritePredicate = function(e) {
  128038. return !!e.actionManager && e.isPickable && e.actionManager.hasPointerTriggers
  128039. }
  128040. }
  128041. return e.prototype.register = function() {
  128042. this.scene._pointerMoveStage.registerStep(Wi.STEP_POINTERMOVE_SPRITE, this, this._pointerMove),
  128043. this.scene._pointerDownStage.registerStep(Wi.STEP_POINTERDOWN_SPRITE, this, this._pointerDown),
  128044. this.scene._pointerUpStage.registerStep(Wi.STEP_POINTERUP_SPRITE, this, this._pointerUp)
  128045. }
  128046. ,
  128047. e.prototype.rebuild = function() {}
  128048. ,
  128049. e.prototype.dispose = function() {
  128050. this.scene.onBeforeSpritesRenderingObservable.clear(),
  128051. this.scene.onAfterSpritesRenderingObservable.clear();
  128052. for (var e = this.scene.spriteManagers; e.length; )
  128053. e[0].dispose()
  128054. }
  128055. ,
  128056. e.prototype._pickSpriteButKeepRay = function(e, t, i, n, r) {
  128057. var o = this.scene.pickSprite(t, i, this._spritePredicate, n, r);
  128058. return o && (o.ray = e ? e.ray : null),
  128059. o
  128060. }
  128061. ,
  128062. e.prototype._pointerMove = function(e, t, i, n, r) {
  128063. var o = this.scene;
  128064. return n ? o.setPointerOverSprite(null) : (i = this._pickSpriteButKeepRay(i, e, t, !1, o.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite ? (o.setPointerOverSprite(i.pickedSprite),
  128065. !o.doNotHandleCursors && r && (o._pointerOverSprite && o._pointerOverSprite.actionManager && o._pointerOverSprite.actionManager.hoverCursor ? r.style.cursor = o._pointerOverSprite.actionManager.hoverCursor : r.style.cursor = o.hoverCursor)) : o.setPointerOverSprite(null),
  128066. i
  128067. }
  128068. ,
  128069. e.prototype._pointerDown = function(e, t, i, n) {
  128070. var r = this.scene;
  128071. if (r._pickedDownSprite = null,
  128072. r.spriteManagers.length > 0 && (i = r.pickSprite(e, t, this._spritePredicate, !1, r.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite && i.pickedSprite.actionManager) {
  128073. switch (r._pickedDownSprite = i.pickedSprite,
  128074. n.button) {
  128075. case 0:
  128076. i.pickedSprite.actionManager.processTrigger(a.ACTION_OnLeftPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n));
  128077. break;
  128078. case 1:
  128079. i.pickedSprite.actionManager.processTrigger(a.ACTION_OnCenterPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n));
  128080. break;
  128081. case 2:
  128082. i.pickedSprite.actionManager.processTrigger(a.ACTION_OnRightPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n))
  128083. }
  128084. i.pickedSprite.actionManager && i.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickDownTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n))
  128085. }
  128086. return i
  128087. }
  128088. ,
  128089. e.prototype._pointerUp = function(e, t, i, n) {
  128090. var r = this.scene;
  128091. if (r.spriteManagers.length > 0) {
  128092. var o = r.pickSprite(e, t, this._spritePredicate, !1, r.cameraToUseForPointers || void 0);
  128093. o && (o.hit && o.pickedSprite && o.pickedSprite.actionManager && (o.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickUpTrigger, w.CreateNewFromSprite(o.pickedSprite, r, n)),
  128094. o.pickedSprite.actionManager && (this.scene._inputManager._isPointerSwiping() || o.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickTrigger, w.CreateNewFromSprite(o.pickedSprite, r, n)))),
  128095. r._pickedDownSprite && r._pickedDownSprite.actionManager && r._pickedDownSprite !== o.pickedSprite && r._pickedDownSprite.actionManager.processTrigger(a.ACTION_OnPickOutTrigger, w.CreateNewFromSprite(r._pickedDownSprite, r, n)))
  128096. }
  128097. return i
  128098. }
  128099. ,
  128100. e
  128101. }();
  128102. Pt.IncludesShadersStore.imageProcessingCompatibility = "#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n";
  128103. Pt.ShadersStore.spritesPixelShader = "uniform bool alphaTest;\nvarying vec4 vColor;\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
  128104. Pt.ShadersStore.spritesVertexShader = "attribute vec4 position;\nattribute vec2 options;\nattribute vec2 offsets;\nattribute vec2 inverts;\nattribute vec4 cellInfo;\nattribute vec4 color;\nuniform mat4 view;\nuniform mat4 projection;\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=offsets.xy;\ncornerPos=vec2(offset.x-0.5,offset.y -0.5)*size;\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\nvec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));\nvec2 uvPlace=cellInfo.xy;\nvec2 uvSize=cellInfo.zw;\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";
  128105. var Gb = function() {
  128106. function e(e, t, i, n) {
  128107. void 0 === i && (i = .01),
  128108. void 0 === n && (n = null),
  128109. this.blendMode = a.ALPHA_COMBINE,
  128110. this.autoResetAlpha = !0,
  128111. this.disableDepthWrite = !1,
  128112. this.fogEnabled = !0,
  128113. this._useVAO = !1,
  128114. this._useInstancing = !1,
  128115. this._vertexBuffers = {},
  128116. this._capacity = t,
  128117. this._epsilon = i,
  128118. this._engine = e,
  128119. this._useInstancing = e.getCaps().instancedArrays,
  128120. this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects,
  128121. this._scene = n,
  128122. this._drawWrapperBase = new Gt(e),
  128123. this._drawWrapperFog = new Gt(e),
  128124. this._drawWrapperDepth = new Gt(e,!1),
  128125. this._drawWrapperFogDepth = new Gt(e,!1),
  128126. this._useInstancing || this._buildIndexBuffer(),
  128127. this._drawWrapperBase.drawContext && (this._drawWrapperBase.drawContext.useInstancing = this._useInstancing),
  128128. this._drawWrapperFog.drawContext && (this._drawWrapperFog.drawContext.useInstancing = this._useInstancing),
  128129. this._drawWrapperDepth.drawContext && (this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing),
  128130. this._drawWrapperFogDepth.drawContext && (this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing),
  128131. this._vertexBufferSize = this._useInstancing ? 16 : 18,
  128132. this._vertexData = new Float32Array(t * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
  128133. this._buffer = new wi(e,this._vertexData,!0,this._vertexBufferSize);
  128134. var r, o = this._buffer.createVertexBuffer(Bi.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing), s = this._buffer.createVertexBuffer("options", 4, 2, this._vertexBufferSize, this._useInstancing), l = 6;
  128135. if (this._useInstancing) {
  128136. var c = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
  128137. this._spriteBuffer = new wi(e,c,!1,2),
  128138. r = this._spriteBuffer.createVertexBuffer("offsets", 0, 2)
  128139. } else
  128140. r = this._buffer.createVertexBuffer("offsets", l, 2, this._vertexBufferSize, this._useInstancing),
  128141. l += 2;
  128142. var u = this._buffer.createVertexBuffer("inverts", l, 2, this._vertexBufferSize, this._useInstancing)
  128143. , h = this._buffer.createVertexBuffer("cellInfo", l + 2, 4, this._vertexBufferSize, this._useInstancing)
  128144. , d = this._buffer.createVertexBuffer(Bi.ColorKind, l + 6, 4, this._vertexBufferSize, this._useInstancing);
  128145. this._vertexBuffers[Bi.PositionKind] = o,
  128146. this._vertexBuffers.options = s,
  128147. this._vertexBuffers.offsets = r,
  128148. this._vertexBuffers.inverts = u,
  128149. this._vertexBuffers.cellInfo = h,
  128150. this._vertexBuffers[Bi.ColorKind] = d,
  128151. this._drawWrapperBase.effect = this._engine.createEffect("sprites", [Bi.PositionKind, "options", "offsets", "inverts", "cellInfo", Bi.ColorKind], ["view", "projection", "textureInfos", "alphaTest"], ["diffuseSampler"], ""),
  128152. this._drawWrapperDepth.effect = this._drawWrapperBase.effect,
  128153. this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext,
  128154. this._scene && (this._drawWrapperFog.effect = this._scene.getEngine().createEffect("sprites", [Bi.PositionKind, "options", "offsets", "inverts", "cellInfo", Bi.ColorKind], ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"], ["diffuseSampler"], "#define FOG"),
  128155. this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect,
  128156. this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext)
  128157. }
  128158. return Object.defineProperty(e.prototype, "capacity", {
  128159. get: function() {
  128160. return this._capacity
  128161. },
  128162. enumerable: !1,
  128163. configurable: !0
  128164. }),
  128165. e.prototype.render = function(e, t, i, n, r) {
  128166. if (void 0 === r && (r = null),
  128167. this.texture && this.texture.isReady() && e.length) {
  128168. var o = this._drawWrapperBase
  128169. , s = this._drawWrapperDepth
  128170. , l = !1;
  128171. this.fogEnabled && this._scene && this._scene.fogEnabled && 0 !== this._scene.fogMode && (o = this._drawWrapperFog,
  128172. s = this._drawWrapperFogDepth,
  128173. l = !0);
  128174. var c = o.effect;
  128175. if (c.isReady()) {
  128176. for (var u = this._engine, h = !(!this._scene || !this._scene.useRightHandedSystem), d = this.texture.getBaseSize(), p = Math.min(this._capacity, e.length), f = 0, _ = !0, m = 0; m < p; m++) {
  128177. var g = e[m];
  128178. g && g.isVisible && (_ = !1,
  128179. g._animate(t),
  128180. this._appendSpriteVertex(f++, g, 0, 0, d, h, r),
  128181. this._useInstancing || (this._appendSpriteVertex(f++, g, 1, 0, d, h, r),
  128182. this._appendSpriteVertex(f++, g, 1, 1, d, h, r),
  128183. this._appendSpriteVertex(f++, g, 0, 1, d, h, r)))
  128184. }
  128185. if (!_) {
  128186. this._buffer.update(this._vertexData);
  128187. var v = !!u.depthCullingState.cull
  128188. , y = u.depthCullingState.zOffset
  128189. , b = u.depthCullingState.zOffsetUnits;
  128190. if (u.setState(v, y, !1, !1, void 0, void 0, b),
  128191. u.enableEffect(o),
  128192. c.setTexture("diffuseSampler", this.texture),
  128193. c.setMatrix("view", i),
  128194. c.setMatrix("projection", n),
  128195. l) {
  128196. var T = this._scene;
  128197. c.setFloat4("vFogInfos", T.fogMode, T.fogStart, T.fogEnd, T.fogDensity),
  128198. c.setColor3("vFogColor", T.fogColor)
  128199. }
  128200. this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = u.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, c)),
  128201. u.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : u.bindBuffers(this._vertexBuffers, this._indexBuffer, c),
  128202. u.depthCullingState.depthFunc = u.useReverseDepthBuffer ? a.GEQUAL : a.LEQUAL,
  128203. this.disableDepthWrite || (c.setBool("alphaTest", !0),
  128204. u.setColorWrite(!1),
  128205. u.enableEffect(s),
  128206. this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6),
  128207. u.enableEffect(o),
  128208. u.setColorWrite(!0),
  128209. c.setBool("alphaTest", !1)),
  128210. u.setAlphaMode(this.blendMode),
  128211. this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6),
  128212. this.autoResetAlpha && u.setAlphaMode(a.ALPHA_DISABLE),
  128213. h && this._scene.getEngine().setState(v, y, !1, !0, void 0, void 0, b),
  128214. u.unbindInstanceAttributes()
  128215. }
  128216. }
  128217. }
  128218. }
  128219. ,
  128220. e.prototype._appendSpriteVertex = function(e, t, i, n, r, o, a) {
  128221. var s = e * this._vertexBufferSize;
  128222. if (0 === i ? i = this._epsilon : 1 === i && (i = 1 - this._epsilon),
  128223. 0 === n ? n = this._epsilon : 1 === n && (n = 1 - this._epsilon),
  128224. a)
  128225. a(t, r);
  128226. else {
  128227. t.cellIndex || (t.cellIndex = 0);
  128228. var l = r.width / this.cellWidth
  128229. , c = t.cellIndex / l >> 0;
  128230. t._xOffset = (t.cellIndex - c * l) * this.cellWidth / r.width,
  128231. t._yOffset = c * this.cellHeight / r.height,
  128232. t._xSize = this.cellWidth,
  128233. t._ySize = this.cellHeight
  128234. }
  128235. this._vertexData[s] = t.position.x,
  128236. this._vertexData[s + 1] = t.position.y,
  128237. this._vertexData[s + 2] = t.position.z,
  128238. this._vertexData[s + 3] = t.angle,
  128239. this._vertexData[s + 4] = t.width,
  128240. this._vertexData[s + 5] = t.height,
  128241. this._useInstancing ? s -= 2 : (this._vertexData[s + 6] = i,
  128242. this._vertexData[s + 7] = n),
  128243. this._vertexData[s + 8] = o ? t.invertU ? 0 : 1 : t.invertU ? 1 : 0,
  128244. this._vertexData[s + 9] = t.invertV ? 1 : 0,
  128245. this._vertexData[s + 10] = t._xOffset,
  128246. this._vertexData[s + 11] = t._yOffset,
  128247. this._vertexData[s + 12] = t._xSize / r.width,
  128248. this._vertexData[s + 13] = t._ySize / r.height,
  128249. this._vertexData[s + 14] = t.color.r,
  128250. this._vertexData[s + 15] = t.color.g,
  128251. this._vertexData[s + 16] = t.color.b,
  128252. this._vertexData[s + 17] = t.color.a
  128253. }
  128254. ,
  128255. e.prototype._buildIndexBuffer = function() {
  128256. for (var e = [], t = 0, i = 0; i < this._capacity; i++)
  128257. e.push(t),
  128258. e.push(t + 1),
  128259. e.push(t + 2),
  128260. e.push(t),
  128261. e.push(t + 2),
  128262. e.push(t + 3),
  128263. t += 4;
  128264. this._indexBuffer = this._engine.createIndexBuffer(e)
  128265. }
  128266. ,
  128267. e.prototype.rebuild = function() {
  128268. var e;
  128269. for (var t in this._indexBuffer && this._buildIndexBuffer(),
  128270. this._useVAO && (this._vertexArrayObject = void 0),
  128271. this._buffer._rebuild(),
  128272. this._vertexBuffers)
  128273. this._vertexBuffers[t]._rebuild();
  128274. null === (e = this._spriteBuffer) || void 0 === e || e._rebuild()
  128275. }
  128276. ,
  128277. e.prototype.dispose = function() {
  128278. this._buffer && (this._buffer.dispose(),
  128279. this._buffer = null),
  128280. this._spriteBuffer && (this._spriteBuffer.dispose(),
  128281. this._spriteBuffer = null),
  128282. this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
  128283. this._indexBuffer = null),
  128284. this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
  128285. this._vertexArrayObject = null),
  128286. this.texture && (this.texture.dispose(),
  128287. this.texture = null),
  128288. this._drawWrapperBase.dispose(),
  128289. this._drawWrapperFog.dispose(),
  128290. this._drawWrapperDepth.dispose(),
  128291. this._drawWrapperFogDepth.dispose()
  128292. }
  128293. ,
  128294. e
  128295. }()
  128296. , zb = function() {
  128297. function e(e, t, i, n, r, o, a, s, l) {
  128298. void 0 === o && (o = .01),
  128299. void 0 === a && (a = io.TRILINEAR_SAMPLINGMODE),
  128300. void 0 === s && (s = !1),
  128301. void 0 === l && (l = null);
  128302. var c = this;
  128303. this.name = e,
  128304. this.sprites = new Array,
  128305. this.renderingGroupId = 0,
  128306. this.layerMask = 268435455,
  128307. this.isPickable = !1,
  128308. this.onDisposeObservable = new h,
  128309. this._disableDepthWrite = !1,
  128310. this._packedAndReady = !1,
  128311. this._customUpdate = function(e, t) {
  128312. e.cellRef || (e.cellIndex = 0);
  128313. var i = e.cellIndex;
  128314. "number" == typeof i && isFinite(i) && Math.floor(i) === i && (e.cellRef = c._spriteMap[e.cellIndex]),
  128315. e._xOffset = c._cellData[e.cellRef].frame.x / t.width,
  128316. e._yOffset = c._cellData[e.cellRef].frame.y / t.height,
  128317. e._xSize = c._cellData[e.cellRef].frame.w,
  128318. e._ySize = c._cellData[e.cellRef].frame.h
  128319. }
  128320. ,
  128321. r || (r = E.LastCreatedScene),
  128322. r._getComponent(Wi.NAME_SPRITE) || r._addComponent(new kb(r)),
  128323. this._fromPacked = s,
  128324. this._scene = r;
  128325. var u = this._scene.getEngine();
  128326. if (this._spriteRenderer = new Gb(u,i,o,r),
  128327. n.width && n.height)
  128328. this.cellWidth = n.width,
  128329. this.cellHeight = n.height;
  128330. else {
  128331. if (void 0 === n)
  128332. return void (this._spriteRenderer = null);
  128333. this.cellWidth = n,
  128334. this.cellHeight = n
  128335. }
  128336. this._scene.spriteManagers.push(this),
  128337. this.uniqueId = this.scene.getUniqueId(),
  128338. t && (this.texture = new io(t,r,!0,!1,a)),
  128339. this._fromPacked && this._makePacked(t, l)
  128340. }
  128341. return Object.defineProperty(e.prototype, "onDispose", {
  128342. set: function(e) {
  128343. this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
  128344. this._onDisposeObserver = this.onDisposeObservable.add(e)
  128345. },
  128346. enumerable: !1,
  128347. configurable: !0
  128348. }),
  128349. Object.defineProperty(e.prototype, "children", {
  128350. get: function() {
  128351. return this.sprites
  128352. },
  128353. enumerable: !1,
  128354. configurable: !0
  128355. }),
  128356. Object.defineProperty(e.prototype, "scene", {
  128357. get: function() {
  128358. return this._scene
  128359. },
  128360. enumerable: !1,
  128361. configurable: !0
  128362. }),
  128363. Object.defineProperty(e.prototype, "capacity", {
  128364. get: function() {
  128365. return this._spriteRenderer.capacity
  128366. },
  128367. enumerable: !1,
  128368. configurable: !0
  128369. }),
  128370. Object.defineProperty(e.prototype, "texture", {
  128371. get: function() {
  128372. return this._spriteRenderer.texture
  128373. },
  128374. set: function(e) {
  128375. e.wrapU = io.CLAMP_ADDRESSMODE,
  128376. e.wrapV = io.CLAMP_ADDRESSMODE,
  128377. this._spriteRenderer.texture = e,
  128378. this._textureContent = null
  128379. },
  128380. enumerable: !1,
  128381. configurable: !0
  128382. }),
  128383. Object.defineProperty(e.prototype, "cellWidth", {
  128384. get: function() {
  128385. return this._spriteRenderer.cellWidth
  128386. },
  128387. set: function(e) {
  128388. this._spriteRenderer.cellWidth = e
  128389. },
  128390. enumerable: !1,
  128391. configurable: !0
  128392. }),
  128393. Object.defineProperty(e.prototype, "cellHeight", {
  128394. get: function() {
  128395. return this._spriteRenderer.cellHeight
  128396. },
  128397. set: function(e) {
  128398. this._spriteRenderer.cellHeight = e
  128399. },
  128400. enumerable: !1,
  128401. configurable: !0
  128402. }),
  128403. Object.defineProperty(e.prototype, "fogEnabled", {
  128404. get: function() {
  128405. return this._spriteRenderer.fogEnabled
  128406. },
  128407. set: function(e) {
  128408. this._spriteRenderer.fogEnabled = e
  128409. },
  128410. enumerable: !1,
  128411. configurable: !0
  128412. }),
  128413. Object.defineProperty(e.prototype, "blendMode", {
  128414. get: function() {
  128415. return this._spriteRenderer.blendMode
  128416. },
  128417. set: function(e) {
  128418. this._spriteRenderer.blendMode = e
  128419. },
  128420. enumerable: !1,
  128421. configurable: !0
  128422. }),
  128423. Object.defineProperty(e.prototype, "disableDepthWrite", {
  128424. get: function() {
  128425. return this._disableDepthWrite
  128426. },
  128427. set: function(e) {
  128428. this._disableDepthWrite = e,
  128429. this._spriteRenderer.disableDepthWrite = e
  128430. },
  128431. enumerable: !1,
  128432. configurable: !0
  128433. }),
  128434. e.prototype.getClassName = function() {
  128435. return "SpriteManager"
  128436. }
  128437. ,
  128438. e.prototype._makePacked = function(e, t) {
  128439. var i = this;
  128440. if (null !== t)
  128441. try {
  128442. var n = void 0;
  128443. if ((n = "string" == typeof t ? JSON.parse(t) : t).frames.length) {
  128444. for (var r = {}, o = 0; o < n.frames.length; o++) {
  128445. var a = n.frames[o];
  128446. if ("string" != typeof Object.keys(a)[0])
  128447. throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");
  128448. r[a[Object.keys(a)[0]]] = a
  128449. }
  128450. n.frames = r
  128451. }
  128452. var s = Reflect.ownKeys(n.frames);
  128453. this._spriteMap = s,
  128454. this._packedAndReady = !0,
  128455. this._cellData = n.frames
  128456. } catch (e) {
  128457. throw this._fromPacked = !1,
  128458. this._packedAndReady = !1,
  128459. new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")
  128460. }
  128461. else {
  128462. var l = /\./g
  128463. , c = void 0;
  128464. do {
  128465. c = l.lastIndex,
  128466. l.test(e)
  128467. } while (l.lastIndex > 0);
  128468. var u = e.substring(0, c - 1) + ".json";
  128469. gi.LoadFile(u, (function(e) {
  128470. try {
  128471. var t = JSON.parse(e)
  128472. , n = Reflect.ownKeys(t.frames);
  128473. i._spriteMap = n,
  128474. i._packedAndReady = !0,
  128475. i._cellData = t.frames
  128476. } catch (e) {
  128477. throw i._fromPacked = !1,
  128478. i._packedAndReady = !1,
  128479. new Error("Invalid JSON format. Please check documentation for format specifications.")
  128480. }
  128481. }
  128482. ), void 0, void 0, !1, (function() {
  128483. K.Error("JSON ERROR: Unable to load JSON file."),
  128484. i._fromPacked = !1,
  128485. i._packedAndReady = !1
  128486. }
  128487. ))
  128488. }
  128489. }
  128490. ,
  128491. e.prototype._checkTextureAlpha = function(e, t, i, n, r) {
  128492. if (!e.useAlphaForPicking || !this.texture)
  128493. return !0;
  128494. var o = this.texture.getSize();
  128495. this._textureContent || (this._textureContent = new Uint8Array(o.width * o.height * 4),
  128496. this.texture.readPixels(0, 0, this._textureContent));
  128497. var a = I.Vector3[0];
  128498. a.copyFrom(t.direction),
  128499. a.normalize(),
  128500. a.scaleInPlace(i),
  128501. a.addInPlace(t.origin);
  128502. var s = (a.x - n.x) / (r.x - n.x) - .5
  128503. , l = 1 - (a.y - n.y) / (r.y - n.y) - .5
  128504. , c = e.angle
  128505. , u = s * Math.cos(c) - l * Math.sin(c) + .5
  128506. , h = s * Math.sin(c) + l * Math.cos(c) + .5
  128507. , d = e._xOffset * o.width + u * e._xSize | 0
  128508. , p = e._yOffset * o.height + h * e._ySize | 0;
  128509. return this._textureContent[4 * (d + p * o.width) + 3] > .5
  128510. }
  128511. ,
  128512. e.prototype.intersects = function(e, t, i, n) {
  128513. for (var r = Math.min(this.capacity, this.sprites.length), o = x.Zero(), a = x.Zero(), s = Number.MAX_VALUE, l = null, c = I.Vector3[0], u = I.Vector3[1], h = t.getViewMatrix(), d = e, p = e, f = 0; f < r; f++) {
  128514. var _ = this.sprites[f];
  128515. if (_) {
  128516. if (i) {
  128517. if (!i(_))
  128518. continue
  128519. } else if (!_.isPickable)
  128520. continue;
  128521. if (x.TransformCoordinatesToRef(_.position, h, u),
  128522. _.angle ? (P.TranslationToRef(-u.x, -u.y, 0, I.Matrix[1]),
  128523. P.TranslationToRef(u.x, u.y, 0, I.Matrix[2]),
  128524. P.RotationZToRef(_.angle, I.Matrix[3]),
  128525. I.Matrix[1].multiplyToRef(I.Matrix[3], I.Matrix[4]),
  128526. I.Matrix[4].multiplyToRef(I.Matrix[2], I.Matrix[0]),
  128527. d = e.clone(),
  128528. x.TransformCoordinatesToRef(e.origin, I.Matrix[0], d.origin),
  128529. x.TransformNormalToRef(e.direction, I.Matrix[0], d.direction)) : d = e,
  128530. o.copyFromFloats(u.x - _.width / 2, u.y - _.height / 2, u.z),
  128531. a.copyFromFloats(u.x + _.width / 2, u.y + _.height / 2, u.z),
  128532. d.intersectsBoxMinMax(o, a)) {
  128533. var m = x.Distance(u, d.origin);
  128534. if (s > m) {
  128535. if (!this._checkTextureAlpha(_, d, m, o, a))
  128536. continue;
  128537. if (p = d,
  128538. s = m,
  128539. l = _,
  128540. n)
  128541. break
  128542. }
  128543. }
  128544. }
  128545. }
  128546. if (l) {
  128547. var g = new Ui;
  128548. h.invertToRef(I.Matrix[0]),
  128549. g.hit = !0,
  128550. g.pickedSprite = l,
  128551. g.distance = s;
  128552. var v = I.Vector3[2];
  128553. return v.copyFrom(p.direction),
  128554. v.normalize(),
  128555. v.scaleInPlace(s),
  128556. p.origin.addToRef(v, c),
  128557. g.pickedPoint = x.TransformCoordinates(c, I.Matrix[0]),
  128558. g
  128559. }
  128560. return null
  128561. }
  128562. ,
  128563. e.prototype.multiIntersects = function(e, t, i) {
  128564. for (var n, r = Math.min(this.capacity, this.sprites.length), o = x.Zero(), a = x.Zero(), s = [], l = I.Vector3[0].copyFromFloats(0, 0, 0), c = I.Vector3[1].copyFromFloats(0, 0, 0), u = t.getViewMatrix(), h = 0; h < r; h++) {
  128565. var d = this.sprites[h];
  128566. if (d) {
  128567. if (i) {
  128568. if (!i(d))
  128569. continue
  128570. } else if (!d.isPickable)
  128571. continue;
  128572. if (x.TransformCoordinatesToRef(d.position, u, c),
  128573. o.copyFromFloats(c.x - d.width / 2, c.y - d.height / 2, c.z),
  128574. a.copyFromFloats(c.x + d.width / 2, c.y + d.height / 2, c.z),
  128575. e.intersectsBoxMinMax(o, a)) {
  128576. if (n = x.Distance(c, e.origin),
  128577. !this._checkTextureAlpha(d, e, n, o, a))
  128578. continue;
  128579. var p = new Ui;
  128580. s.push(p),
  128581. u.invertToRef(I.Matrix[0]),
  128582. p.hit = !0,
  128583. p.pickedSprite = d,
  128584. p.distance = n;
  128585. var f = I.Vector3[2];
  128586. f.copyFrom(e.direction),
  128587. f.normalize(),
  128588. f.scaleInPlace(n),
  128589. e.origin.addToRef(f, l),
  128590. p.pickedPoint = x.TransformCoordinates(l, I.Matrix[0])
  128591. }
  128592. }
  128593. }
  128594. return s
  128595. }
  128596. ,
  128597. e.prototype.render = function() {
  128598. if (!this._fromPacked || this._packedAndReady && this._spriteMap && this._cellData) {
  128599. var e = this._scene.getEngine().getDeltaTime();
  128600. this._packedAndReady ? this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate) : this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix())
  128601. }
  128602. }
  128603. ,
  128604. e.prototype.rebuild = function() {
  128605. var e;
  128606. null === (e = this._spriteRenderer) || void 0 === e || e.rebuild()
  128607. }
  128608. ,
  128609. e.prototype.dispose = function() {
  128610. this._spriteRenderer && (this._spriteRenderer.dispose(),
  128611. this._spriteRenderer = null),
  128612. this._textureContent = null;
  128613. var e = this._scene.spriteManagers.indexOf(this);
  128614. this._scene.spriteManagers.splice(e, 1),
  128615. this.onDisposeObservable.notifyObservers(this),
  128616. this.onDisposeObservable.clear()
  128617. }
  128618. ,
  128619. e.prototype.serialize = function(e) {
  128620. void 0 === e && (e = !1);
  128621. var t = {};
  128622. t.name = this.name,
  128623. t.capacity = this.capacity,
  128624. t.cellWidth = this.cellWidth,
  128625. t.cellHeight = this.cellHeight,
  128626. this.texture && (e ? t.texture = this.texture.serialize() : (t.textureUrl = this.texture.name,
  128627. t.invertY = this.texture._invertY)),
  128628. t.sprites = [];
  128629. for (var i = 0, n = this.sprites; i < n.length; i++) {
  128630. var r = n[i];
  128631. t.sprites.push(r.serialize())
  128632. }
  128633. return t
  128634. }
  128635. ,
  128636. e.Parse = function(t, i, n) {
  128637. var r = new e(t.name,"",t.capacity,{
  128638. width: t.cellWidth,
  128639. height: t.cellHeight
  128640. },i);
  128641. t.texture ? r.texture = io.Parse(t.texture, i, n) : t.textureName && (r.texture = new io(n + t.textureUrl,i,!1,void 0 === t.invertY || t.invertY));
  128642. for (var o = 0, a = t.sprites; o < a.length; o++) {
  128643. var s = a[o];
  128644. Vb.Parse(s, r)
  128645. }
  128646. return r
  128647. }
  128648. ,
  128649. e.ParseFromFileAsync = function(t, i, n, r) {
  128650. return void 0 === r && (r = ""),
  128651. new Promise((function(o, a) {
  128652. var s = new Ye;
  128653. s.addEventListener("readystatechange", (function() {
  128654. if (4 == s.readyState)
  128655. if (200 == s.status) {
  128656. var i = JSON.parse(s.responseText)
  128657. , l = e.Parse(i, n || E.LastCreatedScene, r);
  128658. t && (l.name = t),
  128659. o(l)
  128660. } else
  128661. a("Unable to load the sprite manager")
  128662. }
  128663. )),
  128664. s.open("GET", i),
  128665. s.send()
  128666. }
  128667. ))
  128668. }
  128669. ,
  128670. e.CreateFromSnippetAsync = function(t, i, n) {
  128671. var r = this;
  128672. return void 0 === n && (n = ""),
  128673. "_BLANK" === t ? Promise.resolve(new e("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,i)) : new Promise((function(o, a) {
  128674. var s = new Ye;
  128675. s.addEventListener("readystatechange", (function() {
  128676. if (4 == s.readyState)
  128677. if (200 == s.status) {
  128678. var r = JSON.parse(JSON.parse(s.responseText).jsonPayload)
  128679. , l = JSON.parse(r.spriteManager)
  128680. , c = e.Parse(l, i || E.LastCreatedScene, n);
  128681. c.snippetId = t,
  128682. o(c)
  128683. } else
  128684. a("Unable to load the snippet " + t)
  128685. }
  128686. )),
  128687. s.open("GET", r.SnippetUrl + "/" + t.replace(/#/g, "/")),
  128688. s.send()
  128689. }
  128690. ))
  128691. }
  128692. ,
  128693. e.SnippetUrl = "https://snippet.babylonjs.com",
  128694. e
  128695. }();
  128696. Pt.ShadersStore.spriteMapPixelShader = "precision highp float;\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nuniform float time;\nuniform float spriteCount;\nuniform sampler2D spriteSheet;\nuniform vec2 spriteMapSize;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform sampler2D frameMap;\nuniform sampler2D tileMaps[LAYERS];\nuniform sampler2D animationMap;\nuniform vec3 colorMul;\nfloat mt;\nconst float fdStep=1./4.;\nconst float aFrameSteps=1./MAX_ANIMATION_FRAMES;\nmat4 getFrameData(float frameID){\nfloat fX=frameID/spriteCount;\nreturn mat4(\ntexture2D(frameMap,vec2(fX,0.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*1.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*2.),0.),\nvec4(0.)\n);\n}\nvoid main(){\nvec4 color=vec4(0.);\nvec2 tileUV=fract(tUV);\n#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\n#endif\nvec2 tileID=floor(tUV);\nvec2 sheetUnits=1./spriteMapSize;\nfloat spriteUnits=1./spriteCount;\nvec2 stageUnits=1./stageSize;\nfor(int i=0; i<LAYERS; i++) {\nfloat frameID;\n#define LAYER_ID_SWITCH\nvec4 animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.); \nif(animationData.y>0.) {\nmt=mod(time*animationData.z,1.0);\nfor(float f=0.; f<MAX_ANIMATION_FRAMES; f++){\nif(animationData.y>mt){\nframeID=animationData.x;\nbreak;\n}\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.); \n}\n}\nmat4 frameData=getFrameData(frameID+0.5);\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\nvec2 offset=frameData[0].xy*sheetUnits;\nvec2 ratio=frameData[2].xy/frameData[0].wz;\nif (frameData[2].z==1.){\ntileUV.xy=tileUV.yx;\n}\nif (i==0){\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\n} else {\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\nfloat alpha=min(color.a+nc.a,1.0);\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\ncolor=vec4(mixed,alpha);\n}\n}\ncolor.xyz*=colorMul;\ngl_FragColor=color;\n}";
  128697. Pt.ShadersStore.spriteMapVertexShader = "precision highp float;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nvarying vec2 stageUnits;\nvarying vec2 levelUnits;\nvarying vec2 tileID;\nuniform float time;\nuniform mat4 worldViewProjection;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform vec2 spriteMapSize;\nuniform float stageScale;\nvoid main() {\nvec4 p=vec4( position,1. );\nvPosition=p.xyz;\nvUV=uv;\ntUV=uv*stageSize; \ngl_Position=worldViewProjection*p;\n}";
  128698. var Wb, Hb = function() {
  128699. function e(e, t, i, n, r) {
  128700. var o = this;
  128701. this.name = e,
  128702. this.sprites = [],
  128703. this.atlasJSON = t,
  128704. this.sprites = this.atlasJSON.frames,
  128705. this.spriteSheet = i,
  128706. this.options = n,
  128707. n.stageSize = n.stageSize || new A(1,1),
  128708. n.outputSize = n.outputSize || n.stageSize,
  128709. n.outputPosition = n.outputPosition || x.Zero(),
  128710. n.outputRotation = n.outputRotation || x.Zero(),
  128711. n.layerCount = n.layerCount || 1,
  128712. n.maxAnimationFrames = n.maxAnimationFrames || 0,
  128713. n.baseTile = n.baseTile || 0,
  128714. n.flipU = n.flipU || !1,
  128715. n.colorMultiply = n.colorMultiply || new x(1,1,1),
  128716. this._scene = r,
  128717. this._frameMap = this._createFrameBuffer(),
  128718. this._tileMaps = new Array;
  128719. for (var a = 0; a < n.layerCount; a++)
  128720. this._tileMaps.push(this._createTileBuffer(null, a));
  128721. this._animationMap = this._createTileAnimationBuffer(null);
  128722. var s = [];
  128723. s.push("#define LAYERS " + n.layerCount),
  128724. n.flipU && s.push("#define FLIPU"),
  128725. s.push("#define MAX_ANIMATION_FRAMES ".concat(n.maxAnimationFrames, ".0"));
  128726. var l, c = Mt.ShadersStore.spriteMapPixelShader;
  128727. if (r.getEngine()._features.supportSwitchCaseInShader) {
  128728. for (l = "switch(i) {",
  128729. a = 0; a < n.layerCount; a++)
  128730. l += "case " + a + " : frameID = texture(tileMaps[" + a + "], (tileID + 0.5) / stageSize, 0.).x;",
  128731. l += "break;";
  128732. l += "}"
  128733. } else {
  128734. l = "";
  128735. for (a = 0; a < n.layerCount; a++)
  128736. l += "if (".concat(a, " == i) { frameID = texture2D(tileMaps[").concat(a, "], (tileID + 0.5) / stageSize, 0.).x; }")
  128737. }
  128738. Mt.ShadersStore["spriteMap" + this.name + "PixelShader"] = c.replace("#define LAYER_ID_SWITCH", l),
  128739. this._material = new jl("spriteMap:" + this.name,this._scene,{
  128740. vertex: "spriteMap",
  128741. fragment: "spriteMap" + this.name
  128742. },{
  128743. defines: s,
  128744. attributes: ["position", "normal", "uv"],
  128745. uniforms: ["worldViewProjection", "time", "stageSize", "outputSize", "spriteMapSize", "spriteCount", "time", "colorMul", "mousePosition", "curTile", "flipU"],
  128746. samplers: ["spriteSheet", "frameMap", "tileMaps", "animationMap"],
  128747. needAlphaBlending: !0
  128748. }),
  128749. this._time = 0,
  128750. this._material.setFloat("spriteCount", this.spriteCount),
  128751. this._material.setVector2("stageSize", n.stageSize),
  128752. this._material.setVector2("outputSize", n.outputSize),
  128753. this._material.setTexture("spriteSheet", this.spriteSheet),
  128754. this._material.setVector2("spriteMapSize", new A(1,1)),
  128755. this._material.setVector3("colorMul", n.colorMultiply);
  128756. var u = 0
  128757. , h = function() {
  128758. o.spriteSheet && o.spriteSheet.isReady() && o.spriteSheet._texture ? o._material.setVector2("spriteMapSize", new A(o.spriteSheet._texture.baseWidth || 1,o.spriteSheet._texture.baseHeight || 1)) : u < 100 && setTimeout((function() {
  128759. u++,
  128760. h()
  128761. }
  128762. ), 100)
  128763. };
  128764. h(),
  128765. this._material.setVector3("colorMul", n.colorMultiply),
  128766. this._material.setTexture("frameMap", this._frameMap),
  128767. this._material.setTextureArray("tileMaps", this._tileMaps),
  128768. this._material.setTexture("animationMap", this._animationMap),
  128769. this._material.setFloat("time", this._time),
  128770. this._output = vo(e + ":output", {
  128771. size: 1,
  128772. updatable: !0
  128773. }, r),
  128774. this._output.scaling.x = n.outputSize.x,
  128775. this._output.scaling.y = n.outputSize.y,
  128776. this.position = n.outputPosition,
  128777. this.rotation = n.outputRotation,
  128778. this._scene.onBeforeRenderObservable.add((function() {
  128779. o._time += o._scene.getEngine().getDeltaTime(),
  128780. o._material.setFloat("time", o._time)
  128781. }
  128782. )),
  128783. this._output.material = this._material
  128784. }
  128785. return Object.defineProperty(e.prototype, "spriteCount", {
  128786. get: function() {
  128787. return this.sprites.length
  128788. },
  128789. enumerable: !1,
  128790. configurable: !0
  128791. }),
  128792. Object.defineProperty(e.prototype, "position", {
  128793. get: function() {
  128794. return this._output.position
  128795. },
  128796. set: function(e) {
  128797. this._output.position = e
  128798. },
  128799. enumerable: !1,
  128800. configurable: !0
  128801. }),
  128802. Object.defineProperty(e.prototype, "rotation", {
  128803. get: function() {
  128804. return this._output.rotation
  128805. },
  128806. set: function(e) {
  128807. this._output.rotation = e
  128808. },
  128809. enumerable: !1,
  128810. configurable: !0
  128811. }),
  128812. Object.defineProperty(e.prototype, "animationMap", {
  128813. get: function() {
  128814. return this._animationMap
  128815. },
  128816. set: function(e) {
  128817. var t = e._texture._bufferView
  128818. , i = this._createTileAnimationBuffer(t);
  128819. this._animationMap.dispose(),
  128820. this._animationMap = i,
  128821. this._material.setTexture("animationMap", this._animationMap)
  128822. },
  128823. enumerable: !1,
  128824. configurable: !0
  128825. }),
  128826. e.prototype.getTileID = function() {
  128827. var e = this.getMousePosition();
  128828. return e.multiplyInPlace(this.options.stageSize || A.Zero()),
  128829. e.x = Math.floor(e.x),
  128830. e.y = Math.floor(e.y),
  128831. e
  128832. }
  128833. ,
  128834. e.prototype.getMousePosition = function() {
  128835. var e = this._output
  128836. , t = this._scene.pick(this._scene.pointerX, this._scene.pointerY, (function(t) {
  128837. return t === e
  128838. }
  128839. ));
  128840. return t && t.hit && t.getTextureCoordinates && t.getTextureCoordinates() || new A(-1,-1)
  128841. }
  128842. ,
  128843. e.prototype._createFrameBuffer = function() {
  128844. for (var e = new Array, t = 0; t < this.spriteCount; t++)
  128845. e.push(0, 0, 0, 0),
  128846. e.push(0, 0, 0, 0),
  128847. e.push(0, 0, 0, 0),
  128848. e.push(0, 0, 0, 0);
  128849. for (t = 0; t < this.spriteCount; t++) {
  128850. var i = this.sprites[t].frame
  128851. , n = this.sprites[t].spriteSourceSize
  128852. , r = this.sprites[t].sourceSize
  128853. , o = this.sprites[t].rotated ? 1 : 0
  128854. , a = this.sprites[t].trimmed ? 1 : 0;
  128855. e[4 * t] = i.x,
  128856. e[4 * t + 1] = i.y,
  128857. e[4 * t + 2] = i.w,
  128858. e[4 * t + 3] = i.h,
  128859. e[4 * t + 4 * this.spriteCount] = n.x,
  128860. e[4 * t + 1 + 4 * this.spriteCount] = n.y,
  128861. e[4 * t + 3 + 4 * this.spriteCount] = n.h,
  128862. e[4 * t + 8 * this.spriteCount] = r.w,
  128863. e[4 * t + 1 + 8 * this.spriteCount] = r.h,
  128864. e[4 * t + 2 + 8 * this.spriteCount] = o,
  128865. e[4 * t + 3 + 8 * this.spriteCount] = a
  128866. }
  128867. var s = new Float32Array(e);
  128868. return ao.CreateRGBATexture(s, this.spriteCount, 4, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
  128869. }
  128870. ,
  128871. e.prototype._createTileBuffer = function(e, t) {
  128872. void 0 === t && (t = 0);
  128873. var i = new Array
  128874. , n = this.options.stageSize.y || 0
  128875. , r = this.options.stageSize.x || 0;
  128876. if (e)
  128877. i = e;
  128878. else {
  128879. var o = this.options.baseTile;
  128880. 0 != t && (o = 0);
  128881. for (var a = 0; a < n; a++)
  128882. for (var s = 0; s < 4 * r; s += 4)
  128883. i.push(o, 0, 0, 0)
  128884. }
  128885. var l = new Float32Array(i);
  128886. return ao.CreateRGBATexture(l, r, n, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
  128887. }
  128888. ,
  128889. e.prototype.changeTiles = function(e, t, i) {
  128890. void 0 === e && (e = 0),
  128891. void 0 === i && (i = 0);
  128892. var n = this._tileMaps[e]._texture._bufferView;
  128893. if (null !== n) {
  128894. var r = new Array;
  128895. t instanceof A ? r.push(t) : r = t;
  128896. for (var o = this.options.stageSize.x || 0, a = 0; a < r.length; a++) {
  128897. var s = r[a];
  128898. s.x = Math.floor(s.x),
  128899. s.y = Math.floor(s.y),
  128900. n[4 * s.x + s.y * (4 * o)] = i
  128901. }
  128902. var l = this._createTileBuffer(n);
  128903. this._tileMaps[e].dispose(),
  128904. this._tileMaps[e] = l,
  128905. this._material.setTextureArray("tileMap", this._tileMaps)
  128906. }
  128907. }
  128908. ,
  128909. e.prototype._createTileAnimationBuffer = function(e) {
  128910. var t, i = new Array;
  128911. if (e)
  128912. t = e;
  128913. else {
  128914. for (var n = 0; n < this.spriteCount; n++) {
  128915. i.push(0, 0, 0, 0);
  128916. for (var r = 1; r < (this.options.maxAnimationFrames || 4); )
  128917. i.push(0, 0, 0, 0),
  128918. r++
  128919. }
  128920. t = new Float32Array(i)
  128921. }
  128922. return ao.CreateRGBATexture(t, this.spriteCount, this.options.maxAnimationFrames || 4, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
  128923. }
  128924. ,
  128925. e.prototype.addAnimationToTile = function(e, t, i, n, r) {
  128926. void 0 === e && (e = 0),
  128927. void 0 === t && (t = 0),
  128928. void 0 === i && (i = 0),
  128929. void 0 === n && (n = 0),
  128930. void 0 === r && (r = 1);
  128931. var o = this._animationMap._texture._bufferView
  128932. , a = 4 * e + 4 * this.spriteCount * t;
  128933. if (o) {
  128934. o[a] = i,
  128935. o[a + 1] = n,
  128936. o[a + 2] = r;
  128937. var s = this._createTileAnimationBuffer(o);
  128938. this._animationMap.dispose(),
  128939. this._animationMap = s,
  128940. this._material.setTexture("animationMap", this._animationMap)
  128941. }
  128942. }
  128943. ,
  128944. e.prototype.saveTileMaps = function() {
  128945. for (var e = "", t = 0; t < this._tileMaps.length; t++)
  128946. t > 0 && (e += "\n\r"),
  128947. e += this._tileMaps[t]._texture._bufferView.toString();
  128948. var i = document.createElement("a");
  128949. i.href = "data:octet/stream;charset=utf-8," + encodeURI(e),
  128950. i.target = "_blank",
  128951. i.download = this.name + ".tilemaps",
  128952. i.click(),
  128953. i.remove()
  128954. }
  128955. ,
  128956. e.prototype.loadTileMaps = function(e) {
  128957. var t = this
  128958. , i = new XMLHttpRequest;
  128959. i.open("GET", e);
  128960. var n = this.options.layerCount || 0;
  128961. i.onload = function() {
  128962. for (var e = i.response.split("\n\r"), r = 0; r < n; r++) {
  128963. var o = e[r].split(",").map(Number)
  128964. , a = t._createTileBuffer(o);
  128965. t._tileMaps[r].dispose(),
  128966. t._tileMaps[r] = a
  128967. }
  128968. t._material.setTextureArray("tileMap", t._tileMaps)
  128969. }
  128970. ,
  128971. i.send()
  128972. }
  128973. ,
  128974. e.prototype.dispose = function() {
  128975. this._output.dispose(),
  128976. this._material.dispose(),
  128977. this._animationMap.dispose(),
  128978. this._tileMaps.forEach((function(e) {
  128979. e.dispose()
  128980. }
  128981. )),
  128982. this._frameMap.dispose()
  128983. }
  128984. ,
  128985. e
  128986. }(), Xb = function(e) {
  128987. function t(t, i, n, r, o, a, s) {
  128988. void 0 === o && (o = null),
  128989. void 0 === a && (a = .01),
  128990. void 0 === s && (s = io.TRILINEAR_SAMPLINGMODE);
  128991. var l = e.call(this, t, i, n, 64, r, a, s, !0, o) || this;
  128992. return l.name = t,
  128993. l
  128994. }
  128995. return U(t, e),
  128996. t
  128997. }(zb);
  128998. !function(e) {
  128999. e[e.INIT = 0] = "INIT",
  129000. e[e.RUNNING = 1] = "RUNNING",
  129001. e[e.DONE = 2] = "DONE",
  129002. e[e.ERROR = 3] = "ERROR"
  129003. }(Wb || (Wb = {}));
  129004. var jb = function() {
  129005. function e(e) {
  129006. this.name = e,
  129007. this._isCompleted = !1,
  129008. this._taskState = Wb.INIT
  129009. }
  129010. return Object.defineProperty(e.prototype, "isCompleted", {
  129011. get: function() {
  129012. return this._isCompleted
  129013. },
  129014. enumerable: !1,
  129015. configurable: !0
  129016. }),
  129017. Object.defineProperty(e.prototype, "taskState", {
  129018. get: function() {
  129019. return this._taskState
  129020. },
  129021. enumerable: !1,
  129022. configurable: !0
  129023. }),
  129024. Object.defineProperty(e.prototype, "errorObject", {
  129025. get: function() {
  129026. return this._errorObject
  129027. },
  129028. enumerable: !1,
  129029. configurable: !0
  129030. }),
  129031. e.prototype._setErrorObject = function(e, t) {
  129032. this._errorObject || (this._errorObject = {
  129033. message: e,
  129034. exception: t
  129035. })
  129036. }
  129037. ,
  129038. e.prototype.run = function(e, t, i) {
  129039. var n = this;
  129040. this._taskState = Wb.RUNNING,
  129041. this.runTask(e, (function() {
  129042. n._onDoneCallback(t, i)
  129043. }
  129044. ), (function(e, t) {
  129045. n._onErrorCallback(i, e, t)
  129046. }
  129047. ))
  129048. }
  129049. ,
  129050. e.prototype.runTask = function(e, t, i) {
  129051. throw new Error("runTask is not implemented")
  129052. }
  129053. ,
  129054. e.prototype.reset = function() {
  129055. this._taskState = Wb.INIT
  129056. }
  129057. ,
  129058. e.prototype._onErrorCallback = function(e, t, i) {
  129059. this._taskState = Wb.ERROR,
  129060. this._errorObject = {
  129061. message: t,
  129062. exception: i
  129063. },
  129064. this.onError && this.onError(this, t, i),
  129065. e()
  129066. }
  129067. ,
  129068. e.prototype._onDoneCallback = function(e, t) {
  129069. try {
  129070. this._taskState = Wb.DONE,
  129071. this._isCompleted = !0,
  129072. this.onSuccess && this.onSuccess(this),
  129073. e()
  129074. } catch (e) {
  129075. this._onErrorCallback(t, "Task is done, error executing success callback(s)", e)
  129076. }
  129077. }
  129078. ,
  129079. e
  129080. }()
  129081. , Yb = function(e, t, i) {
  129082. this.remainingCount = e,
  129083. this.totalCount = t,
  129084. this.task = i
  129085. }
  129086. , Kb = function(e) {
  129087. function t(t, i, n, r) {
  129088. var o = e.call(this, t) || this;
  129089. return o.name = t,
  129090. o.meshesNames = i,
  129091. o.rootUrl = n,
  129092. o.sceneFilename = r,
  129093. o
  129094. }
  129095. return U(t, e),
  129096. t.prototype.runTask = function(e, t, i) {
  129097. var n = this;
  129098. od.LoadAssetContainer(this.rootUrl, this.sceneFilename, e, (function(e) {
  129099. n.loadedContainer = e,
  129100. n.loadedMeshes = e.meshes,
  129101. n.loadedParticleSystems = e.particleSystems,
  129102. n.loadedSkeletons = e.skeletons,
  129103. n.loadedAnimationGroups = e.animationGroups,
  129104. t()
  129105. }
  129106. ), null, (function(e, t, n) {
  129107. i(t, n)
  129108. }
  129109. ))
  129110. }
  129111. ,
  129112. t
  129113. }(jb)
  129114. , Qb = function(e) {
  129115. function t(t, i, n, r) {
  129116. var o = e.call(this, t) || this;
  129117. return o.name = t,
  129118. o.meshesNames = i,
  129119. o.rootUrl = n,
  129120. o.sceneFilename = r,
  129121. o
  129122. }
  129123. return U(t, e),
  129124. t.prototype.runTask = function(e, t, i) {
  129125. var n = this;
  129126. od.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, e, (function(e, i, r, o) {
  129127. n.loadedMeshes = e,
  129128. n.loadedParticleSystems = i,
  129129. n.loadedSkeletons = r,
  129130. n.loadedAnimationGroups = o,
  129131. t()
  129132. }
  129133. ), null, (function(e, t, n) {
  129134. i(t, n)
  129135. }
  129136. ))
  129137. }
  129138. ,
  129139. t
  129140. }(jb)
  129141. , qb = function(e) {
  129142. function t(t, i) {
  129143. var n = e.call(this, t) || this;
  129144. return n.name = t,
  129145. n.url = i,
  129146. n
  129147. }
  129148. return U(t, e),
  129149. t.prototype.runTask = function(e, t, i) {
  129150. var n = this;
  129151. e._loadFile(this.url, (function(e) {
  129152. n.text = e,
  129153. t()
  129154. }
  129155. ), void 0, !1, !1, (function(e, t) {
  129156. e && i(e.status + " " + e.statusText, t)
  129157. }
  129158. ))
  129159. }
  129160. ,
  129161. t
  129162. }(jb)
  129163. , Zb = function(e) {
  129164. function t(t, i) {
  129165. var n = e.call(this, t) || this;
  129166. return n.name = t,
  129167. n.url = i,
  129168. n
  129169. }
  129170. return U(t, e),
  129171. t.prototype.runTask = function(e, t, i) {
  129172. var n = this;
  129173. e._loadFile(this.url, (function(e) {
  129174. n.data = e,
  129175. t()
  129176. }
  129177. ), void 0, !0, !0, (function(e, t) {
  129178. e && i(e.status + " " + e.statusText, t)
  129179. }
  129180. ))
  129181. }
  129182. ,
  129183. t
  129184. }(jb)
  129185. , Jb = function(e) {
  129186. function t(t, i) {
  129187. var n = e.call(this, t) || this;
  129188. return n.name = t,
  129189. n.url = i,
  129190. n
  129191. }
  129192. return U(t, e),
  129193. t.prototype.runTask = function(e, t, i) {
  129194. var n = this
  129195. , r = new Image;
  129196. gi.SetCorsBehavior(this.url, r),
  129197. r.onload = function() {
  129198. n.image = r,
  129199. t()
  129200. }
  129201. ,
  129202. r.onerror = function(e) {
  129203. i("Error loading image", e)
  129204. }
  129205. ,
  129206. r.src = this.url
  129207. }
  129208. ,
  129209. t
  129210. }(jb)
  129211. , $b = function(e) {
  129212. function t(t, i, n, r, o) {
  129213. void 0 === r && (r = !0),
  129214. void 0 === o && (o = io.TRILINEAR_SAMPLINGMODE);
  129215. var a = e.call(this, t) || this;
  129216. return a.name = t,
  129217. a.url = i,
  129218. a.noMipmap = n,
  129219. a.invertY = r,
  129220. a.samplingMode = o,
  129221. a
  129222. }
  129223. return U(t, e),
  129224. t.prototype.runTask = function(e, t, i) {
  129225. this.texture = new io(this.url,e,this.noMipmap,this.invertY,this.samplingMode,(function() {
  129226. t()
  129227. }
  129228. ),(function(e, t) {
  129229. i(e, t)
  129230. }
  129231. ))
  129232. }
  129233. ,
  129234. t
  129235. }(jb)
  129236. , eT = function(e) {
  129237. function t(t, i, n, r, o, a) {
  129238. var s = e.call(this, t) || this;
  129239. return s.name = t,
  129240. s.url = i,
  129241. s.extensions = n,
  129242. s.noMipmap = r,
  129243. s.files = o,
  129244. s.prefiltered = a,
  129245. s
  129246. }
  129247. return U(t, e),
  129248. t.prototype.runTask = function(e, t, i) {
  129249. this.texture = new Bd(this.url,e,this.extensions,this.noMipmap,this.files,(function() {
  129250. t()
  129251. }
  129252. ),(function(e, t) {
  129253. i(e, t)
  129254. }
  129255. ),void 0,this.prefiltered)
  129256. }
  129257. ,
  129258. t
  129259. }(jb)
  129260. , tT = function(e) {
  129261. function t(t, i, n, r, o, a, s) {
  129262. void 0 === r && (r = !1),
  129263. void 0 === o && (o = !0),
  129264. void 0 === a && (a = !1),
  129265. void 0 === s && (s = !1);
  129266. var l = e.call(this, t) || this;
  129267. return l.name = t,
  129268. l.url = i,
  129269. l.size = n,
  129270. l.noMipmap = r,
  129271. l.generateHarmonics = o,
  129272. l.gammaSpace = a,
  129273. l.reserved = s,
  129274. l
  129275. }
  129276. return U(t, e),
  129277. t.prototype.runTask = function(e, t, i) {
  129278. this.texture = new E_(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,(function() {
  129279. t()
  129280. }
  129281. ),(function(e, t) {
  129282. i(e, t)
  129283. }
  129284. ))
  129285. }
  129286. ,
  129287. t
  129288. }(jb)
  129289. , iT = function(e) {
  129290. function t(t, i, n, r, o) {
  129291. void 0 === r && (r = !1),
  129292. void 0 === o && (o = !0);
  129293. var a = e.call(this, t) || this;
  129294. return a.name = t,
  129295. a.url = i,
  129296. a.size = n,
  129297. a.noMipmap = r,
  129298. a.gammaSpace = o,
  129299. a
  129300. }
  129301. return U(t, e),
  129302. t.prototype.runTask = function(e, t, i) {
  129303. this.texture = new K_(this.url,e,this.size,this.noMipmap,this.gammaSpace,(function() {
  129304. t()
  129305. }
  129306. ),(function(e, t) {
  129307. i(e, t)
  129308. }
  129309. ))
  129310. }
  129311. ,
  129312. t
  129313. }(jb)
  129314. , nT = function() {
  129315. function e(e) {
  129316. this._isLoading = !1,
  129317. this._tasks = new Array,
  129318. this._waitingTasksCount = 0,
  129319. this._totalTasksCount = 0,
  129320. this.onTaskSuccessObservable = new h,
  129321. this.onTaskErrorObservable = new h,
  129322. this.onTasksDoneObservable = new h,
  129323. this.onProgressObservable = new h,
  129324. this.useDefaultLoadingScreen = !0,
  129325. this.autoHideLoadingUI = !0,
  129326. this._scene = e || E.LastCreatedScene
  129327. }
  129328. return e.prototype.addContainerTask = function(e, t, i, n) {
  129329. var r = new Kb(e,t,i,n);
  129330. return this._tasks.push(r),
  129331. r
  129332. }
  129333. ,
  129334. e.prototype.addMeshTask = function(e, t, i, n) {
  129335. var r = new Qb(e,t,i,n);
  129336. return this._tasks.push(r),
  129337. r
  129338. }
  129339. ,
  129340. e.prototype.addTextFileTask = function(e, t) {
  129341. var i = new qb(e,t);
  129342. return this._tasks.push(i),
  129343. i
  129344. }
  129345. ,
  129346. e.prototype.addBinaryFileTask = function(e, t) {
  129347. var i = new Zb(e,t);
  129348. return this._tasks.push(i),
  129349. i
  129350. }
  129351. ,
  129352. e.prototype.addImageTask = function(e, t) {
  129353. var i = new Jb(e,t);
  129354. return this._tasks.push(i),
  129355. i
  129356. }
  129357. ,
  129358. e.prototype.addTextureTask = function(e, t, i, n, r) {
  129359. void 0 === r && (r = io.TRILINEAR_SAMPLINGMODE);
  129360. var o = new $b(e,t,i,n,r);
  129361. return this._tasks.push(o),
  129362. o
  129363. }
  129364. ,
  129365. e.prototype.addCubeTextureTask = function(e, t, i, n, r, o) {
  129366. var a = new eT(e,t,i,n,r,o);
  129367. return this._tasks.push(a),
  129368. a
  129369. }
  129370. ,
  129371. e.prototype.addHDRCubeTextureTask = function(e, t, i, n, r, o, a) {
  129372. void 0 === n && (n = !1),
  129373. void 0 === r && (r = !0),
  129374. void 0 === o && (o = !1),
  129375. void 0 === a && (a = !1);
  129376. var s = new tT(e,t,i,n,r,o,a);
  129377. return this._tasks.push(s),
  129378. s
  129379. }
  129380. ,
  129381. e.prototype.addEquiRectangularCubeTextureAssetTask = function(e, t, i, n, r) {
  129382. void 0 === n && (n = !1),
  129383. void 0 === r && (r = !0);
  129384. var o = new iT(e,t,i,n,r);
  129385. return this._tasks.push(o),
  129386. o
  129387. }
  129388. ,
  129389. e.prototype.removeTask = function(e) {
  129390. var t = this._tasks.indexOf(e);
  129391. t > -1 && this._tasks.splice(t, 1)
  129392. }
  129393. ,
  129394. e.prototype._decreaseWaitingTasksCount = function(e) {
  129395. this._waitingTasksCount--;
  129396. try {
  129397. this.onProgress && this.onProgress(this._waitingTasksCount, this._totalTasksCount, e),
  129398. this.onProgressObservable.notifyObservers(new Yb(this._waitingTasksCount,this._totalTasksCount,e))
  129399. } catch (e) {
  129400. K.Error("Error running progress callbacks."),
  129401. console.log(e)
  129402. }
  129403. if (0 === this._waitingTasksCount) {
  129404. try {
  129405. var t = this._tasks.slice();
  129406. this.onFinish && this.onFinish(t);
  129407. for (var i = 0, n = t; i < n.length; i++) {
  129408. var r = n[i];
  129409. if (r.taskState === Wb.DONE) {
  129410. var o = this._tasks.indexOf(r);
  129411. o > -1 && this._tasks.splice(o, 1)
  129412. }
  129413. }
  129414. this.onTasksDoneObservable.notifyObservers(this._tasks)
  129415. } catch (e) {
  129416. K.Error("Error running tasks-done callbacks."),
  129417. console.log(e)
  129418. }
  129419. this._isLoading = !1,
  129420. this.autoHideLoadingUI && this._scene.getEngine().hideLoadingUI()
  129421. }
  129422. }
  129423. ,
  129424. e.prototype._runTask = function(e) {
  129425. var t = this
  129426. , i = function(i, n) {
  129427. e._setErrorObject(i, n),
  129428. t.onTaskError ? t.onTaskError(e) : e.onError || K.Error(t._formatTaskErrorMessage(e)),
  129429. t.onTaskErrorObservable.notifyObservers(e),
  129430. t._decreaseWaitingTasksCount(e)
  129431. };
  129432. e.run(this._scene, (function() {
  129433. try {
  129434. t.onTaskSuccess && t.onTaskSuccess(e),
  129435. t.onTaskSuccessObservable.notifyObservers(e),
  129436. t._decreaseWaitingTasksCount(e)
  129437. } catch (e) {
  129438. i("Error executing task success callbacks", e)
  129439. }
  129440. }
  129441. ), i)
  129442. }
  129443. ,
  129444. e.prototype._formatTaskErrorMessage = function(e) {
  129445. var t = "Unable to complete task " + e.name;
  129446. return e.errorObject.message && (t += ": ".concat(e.errorObject.message)),
  129447. e.errorObject.exception && (t += ": ".concat(e.errorObject.exception)),
  129448. t
  129449. }
  129450. ,
  129451. e.prototype.reset = function() {
  129452. return this._isLoading = !1,
  129453. this._tasks = new Array,
  129454. this
  129455. }
  129456. ,
  129457. e.prototype.load = function() {
  129458. if (this._isLoading)
  129459. return this;
  129460. if (this._isLoading = !0,
  129461. this._waitingTasksCount = this._tasks.length,
  129462. this._totalTasksCount = this._tasks.length,
  129463. 0 === this._waitingTasksCount)
  129464. return this._isLoading = !1,
  129465. this.onFinish && this.onFinish(this._tasks),
  129466. this.onTasksDoneObservable.notifyObservers(this._tasks),
  129467. this;
  129468. this.useDefaultLoadingScreen && this._scene.getEngine().displayLoadingUI();
  129469. for (var e = 0; e < this._tasks.length; e++) {
  129470. var t = this._tasks[e];
  129471. t.taskState === Wb.INIT && this._runTask(t)
  129472. }
  129473. return this
  129474. }
  129475. ,
  129476. e.prototype.loadAsync = function() {
  129477. var e = this;
  129478. return new Promise((function(t, i) {
  129479. e._isLoading ? t() : (e.onTasksDoneObservable.addOnce((function(e) {
  129480. e && e.length ? i(e) : t()
  129481. }
  129482. )),
  129483. e.load())
  129484. }
  129485. ))
  129486. }
  129487. ,
  129488. e
  129489. }()
  129490. , rT = function() {
  129491. function e() {
  129492. var e = this;
  129493. this.promise = new Promise((function(t, i) {
  129494. e._resolve = t,
  129495. e._reject = i
  129496. }
  129497. ))
  129498. }
  129499. return Object.defineProperty(e.prototype, "resolve", {
  129500. get: function() {
  129501. return this._resolve
  129502. },
  129503. enumerable: !1,
  129504. configurable: !0
  129505. }),
  129506. Object.defineProperty(e.prototype, "reject", {
  129507. get: function() {
  129508. return this._reject
  129509. },
  129510. enumerable: !1,
  129511. configurable: !0
  129512. }),
  129513. e
  129514. }()
  129515. , oT = function() {
  129516. function e(e, t) {
  129517. this._meshesOrigins = [],
  129518. this._toCenterVectors = [],
  129519. this._scaledDirection = x.Zero(),
  129520. this._newPosition = x.Zero(),
  129521. this._centerPosition = x.Zero(),
  129522. this._meshes = e.slice(),
  129523. t ? this._centerMesh = t : this._setCenterMesh();
  129524. var i = this._meshes.indexOf(this._centerMesh);
  129525. i >= 0 && this._meshes.splice(i, 1),
  129526. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  129527. for (var n = 0; n < this._meshes.length; n++)
  129528. if (this._meshes[n]) {
  129529. var r = this._meshes[n];
  129530. this._meshesOrigins[n] = r.getAbsolutePosition().clone(),
  129531. this._toCenterVectors[n] = x.Zero(),
  129532. r.hasBoundingInfo && this._centerMesh.hasBoundingInfo && r.getBoundingInfo().boundingBox.centerWorld.subtractToRef(this._centerMesh.getBoundingInfo().boundingBox.centerWorld, this._toCenterVectors[n])
  129533. }
  129534. }
  129535. return e.prototype._setCenterMesh = function() {
  129536. for (var e = x.Zero(), t = x.Zero(), i = Number.MAX_VALUE, n = 0; n < this._meshes.length; n++)
  129537. this._meshes[n] && (o = (r = this._meshes[n]).getBoundingInfo()) && t.addInPlace(o.boundingBox.centerWorld);
  129538. for (e = t.scale(1 / this._meshes.length),
  129539. n = 0; n < this._meshes.length; n++) {
  129540. var r, o;
  129541. if (this._meshes[n] && (o = (r = this._meshes[n]).getBoundingInfo())) {
  129542. var a = o.boundingBox.centerWorld.subtract(e).lengthSquared();
  129543. a < i && (this._centerMesh = r,
  129544. i = a)
  129545. }
  129546. }
  129547. }
  129548. ,
  129549. e.prototype.getClassName = function() {
  129550. return "MeshExploder"
  129551. }
  129552. ,
  129553. e.prototype.getMeshes = function() {
  129554. var e = this._meshes.slice();
  129555. return e.unshift(this._centerMesh),
  129556. e
  129557. }
  129558. ,
  129559. e.prototype.explode = function(e) {
  129560. void 0 === e && (e = 1);
  129561. for (var t = 0; t < this._meshes.length; t++)
  129562. this._meshes[t] && this._meshesOrigins[t] && this._toCenterVectors[t] && (this._toCenterVectors[t].scaleToRef(e, this._scaledDirection),
  129563. this._meshesOrigins[t].addToRef(this._scaledDirection, this._newPosition),
  129564. this._meshes[t].setAbsolutePosition(this._newPosition));
  129565. this._centerMesh.setAbsolutePosition(this._centerPosition)
  129566. }
  129567. ,
  129568. e
  129569. }()
  129570. , aT = function() {
  129571. function e(e, t, i, n, r, o, a, s, l) {
  129572. var c = this;
  129573. this.onProcessFileCallback = function() {
  129574. return !0
  129575. }
  129576. ,
  129577. this.loadAsync = function(e, t) {
  129578. return od.LoadAsync("file:", e, c._engine, t)
  129579. }
  129580. ,
  129581. this._engine = e,
  129582. this._currentScene = t,
  129583. this._sceneLoadedCallback = i,
  129584. this._progressCallback = n,
  129585. this._additionalRenderLoopLogicCallback = r,
  129586. this._textureLoadingCallback = o,
  129587. this._startingProcessingFilesCallback = a,
  129588. this._onReloadCallback = s,
  129589. this._errorCallback = l
  129590. }
  129591. return Object.defineProperty(e, "FilesToLoad", {
  129592. get: function() {
  129593. return ut.FilesToLoad
  129594. },
  129595. enumerable: !1,
  129596. configurable: !0
  129597. }),
  129598. e.prototype.monitorElementForDragNDrop = function(e) {
  129599. var t = this;
  129600. e && (this._elementToMonitor = e,
  129601. this._dragEnterHandler = function(e) {
  129602. t._drag(e)
  129603. }
  129604. ,
  129605. this._dragOverHandler = function(e) {
  129606. t._drag(e)
  129607. }
  129608. ,
  129609. this._dropHandler = function(e) {
  129610. t._drop(e)
  129611. }
  129612. ,
  129613. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, !1),
  129614. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, !1),
  129615. this._elementToMonitor.addEventListener("drop", this._dropHandler, !1))
  129616. }
  129617. ,
  129618. Object.defineProperty(e.prototype, "filesToLoad", {
  129619. get: function() {
  129620. return this._filesToLoad
  129621. },
  129622. enumerable: !1,
  129623. configurable: !0
  129624. }),
  129625. e.prototype.dispose = function() {
  129626. this._elementToMonitor && (this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler),
  129627. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler),
  129628. this._elementToMonitor.removeEventListener("drop", this._dropHandler))
  129629. }
  129630. ,
  129631. e.prototype._renderFunction = function() {
  129632. if (this._additionalRenderLoopLogicCallback && this._additionalRenderLoopLogicCallback(),
  129633. this._currentScene) {
  129634. if (this._textureLoadingCallback) {
  129635. var e = this._currentScene.getWaitingItemsCount();
  129636. e > 0 && this._textureLoadingCallback(e)
  129637. }
  129638. this._currentScene.render()
  129639. }
  129640. }
  129641. ,
  129642. e.prototype._drag = function(e) {
  129643. e.stopPropagation(),
  129644. e.preventDefault()
  129645. }
  129646. ,
  129647. e.prototype._drop = function(e) {
  129648. e.stopPropagation(),
  129649. e.preventDefault(),
  129650. this.loadFiles(e)
  129651. }
  129652. ,
  129653. e.prototype._traverseFolder = function(e, t, i, n) {
  129654. var r = this
  129655. , o = e.createReader()
  129656. , a = e.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  129657. o.readEntries((function(e) {
  129658. i.count += e.length;
  129659. for (var o = 0, s = e; o < s.length; o++) {
  129660. var l = s[o];
  129661. l.isFile ? l.file((function(e) {
  129662. e.correctName = a + e.name,
  129663. t.push(e),
  129664. 0 == --i.count && n()
  129665. }
  129666. )) : l.isDirectory && r._traverseFolder(l, t, i, n)
  129667. }
  129668. 0 == --i.count && n()
  129669. }
  129670. ))
  129671. }
  129672. ,
  129673. e.prototype._processFiles = function(t) {
  129674. for (var i = this, n = 0; n < t.length; n++) {
  129675. var r = t[n].correctName.toLowerCase()
  129676. , o = r.split(".").pop();
  129677. this.onProcessFileCallback(t[n], r, o, (function(e) {
  129678. return i._sceneFileToLoad = e
  129679. }
  129680. )) && (od.IsPluginForExtensionAvailable("." + o) && (this._sceneFileToLoad = t[n]),
  129681. e.FilesToLoad[r] = t[n])
  129682. }
  129683. }
  129684. ,
  129685. e.prototype.loadFiles = function(e) {
  129686. var t = this;
  129687. if (e && e.dataTransfer && e.dataTransfer.files && (this._filesToLoad = e.dataTransfer.files),
  129688. e && e.target && e.target.files && (this._filesToLoad = e.target.files),
  129689. this._filesToLoad && 0 !== this._filesToLoad.length && (this._startingProcessingFilesCallback && this._startingProcessingFilesCallback(this._filesToLoad),
  129690. this._filesToLoad && this._filesToLoad.length > 0)) {
  129691. for (var i = new Array, n = [], r = e.dataTransfer ? e.dataTransfer.items : null, o = 0; o < this._filesToLoad.length; o++) {
  129692. var a = this._filesToLoad[o]
  129693. , s = a.name.toLowerCase()
  129694. , l = void 0;
  129695. if (a.correctName = s,
  129696. r) {
  129697. var c = r[o];
  129698. c.getAsEntry ? l = c.getAsEntry() : c.webkitGetAsEntry && (l = c.webkitGetAsEntry())
  129699. }
  129700. l && l.isDirectory ? n.push(l) : i.push(a)
  129701. }
  129702. if (0 === n.length)
  129703. this._processFiles(i),
  129704. this._processReload();
  129705. else
  129706. for (var u = {
  129707. count: n.length
  129708. }, h = 0, d = n; h < d.length; h++) {
  129709. var p = d[h];
  129710. this._traverseFolder(p, i, u, (function() {
  129711. t._processFiles(i),
  129712. 0 === u.count && t._processReload()
  129713. }
  129714. ))
  129715. }
  129716. }
  129717. }
  129718. ,
  129719. e.prototype._processReload = function() {
  129720. this._onReloadCallback ? this._onReloadCallback(this._sceneFileToLoad) : this.reload()
  129721. }
  129722. ,
  129723. e.prototype.reload = function() {
  129724. var e = this;
  129725. this._sceneFileToLoad ? (this._currentScene && (K.errorsCount > 0 && K.ClearLogCache(),
  129726. this._engine.stopRenderLoop()),
  129727. od.ShowLoadingScreen = !1,
  129728. this._engine.displayLoadingUI(),
  129729. this.loadAsync(this._sceneFileToLoad, this._progressCallback).then((function(t) {
  129730. e._currentScene && e._currentScene.dispose(),
  129731. e._currentScene = t,
  129732. e._sceneLoadedCallback && e._sceneLoadedCallback(e._sceneFileToLoad, e._currentScene),
  129733. e._currentScene.executeWhenReady((function() {
  129734. e._engine.hideLoadingUI(),
  129735. e._engine.runRenderLoop((function() {
  129736. e._renderFunction()
  129737. }
  129738. ))
  129739. }
  129740. ))
  129741. }
  129742. )).catch((function(t) {
  129743. e._engine.hideLoadingUI(),
  129744. e._errorCallback && e._errorCallback(e._sceneFileToLoad, e._currentScene, t.message)
  129745. }
  129746. ))) : K.Error("Please provide a valid .babylon file.")
  129747. }
  129748. ,
  129749. e
  129750. }()
  129751. , sT = function() {
  129752. function e(e) {
  129753. void 0 === e && (e = 0),
  129754. this.priority = e
  129755. }
  129756. return e.prototype.getDescription = function() {
  129757. return ""
  129758. }
  129759. ,
  129760. e.prototype.apply = function(e, t) {
  129761. return !0
  129762. }
  129763. ,
  129764. e
  129765. }()
  129766. , lT = function(e) {
  129767. function t(t, i, n) {
  129768. void 0 === t && (t = 0),
  129769. void 0 === i && (i = 1024),
  129770. void 0 === n && (n = .5);
  129771. var r = e.call(this, t) || this;
  129772. return r.priority = t,
  129773. r.maximumSize = i,
  129774. r.step = n,
  129775. r
  129776. }
  129777. return U(t, e),
  129778. t.prototype.getDescription = function() {
  129779. return "Reducing render target texture size to " + this.maximumSize
  129780. }
  129781. ,
  129782. t.prototype.apply = function(e, t) {
  129783. for (var i = !0, n = 0; n < e.textures.length; n++) {
  129784. var r = e.textures[n];
  129785. if (r.canRescale && !r.getContext) {
  129786. var o = r.getSize();
  129787. Math.max(o.width, o.height) > this.maximumSize && (r.scale(this.step),
  129788. i = !1)
  129789. }
  129790. }
  129791. return i
  129792. }
  129793. ,
  129794. t
  129795. }(sT)
  129796. , cT = function(e) {
  129797. function t(t, i, n) {
  129798. void 0 === t && (t = 0),
  129799. void 0 === i && (i = 2),
  129800. void 0 === n && (n = .25);
  129801. var r = e.call(this, t) || this;
  129802. return r.priority = t,
  129803. r.maximumScale = i,
  129804. r.step = n,
  129805. r._currentScale = -1,
  129806. r._directionOffset = 1,
  129807. r
  129808. }
  129809. return U(t, e),
  129810. t.prototype.getDescription = function() {
  129811. return "Setting hardware scaling level to " + this._currentScale
  129812. }
  129813. ,
  129814. t.prototype.apply = function(e, t) {
  129815. return -1 === this._currentScale && (this._currentScale = e.getEngine().getHardwareScalingLevel(),
  129816. this._currentScale > this.maximumScale && (this._directionOffset = -1)),
  129817. this._currentScale += this._directionOffset * this.step,
  129818. e.getEngine().setHardwareScalingLevel(this._currentScale),
  129819. 1 === this._directionOffset ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale
  129820. }
  129821. ,
  129822. t
  129823. }(sT)
  129824. , uT = function(e) {
  129825. function t() {
  129826. return null !== e && e.apply(this, arguments) || this
  129827. }
  129828. return U(t, e),
  129829. t.prototype.getDescription = function() {
  129830. return "Turning shadows on/off"
  129831. }
  129832. ,
  129833. t.prototype.apply = function(e, t) {
  129834. return e.shadowsEnabled = t.isInImprovementMode,
  129835. !0
  129836. }
  129837. ,
  129838. t
  129839. }(sT)
  129840. , hT = function(e) {
  129841. function t() {
  129842. return null !== e && e.apply(this, arguments) || this
  129843. }
  129844. return U(t, e),
  129845. t.prototype.getDescription = function() {
  129846. return "Turning post-processes on/off"
  129847. }
  129848. ,
  129849. t.prototype.apply = function(e, t) {
  129850. return e.postProcessesEnabled = t.isInImprovementMode,
  129851. !0
  129852. }
  129853. ,
  129854. t
  129855. }(sT)
  129856. , dT = function(e) {
  129857. function t() {
  129858. return null !== e && e.apply(this, arguments) || this
  129859. }
  129860. return U(t, e),
  129861. t.prototype.getDescription = function() {
  129862. return "Turning lens flares on/off"
  129863. }
  129864. ,
  129865. t.prototype.apply = function(e, t) {
  129866. return e.lensFlaresEnabled = t.isInImprovementMode,
  129867. !0
  129868. }
  129869. ,
  129870. t
  129871. }(sT)
  129872. , pT = function(e) {
  129873. function t() {
  129874. return null !== e && e.apply(this, arguments) || this
  129875. }
  129876. return U(t, e),
  129877. t.prototype.getDescription = function() {
  129878. return this.onGetDescription ? this.onGetDescription() : "Running user defined callback"
  129879. }
  129880. ,
  129881. t.prototype.apply = function(e, t) {
  129882. return !this.onApply || this.onApply(e, t)
  129883. }
  129884. ,
  129885. t
  129886. }(sT)
  129887. , fT = function(e) {
  129888. function t() {
  129889. return null !== e && e.apply(this, arguments) || this
  129890. }
  129891. return U(t, e),
  129892. t.prototype.getDescription = function() {
  129893. return "Turning particles on/off"
  129894. }
  129895. ,
  129896. t.prototype.apply = function(e, t) {
  129897. return e.particlesEnabled = t.isInImprovementMode,
  129898. !0
  129899. }
  129900. ,
  129901. t
  129902. }(sT)
  129903. , _T = function(e) {
  129904. function t() {
  129905. return null !== e && e.apply(this, arguments) || this
  129906. }
  129907. return U(t, e),
  129908. t.prototype.getDescription = function() {
  129909. return "Turning render targets off"
  129910. }
  129911. ,
  129912. t.prototype.apply = function(e, t) {
  129913. return e.renderTargetsEnabled = t.isInImprovementMode,
  129914. !0
  129915. }
  129916. ,
  129917. t
  129918. }(sT)
  129919. , mT = function(e) {
  129920. function t() {
  129921. var t = null !== e && e.apply(this, arguments) || this;
  129922. return t._canBeMerged = function(e) {
  129923. if (!(e instanceof Vr))
  129924. return !1;
  129925. var t = e;
  129926. return !(t.isDisposed() || !t.isVisible || !t.isEnabled() || t.instances.length > 0 || t.skeleton || t.hasLODLevels)
  129927. }
  129928. ,
  129929. t
  129930. }
  129931. return U(t, e),
  129932. Object.defineProperty(t, "UpdateSelectionTree", {
  129933. get: function() {
  129934. return t._UpdateSelectionTree
  129935. },
  129936. set: function(e) {
  129937. t._UpdateSelectionTree = e
  129938. },
  129939. enumerable: !1,
  129940. configurable: !0
  129941. }),
  129942. t.prototype.getDescription = function() {
  129943. return "Merging similar meshes together"
  129944. }
  129945. ,
  129946. t.prototype.apply = function(e, i, n) {
  129947. for (var r = e.meshes.slice(0), o = r.length, a = 0; a < o; a++) {
  129948. var s = new Array
  129949. , l = r[a];
  129950. if (this._canBeMerged(l)) {
  129951. s.push(l);
  129952. for (var c = a + 1; c < o; c++) {
  129953. var u = r[c];
  129954. this._canBeMerged(u) && u.material === l.material && u.checkCollisions === l.checkCollisions && (s.push(u),
  129955. o--,
  129956. r.splice(c, 1),
  129957. c--)
  129958. }
  129959. s.length < 2 || Vr.MergeMeshes(s, void 0, !0)
  129960. }
  129961. }
  129962. var h = e;
  129963. return h.createOrUpdateSelectionOctree && (null != n ? n && h.createOrUpdateSelectionOctree() : t.UpdateSelectionTree && h.createOrUpdateSelectionOctree()),
  129964. !0
  129965. }
  129966. ,
  129967. t._UpdateSelectionTree = !1,
  129968. t
  129969. }(sT)
  129970. , gT = function() {
  129971. function e(e, t) {
  129972. void 0 === e && (e = 60),
  129973. void 0 === t && (t = 2e3),
  129974. this.targetFrameRate = e,
  129975. this.trackerDuration = t,
  129976. this.optimizations = new Array
  129977. }
  129978. return e.prototype.addOptimization = function(e) {
  129979. return this.optimizations.push(e),
  129980. this
  129981. }
  129982. ,
  129983. e.prototype.addCustomOptimization = function(e, t, i) {
  129984. void 0 === i && (i = 0);
  129985. var n = new pT(i);
  129986. return n.onApply = e,
  129987. n.onGetDescription = t,
  129988. this.optimizations.push(n),
  129989. this
  129990. }
  129991. ,
  129992. e.LowDegradationAllowed = function(t) {
  129993. var i = new e(t)
  129994. , n = 0;
  129995. return i.addOptimization(new mT(n)),
  129996. i.addOptimization(new uT(n)),
  129997. i.addOptimization(new dT(n)),
  129998. n++,
  129999. i.addOptimization(new hT(n)),
  130000. i.addOptimization(new fT(n)),
  130001. n++,
  130002. i.addOptimization(new lT(n,1024)),
  130003. i
  130004. }
  130005. ,
  130006. e.ModerateDegradationAllowed = function(t) {
  130007. var i = new e(t)
  130008. , n = 0;
  130009. return i.addOptimization(new mT(n)),
  130010. i.addOptimization(new uT(n)),
  130011. i.addOptimization(new dT(n)),
  130012. n++,
  130013. i.addOptimization(new hT(n)),
  130014. i.addOptimization(new fT(n)),
  130015. n++,
  130016. i.addOptimization(new lT(n,512)),
  130017. n++,
  130018. i.addOptimization(new _T(n)),
  130019. n++,
  130020. i.addOptimization(new cT(n,2)),
  130021. i
  130022. }
  130023. ,
  130024. e.HighDegradationAllowed = function(t) {
  130025. var i = new e(t)
  130026. , n = 0;
  130027. return i.addOptimization(new mT(n)),
  130028. i.addOptimization(new uT(n)),
  130029. i.addOptimization(new dT(n)),
  130030. n++,
  130031. i.addOptimization(new hT(n)),
  130032. i.addOptimization(new fT(n)),
  130033. n++,
  130034. i.addOptimization(new lT(n,256)),
  130035. n++,
  130036. i.addOptimization(new _T(n)),
  130037. n++,
  130038. i.addOptimization(new cT(n,4)),
  130039. i
  130040. }
  130041. ,
  130042. e
  130043. }()
  130044. , vT = function() {
  130045. function e(e, t, i, n) {
  130046. void 0 === i && (i = !0),
  130047. void 0 === n && (n = !1);
  130048. var r = this;
  130049. if (this._isRunning = !1,
  130050. this._currentPriorityLevel = 0,
  130051. this._targetFrameRate = 60,
  130052. this._trackerDuration = 2e3,
  130053. this._currentFrameRate = 0,
  130054. this._improvementMode = !1,
  130055. this.onSuccessObservable = new h,
  130056. this.onNewOptimizationAppliedObservable = new h,
  130057. this.onFailureObservable = new h,
  130058. this._options = t || new gT,
  130059. this._options.targetFrameRate && (this._targetFrameRate = this._options.targetFrameRate),
  130060. this._options.trackerDuration && (this._trackerDuration = this._options.trackerDuration),
  130061. i)
  130062. for (var o = 0, a = 0, s = this._options.optimizations; a < s.length; a++)
  130063. s[a].priority = o++;
  130064. this._improvementMode = n,
  130065. this._scene = e || E.LastCreatedScene,
  130066. this._sceneDisposeObserver = this._scene.onDisposeObservable.add((function() {
  130067. r._sceneDisposeObserver = null,
  130068. r.dispose()
  130069. }
  130070. ))
  130071. }
  130072. return Object.defineProperty(e.prototype, "isInImprovementMode", {
  130073. get: function() {
  130074. return this._improvementMode
  130075. },
  130076. enumerable: !1,
  130077. configurable: !0
  130078. }),
  130079. Object.defineProperty(e.prototype, "currentPriorityLevel", {
  130080. get: function() {
  130081. return this._currentPriorityLevel
  130082. },
  130083. enumerable: !1,
  130084. configurable: !0
  130085. }),
  130086. Object.defineProperty(e.prototype, "currentFrameRate", {
  130087. get: function() {
  130088. return this._currentFrameRate
  130089. },
  130090. enumerable: !1,
  130091. configurable: !0
  130092. }),
  130093. Object.defineProperty(e.prototype, "targetFrameRate", {
  130094. get: function() {
  130095. return this._targetFrameRate
  130096. },
  130097. set: function(e) {
  130098. this._targetFrameRate = e
  130099. },
  130100. enumerable: !1,
  130101. configurable: !0
  130102. }),
  130103. Object.defineProperty(e.prototype, "trackerDuration", {
  130104. get: function() {
  130105. return this._trackerDuration
  130106. },
  130107. set: function(e) {
  130108. this._trackerDuration = e
  130109. },
  130110. enumerable: !1,
  130111. configurable: !0
  130112. }),
  130113. Object.defineProperty(e.prototype, "optimizations", {
  130114. get: function() {
  130115. return this._options.optimizations
  130116. },
  130117. enumerable: !1,
  130118. configurable: !0
  130119. }),
  130120. e.prototype.stop = function() {
  130121. this._isRunning = !1
  130122. }
  130123. ,
  130124. e.prototype.reset = function() {
  130125. this._currentPriorityLevel = 0
  130126. }
  130127. ,
  130128. e.prototype.start = function() {
  130129. var e = this;
  130130. this._isRunning || (this._isRunning = !0,
  130131. this._scene.executeWhenReady((function() {
  130132. setTimeout((function() {
  130133. e._checkCurrentState()
  130134. }
  130135. ), e._trackerDuration)
  130136. }
  130137. )))
  130138. }
  130139. ,
  130140. e.prototype._checkCurrentState = function() {
  130141. var e = this;
  130142. if (this._isRunning) {
  130143. var t = this._scene
  130144. , i = this._options;
  130145. if (this._currentFrameRate = Math.round(t.getEngine().getFps()),
  130146. this._improvementMode && this._currentFrameRate <= this._targetFrameRate || !this._improvementMode && this._currentFrameRate >= this._targetFrameRate)
  130147. return this._isRunning = !1,
  130148. void this.onSuccessObservable.notifyObservers(this);
  130149. for (var n = !0, r = !0, o = 0; o < i.optimizations.length; o++) {
  130150. var a = i.optimizations[o];
  130151. a.priority === this._currentPriorityLevel && (r = !1,
  130152. n = n && a.apply(t, this),
  130153. this.onNewOptimizationAppliedObservable.notifyObservers(a))
  130154. }
  130155. if (r)
  130156. return this._isRunning = !1,
  130157. void this.onFailureObservable.notifyObservers(this);
  130158. n && this._currentPriorityLevel++,
  130159. t.executeWhenReady((function() {
  130160. setTimeout((function() {
  130161. e._checkCurrentState()
  130162. }
  130163. ), e._trackerDuration)
  130164. }
  130165. ))
  130166. }
  130167. }
  130168. ,
  130169. e.prototype.dispose = function() {
  130170. this.stop(),
  130171. this.onSuccessObservable.clear(),
  130172. this.onFailureObservable.clear(),
  130173. this.onNewOptimizationAppliedObservable.clear(),
  130174. this._sceneDisposeObserver && this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)
  130175. }
  130176. ,
  130177. e.OptimizeAsync = function(t, i, n, r) {
  130178. var o = new e(t,i || gT.ModerateDegradationAllowed(),!1);
  130179. return n && o.onSuccessObservable.add((function() {
  130180. n()
  130181. }
  130182. )),
  130183. r && o.onFailureObservable.add((function() {
  130184. r()
  130185. }
  130186. )),
  130187. o.start(),
  130188. o
  130189. }
  130190. ,
  130191. e
  130192. }()
  130193. , yT = []
  130194. , bT = function(e, t) {
  130195. e.doNotSerialize || (t.vertexData.push(e.serializeVerticeData()),
  130196. yT[e.id] = !0)
  130197. }
  130198. , TT = function(e, t) {
  130199. var i = {}
  130200. , n = e._geometry;
  130201. return n && (e.getScene().getGeometryById(n.id) || bT(n, t.geometries)),
  130202. e.serialize && e.serialize(i),
  130203. i
  130204. }
  130205. , ET = function() {
  130206. function e() {}
  130207. return e.ClearCache = function() {
  130208. yT = []
  130209. }
  130210. ,
  130211. e.Serialize = function(t) {
  130212. return e._Serialize(t)
  130213. }
  130214. ,
  130215. e._Serialize = function(t, i) {
  130216. void 0 === i && (i = !0);
  130217. var n, r, o, s = {};
  130218. if (i && !t.getEngine()._features.supportSyncTextureRead && io.ForceSerializeBuffers && console.warn("The serialization object may not contain the proper base64 encoded texture data! You should use the SerializeAsync method instead."),
  130219. e.ClearCache(),
  130220. s.useDelayedTextureLoading = t.useDelayedTextureLoading,
  130221. s.autoClear = t.autoClear,
  130222. s.clearColor = t.clearColor.asArray(),
  130223. s.ambientColor = t.ambientColor.asArray(),
  130224. s.gravity = t.gravity.asArray(),
  130225. s.collisionsEnabled = t.collisionsEnabled,
  130226. s.useRightHandedSystem = t.useRightHandedSystem,
  130227. t.fogMode && 0 !== t.fogMode && (s.fogMode = t.fogMode,
  130228. s.fogColor = t.fogColor.asArray(),
  130229. s.fogStart = t.fogStart,
  130230. s.fogEnd = t.fogEnd,
  130231. s.fogDensity = t.fogDensity),
  130232. t.isPhysicsEnabled()) {
  130233. var l = t.getPhysicsEngine();
  130234. l && (s.physicsEnabled = !0,
  130235. s.physicsGravity = l.gravity.asArray(),
  130236. s.physicsEngine = l.getPhysicsPluginName())
  130237. }
  130238. t.metadata && (s.metadata = t.metadata),
  130239. s.morphTargetManagers = [];
  130240. for (var c = 0, u = t.meshes; c < u.length; c++) {
  130241. var h = (b = u[c]).morphTargetManager;
  130242. h && s.morphTargetManagers.push(h.serialize())
  130243. }
  130244. for (s.lights = [],
  130245. n = 0; n < t.lights.length; n++)
  130246. (r = t.lights[n]).doNotSerialize || s.lights.push(r.serialize());
  130247. for (s.cameras = [],
  130248. n = 0; n < t.cameras.length; n++) {
  130249. var d = t.cameras[n];
  130250. d.doNotSerialize || s.cameras.push(d.serialize())
  130251. }
  130252. if (t.activeCamera && (s.activeCameraID = t.activeCamera.id),
  130253. Ge.AppendSerializedAnimations(t, s),
  130254. t.animationGroups && t.animationGroups.length > 0) {
  130255. s.animationGroups = [];
  130256. for (var p = 0; p < t.animationGroups.length; p++) {
  130257. var f = t.animationGroups[p];
  130258. s.animationGroups.push(f.serialize())
  130259. }
  130260. }
  130261. if (t.reflectionProbes && t.reflectionProbes.length > 0)
  130262. for (s.reflectionProbes = [],
  130263. n = 0; n < t.reflectionProbes.length; n++) {
  130264. var _ = t.reflectionProbes[n];
  130265. s.reflectionProbes.push(_.serialize())
  130266. }
  130267. for (s.materials = [],
  130268. s.multiMaterials = [],
  130269. n = 0; n < t.materials.length; n++)
  130270. (o = t.materials[n]).doNotSerialize || s.materials.push(o.serialize());
  130271. for (s.multiMaterials = [],
  130272. n = 0; n < t.multiMaterials.length; n++) {
  130273. var m = t.multiMaterials[n];
  130274. s.multiMaterials.push(m.serialize())
  130275. }
  130276. for (t.environmentTexture && (s.environmentTexture = t.environmentTexture.name,
  130277. s.environmentTextureRotationY = t.environmentTexture.rotationY),
  130278. s.environmentIntensity = t.environmentIntensity,
  130279. s.skeletons = [],
  130280. n = 0; n < t.skeletons.length; n++) {
  130281. var g = t.skeletons[n];
  130282. g.doNotSerialize || s.skeletons.push(g.serialize())
  130283. }
  130284. for (s.transformNodes = [],
  130285. n = 0; n < t.transformNodes.length; n++)
  130286. t.transformNodes[n].doNotSerialize || s.transformNodes.push(t.transformNodes[n].serialize());
  130287. s.geometries = {},
  130288. s.geometries.boxes = [],
  130289. s.geometries.spheres = [],
  130290. s.geometries.cylinders = [],
  130291. s.geometries.toruses = [],
  130292. s.geometries.grounds = [],
  130293. s.geometries.planes = [],
  130294. s.geometries.torusKnots = [],
  130295. s.geometries.vertexData = [],
  130296. yT = [];
  130297. var v = t.getGeometries();
  130298. for (n = 0; n < v.length; n++) {
  130299. var y = v[n];
  130300. y.isReady() && bT(y, s.geometries)
  130301. }
  130302. for (s.meshes = [],
  130303. n = 0; n < t.meshes.length; n++) {
  130304. var b;
  130305. if ((b = t.meshes[n])instanceof Vr) {
  130306. var T = b;
  130307. T.doNotSerialize || T.delayLoadState !== a.DELAYLOADSTATE_LOADED && T.delayLoadState !== a.DELAYLOADSTATE_NONE || s.meshes.push(TT(T, s))
  130308. }
  130309. }
  130310. for (s.particleSystems = [],
  130311. n = 0; n < t.particleSystems.length; n++)
  130312. s.particleSystems.push(t.particleSystems[n].serialize(!1));
  130313. for (s.postProcesses = [],
  130314. n = 0; n < t.postProcesses.length; n++)
  130315. s.postProcesses.push(t.postProcesses[n].serialize());
  130316. t.actionManager && (s.actions = t.actionManager.serialize("scene"));
  130317. for (var E = 0, S = t._serializableComponents; E < S.length; E++)
  130318. S[E].serialize(s);
  130319. return s
  130320. }
  130321. ,
  130322. e.SerializeAsync = function(t) {
  130323. var i = e._Serialize(t, !1)
  130324. , n = [];
  130325. return this._CollectPromises(i, n),
  130326. Promise.all(n).then((function() {
  130327. return i
  130328. }
  130329. ))
  130330. }
  130331. ,
  130332. e._CollectPromises = function(e, t) {
  130333. if (Array.isArray(e))
  130334. for (var i = function(i) {
  130335. var r = e[i];
  130336. r instanceof Promise ? t.push(r.then((function(t) {
  130337. return e[i] = t
  130338. }
  130339. ))) : (r instanceof Object || Array.isArray(r)) && n._CollectPromises(r, t)
  130340. }, n = this, r = 0; r < e.length; ++r)
  130341. i(r);
  130342. else if (e instanceof Object) {
  130343. var o = function(i) {
  130344. if (Object.prototype.hasOwnProperty.call(e, i)) {
  130345. var n = e[i];
  130346. n instanceof Promise ? t.push(n.then((function(t) {
  130347. return e[i] = t
  130348. }
  130349. ))) : (n instanceof Object || Array.isArray(n)) && a._CollectPromises(n, t)
  130350. }
  130351. }
  130352. , a = this;
  130353. for (var s in e)
  130354. o(s)
  130355. }
  130356. }
  130357. ,
  130358. e.SerializeMesh = function(t, i, n) {
  130359. void 0 === i && (i = !1),
  130360. void 0 === n && (n = !1);
  130361. var r = {};
  130362. if (e.ClearCache(),
  130363. t = t instanceof Array ? t : [t],
  130364. i || n)
  130365. for (var o = 0; o < t.length; ++o)
  130366. n && t[o].getDescendants().forEach((function(e) {
  130367. e instanceof Vr && t.indexOf(e) < 0 && !e.doNotSerialize && t.push(e)
  130368. }
  130369. )),
  130370. i && t[o].parent && t.indexOf(t[o].parent) < 0 && !t[o].parent.doNotSerialize && t.push(t[o].parent);
  130371. return t.forEach((function(e) {
  130372. !function(e, t) {
  130373. if (e.delayLoadState === a.DELAYLOADSTATE_LOADED || e.delayLoadState === a.DELAYLOADSTATE_NONE) {
  130374. var i = function(i) {
  130375. t.materials = t.materials || [],
  130376. t.materials.some((function(t) {
  130377. return t.id === e.material.id
  130378. }
  130379. )) || t.materials.push(i.serialize())
  130380. };
  130381. if (e.material && !e.material.doNotSerialize)
  130382. if (e.material instanceof Dr) {
  130383. if (t.multiMaterials = t.multiMaterials || [],
  130384. !t.multiMaterials.some((function(t) {
  130385. return t.id === e.material.id
  130386. }
  130387. ))) {
  130388. t.multiMaterials.push(e.material.serialize());
  130389. for (var n = 0, r = e.material.subMaterials; n < r.length; n++) {
  130390. var o = r[n];
  130391. o && i(o)
  130392. }
  130393. }
  130394. } else
  130395. i(e.material);
  130396. else
  130397. e.material || i(e.getScene().defaultMaterial);
  130398. var s = e._geometry;
  130399. s && (t.geometries || (t.geometries = {},
  130400. t.geometries.boxes = [],
  130401. t.geometries.spheres = [],
  130402. t.geometries.cylinders = [],
  130403. t.geometries.toruses = [],
  130404. t.geometries.grounds = [],
  130405. t.geometries.planes = [],
  130406. t.geometries.torusKnots = [],
  130407. t.geometries.vertexData = []),
  130408. bT(s, t.geometries)),
  130409. e.skeleton && !e.skeleton.doNotSerialize && (t.skeletons = t.skeletons || [],
  130410. t.skeletons.push(e.skeleton.serialize())),
  130411. t.meshes = t.meshes || [],
  130412. t.meshes.push(TT(e, t))
  130413. }
  130414. }(e, r)
  130415. }
  130416. )),
  130417. r
  130418. }
  130419. ,
  130420. e
  130421. }()
  130422. , ST = function() {
  130423. function e(t, i) {
  130424. if (void 0 === i && (i = {}),
  130425. !e.IsSupported(t))
  130426. throw "Your browser does not support recording so far.";
  130427. var n = t.getRenderingCanvas();
  130428. if (!n)
  130429. throw "The babylon engine must have a canvas to be recorded";
  130430. this._canvas = n,
  130431. this._canvas.isRecording = !1,
  130432. this._options = V(V({}, e._DefaultOptions), i);
  130433. var r = this._canvas.captureStream(this._options.fps);
  130434. if (this._options.audioTracks)
  130435. for (var o = 0, a = this._options.audioTracks; o < a.length; o++) {
  130436. var s = a[o];
  130437. r.addTrack(s)
  130438. }
  130439. this._mediaRecorder = new MediaRecorder(r,{
  130440. mimeType: this._options.mimeType
  130441. }),
  130442. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this),
  130443. this._mediaRecorder.onerror = this._handleError.bind(this),
  130444. this._mediaRecorder.onstop = this._handleStop.bind(this)
  130445. }
  130446. return e.IsSupported = function(e) {
  130447. var t = e.getRenderingCanvas();
  130448. return !!t && "function" == typeof t.captureStream
  130449. }
  130450. ,
  130451. Object.defineProperty(e.prototype, "isRecording", {
  130452. get: function() {
  130453. return !!this._canvas && this._canvas.isRecording
  130454. },
  130455. enumerable: !1,
  130456. configurable: !0
  130457. }),
  130458. e.prototype.stopRecording = function() {
  130459. this._canvas && this._mediaRecorder && this.isRecording && (this._canvas.isRecording = !1,
  130460. this._mediaRecorder.stop())
  130461. }
  130462. ,
  130463. e.prototype.startRecording = function(e, t) {
  130464. var i = this;
  130465. if (void 0 === e && (e = "babylonjs.webm"),
  130466. void 0 === t && (t = 7),
  130467. !this._canvas || !this._mediaRecorder)
  130468. throw "Recorder has already been disposed";
  130469. if (this.isRecording)
  130470. throw "Recording already in progress";
  130471. return t > 0 && setTimeout((function() {
  130472. i.stopRecording()
  130473. }
  130474. ), 1e3 * t),
  130475. this._fileName = e,
  130476. this._recordedChunks = [],
  130477. this._resolve = null,
  130478. this._reject = null,
  130479. this._canvas.isRecording = !0,
  130480. this._mediaRecorder.start(this._options.recordChunckSize),
  130481. new Promise((function(e, t) {
  130482. i._resolve = e,
  130483. i._reject = t
  130484. }
  130485. ))
  130486. }
  130487. ,
  130488. e.prototype.dispose = function() {
  130489. this._canvas = null,
  130490. this._mediaRecorder = null,
  130491. this._recordedChunks = [],
  130492. this._fileName = null,
  130493. this._resolve = null,
  130494. this._reject = null
  130495. }
  130496. ,
  130497. e.prototype._handleDataAvailable = function(e) {
  130498. e.data.size > 0 && this._recordedChunks.push(e.data)
  130499. }
  130500. ,
  130501. e.prototype._handleError = function(e) {
  130502. if (this.stopRecording(),
  130503. !this._reject)
  130504. throw new e.error;
  130505. this._reject(e.error)
  130506. }
  130507. ,
  130508. e.prototype._handleStop = function() {
  130509. this.stopRecording();
  130510. var e = new Blob(this._recordedChunks);
  130511. this._resolve && this._resolve(e),
  130512. window.URL.createObjectURL(e),
  130513. this._fileName && gi.Download(e, this._fileName)
  130514. }
  130515. ,
  130516. e._DefaultOptions = {
  130517. mimeType: "video/webm",
  130518. fps: 25,
  130519. recordChunckSize: 3e3
  130520. },
  130521. e
  130522. }();
  130523. function AT(e, t, i, n, r, o) {
  130524. void 0 === r && (r = "image/png"),
  130525. void 0 === o && (o = !1);
  130526. var a = MT(e, t, i)
  130527. , s = a.height
  130528. , l = a.width;
  130529. if (s && l) {
  130530. gi._ScreenshotCanvas || (gi._ScreenshotCanvas = document.createElement("canvas")),
  130531. gi._ScreenshotCanvas.width = l,
  130532. gi._ScreenshotCanvas.height = s;
  130533. var c = gi._ScreenshotCanvas.getContext("2d")
  130534. , u = e.getRenderWidth() / e.getRenderHeight()
  130535. , h = l
  130536. , d = h / u;
  130537. d > s && (h = (d = s) * u);
  130538. var p = Math.max(0, l - h) / 2
  130539. , f = Math.max(0, s - d) / 2;
  130540. e.onEndFrameObservable.addOnce((function() {
  130541. var t = e.getRenderingCanvas();
  130542. c && t && c.drawImage(t, p, f, h, d),
  130543. o ? (gi.EncodeScreenshotCanvasData(void 0, r),
  130544. n && n("")) : gi.EncodeScreenshotCanvasData(n, r)
  130545. }
  130546. ))
  130547. } else
  130548. K.Error("Invalid 'size' parameter !")
  130549. }
  130550. function xT(e, t, i, n) {
  130551. return void 0 === n && (n = "image/png"),
  130552. new Promise((function(r, o) {
  130553. AT(e, t, i, (function(e) {
  130554. void 0 !== e ? r(e) : o(new Error("Data is undefined"))
  130555. }
  130556. ), n)
  130557. }
  130558. ))
  130559. }
  130560. function RT(e, t, i, n, r) {
  130561. return void 0 === r && (r = "image/png"),
  130562. new Promise((function(o) {
  130563. AT(e, t, {
  130564. width: i,
  130565. height: n
  130566. }, (function() {
  130567. o()
  130568. }
  130569. ), r, !0)
  130570. }
  130571. ))
  130572. }
  130573. function CT(e, t, i, n, r, o, s, l, c, u) {
  130574. void 0 === r && (r = "image/png"),
  130575. void 0 === o && (o = 1),
  130576. void 0 === s && (s = !1),
  130577. void 0 === c && (c = !1),
  130578. void 0 === u && (u = !1);
  130579. var h = MT(e, t, i)
  130580. , d = h.height
  130581. , p = h.width
  130582. , f = {
  130583. width: p,
  130584. height: d
  130585. };
  130586. if (d && p) {
  130587. var _ = t.getScene()
  130588. , m = null
  130589. , g = _.activeCameras;
  130590. _.activeCameras = null,
  130591. _.activeCamera !== t && (m = _.activeCamera,
  130592. _.activeCamera = t),
  130593. _.render();
  130594. var v = new ns("screenShot",f,_,!1,!1,a.TEXTURETYPE_UNSIGNED_INT,!1,io.NEAREST_SAMPLINGMODE,void 0,u,void 0,void 0,void 0,o);
  130595. v.renderList = null,
  130596. v.samples = o,
  130597. v.renderSprites = c,
  130598. e.onEndFrameObservable.addOnce((function() {
  130599. v.readPixels(void 0, void 0, void 0, !1).then((function(e) {
  130600. gi.DumpData(p, d, e, n, r, l, !0),
  130601. v.dispose()
  130602. }
  130603. ))
  130604. }
  130605. ));
  130606. var y = function() {
  130607. _.incrementRenderId(),
  130608. _.resetCachedMaterial(),
  130609. v.render(!0),
  130610. _.incrementRenderId(),
  130611. _.resetCachedMaterial(),
  130612. m && (_.activeCamera = m),
  130613. _.activeCameras = g,
  130614. t.getProjectionMatrix(!0),
  130615. _.render()
  130616. };
  130617. if (s) {
  130618. var b = new eb("antialiasing",1,_.activeCamera);
  130619. v.addPostProcess(b),
  130620. b.getEffect().isReady() ? y() : b.getEffect().onCompiled = function() {
  130621. y()
  130622. }
  130623. } else
  130624. y()
  130625. } else
  130626. K.Error("Invalid 'size' parameter !")
  130627. }
  130628. function PT(e, t, i, n, r, o, a, s) {
  130629. return void 0 === n && (n = "image/png"),
  130630. void 0 === r && (r = 1),
  130631. void 0 === o && (o = !1),
  130632. void 0 === s && (s = !1),
  130633. new Promise((function(l, c) {
  130634. CT(e, t, i, (function(e) {
  130635. void 0 !== e ? l(e) : c(new Error("Data is undefined"))
  130636. }
  130637. ), n, r, o, a, s)
  130638. }
  130639. ))
  130640. }
  130641. function MT(e, t, i) {
  130642. var n = 0
  130643. , r = 0;
  130644. if ("object" == typeof i) {
  130645. var o = i.precision ? Math.abs(i.precision) : 1;
  130646. i.width && i.height ? (n = i.height * o,
  130647. r = i.width * o) : i.width && !i.height ? (r = i.width * o,
  130648. n = Math.round(r / e.getAspectRatio(t))) : i.height && !i.width ? (n = i.height * o,
  130649. r = Math.round(n * e.getAspectRatio(t))) : (r = Math.round(e.getRenderWidth() * o),
  130650. n = Math.round(r / e.getAspectRatio(t)))
  130651. } else
  130652. isNaN(i) || (n = i,
  130653. r = i);
  130654. return r && (r = Math.floor(r)),
  130655. n && (n = Math.floor(n)),
  130656. {
  130657. height: 0 | n,
  130658. width: 0 | r
  130659. }
  130660. }
  130661. var IT, OT = {
  130662. CreateScreenshot: AT,
  130663. CreateScreenshotAsync: xT,
  130664. CreateScreenshotWithResizeAsync: RT,
  130665. CreateScreenshotUsingRenderTarget: CT,
  130666. CreateScreenshotUsingRenderTargetAsync: PT
  130667. };
  130668. gi.CreateScreenshot = AT,
  130669. gi.CreateScreenshotAsync = xT,
  130670. gi.CreateScreenshotUsingRenderTarget = CT,
  130671. gi.CreateScreenshotUsingRenderTargetAsync = PT,
  130672. function(e) {
  130673. e[e.Checkbox = 0] = "Checkbox",
  130674. e[e.Slider = 1] = "Slider",
  130675. e[e.Vector3 = 2] = "Vector3",
  130676. e[e.Quaternion = 3] = "Quaternion",
  130677. e[e.Color3 = 4] = "Color3",
  130678. e[e.String = 5] = "String",
  130679. e[e.Button = 6] = "Button",
  130680. e[e.Options = 7] = "Options",
  130681. e[e.Tab = 8] = "Tab"
  130682. }(IT || (IT = {}));
  130683. var DT, NT = function() {
  130684. function e(e) {
  130685. this.byteOffset = 0,
  130686. this.buffer = e
  130687. }
  130688. return e.prototype.loadAsync = function(e) {
  130689. var t = this;
  130690. return this.buffer.readAsync(this.byteOffset, e).then((function(e) {
  130691. t._dataView = new DataView(e.buffer,e.byteOffset,e.byteLength),
  130692. t._dataByteOffset = 0
  130693. }
  130694. ))
  130695. }
  130696. ,
  130697. e.prototype.readUint32 = function() {
  130698. var e = this._dataView.getUint32(this._dataByteOffset, !0);
  130699. return this._dataByteOffset += 4,
  130700. this.byteOffset += 4,
  130701. e
  130702. }
  130703. ,
  130704. e.prototype.readUint8Array = function(e) {
  130705. var t = new Uint8Array(this._dataView.buffer,this._dataView.byteOffset + this._dataByteOffset,e);
  130706. return this._dataByteOffset += e,
  130707. this.byteOffset += e,
  130708. t
  130709. }
  130710. ,
  130711. e.prototype.readString = function(e) {
  130712. return se(this.readUint8Array(e))
  130713. }
  130714. ,
  130715. e.prototype.skipBytes = function(e) {
  130716. this._dataByteOffset += e,
  130717. this.byteOffset += e
  130718. }
  130719. ,
  130720. e
  130721. }(), LT = function() {
  130722. function e() {}
  130723. return e._GetStorage = function() {
  130724. try {
  130725. return localStorage.setItem("test", ""),
  130726. localStorage.removeItem("test"),
  130727. localStorage
  130728. } catch (t) {
  130729. var e = {};
  130730. return {
  130731. getItem: function(t) {
  130732. var i = e[t];
  130733. return void 0 === i ? null : i
  130734. },
  130735. setItem: function(t, i) {
  130736. e[t] = i
  130737. }
  130738. }
  130739. }
  130740. }
  130741. ,
  130742. e.ReadString = function(e, t) {
  130743. var i = this._Storage.getItem(e);
  130744. return null !== i ? i : t
  130745. }
  130746. ,
  130747. e.WriteString = function(e, t) {
  130748. this._Storage.setItem(e, t)
  130749. }
  130750. ,
  130751. e.ReadBoolean = function(e, t) {
  130752. var i = this._Storage.getItem(e);
  130753. return null !== i ? "true" === i : t
  130754. }
  130755. ,
  130756. e.WriteBoolean = function(e, t) {
  130757. this._Storage.setItem(e, t ? "true" : "false")
  130758. }
  130759. ,
  130760. e.ReadNumber = function(e, t) {
  130761. var i = this._Storage.getItem(e);
  130762. return null !== i ? parseFloat(i) : t
  130763. }
  130764. ,
  130765. e.WriteNumber = function(e, t) {
  130766. this._Storage.setItem(e, t.toString())
  130767. }
  130768. ,
  130769. e._Storage = e._GetStorage(),
  130770. e
  130771. }(), FT = function() {
  130772. function e() {
  130773. this._trackedScene = null
  130774. }
  130775. return e.prototype.track = function(e) {
  130776. this._trackedScene = e,
  130777. Ge.AllowLoadingUniqueId = !0,
  130778. this._savedJSON = ET.Serialize(e),
  130779. Ge.AllowLoadingUniqueId = !1
  130780. }
  130781. ,
  130782. e.prototype.getDelta = function() {
  130783. if (!this._trackedScene)
  130784. return null;
  130785. var e = io.ForceSerializeBuffers;
  130786. io.ForceSerializeBuffers = !1,
  130787. Ge.AllowLoadingUniqueId = !0;
  130788. var t = ET.Serialize(this._trackedScene);
  130789. Ge.AllowLoadingUniqueId = !1;
  130790. var i = {};
  130791. for (var n in t)
  130792. this._compareCollections(n, this._savedJSON[n], t[n], i);
  130793. return io.ForceSerializeBuffers = e,
  130794. i
  130795. }
  130796. ,
  130797. e.prototype._compareArray = function(e, t, i, n) {
  130798. if (0 === t.length && 0 === i.length)
  130799. return !0;
  130800. if (t.length && !isNaN(t[0]) || i.length && !isNaN(i[0])) {
  130801. if (t.length !== i.length)
  130802. return !1;
  130803. if (0 === t.length)
  130804. return !0;
  130805. for (var r = 0; r < t.length; r++)
  130806. if (t[r] !== i[r])
  130807. return n[e] = i,
  130808. !1;
  130809. return !0
  130810. }
  130811. var o = []
  130812. , a = function(r) {
  130813. var a = t[r]
  130814. , l = a.uniqueId;
  130815. o.push(l);
  130816. var c = i.filter((function(e) {
  130817. return e.uniqueId === l
  130818. }
  130819. ));
  130820. if (c.length) {
  130821. var u = c[0]
  130822. , h = {};
  130823. s._compareObjects(a, u, h) || (n[e] || (n[e] = []),
  130824. h.__state = {
  130825. id: u.id || u.name
  130826. },
  130827. n[e].push(h))
  130828. } else
  130829. h = {
  130830. __state: {
  130831. deleteId: a.id || a.name
  130832. }
  130833. },
  130834. n[e].push(h)
  130835. }
  130836. , s = this;
  130837. for (r = 0; r < t.length; r++)
  130838. a(r);
  130839. for (r = 0; r < i.length; r++) {
  130840. var l = i[r]
  130841. , c = l.uniqueId;
  130842. -1 === o.indexOf(c) && (n[e] || (n[e] = []),
  130843. n[e].push(l))
  130844. }
  130845. return !0
  130846. }
  130847. ,
  130848. e.prototype._compareObjects = function(e, t, i) {
  130849. var n = !1;
  130850. for (var r in e)
  130851. if (Object.prototype.hasOwnProperty.call(e, r)) {
  130852. var o = e[r]
  130853. , a = t[r]
  130854. , s = !1;
  130855. if (Array.isArray(o))
  130856. s = JSON.stringify(o) !== JSON.stringify(a);
  130857. else if (isNaN(o) && "[object String]" != Object.prototype.toString.call(o)) {
  130858. if ("object" == typeof o && "object" == typeof a) {
  130859. var l = {};
  130860. this._compareObjects(o, a, l) || (i[r] = l,
  130861. n = !0)
  130862. }
  130863. } else
  130864. s = o !== a;
  130865. s && (n = !0,
  130866. i[r] = a)
  130867. }
  130868. return !n
  130869. }
  130870. ,
  130871. e.prototype._compareCollections = function(e, t, i, n) {
  130872. if (t !== i && t && i)
  130873. if (Array.isArray(t) && Array.isArray(i)) {
  130874. if (this._compareArray(e, t, i, n))
  130875. return
  130876. } else if ("object" == typeof t && "object" == typeof i) {
  130877. var r = {};
  130878. return void (this._compareObjects(t, i, r) || (n[e] = r))
  130879. }
  130880. }
  130881. ,
  130882. e.GetShadowGeneratorById = function(e, t) {
  130883. for (var i = 0, n = e.lights.map((function(e) {
  130884. return e.getShadowGenerator()
  130885. }
  130886. )); i < n.length; i++) {
  130887. var r = n[i];
  130888. if (r && r.id === t)
  130889. return r
  130890. }
  130891. return null
  130892. }
  130893. ,
  130894. e.ApplyDelta = function(e, t) {
  130895. var i = this;
  130896. "string" == typeof e && (e = JSON.parse(e));
  130897. var n = t;
  130898. for (var r in e) {
  130899. var o = e[r]
  130900. , a = n[r];
  130901. if (Array.isArray(a) || "shadowGenerators" === r)
  130902. switch (r) {
  130903. case "cameras":
  130904. this._ApplyDeltaForEntity(o, t, t.getCameraById.bind(t), (function(e) {
  130905. return Rr.Parse(e, t)
  130906. }
  130907. ));
  130908. break;
  130909. case "lights":
  130910. this._ApplyDeltaForEntity(o, t, t.getLightById.bind(t), (function(e) {
  130911. return Cr.Parse(e, t)
  130912. }
  130913. ));
  130914. break;
  130915. case "shadowGenerators":
  130916. this._ApplyDeltaForEntity(o, t, (function(e) {
  130917. return i.GetShadowGeneratorById(t, e)
  130918. }
  130919. ), (function(e) {
  130920. return r_.Parse(e, t)
  130921. }
  130922. ));
  130923. break;
  130924. case "meshes":
  130925. this._ApplyDeltaForEntity(o, t, t.getMeshById.bind(t), (function(e) {
  130926. return Vr.Parse(e, t, "")
  130927. }
  130928. ));
  130929. break;
  130930. case "skeletons":
  130931. this._ApplyDeltaForEntity(o, t, t.getSkeletonById.bind(t), (function(e) {
  130932. return Fo.Parse(e, t)
  130933. }
  130934. ));
  130935. break;
  130936. case "materials":
  130937. this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function(e) {
  130938. return Or.Parse(e, t, "")
  130939. }
  130940. ));
  130941. break;
  130942. case "multiMaterials":
  130943. this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function(e) {
  130944. return Dr.Parse(e, t, "")
  130945. }
  130946. ));
  130947. break;
  130948. case "transformNodes":
  130949. this._ApplyDeltaForEntity(o, t, t.getTransformNodeById.bind(t), (function(e) {
  130950. return yr.Parse(e, t, "")
  130951. }
  130952. ));
  130953. break;
  130954. case "particleSystems":
  130955. this._ApplyDeltaForEntity(o, t, t.getParticleSystemById.bind(t), (function(e) {
  130956. return fy.Parse(e, t, "")
  130957. }
  130958. ));
  130959. break;
  130960. case "morphTargetManagers":
  130961. this._ApplyDeltaForEntity(o, t, t.getMorphTargetById.bind(t), (function(e) {
  130962. return x_.Parse(e, t)
  130963. }
  130964. ));
  130965. break;
  130966. case "postProcesses":
  130967. this._ApplyDeltaForEntity(o, t, t.getPostProcessByName.bind(t), (function(e) {
  130968. return Ba.Parse(e, t, "")
  130969. }
  130970. ))
  130971. }
  130972. else
  130973. isNaN(a) ? a.fromArray && a.fromArray(o) : n[r] = o
  130974. }
  130975. }
  130976. ,
  130977. e._ApplyPropertiesToEntity = function(e, t) {
  130978. for (var i in e) {
  130979. var n = e[i]
  130980. , r = t[i];
  130981. void 0 !== r && (!isNaN(r) || Array.isArray(r) ? t[i] = n : r.fromArray ? r.fromArray(n) : "object" == typeof r && null !== r && this._ApplyPropertiesToEntity(n, r))
  130982. }
  130983. }
  130984. ,
  130985. e._ApplyDeltaForEntity = function(e, t, i, n) {
  130986. for (var r = 0, o = e; r < o.length; r++) {
  130987. var a = o[r];
  130988. if (a.__state && void 0 !== a.__state.id) {
  130989. var s = i(a.__state.id);
  130990. s && this._ApplyPropertiesToEntity(a, s)
  130991. } else if (a.__state && void 0 !== a.__state.deleteId) {
  130992. var l = i(a.__state.deleteId);
  130993. null == l || l.dispose()
  130994. } else
  130995. n(a)
  130996. }
  130997. }
  130998. ,
  130999. e
  131000. }();
  131001. !function(e) {
  131002. var t = function() {
  131003. function e(e, t, i, n) {
  131004. var r;
  131005. void 0 === t && (t = null),
  131006. void 0 === i && (i = null),
  131007. void 0 === n && (n = null),
  131008. t = null != t ? t : function() {
  131009. return 1
  131010. }
  131011. ,
  131012. i = null != i ? i : function() {
  131013. return 1
  131014. }
  131015. ,
  131016. n = null != n ? n : function(e, t) {
  131017. return e === t ? 0 : 1
  131018. }
  131019. ,
  131020. this._characterToIdx = new Map,
  131021. this._insertionCosts = new Array(e.length),
  131022. this._deletionCosts = new Array(e.length),
  131023. this._substitutionCosts = new Array(e.length);
  131024. for (var o = 0; o < e.length; ++o) {
  131025. r = e[o],
  131026. this._characterToIdx.set(r, o),
  131027. this._insertionCosts[o] = t(r),
  131028. this._deletionCosts[o] = i(r),
  131029. this._substitutionCosts[o] = new Array(e.length);
  131030. for (var a = o; a < e.length; ++a)
  131031. this._substitutionCosts[o][a] = n(r, e[a])
  131032. }
  131033. }
  131034. return e.prototype.serialize = function() {
  131035. var e = {}
  131036. , t = new Array(this._characterToIdx.size);
  131037. return this._characterToIdx.forEach((function(e, i) {
  131038. t[e] = i
  131039. }
  131040. )),
  131041. e.characters = t,
  131042. e.insertionCosts = this._insertionCosts,
  131043. e.deletionCosts = this._deletionCosts,
  131044. e.substitutionCosts = this._substitutionCosts,
  131045. JSON.stringify(e)
  131046. }
  131047. ,
  131048. e.Deserialize = function(t) {
  131049. var i = JSON.parse(t)
  131050. , n = new e(i.characters);
  131051. return n._insertionCosts = i.insertionCosts,
  131052. n._deletionCosts = i.deletionCosts,
  131053. n._substitutionCosts = i.substitutionCosts,
  131054. n
  131055. }
  131056. ,
  131057. e.prototype.getCharacterIdx = function(e) {
  131058. return this._characterToIdx.get(e)
  131059. }
  131060. ,
  131061. e.prototype.getInsertionCost = function(e) {
  131062. return this._insertionCosts[e]
  131063. }
  131064. ,
  131065. e.prototype.getDeletionCost = function(e) {
  131066. return this._deletionCosts[e]
  131067. }
  131068. ,
  131069. e.prototype.getSubstitutionCost = function(e, t) {
  131070. var i = Math.min(e, t)
  131071. , n = Math.max(e, t);
  131072. return this._substitutionCosts[i][n]
  131073. }
  131074. ,
  131075. e
  131076. }();
  131077. e.Alphabet = t;
  131078. var i = function() {
  131079. function e(t, i) {
  131080. var n = this;
  131081. if (t.length > e._MAX_SEQUENCE_LENGTH)
  131082. throw new Error("Sequences longer than " + e._MAX_SEQUENCE_LENGTH + " not supported.");
  131083. this._alphabet = i,
  131084. this._characters = t.map((function(e) {
  131085. return n._alphabet.getCharacterIdx(e)
  131086. }
  131087. ))
  131088. }
  131089. return e.prototype.serialize = function() {
  131090. return JSON.stringify(this._characters)
  131091. }
  131092. ,
  131093. e.Deserialize = function(t, i) {
  131094. var n = new e([],i);
  131095. return n._characters = JSON.parse(t),
  131096. n
  131097. }
  131098. ,
  131099. e.prototype.distance = function(t) {
  131100. return e._Distance(this, t)
  131101. }
  131102. ,
  131103. e._Distance = function(t, i) {
  131104. var n = t._alphabet;
  131105. if (n !== i._alphabet)
  131106. throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");
  131107. var r = t._characters
  131108. , o = i._characters
  131109. , a = r.length
  131110. , s = o.length
  131111. , l = e._CostMatrix;
  131112. l[0][0] = 0;
  131113. for (var c = 0; c < a; ++c)
  131114. l[c + 1][0] = l[c][0] + n.getInsertionCost(r[c]);
  131115. for (c = 0; c < s; ++c)
  131116. l[0][c + 1] = l[0][c] + n.getInsertionCost(o[c]);
  131117. for (var u = 0; u < a; ++u)
  131118. for (var h = 0; h < s; ++h)
  131119. e._InsertionCost = l[u + 1][h] + n.getInsertionCost(o[h]),
  131120. e._DeletionCost = l[u][h + 1] + n.getDeletionCost(r[u]),
  131121. e._SubstitutionCost = l[u][h] + n.getSubstitutionCost(r[u], o[h]),
  131122. l[u + 1][h + 1] = Math.min(e._InsertionCost, e._DeletionCost, e._SubstitutionCost);
  131123. return l[a][s]
  131124. }
  131125. ,
  131126. e._MAX_SEQUENCE_LENGTH = 256,
  131127. e._CostMatrix = W([], Array(e._MAX_SEQUENCE_LENGTH + 1), !0).map((function() {
  131128. return new Array(e._MAX_SEQUENCE_LENGTH + 1)
  131129. }
  131130. )),
  131131. e
  131132. }();
  131133. e.Sequence = i
  131134. }(DT || (DT = {}));
  131135. var wT = function() {
  131136. function e(e) {
  131137. void 0 === e && (e = .01),
  131138. this._points = [],
  131139. this._segmentLength = e
  131140. }
  131141. return e.prototype.serialize = function() {
  131142. return JSON.stringify(this)
  131143. }
  131144. ,
  131145. e.Deserialize = function(t) {
  131146. var i = JSON.parse(t)
  131147. , n = new e(i._segmentLength);
  131148. return n._points = i._points.map((function(e) {
  131149. return new x(e._x,e._y,e._z)
  131150. }
  131151. )),
  131152. n
  131153. }
  131154. ,
  131155. e.prototype.getLength = function() {
  131156. return this._points.length * this._segmentLength
  131157. }
  131158. ,
  131159. e.prototype.add = function(e) {
  131160. var t = this
  131161. , i = this._points.length;
  131162. if (0 === i)
  131163. this._points.push(e.clone());
  131164. else
  131165. for (var n = function() {
  131166. return t._segmentLength / x.Distance(t._points[i - 1], e)
  131167. }, r = n(); r <= 1; r = n()) {
  131168. var o = this._points[i - 1].scale(1 - r);
  131169. e.scaleAndAddToRef(r, o),
  131170. this._points.push(o),
  131171. ++i
  131172. }
  131173. }
  131174. ,
  131175. e.prototype.resampleAtTargetResolution = function(t) {
  131176. var i = new e(this.getLength() / t);
  131177. return this._points.forEach((function(e) {
  131178. i.add(e)
  131179. }
  131180. )),
  131181. i
  131182. }
  131183. ,
  131184. e.prototype.tokenize = function(t) {
  131185. for (var i = [], n = new x, r = 2; r < this._points.length; ++r)
  131186. e._TransformSegmentDirToRef(this._points[r - 2], this._points[r - 1], this._points[r], n) && i.push(e._TokenizeSegment(n, t));
  131187. return i
  131188. }
  131189. ,
  131190. e._TransformSegmentDirToRef = function(t, i, n, r) {
  131191. return i.subtractToRef(t, e._ForwardDir),
  131192. e._ForwardDir.normalize(),
  131193. i.scaleToRef(-1, e._InverseFromVec),
  131194. e._InverseFromVec.normalize(),
  131195. !(Math.abs(x.Dot(e._ForwardDir, e._InverseFromVec)) > .98 || (x.CrossToRef(e._ForwardDir, e._InverseFromVec, e._UpDir),
  131196. e._UpDir.normalize(),
  131197. P.LookAtLHToRef(t, i, e._UpDir, e._LookMatrix),
  131198. n.subtractToRef(i, e._FromToVec),
  131199. e._FromToVec.normalize(),
  131200. x.TransformNormalToRef(e._FromToVec, e._LookMatrix, r),
  131201. 0))
  131202. }
  131203. ,
  131204. e._TokenizeSegment = function(t, i) {
  131205. e._BestMatch = 0,
  131206. e._Score = x.Dot(t, i[0]),
  131207. e._BestScore = e._Score;
  131208. for (var n = 1; n < i.length; ++n)
  131209. e._Score = x.Dot(t, i[n]),
  131210. e._Score > e._BestScore && (e._BestMatch = n,
  131211. e._BestScore = e._Score);
  131212. return e._BestMatch
  131213. }
  131214. ,
  131215. e._ForwardDir = new x,
  131216. e._InverseFromVec = new x,
  131217. e._UpDir = new x,
  131218. e._FromToVec = new x,
  131219. e._LookMatrix = new P,
  131220. e
  131221. }()
  131222. , BT = function() {
  131223. function e(e) {
  131224. this.chars = new Array(e)
  131225. }
  131226. return e.Generate = function(t, i, n, r, o) {
  131227. void 0 === t && (t = 64),
  131228. void 0 === i && (i = 256),
  131229. void 0 === n && (n = .1),
  131230. void 0 === r && (r = .001),
  131231. void 0 === o && (o = []);
  131232. for (var a, s, l = new e(t), c = 0; c < t; ++c)
  131233. l.chars[c] = new x(Math.random() - .5,Math.random() - .5,Math.random() - .5),
  131234. l.chars[c].normalize();
  131235. for (c = 0; c < o.length; ++c)
  131236. l.chars[c].copyFrom(o[c]);
  131237. for (var u, h = new x, d = new x, p = 0; p < i; ++p) {
  131238. a = (1 - (u = p / (i - 1))) * n + u * r;
  131239. var f = function(e) {
  131240. h.copyFromFloats(0, 0, 0),
  131241. l.chars.forEach((function(t) {
  131242. l.chars[e].subtractToRef(t, d),
  131243. (s = d.lengthSquared()) > 1e-6 && d.scaleAndAddToRef(1 / (d.lengthSquared() * s), h)
  131244. }
  131245. )),
  131246. h.scaleInPlace(a),
  131247. l.chars[e].addInPlace(h),
  131248. l.chars[e].normalize()
  131249. };
  131250. for (c = o.length; c < l.chars.length; ++c)
  131251. f(c)
  131252. }
  131253. return l
  131254. }
  131255. ,
  131256. e.prototype.serialize = function() {
  131257. return JSON.stringify(this.chars)
  131258. }
  131259. ,
  131260. e.Deserialize = function(t) {
  131261. for (var i = JSON.parse(t), n = new e(i.length), r = 0; r < i.length; ++r)
  131262. n.chars[r] = new x(i[r]._x,i[r]._y,i[r]._z);
  131263. return n
  131264. }
  131265. ,
  131266. e
  131267. }()
  131268. , UT = function() {
  131269. function e() {
  131270. this._sequences = []
  131271. }
  131272. return e.prototype.serialize = function() {
  131273. return JSON.stringify(this._sequences.map((function(e) {
  131274. return e.serialize()
  131275. }
  131276. )))
  131277. }
  131278. ,
  131279. e.Deserialize = function(t, i) {
  131280. var n = new e;
  131281. return n._sequences = JSON.parse(t).map((function(e) {
  131282. return DT.Sequence.Deserialize(e, i)
  131283. }
  131284. )),
  131285. n
  131286. }
  131287. ,
  131288. e.CreateFromTrajectory = function(t, i, n) {
  131289. return e.CreateFromTokenizationPyramid(e._GetTokenizationPyramid(t, i), n)
  131290. }
  131291. ,
  131292. e.CreateFromTokenizationPyramid = function(t, i) {
  131293. var n = new e;
  131294. return n._sequences = t.map((function(e) {
  131295. return new DT.Sequence(e,i)
  131296. }
  131297. )),
  131298. n
  131299. }
  131300. ,
  131301. e._GetTokenizationPyramid = function(t, i, n) {
  131302. void 0 === n && (n = e._FINEST_DESCRIPTOR_RESOLUTION);
  131303. for (var r = [], o = n; o > 4; o = Math.floor(o / 2))
  131304. r.push(t.resampleAtTargetResolution(o).tokenize(i.chars));
  131305. return r
  131306. }
  131307. ,
  131308. e.prototype.distance = function(e) {
  131309. for (var t = 0, i = 0; i < this._sequences.length; ++i)
  131310. t += Math.pow(2, i) * this._sequences[i].distance(e._sequences[i]);
  131311. return t
  131312. }
  131313. ,
  131314. e._FINEST_DESCRIPTOR_RESOLUTION = 32,
  131315. e
  131316. }()
  131317. , VT = function() {
  131318. function e(e) {
  131319. void 0 === e && (e = []),
  131320. this._descriptors = e,
  131321. this._centroidIdx = -1,
  131322. this._averageDistance = 0,
  131323. this._refreshDescription()
  131324. }
  131325. return e.prototype.serialize = function() {
  131326. var e = {};
  131327. return e.descriptors = this._descriptors.map((function(e) {
  131328. return e.serialize()
  131329. }
  131330. )),
  131331. e.centroidIdx = this._centroidIdx,
  131332. e.averageDistance = this._averageDistance,
  131333. JSON.stringify(e)
  131334. }
  131335. ,
  131336. e.Deserialize = function(t, i) {
  131337. var n = JSON.parse(t)
  131338. , r = new e;
  131339. return r._descriptors = n.descriptors.map((function(e) {
  131340. return UT.Deserialize(e, i)
  131341. }
  131342. )),
  131343. r._centroidIdx = n.centroidIdx,
  131344. r._averageDistance = n.averageDistance,
  131345. r
  131346. }
  131347. ,
  131348. e.prototype.add = function(e) {
  131349. this._descriptors.push(e),
  131350. this._refreshDescription()
  131351. }
  131352. ,
  131353. e.prototype.getMatchCost = function(e) {
  131354. return e.distance(this._descriptors[this._centroidIdx]) / this._averageDistance
  131355. }
  131356. ,
  131357. e.prototype.getMatchMinimumDistance = function(e) {
  131358. return Math.min.apply(Math, this._descriptors.map((function(t) {
  131359. return t.distance(e)
  131360. }
  131361. )))
  131362. }
  131363. ,
  131364. e.prototype._refreshDescription = function() {
  131365. var t, i = this;
  131366. this._centroidIdx = -1;
  131367. for (var n = this._descriptors.map((function(e) {
  131368. return t = 0,
  131369. i._descriptors.forEach((function(i) {
  131370. t += e.distance(i)
  131371. }
  131372. )),
  131373. t
  131374. }
  131375. )), r = 0; r < n.length; ++r)
  131376. (this._centroidIdx < 0 || n[r] < n[this._centroidIdx]) && (this._centroidIdx = r);
  131377. this._averageDistance = 0,
  131378. this._descriptors.forEach((function(e) {
  131379. i._averageDistance += e.distance(i._descriptors[i._centroidIdx])
  131380. }
  131381. )),
  131382. this._descriptors.length > 0 && (this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, e._MIN_AVERAGE_DISTANCE))
  131383. }
  131384. ,
  131385. e._MIN_AVERAGE_DISTANCE = 1,
  131386. e
  131387. }()
  131388. , kT = function() {
  131389. function e() {
  131390. this._maximumAllowableMatchCost = 4,
  131391. this._nameToDescribedTrajectory = new Map
  131392. }
  131393. return e.prototype.serialize = function() {
  131394. var e = {};
  131395. return e.maximumAllowableMatchCost = this._maximumAllowableMatchCost,
  131396. e.vector3Alphabet = this._vector3Alphabet.serialize(),
  131397. e.levenshteinAlphabet = this._levenshteinAlphabet.serialize(),
  131398. e.nameToDescribedTrajectory = [],
  131399. this._nameToDescribedTrajectory.forEach((function(t, i) {
  131400. e.nameToDescribedTrajectory.push(i),
  131401. e.nameToDescribedTrajectory.push(t.serialize())
  131402. }
  131403. )),
  131404. JSON.stringify(e)
  131405. }
  131406. ,
  131407. e.Deserialize = function(t) {
  131408. var i = JSON.parse(t)
  131409. , n = new e;
  131410. n._maximumAllowableMatchCost = i.maximumAllowableMatchCost,
  131411. n._vector3Alphabet = BT.Deserialize(i.vector3Alphabet),
  131412. n._levenshteinAlphabet = DT.Alphabet.Deserialize(i.levenshteinAlphabet);
  131413. for (var r = 0; r < i.nameToDescribedTrajectory.length; r += 2)
  131414. n._nameToDescribedTrajectory.set(i.nameToDescribedTrajectory[r], VT.Deserialize(i.nameToDescribedTrajectory[r + 1], n._levenshteinAlphabet));
  131415. return n
  131416. }
  131417. ,
  131418. e.Generate = function() {
  131419. for (var t = BT.Generate(64, 256, .1, .001, [x.Forward()]), i = new Array(t.chars.length), n = 0; n < i.length; ++n)
  131420. i[n] = n;
  131421. var r = new DT.Alphabet(i,(function(e) {
  131422. return 0 === e ? 0 : 1
  131423. }
  131424. ),(function(e) {
  131425. return 0 === e ? 0 : 1
  131426. }
  131427. ),(function(e, i) {
  131428. return Math.min(1 - x.Dot(t.chars[e], t.chars[i]), 1)
  131429. }
  131430. ))
  131431. , o = new e;
  131432. return o._vector3Alphabet = t,
  131433. o._levenshteinAlphabet = r,
  131434. o
  131435. }
  131436. ,
  131437. e.prototype.addTrajectoryToClassification = function(e, t) {
  131438. this._nameToDescribedTrajectory.has(t) || this._nameToDescribedTrajectory.set(t, new VT),
  131439. this._nameToDescribedTrajectory.get(t).add(UT.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet))
  131440. }
  131441. ,
  131442. e.prototype.deleteClassification = function(e) {
  131443. return this._nameToDescribedTrajectory.delete(e)
  131444. }
  131445. ,
  131446. e.prototype.classifyTrajectory = function(e) {
  131447. var t = this
  131448. , i = UT.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet)
  131449. , n = [];
  131450. if (this._nameToDescribedTrajectory.forEach((function(e, r) {
  131451. e.getMatchCost(i) < t._maximumAllowableMatchCost && n.push(r)
  131452. }
  131453. )),
  131454. 0 === n.length)
  131455. return null;
  131456. for (var r, o = 0, a = this._nameToDescribedTrajectory.get(n[o]).getMatchMinimumDistance(i), s = 0; s < n.length; ++s)
  131457. (r = this._nameToDescribedTrajectory.get(n[s]).getMatchMinimumDistance(i)) < a && (a = r,
  131458. o = s);
  131459. return n[o]
  131460. }
  131461. ,
  131462. e
  131463. }()
  131464. , GT = function() {
  131465. function e(t, i, n) {
  131466. var r = this;
  131467. this._scene = t,
  131468. K.Log("[Reflector] Connecting to ws://".concat(i, ":").concat(n)),
  131469. this._webSocket = new WebSocket("ws://".concat(i, ":").concat(n)),
  131470. this._webSocket.onmessage = function(t) {
  131471. var i = t.data;
  131472. if (ae(i, e._SERVER_PREFIX)) {
  131473. var n = i.substr(e._SERVER_PREFIX.length);
  131474. return K.Log("[Reflector] Received server message: ".concat(n.substr(0, 64))),
  131475. void r._handleServerMessage(n)
  131476. }
  131477. K.Log("[Reflector] Received client message: ".concat(i.substr(0, 64))),
  131478. r._handleClientMessage()
  131479. }
  131480. ,
  131481. this._webSocket.onclose = function(e) {
  131482. K.Log("[Reflector] Disconnected ".concat(e.code, " ").concat(e.reason))
  131483. }
  131484. }
  131485. return e.prototype.close = function() {
  131486. this._webSocket.close()
  131487. }
  131488. ,
  131489. e.prototype._handleServerMessage = function(e) {
  131490. var t = this;
  131491. "connected" === e && ET.SerializeAsync(this._scene).then((function(e) {
  131492. t._webSocket.send("load|".concat(JSON.stringify(e)))
  131493. }
  131494. ))
  131495. }
  131496. ,
  131497. e.prototype._handleClientMessage = function() {}
  131498. ,
  131499. e._SERVER_PREFIX = "$$",
  131500. e
  131501. }()
  131502. , zT = function() {
  131503. function e(e) {
  131504. this._view = new Float32Array(e),
  131505. this._itemLength = 0
  131506. }
  131507. return Object.defineProperty(e.prototype, "itemLength", {
  131508. get: function() {
  131509. return this._itemLength
  131510. },
  131511. enumerable: !1,
  131512. configurable: !0
  131513. }),
  131514. e.prototype.at = function(e) {
  131515. return e < 0 || e >= this._itemLength ? NaN : this._view[e]
  131516. }
  131517. ,
  131518. e.prototype.subarray = function(e, t) {
  131519. return e >= t || e < 0 ? new Float32Array(0) : (t > this._itemLength && (t = this._itemLength),
  131520. this._view.subarray(e, t))
  131521. }
  131522. ,
  131523. e.prototype.push = function(e) {
  131524. this._view[this._itemLength] = e,
  131525. this._itemLength++,
  131526. this._itemLength >= this._view.length && this._growArray()
  131527. }
  131528. ,
  131529. e.prototype._growArray = function() {
  131530. var e = Math.floor(1.5 * this._view.length)
  131531. , t = new Float32Array(e);
  131532. t.set(this._view),
  131533. this._view = t
  131534. }
  131535. ,
  131536. e
  131537. }()
  131538. , WT = 1800
  131539. , HT = "timestamp"
  131540. , XT = "numPoints"
  131541. , jT = /\r/g
  131542. , YT = "@"
  131543. , KT = function() {
  131544. function e(t, i) {
  131545. var n = this;
  131546. this._scene = t,
  131547. this._collectDataAtFrame = function() {
  131548. var t = ct.Now - n._startingTimestamp
  131549. , i = n.datasets.ids.length
  131550. , r = n.datasets.startingIndices.itemLength
  131551. , o = 0;
  131552. if (r > 0) {
  131553. var a = n.datasets.startingIndices.at(r - 1);
  131554. o = a + n.datasets.data.at(a + e.NumberOfPointsOffset) + e.SliceDataOffset
  131555. }
  131556. if (n.datasets.startingIndices.push(o),
  131557. n.datasets.data.push(t),
  131558. n.datasets.data.push(i),
  131559. n.datasets.ids.forEach((function(e) {
  131560. var t = n._strategies.get(e);
  131561. t && n.datasets.data.push(t.getData())
  131562. }
  131563. )),
  131564. n.datasetObservable.hasObservers()) {
  131565. for (var s = [t, i], l = 0; l < i; l++)
  131566. s.push(n.datasets.data.at(o + e.SliceDataOffset + l));
  131567. n.datasetObservable.notifyObservers(s)
  131568. }
  131569. }
  131570. ,
  131571. this.datasets = {
  131572. ids: [],
  131573. data: new zT(WT),
  131574. startingIndices: new zT(WT)
  131575. },
  131576. this._strategies = new Map,
  131577. this._datasetMeta = new Map,
  131578. this._eventRestoreSet = new Set,
  131579. this._customEventObservable = new h,
  131580. this.datasetObservable = new h,
  131581. this.metadataObservable = new h((function(e) {
  131582. return e.callback(n._datasetMeta, new l(0))
  131583. }
  131584. )),
  131585. i && this.addCollectionStrategies.apply(this, i)
  131586. }
  131587. return Object.defineProperty(e, "SliceDataOffset", {
  131588. get: function() {
  131589. return 2
  131590. },
  131591. enumerable: !1,
  131592. configurable: !0
  131593. }),
  131594. Object.defineProperty(e, "NumberOfPointsOffset", {
  131595. get: function() {
  131596. return 1
  131597. },
  131598. enumerable: !1,
  131599. configurable: !0
  131600. }),
  131601. e.prototype.registerEvent = function(e, t, i) {
  131602. var n, r = this;
  131603. if (!this._strategies.has(e) || t) {
  131604. this._strategies.has(e) && t && (null === (n = this._strategies.get(e)) || void 0 === n || n.dispose(),
  131605. this._strategies.delete(e));
  131606. var o = {
  131607. name: e
  131608. };
  131609. return this._eventRestoreSet.add(e),
  131610. this.addCollectionStrategies({
  131611. strategyCallback: function(t) {
  131612. var i = 0
  131613. , n = 0
  131614. , o = t.onAfterRenderObservable.add((function() {
  131615. n = i,
  131616. i = 0
  131617. }
  131618. ))
  131619. , a = r._customEventObservable.add((function(t) {
  131620. e === t.name && (void 0 !== t.value ? i = t.value : i++)
  131621. }
  131622. ));
  131623. return {
  131624. id: e,
  131625. getData: function() {
  131626. return n
  131627. },
  131628. dispose: function() {
  131629. t.onAfterRenderObservable.remove(o),
  131630. r._customEventObservable.remove(a)
  131631. }
  131632. }
  131633. },
  131634. category: i
  131635. }),
  131636. o
  131637. }
  131638. }
  131639. ,
  131640. e.prototype.sendEvent = function(e) {
  131641. this._customEventObservable.notifyObservers(e)
  131642. }
  131643. ,
  131644. e.prototype._restoreStringEvents = function() {
  131645. var e = this;
  131646. this._eventRestoreSet.size !== this._customEventObservable.observers.length && this._eventRestoreSet.forEach((function(t) {
  131647. e.registerEvent(t, !0)
  131648. }
  131649. ))
  131650. }
  131651. ,
  131652. e.prototype.addCollectionStrategies = function() {
  131653. for (var e = [], t = 0; t < arguments.length; t++)
  131654. e[t] = arguments[t];
  131655. for (var i = 0, n = e; i < n.length; i++) {
  131656. var r = n[i]
  131657. , o = r.strategyCallback
  131658. , a = r.category
  131659. , s = r.hidden
  131660. , l = o(this._scene);
  131661. this._strategies.has(l.id) ? l.dispose() : (this.datasets.ids.push(l.id),
  131662. a && (a = a.replace(new RegExp(YT,"g"), "")),
  131663. this._datasetMeta.set(l.id, {
  131664. color: this._getHexColorFromId(l.id),
  131665. category: a,
  131666. hidden: s
  131667. }),
  131668. this._strategies.set(l.id, l))
  131669. }
  131670. this.metadataObservable.notifyObservers(this._datasetMeta)
  131671. }
  131672. ,
  131673. e.prototype._getHexColorFromId = function(e) {
  131674. for (var t = 0, i = 0; i < e.length; i++)
  131675. t = e.charCodeAt(i) + ((t << 5) - t);
  131676. var n = "#";
  131677. for (i = 0; i < 24; i += 8)
  131678. n += ("0" + (t >> i & 255).toString(16)).substr(-2);
  131679. return n
  131680. }
  131681. ,
  131682. e.prototype.getCurrentSlice = function() {
  131683. var e = this
  131684. , t = [ct.Now - this._startingTimestamp, this.datasets.ids.length];
  131685. this.datasets.ids.forEach((function(i) {
  131686. var n = e._strategies.get(i);
  131687. n && e.datasetObservable.hasObservers() && t.push(n.getData())
  131688. }
  131689. )),
  131690. this.datasetObservable.hasObservers() && this.datasetObservable.notifyObservers(t)
  131691. }
  131692. ,
  131693. e.prototype.updateMetadata = function(e, t, i) {
  131694. var n = this._datasetMeta.get(e);
  131695. n && (n[t] = i,
  131696. this.metadataObservable.notifyObservers(this._datasetMeta))
  131697. }
  131698. ,
  131699. e.prototype.clear = function(e) {
  131700. this.datasets.data = new zT(WT),
  131701. this.datasets.ids.length = 0,
  131702. this.datasets.startingIndices = new zT(WT),
  131703. this._datasetMeta.clear(),
  131704. this._strategies.forEach((function(e) {
  131705. return e.dispose()
  131706. }
  131707. )),
  131708. this._strategies.clear(),
  131709. e || this._eventRestoreSet.clear(),
  131710. this._hasLoadedData = !1
  131711. }
  131712. ,
  131713. Object.defineProperty(e.prototype, "hasLoadedData", {
  131714. get: function() {
  131715. return this._hasLoadedData
  131716. },
  131717. enumerable: !1,
  131718. configurable: !0
  131719. }),
  131720. e.prototype.loadFromFileData = function(t, i) {
  131721. var n = t.replace(jT, "").split("\n").map((function(e) {
  131722. return e.split(",").filter((function(e) {
  131723. return e.length > 0
  131724. }
  131725. ))
  131726. }
  131727. )).filter((function(e) {
  131728. return e.length > 0
  131729. }
  131730. ))
  131731. , r = e.NumberOfPointsOffset;
  131732. if (n.length < 2)
  131733. return !1;
  131734. var o = {
  131735. ids: [],
  131736. data: new zT(WT),
  131737. startingIndices: new zT(WT)
  131738. }
  131739. , a = n[0]
  131740. , s = n.slice(1);
  131741. if (a.length < 2 || a[0] !== HT || a[r] !== XT)
  131742. return !1;
  131743. for (var l = new Map, c = e.SliceDataOffset; c < a.length; c++) {
  131744. var u = a[c].split(YT)
  131745. , h = u[0]
  131746. , d = u[1];
  131747. o.ids.push(h),
  131748. l.set(h, d)
  131749. }
  131750. for (var p = 0, f = 0, _ = s; f < _.length; f++) {
  131751. var m = _[f];
  131752. if (m.length < 2)
  131753. return !1;
  131754. var g = parseFloat(m[0])
  131755. , v = parseInt(m[r]);
  131756. if (isNaN(v) || isNaN(g))
  131757. return !1;
  131758. if (o.data.push(g),
  131759. o.data.push(v),
  131760. v + e.SliceDataOffset !== m.length)
  131761. return !1;
  131762. for (c = e.SliceDataOffset; c < m.length; c++) {
  131763. var y = parseFloat(m[c]);
  131764. if (isNaN(y))
  131765. return !1;
  131766. o.data.push(y)
  131767. }
  131768. o.startingIndices.push(p),
  131769. p += m.length
  131770. }
  131771. if (this.datasets.ids = o.ids,
  131772. this.datasets.data = o.data,
  131773. this.datasets.startingIndices = o.startingIndices,
  131774. i || this._datasetMeta.clear(),
  131775. this._strategies.forEach((function(e) {
  131776. return e.dispose()
  131777. }
  131778. )),
  131779. this._strategies.clear(),
  131780. !i)
  131781. for (var b = 0, T = this.datasets.ids; b < T.length; b++)
  131782. h = T[b],
  131783. d = l.get(h),
  131784. this._datasetMeta.set(h, {
  131785. category: d,
  131786. color: this._getHexColorFromId(h)
  131787. });
  131788. return this.metadataObservable.notifyObservers(this._datasetMeta),
  131789. this._hasLoadedData = !0,
  131790. !0
  131791. }
  131792. ,
  131793. e.prototype.exportDataToCsv = function() {
  131794. var t = "";
  131795. t += "".concat(HT, ",").concat(XT);
  131796. for (var i = 0; i < this.datasets.ids.length; i++)
  131797. if (t += ",".concat(this.datasets.ids[i]),
  131798. this._datasetMeta) {
  131799. var n = this._datasetMeta.get(this.datasets.ids[i]);
  131800. (null == n ? void 0 : n.category) && (t += "".concat(YT).concat(n.category))
  131801. }
  131802. for (t += "\n",
  131803. i = 0; i < this.datasets.startingIndices.itemLength; i++) {
  131804. var r = this.datasets.startingIndices.at(i)
  131805. , o = this.datasets.data.at(r)
  131806. , a = this.datasets.data.at(r + e.NumberOfPointsOffset);
  131807. t += "".concat(o, ",").concat(a);
  131808. for (var s = 0; s < a; s++)
  131809. t += ",".concat(this.datasets.data.at(r + e.SliceDataOffset + s));
  131810. for (var l = 0; l < this.datasets.ids.length - a; l++)
  131811. t += ",";
  131812. t += "\n"
  131813. }
  131814. var c = "".concat((new Date).toISOString(), "-perfdata.csv");
  131815. gi.Download(new Blob([t],{
  131816. type: "text/csv"
  131817. }), c)
  131818. }
  131819. ,
  131820. e.prototype.start = function(e) {
  131821. e ? void 0 === this._startingTimestamp && (this._startingTimestamp = ct.Now) : (this.datasets.data = new zT(WT),
  131822. this.datasets.startingIndices = new zT(WT),
  131823. this._startingTimestamp = ct.Now),
  131824. this._scene.onAfterRenderObservable.add(this._collectDataAtFrame),
  131825. this._restoreStringEvents(),
  131826. this._isStarted = !0
  131827. }
  131828. ,
  131829. e.prototype.stop = function() {
  131830. this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),
  131831. this._isStarted = !1
  131832. }
  131833. ,
  131834. Object.defineProperty(e.prototype, "isStarted", {
  131835. get: function() {
  131836. return this._isStarted
  131837. },
  131838. enumerable: !1,
  131839. configurable: !0
  131840. }),
  131841. e.prototype.dispose = function() {
  131842. this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),
  131843. this._datasetMeta.clear(),
  131844. this._strategies.forEach((function(e) {
  131845. e.dispose()
  131846. }
  131847. )),
  131848. this.datasetObservable.clear(),
  131849. this.metadataObservable.clear(),
  131850. this._isStarted = !1,
  131851. this.datasets = null
  131852. }
  131853. ,
  131854. e
  131855. }()
  131856. , QT = function() {}
  131857. , qT = function() {
  131858. function e() {}
  131859. return e.FpsStrategy = function() {
  131860. return function(e) {
  131861. var t = e.getEngine();
  131862. return {
  131863. id: "FPS",
  131864. getData: function() {
  131865. return t.getFps()
  131866. },
  131867. dispose: QT
  131868. }
  131869. }
  131870. }
  131871. ,
  131872. e.CpuStrategy = function() {
  131873. return function(e) {
  131874. var t = 0
  131875. , i = e.onComputePressureChanged.add((function(e) {
  131876. t = e.cpuUtilization
  131877. }
  131878. ));
  131879. return {
  131880. id: "CPU utilization",
  131881. getData: function() {
  131882. return t
  131883. },
  131884. dispose: function() {
  131885. return e.onComputePressureChanged.remove(i)
  131886. }
  131887. }
  131888. }
  131889. }
  131890. ,
  131891. e.TotalMeshesStrategy = function() {
  131892. return function(e) {
  131893. return {
  131894. id: "Total meshes",
  131895. getData: function() {
  131896. return e.meshes.length
  131897. },
  131898. dispose: QT
  131899. }
  131900. }
  131901. }
  131902. ,
  131903. e.ActiveMeshesStrategy = function() {
  131904. return function(e) {
  131905. return {
  131906. id: "Active meshes",
  131907. getData: function() {
  131908. return e.getActiveMeshes().length
  131909. },
  131910. dispose: QT
  131911. }
  131912. }
  131913. }
  131914. ,
  131915. e.ActiveIndicesStrategy = function() {
  131916. return function(e) {
  131917. return {
  131918. id: "Active indices",
  131919. getData: function() {
  131920. return e.getActiveIndices()
  131921. },
  131922. dispose: QT
  131923. }
  131924. }
  131925. }
  131926. ,
  131927. e.ActiveFacesStrategy = function() {
  131928. return function(e) {
  131929. return {
  131930. id: "Active faces",
  131931. getData: function() {
  131932. return e.getActiveIndices() / 3
  131933. },
  131934. dispose: QT
  131935. }
  131936. }
  131937. }
  131938. ,
  131939. e.ActiveBonesStrategy = function() {
  131940. return function(e) {
  131941. return {
  131942. id: "Active bones",
  131943. getData: function() {
  131944. return e.getActiveBones()
  131945. },
  131946. dispose: QT
  131947. }
  131948. }
  131949. }
  131950. ,
  131951. e.ActiveParticlesStrategy = function() {
  131952. return function(e) {
  131953. return {
  131954. id: "Active particles",
  131955. getData: function() {
  131956. return e.getActiveParticles()
  131957. },
  131958. dispose: QT
  131959. }
  131960. }
  131961. }
  131962. ,
  131963. e.DrawCallsStrategy = function() {
  131964. return function(e) {
  131965. var t = 0
  131966. , i = e.onBeforeAnimationsObservable.add((function() {
  131967. e.getEngine()._drawCalls.fetchNewFrame()
  131968. }
  131969. ))
  131970. , n = e.onAfterRenderObservable.add((function() {
  131971. t = e.getEngine()._drawCalls.current
  131972. }
  131973. ));
  131974. return {
  131975. id: "Draw calls",
  131976. getData: function() {
  131977. return t
  131978. },
  131979. dispose: function() {
  131980. e.onBeforeAnimationsObservable.remove(i),
  131981. e.onAfterRenderObservable.remove(n)
  131982. }
  131983. }
  131984. }
  131985. }
  131986. ,
  131987. e.TotalLightsStrategy = function() {
  131988. return function(e) {
  131989. return {
  131990. id: "Total lights",
  131991. getData: function() {
  131992. return e.lights.length
  131993. },
  131994. dispose: QT
  131995. }
  131996. }
  131997. }
  131998. ,
  131999. e.TotalVerticesStrategy = function() {
  132000. return function(e) {
  132001. return {
  132002. id: "Total vertices",
  132003. getData: function() {
  132004. return e.getTotalVertices()
  132005. },
  132006. dispose: QT
  132007. }
  132008. }
  132009. }
  132010. ,
  132011. e.TotalMaterialsStrategy = function() {
  132012. return function(e) {
  132013. return {
  132014. id: "Total materials",
  132015. getData: function() {
  132016. return e.materials.length
  132017. },
  132018. dispose: QT
  132019. }
  132020. }
  132021. }
  132022. ,
  132023. e.TotalTexturesStrategy = function() {
  132024. return function(e) {
  132025. return {
  132026. id: "Total textures",
  132027. getData: function() {
  132028. return e.textures.length
  132029. },
  132030. dispose: QT
  132031. }
  132032. }
  132033. }
  132034. ,
  132035. e.AbsoluteFpsStrategy = function() {
  132036. return function(e) {
  132037. var t = new Yf(e);
  132038. return t.captureFrameTime = !0,
  132039. {
  132040. id: "Absolute FPS",
  132041. getData: function() {
  132042. return 1e3 / t.frameTimeCounter.lastSecAverage
  132043. },
  132044. dispose: QT
  132045. }
  132046. }
  132047. }
  132048. ,
  132049. e.MeshesSelectionStrategy = function() {
  132050. return function(e) {
  132051. var t = ct.Now
  132052. , i = 0
  132053. , n = e.onBeforeActiveMeshesEvaluationObservable.add((function() {
  132054. t = ct.Now
  132055. }
  132056. ))
  132057. , r = e.onAfterActiveMeshesEvaluationObservable.add((function() {
  132058. i = ct.Now - t
  132059. }
  132060. ));
  132061. return {
  132062. id: "Meshes Selection",
  132063. getData: function() {
  132064. return i
  132065. },
  132066. dispose: function() {
  132067. e.onBeforeActiveMeshesEvaluationObservable.remove(n),
  132068. e.onAfterActiveMeshesEvaluationObservable.remove(r)
  132069. }
  132070. }
  132071. }
  132072. }
  132073. ,
  132074. e.RenderTargetsStrategy = function() {
  132075. return function(e) {
  132076. var t = ct.Now
  132077. , i = 0
  132078. , n = e.onBeforeRenderTargetsRenderObservable.add((function() {
  132079. t = ct.Now
  132080. }
  132081. ))
  132082. , r = e.onAfterRenderTargetsRenderObservable.add((function() {
  132083. i = ct.Now - t
  132084. }
  132085. ));
  132086. return {
  132087. id: "Render Targets",
  132088. getData: function() {
  132089. return i
  132090. },
  132091. dispose: function() {
  132092. e.onBeforeRenderTargetsRenderObservable.remove(n),
  132093. e.onAfterRenderTargetsRenderObservable.remove(r)
  132094. }
  132095. }
  132096. }
  132097. }
  132098. ,
  132099. e.ParticlesStrategy = function() {
  132100. return function(e) {
  132101. var t = ct.Now
  132102. , i = 0
  132103. , n = e.onBeforeParticlesRenderingObservable.add((function() {
  132104. t = ct.Now
  132105. }
  132106. ))
  132107. , r = e.onAfterParticlesRenderingObservable.add((function() {
  132108. i = ct.Now - t
  132109. }
  132110. ));
  132111. return {
  132112. id: "Particles",
  132113. getData: function() {
  132114. return i
  132115. },
  132116. dispose: function() {
  132117. e.onBeforeParticlesRenderingObservable.remove(n),
  132118. e.onAfterParticlesRenderingObservable.remove(r)
  132119. }
  132120. }
  132121. }
  132122. }
  132123. ,
  132124. e.SpritesStrategy = function() {
  132125. return function(e) {
  132126. var t, i, n = ct.Now, r = 0, o = null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t ? void 0 : t.add((function() {
  132127. n = ct.Now
  132128. }
  132129. )), a = null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i ? void 0 : i.add((function() {
  132130. r = ct.Now - n
  132131. }
  132132. ));
  132133. return {
  132134. id: "Sprites",
  132135. getData: function() {
  132136. return r
  132137. },
  132138. dispose: function() {
  132139. var t, i;
  132140. null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t || t.remove(o),
  132141. null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i || i.remove(a)
  132142. }
  132143. }
  132144. }
  132145. }
  132146. ,
  132147. e.AnimationsStrategy = function() {
  132148. return function(e) {
  132149. var t = ct.Now
  132150. , i = 0
  132151. , n = e.onBeforeAnimationsObservable.add((function() {
  132152. t = ct.Now
  132153. }
  132154. ))
  132155. , r = e.onAfterAnimationsObservable.add((function() {
  132156. i = ct.Now - t
  132157. }
  132158. ));
  132159. return {
  132160. id: "Animations",
  132161. getData: function() {
  132162. return i
  132163. },
  132164. dispose: function() {
  132165. e.onBeforeAnimationsObservable.remove(n),
  132166. e.onAfterAnimationsObservable.remove(r)
  132167. }
  132168. }
  132169. }
  132170. }
  132171. ,
  132172. e.PhysicsStrategy = function() {
  132173. return function(e) {
  132174. var t, i, n = ct.Now, r = 0, o = null === (t = e.onBeforePhysicsObservable) || void 0 === t ? void 0 : t.add((function() {
  132175. n = ct.Now
  132176. }
  132177. )), a = null === (i = e.onAfterPhysicsObservable) || void 0 === i ? void 0 : i.add((function() {
  132178. r = ct.Now - n
  132179. }
  132180. ));
  132181. return {
  132182. id: "Physics",
  132183. getData: function() {
  132184. return r
  132185. },
  132186. dispose: function() {
  132187. var t, i;
  132188. null === (t = e.onBeforePhysicsObservable) || void 0 === t || t.remove(o),
  132189. null === (i = e.onAfterPhysicsObservable) || void 0 === i || i.remove(a)
  132190. }
  132191. }
  132192. }
  132193. }
  132194. ,
  132195. e.RenderStrategy = function() {
  132196. return function(e) {
  132197. var t = ct.Now
  132198. , i = 0
  132199. , n = e.onBeforeDrawPhaseObservable.add((function() {
  132200. t = ct.Now
  132201. }
  132202. ))
  132203. , r = e.onAfterDrawPhaseObservable.add((function() {
  132204. i = ct.Now - t
  132205. }
  132206. ));
  132207. return {
  132208. id: "Render",
  132209. getData: function() {
  132210. return i
  132211. },
  132212. dispose: function() {
  132213. e.onBeforeDrawPhaseObservable.remove(n),
  132214. e.onAfterDrawPhaseObservable.remove(r)
  132215. }
  132216. }
  132217. }
  132218. }
  132219. ,
  132220. e.FrameTotalStrategy = function() {
  132221. return function(e) {
  132222. var t = ct.Now
  132223. , i = 0
  132224. , n = e.onBeforeAnimationsObservable.add((function() {
  132225. t = ct.Now
  132226. }
  132227. ))
  132228. , r = e.onAfterRenderObservable.add((function() {
  132229. i = ct.Now - t
  132230. }
  132231. ));
  132232. return {
  132233. id: "Frame Total",
  132234. getData: function() {
  132235. return i
  132236. },
  132237. dispose: function() {
  132238. e.onBeforeAnimationsObservable.remove(n),
  132239. e.onAfterRenderObservable.remove(r)
  132240. }
  132241. }
  132242. }
  132243. }
  132244. ,
  132245. e.InterFrameStrategy = function() {
  132246. return function(e) {
  132247. var t = ct.Now
  132248. , i = 0
  132249. , n = e.onBeforeAnimationsObservable.add((function() {
  132250. i = ct.Now - t
  132251. }
  132252. ))
  132253. , r = e.onAfterRenderObservable.add((function() {
  132254. t = ct.Now
  132255. }
  132256. ));
  132257. return {
  132258. id: "Inter-frame",
  132259. getData: function() {
  132260. return i
  132261. },
  132262. dispose: function() {
  132263. e.onBeforeAnimationsObservable.remove(n),
  132264. e.onAfterRenderObservable.remove(r)
  132265. }
  132266. }
  132267. }
  132268. }
  132269. ,
  132270. e.GpuFrameTimeStrategy = function() {
  132271. return function(e) {
  132272. var t = new jf(e.getEngine());
  132273. return t.captureGPUFrameTime = !0,
  132274. {
  132275. id: "GPU frame time",
  132276. getData: function() {
  132277. return Math.max(1e-6 * t.gpuFrameTimeCounter.current, 0)
  132278. },
  132279. dispose: function() {
  132280. t.dispose()
  132281. }
  132282. }
  132283. }
  132284. }
  132285. ,
  132286. e
  132287. }();
  132288. mn.prototype.getPerfCollector = function() {
  132289. return this._perfCollector || (this._perfCollector = new KT(this)),
  132290. this._perfCollector
  132291. }
  132292. ,
  132293. h.prototype.runCoroutineAsync = function(e) {
  132294. if (!this._coroutineScheduler) {
  132295. var t = (i = this,
  132296. n = new Array,
  132297. r = new Array,
  132298. o = new Array,
  132299. a = i.add((function() {
  132300. for (var e = n.length, t = 0; t < e; t++)
  132301. jn(n.shift(), r.shift(), o.shift())
  132302. }
  132303. )),
  132304. {
  132305. scheduler: function(e, t, i) {
  132306. n.push(e),
  132307. r.push(t),
  132308. o.push(i)
  132309. },
  132310. dispose: function() {
  132311. i.remove(a)
  132312. }
  132313. });
  132314. this._coroutineScheduler = t.scheduler,
  132315. this._coroutineSchedulerDispose = t.dispose
  132316. }
  132317. var i, n, r, o, a;
  132318. return qn(e, this._coroutineScheduler)
  132319. }
  132320. ,
  132321. h.prototype.cancelAllCoroutines = function() {
  132322. this._coroutineSchedulerDispose && this._coroutineSchedulerDispose(),
  132323. this._coroutineScheduler = void 0,
  132324. this._coroutineSchedulerDispose = void 0
  132325. }
  132326. ;
  132327. var ZT = function(e) {
  132328. function t(i, n) {
  132329. void 0 === n && (n = {});
  132330. var r = e.call(this, i) || this;
  132331. return r.options = n,
  132332. r._direction = new x(0,0,-1),
  132333. r._mat = new P,
  132334. r._onSelectEnabled = !1,
  132335. r._origin = new x(0,0,0),
  132336. r.lastNativeXRHitResults = [],
  132337. r.onHitTestResultObservable = new h,
  132338. r._onHitTestResults = function(e) {
  132339. var t = e.map((function(e) {
  132340. var t = P.FromArray(e.hitMatrix);
  132341. return r._xrSessionManager.scene.useRightHandedSystem || t.toggleModelMatrixHandInPlace(),
  132342. r.options.worldParentNode && t.multiplyToRef(r.options.worldParentNode.getWorldMatrix(), t),
  132343. {
  132344. xrHitResult: e,
  132345. transformationMatrix: t
  132346. }
  132347. }
  132348. ));
  132349. r.lastNativeXRHitResults = e,
  132350. r.onHitTestResultObservable.notifyObservers(t)
  132351. }
  132352. ,
  132353. r._onSelect = function(e) {
  132354. r._onSelectEnabled && t.XRHitTestWithSelectEvent(e, r._xrSessionManager.referenceSpace)
  132355. }
  132356. ,
  132357. r.xrNativeFeatureName = "hit-test",
  132358. gi.Warn("A newer version of this plugin is available"),
  132359. r
  132360. }
  132361. return U(t, e),
  132362. t.XRHitTestWithRay = function(e, t, i, n) {
  132363. return e.requestHitTest(t, i).then((function(e) {
  132364. var t = n || function(e) {
  132365. return !!e.hitMatrix
  132366. }
  132367. ;
  132368. return e.filter(t)
  132369. }
  132370. ))
  132371. }
  132372. ,
  132373. t.XRHitTestWithSelectEvent = function(e, t) {
  132374. var i = e.frame.getPose(e.inputSource.targetRaySpace, t);
  132375. if (!i)
  132376. return Promise.resolve([]);
  132377. var n = new XRRay(i.transform);
  132378. return this.XRHitTestWithRay(e.frame.session, n, t)
  132379. }
  132380. ,
  132381. t.prototype.attach = function() {
  132382. return !!e.prototype.attach.call(this) && (this.options.testOnPointerDownOnly && this._xrSessionManager.session.addEventListener("select", this._onSelect, !1),
  132383. !0)
  132384. }
  132385. ,
  132386. t.prototype.detach = function() {
  132387. return !!e.prototype.detach.call(this) && (this._onSelectEnabled = !1,
  132388. this._xrSessionManager.session.removeEventListener("select", this._onSelect),
  132389. !0)
  132390. }
  132391. ,
  132392. t.prototype.dispose = function() {
  132393. e.prototype.dispose.call(this),
  132394. this.onHitTestResultObservable.clear()
  132395. }
  132396. ,
  132397. t.prototype._onXRFrame = function(e) {
  132398. if (this.attached && !this.options.testOnPointerDownOnly) {
  132399. var i = e.getViewerPose(this._xrSessionManager.referenceSpace);
  132400. if (i) {
  132401. P.FromArrayToRef(i.transform.matrix, 0, this._mat),
  132402. x.TransformCoordinatesFromFloatsToRef(0, 0, 0, this._mat, this._origin),
  132403. x.TransformCoordinatesFromFloatsToRef(0, 0, -1, this._mat, this._direction),
  132404. this._direction.subtractInPlace(this._origin),
  132405. this._direction.normalize();
  132406. var n = new XRRay({
  132407. x: this._origin.x,
  132408. y: this._origin.y,
  132409. z: this._origin.z,
  132410. w: 0
  132411. },{
  132412. x: this._direction.x,
  132413. y: this._direction.y,
  132414. z: this._direction.z,
  132415. w: 0
  132416. });
  132417. t.XRHitTestWithRay(this._xrSessionManager.session, n, this._xrSessionManager.referenceSpace).then(this._onHitTestResults)
  132418. }
  132419. }
  132420. }
  132421. ,
  132422. t.Name = Io.HIT_TEST,
  132423. t.Version = 1,
  132424. t
  132425. }(wp);
  132426. Oo.AddWebXRFeature(ZT.Name, (function(e, t) {
  132427. return function() {
  132428. return new ZT(e,t)
  132429. }
  132430. }
  132431. ), ZT.Version, !1);
  132432. var JT = 0
  132433. , $T = function(e) {
  132434. function t(t, i) {
  132435. void 0 === i && (i = {});
  132436. var n = e.call(this, t) || this;
  132437. return n._options = i,
  132438. n._lastFrameDetected = new Set,
  132439. n._trackedAnchors = [],
  132440. n._futureAnchors = [],
  132441. n.onAnchorAddedObservable = new h,
  132442. n.onAnchorRemovedObservable = new h,
  132443. n.onAnchorUpdatedObservable = new h,
  132444. n._tmpVector = new x,
  132445. n._tmpQuaternion = new C,
  132446. n.xrNativeFeatureName = "anchors",
  132447. n
  132448. }
  132449. return U(t, e),
  132450. Object.defineProperty(t.prototype, "referenceSpaceForFrameAnchors", {
  132451. set: function(e) {
  132452. this._referenceSpaceForFrameAnchors = e
  132453. },
  132454. enumerable: !1,
  132455. configurable: !0
  132456. }),
  132457. t.prototype._populateTmpTransformation = function(e, t) {
  132458. return this._tmpVector.copyFrom(e),
  132459. this._tmpQuaternion.copyFrom(t),
  132460. this._xrSessionManager.scene.useRightHandedSystem || (this._tmpVector.z *= -1,
  132461. this._tmpQuaternion.z *= -1,
  132462. this._tmpQuaternion.w *= -1),
  132463. {
  132464. position: this._tmpVector,
  132465. rotationQuaternion: this._tmpQuaternion
  132466. }
  132467. }
  132468. ,
  132469. t.prototype.addAnchorPointUsingHitTestResultAsync = function(e, t, i) {
  132470. return void 0 === t && (t = new x),
  132471. void 0 === i && (i = new C),
  132472. G(this, void 0, void 0, (function() {
  132473. var n, r, o, a = this;
  132474. return z(this, (function(s) {
  132475. switch (s.label) {
  132476. case 0:
  132477. if (this._populateTmpTransformation(t, i),
  132478. n = new XRRigidTransform({
  132479. x: this._tmpVector.x,
  132480. y: this._tmpVector.y,
  132481. z: this._tmpVector.z
  132482. },{
  132483. x: this._tmpQuaternion.x,
  132484. y: this._tmpQuaternion.y,
  132485. z: this._tmpQuaternion.z,
  132486. w: this._tmpQuaternion.w
  132487. }),
  132488. e.xrHitResult.createAnchor)
  132489. return [3, 1];
  132490. throw this.detach(),
  132491. new Error("Anchors not enabled in this environment/browser");
  132492. case 1:
  132493. return s.trys.push([1, 3, , 4]),
  132494. [4, e.xrHitResult.createAnchor(n)];
  132495. case 2:
  132496. return r = s.sent(),
  132497. [2, new Promise((function(e, t) {
  132498. a._futureAnchors.push({
  132499. nativeAnchor: r,
  132500. resolved: !1,
  132501. submitted: !0,
  132502. xrTransformation: n,
  132503. resolve: e,
  132504. reject: t
  132505. })
  132506. }
  132507. ))];
  132508. case 3:
  132509. throw o = s.sent(),
  132510. new Error(o);
  132511. case 4:
  132512. return [2]
  132513. }
  132514. }
  132515. ))
  132516. }
  132517. ))
  132518. }
  132519. ,
  132520. t.prototype.addAnchorAtPositionAndRotationAsync = function(e, t, i) {
  132521. return void 0 === t && (t = new C),
  132522. void 0 === i && (i = !1),
  132523. G(this, void 0, void 0, (function() {
  132524. var n, r, o, a = this;
  132525. return z(this, (function(s) {
  132526. switch (s.label) {
  132527. case 0:
  132528. return this._populateTmpTransformation(e, t),
  132529. n = new XRRigidTransform({
  132530. x: this._tmpVector.x,
  132531. y: this._tmpVector.y,
  132532. z: this._tmpVector.z
  132533. },{
  132534. x: this._tmpQuaternion.x,
  132535. y: this._tmpQuaternion.y,
  132536. z: this._tmpQuaternion.z,
  132537. w: this._tmpQuaternion.w
  132538. }),
  132539. i && this.attached && this._xrSessionManager.currentFrame ? [4, this._createAnchorAtTransformation(n, this._xrSessionManager.currentFrame)] : [3, 2];
  132540. case 1:
  132541. return o = s.sent(),
  132542. [3, 3];
  132543. case 2:
  132544. o = void 0,
  132545. s.label = 3;
  132546. case 3:
  132547. return r = o,
  132548. [2, new Promise((function(e, t) {
  132549. a._futureAnchors.push({
  132550. nativeAnchor: r,
  132551. resolved: !1,
  132552. submitted: !1,
  132553. xrTransformation: n,
  132554. resolve: e,
  132555. reject: t
  132556. })
  132557. }
  132558. ))]
  132559. }
  132560. }
  132561. ))
  132562. }
  132563. ))
  132564. }
  132565. ,
  132566. Object.defineProperty(t.prototype, "anchors", {
  132567. get: function() {
  132568. return this._trackedAnchors
  132569. },
  132570. enumerable: !1,
  132571. configurable: !0
  132572. }),
  132573. t.prototype.detach = function() {
  132574. if (!e.prototype.detach.call(this))
  132575. return !1;
  132576. if (!this._options.doNotRemoveAnchorsOnSessionEnded)
  132577. for (; this._trackedAnchors.length; ) {
  132578. var t = this._trackedAnchors.pop();
  132579. if (t) {
  132580. try {
  132581. t.remove()
  132582. } catch (e) {}
  132583. this.onAnchorRemovedObservable.notifyObservers(t)
  132584. }
  132585. }
  132586. return !0
  132587. }
  132588. ,
  132589. t.prototype.dispose = function() {
  132590. this._futureAnchors.length = 0,
  132591. e.prototype.dispose.call(this),
  132592. this.onAnchorAddedObservable.clear(),
  132593. this.onAnchorRemovedObservable.clear(),
  132594. this.onAnchorUpdatedObservable.clear()
  132595. }
  132596. ,
  132597. t.prototype._onXRFrame = function(e) {
  132598. var t = this;
  132599. if (this.attached && e) {
  132600. var i = e.trackedAnchors;
  132601. if (i) {
  132602. var n = this._trackedAnchors.filter((function(e) {
  132603. return !i.has(e.xrAnchor)
  132604. }
  132605. )).map((function(e) {
  132606. return t._trackedAnchors.indexOf(e)
  132607. }
  132608. ))
  132609. , r = 0;
  132610. n.forEach((function(e) {
  132611. var i = t._trackedAnchors.splice(e - r, 1)[0];
  132612. t.onAnchorRemovedObservable.notifyObservers(i),
  132613. r++
  132614. }
  132615. )),
  132616. i.forEach((function(i) {
  132617. if (t._lastFrameDetected.has(i)) {
  132618. var n = t._findIndexInAnchorArray(i);
  132619. o = t._trackedAnchors[n];
  132620. try {
  132621. t._updateAnchorWithXRFrame(i, o, e),
  132622. o.attachedNode && (o.attachedNode.rotationQuaternion = o.attachedNode.rotationQuaternion || new C,
  132623. o.transformationMatrix.decompose(o.attachedNode.scaling, o.attachedNode.rotationQuaternion, o.attachedNode.position)),
  132624. t.onAnchorUpdatedObservable.notifyObservers(o)
  132625. } catch (e) {
  132626. gi.Warn("Anchor could not be updated")
  132627. }
  132628. } else {
  132629. var r = {
  132630. id: JT++,
  132631. xrAnchor: i,
  132632. remove: function() {
  132633. return i.delete()
  132634. }
  132635. }
  132636. , o = t._updateAnchorWithXRFrame(i, r, e);
  132637. t._trackedAnchors.push(o),
  132638. t.onAnchorAddedObservable.notifyObservers(o);
  132639. var a = t._futureAnchors.filter((function(e) {
  132640. return e.nativeAnchor === i
  132641. }
  132642. ))[0];
  132643. a && (a.resolve(o),
  132644. a.resolved = !0)
  132645. }
  132646. }
  132647. )),
  132648. this._lastFrameDetected = i
  132649. }
  132650. this._futureAnchors.forEach((function(i) {
  132651. i.resolved || i.submitted || (t._createAnchorAtTransformation(i.xrTransformation, e).then((function(e) {
  132652. i.nativeAnchor = e
  132653. }
  132654. ), (function(e) {
  132655. i.resolved = !0,
  132656. i.reject(e)
  132657. }
  132658. )),
  132659. i.submitted = !0)
  132660. }
  132661. ))
  132662. }
  132663. }
  132664. ,
  132665. t.prototype._findIndexInAnchorArray = function(e) {
  132666. for (var t = 0; t < this._trackedAnchors.length; ++t)
  132667. if (this._trackedAnchors[t].xrAnchor === e)
  132668. return t;
  132669. return -1
  132670. }
  132671. ,
  132672. t.prototype._updateAnchorWithXRFrame = function(e, t, i) {
  132673. var n = i.getPose(e.anchorSpace, this._xrSessionManager.referenceSpace);
  132674. if (n) {
  132675. var r = t.transformationMatrix || new P;
  132676. P.FromArrayToRef(n.transform.matrix, 0, r),
  132677. this._xrSessionManager.scene.useRightHandedSystem || r.toggleModelMatrixHandInPlace(),
  132678. t.transformationMatrix = r,
  132679. this._options.worldParentNode && r.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), r)
  132680. }
  132681. return t
  132682. }
  132683. ,
  132684. t.prototype._createAnchorAtTransformation = function(e, t) {
  132685. var i;
  132686. return G(this, void 0, void 0, (function() {
  132687. return z(this, (function(n) {
  132688. if (!t.createAnchor)
  132689. throw this.detach(),
  132690. new Error("Anchors are not enabled in your browser");
  132691. try {
  132692. return [2, t.createAnchor(e, null !== (i = this._referenceSpaceForFrameAnchors) && void 0 !== i ? i : this._xrSessionManager.referenceSpace)]
  132693. } catch (e) {
  132694. throw new Error(e)
  132695. }
  132696. return [2]
  132697. }
  132698. ))
  132699. }
  132700. ))
  132701. }
  132702. ,
  132703. t.Name = Io.ANCHOR_SYSTEM,
  132704. t.Version = 1,
  132705. t
  132706. }(wp);
  132707. Oo.AddWebXRFeature($T.Name, (function(e, t) {
  132708. return function() {
  132709. return new $T(e,t)
  132710. }
  132711. }
  132712. ), $T.Version);
  132713. var eE = 0
  132714. , tE = function(e) {
  132715. function t(t, i) {
  132716. void 0 === i && (i = {});
  132717. var n = e.call(this, t) || this;
  132718. return n._options = i,
  132719. n._detectedPlanes = [],
  132720. n._enabled = !1,
  132721. n._lastFrameDetected = new Set,
  132722. n.onPlaneAddedObservable = new h,
  132723. n.onPlaneRemovedObservable = new h,
  132724. n.onPlaneUpdatedObservable = new h,
  132725. n.xrNativeFeatureName = "plane-detection",
  132726. n._xrSessionManager.session ? n._init() : n._xrSessionManager.onXRSessionInit.addOnce((function() {
  132727. n._init()
  132728. }
  132729. )),
  132730. n
  132731. }
  132732. return U(t, e),
  132733. t.prototype.detach = function() {
  132734. if (!e.prototype.detach.call(this))
  132735. return !1;
  132736. if (!this._options.doNotRemovePlanesOnSessionEnded)
  132737. for (; this._detectedPlanes.length; ) {
  132738. var t = this._detectedPlanes.pop();
  132739. t && this.onPlaneRemovedObservable.notifyObservers(t)
  132740. }
  132741. return !0
  132742. }
  132743. ,
  132744. t.prototype.dispose = function() {
  132745. e.prototype.dispose.call(this),
  132746. this.onPlaneAddedObservable.clear(),
  132747. this.onPlaneRemovedObservable.clear(),
  132748. this.onPlaneUpdatedObservable.clear()
  132749. }
  132750. ,
  132751. t.prototype.isCompatible = function() {
  132752. return "undefined" != typeof XRPlane
  132753. }
  132754. ,
  132755. t.prototype._onXRFrame = function(e) {
  132756. var t, i = this;
  132757. if (this.attached && this._enabled && e) {
  132758. var n = e.detectedPlanes || (null === (t = e.worldInformation) || void 0 === t ? void 0 : t.detectedPlanes);
  132759. if (n) {
  132760. for (var r = 0; r < this._detectedPlanes.length; r++) {
  132761. var o = this._detectedPlanes[r];
  132762. n.has(o.xrPlane) || (this._detectedPlanes.splice(r--, 1),
  132763. this.onPlaneRemovedObservable.notifyObservers(o))
  132764. }
  132765. n.forEach((function(t) {
  132766. if (i._lastFrameDetected.has(t)) {
  132767. if (t.lastChangedTime === i._xrSessionManager.currentTimestamp) {
  132768. var n = i._findIndexInPlaneArray(t);
  132769. o = i._detectedPlanes[n],
  132770. i._updatePlaneWithXRPlane(t, o, e),
  132771. i.onPlaneUpdatedObservable.notifyObservers(o)
  132772. }
  132773. } else {
  132774. var r = {
  132775. id: eE++,
  132776. xrPlane: t,
  132777. polygonDefinition: []
  132778. }
  132779. , o = i._updatePlaneWithXRPlane(t, r, e);
  132780. i._detectedPlanes.push(o),
  132781. i.onPlaneAddedObservable.notifyObservers(o)
  132782. }
  132783. }
  132784. )),
  132785. this._lastFrameDetected = n
  132786. }
  132787. }
  132788. }
  132789. ,
  132790. t.prototype._init = function() {
  132791. var e = this
  132792. , t = function() {
  132793. e._enabled = !0,
  132794. e._detectedPlanes.length && (e._detectedPlanes.length = 0)
  132795. };
  132796. this._xrSessionManager.isNative && this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions),
  132797. this._xrSessionManager.session.updateWorldTrackingState ? (this._xrSessionManager.session.updateWorldTrackingState({
  132798. planeDetectionState: {
  132799. enabled: !0
  132800. }
  132801. }),
  132802. t()) : t()
  132803. }
  132804. ,
  132805. t.prototype._updatePlaneWithXRPlane = function(e, t, i) {
  132806. var n = this;
  132807. t.polygonDefinition = e.polygon.map((function(e) {
  132808. var t = n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
  132809. return new x(e.x,e.y,e.z * t)
  132810. }
  132811. ));
  132812. var r = i.getPose(e.planeSpace, this._xrSessionManager.referenceSpace);
  132813. if (r) {
  132814. var o = t.transformationMatrix || new P;
  132815. P.FromArrayToRef(r.transform.matrix, 0, o),
  132816. this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(),
  132817. t.transformationMatrix = o,
  132818. this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o)
  132819. }
  132820. return t
  132821. }
  132822. ,
  132823. t.prototype._findIndexInPlaneArray = function(e) {
  132824. for (var t = 0; t < this._detectedPlanes.length; ++t)
  132825. if (this._detectedPlanes[t].xrPlane === e)
  132826. return t;
  132827. return -1
  132828. }
  132829. ,
  132830. t.Name = Io.PLANE_DETECTION,
  132831. t.Version = 1,
  132832. t
  132833. }(wp);
  132834. Oo.AddWebXRFeature(tE.Name, (function(e, t) {
  132835. return function() {
  132836. return new tE(e,t)
  132837. }
  132838. }
  132839. ), tE.Version);
  132840. var iE = function(e) {
  132841. function t(t, i) {
  132842. void 0 === i && (i = {});
  132843. var n = e.call(this, t) || this;
  132844. return n.options = i,
  132845. n.onBackgroundStateChangedObservable = new h,
  132846. n
  132847. }
  132848. return U(t, e),
  132849. t.prototype.attach = function() {
  132850. return this._setBackgroundState(!1),
  132851. e.prototype.attach.call(this)
  132852. }
  132853. ,
  132854. t.prototype.detach = function() {
  132855. return this._setBackgroundState(!0),
  132856. e.prototype.detach.call(this)
  132857. }
  132858. ,
  132859. t.prototype.dispose = function() {
  132860. e.prototype.dispose.call(this),
  132861. this.onBackgroundStateChangedObservable.clear()
  132862. }
  132863. ,
  132864. t.prototype._onXRFrame = function(e) {}
  132865. ,
  132866. t.prototype._setBackgroundState = function(e) {
  132867. var t = this._xrSessionManager.scene;
  132868. if (!this.options.ignoreEnvironmentHelper)
  132869. if (this.options.environmentHelperRemovalFlags) {
  132870. if (this.options.environmentHelperRemovalFlags.skyBox) {
  132871. var i = t.getMeshByName("BackgroundSkybox");
  132872. i && i.setEnabled(e)
  132873. }
  132874. if (this.options.environmentHelperRemovalFlags.ground) {
  132875. var n = t.getMeshByName("BackgroundPlane");
  132876. n && n.setEnabled(e)
  132877. }
  132878. } else {
  132879. var r = t.getMeshByName("BackgroundHelper");
  132880. r && r.setEnabled(e)
  132881. }
  132882. this.options.backgroundMeshes && this.options.backgroundMeshes.forEach((function(t) {
  132883. return t.setEnabled(e)
  132884. }
  132885. )),
  132886. this.onBackgroundStateChangedObservable.notifyObservers(e)
  132887. }
  132888. ,
  132889. t.Name = Io.BACKGROUND_REMOVER,
  132890. t.Version = 1,
  132891. t
  132892. }(wp);
  132893. Oo.AddWebXRFeature(iE.Name, (function(e, t) {
  132894. return function() {
  132895. return new iE(e,t)
  132896. }
  132897. }
  132898. ), iE.Version, !0);
  132899. var nE = function() {}
  132900. , rE = function(e) {
  132901. function t(t, i) {
  132902. var n = e.call(this, t) || this;
  132903. return n._options = i,
  132904. n._attachController = function(e) {
  132905. n._controllers[e.uniqueId] || (n._xrSessionManager.scene.isPhysicsEnabled() || K.Warn("physics engine not enabled, skipped. Please add this controller manually."),
  132906. n._options.physicsProperties.useControllerMesh && e.inputSource.gamepad ? e.onMotionControllerInitObservable.addOnce((function(t) {
  132907. t._doNotLoadControllerMesh ? n._createPhysicsImpostor(e) : t.onModelLoadedObservable.addOnce((function() {
  132908. var i = new Vl(t.rootMesh,Vl.MeshImpostor,V({
  132909. mass: 0
  132910. }, n._options.physicsProperties))
  132911. , r = e.grip || e.pointer;
  132912. n._controllers[e.uniqueId] = {
  132913. xrController: e,
  132914. impostor: i,
  132915. oldPos: r.position.clone(),
  132916. oldRotation: r.rotationQuaternion.clone()
  132917. }
  132918. }
  132919. ))
  132920. }
  132921. )) : n._createPhysicsImpostor(e))
  132922. }
  132923. ,
  132924. n._controllers = {},
  132925. n._debugMode = !1,
  132926. n._delta = 0,
  132927. n._lastTimestamp = 0,
  132928. n._tmpQuaternion = new C,
  132929. n._tmpVector = new x,
  132930. n._options.physicsProperties || (n._options.physicsProperties = {}),
  132931. n
  132932. }
  132933. return U(t, e),
  132934. t.prototype._createPhysicsImpostor = function(e) {
  132935. var t = this._options.physicsProperties.impostorType || Vl.SphereImpostor
  132936. , i = this._options.physicsProperties.impostorSize || .1
  132937. , n = Dl("impostor-mesh-" + e.uniqueId, {
  132938. diameterX: "number" == typeof i ? i : i.width,
  132939. diameterY: "number" == typeof i ? i : i.height,
  132940. diameterZ: "number" == typeof i ? i : i.depth
  132941. });
  132942. n.isVisible = this._debugMode,
  132943. n.isPickable = !1,
  132944. n.rotationQuaternion = new C;
  132945. var r = e.grip || e.pointer;
  132946. n.position.copyFrom(r.position),
  132947. n.rotationQuaternion.copyFrom(r.rotationQuaternion);
  132948. var o = new Vl(n,t,V({
  132949. mass: 0
  132950. }, this._options.physicsProperties));
  132951. this._controllers[e.uniqueId] = {
  132952. xrController: e,
  132953. impostor: o,
  132954. impostorMesh: n
  132955. }
  132956. }
  132957. ,
  132958. t.prototype._enablePhysicsDebug = function() {
  132959. var e = this;
  132960. this._debugMode = !0,
  132961. Object.keys(this._controllers).forEach((function(t) {
  132962. var i = e._controllers[t];
  132963. i.impostorMesh && (i.impostorMesh.isVisible = !0)
  132964. }
  132965. ))
  132966. }
  132967. ,
  132968. t.prototype.addController = function(e) {
  132969. this._attachController(e)
  132970. }
  132971. ,
  132972. t.prototype.attach = function() {
  132973. var t = this;
  132974. if (!e.prototype.attach.call(this))
  132975. return !1;
  132976. if (!this._options.xrInput)
  132977. return !0;
  132978. if (this._options.xrInput.controllers.forEach(this._attachController),
  132979. this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
  132980. this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function(e) {
  132981. t._detachController(e.uniqueId)
  132982. }
  132983. )),
  132984. this._options.enableHeadsetImpostor) {
  132985. var i = this._options.headsetImpostorParams || {
  132986. impostorType: Vl.SphereImpostor,
  132987. restitution: .8,
  132988. impostorSize: .3
  132989. }
  132990. , n = i.impostorSize || .3;
  132991. this._headsetMesh = Dl("headset-mesh", {
  132992. diameterX: "number" == typeof n ? n : n.width,
  132993. diameterY: "number" == typeof n ? n : n.height,
  132994. diameterZ: "number" == typeof n ? n : n.depth
  132995. }),
  132996. this._headsetMesh.rotationQuaternion = new C,
  132997. this._headsetMesh.isVisible = !1,
  132998. this._headsetImpostor = new Vl(this._headsetMesh,i.impostorType,V({
  132999. mass: 0
  133000. }, i))
  133001. }
  133002. return !0
  133003. }
  133004. ,
  133005. t.prototype.detach = function() {
  133006. var t = this;
  133007. return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
  133008. t._detachController(e)
  133009. }
  133010. )),
  133011. this._headsetMesh && this._headsetMesh.dispose(),
  133012. !0)
  133013. }
  133014. ,
  133015. t.prototype.getHeadsetImpostor = function() {
  133016. return this._headsetImpostor
  133017. }
  133018. ,
  133019. t.prototype.getImpostorForController = function(e) {
  133020. var t = "string" == typeof e ? e : e.uniqueId;
  133021. return this._controllers[t] ? this._controllers[t].impostor : null
  133022. }
  133023. ,
  133024. t.prototype.setPhysicsProperties = function(e) {
  133025. this._options.physicsProperties = V(V({}, this._options.physicsProperties), e)
  133026. }
  133027. ,
  133028. t.prototype._onXRFrame = function(e) {
  133029. var t, i, n = this;
  133030. if (this._delta = this._xrSessionManager.currentTimestamp - this._lastTimestamp,
  133031. this._lastTimestamp = this._xrSessionManager.currentTimestamp,
  133032. this._headsetMesh && this._headsetImpostor) {
  133033. if (this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.globalPosition),
  133034. this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.absoluteRotation),
  133035. null === (t = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === t ? void 0 : t.linearVelocity) {
  133036. var r = this._options.xrInput.xrCamera._lastXRViewerPose.linearVelocity;
  133037. this._tmpVector.set(r.x, r.y, r.z),
  133038. this._headsetImpostor.setLinearVelocity(this._tmpVector)
  133039. }
  133040. if (null === (i = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === i ? void 0 : i.angularVelocity) {
  133041. var o = this._options.xrInput.xrCamera._lastXRViewerPose.angularVelocity;
  133042. this._tmpVector.set(o.x, o.y, o.z),
  133043. this._headsetImpostor.setAngularVelocity(this._tmpVector)
  133044. }
  133045. }
  133046. Object.keys(this._controllers).forEach((function(e) {
  133047. var t, i, r = n._controllers[e], o = r.xrController.grip || r.xrController.pointer, a = r.oldPos || r.impostorMesh.position;
  133048. if (null === (t = r.xrController._lastXRPose) || void 0 === t ? void 0 : t.linearVelocity) {
  133049. var s = r.xrController._lastXRPose.linearVelocity;
  133050. n._tmpVector.set(s.x, s.y, s.z),
  133051. r.impostor.setLinearVelocity(n._tmpVector)
  133052. } else
  133053. o.position.subtractToRef(a, n._tmpVector),
  133054. n._tmpVector.scaleInPlace(1e3 / n._delta),
  133055. r.impostor.setLinearVelocity(n._tmpVector);
  133056. a.copyFrom(o.position),
  133057. n._debugMode && console.log(n._tmpVector, "linear");
  133058. var l = r.oldRotation || r.impostorMesh.rotationQuaternion;
  133059. if (null === (i = r.xrController._lastXRPose) || void 0 === i ? void 0 : i.angularVelocity) {
  133060. var c = r.xrController._lastXRPose.angularVelocity;
  133061. n._tmpVector.set(c.x, c.y, c.z),
  133062. r.impostor.setAngularVelocity(n._tmpVector)
  133063. } else if (!l.equalsWithEpsilon(o.rotationQuaternion)) {
  133064. l.conjugateInPlace().multiplyToRef(o.rotationQuaternion, n._tmpQuaternion);
  133065. var u = Math.sqrt(n._tmpQuaternion.x * n._tmpQuaternion.x + n._tmpQuaternion.y * n._tmpQuaternion.y + n._tmpQuaternion.z * n._tmpQuaternion.z);
  133066. if (n._tmpVector.set(n._tmpQuaternion.x, n._tmpQuaternion.y, n._tmpQuaternion.z),
  133067. u < .001)
  133068. n._tmpVector.scaleInPlace(2);
  133069. else {
  133070. var h = 2 * Math.atan2(u, n._tmpQuaternion.w);
  133071. n._tmpVector.scaleInPlace(h / (u * (n._delta / 1e3)))
  133072. }
  133073. r.impostor.setAngularVelocity(n._tmpVector)
  133074. }
  133075. l.copyFrom(o.rotationQuaternion),
  133076. n._debugMode && console.log(n._tmpVector, n._tmpQuaternion, "angular")
  133077. }
  133078. ))
  133079. }
  133080. ,
  133081. t.prototype._detachController = function(e) {
  133082. var t = this._controllers[e];
  133083. t && (t.impostorMesh && t.impostorMesh.dispose(),
  133084. delete this._controllers[e])
  133085. }
  133086. ,
  133087. t.Name = Io.PHYSICS_CONTROLLERS,
  133088. t.Version = 1,
  133089. t
  133090. }(wp);
  133091. Oo.AddWebXRFeature(rE.Name, (function(e, t) {
  133092. return function() {
  133093. return new rE(e,t)
  133094. }
  133095. }
  133096. ), rE.Version, !0);
  133097. var oE = function(e) {
  133098. function t(t, i) {
  133099. void 0 === i && (i = {});
  133100. var n = e.call(this, t) || this;
  133101. return n.options = i,
  133102. n._tmpMat = new P,
  133103. n._tmpPos = new x,
  133104. n._tmpQuat = new C,
  133105. n._initHitTestSource = function(e) {
  133106. if (e) {
  133107. var t = new XRRay(n.options.offsetRay || {})
  133108. , i = {
  133109. space: n.options.useReferenceSpace ? e : n._xrSessionManager.viewerReferenceSpace,
  133110. offsetRay: t
  133111. };
  133112. n.options.entityTypes && (i.entityTypes = n.options.entityTypes),
  133113. i.space ? n._xrSessionManager.session.requestHitTestSource(i).then((function(e) {
  133114. n._xrHitTestSource && n._xrHitTestSource.cancel(),
  133115. n._xrHitTestSource = e
  133116. }
  133117. )) : gi.Warn("waiting for viewer reference space to initialize")
  133118. }
  133119. }
  133120. ,
  133121. n.autoCloneTransformation = !1,
  133122. n.onHitTestResultObservable = new h,
  133123. n.paused = !1,
  133124. n.xrNativeFeatureName = "hit-test",
  133125. gi.Warn("Hit test is an experimental and unstable feature."),
  133126. n
  133127. }
  133128. return U(t, e),
  133129. t.prototype.attach = function() {
  133130. var t = this;
  133131. if (!e.prototype.attach.call(this))
  133132. return !1;
  133133. if (!this._xrSessionManager.session.requestHitTestSource)
  133134. return !1;
  133135. if (this.options.disablePermanentHitTest || (this._xrSessionManager.referenceSpace && this._initHitTestSource(this._xrSessionManager.referenceSpace),
  133136. this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)),
  133137. this.options.enableTransientHitTest) {
  133138. var i = new XRRay(this.options.transientOffsetRay || {});
  133139. this._xrSessionManager.session.requestHitTestSourceForTransientInput({
  133140. profile: this.options.transientHitTestProfile || "generic-touchscreen",
  133141. offsetRay: i,
  133142. entityTypes: this.options.entityTypes
  133143. }).then((function(e) {
  133144. t._transientXrHitTestSource = e
  133145. }
  133146. ))
  133147. }
  133148. return !0
  133149. }
  133150. ,
  133151. t.prototype.detach = function() {
  133152. return !!e.prototype.detach.call(this) && (this._xrHitTestSource && (this._xrHitTestSource.cancel(),
  133153. this._xrHitTestSource = null),
  133154. this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource),
  133155. this._transientXrHitTestSource && (this._transientXrHitTestSource.cancel(),
  133156. this._transientXrHitTestSource = null),
  133157. !0)
  133158. }
  133159. ,
  133160. t.prototype.dispose = function() {
  133161. e.prototype.dispose.call(this),
  133162. this.onHitTestResultObservable.clear()
  133163. }
  133164. ,
  133165. t.prototype._onXRFrame = function(e) {
  133166. var t = this;
  133167. if (this.attached && !this.paused) {
  133168. if (this._xrHitTestSource) {
  133169. var i = e.getHitTestResults(this._xrHitTestSource);
  133170. this._processWebXRHitTestResult(i)
  133171. }
  133172. this._transientXrHitTestSource && e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach((function(e) {
  133173. t._processWebXRHitTestResult(e.results, e.inputSource)
  133174. }
  133175. ))
  133176. }
  133177. }
  133178. ,
  133179. t.prototype._processWebXRHitTestResult = function(e, t) {
  133180. var i = this
  133181. , n = [];
  133182. e.forEach((function(e) {
  133183. var r = e.getPose(i._xrSessionManager.referenceSpace);
  133184. if (r) {
  133185. var o = r.transform.position
  133186. , a = r.transform.orientation;
  133187. i._tmpPos.set(o.x, o.y, o.z),
  133188. i._tmpQuat.set(a.x, a.y, a.z, a.w),
  133189. P.FromFloat32ArrayToRefScaled(r.transform.matrix, 0, 1, i._tmpMat),
  133190. i._xrSessionManager.scene.useRightHandedSystem || (i._tmpPos.z *= -1,
  133191. i._tmpQuat.z *= -1,
  133192. i._tmpQuat.w *= -1,
  133193. i._tmpMat.toggleModelMatrixHandInPlace());
  133194. var s = {
  133195. position: i.autoCloneTransformation ? i._tmpPos.clone() : i._tmpPos,
  133196. rotationQuaternion: i.autoCloneTransformation ? i._tmpQuat.clone() : i._tmpQuat,
  133197. transformationMatrix: i.autoCloneTransformation ? i._tmpMat.clone() : i._tmpMat,
  133198. inputSource: t,
  133199. isTransient: !!t,
  133200. xrHitResult: e
  133201. };
  133202. n.push(s)
  133203. }
  133204. }
  133205. )),
  133206. this.onHitTestResultObservable.notifyObservers(n)
  133207. }
  133208. ,
  133209. t.Name = Io.HIT_TEST,
  133210. t.Version = 2,
  133211. t
  133212. }(wp);
  133213. Oo.AddWebXRFeature(oE.Name, (function(e, t) {
  133214. return function() {
  133215. return new oE(e,t)
  133216. }
  133217. }
  133218. ), oE.Version, !1);
  133219. var aE, sE = function(e) {
  133220. function t(t) {
  133221. var i = e.call(this, t) || this;
  133222. return i._enabled = !1,
  133223. i._featurePointCloud = [],
  133224. i.onFeaturePointsAddedObservable = new h,
  133225. i.onFeaturePointsUpdatedObservable = new h,
  133226. i.xrNativeFeatureName = "bjsfeature-points",
  133227. i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function() {
  133228. i._init()
  133229. }
  133230. )),
  133231. i
  133232. }
  133233. return U(t, e),
  133234. Object.defineProperty(t.prototype, "featurePointCloud", {
  133235. get: function() {
  133236. return this._featurePointCloud
  133237. },
  133238. enumerable: !1,
  133239. configurable: !0
  133240. }),
  133241. t.prototype.detach = function() {
  133242. return !!e.prototype.detach.call(this) && (this.featurePointCloud.length = 0,
  133243. !0)
  133244. }
  133245. ,
  133246. t.prototype.dispose = function() {
  133247. e.prototype.dispose.call(this),
  133248. this._featurePointCloud.length = 0,
  133249. this.onFeaturePointsUpdatedObservable.clear(),
  133250. this.onFeaturePointsAddedObservable.clear()
  133251. }
  133252. ,
  133253. t.prototype._onXRFrame = function(e) {
  133254. if (this.attached && this._enabled && e) {
  133255. var t = e.featurePointCloud;
  133256. if (t && 0 !== t.length) {
  133257. if (t.length % 5 != 0)
  133258. throw new Error("Received malformed feature point cloud of length: " + t.length);
  133259. for (var i = t.length / 5, n = new Array, r = new Array, o = 0; o < i; o++) {
  133260. var a = 5 * o
  133261. , s = t[a + 4];
  133262. this._featurePointCloud[s] ? n.push(s) : (this._featurePointCloud[s] = {
  133263. position: new x,
  133264. confidenceValue: 0
  133265. },
  133266. r.push(s)),
  133267. this._featurePointCloud[s].position.x = t[a],
  133268. this._featurePointCloud[s].position.y = t[a + 1],
  133269. this._featurePointCloud[s].position.z = t[a + 2],
  133270. this._featurePointCloud[s].confidenceValue = t[a + 3]
  133271. }
  133272. r.length > 0 && this.onFeaturePointsAddedObservable.notifyObservers(r),
  133273. n.length > 0 && this.onFeaturePointsUpdatedObservable.notifyObservers(n)
  133274. }
  133275. }
  133276. }
  133277. ,
  133278. t.prototype._init = function() {
  133279. this._xrSessionManager.session.trySetFeaturePointCloudEnabled && this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0) && (this._enabled = !0)
  133280. }
  133281. ,
  133282. t.Name = Io.FEATURE_POINTS,
  133283. t.Version = 1,
  133284. t
  133285. }(wp);
  133286. Oo.AddWebXRFeature(sE.Name, (function(e) {
  133287. return function() {
  133288. return new sE(e)
  133289. }
  133290. }
  133291. ), sE.Version);
  133292. var lE = ["wrist", "thumb-metacarpal", "thumb-phalanx-proximal", "thumb-phalanx-distal", "thumb-tip", "index-finger-metacarpal", "index-finger-phalanx-proximal", "index-finger-phalanx-intermediate", "index-finger-phalanx-distal", "index-finger-tip", "middle-finger-metacarpal", "middle-finger-phalanx-proximal", "middle-finger-phalanx-intermediate", "middle-finger-phalanx-distal", "middle-finger-tip", "ring-finger-metacarpal", "ring-finger-phalanx-proximal", "ring-finger-phalanx-intermediate", "ring-finger-phalanx-distal", "ring-finger-tip", "pinky-finger-metacarpal", "pinky-finger-phalanx-proximal", "pinky-finger-phalanx-intermediate", "pinky-finger-phalanx-distal", "pinky-finger-tip"]
  133293. , cE = ((aE = {}).wrist = ["wrist"],
  133294. aE.thumb = ["thumb-metacarpal", "thumb-phalanx-proximal", "thumb-phalanx-distal", "thumb-tip"],
  133295. aE.index = ["index-finger-metacarpal", "index-finger-phalanx-proximal", "index-finger-phalanx-intermediate", "index-finger-phalanx-distal", "index-finger-tip"],
  133296. aE.middle = ["middle-finger-metacarpal", "middle-finger-phalanx-proximal", "middle-finger-phalanx-intermediate", "middle-finger-phalanx-distal", "middle-finger-tip"],
  133297. aE.ring = ["ring-finger-metacarpal", "ring-finger-phalanx-proximal", "ring-finger-phalanx-intermediate", "ring-finger-phalanx-distal", "ring-finger-tip"],
  133298. aE.little = ["pinky-finger-metacarpal", "pinky-finger-phalanx-proximal", "pinky-finger-phalanx-intermediate", "pinky-finger-phalanx-distal", "pinky-finger-tip"],
  133299. aE)
  133300. , uE = function() {
  133301. function e(e, t, i, n, r, o, a) {
  133302. void 0 === r && (r = !1),
  133303. void 0 === o && (o = !1),
  133304. void 0 === a && (a = 1),
  133305. this.xrController = e,
  133306. this._jointMeshes = t,
  133307. this._handMesh = i,
  133308. this.rigMapping = n,
  133309. this._leftHandedMeshes = r,
  133310. this._jointsInvisible = o,
  133311. this._jointScaleFactor = a,
  133312. this._jointTransforms = new Array(lE.length),
  133313. this._jointTransformMatrices = new Float32Array(16 * lE.length),
  133314. this._tempJointMatrix = new P,
  133315. this._jointRadii = new Float32Array(lE.length),
  133316. this._scene = t[0].getScene();
  133317. for (var s = 0; s < this._jointTransforms.length; s++)
  133318. (this._jointTransforms[s] = new yr(lE[s],this._scene)).rotationQuaternion = new C,
  133319. t[s].rotationQuaternion = new C;
  133320. i && this.setHandMesh(i, n),
  133321. this.xrController.motionController && (this.xrController.motionController.rootMesh ? this.xrController.motionController.rootMesh.setEnabled(!1) : this.xrController.motionController.onModelLoadedObservable.add((function(e) {
  133322. e.rootMesh && e.rootMesh.setEnabled(!1)
  133323. }
  133324. ))),
  133325. this.xrController.onMotionControllerInitObservable.add((function(e) {
  133326. e.onModelLoadedObservable.add((function(e) {
  133327. e.rootMesh && e.rootMesh.setEnabled(!1)
  133328. }
  133329. )),
  133330. e.rootMesh && e.rootMesh.setEnabled(!1)
  133331. }
  133332. ))
  133333. }
  133334. return Object.defineProperty(e.prototype, "handMesh", {
  133335. get: function() {
  133336. return this._handMesh
  133337. },
  133338. enumerable: !1,
  133339. configurable: !0
  133340. }),
  133341. e.prototype.getHandPartMeshes = function(e) {
  133342. var t = this;
  133343. return cE[e].map((function(e) {
  133344. return t._jointMeshes[lE.indexOf(e)]
  133345. }
  133346. ))
  133347. }
  133348. ,
  133349. e.prototype.getJointMesh = function(e) {
  133350. return this._jointMeshes[lE.indexOf(e)]
  133351. }
  133352. ,
  133353. e.prototype.setHandMesh = function(e, t) {
  133354. var i = this;
  133355. if (this._handMesh = e,
  133356. e.alwaysSelectAsActiveMesh = !0,
  133357. e.getChildMeshes().forEach((function(e) {
  133358. return e.alwaysSelectAsActiveMesh = !0
  133359. }
  133360. )),
  133361. this._handMesh.skeleton) {
  133362. var n = this._handMesh.skeleton;
  133363. lE.forEach((function(e, r) {
  133364. var o = n.getBoneIndexByName(t ? t[e] : e);
  133365. -1 !== o && n.bones[o].linkTransformNode(i._jointTransforms[r])
  133366. }
  133367. ))
  133368. }
  133369. }
  133370. ,
  133371. e.prototype.updateFromXRFrame = function(e, t) {
  133372. var i = this
  133373. , n = this.xrController.inputSource.hand;
  133374. if (n) {
  133375. var r = n
  133376. , o = lE.map((function(e) {
  133377. return r[e] || n.get(e)
  133378. }
  133379. ))
  133380. , a = !1;
  133381. if (e.fillPoses && e.fillJointRadii)
  133382. a = e.fillPoses(o, t, this._jointTransformMatrices) && e.fillJointRadii(o, this._jointRadii);
  133383. else if (e.getJointPose) {
  133384. a = !0;
  133385. for (var s = 0; s < o.length; s++) {
  133386. var l = e.getJointPose(o[s], t);
  133387. if (!l) {
  133388. a = !1;
  133389. break
  133390. }
  133391. this._jointTransformMatrices.set(l.transform.matrix, 16 * s),
  133392. this._jointRadii[s] = l.radius || .008
  133393. }
  133394. }
  133395. a && (lE.forEach((function(e, t) {
  133396. var n = i._jointTransforms[t];
  133397. P.FromArrayToRef(i._jointTransformMatrices, 16 * t, i._tempJointMatrix),
  133398. i._tempJointMatrix.decompose(void 0, n.rotationQuaternion, n.position);
  133399. var r = i._jointRadii[t] * i._jointScaleFactor
  133400. , o = i._jointMeshes[t];
  133401. o.isVisible = !i._handMesh && !i._jointsInvisible,
  133402. o.position.copyFrom(n.position),
  133403. o.rotationQuaternion.copyFrom(n.rotationQuaternion),
  133404. o.scaling.setAll(r),
  133405. i._scene.useRightHandedSystem || (o.position.z *= -1,
  133406. o.rotationQuaternion.z *= -1,
  133407. o.rotationQuaternion.w *= -1,
  133408. i._leftHandedMeshes && i._handMesh && (n.position.z *= -1,
  133409. n.rotationQuaternion.z *= -1,
  133410. n.rotationQuaternion.w *= -1))
  133411. }
  133412. )),
  133413. this._handMesh && (this._handMesh.isVisible = !0))
  133414. }
  133415. }
  133416. ,
  133417. e.prototype.dispose = function() {
  133418. this._handMesh && (this._handMesh.isVisible = !1)
  133419. }
  133420. ,
  133421. e
  133422. }()
  133423. , hE = function(e) {
  133424. function t(t, i) {
  133425. var n = e.call(this, t) || this;
  133426. n.options = i,
  133427. n._attachedHands = {},
  133428. n._trackingHands = {
  133429. left: null,
  133430. right: null
  133431. },
  133432. n._handResources = {
  133433. jointMeshes: null,
  133434. handMeshes: null,
  133435. rigMappings: null
  133436. },
  133437. n.onHandAddedObservable = new h,
  133438. n.onHandRemovedObservable = new h,
  133439. n._attachHand = function(e) {
  133440. var t, i, r;
  133441. if (e.inputSource.hand && "none" != e.inputSource.handedness && n._handResources.jointMeshes) {
  133442. var o = e.inputSource.handedness
  133443. , a = new uE(e,n._handResources.jointMeshes[o],n._handResources.handMeshes && n._handResources.handMeshes[o],n._handResources.rigMappings && n._handResources.rigMappings[o],null === (t = n.options.handMeshes) || void 0 === t ? void 0 : t.meshesUseLeftHandedCoordinates,null === (i = n.options.jointMeshes) || void 0 === i ? void 0 : i.invisible,null === (r = n.options.jointMeshes) || void 0 === r ? void 0 : r.scaleFactor);
  133444. n._attachedHands[e.uniqueId] = a,
  133445. n._trackingHands[o] = a,
  133446. n.onHandAddedObservable.notifyObservers(a)
  133447. }
  133448. }
  133449. ,
  133450. n._detachHand = function(e) {
  133451. n._detachHandById(e.uniqueId)
  133452. }
  133453. ,
  133454. n.xrNativeFeatureName = "hand-tracking";
  133455. var r = i.jointMeshes;
  133456. if (r && (void 0 !== r.disableDefaultHandMesh && (i.handMeshes = i.handMeshes || {},
  133457. i.handMeshes.disableDefaultMeshes = r.disableDefaultHandMesh),
  133458. void 0 !== r.handMeshes && (i.handMeshes = i.handMeshes || {},
  133459. i.handMeshes.customMeshes = r.handMeshes),
  133460. void 0 !== r.leftHandedSystemMeshes && (i.handMeshes = i.handMeshes || {},
  133461. i.handMeshes.meshesUseLeftHandedCoordinates = r.leftHandedSystemMeshes),
  133462. void 0 !== r.rigMapping)) {
  133463. i.handMeshes = i.handMeshes || {};
  133464. var o = {}
  133465. , a = {};
  133466. [[r.rigMapping.left, o], [r.rigMapping.right, a]].forEach((function(e) {
  133467. var t = e[0]
  133468. , i = e[1];
  133469. t.forEach((function(e, t) {
  133470. i[lE[t]] = e
  133471. }
  133472. ))
  133473. }
  133474. )),
  133475. i.handMeshes.customRigMappings = {
  133476. left: o,
  133477. right: a
  133478. }
  133479. }
  133480. return n
  133481. }
  133482. return U(t, e),
  133483. t._GenerateTrackedJointMeshes = function(e) {
  133484. var i = {};
  133485. return ["left", "right"].map((function(n) {
  133486. var r, o, a, s, l, c = [], u = (null === (r = e.jointMeshes) || void 0 === r ? void 0 : r.sourceMesh) || Lv("jointParent", t._ICOSPHERE_PARAMS);
  133487. u.isVisible = !!(null === (o = e.jointMeshes) || void 0 === o ? void 0 : o.keepOriginalVisible);
  133488. for (var h = 0; h < lE.length; ++h) {
  133489. var d = u.createInstance("".concat(n, "-handJoint-").concat(h));
  133490. if (null === (a = e.jointMeshes) || void 0 === a ? void 0 : a.onHandJointMeshGenerated) {
  133491. var p = e.jointMeshes.onHandJointMeshGenerated(d, h, n);
  133492. p && p !== d && (d.dispose(),
  133493. d = p)
  133494. }
  133495. if (d.isPickable = !1,
  133496. null === (s = e.jointMeshes) || void 0 === s ? void 0 : s.enablePhysics) {
  133497. var f = (null === (l = e.jointMeshes) || void 0 === l ? void 0 : l.physicsProps) || {};
  133498. d.scaling.setAll(.02);
  133499. var _ = void 0 !== f.impostorType ? f.impostorType : Vl.SphereImpostor;
  133500. d.physicsImpostor = new Vl(d,_,V({
  133501. mass: 0
  133502. }, f))
  133503. }
  133504. d.rotationQuaternion = new C,
  133505. d.isVisible = !1,
  133506. c.push(d)
  133507. }
  133508. i[n] = c
  133509. }
  133510. )),
  133511. {
  133512. left: i.left,
  133513. right: i.right
  133514. }
  133515. }
  133516. ,
  133517. t._GenerateDefaultHandMeshesAsync = function(e, i) {
  133518. var n = this;
  133519. return new Promise((function(r) {
  133520. return G(n, void 0, void 0, (function() {
  133521. var n, o, s, l, c, u, h, d, p, f, _;
  133522. return z(this, (function(m) {
  133523. switch (m.label) {
  133524. case 0:
  133525. return n = {},
  133526. (null === (d = null === (h = t._RightHandGLB) || void 0 === h ? void 0 : h.meshes[1]) || void 0 === d ? void 0 : d.isDisposed()) && (t._RightHandGLB = null),
  133527. (null === (f = null === (p = t._LeftHandGLB) || void 0 === p ? void 0 : p.meshes[1]) || void 0 === f ? void 0 : f.isDisposed()) && (t._LeftHandGLB = null),
  133528. o = !(!t._RightHandGLB || !t._LeftHandGLB),
  133529. [4, Promise.all([t._RightHandGLB || od.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_RIGHT_FILENAME, e), t._LeftHandGLB || od.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_LEFT_FILENAME, e)])];
  133530. case 1:
  133531. return s = m.sent(),
  133532. t._RightHandGLB = s[0],
  133533. t._LeftHandGLB = s[1],
  133534. [4, (l = new Of("handShader",e,{
  133535. emitComments: !1
  133536. })).loadAsync(t.DEFAULT_HAND_MODEL_SHADER_URL)];
  133537. case 2:
  133538. return m.sent(),
  133539. l.needDepthPrePass = !0,
  133540. l.transparencyMode = Or.MATERIAL_ALPHABLEND,
  133541. l.alphaMode = a.ALPHA_COMBINE,
  133542. l.build(!1),
  133543. c = V({
  133544. base: D.FromInts(116, 63, 203),
  133545. fresnel: D.FromInts(149, 102, 229),
  133546. fingerColor: D.FromInts(177, 130, 255),
  133547. tipFresnel: D.FromInts(220, 200, 255)
  133548. }, null === (_ = null == i ? void 0 : i.handMeshes) || void 0 === _ ? void 0 : _.customColors),
  133549. (u = {
  133550. base: l.getBlockByName("baseColor"),
  133551. fresnel: l.getBlockByName("fresnelColor"),
  133552. fingerColor: l.getBlockByName("fingerColor"),
  133553. tipFresnel: l.getBlockByName("tipFresnelColor")
  133554. }).base.value = c.base,
  133555. u.fresnel.value = c.fresnel,
  133556. u.fingerColor.value = c.fingerColor,
  133557. u.tipFresnel.value = c.tipFresnel,
  133558. ["left", "right"].forEach((function(i) {
  133559. var r = "left" == i ? t._LeftHandGLB : t._RightHandGLB;
  133560. if (!r)
  133561. throw new Error("Could not load hand model");
  133562. var a = r.meshes[1];
  133563. a._internalAbstractMeshDataInfo._computeBonesUsingShaders = !0,
  133564. a.material = l.clone("".concat(i, "HandShaderClone"), !0),
  133565. a.isVisible = !1,
  133566. n[i] = a,
  133567. o || e.useRightHandedSystem || r.transformNodes[0].rotate(vn.Y, Math.PI)
  133568. }
  133569. )),
  133570. l.dispose(),
  133571. r({
  133572. left: n.left,
  133573. right: n.right
  133574. }),
  133575. [2]
  133576. }
  133577. }
  133578. ))
  133579. }
  133580. ))
  133581. }
  133582. ))
  133583. }
  133584. ,
  133585. t._GenerateDefaultHandMeshRigMapping = function(e) {
  133586. var t, i = "right" == e ? "R" : "L";
  133587. return (t = {}).wrist = "wrist_".concat(i),
  133588. t["thumb-metacarpal"] = "thumb_metacarpal_".concat(i),
  133589. t["thumb-phalanx-proximal"] = "thumb_proxPhalanx_".concat(i),
  133590. t["thumb-phalanx-distal"] = "thumb_distPhalanx_".concat(i),
  133591. t["thumb-tip"] = "thumb_tip_".concat(i),
  133592. t["index-finger-metacarpal"] = "index_metacarpal_".concat(i),
  133593. t["index-finger-phalanx-proximal"] = "index_proxPhalanx_".concat(i),
  133594. t["index-finger-phalanx-intermediate"] = "index_intPhalanx_".concat(i),
  133595. t["index-finger-phalanx-distal"] = "index_distPhalanx_".concat(i),
  133596. t["index-finger-tip"] = "index_tip_".concat(i),
  133597. t["middle-finger-metacarpal"] = "middle_metacarpal_".concat(i),
  133598. t["middle-finger-phalanx-proximal"] = "middle_proxPhalanx_".concat(i),
  133599. t["middle-finger-phalanx-intermediate"] = "middle_intPhalanx_".concat(i),
  133600. t["middle-finger-phalanx-distal"] = "middle_distPhalanx_".concat(i),
  133601. t["middle-finger-tip"] = "middle_tip_".concat(i),
  133602. t["ring-finger-metacarpal"] = "ring_metacarpal_".concat(i),
  133603. t["ring-finger-phalanx-proximal"] = "ring_proxPhalanx_".concat(i),
  133604. t["ring-finger-phalanx-intermediate"] = "ring_intPhalanx_".concat(i),
  133605. t["ring-finger-phalanx-distal"] = "ring_distPhalanx_".concat(i),
  133606. t["ring-finger-tip"] = "ring_tip_".concat(i),
  133607. t["pinky-finger-metacarpal"] = "little_metacarpal_".concat(i),
  133608. t["pinky-finger-phalanx-proximal"] = "little_proxPhalanx_".concat(i),
  133609. t["pinky-finger-phalanx-intermediate"] = "little_intPhalanx_".concat(i),
  133610. t["pinky-finger-phalanx-distal"] = "little_distPhalanx_".concat(i),
  133611. t["pinky-finger-tip"] = "little_tip_".concat(i),
  133612. t
  133613. }
  133614. ,
  133615. t.prototype.isCompatible = function() {
  133616. return "undefined" != typeof XRHand
  133617. }
  133618. ,
  133619. t.prototype.getHandByControllerId = function(e) {
  133620. return this._attachedHands[e]
  133621. }
  133622. ,
  133623. t.prototype.getHandByHandedness = function(e) {
  133624. return "none" == e ? null : this._trackingHands[e]
  133625. }
  133626. ,
  133627. t.prototype.attach = function() {
  133628. var i, n, r, o, a = this;
  133629. return !!e.prototype.attach.call(this) && (this._handResources = {
  133630. jointMeshes: t._GenerateTrackedJointMeshes(this.options),
  133631. handMeshes: (null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) || null,
  133632. rigMappings: (null === (n = this.options.handMeshes) || void 0 === n ? void 0 : n.customRigMappings) || null
  133633. },
  133634. (null === (r = this.options.handMeshes) || void 0 === r ? void 0 : r.customMeshes) || (null === (o = this.options.handMeshes) || void 0 === o ? void 0 : o.disableDefaultMeshes) || t._GenerateDefaultHandMeshesAsync(E.LastCreatedScene, this.options).then((function(e) {
  133635. var i, n;
  133636. a._handResources.handMeshes = e,
  133637. a._handResources.rigMappings = {
  133638. left: t._GenerateDefaultHandMeshRigMapping("left"),
  133639. right: t._GenerateDefaultHandMeshRigMapping("right")
  133640. },
  133641. null === (i = a._trackingHands.left) || void 0 === i || i.setHandMesh(a._handResources.handMeshes.left, a._handResources.rigMappings.left),
  133642. null === (n = a._trackingHands.right) || void 0 === n || n.setHandMesh(a._handResources.handMeshes.right, a._handResources.rigMappings.right)
  133643. }
  133644. )),
  133645. this.options.xrInput.controllers.forEach(this._attachHand),
  133646. this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand),
  133647. this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand),
  133648. !0)
  133649. }
  133650. ,
  133651. t.prototype._onXRFrame = function(e) {
  133652. var t, i;
  133653. null === (t = this._trackingHands.left) || void 0 === t || t.updateFromXRFrame(e, this._xrSessionManager.referenceSpace),
  133654. null === (i = this._trackingHands.right) || void 0 === i || i.updateFromXRFrame(e, this._xrSessionManager.referenceSpace)
  133655. }
  133656. ,
  133657. t.prototype._detachHandById = function(e) {
  133658. var t, i = this.getHandByControllerId(e);
  133659. if (i) {
  133660. var n = "left" == i.xrController.inputSource.handedness ? "left" : "right";
  133661. (null === (t = this._trackingHands[n]) || void 0 === t ? void 0 : t.xrController.uniqueId) === e && (this._trackingHands[n] = null),
  133662. this.onHandRemovedObservable.notifyObservers(i),
  133663. i.dispose(),
  133664. delete this._attachedHands[e]
  133665. }
  133666. }
  133667. ,
  133668. t.prototype.detach = function() {
  133669. var t = this;
  133670. return !!e.prototype.detach.call(this) && (Object.keys(this._attachedHands).forEach((function(e) {
  133671. return t._detachHandById(e)
  133672. }
  133673. )),
  133674. !0)
  133675. }
  133676. ,
  133677. t.prototype.dispose = function() {
  133678. var i;
  133679. e.prototype.dispose.call(this),
  133680. this.onHandAddedObservable.clear(),
  133681. this.onHandRemovedObservable.clear(),
  133682. this._handResources.handMeshes && !(null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) && (this._handResources.handMeshes.left.dispose(),
  133683. this._handResources.handMeshes.right.dispose(),
  133684. t._RightHandGLB = null,
  133685. t._LeftHandGLB = null),
  133686. this._handResources.jointMeshes && (this._handResources.jointMeshes.left.forEach((function(e) {
  133687. return e.dispose()
  133688. }
  133689. )),
  133690. this._handResources.jointMeshes.right.forEach((function(e) {
  133691. return e.dispose()
  133692. }
  133693. )))
  133694. }
  133695. ,
  133696. t.Name = Io.HAND_TRACKING,
  133697. t.Version = 1,
  133698. t.DEFAULT_HAND_MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/HandMeshes/",
  133699. t.DEFAULT_HAND_MODEL_RIGHT_FILENAME = "r_hand_rhs.glb",
  133700. t.DEFAULT_HAND_MODEL_LEFT_FILENAME = "l_hand_rhs.glb",
  133701. t.DEFAULT_HAND_MODEL_SHADER_URL = "https://assets.babylonjs.com/meshes/HandMeshes/handsShader.json",
  133702. t._ICOSPHERE_PARAMS = {
  133703. radius: .5,
  133704. flat: !1,
  133705. subdivisions: 2
  133706. },
  133707. t._RightHandGLB = null,
  133708. t._LeftHandGLB = null,
  133709. t
  133710. }(wp);
  133711. Oo.AddWebXRFeature(hE.Name, (function(e, t) {
  133712. return function() {
  133713. return new hE(e,t)
  133714. }
  133715. }
  133716. ), hE.Version, !1);
  133717. var dE = 0
  133718. , pE = function(e) {
  133719. function t(t, i) {
  133720. void 0 === i && (i = {});
  133721. var n = e.call(this, t) || this;
  133722. return n._options = i,
  133723. n._detectedMeshes = new Map,
  133724. n.onMeshAddedObservable = new h,
  133725. n.onMeshRemovedObservable = new h,
  133726. n.onMeshUpdatedObservable = new h,
  133727. n.xrNativeFeatureName = "mesh-detection",
  133728. n._xrSessionManager.session ? n._init() : n._xrSessionManager.onXRSessionInit.addOnce((function() {
  133729. n._init()
  133730. }
  133731. )),
  133732. n
  133733. }
  133734. return U(t, e),
  133735. t.prototype.detach = function() {
  133736. var t = this;
  133737. return !!e.prototype.detach.call(this) && (this._xrSessionManager.isNative && this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!1),
  133738. this._options.doNotRemoveMeshesOnSessionEnded || (this._detectedMeshes.forEach((function(e) {
  133739. t.onMeshRemovedObservable.notifyObservers(e)
  133740. }
  133741. )),
  133742. this._detectedMeshes.clear()),
  133743. !0)
  133744. }
  133745. ,
  133746. t.prototype.dispose = function() {
  133747. e.prototype.dispose.call(this),
  133748. this.onMeshAddedObservable.clear(),
  133749. this.onMeshRemovedObservable.clear(),
  133750. this.onMeshUpdatedObservable.clear()
  133751. }
  133752. ,
  133753. t.prototype._onXRFrame = function(e) {
  133754. var t, i = this;
  133755. try {
  133756. if (!this.attached || !e)
  133757. return;
  133758. var n = null === (t = e.worldInformation) || void 0 === t ? void 0 : t.detectedMeshes;
  133759. if (n) {
  133760. var r = new Set;
  133761. this._detectedMeshes.forEach((function(e, t) {
  133762. n.has(t) || r.add(t)
  133763. }
  133764. )),
  133765. r.forEach((function(e) {
  133766. var t = i._detectedMeshes.get(e);
  133767. t && (i.onMeshRemovedObservable.notifyObservers(t),
  133768. i._detectedMeshes.delete(e))
  133769. }
  133770. )),
  133771. n.forEach((function(t) {
  133772. if (i._detectedMeshes.has(t))
  133773. t.lastChangedTime === i._xrSessionManager.currentTimestamp && (r = i._detectedMeshes.get(t)) && (i._updateVertexDataWithXRMesh(t, r, e),
  133774. i.onMeshUpdatedObservable.notifyObservers(r));
  133775. else {
  133776. var n = {
  133777. id: dE++,
  133778. xrMesh: t
  133779. }
  133780. , r = i._updateVertexDataWithXRMesh(t, n, e);
  133781. i._detectedMeshes.set(t, r),
  133782. i.onMeshAddedObservable.notifyObservers(r)
  133783. }
  133784. }
  133785. ))
  133786. }
  133787. } catch (e) {
  133788. console.log(e.stack)
  133789. }
  133790. }
  133791. ,
  133792. t.prototype._init = function() {
  133793. this._xrSessionManager.isNative && (this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!0),
  133794. this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions(this._options.preferredDetectorOptions))
  133795. }
  133796. ,
  133797. t.prototype._updateVertexDataWithXRMesh = function(e, t, i) {
  133798. if (t.xrMesh = e,
  133799. t.worldParentNode = this._options.worldParentNode,
  133800. this._options.convertCoordinateSystems) {
  133801. if (this._xrSessionManager.scene.useRightHandedSystem)
  133802. t.positions = e.positions,
  133803. t.normals = e.normals;
  133804. else {
  133805. t.positions = new Float32Array(e.positions.length);
  133806. for (var n = 0; n < e.positions.length; n += 3)
  133807. t.positions[n] = e.positions[n],
  133808. t.positions[n + 1] = e.positions[n + 1],
  133809. t.positions[n + 2] = -1 * e.positions[n + 2];
  133810. if (e.normals)
  133811. for (t.normals = new Float32Array(e.normals.length),
  133812. n = 0; n < e.normals.length; n += 3)
  133813. t.normals[n] = e.normals[n],
  133814. t.normals[n + 1] = e.normals[n + 1],
  133815. t.normals[n + 2] = -1 * e.normals[n + 2]
  133816. }
  133817. t.indices = e.indices;
  133818. var r = i.getPose(e.meshSpace, this._xrSessionManager.referenceSpace);
  133819. if (r) {
  133820. var o = t.transformationMatrix || new P;
  133821. P.FromArrayToRef(r.transform.matrix, 0, o),
  133822. this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(),
  133823. t.transformationMatrix = o,
  133824. this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o)
  133825. }
  133826. }
  133827. return t
  133828. }
  133829. ,
  133830. t.Name = Io.MESH_DETECTION,
  133831. t.Version = 1,
  133832. t
  133833. }(wp);
  133834. Oo.AddWebXRFeature(pE.Name, (function(e, t) {
  133835. return function() {
  133836. return new pE(e,t)
  133837. }
  133838. }
  133839. ), pE.Version, !1);
  133840. var fE = function(e) {
  133841. function t(t, i) {
  133842. var n = e.call(this, t) || this;
  133843. return n.options = i,
  133844. n.onUntrackableImageFoundObservable = new h,
  133845. n.onTrackableImageFoundObservable = new h,
  133846. n.onTrackedImageUpdatedObservable = new h,
  133847. n._trackableScoresReceived = !1,
  133848. n._trackedImages = [],
  133849. n.xrNativeFeatureName = "image-tracking",
  133850. n
  133851. }
  133852. return U(t, e),
  133853. t.prototype.attach = function() {
  133854. return e.prototype.attach.call(this)
  133855. }
  133856. ,
  133857. t.prototype.detach = function() {
  133858. return e.prototype.detach.call(this)
  133859. }
  133860. ,
  133861. t.prototype.isCompatible = function() {
  133862. return "undefined" != typeof XRImageTrackingResult
  133863. }
  133864. ,
  133865. t.prototype.getTrackedImageById = function(e) {
  133866. return this._trackedImages[e] || null
  133867. }
  133868. ,
  133869. t.prototype.dispose = function() {
  133870. e.prototype.dispose.call(this),
  133871. this._trackedImages.forEach((function(e) {
  133872. e.originalBitmap.close()
  133873. }
  133874. )),
  133875. this._trackedImages.length = 0,
  133876. this.onTrackableImageFoundObservable.clear(),
  133877. this.onUntrackableImageFoundObservable.clear(),
  133878. this.onTrackedImageUpdatedObservable.clear()
  133879. }
  133880. ,
  133881. t.prototype.getXRSessionInitExtension = function() {
  133882. return G(this, void 0, void 0, (function() {
  133883. var e, t, i = this;
  133884. return z(this, (function(n) {
  133885. switch (n.label) {
  133886. case 0:
  133887. if (!this.options.images || !this.options.images.length)
  133888. return [2, {}];
  133889. e = this.options.images.map((function(e) {
  133890. return "string" == typeof e.src ? i._xrSessionManager.scene.getEngine().createImageBitmapFromSource(e.src) : Promise.resolve(e.src)
  133891. }
  133892. )),
  133893. n.label = 1;
  133894. case 1:
  133895. return n.trys.push([1, 3, , 4]),
  133896. [4, Promise.all(e)];
  133897. case 2:
  133898. return t = n.sent(),
  133899. this._originalTrackingRequest = t.map((function(e, t) {
  133900. return {
  133901. image: e,
  133902. widthInMeters: i.options.images[t].estimatedRealWorldWidth
  133903. }
  133904. }
  133905. )),
  133906. [2, {
  133907. trackedImages: this._originalTrackingRequest
  133908. }];
  133909. case 3:
  133910. return n.sent(),
  133911. gi.Error("Error loading images for tracking, WebXRImageTracking disabled for this session."),
  133912. [2, {}];
  133913. case 4:
  133914. return [2]
  133915. }
  133916. }
  133917. ))
  133918. }
  133919. ))
  133920. }
  133921. ,
  133922. t.prototype._onXRFrame = function(e) {
  133923. if (e.getImageTrackingResults && (this._trackableScoresReceived || (this._checkScores(),
  133924. this._trackableScoresReceived)))
  133925. for (var t = 0, i = e.getImageTrackingResults(); t < i.length; t++) {
  133926. var n = i[t]
  133927. , r = !1
  133928. , o = n.index
  133929. , a = this._trackedImages[o];
  133930. if (a) {
  133931. a.xrTrackingResult = n,
  133932. a.realWorldWidth !== n.measuredWidthInMeters && (a.realWorldWidth = n.measuredWidthInMeters,
  133933. r = !0);
  133934. var s = e.getPose(n.imageSpace, this._xrSessionManager.referenceSpace);
  133935. if (s) {
  133936. var l = a.transformationMatrix;
  133937. P.FromArrayToRef(s.transform.matrix, 0, l),
  133938. this._xrSessionManager.scene.useRightHandedSystem || l.toggleModelMatrixHandInPlace(),
  133939. r = !0
  133940. }
  133941. var c = "emulated" === n.trackingState;
  133942. a.emulated !== c && (a.emulated = c,
  133943. r = !0),
  133944. r && this.onTrackedImageUpdatedObservable.notifyObservers(a)
  133945. }
  133946. }
  133947. }
  133948. ,
  133949. t.prototype._checkScores = function() {
  133950. if (this._xrSessionManager.session.getTrackedImageScores && !this._trackableScoresReceived) {
  133951. for (var e = this._xrSessionManager.session.getTrackedImageScores(), t = 0; t < e.length; ++t)
  133952. if ("untrackable" == e[t])
  133953. this.onUntrackableImageFoundObservable.notifyObservers(t);
  133954. else {
  133955. var i = this._originalTrackingRequest[t].image
  133956. , n = {
  133957. id: t,
  133958. originalBitmap: i,
  133959. transformationMatrix: new P,
  133960. ratio: i.width / i.height
  133961. };
  133962. this._trackedImages[t] = n,
  133963. this.onTrackableImageFoundObservable.notifyObservers(n)
  133964. }
  133965. this._trackableScoresReceived || (this._trackableScoresReceived = e.length > 0)
  133966. }
  133967. }
  133968. ,
  133969. t.Name = Io.IMAGE_TRACKING,
  133970. t.Version = 1,
  133971. t
  133972. }(wp);
  133973. Oo.AddWebXRFeature(fE.Name, (function(e, t) {
  133974. return function() {
  133975. return new fE(e,t)
  133976. }
  133977. }
  133978. ), fE.Version, !1);
  133979. var _E = function(e) {
  133980. function t(t, i) {
  133981. var n = e.call(this, t) || this;
  133982. return n.options = i,
  133983. n._domOverlayType = null,
  133984. n._beforeXRSelectListener = null,
  133985. n._element = null,
  133986. n.xrNativeFeatureName = "dom-overlay",
  133987. gi.Warn("dom-overlay is an experimental and unstable feature."),
  133988. n
  133989. }
  133990. return U(t, e),
  133991. t.prototype.attach = function() {
  133992. return !(!e.prototype.attach.call(this) || !this._xrSessionManager.session.domOverlayState || null === this._xrSessionManager.session.domOverlayState.type || (this._domOverlayType = this._xrSessionManager.session.domOverlayState.type,
  133993. null !== this._element && !0 === this.options.supressXRSelectEvents && (this._beforeXRSelectListener = function(e) {
  133994. e.preventDefault()
  133995. }
  133996. ,
  133997. this._element.addEventListener("beforexrselect", this._beforeXRSelectListener)),
  133998. 0))
  133999. }
  134000. ,
  134001. Object.defineProperty(t.prototype, "domOverlayType", {
  134002. get: function() {
  134003. return this._domOverlayType
  134004. },
  134005. enumerable: !1,
  134006. configurable: !0
  134007. }),
  134008. t.prototype.dispose = function() {
  134009. e.prototype.dispose.call(this),
  134010. null !== this._element && this._beforeXRSelectListener && this._element.removeEventListener("beforexrselect", this._beforeXRSelectListener)
  134011. }
  134012. ,
  134013. t.prototype._onXRFrame = function(e) {}
  134014. ,
  134015. t.prototype.getXRSessionInitExtension = function() {
  134016. return G(this, void 0, void 0, (function() {
  134017. var e;
  134018. return z(this, (function(t) {
  134019. if (void 0 === this.options.element)
  134020. return gi.Warn('"element" option must be provided to attach xr-dom-overlay feature.'),
  134021. [2, {}];
  134022. if ("string" == typeof this.options.element) {
  134023. if (null === (e = document.querySelector(this.options.element)))
  134024. return gi.Warn("element not found '".concat(this.options.element, "' (not requesting xr-dom-overlay)")),
  134025. [2, {}];
  134026. this._element = e
  134027. } else
  134028. this._element = this.options.element;
  134029. return [2, {
  134030. domOverlay: {
  134031. root: this._element
  134032. }
  134033. }]
  134034. }
  134035. ))
  134036. }
  134037. ))
  134038. }
  134039. ,
  134040. t.Name = Io.DOM_OVERLAY,
  134041. t.Version = 1,
  134042. t
  134043. }(wp);
  134044. Oo.AddWebXRFeature(_E.Name, (function(e, t) {
  134045. return function() {
  134046. return new _E(e,t)
  134047. }
  134048. }
  134049. ), _E.Version, !1);
  134050. var mE = function(e) {
  134051. function t(i, n) {
  134052. var r, o, a, s, l, c, u = this;
  134053. return (u = e.call(this, i) || this)._controllers = {},
  134054. u._currentRegistrationConfigurations = [],
  134055. u._movementDirection = null,
  134056. u._tmpRotationMatrix = P.Identity(),
  134057. u._tmpTranslationDirection = new x,
  134058. u._tmpMovementTranslation = new x,
  134059. u._attachController = function(e) {
  134060. if (!u._controllers[e.uniqueId]) {
  134061. u._controllers[e.uniqueId] = {
  134062. xrController: e,
  134063. registeredComponents: []
  134064. };
  134065. var t = u._controllers[e.uniqueId];
  134066. if ("tracked-pointer" === t.xrController.inputSource.targetRayMode && t.xrController.inputSource.gamepad) {
  134067. var i = function() {
  134068. if (e.motionController)
  134069. for (var i = function(i) {
  134070. var n = null;
  134071. if (i.allowedComponentTypes)
  134072. for (var r = 0, o = i.allowedComponentTypes; r < o.length; r++) {
  134073. var a = o[r]
  134074. , s = e.motionController.getComponentOfType(a);
  134075. if (null !== s) {
  134076. n = s;
  134077. break
  134078. }
  134079. }
  134080. if (i.mainComponentOnly) {
  134081. var l = e.motionController.getMainComponent();
  134082. if (null === l)
  134083. return "continue";
  134084. n = l
  134085. }
  134086. if ("function" == typeof i.componentSelectionPredicate && (n = i.componentSelectionPredicate(e)),
  134087. n && i.forceHandedness && e.inputSource.handedness !== i.forceHandedness)
  134088. return "continue";
  134089. if (null === n)
  134090. return "continue";
  134091. var c = {
  134092. registrationConfiguration: i,
  134093. component: n
  134094. };
  134095. t.registeredComponents.push(c),
  134096. "axisChangedHandler"in i && (c.onAxisChangedObserver = n.onAxisValueChangedObservable.add((function(e) {
  134097. i.axisChangedHandler(e, u._movementState, u._featureContext, u._xrInput)
  134098. }
  134099. ))),
  134100. "buttonChangedhandler"in i && (c.onButtonChangedObserver = n.onButtonStateChangedObservable.add((function() {
  134101. n.changes.pressed && i.buttonChangedhandler(n.changes.pressed, u._movementState, u._featureContext, u._xrInput)
  134102. }
  134103. )))
  134104. }, n = 0, r = u._currentRegistrationConfigurations; n < r.length; n++)
  134105. i(r[n])
  134106. };
  134107. e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function() {
  134108. i()
  134109. }
  134110. ))
  134111. }
  134112. }
  134113. }
  134114. ,
  134115. n && void 0 !== n.xrInput ? (Array.isArray(n.customRegistrationConfigurations) ? u._currentRegistrationConfigurations = n.customRegistrationConfigurations : u._currentRegistrationConfigurations = t.REGISTRATIONS.default,
  134116. u._featureContext = {
  134117. movementEnabled: n.movementEnabled || !0,
  134118. movementOrientationFollowsViewerPose: null === (r = n.movementOrientationFollowsViewerPose) || void 0 === r || r,
  134119. movementSpeed: null !== (o = n.movementSpeed) && void 0 !== o ? o : 1,
  134120. movementThreshold: null !== (a = n.movementThreshold) && void 0 !== a ? a : .25,
  134121. rotationEnabled: null === (s = n.rotationEnabled) || void 0 === s || s,
  134122. rotationSpeed: null !== (l = n.rotationSpeed) && void 0 !== l ? l : 1,
  134123. rotationThreshold: null !== (c = n.rotationThreshold) && void 0 !== c ? c : .25
  134124. },
  134125. u._movementState = {
  134126. moveX: 0,
  134127. moveY: 0,
  134128. rotateX: 0,
  134129. rotateY: 0
  134130. },
  134131. u._xrInput = n.xrInput,
  134132. u) : (gi.Error('WebXRControllerMovement feature requires "xrInput" option.'),
  134133. u)
  134134. }
  134135. return U(t, e),
  134136. Object.defineProperty(t.prototype, "movementDirection", {
  134137. get: function() {
  134138. return this._movementDirection
  134139. },
  134140. enumerable: !1,
  134141. configurable: !0
  134142. }),
  134143. Object.defineProperty(t.prototype, "movementEnabled", {
  134144. get: function() {
  134145. return this._featureContext.movementEnabled
  134146. },
  134147. set: function(e) {
  134148. this._featureContext.movementEnabled = e
  134149. },
  134150. enumerable: !1,
  134151. configurable: !0
  134152. }),
  134153. Object.defineProperty(t.prototype, "movementOrientationFollowsViewerPose", {
  134154. get: function() {
  134155. return this._featureContext.movementOrientationFollowsViewerPose
  134156. },
  134157. set: function(e) {
  134158. this._featureContext.movementOrientationFollowsViewerPose = e
  134159. },
  134160. enumerable: !1,
  134161. configurable: !0
  134162. }),
  134163. Object.defineProperty(t.prototype, "movementSpeed", {
  134164. get: function() {
  134165. return this._featureContext.movementSpeed
  134166. },
  134167. set: function(e) {
  134168. this._featureContext.movementSpeed = e
  134169. },
  134170. enumerable: !1,
  134171. configurable: !0
  134172. }),
  134173. Object.defineProperty(t.prototype, "movementThreshold", {
  134174. get: function() {
  134175. return this._featureContext.movementThreshold
  134176. },
  134177. set: function(e) {
  134178. this._featureContext.movementThreshold = e
  134179. },
  134180. enumerable: !1,
  134181. configurable: !0
  134182. }),
  134183. Object.defineProperty(t.prototype, "rotationEnabled", {
  134184. get: function() {
  134185. return this._featureContext.rotationEnabled
  134186. },
  134187. set: function(e) {
  134188. this._featureContext.rotationEnabled = e
  134189. },
  134190. enumerable: !1,
  134191. configurable: !0
  134192. }),
  134193. Object.defineProperty(t.prototype, "rotationSpeed", {
  134194. get: function() {
  134195. return this._featureContext.rotationSpeed
  134196. },
  134197. set: function(e) {
  134198. this._featureContext.rotationSpeed = e
  134199. },
  134200. enumerable: !1,
  134201. configurable: !0
  134202. }),
  134203. Object.defineProperty(t.prototype, "rotationThreshold", {
  134204. get: function() {
  134205. return this._featureContext.rotationThreshold
  134206. },
  134207. set: function(e) {
  134208. this._featureContext.rotationThreshold = e
  134209. },
  134210. enumerable: !1,
  134211. configurable: !0
  134212. }),
  134213. t.prototype.attach = function() {
  134214. var t = this;
  134215. return !!e.prototype.attach.call(this) && (this._xrInput.controllers.forEach(this._attachController),
  134216. this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController),
  134217. this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable, (function(e) {
  134218. t._detachController(e.uniqueId)
  134219. }
  134220. )),
  134221. !0)
  134222. }
  134223. ,
  134224. t.prototype.detach = function() {
  134225. var t = this;
  134226. return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
  134227. t._detachController(e)
  134228. }
  134229. )),
  134230. this._controllers = {},
  134231. !0)
  134232. }
  134233. ,
  134234. t.prototype._onXRFrame = function(e) {
  134235. if (this.attach) {
  134236. if (null === this._movementDirection && (this._movementDirection = this._xrInput.xrCamera.rotationQuaternion.clone()),
  134237. 0 !== this._movementState.rotateX && this._featureContext.rotationEnabled) {
  134238. var t = .001 * this._xrSessionManager.scene.getEngine().getDeltaTime() * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
  134239. !0 === this._featureContext.movementOrientationFollowsViewerPose ? (this._xrInput.xrCamera.cameraRotation.y += t,
  134240. this._movementDirection = this._xrInput.xrCamera.rotationQuaternion.multiply(C.RotationYawPitchRoll(t, 0, 0))) : this._movementDirection.multiplyInPlace(C.RotationYawPitchRoll(3 * t, 0, 0))
  134241. } else
  134242. !0 === this._featureContext.movementOrientationFollowsViewerPose && this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);
  134243. 0 === this._movementState.moveX && 0 === this._movementState.moveY || !this._featureContext.movementEnabled || (P.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix),
  134244. this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
  134245. x.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation),
  134246. this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed),
  134247. this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation))
  134248. }
  134249. }
  134250. ,
  134251. t.prototype._detachController = function(e) {
  134252. var t = this._controllers[e];
  134253. if (t) {
  134254. for (var i = 0, n = t.registeredComponents; i < n.length; i++) {
  134255. var r = n[i];
  134256. r.onAxisChangedObserver && r.component.onAxisValueChangedObservable.remove(r.onAxisChangedObserver),
  134257. r.onButtonChangedObserver && r.component.onButtonStateChangedObservable.remove(r.onButtonChangedObserver)
  134258. }
  134259. delete this._controllers[e]
  134260. }
  134261. }
  134262. ,
  134263. t.Name = Io.MOVEMENT,
  134264. t.REGISTRATIONS = {
  134265. default: [{
  134266. allowedComponentTypes: [Ap.THUMBSTICK_TYPE, Ap.TOUCHPAD_TYPE],
  134267. forceHandedness: "left",
  134268. axisChangedHandler: function(e, t, i) {
  134269. t.rotateX = Math.abs(e.x) > i.rotationThreshold ? e.x : 0,
  134270. t.rotateY = Math.abs(e.y) > i.rotationThreshold ? e.y : 0
  134271. }
  134272. }, {
  134273. allowedComponentTypes: [Ap.THUMBSTICK_TYPE, Ap.TOUCHPAD_TYPE],
  134274. forceHandedness: "right",
  134275. axisChangedHandler: function(e, t, i) {
  134276. t.moveX = Math.abs(e.x) > i.movementThreshold ? e.x : 0,
  134277. t.moveY = Math.abs(e.y) > i.movementThreshold ? e.y : 0
  134278. }
  134279. }]
  134280. },
  134281. t.Version = 1,
  134282. t
  134283. }(wp);
  134284. Oo.AddWebXRFeature(mE.Name, (function(e, t) {
  134285. return function() {
  134286. return new mE(e,t)
  134287. }
  134288. }
  134289. ), mE.Version, !0);
  134290. var gE = function(e) {
  134291. function t(t, i) {
  134292. var n = e.call(this, t) || this;
  134293. return n.options = i,
  134294. n._canvasContext = null,
  134295. n._reflectionCubeMap = null,
  134296. n._xrLightEstimate = null,
  134297. n._xrLightProbe = null,
  134298. n._xrWebGLBinding = null,
  134299. n._lightDirection = x.Up().negateInPlace(),
  134300. n._lightColor = D.White(),
  134301. n._intensity = 1,
  134302. n._sphericalHarmonics = new Cc,
  134303. n._cubeMapPollTime = Date.now(),
  134304. n._lightEstimationPollTime = Date.now(),
  134305. n._reflectionCubeMapTextureSize = 16,
  134306. n.directionalLight = null,
  134307. n.onReflectionCubeMapUpdatedObservable = new h,
  134308. n._updateReflectionCubeMap = function() {
  134309. var e;
  134310. if (n._xrLightProbe) {
  134311. if (n.options.cubeMapPollInterval) {
  134312. var t = Date.now();
  134313. if (t - n._cubeMapPollTime < n.options.cubeMapPollInterval)
  134314. return;
  134315. n._cubeMapPollTime = t
  134316. }
  134317. var i = n._getXRGLBinding().getReflectionCubeMap(n._xrLightProbe);
  134318. if (i && n._reflectionCubeMap) {
  134319. if (n._reflectionCubeMap._texture)
  134320. null === (e = n._reflectionCubeMap._texture._hardwareTexture) || void 0 === e || e.set(i),
  134321. n._reflectionCubeMap._texture.getEngine().resetTextureCache();
  134322. else {
  134323. var r = new Lt(n._xrSessionManager.scene.getEngine(),At.Unknown);
  134324. r.isCube = !0,
  134325. r.invertY = !1,
  134326. r._useSRGBBuffer = "srgba8" === n.options.reflectionFormat,
  134327. r.format = a.TEXTUREFORMAT_RGBA,
  134328. r.generateMipMaps = !0,
  134329. r.type = "srgba8" !== n.options.reflectionFormat ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE,
  134330. r.samplingMode = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
  134331. r.width = n._reflectionCubeMapTextureSize,
  134332. r.height = n._reflectionCubeMapTextureSize,
  134333. r._cachedWrapU = a.TEXTURE_WRAP_ADDRESSMODE,
  134334. r._cachedWrapV = a.TEXTURE_WRAP_ADDRESSMODE,
  134335. r._hardwareTexture = new kt(i,n._getCanvasContext()),
  134336. n._reflectionCubeMap._texture = r
  134337. }
  134338. n._reflectionCubeMap._texture.isReady = !0,
  134339. n._xrSessionManager.scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag),
  134340. n.onReflectionCubeMapUpdatedObservable.notifyObservers(n._reflectionCubeMap)
  134341. }
  134342. }
  134343. }
  134344. ,
  134345. n.xrNativeFeatureName = "light-estimation",
  134346. n.options.createDirectionalLightSource && (n.directionalLight = new Rd("light estimation directional",n._lightDirection,n._xrSessionManager.scene),
  134347. n.directionalLight.position = new x(0,8,0),
  134348. n.directionalLight.intensity = 0,
  134349. n.directionalLight.falloffType = fn.FALLOFF_GLTF),
  134350. gi.Warn("light-estimation is an experimental and unstable feature."),
  134351. n
  134352. }
  134353. return U(t, e),
  134354. Object.defineProperty(t.prototype, "reflectionCubeMapTexture", {
  134355. get: function() {
  134356. return this._reflectionCubeMap
  134357. },
  134358. enumerable: !1,
  134359. configurable: !0
  134360. }),
  134361. Object.defineProperty(t.prototype, "xrLightingEstimate", {
  134362. get: function() {
  134363. return this._xrLightEstimate ? {
  134364. lightColor: this._lightColor,
  134365. lightDirection: this._lightDirection,
  134366. lightIntensity: this._intensity,
  134367. sphericalHarmonics: this._sphericalHarmonics
  134368. } : this._xrLightEstimate
  134369. },
  134370. enumerable: !1,
  134371. configurable: !0
  134372. }),
  134373. t.prototype._getCanvasContext = function() {
  134374. return null === this._canvasContext && (this._canvasContext = this._xrSessionManager.scene.getEngine()._gl),
  134375. this._canvasContext
  134376. }
  134377. ,
  134378. t.prototype._getXRGLBinding = function() {
  134379. if (null === this._xrWebGLBinding) {
  134380. var e = this._getCanvasContext();
  134381. this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session,e)
  134382. }
  134383. return this._xrWebGLBinding
  134384. }
  134385. ,
  134386. t.prototype.attach = function() {
  134387. var t, i = this;
  134388. if (!e.prototype.attach.call(this))
  134389. return !1;
  134390. var n = null !== (t = this.options.reflectionFormat) && void 0 !== t ? t : this._xrSessionManager.session.preferredReflectionFormat || "srgba8";
  134391. return this.options.reflectionFormat = n,
  134392. this._xrSessionManager.session.requestLightProbe({
  134393. reflectionFormat: n
  134394. }).then((function(e) {
  134395. i._xrLightProbe = e,
  134396. i.options.disableCubeMapReflection || (i._reflectionCubeMap || (i._reflectionCubeMap = new Zr(i._xrSessionManager.scene),
  134397. i._reflectionCubeMap.isCube = !0,
  134398. i._reflectionCubeMap.coordinatesMode = a.TEXTURE_CUBIC_MODE,
  134399. i.options.setSceneEnvironmentTexture && (i._xrSessionManager.scene.environmentTexture = i._reflectionCubeMap)),
  134400. i._xrLightProbe.addEventListener("reflectionchange", i._updateReflectionCubeMap))
  134401. }
  134402. )),
  134403. !0
  134404. }
  134405. ,
  134406. t.prototype.detach = function() {
  134407. var t = e.prototype.detach.call(this);
  134408. return null === this._xrLightProbe || this.options.disableCubeMapReflection || (this._xrLightProbe.removeEventListener("reflectionchange", this._updateReflectionCubeMap),
  134409. this._xrLightProbe = null),
  134410. this._canvasContext = null,
  134411. this._xrLightEstimate = null,
  134412. this._xrWebGLBinding = null,
  134413. t
  134414. }
  134415. ,
  134416. t.prototype.dispose = function() {
  134417. e.prototype.dispose.call(this),
  134418. this.onReflectionCubeMapUpdatedObservable.clear(),
  134419. this.directionalLight && (this.directionalLight.dispose(),
  134420. this.directionalLight = null),
  134421. null !== this._reflectionCubeMap && (this._reflectionCubeMap._texture && this._reflectionCubeMap._texture.dispose(),
  134422. this._reflectionCubeMap.dispose(),
  134423. this._reflectionCubeMap = null)
  134424. }
  134425. ,
  134426. t.prototype._onXRFrame = function(e) {
  134427. var t;
  134428. if (null !== this._xrLightProbe) {
  134429. if (this.options.lightEstimationPollInterval) {
  134430. var i = Date.now();
  134431. if (i - this._lightEstimationPollTime < this.options.lightEstimationPollInterval)
  134432. return;
  134433. this._lightEstimationPollTime = i
  134434. }
  134435. if (this._xrLightEstimate = e.getLightEstimate(this._xrLightProbe),
  134436. this._xrLightEstimate) {
  134437. this._intensity = Math.max(1, this._xrLightEstimate.primaryLightIntensity.x, this._xrLightEstimate.primaryLightIntensity.y, this._xrLightEstimate.primaryLightIntensity.z);
  134438. var n = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
  134439. this.options.disableVectorReuse && (this._lightDirection = new x,
  134440. this._lightColor = new D,
  134441. this.directionalLight && (this.directionalLight.direction = this._lightDirection,
  134442. this.directionalLight.diffuse = this._lightColor)),
  134443. this._lightDirection.copyFromFloats(this._xrLightEstimate.primaryLightDirection.x, this._xrLightEstimate.primaryLightDirection.y, this._xrLightEstimate.primaryLightDirection.z * n),
  134444. this._lightColor.copyFromFloats(this._xrLightEstimate.primaryLightIntensity.x / this._intensity, this._xrLightEstimate.primaryLightIntensity.y / this._intensity, this._xrLightEstimate.primaryLightIntensity.z / this._intensity),
  134445. this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients),
  134446. this._reflectionCubeMap && !this.options.disableSphericalPolynomial && (this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new Pc,
  134447. null === (t = this._reflectionCubeMap.sphericalPolynomial) || void 0 === t || t.updateFromHarmonics(this._sphericalHarmonics)),
  134448. this._lightDirection.negateInPlace(),
  134449. this.directionalLight && (this.directionalLight.direction.copyFrom(this._lightDirection),
  134450. this.directionalLight.intensity = Math.min(this._intensity, 1),
  134451. this.directionalLight.diffuse.copyFrom(this._lightColor))
  134452. }
  134453. }
  134454. }
  134455. ,
  134456. t.Name = Io.LIGHT_ESTIMATION,
  134457. t.Version = 1,
  134458. t
  134459. }(wp);
  134460. Oo.AddWebXRFeature(gE.Name, (function(e, t) {
  134461. return function() {
  134462. return new gE(e,t)
  134463. }
  134464. }
  134465. ), gE.Version, !1);
  134466. var vE = function(e) {
  134467. function t(t) {
  134468. var i = e.call(this, t) || this;
  134469. return i.onEyeTrackingStartedObservable = new h,
  134470. i.onEyeTrackingEndedObservable = new h,
  134471. i.onEyeTrackingFrameUpdateObservable = new h,
  134472. i._eyeTrackingStartListener = function(e) {
  134473. i._latestEyeSpace = e.gazeSpace,
  134474. i._gazeRay = new _o(x.Zero(),x.Forward()),
  134475. i.onEyeTrackingStartedObservable.notifyObservers(i._gazeRay)
  134476. }
  134477. ,
  134478. i._eyeTrackingEndListener = function() {
  134479. i._latestEyeSpace = null,
  134480. i._gazeRay = null,
  134481. i.onEyeTrackingEndedObservable.notifyObservers()
  134482. }
  134483. ,
  134484. i.xrNativeFeatureName = "eye-tracking",
  134485. i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function() {
  134486. i._init()
  134487. }
  134488. )),
  134489. i
  134490. }
  134491. return U(t, e),
  134492. t.prototype.dispose = function() {
  134493. e.prototype.dispose.call(this),
  134494. this._xrSessionManager.session.removeEventListener("eyetrackingstart", this._eyeTrackingStartListener),
  134495. this._xrSessionManager.session.removeEventListener("eyetrackingend", this._eyeTrackingEndListener),
  134496. this.onEyeTrackingStartedObservable.clear(),
  134497. this.onEyeTrackingEndedObservable.clear(),
  134498. this.onEyeTrackingFrameUpdateObservable.clear()
  134499. }
  134500. ,
  134501. Object.defineProperty(t.prototype, "isEyeGazeValid", {
  134502. get: function() {
  134503. return !!this._gazeRay
  134504. },
  134505. enumerable: !1,
  134506. configurable: !0
  134507. }),
  134508. t.prototype.getEyeGaze = function() {
  134509. return this._gazeRay
  134510. }
  134511. ,
  134512. t.prototype._onXRFrame = function(e) {
  134513. if (this.attached && e && this._latestEyeSpace && this._gazeRay) {
  134514. var t = e.getPose(this._latestEyeSpace, this._xrSessionManager.referenceSpace);
  134515. if (t) {
  134516. this._gazeRay.origin.set(t.transform.position.x, t.transform.position.y, t.transform.position.z);
  134517. var i = t.transform.orientation;
  134518. I.Quaternion[0].set(i.x, i.y, i.z, i.w),
  134519. this._xrSessionManager.scene.useRightHandedSystem ? x.RightHandedForwardReadOnly.rotateByQuaternionToRef(I.Quaternion[0], this._gazeRay.direction) : (this._gazeRay.origin.z *= -1,
  134520. I.Quaternion[0].z *= -1,
  134521. I.Quaternion[0].w *= -1,
  134522. x.LeftHandedForwardReadOnly.rotateByQuaternionToRef(I.Quaternion[0], this._gazeRay.direction)),
  134523. this.onEyeTrackingFrameUpdateObservable.notifyObservers(this._gazeRay)
  134524. }
  134525. }
  134526. }
  134527. ,
  134528. t.prototype._init = function() {
  134529. this._xrSessionManager.isNative && (this._xrSessionManager.session.addEventListener("eyetrackingstart", this._eyeTrackingStartListener),
  134530. this._xrSessionManager.session.addEventListener("eyetrackingend", this._eyeTrackingEndListener))
  134531. }
  134532. ,
  134533. t.Name = Io.EYE_TRACKING,
  134534. t.Version = 1,
  134535. t
  134536. }(wp);
  134537. Oo.AddWebXRFeature(vE.Name, (function(e) {
  134538. return function() {
  134539. return new vE(e)
  134540. }
  134541. }
  134542. ), vE.Version, !1);
  134543. var yE = function() {
  134544. function e(e, t) {
  134545. this._samples = [],
  134546. this._idx = 0;
  134547. for (var i = 0; i < e; ++i)
  134548. this._samples.push(t ? t() : A.Zero())
  134549. }
  134550. return Object.defineProperty(e.prototype, "length", {
  134551. get: function() {
  134552. return this._samples.length
  134553. },
  134554. enumerable: !1,
  134555. configurable: !0
  134556. }),
  134557. e.prototype.push = function(e, t) {
  134558. this._idx = (this._idx + this._samples.length - 1) % this._samples.length,
  134559. this.at(0).copyFromFloats(e, t)
  134560. }
  134561. ,
  134562. e.prototype.at = function(e) {
  134563. if (e >= this._samples.length)
  134564. throw new Error("Index out of bounds");
  134565. return this._samples[(this._idx + e) % this._samples.length]
  134566. }
  134567. ,
  134568. e
  134569. }()
  134570. , bE = function() {
  134571. function e() {
  134572. this._samples = new yE(20),
  134573. this._entropy = 0,
  134574. this.onFirstStepDetected = new h
  134575. }
  134576. return e.prototype.update = function(e, t, i, n) {
  134577. this._samples.push(e, t);
  134578. var r = this._samples.at(0);
  134579. if (this._entropy *= this._entropyDecayFactor,
  134580. this._entropy += A.Distance(r, this._samples.at(1)),
  134581. !(this._entropy > this._entropyThreshold)) {
  134582. var o;
  134583. for (o = this._samePointCheckStartIdx; o < this._samples.length && !(A.DistanceSquared(r, this._samples.at(o)) < this._samePointSquaredDistanceThreshold); ++o)
  134584. ;
  134585. if (o !== this._samples.length) {
  134586. for (var a = -1, s = 0, l = void 0, c = 1; c < o; ++c)
  134587. (l = A.DistanceSquared(r, this._samples.at(c))) > a && (s = c,
  134588. a = l);
  134589. if (!(a < this._apexSquaredDistanceThreshold)) {
  134590. var u = this._samples.at(s)
  134591. , h = u.subtract(r);
  134592. h.normalize();
  134593. var d, p = I.Vector2[0], f = 0;
  134594. for (c = 1; c < o; ++c)
  134595. this._samples.at(c).subtractToRef(r, p),
  134596. d = A.Dot(h, p),
  134597. f += p.lengthSquared() - d * d;
  134598. if (!(f > o * this._squaredProjectionDistanceThreshold)) {
  134599. var _ = I.Vector3[0];
  134600. _.set(i, n, 0);
  134601. var m = I.Vector3[1];
  134602. m.set(h.x, h.y, 0);
  134603. var g = x.Cross(_, m).z > 0
  134604. , v = r.clone()
  134605. , y = r.clone();
  134606. u.subtractToRef(r, h),
  134607. g ? (h.scaleAndAddToRef(this._axisToApexShrinkFactor, v),
  134608. h.scaleAndAddToRef(this._axisToApexExtendFactor, y)) : (h.scaleAndAddToRef(this._axisToApexExtendFactor, v),
  134609. h.scaleAndAddToRef(this._axisToApexShrinkFactor, y)),
  134610. this.onFirstStepDetected.notifyObservers({
  134611. leftApex: v,
  134612. rightApex: y,
  134613. currentPosition: r,
  134614. currentStepDirection: g ? "right" : "left"
  134615. })
  134616. }
  134617. }
  134618. }
  134619. }
  134620. }
  134621. ,
  134622. e.prototype.reset = function() {
  134623. for (var e = 0; e < this._samples.length; ++e)
  134624. this._samples.at(e).copyFromFloats(0, 0)
  134625. }
  134626. ,
  134627. Object.defineProperty(e.prototype, "_samePointCheckStartIdx", {
  134628. get: function() {
  134629. return Math.floor(this._samples.length / 3)
  134630. },
  134631. enumerable: !1,
  134632. configurable: !0
  134633. }),
  134634. Object.defineProperty(e.prototype, "_samePointSquaredDistanceThreshold", {
  134635. get: function() {
  134636. return 9e-4
  134637. },
  134638. enumerable: !1,
  134639. configurable: !0
  134640. }),
  134641. Object.defineProperty(e.prototype, "_apexSquaredDistanceThreshold", {
  134642. get: function() {
  134643. return .0081
  134644. },
  134645. enumerable: !1,
  134646. configurable: !0
  134647. }),
  134648. Object.defineProperty(e.prototype, "_squaredProjectionDistanceThreshold", {
  134649. get: function() {
  134650. return 9e-4
  134651. },
  134652. enumerable: !1,
  134653. configurable: !0
  134654. }),
  134655. Object.defineProperty(e.prototype, "_axisToApexShrinkFactor", {
  134656. get: function() {
  134657. return .8
  134658. },
  134659. enumerable: !1,
  134660. configurable: !0
  134661. }),
  134662. Object.defineProperty(e.prototype, "_axisToApexExtendFactor", {
  134663. get: function() {
  134664. return -1.6
  134665. },
  134666. enumerable: !1,
  134667. configurable: !0
  134668. }),
  134669. Object.defineProperty(e.prototype, "_entropyDecayFactor", {
  134670. get: function() {
  134671. return .93
  134672. },
  134673. enumerable: !1,
  134674. configurable: !0
  134675. }),
  134676. Object.defineProperty(e.prototype, "_entropyThreshold", {
  134677. get: function() {
  134678. return .4
  134679. },
  134680. enumerable: !1,
  134681. configurable: !0
  134682. }),
  134683. e
  134684. }()
  134685. , TE = function() {
  134686. function e(e, t, i, n) {
  134687. this._leftApex = new A,
  134688. this._rightApex = new A,
  134689. this._currentPosition = new A,
  134690. this._axis = new A,
  134691. this._axisLength = -1,
  134692. this._forward = new A,
  134693. this._steppingLeft = !1,
  134694. this._t = -1,
  134695. this._maxT = -1,
  134696. this._maxTPosition = new A,
  134697. this._vitality = 0,
  134698. this.onMovement = new h,
  134699. this.onFootfall = new h,
  134700. this._reset(e, t, i, "left" === n)
  134701. }
  134702. return e.prototype._reset = function(e, t, i, n) {
  134703. this._leftApex.copyFrom(e),
  134704. this._rightApex.copyFrom(t),
  134705. this._steppingLeft = n,
  134706. this._steppingLeft ? (this._leftApex.subtractToRef(this._rightApex, this._axis),
  134707. this._forward.copyFromFloats(-this._axis.y, this._axis.x)) : (this._rightApex.subtractToRef(this._leftApex, this._axis),
  134708. this._forward.copyFromFloats(this._axis.y, -this._axis.x)),
  134709. this._axisLength = this._axis.length(),
  134710. this._forward.scaleInPlace(1 / this._axisLength),
  134711. this._updateTAndVitality(i.x, i.y),
  134712. this._maxT = this._t,
  134713. this._maxTPosition.copyFrom(i),
  134714. this._vitality = 1
  134715. }
  134716. ,
  134717. e.prototype._updateTAndVitality = function(e, t) {
  134718. this._currentPosition.copyFromFloats(e, t),
  134719. this._steppingLeft ? this._currentPosition.subtractInPlace(this._rightApex) : this._currentPosition.subtractInPlace(this._leftApex);
  134720. var i = this._t
  134721. , n = A.Dot(this._currentPosition, this._axis);
  134722. this._t = n / (this._axisLength * this._axisLength);
  134723. var r = this._currentPosition.lengthSquared() - n / this._axisLength * (n / this._axisLength);
  134724. this._vitality *= .92 - 100 * Math.max(r - .0016, 0) + Math.max(this._t - i, 0)
  134725. }
  134726. ,
  134727. e.prototype.update = function(e, t) {
  134728. if (this._vitality < this._vitalityThreshold)
  134729. return !1;
  134730. var i = this._t;
  134731. return this._updateTAndVitality(e, t),
  134732. this._t > this._maxT && (this._maxT = this._t,
  134733. this._maxTPosition.copyFromFloats(e, t)),
  134734. !(this._vitality < this._vitalityThreshold || (this._t > i && (this.onMovement.notifyObservers({
  134735. deltaT: this._t - i
  134736. }),
  134737. i < .5 && this._t >= .5 && this.onFootfall.notifyObservers({
  134738. foot: this._steppingLeft ? "left" : "right"
  134739. })),
  134740. this._t < .95 * this._maxT && (this._currentPosition.copyFromFloats(e, t),
  134741. this._steppingLeft ? this._leftApex.copyFrom(this._maxTPosition) : this._rightApex.copyFrom(this._maxTPosition),
  134742. this._reset(this._leftApex, this._rightApex, this._currentPosition, !this._steppingLeft)),
  134743. this._axisLength < .03))
  134744. }
  134745. ,
  134746. Object.defineProperty(e.prototype, "_vitalityThreshold", {
  134747. get: function() {
  134748. return .1
  134749. },
  134750. enumerable: !1,
  134751. configurable: !0
  134752. }),
  134753. Object.defineProperty(e.prototype, "forward", {
  134754. get: function() {
  134755. return this._forward
  134756. },
  134757. enumerable: !1,
  134758. configurable: !0
  134759. }),
  134760. e
  134761. }()
  134762. , EE = function() {
  134763. function e(t) {
  134764. var i = this;
  134765. this._detector = new bE,
  134766. this._walker = null,
  134767. this._movement = new A,
  134768. this._millisecondsSinceLastUpdate = e._MillisecondsPerUpdate,
  134769. this.movementThisFrame = x.Zero(),
  134770. this._engine = t,
  134771. this._detector.onFirstStepDetected.add((function(e) {
  134772. i._walker || (i._walker = new TE(e.leftApex,e.rightApex,e.currentPosition,e.currentStepDirection),
  134773. i._walker.onFootfall.add((function() {
  134774. console.log("Footfall!")
  134775. }
  134776. )),
  134777. i._walker.onMovement.add((function(e) {
  134778. i._walker.forward.scaleAndAddToRef(.024 * e.deltaT, i._movement)
  134779. }
  134780. )))
  134781. }
  134782. ))
  134783. }
  134784. return Object.defineProperty(e, "_MillisecondsPerUpdate", {
  134785. get: function() {
  134786. return 1e3 / 15
  134787. },
  134788. enumerable: !1,
  134789. configurable: !0
  134790. }),
  134791. e.prototype.update = function(t, i) {
  134792. i.y = 0,
  134793. i.normalize(),
  134794. this._millisecondsSinceLastUpdate += this._engine.getDeltaTime(),
  134795. this._millisecondsSinceLastUpdate >= e._MillisecondsPerUpdate && (this._millisecondsSinceLastUpdate -= e._MillisecondsPerUpdate,
  134796. this._detector.update(t.x, t.z, i.x, i.z),
  134797. this._walker && (this._walker.update(t.x, t.z) || (this._walker = null)),
  134798. this._movement.scaleInPlace(.85)),
  134799. this.movementThisFrame.set(this._movement.x, 0, this._movement.y)
  134800. }
  134801. ,
  134802. e
  134803. }()
  134804. , SE = function(e) {
  134805. function t(t, i) {
  134806. var n = e.call(this, t) || this;
  134807. return n._up = new x,
  134808. n._forward = new x,
  134809. n._position = new x,
  134810. n._movement = new x,
  134811. n._sessionManager = t,
  134812. n.locomotionTarget = i.locomotionTarget,
  134813. n._isLocomotionTargetWebXRCamera && K.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"),
  134814. n
  134815. }
  134816. return U(t, e),
  134817. Object.defineProperty(t, "Name", {
  134818. get: function() {
  134819. return Io.WALKING_LOCOMOTION
  134820. },
  134821. enumerable: !1,
  134822. configurable: !0
  134823. }),
  134824. Object.defineProperty(t, "Version", {
  134825. get: function() {
  134826. return 1
  134827. },
  134828. enumerable: !1,
  134829. configurable: !0
  134830. }),
  134831. Object.defineProperty(t.prototype, "locomotionTarget", {
  134832. get: function() {
  134833. return this._locomotionTarget
  134834. },
  134835. set: function(e) {
  134836. this._locomotionTarget = e,
  134837. this._isLocomotionTargetWebXRCamera = "WebXRCamera" === this._locomotionTarget.getClassName()
  134838. },
  134839. enumerable: !1,
  134840. configurable: !0
  134841. }),
  134842. t.prototype.isCompatible = function() {
  134843. return void 0 === this._sessionManager.sessionMode || "immersive-vr" === this._sessionManager.sessionMode
  134844. }
  134845. ,
  134846. t.prototype.attach = function() {
  134847. return !(!this.isCompatible || !e.prototype.attach.call(this) || (this._walker = new EE(this._sessionManager.scene.getEngine()),
  134848. 0))
  134849. }
  134850. ,
  134851. t.prototype.detach = function() {
  134852. return !!e.prototype.detach.call(this) && (this._walker = null,
  134853. !0)
  134854. }
  134855. ,
  134856. t.prototype._onXRFrame = function(e) {
  134857. var t = e.getViewerPose(this._sessionManager.baseReferenceSpace);
  134858. if (t) {
  134859. var i = this.locomotionTarget.getScene().useRightHandedSystem ? 1 : -1
  134860. , n = t.transform.matrix;
  134861. this._up.copyFromFloats(n[4], n[5], i * n[6]),
  134862. this._forward.copyFromFloats(n[8], n[9], i * n[10]),
  134863. this._position.copyFromFloats(n[12], n[13], i * n[14]),
  134864. this._forward.scaleAndAddToRef(.05, this._position),
  134865. this._up.scaleAndAddToRef(-.05, this._position),
  134866. this._walker.update(this._position, this._forward),
  134867. this._movement.copyFrom(this._walker.movementThisFrame),
  134868. this._isLocomotionTargetWebXRCamera || x.TransformNormalToRef(this._movement, this.locomotionTarget.getWorldMatrix(), this._movement),
  134869. this.locomotionTarget.position.addInPlace(this._movement)
  134870. }
  134871. }
  134872. ,
  134873. t
  134874. }(wp);
  134875. Oo.AddWebXRFeature(SE.Name, (function(e, t) {
  134876. return function() {
  134877. return new SE(e,t)
  134878. }
  134879. }
  134880. ), SE.Version, !1);
  134881. var AE = function(e) {
  134882. function t(t, i, n, r, o, a) {
  134883. var s = e.call(this, t, i, n, r, a) || this;
  134884. return s.getWidth = t,
  134885. s.getHeight = i,
  134886. s.layer = n,
  134887. s.layerType = r,
  134888. s.isMultiview = o,
  134889. s.createRTTProvider = a,
  134890. s
  134891. }
  134892. return U(t, e),
  134893. t
  134894. }(ws)
  134895. , xE = function(e) {
  134896. function t(t, i, n) {
  134897. var r = e.call(this, t.scene, n) || this;
  134898. return r._xrSessionManager = t,
  134899. r._xrWebGLBinding = i,
  134900. r.layerWrapper = n,
  134901. r._lastSubImages = new Map,
  134902. r._compositionLayer = n.layer,
  134903. r
  134904. }
  134905. return U(t, e),
  134906. t.prototype._getRenderTargetForSubImage = function(e, t) {
  134907. var i = this._lastSubImages.get(t)
  134908. , n = "left" == t ? 0 : 1;
  134909. return this._renderTargetTextures[n] && (null == i ? void 0 : i.textureWidth) === e.textureWidth && (null == i ? void 0 : i.textureHeight) == e.textureHeight || (this._renderTargetTextures[n] = this._createRenderTargetTexture(e.textureWidth, e.textureHeight, null, e.colorTexture, e.depthStencilTexture, this.layerWrapper.isMultiview),
  134910. this._framebufferDimensions = {
  134911. framebufferWidth: e.textureWidth,
  134912. framebufferHeight: e.textureHeight
  134913. }),
  134914. this._lastSubImages.set(t, e),
  134915. this._renderTargetTextures[n]
  134916. }
  134917. ,
  134918. t.prototype._getSubImageForEye = function(e) {
  134919. var t = this._xrSessionManager.currentFrame;
  134920. return t ? this._xrWebGLBinding.getSubImage(this._compositionLayer, t, e) : null
  134921. }
  134922. ,
  134923. t.prototype.getRenderTargetTextureForEye = function(e) {
  134924. var t = this._getSubImageForEye(e);
  134925. return t ? this._getRenderTargetForSubImage(t, e) : null
  134926. }
  134927. ,
  134928. t.prototype.getRenderTargetTextureForView = function(e) {
  134929. return this.getRenderTargetTextureForEye(e.eye)
  134930. }
  134931. ,
  134932. t.prototype._setViewportForSubImage = function(e, t) {
  134933. var i = t.textureWidth
  134934. , n = t.textureHeight
  134935. , r = t.viewport;
  134936. e.x = r.x / i,
  134937. e.y = r.y / n,
  134938. e.width = r.width / i,
  134939. e.height = r.height / n
  134940. }
  134941. ,
  134942. t.prototype.trySetViewportForView = function(e, t) {
  134943. var i = this._lastSubImages.get(t.eye) || this._getSubImageForEye(t.eye);
  134944. return !!i && (this._setViewportForSubImage(e, i),
  134945. !0)
  134946. }
  134947. ,
  134948. t
  134949. }(Bs)
  134950. , RE = function(e) {
  134951. function t(t, i, n) {
  134952. var r = e.call(this, (function() {
  134953. return t.textureWidth
  134954. }
  134955. ), (function() {
  134956. return t.textureHeight
  134957. }
  134958. ), t, "XRProjectionLayer", i, (function(e) {
  134959. return new CE(e,n,r)
  134960. }
  134961. )) || this;
  134962. return r.layer = t,
  134963. r
  134964. }
  134965. return U(t, e),
  134966. t
  134967. }(AE)
  134968. , CE = function(e) {
  134969. function t(t, i, n) {
  134970. var r = e.call(this, t, i, n) || this;
  134971. return r.layerWrapper = n,
  134972. r._projectionLayer = n.layer,
  134973. r
  134974. }
  134975. return U(t, e),
  134976. t.prototype._getSubImageForView = function(e) {
  134977. return this._xrWebGLBinding.getViewSubImage(this._projectionLayer, e)
  134978. }
  134979. ,
  134980. t.prototype.getRenderTargetTextureForView = function(e) {
  134981. return this._getRenderTargetForSubImage(this._getSubImageForView(e), e.eye)
  134982. }
  134983. ,
  134984. t.prototype.getRenderTargetTextureForEye = function(e) {
  134985. var t = this._lastSubImages.get(e);
  134986. return t ? this._getRenderTargetForSubImage(t, e) : null
  134987. }
  134988. ,
  134989. t.prototype.trySetViewportForView = function(e, t) {
  134990. var i = this._lastSubImages.get(t.eye) || this._getSubImageForView(t);
  134991. return !!i && (this._setViewportForSubImage(e, i),
  134992. !0)
  134993. }
  134994. ,
  134995. t
  134996. }(xE)
  134997. , PE = {}
  134998. , ME = {
  134999. textureType: "texture",
  135000. colorFormat: 6408,
  135001. depthFormat: 35056,
  135002. scaleFactor: 1
  135003. }
  135004. , IE = function(e) {
  135005. function t(t, i) {
  135006. void 0 === i && (i = {});
  135007. var n = e.call(this, t) || this;
  135008. return n._options = i,
  135009. n._existingLayers = [],
  135010. n.xrNativeFeatureName = "layers",
  135011. n
  135012. }
  135013. return U(t, e),
  135014. t.prototype.attach = function() {
  135015. if (!e.prototype.attach.call(this))
  135016. return !1;
  135017. var t = this._xrSessionManager.scene.getEngine();
  135018. this._glContext = t._gl,
  135019. this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session,this._glContext),
  135020. this._existingLayers = [];
  135021. var i = V({}, ME)
  135022. , n = this._options.preferMultiviewOnInit && t.getCaps().multiview;
  135023. return n && (i.textureType = "texture-array"),
  135024. this.addXRSessionLayer(this.createProjectionLayer(i, n)),
  135025. !0
  135026. }
  135027. ,
  135028. t.prototype.detach = function() {
  135029. return !!e.prototype.detach.call(this) && (this._existingLayers.length = 0,
  135030. !0)
  135031. }
  135032. ,
  135033. t.prototype.createXRWebGLLayer = function(e) {
  135034. void 0 === e && (e = PE);
  135035. var t = new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);
  135036. return new Us(t)
  135037. }
  135038. ,
  135039. t.prototype.createProjectionLayer = function(e, t) {
  135040. if (void 0 === e && (e = ME),
  135041. void 0 === t && (t = !1),
  135042. t && "texture-array" !== e.textureType)
  135043. throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");
  135044. if (!t && "texture-array" === e.textureType)
  135045. throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.");
  135046. var i = this._xrWebGLBinding.createProjectionLayer(e);
  135047. return new RE(i,t,this._xrWebGLBinding)
  135048. }
  135049. ,
  135050. t.prototype.addXRSessionLayer = function(e) {
  135051. this.setXRSessionLayers(W(W([], this._existingLayers, !0), [e], !1))
  135052. }
  135053. ,
  135054. t.prototype.setXRSessionLayers = function(e) {
  135055. this._existingLayers = e;
  135056. var t = V({}, this._xrSessionManager.session.renderState);
  135057. t.baseLayer = void 0,
  135058. t.layers = e.map((function(e) {
  135059. return e.layer
  135060. }
  135061. )),
  135062. this._xrSessionManager.updateRenderState(t),
  135063. this._xrSessionManager._setBaseLayerWrapper(e.length > 0 ? e[0] : null)
  135064. }
  135065. ,
  135066. t.prototype.isCompatible = function() {
  135067. return !this._xrSessionManager.isNative && "undefined" != typeof XRWebGLBinding && !!XRWebGLBinding.prototype.createProjectionLayer
  135068. }
  135069. ,
  135070. t.prototype.dispose = function() {
  135071. e.prototype.dispose.call(this)
  135072. }
  135073. ,
  135074. t.prototype._onXRFrame = function(e) {}
  135075. ,
  135076. t.Name = Io.LAYERS,
  135077. t.Version = 1,
  135078. t
  135079. }(wp);
  135080. Oo.AddWebXRFeature(IE.Name, (function(e, t) {
  135081. return function() {
  135082. return new IE(e,t)
  135083. }
  135084. }
  135085. ), IE.Version, !1);
  135086. var OE = function(e) {
  135087. function t(t, i, n) {
  135088. var r = e.call(this, t, DE[n], i, n, !0) || this;
  135089. return r.profileId = "generic-hand-select-grasp",
  135090. r
  135091. }
  135092. return U(t, e),
  135093. t.prototype._getFilenameAndPath = function() {
  135094. return {
  135095. filename: "generic.babylon",
  135096. path: "https://controllers.babylonjs.com/generic/"
  135097. }
  135098. }
  135099. ,
  135100. t.prototype._getModelLoadingConstraints = function() {
  135101. return !0
  135102. }
  135103. ,
  135104. t.prototype._processLoadedModel = function(e) {}
  135105. ,
  135106. t.prototype._setRootMesh = function(e) {}
  135107. ,
  135108. t.prototype._updateModel = function() {}
  135109. ,
  135110. t
  135111. }(xp);
  135112. Ip.RegisterController("generic-hand-select-grasp", (function(e, t) {
  135113. return new OE(t,e.gamepad,e.handedness)
  135114. }
  135115. ));
  135116. var DE = {
  135117. left: {
  135118. selectComponentId: "xr-standard-trigger",
  135119. components: {
  135120. "xr-standard-trigger": {
  135121. type: "trigger",
  135122. gamepadIndices: {
  135123. button: 0
  135124. },
  135125. rootNodeName: "xr-standard-trigger",
  135126. visualResponses: {}
  135127. },
  135128. grasp: {
  135129. type: "trigger",
  135130. gamepadIndices: {
  135131. button: 4
  135132. },
  135133. rootNodeName: "grasp",
  135134. visualResponses: {}
  135135. }
  135136. },
  135137. gamepadMapping: "xr-standard",
  135138. rootNodeName: "generic-hand-select-grasp-left",
  135139. assetPath: "left.glb"
  135140. },
  135141. right: {
  135142. selectComponentId: "xr-standard-trigger",
  135143. components: {
  135144. "xr-standard-trigger": {
  135145. type: "trigger",
  135146. gamepadIndices: {
  135147. button: 0
  135148. },
  135149. rootNodeName: "xr-standard-trigger",
  135150. visualResponses: {}
  135151. },
  135152. grasp: {
  135153. type: "trigger",
  135154. gamepadIndices: {
  135155. button: 4
  135156. },
  135157. rootNodeName: "grasp",
  135158. visualResponses: {}
  135159. }
  135160. },
  135161. gamepadMapping: "xr-standard",
  135162. rootNodeName: "generic-hand-select-grasp-right",
  135163. assetPath: "right.glb"
  135164. },
  135165. none: {
  135166. selectComponentId: "xr-standard-trigger",
  135167. components: {
  135168. "xr-standard-trigger": {
  135169. type: "trigger",
  135170. gamepadIndices: {
  135171. button: 0
  135172. },
  135173. rootNodeName: "xr-standard-trigger",
  135174. visualResponses: {}
  135175. },
  135176. grasp: {
  135177. type: "trigger",
  135178. gamepadIndices: {
  135179. button: 4
  135180. },
  135181. rootNodeName: "grasp",
  135182. visualResponses: {}
  135183. }
  135184. },
  135185. gamepadMapping: "xr-standard",
  135186. rootNodeName: "generic-hand-select-grasp-none",
  135187. assetPath: "none.glb"
  135188. }
  135189. }
  135190. , NE = function(e) {
  135191. function t(t, i, n) {
  135192. var r = e.call(this, t, LE["left-right"], i, n) || this;
  135193. return r._mapping = {
  135194. defaultButton: {
  135195. valueNodeName: "VALUE",
  135196. unpressedNodeName: "UNPRESSED",
  135197. pressedNodeName: "PRESSED"
  135198. },
  135199. defaultAxis: {
  135200. valueNodeName: "VALUE",
  135201. minNodeName: "MIN",
  135202. maxNodeName: "MAX"
  135203. },
  135204. buttons: {
  135205. "xr-standard-trigger": {
  135206. rootNodeName: "SELECT",
  135207. componentProperty: "button",
  135208. states: ["default", "touched", "pressed"]
  135209. },
  135210. "xr-standard-squeeze": {
  135211. rootNodeName: "GRASP",
  135212. componentProperty: "state",
  135213. states: ["pressed"]
  135214. },
  135215. "xr-standard-touchpad": {
  135216. rootNodeName: "TOUCHPAD_PRESS",
  135217. labelAnchorNodeName: "squeeze-label",
  135218. touchPointNodeName: "TOUCH"
  135219. },
  135220. "xr-standard-thumbstick": {
  135221. rootNodeName: "THUMBSTICK_PRESS",
  135222. componentProperty: "state",
  135223. states: ["pressed"]
  135224. }
  135225. },
  135226. axes: {
  135227. "xr-standard-touchpad": {
  135228. "x-axis": {
  135229. rootNodeName: "TOUCHPAD_TOUCH_X"
  135230. },
  135231. "y-axis": {
  135232. rootNodeName: "TOUCHPAD_TOUCH_Y"
  135233. }
  135234. },
  135235. "xr-standard-thumbstick": {
  135236. "x-axis": {
  135237. rootNodeName: "THUMBSTICK_X"
  135238. },
  135239. "y-axis": {
  135240. rootNodeName: "THUMBSTICK_Y"
  135241. }
  135242. }
  135243. }
  135244. },
  135245. r.profileId = "microsoft-mixed-reality",
  135246. r
  135247. }
  135248. return U(t, e),
  135249. t.prototype._getFilenameAndPath = function() {
  135250. return {
  135251. filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
  135252. path: t.MODEL_BASE_URL + "default/"
  135253. }
  135254. }
  135255. ,
  135256. t.prototype._getModelLoadingConstraints = function() {
  135257. var e = od.IsPluginForExtensionAvailable(".glb");
  135258. return e || K.Warn("glTF / glb loaded was not registered, using generic controller instead"),
  135259. e
  135260. }
  135261. ,
  135262. t.prototype._processLoadedModel = function(e) {
  135263. var t = this;
  135264. this.rootMesh && (this.getComponentIds().forEach((function(e, i) {
  135265. if (!t.disableAnimation && e && t.rootMesh) {
  135266. var n = t._mapping.buttons[e]
  135267. , r = n.rootNodeName;
  135268. if (!r)
  135269. return void K.Log("Skipping unknown button at index: " + i + " with mapped name: " + e);
  135270. var o = t._getChildByName(t.rootMesh, r);
  135271. if (!o)
  135272. return void K.Warn("Missing button mesh with name: " + r);
  135273. if (n.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.valueNodeName),
  135274. n.pressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.pressedNodeName),
  135275. n.unpressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.unpressedNodeName),
  135276. n.valueMesh && n.pressedMesh && n.unpressedMesh) {
  135277. var a = t.getComponent(e);
  135278. a && a.onButtonStateChangedObservable.add((function(e) {
  135279. t._lerpTransform(n, e.value)
  135280. }
  135281. ), void 0, !0)
  135282. } else
  135283. K.Warn("Missing button submesh under mesh with name: " + r)
  135284. }
  135285. }
  135286. )),
  135287. this.getComponentIds().forEach((function(e) {
  135288. var i = t.getComponent(e);
  135289. i.isAxes() && ["x-axis", "y-axis"].forEach((function(n) {
  135290. if (t.rootMesh) {
  135291. var r = t._mapping.axes[e][n]
  135292. , o = t._getChildByName(t.rootMesh, r.rootNodeName);
  135293. o ? (r.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.valueNodeName),
  135294. r.minMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.minNodeName),
  135295. r.maxMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.maxNodeName),
  135296. r.valueMesh && r.minMesh && r.maxMesh ? i && i.onAxisValueChangedObservable.add((function(e) {
  135297. var i = "x-axis" === n ? e.x : e.y;
  135298. t._lerpTransform(r, i, !0)
  135299. }
  135300. ), void 0, !0) : K.Warn("Missing axis submesh under mesh with name: " + r.rootNodeName)) : K.Warn("Missing axis mesh with name: " + r.rootNodeName)
  135301. }
  135302. }
  135303. ))
  135304. }
  135305. )))
  135306. }
  135307. ,
  135308. t.prototype._setRootMesh = function(e) {
  135309. var t;
  135310. this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
  135311. this.rootMesh.isPickable = !1;
  135312. for (var i = 0; i < e.length; i++) {
  135313. var n = e[i];
  135314. n.isPickable = !1,
  135315. n.parent || (t = n)
  135316. }
  135317. t && t.setParent(this.rootMesh),
  135318. this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0))
  135319. }
  135320. ,
  135321. t.prototype._updateModel = function() {}
  135322. ,
  135323. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/",
  135324. t.MODEL_LEFT_FILENAME = "left.glb",
  135325. t.MODEL_RIGHT_FILENAME = "right.glb",
  135326. t
  135327. }(xp);
  135328. Ip.RegisterController("windows-mixed-reality", (function(e, t) {
  135329. return new NE(t,e.gamepad,e.handedness)
  135330. }
  135331. ));
  135332. var LE = {
  135333. left: {
  135334. selectComponentId: "xr-standard-trigger",
  135335. components: {
  135336. "xr-standard-trigger": {
  135337. type: "trigger",
  135338. gamepadIndices: {
  135339. button: 0
  135340. },
  135341. rootNodeName: "xr_standard_trigger",
  135342. visualResponses: {
  135343. xr_standard_trigger_pressed: {
  135344. componentProperty: "button",
  135345. states: ["default", "touched", "pressed"],
  135346. valueNodeProperty: "transform",
  135347. valueNodeName: "xr_standard_trigger_pressed_value",
  135348. minNodeName: "xr_standard_trigger_pressed_min",
  135349. maxNodeName: "xr_standard_trigger_pressed_max"
  135350. }
  135351. }
  135352. },
  135353. "xr-standard-squeeze": {
  135354. type: "squeeze",
  135355. gamepadIndices: {
  135356. button: 1
  135357. },
  135358. rootNodeName: "xr_standard_squeeze",
  135359. visualResponses: {
  135360. xr_standard_squeeze_pressed: {
  135361. componentProperty: "button",
  135362. states: ["default", "touched", "pressed"],
  135363. valueNodeProperty: "transform",
  135364. valueNodeName: "xr_standard_squeeze_pressed_value",
  135365. minNodeName: "xr_standard_squeeze_pressed_min",
  135366. maxNodeName: "xr_standard_squeeze_pressed_max"
  135367. }
  135368. }
  135369. },
  135370. "xr-standard-touchpad": {
  135371. type: "touchpad",
  135372. gamepadIndices: {
  135373. button: 2,
  135374. xAxis: 0,
  135375. yAxis: 1
  135376. },
  135377. rootNodeName: "xr_standard_touchpad",
  135378. visualResponses: {
  135379. xr_standard_touchpad_pressed: {
  135380. componentProperty: "button",
  135381. states: ["default", "touched", "pressed"],
  135382. valueNodeProperty: "transform",
  135383. valueNodeName: "xr_standard_touchpad_pressed_value",
  135384. minNodeName: "xr_standard_touchpad_pressed_min",
  135385. maxNodeName: "xr_standard_touchpad_pressed_max"
  135386. },
  135387. xr_standard_touchpad_xaxis_pressed: {
  135388. componentProperty: "xAxis",
  135389. states: ["default", "touched", "pressed"],
  135390. valueNodeProperty: "transform",
  135391. valueNodeName: "xr_standard_touchpad_xaxis_pressed_value",
  135392. minNodeName: "xr_standard_touchpad_xaxis_pressed_min",
  135393. maxNodeName: "xr_standard_touchpad_xaxis_pressed_max"
  135394. },
  135395. xr_standard_touchpad_yaxis_pressed: {
  135396. componentProperty: "yAxis",
  135397. states: ["default", "touched", "pressed"],
  135398. valueNodeProperty: "transform",
  135399. valueNodeName: "xr_standard_touchpad_yaxis_pressed_value",
  135400. minNodeName: "xr_standard_touchpad_yaxis_pressed_min",
  135401. maxNodeName: "xr_standard_touchpad_yaxis_pressed_max"
  135402. },
  135403. xr_standard_touchpad_xaxis_touched: {
  135404. componentProperty: "xAxis",
  135405. states: ["default", "touched", "pressed"],
  135406. valueNodeProperty: "transform",
  135407. valueNodeName: "xr_standard_touchpad_xaxis_touched_value",
  135408. minNodeName: "xr_standard_touchpad_xaxis_touched_min",
  135409. maxNodeName: "xr_standard_touchpad_xaxis_touched_max"
  135410. },
  135411. xr_standard_touchpad_yaxis_touched: {
  135412. componentProperty: "yAxis",
  135413. states: ["default", "touched", "pressed"],
  135414. valueNodeProperty: "transform",
  135415. valueNodeName: "xr_standard_touchpad_yaxis_touched_value",
  135416. minNodeName: "xr_standard_touchpad_yaxis_touched_min",
  135417. maxNodeName: "xr_standard_touchpad_yaxis_touched_max"
  135418. },
  135419. xr_standard_touchpad_axes_touched: {
  135420. componentProperty: "state",
  135421. states: ["touched", "pressed"],
  135422. valueNodeProperty: "visibility",
  135423. valueNodeName: "xr_standard_touchpad_axes_touched_value"
  135424. }
  135425. },
  135426. touchPointNodeName: "xr_standard_touchpad_axes_touched_value"
  135427. },
  135428. "xr-standard-thumbstick": {
  135429. type: "thumbstick",
  135430. gamepadIndices: {
  135431. button: 3,
  135432. xAxis: 2,
  135433. yAxis: 3
  135434. },
  135435. rootNodeName: "xr_standard_thumbstick",
  135436. visualResponses: {
  135437. xr_standard_thumbstick_pressed: {
  135438. componentProperty: "button",
  135439. states: ["default", "touched", "pressed"],
  135440. valueNodeProperty: "transform",
  135441. valueNodeName: "xr_standard_thumbstick_pressed_value",
  135442. minNodeName: "xr_standard_thumbstick_pressed_min",
  135443. maxNodeName: "xr_standard_thumbstick_pressed_max"
  135444. },
  135445. xr_standard_thumbstick_xaxis_pressed: {
  135446. componentProperty: "xAxis",
  135447. states: ["default", "touched", "pressed"],
  135448. valueNodeProperty: "transform",
  135449. valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value",
  135450. minNodeName: "xr_standard_thumbstick_xaxis_pressed_min",
  135451. maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max"
  135452. },
  135453. xr_standard_thumbstick_yaxis_pressed: {
  135454. componentProperty: "yAxis",
  135455. states: ["default", "touched", "pressed"],
  135456. valueNodeProperty: "transform",
  135457. valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value",
  135458. minNodeName: "xr_standard_thumbstick_yaxis_pressed_min",
  135459. maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max"
  135460. }
  135461. }
  135462. }
  135463. },
  135464. gamepadMapping: "xr-standard",
  135465. rootNodeName: "microsoft-mixed-reality-left",
  135466. assetPath: "left.glb"
  135467. },
  135468. right: {
  135469. selectComponentId: "xr-standard-trigger",
  135470. components: {
  135471. "xr-standard-trigger": {
  135472. type: "trigger",
  135473. gamepadIndices: {
  135474. button: 0
  135475. },
  135476. rootNodeName: "xr_standard_trigger",
  135477. visualResponses: {
  135478. xr_standard_trigger_pressed: {
  135479. componentProperty: "button",
  135480. states: ["default", "touched", "pressed"],
  135481. valueNodeProperty: "transform",
  135482. valueNodeName: "xr_standard_trigger_pressed_value",
  135483. minNodeName: "xr_standard_trigger_pressed_min",
  135484. maxNodeName: "xr_standard_trigger_pressed_max"
  135485. }
  135486. }
  135487. },
  135488. "xr-standard-squeeze": {
  135489. type: "squeeze",
  135490. gamepadIndices: {
  135491. button: 1
  135492. },
  135493. rootNodeName: "xr_standard_squeeze",
  135494. visualResponses: {
  135495. xr_standard_squeeze_pressed: {
  135496. componentProperty: "button",
  135497. states: ["default", "touched", "pressed"],
  135498. valueNodeProperty: "transform",
  135499. valueNodeName: "xr_standard_squeeze_pressed_value",
  135500. minNodeName: "xr_standard_squeeze_pressed_min",
  135501. maxNodeName: "xr_standard_squeeze_pressed_max"
  135502. }
  135503. }
  135504. },
  135505. "xr-standard-touchpad": {
  135506. type: "touchpad",
  135507. gamepadIndices: {
  135508. button: 2,
  135509. xAxis: 0,
  135510. yAxis: 1
  135511. },
  135512. rootNodeName: "xr_standard_touchpad",
  135513. visualResponses: {
  135514. xr_standard_touchpad_pressed: {
  135515. componentProperty: "button",
  135516. states: ["default", "touched", "pressed"],
  135517. valueNodeProperty: "transform",
  135518. valueNodeName: "xr_standard_touchpad_pressed_value",
  135519. minNodeName: "xr_standard_touchpad_pressed_min",
  135520. maxNodeName: "xr_standard_touchpad_pressed_max"
  135521. },
  135522. xr_standard_touchpad_xaxis_pressed: {
  135523. componentProperty: "xAxis",
  135524. states: ["default", "touched", "pressed"],
  135525. valueNodeProperty: "transform",
  135526. valueNodeName: "xr_standard_touchpad_xaxis_pressed_value",
  135527. minNodeName: "xr_standard_touchpad_xaxis_pressed_min",
  135528. maxNodeName: "xr_standard_touchpad_xaxis_pressed_max"
  135529. },
  135530. xr_standard_touchpad_yaxis_pressed: {
  135531. componentProperty: "yAxis",
  135532. states: ["default", "touched", "pressed"],
  135533. valueNodeProperty: "transform",
  135534. valueNodeName: "xr_standard_touchpad_yaxis_pressed_value",
  135535. minNodeName: "xr_standard_touchpad_yaxis_pressed_min",
  135536. maxNodeName: "xr_standard_touchpad_yaxis_pressed_max"
  135537. },
  135538. xr_standard_touchpad_xaxis_touched: {
  135539. componentProperty: "xAxis",
  135540. states: ["default", "touched", "pressed"],
  135541. valueNodeProperty: "transform",
  135542. valueNodeName: "xr_standard_touchpad_xaxis_touched_value",
  135543. minNodeName: "xr_standard_touchpad_xaxis_touched_min",
  135544. maxNodeName: "xr_standard_touchpad_xaxis_touched_max"
  135545. },
  135546. xr_standard_touchpad_yaxis_touched: {
  135547. componentProperty: "yAxis",
  135548. states: ["default", "touched", "pressed"],
  135549. valueNodeProperty: "transform",
  135550. valueNodeName: "xr_standard_touchpad_yaxis_touched_value",
  135551. minNodeName: "xr_standard_touchpad_yaxis_touched_min",
  135552. maxNodeName: "xr_standard_touchpad_yaxis_touched_max"
  135553. },
  135554. xr_standard_touchpad_axes_touched: {
  135555. componentProperty: "state",
  135556. states: ["touched", "pressed"],
  135557. valueNodeProperty: "visibility",
  135558. valueNodeName: "xr_standard_touchpad_axes_touched_value"
  135559. }
  135560. },
  135561. touchPointNodeName: "xr_standard_touchpad_axes_touched_value"
  135562. },
  135563. "xr-standard-thumbstick": {
  135564. type: "thumbstick",
  135565. gamepadIndices: {
  135566. button: 3,
  135567. xAxis: 2,
  135568. yAxis: 3
  135569. },
  135570. rootNodeName: "xr_standard_thumbstick",
  135571. visualResponses: {
  135572. xr_standard_thumbstick_pressed: {
  135573. componentProperty: "button",
  135574. states: ["default", "touched", "pressed"],
  135575. valueNodeProperty: "transform",
  135576. valueNodeName: "xr_standard_thumbstick_pressed_value",
  135577. minNodeName: "xr_standard_thumbstick_pressed_min",
  135578. maxNodeName: "xr_standard_thumbstick_pressed_max"
  135579. },
  135580. xr_standard_thumbstick_xaxis_pressed: {
  135581. componentProperty: "xAxis",
  135582. states: ["default", "touched", "pressed"],
  135583. valueNodeProperty: "transform",
  135584. valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value",
  135585. minNodeName: "xr_standard_thumbstick_xaxis_pressed_min",
  135586. maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max"
  135587. },
  135588. xr_standard_thumbstick_yaxis_pressed: {
  135589. componentProperty: "yAxis",
  135590. states: ["default", "touched", "pressed"],
  135591. valueNodeProperty: "transform",
  135592. valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value",
  135593. minNodeName: "xr_standard_thumbstick_yaxis_pressed_min",
  135594. maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max"
  135595. }
  135596. }
  135597. }
  135598. },
  135599. gamepadMapping: "xr-standard",
  135600. rootNodeName: "microsoft-mixed-reality-right",
  135601. assetPath: "right.glb"
  135602. }
  135603. }
  135604. , FE = function(e) {
  135605. function t(t, i, n, r, o) {
  135606. void 0 === r && (r = !1),
  135607. void 0 === o && (o = !1);
  135608. var a = e.call(this, t, wE[n], i, n) || this;
  135609. return a._forceLegacyControllers = o,
  135610. a.profileId = "oculus-touch",
  135611. a
  135612. }
  135613. return U(t, e),
  135614. t.prototype._getFilenameAndPath = function() {
  135615. return {
  135616. filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
  135617. path: this._isQuest() ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL
  135618. }
  135619. }
  135620. ,
  135621. t.prototype._getModelLoadingConstraints = function() {
  135622. return !0
  135623. }
  135624. ,
  135625. t.prototype._processLoadedModel = function(e) {
  135626. var t = this
  135627. , i = this._isQuest()
  135628. , n = "right" === this.handedness ? -1 : 1;
  135629. this.getComponentIds().forEach((function(e) {
  135630. var r = e && t.getComponent(e);
  135631. r && r.onButtonStateChangedObservable.add((function(r) {
  135632. if (t.rootMesh && !t.disableAnimation)
  135633. switch (e) {
  135634. case "xr-standard-trigger":
  135635. return void (i || (t._modelRootNode.getChildren()[3].rotation.x = .2 * -r.value,
  135636. t._modelRootNode.getChildren()[3].position.y = .005 * -r.value,
  135637. t._modelRootNode.getChildren()[3].position.z = .005 * -r.value));
  135638. case "xr-standard-squeeze":
  135639. return void (i || (t._modelRootNode.getChildren()[4].position.x = n * r.value * .0035));
  135640. case "xr-standard-thumbstick":
  135641. return;
  135642. case "a-button":
  135643. case "x-button":
  135644. return void (i || (r.pressed ? t._modelRootNode.getChildren()[1].position.y = -.001 : t._modelRootNode.getChildren()[1].position.y = 0));
  135645. case "b-button":
  135646. case "y-button":
  135647. return void (i || (r.pressed ? t._modelRootNode.getChildren()[2].position.y = -.001 : t._modelRootNode.getChildren()[2].position.y = 0))
  135648. }
  135649. }
  135650. ), void 0, !0)
  135651. }
  135652. ))
  135653. }
  135654. ,
  135655. t.prototype._setRootMesh = function(e) {
  135656. this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
  135657. this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)),
  135658. e.forEach((function(e) {
  135659. e.isPickable = !1
  135660. }
  135661. )),
  135662. this._isQuest() ? this._modelRootNode = e[0] : (this._modelRootNode = e[1],
  135663. this.rootMesh.position.y = .034,
  135664. this.rootMesh.position.z = .052),
  135665. this._modelRootNode.parent = this.rootMesh
  135666. }
  135667. ,
  135668. t.prototype._updateModel = function() {}
  135669. ,
  135670. t.prototype._isQuest = function() {
  135671. return !!navigator.userAgent.match(/Quest/gi) && !this._forceLegacyControllers
  135672. }
  135673. ,
  135674. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/",
  135675. t.MODEL_LEFT_FILENAME = "left.babylon",
  135676. t.MODEL_RIGHT_FILENAME = "right.babylon",
  135677. t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/",
  135678. t
  135679. }(xp);
  135680. Ip.RegisterController("oculus-touch", (function(e, t) {
  135681. return new FE(t,e.gamepad,e.handedness)
  135682. }
  135683. )),
  135684. Ip.RegisterController("oculus-touch-legacy", (function(e, t) {
  135685. return new FE(t,e.gamepad,e.handedness,!0)
  135686. }
  135687. ));
  135688. var wE = {
  135689. left: {
  135690. selectComponentId: "xr-standard-trigger",
  135691. components: {
  135692. "xr-standard-trigger": {
  135693. type: "trigger",
  135694. gamepadIndices: {
  135695. button: 0
  135696. },
  135697. rootNodeName: "xr_standard_trigger",
  135698. visualResponses: {}
  135699. },
  135700. "xr-standard-squeeze": {
  135701. type: "squeeze",
  135702. gamepadIndices: {
  135703. button: 1
  135704. },
  135705. rootNodeName: "xr_standard_squeeze",
  135706. visualResponses: {}
  135707. },
  135708. "xr-standard-thumbstick": {
  135709. type: "thumbstick",
  135710. gamepadIndices: {
  135711. button: 3,
  135712. xAxis: 2,
  135713. yAxis: 3
  135714. },
  135715. rootNodeName: "xr_standard_thumbstick",
  135716. visualResponses: {}
  135717. },
  135718. "x-button": {
  135719. type: "button",
  135720. gamepadIndices: {
  135721. button: 4
  135722. },
  135723. rootNodeName: "x_button",
  135724. visualResponses: {}
  135725. },
  135726. "y-button": {
  135727. type: "button",
  135728. gamepadIndices: {
  135729. button: 5
  135730. },
  135731. rootNodeName: "y_button",
  135732. visualResponses: {}
  135733. },
  135734. thumbrest: {
  135735. type: "button",
  135736. gamepadIndices: {
  135737. button: 6
  135738. },
  135739. rootNodeName: "thumbrest",
  135740. visualResponses: {}
  135741. }
  135742. },
  135743. gamepadMapping: "xr-standard",
  135744. rootNodeName: "oculus-touch-v2-left",
  135745. assetPath: "left.glb"
  135746. },
  135747. right: {
  135748. selectComponentId: "xr-standard-trigger",
  135749. components: {
  135750. "xr-standard-trigger": {
  135751. type: "trigger",
  135752. gamepadIndices: {
  135753. button: 0
  135754. },
  135755. rootNodeName: "xr_standard_trigger",
  135756. visualResponses: {}
  135757. },
  135758. "xr-standard-squeeze": {
  135759. type: "squeeze",
  135760. gamepadIndices: {
  135761. button: 1
  135762. },
  135763. rootNodeName: "xr_standard_squeeze",
  135764. visualResponses: {}
  135765. },
  135766. "xr-standard-thumbstick": {
  135767. type: "thumbstick",
  135768. gamepadIndices: {
  135769. button: 3,
  135770. xAxis: 2,
  135771. yAxis: 3
  135772. },
  135773. rootNodeName: "xr_standard_thumbstick",
  135774. visualResponses: {}
  135775. },
  135776. "a-button": {
  135777. type: "button",
  135778. gamepadIndices: {
  135779. button: 4
  135780. },
  135781. rootNodeName: "a_button",
  135782. visualResponses: {}
  135783. },
  135784. "b-button": {
  135785. type: "button",
  135786. gamepadIndices: {
  135787. button: 5
  135788. },
  135789. rootNodeName: "b_button",
  135790. visualResponses: {}
  135791. },
  135792. thumbrest: {
  135793. type: "button",
  135794. gamepadIndices: {
  135795. button: 6
  135796. },
  135797. rootNodeName: "thumbrest",
  135798. visualResponses: {}
  135799. }
  135800. },
  135801. gamepadMapping: "xr-standard",
  135802. rootNodeName: "oculus-touch-v2-right",
  135803. assetPath: "right.glb"
  135804. }
  135805. }
  135806. , BE = function(e) {
  135807. function t(t, i, n) {
  135808. var r = e.call(this, t, UE[n], i, n) || this;
  135809. return r.profileId = "htc-vive",
  135810. r
  135811. }
  135812. return U(t, e),
  135813. t.prototype._getFilenameAndPath = function() {
  135814. return {
  135815. filename: t.MODEL_FILENAME,
  135816. path: t.MODEL_BASE_URL
  135817. }
  135818. }
  135819. ,
  135820. t.prototype._getModelLoadingConstraints = function() {
  135821. return !0
  135822. }
  135823. ,
  135824. t.prototype._processLoadedModel = function(e) {
  135825. var t = this;
  135826. this.getComponentIds().forEach((function(e) {
  135827. var i = e && t.getComponent(e);
  135828. i && i.onButtonStateChangedObservable.add((function(i) {
  135829. if (t.rootMesh && !t.disableAnimation)
  135830. switch (e) {
  135831. case "xr-standard-trigger":
  135832. return void (t._modelRootNode.getChildren()[6].rotation.x = .15 * -i.value);
  135833. case "xr-standard-touchpad":
  135834. case "xr-standard-squeeze":
  135835. return
  135836. }
  135837. }
  135838. ), void 0, !0)
  135839. }
  135840. ))
  135841. }
  135842. ,
  135843. t.prototype._setRootMesh = function(e) {
  135844. this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
  135845. e.forEach((function(e) {
  135846. e.isPickable = !1
  135847. }
  135848. )),
  135849. this._modelRootNode = e[1],
  135850. this._modelRootNode.parent = this.rootMesh,
  135851. this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0))
  135852. }
  135853. ,
  135854. t.prototype._updateModel = function() {}
  135855. ,
  135856. t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/",
  135857. t.MODEL_FILENAME = "wand.babylon",
  135858. t
  135859. }(xp);
  135860. Ip.RegisterController("htc-vive", (function(e, t) {
  135861. return new BE(t,e.gamepad,e.handedness)
  135862. }
  135863. ));
  135864. var UE = {
  135865. left: {
  135866. selectComponentId: "xr-standard-trigger",
  135867. components: {
  135868. "xr-standard-trigger": {
  135869. type: "trigger",
  135870. gamepadIndices: {
  135871. button: 0
  135872. },
  135873. rootNodeName: "xr_standard_trigger",
  135874. visualResponses: {}
  135875. },
  135876. "xr-standard-squeeze": {
  135877. type: "squeeze",
  135878. gamepadIndices: {
  135879. button: 1
  135880. },
  135881. rootNodeName: "xr_standard_squeeze",
  135882. visualResponses: {}
  135883. },
  135884. "xr-standard-touchpad": {
  135885. type: "touchpad",
  135886. gamepadIndices: {
  135887. button: 2,
  135888. xAxis: 0,
  135889. yAxis: 1
  135890. },
  135891. rootNodeName: "xr_standard_touchpad",
  135892. visualResponses: {}
  135893. },
  135894. menu: {
  135895. type: "button",
  135896. gamepadIndices: {
  135897. button: 4
  135898. },
  135899. rootNodeName: "menu",
  135900. visualResponses: {}
  135901. }
  135902. },
  135903. gamepadMapping: "xr-standard",
  135904. rootNodeName: "htc_vive_none",
  135905. assetPath: "none.glb"
  135906. },
  135907. right: {
  135908. selectComponentId: "xr-standard-trigger",
  135909. components: {
  135910. "xr-standard-trigger": {
  135911. type: "trigger",
  135912. gamepadIndices: {
  135913. button: 0
  135914. },
  135915. rootNodeName: "xr_standard_trigger",
  135916. visualResponses: {}
  135917. },
  135918. "xr-standard-squeeze": {
  135919. type: "squeeze",
  135920. gamepadIndices: {
  135921. button: 1
  135922. },
  135923. rootNodeName: "xr_standard_squeeze",
  135924. visualResponses: {}
  135925. },
  135926. "xr-standard-touchpad": {
  135927. type: "touchpad",
  135928. gamepadIndices: {
  135929. button: 2,
  135930. xAxis: 0,
  135931. yAxis: 1
  135932. },
  135933. rootNodeName: "xr_standard_touchpad",
  135934. visualResponses: {}
  135935. },
  135936. menu: {
  135937. type: "button",
  135938. gamepadIndices: {
  135939. button: 4
  135940. },
  135941. rootNodeName: "menu",
  135942. visualResponses: {}
  135943. }
  135944. },
  135945. gamepadMapping: "xr-standard",
  135946. rootNodeName: "htc_vive_none",
  135947. assetPath: "none.glb"
  135948. },
  135949. none: {
  135950. selectComponentId: "xr-standard-trigger",
  135951. components: {
  135952. "xr-standard-trigger": {
  135953. type: "trigger",
  135954. gamepadIndices: {
  135955. button: 0
  135956. },
  135957. rootNodeName: "xr_standard_trigger",
  135958. visualResponses: {}
  135959. },
  135960. "xr-standard-squeeze": {
  135961. type: "squeeze",
  135962. gamepadIndices: {
  135963. button: 1
  135964. },
  135965. rootNodeName: "xr_standard_squeeze",
  135966. visualResponses: {}
  135967. },
  135968. "xr-standard-touchpad": {
  135969. type: "touchpad",
  135970. gamepadIndices: {
  135971. button: 2,
  135972. xAxis: 0,
  135973. yAxis: 1
  135974. },
  135975. rootNodeName: "xr_standard_touchpad",
  135976. visualResponses: {}
  135977. },
  135978. menu: {
  135979. type: "button",
  135980. gamepadIndices: {
  135981. button: 4
  135982. },
  135983. rootNodeName: "menu",
  135984. visualResponses: {}
  135985. }
  135986. },
  135987. gamepadMapping: "xr-standard",
  135988. rootNodeName: "htc-vive-none",
  135989. assetPath: "none.glb"
  135990. }
  135991. }
  135992. , VE = function() {
  135993. function e(e) {
  135994. this._nativeImpl = e,
  135995. this._xrTransform = new XRRigidTransform,
  135996. this._xrPose = {
  135997. transform: this._xrTransform,
  135998. emulatedPosition: !1
  135999. },
  136000. this._xrPoseVectorData = new Float32Array(8),
  136001. this.fillPoses = this._nativeImpl.fillPoses.bind(this._nativeImpl),
  136002. this.getViewerPose = this._nativeImpl.getViewerPose.bind(this._nativeImpl),
  136003. this.getHitTestResults = this._nativeImpl.getHitTestResults.bind(this._nativeImpl),
  136004. this.getHitTestResultsForTransientInput = function() {
  136005. throw new Error("XRFrame.getHitTestResultsForTransientInput not supported on native.")
  136006. }
  136007. ,
  136008. this.createAnchor = this._nativeImpl.createAnchor.bind(this._nativeImpl),
  136009. this.getJointPose = this._nativeImpl.getJointPose.bind(this._nativeImpl),
  136010. this.fillJointRadii = this._nativeImpl.fillJointRadii.bind(this._nativeImpl),
  136011. this.getLightEstimate = function() {
  136012. throw new Error("XRFrame.getLightEstimate not supported on native.")
  136013. }
  136014. ,
  136015. this.getImageTrackingResults = this._nativeImpl.getImageTrackingResults.bind(this._nativeImpl)
  136016. }
  136017. return Object.defineProperty(e.prototype, "session", {
  136018. get: function() {
  136019. return this._nativeImpl.session
  136020. },
  136021. enumerable: !1,
  136022. configurable: !0
  136023. }),
  136024. e.prototype.getPose = function(e, t) {
  136025. if (this._nativeImpl.getPoseData(e, t, this._xrPoseVectorData.buffer, this._xrTransform.matrix.buffer)) {
  136026. var i = this._xrTransform.position;
  136027. i.x = this._xrPoseVectorData[0],
  136028. i.y = this._xrPoseVectorData[1],
  136029. i.z = this._xrPoseVectorData[2],
  136030. i.w = this._xrPoseVectorData[3];
  136031. var n = this._xrTransform.orientation;
  136032. return n.x = this._xrPoseVectorData[4],
  136033. n.y = this._xrPoseVectorData[5],
  136034. n.z = this._xrPoseVectorData[6],
  136035. n.w = this._xrPoseVectorData[7],
  136036. this._xrPose
  136037. }
  136038. }
  136039. ,
  136040. Object.defineProperty(e.prototype, "trackedAnchors", {
  136041. get: function() {
  136042. return this._nativeImpl.trackedAnchors
  136043. },
  136044. enumerable: !1,
  136045. configurable: !0
  136046. }),
  136047. Object.defineProperty(e.prototype, "worldInformation", {
  136048. get: function() {
  136049. return this._nativeImpl.worldInformation
  136050. },
  136051. enumerable: !1,
  136052. configurable: !0
  136053. }),
  136054. Object.defineProperty(e.prototype, "detectedPlanes", {
  136055. get: function() {
  136056. return this._nativeImpl.detectedPlanes
  136057. },
  136058. enumerable: !1,
  136059. configurable: !0
  136060. }),
  136061. Object.defineProperty(e.prototype, "featurePointCloud", {
  136062. get: function() {
  136063. return this._nativeImpl.featurePointCloud
  136064. },
  136065. enumerable: !1,
  136066. configurable: !0
  136067. }),
  136068. e
  136069. }();
  136070. ou("NativeXRFrame", VE);
  136071. var kE = void 0 !== e.g ? e.g : "undefined" != typeof window ? window : void 0;
  136072. if (void 0 !== kE) {
  136073. kE.BABYLON = kE.BABYLON || {};
  136074. var GE = kE.BABYLON;
  136075. GE.Debug = GE.Debug || {};
  136076. var zE = [];
  136077. for (var WE in i)
  136078. GE.Debug[WE] = i[WE],
  136079. zE.push(WE);
  136080. for (var WE in n)
  136081. GE[WE] = n[WE]
  136082. }
  136083. var HE = {
  136084. AxesViewer: xl,
  136085. BoneAxesViewer: Rl,
  136086. PhysicsViewer: Wl,
  136087. SkeletonViewer: cc
  136088. };
  136089. const XE = r;
  136090. return t.default
  136091. }
  136092. )()
  136093. }
  136094. ));
  136095. //# sourceMappingURL=babylon.js.map